Skip to content

Commit f93c224

Browse files
Move analyzers to main repo (#534)
1 parent 59414c9 commit f93c224

24 files changed

+1218
-13
lines changed

Machine.Specifications.sln

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.0.31903.59
4+
VisualStudioVersion = 17.12.35527.113 d17.12
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Machine.Specifications", "src\Machine.Specifications\Machine.Specifications.csproj", "{EC054D80-8858-4A61-9FD9-0185EA3F4643}"
77
EndProject
8-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{1D85E618-71A9-43F2-B76D-95DC161E2A13}"
9-
ProjectSection(SolutionItems) = preProject
10-
build.ps1 = build.ps1
11-
build.sh = build.sh
12-
.github\workflows\build.yml = .github\workflows\build.yml
13-
CONTRIBUTING.md = CONTRIBUTING.md
14-
.config\dotnet-tools.json = .config\dotnet-tools.json
15-
GitVersion.yml = GitVersion.yml
16-
.github\workflows\publish.yml = .github\workflows\publish.yml
17-
README.md = README.md
18-
EndProjectSection
19-
EndProject
208
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Machine.Specifications.Runner.Utility", "src\Machine.Specifications.Runner.Utility\Machine.Specifications.Runner.Utility.csproj", "{7E11A6CD-5900-4FFD-AE68-231BDA2436BA}"
219
EndProject
2210
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Machine.Specifications.Runner.Utility.Specs", "src\Machine.Specifications.Runner.Utility.Specs\Machine.Specifications.Runner.Utility.Specs.csproj", "{068B7D50-95A9-4510-96DC-59AB697D6C5F}"
@@ -33,6 +21,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Machine.Specifications.Core
3321
EndProject
3422
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Machine.Specifications.Fixtures", "src\Machine.Specifications.Fixtures\Machine.Specifications.Fixtures.csproj", "{2934AB5B-7506-4150-B61B-FE16EBB13D50}"
3523
EndProject
24+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Machine.Specifications.Analyzers", "src\Machine.Specifications.Analyzers\Machine.Specifications.Analyzers.csproj", "{0CFB2FE5-BDAF-4B7B-9E05-F05491B05CDA}"
25+
EndProject
26+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Machine.Specifications.Analyzers.Tests", "src\Machine.Specifications.Analyzers.Tests\Machine.Specifications.Analyzers.Tests.csproj", "{402EF260-6140-4633-880B-18BEBF7B9DA2}"
27+
EndProject
3628
Global
3729
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3830
Debug|Any CPU = Debug|Any CPU
@@ -75,6 +67,14 @@ Global
7567
{2934AB5B-7506-4150-B61B-FE16EBB13D50}.Debug|Any CPU.Build.0 = Debug|Any CPU
7668
{2934AB5B-7506-4150-B61B-FE16EBB13D50}.Release|Any CPU.ActiveCfg = Release|Any CPU
7769
{2934AB5B-7506-4150-B61B-FE16EBB13D50}.Release|Any CPU.Build.0 = Release|Any CPU
70+
{0CFB2FE5-BDAF-4B7B-9E05-F05491B05CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71+
{0CFB2FE5-BDAF-4B7B-9E05-F05491B05CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
72+
{0CFB2FE5-BDAF-4B7B-9E05-F05491B05CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
73+
{0CFB2FE5-BDAF-4B7B-9E05-F05491B05CDA}.Release|Any CPU.Build.0 = Release|Any CPU
74+
{402EF260-6140-4633-880B-18BEBF7B9DA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75+
{402EF260-6140-4633-880B-18BEBF7B9DA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{402EF260-6140-4633-880B-18BEBF7B9DA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
77+
{402EF260-6140-4633-880B-18BEBF7B9DA2}.Release|Any CPU.Build.0 = Release|Any CPU
7878
EndGlobalSection
7979
GlobalSection(SolutionProperties) = preSolution
8080
HideSolutionNode = FALSE
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using Microsoft.CodeAnalysis;
4+
using Microsoft.CodeAnalysis.CSharp.Testing;
5+
using Microsoft.CodeAnalysis.Diagnostics;
6+
using Microsoft.CodeAnalysis.Testing;
7+
8+
namespace Machine.Specifications.Analyzers.Tests;
9+
10+
public static class AnalyzerVerifier<TAnalyzer>
11+
where TAnalyzer : DiagnosticAnalyzer, new()
12+
{
13+
public static DiagnosticResult Diagnostic()
14+
{
15+
return CSharpAnalyzerVerifier<TAnalyzer, DefaultVerifier>.Diagnostic();
16+
}
17+
18+
public static DiagnosticResult Diagnostic(string diagnosticId)
19+
{
20+
return CSharpAnalyzerVerifier<TAnalyzer, DefaultVerifier>.Diagnostic(diagnosticId);
21+
}
22+
23+
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
24+
{
25+
return CSharpAnalyzerVerifier<TAnalyzer, DefaultVerifier>.Diagnostic(descriptor);
26+
}
27+
28+
public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected)
29+
{
30+
var test = new Test
31+
{
32+
TestCode = source
33+
};
34+
35+
test.ExpectedDiagnostics.AddRange(expected);
36+
37+
await test.RunAsync(CancellationToken.None);
38+
}
39+
40+
private class Test : CSharpAnalyzerTest<TAnalyzer, DefaultVerifier>
41+
{
42+
public Test()
43+
{
44+
ReferenceAssemblies = VerifierHelper.MspecAssemblies;
45+
SolutionTransforms.Add(VerifierHelper.GetNullableTransform);
46+
}
47+
}
48+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using Microsoft.CodeAnalysis;
4+
using Microsoft.CodeAnalysis.CodeFixes;
5+
using Microsoft.CodeAnalysis.CSharp.Testing;
6+
using Microsoft.CodeAnalysis.Diagnostics;
7+
using Microsoft.CodeAnalysis.Testing;
8+
9+
namespace Machine.Specifications.Analyzers.Tests
10+
{
11+
public static class CodeFixVerifier<TAnalyzer, TCodeFix>
12+
where TAnalyzer : DiagnosticAnalyzer, new()
13+
where TCodeFix : CodeFixProvider, new()
14+
{
15+
public static DiagnosticResult Diagnostic()
16+
{
17+
return CSharpCodeFixVerifier<TAnalyzer, TCodeFix, DefaultVerifier>.Diagnostic();
18+
}
19+
20+
public static DiagnosticResult Diagnostic(string diagnosticId)
21+
{
22+
return CSharpCodeFixVerifier<TAnalyzer, TCodeFix, DefaultVerifier>.Diagnostic(diagnosticId);
23+
}
24+
25+
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
26+
{
27+
return CSharpCodeFixVerifier<TAnalyzer, TCodeFix, DefaultVerifier>.Diagnostic(descriptor);
28+
}
29+
30+
public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected)
31+
{
32+
var test = new Test
33+
{
34+
TestCode = source
35+
};
36+
37+
test.ExpectedDiagnostics.AddRange(expected);
38+
39+
await test.RunAsync(CancellationToken.None);
40+
}
41+
42+
public static async Task VerifyCodeFixAsync(string source, string fixedSource)
43+
{
44+
await VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource);
45+
}
46+
47+
public static async Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource)
48+
{
49+
await VerifyCodeFixAsync(source, new[] {expected}, fixedSource);
50+
}
51+
52+
public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource)
53+
{
54+
var test = new Test
55+
{
56+
TestCode = source,
57+
FixedCode = fixedSource
58+
};
59+
60+
test.ExpectedDiagnostics.AddRange(expected);
61+
62+
await test.RunAsync(CancellationToken.None);
63+
}
64+
65+
private class Test : CSharpCodeFixTest<TAnalyzer, TCodeFix, DefaultVerifier>
66+
{
67+
public Test()
68+
{
69+
ReferenceAssemblies = VerifierHelper.MspecAssemblies;
70+
SolutionTransforms.Add(VerifierHelper.GetNullableTransform);
71+
}
72+
}
73+
}
74+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<LangVersion>latest</LangVersion>
8+
<IsPackable>false</IsPackable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<Using Include="Xunit" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.CodeAnalysis" Version="4.11.0" />
17+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="1.1.2" />
18+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.2" />
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
20+
<PackageReference Include="xunit" Version="2.9.2" />
21+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
<PrivateAssets>all</PrivateAssets>
24+
</PackageReference>
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<ProjectReference Include="..\Machine.Specifications.Analyzers\Machine.Specifications.Analyzers.csproj" />
29+
</ItemGroup>
30+
31+
</Project>

0 commit comments

Comments
 (0)