Add analyzer to enforce use of PooledArrayBuilder<T>.AsRef() with using statements

This commit is contained in:
Dustin Campbell 2023-09-18 16:54:53 -07:00
Родитель 5c23c92314
Коммит 1b5601b343
37 изменённых файлов: 881 добавлений и 1 удалений

Просмотреть файл

@ -46,6 +46,8 @@
"src\\Razor\\test\\Microsoft.VisualStudio.LiveShare.Razor.Test\\Microsoft.VisualStudio.LiveShare.Razor.Test.csproj",
"src\\Shared\\Microsoft.AspNetCore.Razor.Utilities.Shared.Test\\Microsoft.AspNetCore.Razor.Utilities.Shared.Test.csproj",
"src\\Shared\\Microsoft.AspNetCore.Razor.Utilities.Shared\\Microsoft.AspNetCore.Razor.Utilities.Shared.csproj"
"src\\Shared\\Razor.Diagnostics.Analyzers\\Razor.Diagnostics.Analyzers.csproj",
"src\\Shared\\Razor.Diagnostics.Analyzers.Test\\Razor.Diagnostics.Analyzers.Test.csproj",
]
}
}

Просмотреть файл

@ -173,6 +173,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Razor.Utilities.Shared", "src\Shared\Microsoft.AspNetCore.Razor.Utilities.Shared\Microsoft.AspNetCore.Razor.Utilities.Shared.csproj", "{BAFE178B-7AD4-41AE-A75D-9B920B9EA050}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Razor.Diagnostics.Analyzers", "src\Shared\Razor.Diagnostics.Analyzers\Razor.Diagnostics.Analyzers.csproj", "{7E1535D1-1896-406D-A58C-E734FBA482FE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Razor.Diagnostics.Analyzers.Test", "src\Shared\Razor.Diagnostics.Analyzers.Test\Razor.Diagnostics.Analyzers.Test.csproj", "{66744CCD-2F35-494F-9A1C-8FC3CE1EF729}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -717,6 +721,22 @@ Global
{BAFE178B-7AD4-41AE-A75D-9B920B9EA050}.Release|Any CPU.Build.0 = Release|Any CPU
{BAFE178B-7AD4-41AE-A75D-9B920B9EA050}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{BAFE178B-7AD4-41AE-A75D-9B920B9EA050}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{7E1535D1-1896-406D-A58C-E734FBA482FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E1535D1-1896-406D-A58C-E734FBA482FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E1535D1-1896-406D-A58C-E734FBA482FE}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{7E1535D1-1896-406D-A58C-E734FBA482FE}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{7E1535D1-1896-406D-A58C-E734FBA482FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E1535D1-1896-406D-A58C-E734FBA482FE}.Release|Any CPU.Build.0 = Release|Any CPU
{7E1535D1-1896-406D-A58C-E734FBA482FE}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{7E1535D1-1896-406D-A58C-E734FBA482FE}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
{66744CCD-2F35-494F-9A1C-8FC3CE1EF729}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66744CCD-2F35-494F-9A1C-8FC3CE1EF729}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66744CCD-2F35-494F-9A1C-8FC3CE1EF729}.DebugNoVSIX|Any CPU.ActiveCfg = Debug|Any CPU
{66744CCD-2F35-494F-9A1C-8FC3CE1EF729}.DebugNoVSIX|Any CPU.Build.0 = Debug|Any CPU
{66744CCD-2F35-494F-9A1C-8FC3CE1EF729}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66744CCD-2F35-494F-9A1C-8FC3CE1EF729}.Release|Any CPU.Build.0 = Release|Any CPU
{66744CCD-2F35-494F-9A1C-8FC3CE1EF729}.ReleaseNoVSIX|Any CPU.ActiveCfg = Release|Any CPU
{66744CCD-2F35-494F-9A1C-8FC3CE1EF729}.ReleaseNoVSIX|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -796,6 +816,8 @@ Global
{4126E0A6-1CA9-44B1-AD22-66EDB9FEE7AD} = {92463391-81BE-462B-AC3C-78C6C760741F}
{7275F376-1B63-49D3-8078-0F7CA15CC637} = {3AE210D1-C435-4693-BF79-2EF13ED554B9}
{BAFE178B-7AD4-41AE-A75D-9B920B9EA050} = {3AE210D1-C435-4693-BF79-2EF13ED554B9}
{7E1535D1-1896-406D-A58C-E734FBA482FE} = {3AE210D1-C435-4693-BF79-2EF13ED554B9}
{66744CCD-2F35-494F-9A1C-8FC3CE1EF729} = {3AE210D1-C435-4693-BF79-2EF13ED554B9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0035341D-175A-4D05-95E6-F1C2785A1E26}

