Skip to content

Commit

Permalink
Update to .NET 8, NUnit 4, other dev packages (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakov-h authored Jul 2, 2024
1 parent c25d8f0 commit 3091f12
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 46 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.423
dotnet-version: 8.0.300

- name: Build WTG.Analyzers
run: dotnet build src --configuration ${{ matrix.configuration }}
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.423
dotnet-version: 8.0.300

- name: Build NuGet Package
run: dotnet pack src -p:CommitID=${{ github.sha }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.423
dotnet-version: 8.0.300

- name: Create NuGet Packages
run: dotnet pack src --configuration Release /p:CommitID=${{ github.sha }} /p:TagVersion=${{ steps.tag_name.outputs.result }}
Expand Down
6 changes: 4 additions & 2 deletions WTG.Analyzers.TestFramework.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
<developmentDependency>true</developmentDependency>
<icon>images\icon.png</icon>
<dependencies>
<group targetFramework=".NETStandard2.0" />
<group targetFramework=".NETFramework4.6.2" />
<group targetFramework="net6.0" />
</dependencies>
</metadata>

<files>
<!-- Binaries -->
<file src="bin\netstandard2.0\WTG.Analyzers.TestFramework.dll" target="lib\netstandard2.0" />
<file src="bin\net462\WTG.Analyzers.TestFramework.dll" target="lib\net462" />
<file src="bin\net6.0\WTG.Analyzers.TestFramework.dll" target="lib\net6.0" />

<!-- Other -->
<file src="LICENSE.md" target="" />
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "8.0.300",
"rollForward": "latestMinor"
}
}
2 changes: 1 addition & 1 deletion src/WTG.Analyzers.Test/RuleSetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void WarnAll()
.Where(line => line.StartsWith(prefix, StringComparison.Ordinal))
.Select(line => line.Split(delimiter, count: 2))
.ToDictionary(
parts => parts[0].Substring(prefix.Length, length: parts[0].IndexOf(".", startIndex: prefix.Length, StringComparison.Ordinal) - prefix.Length),
parts => parts[0].Substring(prefix.Length, length: parts[0].IndexOf('.', startIndex: prefix.Length) - prefix.Length),
parts => (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity), parts[1].Trim(), ignoreCase: true));

var descriptors = typeof(Rules).GetFields()
Expand Down
12 changes: 6 additions & 6 deletions src/WTG.Analyzers.Test/WTG.Analyzers.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>WTG Analyzers Test</AssemblyTitle>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<OutputPath>..\..\bin</OutputPath>
</PropertyGroup>
<ItemGroup>
Expand All @@ -13,20 +13,20 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NUnit.Analyzers" Version="3.5.0">
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>WTG Analyzers Test Framework Test</AssemblyTitle>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<OutputPath>..\..\bin</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NUnit.Analyzers" Version="3.5.0">
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public DiagnosticConstraint(IEnumerable<DiagnosticResult> expected)
{
}

public override string Description => "has specified diagnostics";

public override ConstraintResult ApplyTo<TActual>(TActual actual)
{
if (actual == null)
Expand All @@ -24,7 +26,7 @@ public override ConstraintResult ApplyTo<TActual>(TActual actual)
{
return ApplyTo(
tmp.Select(DiagnosticConversion.Convert),
(IEnumerable<DiagnosticResult>)Arguments[0]);
(IEnumerable<DiagnosticResult>)Arguments[0]!);
}

return new ConstraintResult(this, actual);
Expand Down
11 changes: 7 additions & 4 deletions src/WTG.Analyzers.TestFramework/Helpers/CodeFixer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -205,10 +206,12 @@ static async Task ReportNewCompilerDiagnosticAsync(Document document, IEnumerabl
var tree = await document.GetSyntaxRootAsync().ConfigureAwait(false);

Assert.Fail(
"Fix introduced new compiler diagnostics:{0}{1}{0}{0}New document:{0}{2}{0}",
Environment.NewLine,
string.Join(Environment.NewLine, newCompilerDiagnostics.Select(d => d.ToString())),
tree?.ToFullString());
string.Format(
CultureInfo.InvariantCulture,
"Fix introduced new compiler diagnostics:{0}{1}{0}{0}New document:{0}{2}{0}",
Environment.NewLine,
string.Join(Environment.NewLine, newCompilerDiagnostics.Select(d => d.ToString())),
tree?.ToFullString()));
}

