Skip to content

Commit 2132a79

Browse files
committed
- Use DefaultVerifier instead of NUnitVerifier in unit tests as suggested (dotnet/roslyn-sdk#1127 (comment)) to fix issues when upgrading to NUnit 4.
- Upgrade to Nunit 4 and upgrade source generation nuget packages to latest stable versions.
1 parent 134f8b8 commit 2132a79

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

DecoratorGenerator.UnitTests/CSharpSourceGeneratorVerifier.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
using Microsoft.CodeAnalysis;
22
using Microsoft.CodeAnalysis.CSharp;
33
using Microsoft.CodeAnalysis.CSharp.Testing;
4-
using Microsoft.CodeAnalysis.Testing.Verifiers;
4+
using Microsoft.CodeAnalysis.Testing;
55
using System.Collections.Immutable;
66

77
namespace DecoratorGenerator.UnitTests;
88

99
public static class CSharpSourceGeneratorVerifier<TSourceGenerator> where TSourceGenerator : ISourceGenerator, new()
1010
{
11-
public class Test : CSharpSourceGeneratorTest<TSourceGenerator, NUnitVerifier>
11+
public class Test : CSharpSourceGeneratorTest<TSourceGenerator, DefaultVerifier>
1212
{
13-
public Test()
14-
{
13+
public Test() {
1514
}
1615

17-
protected override CompilationOptions CreateCompilationOptions()
18-
{
16+
protected override CompilationOptions CreateCompilationOptions() {
1917
var compilationOptions = base.CreateCompilationOptions();
2018
return compilationOptions.WithSpecificDiagnosticOptions(
2119
compilationOptions.SpecificDiagnosticOptions.SetItems(GetNullableWarningsFromCompiler()));
2220
}
2321

2422
public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Default;
2523

26-
private static ImmutableDictionary<string, ReportDiagnostic> GetNullableWarningsFromCompiler()
27-
{
24+
private static ImmutableDictionary<string, ReportDiagnostic> GetNullableWarningsFromCompiler() {
2825
string[] args = { "/warnaserror:nullable" };
2926
var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory);
3027
var nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions;
3128

3229
return nullableWarnings;
3330
}
3431

35-
protected override ParseOptions CreateParseOptions()
36-
{
32+
protected override ParseOptions CreateParseOptions() {
3733
return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(LanguageVersion);
3834
}
3935
}

DecoratorGenerator.UnitTests/DecoratorGenerator.UnitTests.csproj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.103.8" />
14-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
14+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
1515
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.NUnit" Version="1.1.1" />
16-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
18-
<PackageReference Include="NUnit" Version="3.14.0" />
16+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.9.2" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
18+
<PackageReference Include="NUnit" Version="4.1.0" />
1919
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
20-
<PackageReference Include="NUnit.Analyzers" Version="3.9.0">
20+
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
21+
<PrivateAssets>all</PrivateAssets>
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
</PackageReference>
24+
<PackageReference Include="coverlet.collector" Version="6.0.2">
2125
<PrivateAssets>all</PrivateAssets>
2226
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2327
</PackageReference>
24-
<PackageReference Include="coverlet.collector" Version="6.0.0" />
2528
</ItemGroup>
2629

2730
<ItemGroup>

DecoratorGenerator/DecoratorGenerator.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
<PrivateAssets>all</PrivateAssets>
5454
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5555
</PackageReference>
56-
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
57-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
56+
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
57+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
5858
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
5959
<PrivateAssets>all</PrivateAssets>
6060
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)