Просмотреть файл

@ -71,6 +71,8 @@
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.8.0-1.23415.13</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.8.0-1.23415.13</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.8.0-1.23415.13</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
<MicrosoftCodeAnalysisCSharpAnalyzerTestingXUnitPackageVersion>1.1.2-beta1.23431.1</MicrosoftCodeAnalysisCSharpAnalyzerTestingXUnitPackageVersion>
<MicrosoftCodeAnalysisTestingVerifiersXUnitPackageVersion>1.1.2-beta1.23431.1</MicrosoftCodeAnalysisTestingVerifiersXUnitPackageVersion>
<MicrosoftVisualStudioLanguageServicesPackageVersion>4.8.0-1.23415.13</MicrosoftVisualStudioLanguageServicesPackageVersion>
<MicrosoftDotNetXliffTasksPackageVersion>1.0.0-beta.23426.1</MicrosoftDotNetXliffTasksPackageVersion>
<!--

Просмотреть файл

@ -40,5 +40,10 @@
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" NoWarn="NU1608" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" PrivateAssets="All" />
<PackageReference Include="Roslyn.Diagnostics.Analyzers" PrivateAssets="All" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\Shared\Razor.Diagnostics.Analyzers\Razor.Diagnostics.Analyzers.csproj"
PrivateAssets="all"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer" />
</ItemGroup>
</Project>

Просмотреть файл

@ -7,6 +7,11 @@
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="$(Tooling_MicrosoftCodeAnalysisAnalyzersPackageVersion)" NoWarn="NU1608" />
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="$(Tooling_MicrosoftCodeAnalysisBannedApiAnalyzersPackageVersion)" />
<PackageReference Include="Roslyn.Diagnostics.Analyzers" Version="$(Tooling_RoslynDiagnosticsAnalyzersPackageVersion)" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\Shared\Razor.Diagnostics.Analyzers\Razor.Diagnostics.Analyzers.csproj"
PrivateAssets="all"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer" />
</ItemGroup>
</Project>

Просмотреть файл

@ -299,6 +299,7 @@
<ItemGroup>
<BindingRedirectAssemblies Include="@(ProjectReference)" AssemblyName="%(Filename)" />
<BindingRedirectAssemblies Remove="@(ProjectReference)" Condition="%(ProjectReference.Name) == 'Microsoft.CodeAnalysis.Remote.Razor.CoreComponents'" />
<BindingRedirectAssemblies Remove="@(ProjectReference)" Condition="%(ProjectReference.ReferenceOutputAssembly) == 'false'" />
<BindingRedirectAssemblies Include="$(AssemblyName)" AssemblyName="$(AssemblyName)" />
</ItemGroup>
<PropertyGroup>

Просмотреть файл

@ -18,6 +18,12 @@
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="$(Tooling_MicrosoftCodeAnalysisAnalyzersPackageVersion)" NoWarn="NU1608" />
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="$(Tooling_MicrosoftCodeAnalysisBannedApiAnalyzersPackageVersion)" />
<PackageReference Include="Roslyn.Diagnostics.Analyzers" Version="$(Tooling_RoslynDiagnosticsAnalyzersPackageVersion)" />
<ProjectReference Condition="'$(ProjectName)' != 'Razor.Diagnostics.Analyzers' AND '$(ProjectName)' != 'Razor.Diagnostics.Analyzers.Test'"
Include="$(MSBuildThisFileDirectory)..\Shared\Razor.Diagnostics.Analyzers\Razor.Diagnostics.Analyzers.csproj"
PrivateAssets="all"
ReferenceOutputAssembly="false"
OutputItemType="Analyzer" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,12 +1,37 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Runtime.CompilerServices;
namespace Microsoft.AspNetCore.Razor.PooledObjects;
internal static class PooledArrayBuilderExtensions
{
/// <summary>
/// Gets a mutable reference to a <see cref="PooledArrayBuilder{T}"/> stored in a <c>using</c> variable.
/// </summary>
/// <remarks>
/// <para>This supporting method allows <see cref="PooledArrayBuilder{T}"/>, a non-copyable <see langword="struct"/>
/// implementing <see cref="IDisposable"/>, to be used with <c>using</c> statements while still allowing them to
/// be passed by reference in calls. The following two calls are equivalent:</para>
///
/// <code>
/// using var array = PooledArrayBuilder&lt;T&gt;.Empty;
///
/// // Using the 'Unsafe.AsRef' method
/// Method(ref Unsafe.AsRef(in builder));
///
/// // Using this helper method
/// Method(ref builder.AsRef());
/// </code>
///
/// <para>⚠ Do not move or rename this method without updating the corresponding
/// Razor.Diagnostics.Analyzers\PooledArrayBuilderAsRefAnalyzer.cs.</para>
/// </remarks>
/// <typeparam name="T">The type of element stored in the pooled array builder.</typeparam>
/// <param name="builder">A read-only reference to a pooled array builder which is part of a <c>using</c> statement.</param>
/// <returns>A mutable reference to the pooled array builder.</returns>
public static ref PooledArrayBuilder<T> AsRef<T>(this in PooledArrayBuilder<T> builder)
=> ref Unsafe.AsRef(in builder);
}

