Skip to content

Commit 8ec2650

Browse files
authored
Merge pull request #29 from d1820/add-c12-support
Add c12 support
2 parents 8376343 + 3e270d3 commit 8ec2650

100 files changed

Lines changed: 2540 additions & 1673 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 555 additions & 79 deletions
Large diffs are not rendered by default.

.github/workflows/dotnet.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v3
19-
19+
2020
- name: Setup MsBuild
2121
uses: microsoft/setup-msbuild@v1.3.1
2222

2323
- name: Setup VSTest.console.exe
2424
# You may pin to the exact commit or the version.
2525
# uses: darenm/Setup-VSTest@d9a5dffa3f11d9c27ec42eb69515d3aaeaad9ef8
2626
uses: darenm/Setup-VSTest@v1.2
27-
27+
2828
- name: Setup NuGet.exe
2929
# You may pin to the exact commit or the version.
3030
# uses: NuGet/setup-nuget@296fd3ccf8528660c91106efefe2364482f86d6f
31-
uses: NuGet/setup-nuget@v1.2.0
32-
31+
uses: NuGet/setup-nuget@v1.2.0
32+
3333
- name: Restore dependencies
3434
run: nuget restore CodeDocumentor.sln
35-
35+
3636
- name: Build
37-
run: msbuild CodeDocumentor.sln /p:platform="Any CPU" /p:configuration="Release"
38-
37+
run: msbuild CodeDocumentor.sln /p:platform="Any CPU" /p:configuration="Debug"
38+
3939
- name: Test
40-
uses: microsoft/vstest-action@v1.0.0
40+
run: vstest.console.exe CodeDocumentor.Test\bin\Debug\net48\CodeDocumentor.Test.dll

CodeDocumentor.Test/Classes/ClassUnitTests.cs

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
1-
using CodeDocumentor.Services;
1+
using System.Threading.Tasks;
22
using CodeDocumentor.Test.TestHelpers;
3-
using CodeDocumentor.Vsix2022;
43
using Microsoft.CodeAnalysis;
54
using Microsoft.CodeAnalysis.CodeFixes;
65
using Microsoft.CodeAnalysis.Diagnostics;
76

87
using Xunit;
8+
using Xunit.Abstractions;
99

