-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds an analyzer that detects whether UseArcGISToolkit has been added (…
…#556) * Adds an analyzer that detects whether UseArcGISToolkit has been added
- Loading branch information
Showing
36 changed files
with
2,034 additions
and
4 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/Analyzers/Toolkit.Analyzers.Test/Esri.ArcGISRuntime.Toolkit.Analyzers.Test.projitems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
<HasSharedItems>true</HasSharedItems> | ||
<SharedGUID>61fbc238-623c-42ff-8c47-95d710a1e66f</SharedGUID> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<Import_RootNamespace>Esri.ArcGISRuntime.Toolkit.Analyzers.Test</Import_RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpAnalyzerVerifier`1+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpAnalyzerVerifier`1.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpCodeFixVerifier`2+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpCodeFixVerifier`2.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpCodeRefactoringVerifier`1+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpCodeRefactoringVerifier`1.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpVerifierHelper.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicAnalyzerVerifier`1+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicAnalyzerVerifier`1.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicCodeFixVerifier`2+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicCodeFixVerifier`2.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicCodeRefactoringVerifier`1+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicCodeRefactoringVerifier`1.cs" /> | ||
</ItemGroup> | ||
</Project> |
13 changes: 13 additions & 0 deletions
13
src/Analyzers/Toolkit.Analyzers.Test/Esri.ArcGISRuntime.Toolkit.Analyzers.Test.shproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>61fbc238-623c-42ff-8c47-95d710a1e66f</ProjectGuid> | ||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" /> | ||
<PropertyGroup /> | ||
<Import Project="Esri.ArcGISRuntime.Toolkit.Analyzers.Test.projitems" Label="Shared" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" /> | ||
</Project> |
26 changes: 26 additions & 0 deletions
26
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpAnalyzerVerifier<TAnalyzer> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
{ | ||
public class Test : CSharpAnalyzerTest<TAnalyzer, MSTestVerifier> | ||
{ | ||
public Test() | ||
{ | ||
SolutionTransforms.Add((solution, projectId) => | ||
{ | ||
var compilationOptions = solution.GetProject(projectId).CompilationOptions; | ||
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( | ||
compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); | ||
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); | ||
return solution; | ||
}); | ||
} | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpAnalyzerVerifier`1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.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, MSTestVerifier>.Diagnostic(); | ||
|
||
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic(string)"/> | ||
public static DiagnosticResult Diagnostic(string diagnosticId) | ||
=> CSharpAnalyzerVerifier<TAnalyzer, MSTestVerifier>.Diagnostic(diagnosticId); | ||
|
||
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic(DiagnosticDescriptor)"/> | ||
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) | ||
=> CSharpAnalyzerVerifier<TAnalyzer, MSTestVerifier>.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); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpCodeFixVerifier`2+Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
using System.Numerics; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpCodeFixVerifier<TAnalyzer, TCodeFix> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
where TCodeFix : CodeFixProvider, new() | ||
{ | ||
public class Test : CSharpCodeFixTest<TAnalyzer, TCodeFix, MSTestVerifier> | ||
{ | ||
public Test() | ||
{ | ||
SolutionTransforms.Add((solution, projectId) => | ||
{ | ||
var compilationOptions = solution.GetProject(projectId).CompilationOptions; | ||
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( | ||
compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); | ||
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); | ||
return solution; | ||
}); | ||
} | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpCodeFixVerifier`2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpCodeFixVerifier<TAnalyzer, TCodeFix> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
where TCodeFix : CodeFixProvider, new() | ||
{ | ||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic()"/> | ||
public static DiagnosticResult Diagnostic() | ||
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, MSTestVerifier>.Diagnostic(); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic(string)"/> | ||
public static DiagnosticResult Diagnostic(string diagnosticId) | ||
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, MSTestVerifier>.Diagnostic(diagnosticId); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic(DiagnosticDescriptor)"/> | ||
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) | ||
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, MSTestVerifier>.Diagnostic(descriptor); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, 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); | ||
} | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, string)"/> | ||
public static async Task VerifyCodeFixAsync(string source, string fixedSource) | ||
=> await VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, DiagnosticResult, string)"/> | ||
public static async Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource) | ||
=> await VerifyCodeFixAsync(source, new[] { expected }, fixedSource); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, DiagnosticResult[], string)"/> | ||
public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource) | ||
{ | ||
var test = new Test | ||
{ | ||
TestCode = source, | ||
FixedCode = fixedSource, | ||
}; | ||
|
||
test.ExpectedDiagnostics.AddRange(expected); | ||
await test.RunAsync(CancellationToken.None); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.CodeAnalysis.CodeRefactorings; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpCodeRefactoringVerifier<TCodeRefactoring> | ||
where TCodeRefactoring : CodeRefactoringProvider, new() | ||
{ | ||
public class Test : CSharpCodeRefactoringTest<TCodeRefactoring, MSTestVerifier> | ||
{ | ||
public Test() | ||
{ | ||
SolutionTransforms.Add((solution, projectId) => | ||
{ | ||
var compilationOptions = solution.GetProject(projectId).CompilationOptions; | ||
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( | ||
compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); | ||
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); | ||
return solution; | ||
}); | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpCodeRefactoringVerifier`1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.CodeAnalysis.CodeRefactorings; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpCodeRefactoringVerifier<TCodeRefactoring> | ||
where TCodeRefactoring : CodeRefactoringProvider, new() | ||
{ | ||
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, string)"/> | ||
public static async Task VerifyRefactoringAsync(string source, string fixedSource) | ||
{ | ||
await VerifyRefactoringAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); | ||
} | ||
|
||
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult, string)"/> | ||
public static async Task VerifyRefactoringAsync(string source, DiagnosticResult expected, string fixedSource) | ||
{ | ||
await VerifyRefactoringAsync(source, new[] { expected }, fixedSource); | ||
} | ||
|
||
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult[], string)"/> | ||
public static async Task VerifyRefactoringAsync(string source, DiagnosticResult[] expected, string fixedSource) | ||
{ | ||
var test = new Test | ||
{ | ||
TestCode = source, | ||
FixedCode = fixedSource, | ||
}; | ||
|
||
test.ExpectedDiagnostics.AddRange(expected); | ||
await test.RunAsync(CancellationToken.None); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpVerifierHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using System; | ||
using System.Collections.Immutable; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.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; | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/VisualBasicAnalyzerVerifier`1+Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
using Microsoft.CodeAnalysis.VisualBasic.Testing; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class VisualBasicAnalyzerVerifier<TAnalyzer> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
{ | ||
public class Test : VisualBasicAnalyzerTest<TAnalyzer, MSTestVerifier> | ||
{ | ||
public Test() | ||
{ | ||
} | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/VisualBasicAnalyzerVerifier`1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
using Microsoft.CodeAnalysis.VisualBasic.Testing; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class VisualBasicAnalyzerVerifier<TAnalyzer> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
{ | ||
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic()"/> | ||
public static DiagnosticResult Diagnostic() | ||
=> VisualBasicAnalyzerVerifier<TAnalyzer, MSTestVerifier>.Diagnostic(); | ||
|
||
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic(string)"/> | ||
public static DiagnosticResult Diagnostic(string diagnosticId) | ||
=> VisualBasicAnalyzerVerifier<TAnalyzer, MSTestVerifier>.Diagnostic(diagnosticId); | ||
|
||
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic(DiagnosticDescriptor)"/> | ||
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) | ||
=> VisualBasicAnalyzerVerifier<TAnalyzer, MSTestVerifier>.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); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/VisualBasicCodeFixVerifier`2+Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
using Microsoft.CodeAnalysis.VisualBasic.Testing; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class VisualBasicCodeFixVerifier<TAnalyzer, TCodeFix> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
where TCodeFix : CodeFixProvider, new() | ||
{ | ||
public class Test : VisualBasicCodeFixTest<TAnalyzer, TCodeFix, MSTestVerifier> | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.