Просмотреть файл

@ -227,7 +227,7 @@ internal partial struct PooledArrayBuilder<T> : IDisposable
if (!items.TryGetCount(out var count))
{
// We can't retrieve a count, so we have to enumerate the elements.
AddRangeSlow(ref this.AsRef(), items);
AddRangeSlow(ref this, items);
return;
}

Просмотреть файл

@ -6,6 +6,10 @@ using System.Runtime.CompilerServices;
// Razor shared utilities test assemblies
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Utilities.Shared.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
// Razor analyzers
[assembly: InternalsVisibleTo("Razor.Diagnostics.Analyzers, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Razor.Diagnostics.Analyzers.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
// Razor compiler assemblies
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.Language, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

Просмотреть файл

@ -0,0 +1,104 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Xunit;
namespace Razor.Diagnostics.Analyzers.Test;
using VerifyCS = CSharpAnalyzerVerifier<PooledArrayBuilderAsRefAnalyzer>;
public class PooledArrayBuilderAsRefAnalyzerTests
{
private const string PooledArrayBuilderSource = """
namespace Microsoft.AspNetCore.Razor.PooledObjects
{
internal struct PooledArrayBuilder<T> : System.IDisposable
{
public void Dispose() { }
}
internal static class PooledArrayBuilderExtensions
{
public static ref PooledArrayBuilder<T> AsRef<T>(this in PooledArrayBuilder<T> array) => throw null;
}
}
""";
[Fact]
public async Task TestUsingVariable_CSharpAsync()
{
var code = $$"""
using Microsoft.AspNetCore.Razor.PooledObjects;
class C
{
void Method()
{
using (var array = new PooledArrayBuilder<int>())
{
ref var arrayRef1 = ref array.AsRef();
ref var arrayRef2 = ref PooledArrayBuilderExtensions.AsRef(in array);
}
}
}
{{PooledArrayBuilderSource}}
""";
await new VerifyCS.Test
{
TestCode = code,
}.RunAsync();
}
[Fact]
public async Task TestUsingDeclarationVariable_CSharpAsync()
{
var code = $$"""
using Microsoft.AspNetCore.Razor.PooledObjects;
class C
{
void Method()
{
using var array = new PooledArrayBuilder<int>();
ref var arrayRef1 = ref array.AsRef();
ref var arrayRef2 = ref PooledArrayBuilderExtensions.AsRef(in array);
}
}
{{PooledArrayBuilderSource}}
""";
await new VerifyCS.Test
{
TestCode = code,
}.RunAsync();
}
[Fact]
public async Task TestNonUsingVariable_CSharpAsync()
{
var code = $$"""
using Microsoft.AspNetCore.Razor.PooledObjects;
class C
{
void Method()
{
var array = new PooledArrayBuilder<int>();
ref var arrayRef1 = ref [|array.AsRef()|];
ref var arrayRef2 = ref [|PooledArrayBuilderExtensions.AsRef(in array)|];
}
}
{{PooledArrayBuilderSource}}
""";
await new VerifyCS.Test
{
TestCode = code,
}.RunAsync();
}
}

Просмотреть файл

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(DefaultNetCoreTargetFrameworks);$(DefaultNetFxTargetFramework)</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);$(DefaultNetFxTargetFramework)</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing.XUnit" Version="$(MicrosoftCodeAnalysisCSharpAnalyzerTestingXUnitPackageVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.Testing.Verifiers.XUnit" Version="$(MicrosoftCodeAnalysisTestingVerifiersXUnitPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Utilities.Shared\Microsoft.AspNetCore.Razor.Utilities.Shared.csproj" />
<ProjectReference Include="..\Razor.Diagnostics.Analyzers\Razor.Diagnostics.Analyzers.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,29 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Razor;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Testing.Verifiers;
namespace Razor.Diagnostics.Analyzers.Test;
public static partial class CSharpAnalyzerVerifier<TAnalyzer>
where TAnalyzer : DiagnosticAnalyzer, new()
{
public class Test : CSharpAnalyzerTest<TAnalyzer, XUnitVerifier>
{
public Test()
{
SolutionTransforms.Add((solution, projectId) =>
{
var compilationOptions = solution.GetProject(projectId).AssumeNotNull().CompilationOptions;
compilationOptions = compilationOptions.AssumeNotNull().WithSpecificDiagnosticOptions(
compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings));
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions);
return solution;
});
}
}
}

Просмотреть файл

@ -0,0 +1,40 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Testing.Verifiers;
namespace Razor.Diagnostics.Analyzers.Test;
public static partial class CSharpAnalyzerVerifier<TAnalyzer>
where TAnalyzer : DiagnosticAnalyzer, new()
{
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic()"/>
public static DiagnosticResult Diagnostic()
=> CSharpAnalyzerVerifier<TAnalyzer, XUnitVerifier>.Diagnostic();
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic(string)"/>
public static DiagnosticResult Diagnostic(string diagnosticId)
=> CSharpAnalyzerVerifier<TAnalyzer, XUnitVerifier>.Diagnostic(diagnosticId);
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic(DiagnosticDescriptor)"/>
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
=> CSharpAnalyzerVerifier<TAnalyzer, XUnitVerifier>.Diagnostic(descriptor);
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.VerifyAnalyzerAsync(string, DiagnosticResult[])"/>
public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected)
{
var test = new Test
{
TestCode = source,
};
test.ExpectedDiagnostics.AddRange(expected);
await test.RunAsync(CancellationToken.None);
}
}