1010
namespace CodeDocumentor.Test.Classes
1111
{
12-
/// <summary>
13-
/// The class unit test.
14-
/// </summary>
1512
public class ClassUnitTest : CodeFixVerifier, IClassFixture<TestFixture>
1613
{
1714
private readonly TestFixture _fixture;
1815

19-
public ClassUnitTest(TestFixture fixture)
16+
public ClassUnitTest(TestFixture fixture, ITestOutputHelper output)
2017
{
2118
_fixture = fixture;
19+
fixture.Initialize(output);
2220
}
2321

24-
/// <summary>
25-
/// No diagnostics show.
26-
/// </summary>
27-
/// <param name="testCode">The test code.</param>
2822
[Theory]
2923
[InlineData("")]
3024
[InlineData("ClassTesterInheritDoc.cs")]
31-
public void NoDiagnosticsShow(string testCode)
25+
public async Task NoDiagnosticsShow(string testCode)
3226
{
3327
if (testCode == string.Empty)
3428
{
35-
VerifyCSharpDiagnostic(testCode, TestFixture.DIAG_TYPE_PUBLIC);
29+
await VerifyCSharpDiagnosticAsync(testCode, TestFixture.DIAG_TYPE_PUBLIC);
3630
}
3731
else
3832
{
39-
var file = _fixture.LoadTestFile($@"./Classes/TestFiles/{testCode}");
33+
var file = _fixture.LoadTestFile($"./Classes/TestFiles/{testCode}");
4034

4135
var expected = new DiagnosticResult
4236
{
@@ -45,33 +39,26 @@ public void NoDiagnosticsShow(string testCode)
4539
Severity = DiagnosticSeverity.Hidden,
4640
Locations =
4741
new[] {
48-
new DiagnosticResultLocation("Test0.cs", 8, 18)
42+
new DiagnosticResultLocation("Test0.cs", 4, 18)
4943
}
5044
};
5145

52-
VerifyCSharpDiagnostic(file, TestFixture.DIAG_TYPE_PUBLIC, expected);
46+
await VerifyCSharpDiagnosticAsync(file, TestFixture.DIAG_TYPE_PUBLIC, expected);
5347
}
5448
}
5549

56-
/// <summary>
57-
/// Shows diagnostic and fix.
58-
/// </summary>
59-
/// <param name="testCode">The test code.</param>
60-
/// <param name="fixCode">The fix code.</param>
61-
/// <param name="line">The line.</param>
62-
/// <param name="column">The column.</param>
6350
[Theory]
64-
[InlineData("ClassTester.cs", "ClassTesterFix.cs", 7, 19, TestFixture.DIAG_TYPE_PRIVATE)]
65-
[InlineData("PublicClassTester.cs", "PublicClassTesterFix.cs", 7, 26, TestFixture.DIAG_TYPE_PUBLIC_ONLY)]
66-
public void ShowDiagnosticAndFix(string testCode, string fixCode, int line, int column, string diagType)
51+
[InlineData("ClassTester.cs", "ClassTesterFix.cs", 3, 19, TestFixture.DIAG_TYPE_PRIVATE)]
52+
[InlineData("PublicClassTester.cs", "PublicClassTesterFix.cs", 3, 26, TestFixture.DIAG_TYPE_PUBLIC_ONLY)]
53+
public async Task ShowClassDiagnosticAndFix(string testCode, string fixCode, int line, int column, string diagType)
6754
{
68-
var fix = _fixture.LoadTestFile($@"./Classes/TestFiles/{fixCode}");
69-
var test = _fixture.LoadTestFile($@"./Classes/TestFiles/{testCode}");
55+
var fix = _fixture.LoadTestFile($"./Classes/TestFiles/{fixCode}");
56+
var test = _fixture.LoadTestFile($"./Classes/TestFiles/{testCode}");
7057

71-
_fixture.OptionsPropertyCallback = (o) =>
58+
_fixture.RegisterCallback(_fixture.CurrentTestName, (o) =>
7259
{
7360
_fixture.SetPublicProcessingOption(o, diagType);
74-
};
61+
});
7562
var expected = new DiagnosticResult
7663
{
7764
Id = ClassAnalyzerSettings.DiagnosticId,
@@ -83,39 +70,31 @@ public void ShowDiagnosticAndFix(string testCode, string fixCode, int line, int
8370
}
8471
};
8572

86-
VerifyCSharpDiagnostic(test, diagType, expected);
73+
await VerifyCSharpDiagnosticAsync(test, diagType, expected);
8774

88-
VerifyCSharpFix(test, fix, diagType);
75+
await VerifyCSharpFixAsync(test, fix, diagType);
8976
}
9077

9178
[Fact]
92-
public void SkipsDiagnosticAndFixWhenPublicOnlyTrue()
79+
public async Task SkipsClassDiagnosticAndFixWhenPublicOnlyTrue()
9380
{
94-
var fix = _fixture.LoadTestFile($@"./Classes/TestFiles/ClassTester.cs");
95-
var test = _fixture.LoadTestFile($@"./Classes/TestFiles/ClassTester.cs");
96-
_fixture.OptionsPropertyCallback = (o) =>
81+
var fix = _fixture.LoadTestFile("./Classes/TestFiles/ClassTester.cs");
82+
var test = _fixture.LoadTestFile("./Classes/TestFiles/ClassTester.cs");
83+
_fixture.RegisterCallback(_fixture.CurrentTestName, (o) =>
9784
{
9885
o.IsEnabledForPublicMembersOnly = true;
99-
};
86+
});
10087

101-
VerifyCSharpDiagnostic(test, TestFixture.DIAG_TYPE_PUBLIC_ONLY);
88+
await VerifyCSharpDiagnosticAsync(test, TestFixture.DIAG_TYPE_PUBLIC_ONLY);
10289

103-
VerifyCSharpFix(test, fix, TestFixture.DIAG_TYPE_PUBLIC_ONLY);
90+
await VerifyCSharpFixAsync(test, fix, TestFixture.DIAG_TYPE_PUBLIC_ONLY);
10491
}
10592

106-
/// <summary>
107-
/// Gets c sharp code fix provider.
108-
/// </summary>
109-
/// <returns>A CodeFixProvider.</returns>
11093
protected override CodeFixProvider GetCSharpCodeFixProvider()
11194
{
11295
return new ClassCodeFixProvider();
11396
}
11497