static async Task<Document> ApplyFixAsync(Document document, CodeAction codeAction)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Immutable;
using System.Collections.Immutable;
using System.Globalization;
using Microsoft.CodeAnalysis;

namespace WTG.Analyzers.TestFramework
Expand All @@ -22,7 +23,7 @@ public static DiagnosticResult Convert(Diagnostic diagnostic)
return new DiagnosticResult(
diagnostic.Id,
diagnostic.Severity,
diagnostic.GetMessage(),
diagnostic.GetMessage(CultureInfo.InvariantCulture),
builder.ToImmutable());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ sealed class DiagnosticResultComparer : IComparer<DiagnosticResult>, IComparer
{
}

public static int Compare(DiagnosticResult x, DiagnosticResult y)
public static int Compare(DiagnosticResult? x, DiagnosticResult? y)
{
switch (x, y)
{
case (null, null):
return 0;
case (null, _):
return -1;
case (_, null):
return 1;
}

var firstLocX = x.Locations.Length == 0 ? null : x.Locations[0];
var firstLocY = y.Locations.Length == 0 ? null : y.Locations[0];
var diff = Compare(firstLocX, firstLocY);
Expand Down Expand Up @@ -111,7 +121,7 @@ static int Compare(DiagnosticResultLocation? x, DiagnosticResultLocation? y)
return diff;
}

int IComparer.Compare(object x, object y) => Compare((DiagnosticResult)x, (DiagnosticResult)y);
int IComparer<DiagnosticResult>.Compare(DiagnosticResult x, DiagnosticResult y) => Compare(x, y);
int IComparer.Compare(object? x, object? y) => Compare((DiagnosticResult?)x, (DiagnosticResult?)y);
int IComparer<DiagnosticResult>.Compare(DiagnosticResult? x, DiagnosticResult? y) => Compare(x, y);
}
}
5 changes: 3 additions & 2 deletions src/WTG.Analyzers.TestFramework/TestData/SampleDataSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ static DiagnosticResult LoadResult(XElement element)
static T GetEnumValue<T>(XElement element, string name)
where T : struct
{
return (T)Enum.Parse(typeof(T), GetStringValue(element, name));
var value = GetStringValue(element, name);
return value is null ? default : (T)Enum.Parse(typeof(T), value);
}

static string? GetStringValue(XElement element, string name)
static string? GetStringValue(XElement? element, string name)
{
while (element != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>WTG Analyzers Test Framework</AssemblyTitle>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<OutputPath>..\..\bin</OutputPath>
<NuspecFile>..\..\WTG.Analyzers.TestFramework.nuspec</NuspecFile>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 2 additions & 0 deletions src/WTG.Analyzers.Utils.Test/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.cs]
dotnet_diagnostic.CA1861.severity = none
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -102,7 +103,7 @@ protected override async Task<Document> ApplyFixesAsync(Document originalDocumen
{
builder.AppendLine();
builder.Append("// ");
builder.Append(diagnostic.GetMessage());
builder.Append(diagnostic.GetMessage(CultureInfo.InvariantCulture));
}

return documentToFix.WithText(SourceText.From(builder.ToString()));
Expand Down
12 changes: 6 additions & 6 deletions src/WTG.Analyzers.Utils.Test/WTG.Analyzers.Utils.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>WTG Analyzers Utils Test</AssemblyTitle>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<OutputPath>..\..\bin</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NUnit.Analyzers" Version="3.5.0">
<PackageReference Include="NUnit.Analyzers" Version="4.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/WTG.Analyzers.Utils/WTG.Analyzers.Utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Nullable" Version="1.3.0">
<PackageReference Include="Nullable" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/WTG.Analyzers/WTG.Analyzers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Nullable" Version="1.3.0">
<PackageReference Include="Nullable" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit 3091f12

Please sign in to comment.