Просмотреть файл

@ -0,0 +1,35 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
namespace Razor.Diagnostics.Analyzers.Test;
internal static class CSharpVerifierHelper
{
/// <summary>
/// By default, the compiler reports diagnostics for nullable reference types at
/// <see cref="DiagnosticSeverity.Warning"/>, and the analyzer test framework defaults to only validating
/// diagnostics at <see cref="DiagnosticSeverity.Error"/>. This map contains all compiler diagnostic IDs
/// related to nullability mapped to <see cref="ReportDiagnostic.Error"/>, which is then used to enable all
/// of these warnings for default validation during analyzer and code fix tests.
/// </summary>
internal static ImmutableDictionary<string, ReportDiagnostic> NullableWarnings { get; } = GetNullableWarningsFromCompiler();
private static ImmutableDictionary<string, ReportDiagnostic> GetNullableWarningsFromCompiler()
{
string[] args = { "/warnaserror:nullable" };
var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory);
var nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions;
// Workaround for https://github.com/dotnet/roslyn/issues/41610
nullableWarnings = nullableWarnings
.SetItem("CS8632", ReportDiagnostic.Error)
.SetItem("CS8669", ReportDiagnostic.Error);
return nullableWarnings;
}
}

Просмотреть файл

@ -0,0 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
namespace Razor.Diagnostics.Analyzers;
internal static class DiagnosticCategory
{
public const string Reliability = nameof(Reliability);
}

Просмотреть файл

@ -0,0 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
namespace Razor.Diagnostics.Analyzers;
internal static class DiagnosticIds
{
public const string PooledArrayBuilderAsRef = "RZD001";
}

Просмотреть файл

@ -0,0 +1,21 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using Microsoft.CodeAnalysis;
namespace Razor.Diagnostics.Analyzers;
internal static class Extensions
{
public static Diagnostic CreateDiagnostic(this IOperation operation, DiagnosticDescriptor rule)
{
var location = operation.Syntax.GetLocation();
if (!location.IsInSource)
{
location = Location.None;
}
return Diagnostic.Create(rule, location);
}
}

Просмотреть файл

@ -0,0 +1,11 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("MicrosoftCodeAnalysisReleaseTracking", "RS2008:Enable analyzer release tracking", Justification = "<Pending>", Scope = "member", Target = "~F:Razor.Diagnostics.Analyzers.PooledArrayBuilderAsRefAnalyzer.Rule")]

Просмотреть файл