115-
/// <summary>
116-
/// Gets c sharp diagnostic analyzer.
117-
/// </summary>
118-
/// <returns>A DiagnosticAnalyzer.</returns>
11998
protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer(string diagType)
12099
{
121100
if (diagType == TestFixture.DIAG_TYPE_PRIVATE)

CodeDocumentor.Test/Classes/TestFiles/ClassTester.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace ConsoleApp4
1+
namespace ConsoleApp4
62
{
73
partial class ClassTester
84
{

CodeDocumentor.Test/Classes/TestFiles/ClassTesterFix.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace ConsoleApp4
1+
namespace ConsoleApp4
62
{
73
/// <summary>
84
/// The class tester.

CodeDocumentor.Test/Classes/TestFiles/ClassTesterInheritDoc.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace CodeDocumentor.Test.Classes.TestFiles
1+
namespace CodeDocumentor.Test.Classes.TestFiles
62
{
73
/// <inheritdoc/>
84
public class ClassTesterInherit

CodeDocumentor.Test/Classes/TestFiles/PublicClassTester.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace ConsoleApp4
1+
namespace ConsoleApp4
62
{
73
public partial class PublicClassTester
84
{

CodeDocumentor.Test/Classes/TestFiles/PublicClassTesterFix.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
5-
namespace ConsoleApp4
1+
namespace ConsoleApp4
62
{
73
/// <summary>
84
/// The public class tester.

CodeDocumentor.Test/CodeDocumentor.Test.csproj

Lines changed: 108 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net472</TargetFramework>
4+
<TargetFramework>net48</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
@@ -24,7 +24,31 @@
2424
<Compile Remove="Fields\TestFiles\InheritDocTestCode.cs" />
2525
<Compile Remove="Interfaces\TestFiles\TestCode.cs" />
2626
<Compile Remove="Interfaces\TestFiles\TestFixCode.cs" />
27+
<Compile Remove="Methods\TestFiles\BasicTestCode.cs" />
28+
<Compile Remove="Methods\TestFiles\BasicTestFixCode.cs" />
2729
<Compile Remove="Methods\TestFiles\InheritDocTestCode.cs" />
30+
<Compile Remove="Methods\TestFiles\MethodWithBooleanParameterTestCode.cs" />
31+
<Compile Remove="Methods\TestFiles\MethodWithBooleanParameterTestFixCode.cs" />
32+
<Compile Remove="Methods\TestFiles\MethodWithCrefTestCode.cs" />
33+
<Compile Remove="Methods\TestFiles\MethodWithCrefTestFixCode.cs" />
34+
<Compile Remove="Methods\TestFiles\MethodWithIntReturnTestCode.cs" />
35+
<Compile Remove="Methods\TestFiles\MethodWithIntReturnTestFixCode.cs" />
36+
<Compile Remove="Methods\TestFiles\MethodWithListIntReturnTestCode.cs" />
37+
<Compile Remove="Methods\TestFiles\MethodWithListIntReturnTestFixCode.cs" />
38+
<Compile Remove="Methods\TestFiles\MethodWithListListIntReturnTestCode.cs" />
39+
<Compile Remove="Methods\TestFiles\MethodWithListListIntReturnTestFixCode.cs" />
40+
<Compile Remove="Methods\TestFiles\MethodWithListQualifiedNameReturnTestCode.cs" />
41+
<Compile Remove="Methods\TestFiles\MethodWithListQualifiedNameReturnTestFixCode.cs" />
42+
<Compile Remove="Methods\TestFiles\MethodWithNullableStructParameterTestCode.cs" />
43+
<Compile Remove="Methods\TestFiles\MethodWithNullableStructParameterTestFixCode.cs" />
44+
<Compile Remove="Methods\TestFiles\MethodWithObjectReturnTestCode.cs" />
45+
<Compile Remove="Methods\TestFiles\MethodWithObjectReturnTestFixCode.cs" />
46+
<Compile Remove="Methods\TestFiles\MethodWithParameterTestCode.cs" />
47+
<Compile Remove="Methods\TestFiles\MethodWithParameterTestFixCode.cs" />
48+
<Compile Remove="Methods\TestFiles\MethodWithReturnTestCode.cs" />
49+
<Compile Remove="Methods\TestFiles\MethodWithReturnTestFixCode.cs" />
50+
<Compile Remove="Methods\TestFiles\MethodWithStringReturnTestCode.cs" />
51+
<Compile Remove="Methods\TestFiles\MethodWithStringReturnTestFixCode.cs" />
2852
<Compile Remove="Properties\TestFiles\InheritDocTestCode.cs" />
2953
<Compile Remove="Records\TestFiles\PublicRecordTester.cs" />
3054
<Compile Remove="Records\TestFiles\PublicRecordTesterFix.cs" />
@@ -34,9 +58,15 @@
3458
</ItemGroup>
3559

3660
<ItemGroup>
37-
<None Include="Methods\TestFiles\InheritDocTestCode.cs">
61+
<Content Include="Methods\TestFiles\BasicTestCode.cs">
3862
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
39-
</None>
63+
</Content>
64+
<Content Include="Methods\TestFiles\BasicTestFixCode.cs">
65+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
66+
</Content>
67+
<Content Include="Methods\TestFiles\InheritDocTestCode.cs">
68+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
69+
</Content>
4070
</ItemGroup>
4171

4272
<ItemGroup>
@@ -82,6 +112,72 @@
82112
<None Include="Interfaces\TestFiles\TestFixCode.cs">
83113
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
84114
</None>
115+
<Content Include="Methods\TestFiles\MethodWithBooleanParameterTestCode.cs">
116+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
117+
</Content>
118+
<Content Include="Methods\TestFiles\MethodWithBooleanParameterTestFixCode.cs">
119+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
120+
</Content>
121+
<Content Include="Methods\TestFiles\MethodWithCrefTestCode.cs">
122+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
123+
</Content>
124+
<Content Include="Methods\TestFiles\MethodWithCrefTestFixCode.cs">
125+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
126+
</Content>
127+
<Content Include="Methods\TestFiles\MethodWithIntReturnTestCode.cs">
128+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
129+
</Content>
130+
<Content Include="Methods\TestFiles\MethodWithIntReturnTestFixCode.cs">
131+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
132+
</Content>
133+
<Content Include="Methods\TestFiles\MethodWithListIntReturnTestCode.cs">
134+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
135+
</Content>
136+
<Content Include="Methods\TestFiles\MethodWithListIntReturnTestFixCode.cs">
137+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
138+
</Content>
139+
<Content Include="Methods\TestFiles\MethodWithListListIntReturnTestCode.cs">
140+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
141+
</Content>
142+
<Content Include="Methods\TestFiles\MethodWithListListIntReturnTestFixCode.cs">
143+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
144+
</Content>
145+
<Content Include="Methods\TestFiles\MethodWithListQualifiedNameReturnTestCode.cs">
146+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
147+
</Content>
148+
<Content Include="Methods\TestFiles\MethodWithListQualifiedNameReturnTestFixCode.cs">
149+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
150+
</Content>
151+
<Content Include="Methods\TestFiles\MethodWithNullableStructParameterTestCode.cs">
152+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
153+
</Content>
154+
<Content Include="Methods\TestFiles\MethodWithNullableStructParameterTestFixCode.cs">
155+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
156+
</Content>
157+
<Content Include="Methods\TestFiles\MethodWithObjectReturnTestCode.cs">
158+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
159+
</Content>
160+
<Content Include="Methods\TestFiles\MethodWithObjectReturnTestFixCode.cs">
161+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
162+
</Content>
163+
<Content Include="Methods\TestFiles\MethodWithParameterTestCode.cs">
164+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
165+
</Content>
166+
<Content Include="Methods\TestFiles\MethodWithParameterTestFixCode.cs">
167+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
168+
</Content>
169+
<Content Include="Methods\TestFiles\MethodWithReturnTestCode.cs">
170+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
171+
</Content>
172+
<Content Include="Methods\TestFiles\MethodWithReturnTestFixCode.cs">
173+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
174+
</Content>
175+
<Content Include="Methods\TestFiles\MethodWithStringReturnTestCode.cs">
176+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
177+
</Content>
178+
<Content Include="Methods\TestFiles\MethodWithStringReturnTestFixCode.cs">
179+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
180+
</Content>
85181
<None Include="Properties\TestFiles\InheritDocTestCode.cs">
86182
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
87183
</None>
@@ -126,16 +222,18 @@
126222
<PrivateAssets>all</PrivateAssets>
127223
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
128224
</PackageReference>
129-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.4.0" />
130-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
131-
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.4.33103.184" />
132-
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="17.4.33103.184" />
133-
<PackageReference Include="Moq" Version="4.20.69" />
225+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
226+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
227+
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.8.37222" ExcludeAssets="runtime">
228+
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
229+
</PackageReference>
230+
<PackageReference Include="Microsoft.VisualStudio.Shell.15.0" Version="17.8.37221" />
231+
<PackageReference Include="Moq" Version="4.20.70" />
134232
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
135233
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
136234
<PackageReference Include="Pluralize.NET" Version="1.0.2" />
137-
<PackageReference Include="xunit" Version="2.5.3" />
138-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
235+
<PackageReference Include="xunit" Version="2.6.5" />
236+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
139237
<PrivateAssets>all</PrivateAssets>
140238
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
141239
</PackageReference>

0 commit comments

Comments
 (0)