@ -0,0 +1,73 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
using static Razor.Diagnostics.Analyzers.Resources;
namespace Razor.Diagnostics.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class PooledArrayBuilderAsRefAnalyzer : DiagnosticAnalyzer
{
internal static readonly DiagnosticDescriptor Rule = new(
DiagnosticIds.PooledArrayBuilderAsRef,
CreateLocalizableResourceString(nameof(PooledArrayBuilderAsRefTitle)),
CreateLocalizableResourceString(nameof(PooledArrayBuilderAsRefMessage)),
DiagnosticCategory.Reliability,
DiagnosticSeverity.Warning,
isEnabledByDefault: true,
description: CreateLocalizableResourceString(nameof(PooledArrayBuilderAsRefDescription)));
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get { return ImmutableArray.Create(Rule); } }
public override void Initialize(AnalysisContext context)
{
context.EnableConcurrentExecution();
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
context.RegisterCompilationStartAction(context =>
{
var pooledArrayBuilderExtensions = context.Compilation.GetTypeByMetadataName(WellKnownTypeNames.PooledArrayBuilderExtensions);
if (pooledArrayBuilderExtensions is null)
{
return;
}
var pooledArrayBuilderAsRef = (IMethodSymbol?)pooledArrayBuilderExtensions.GetMembers("AsRef").SingleOrDefault();
if (pooledArrayBuilderAsRef is null)
{
return;
}
context.RegisterOperationAction(context => AnalyzeInvocation(context, pooledArrayBuilderAsRef), OperationKind.Invocation);
});
}
private static void AnalyzeInvocation(OperationAnalysisContext context, IMethodSymbol pooledArrayBuilderAsRef)
{
var invocation = (IInvocationOperation)context.Operation;
var targetMethod = invocation.TargetMethod.ReducedFrom ?? invocation.TargetMethod;
if (!SymbolEqualityComparer.Default.Equals(targetMethod.OriginalDefinition, pooledArrayBuilderAsRef))
{
return;
}
var instance = invocation.Instance ?? invocation.Arguments.FirstOrDefault()?.Value;
if (instance is not ILocalReferenceOperation localReference)
{
context.ReportDiagnostic(invocation.CreateDiagnostic(Rule));
return;
}
var declaration = invocation.SemanticModel!.GetOperation(localReference.Local.DeclaringSyntaxReferences.Single().GetSyntax(context.CancellationToken), context.CancellationToken);
if (declaration is not { Parent: IVariableDeclarationOperation { Parent: IVariableDeclarationGroupOperation { Parent: IUsingOperation or IUsingDeclarationOperation } } })
{
context.ReportDiagnostic(invocation.CreateDiagnostic(Rule));
return;
}
}
}

Просмотреть файл

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,18 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis;
namespace Razor.Diagnostics.Analyzers;
internal partial class Resources
{
private static readonly Type s_resourcesType = typeof(Resources);
public static LocalizableResourceString CreateLocalizableResourceString(string nameOfLocalizableResource)
=> new(nameOfLocalizableResource, ResourceManager, s_resourcesType);
public static LocalizableResourceString CreateLocalizableResourceString(string nameOfLocalizableResource, params string[] formatArguments)
=> new(nameOfLocalizableResource, ResourceManager, s_resourcesType, formatArguments);
}

Просмотреть файл

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="PooledArrayBuilderAsRefDescription" xml:space="preserve">
<value>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</value>
<comment>An optional longer localizable description of the diagnostic.</comment>
</data>
<data name="PooledArrayBuilderAsRefMessage" xml:space="preserve">
<value>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</value>
<comment>The format-able message the diagnostic displays.</comment>
</data>
<data name="PooledArrayBuilderAsRefTitle" xml:space="preserve">
<value>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</value>
<comment>The title of the diagnostic.</comment>
</data>
</root>

Просмотреть файл

@ -0,0 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See License.txt in the project root for license information.
namespace Razor.Diagnostics.Analyzers;
internal static class WellKnownTypeNames
{
public const string PooledArrayBuilderExtensions = "Microsoft.AspNetCore.Razor.PooledObjects.PooledArrayBuilderExtensions";
}

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.cs.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="cs" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.de.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="de" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.es.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="es" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.fr.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="fr" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.it.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="it" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.ja.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ja" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.ko.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ko" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.pl.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pl" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.pt-BR.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pt-BR" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.ru.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ru" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.tr.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="tr" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.zh-Hans.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hans" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>

22
src/Shared/Razor.Diagnostics.Analyzers/xlf/Resources.zh-Hant.xlf сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-Hant" original="../Resources.resx">
<body>
<trans-unit id="PooledArrayBuilderAsRefDescription">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable.</target>
<note>An optional longer localizable description of the diagnostic.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefMessage">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The format-able message the diagnostic displays.</note>
</trans-unit>
<trans-unit id="PooledArrayBuilderAsRefTitle">
<source>Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</source>
<target state="new">Instance of PooledArrayBuilder&lt;T&gt;.AsRef() must be a 'using' variable</target>
<note>The title of the diagnostic.</note>
</trans-unit>
</body>
</file>
</xliff>