diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index ad7255fb..6dabc801 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -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 }}
@@ -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 }}
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index b2787f06..9f4958ce 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -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 }}
diff --git a/WTG.Analyzers.TestFramework.nuspec b/WTG.Analyzers.TestFramework.nuspec
index 06ae5474..bd283a37 100644
--- a/WTG.Analyzers.TestFramework.nuspec
+++ b/WTG.Analyzers.TestFramework.nuspec
@@ -13,13 +13,15 @@
true
images\icon.png
-
+
+
-
+
+
diff --git a/global.json b/global.json
index 1b8195c4..fb0099cb 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "6.0.100",
+ "version": "8.0.300",
"rollForward": "latestMinor"
}
}
diff --git a/src/WTG.Analyzers.Test/RuleSetTest.cs b/src/WTG.Analyzers.Test/RuleSetTest.cs
index 5adf5a81..308efc61 100644
--- a/src/WTG.Analyzers.Test/RuleSetTest.cs
+++ b/src/WTG.Analyzers.Test/RuleSetTest.cs
@@ -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()
diff --git a/src/WTG.Analyzers.Test/WTG.Analyzers.Test.csproj b/src/WTG.Analyzers.Test/WTG.Analyzers.Test.csproj
index 2fd0ab00..22ddf997 100644
--- a/src/WTG.Analyzers.Test/WTG.Analyzers.Test.csproj
+++ b/src/WTG.Analyzers.Test/WTG.Analyzers.Test.csproj
@@ -2,7 +2,7 @@
WTG Analyzers Test
- net472;net6.0
+ net472;net8.0
..\..\bin
@@ -13,20 +13,20 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/WTG.Analyzers.TestFramework.Test/WTG.Analyzers.TestFramework.Test.csproj b/src/WTG.Analyzers.TestFramework.Test/WTG.Analyzers.TestFramework.Test.csproj
index bcd677cc..c9d8c1b2 100644
--- a/src/WTG.Analyzers.TestFramework.Test/WTG.Analyzers.TestFramework.Test.csproj
+++ b/src/WTG.Analyzers.TestFramework.Test/WTG.Analyzers.TestFramework.Test.csproj
@@ -2,24 +2,24 @@
WTG Analyzers Test Framework Test
- net472;net6.0
+ net472;net8.0
..\..\bin
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/WTG.Analyzers.TestFramework/Constraints/DiagnosticConstraint.cs b/src/WTG.Analyzers.TestFramework/Constraints/DiagnosticConstraint.cs
index e50fd2b8..630fcf3b 100644
--- a/src/WTG.Analyzers.TestFramework/Constraints/DiagnosticConstraint.cs
+++ b/src/WTG.Analyzers.TestFramework/Constraints/DiagnosticConstraint.cs
@@ -13,6 +13,8 @@ public DiagnosticConstraint(IEnumerable expected)
{
}
+ public override string Description => "has specified diagnostics";
+
public override ConstraintResult ApplyTo(TActual actual)
{
if (actual == null)
@@ -24,7 +26,7 @@ public override ConstraintResult ApplyTo(TActual actual)
{
return ApplyTo(
tmp.Select(DiagnosticConversion.Convert),
- (IEnumerable)Arguments[0]);
+ (IEnumerable)Arguments[0]!);
}
return new ConstraintResult(this, actual);
diff --git a/src/WTG.Analyzers.TestFramework/Helpers/CodeFixer.cs b/src/WTG.Analyzers.TestFramework/Helpers/CodeFixer.cs
index 9f25aea0..0f275257 100644
--- a/src/WTG.Analyzers.TestFramework/Helpers/CodeFixer.cs
+++ b/src/WTG.Analyzers.TestFramework/Helpers/CodeFixer.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -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 ApplyFixAsync(Document document, CodeAction codeAction)
diff --git a/src/WTG.Analyzers.TestFramework/TestData/DiagnosticConversion.cs b/src/WTG.Analyzers.TestFramework/TestData/DiagnosticConversion.cs
index bf1a2f3a..4dce18bb 100644
--- a/src/WTG.Analyzers.TestFramework/TestData/DiagnosticConversion.cs
+++ b/src/WTG.Analyzers.TestFramework/TestData/DiagnosticConversion.cs
@@ -1,4 +1,5 @@
-using System.Collections.Immutable;
+using System.Collections.Immutable;
+using System.Globalization;
using Microsoft.CodeAnalysis;
namespace WTG.Analyzers.TestFramework
@@ -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());
}
diff --git a/src/WTG.Analyzers.TestFramework/TestData/DiagnosticResultComparer.cs b/src/WTG.Analyzers.TestFramework/TestData/DiagnosticResultComparer.cs
index 9bb5b66b..3b9ae2e0 100644
--- a/src/WTG.Analyzers.TestFramework/TestData/DiagnosticResultComparer.cs
+++ b/src/WTG.Analyzers.TestFramework/TestData/DiagnosticResultComparer.cs
@@ -12,8 +12,18 @@ sealed class DiagnosticResultComparer : IComparer, 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);
@@ -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.Compare(DiagnosticResult x, DiagnosticResult y) => Compare(x, y);
+ int IComparer.Compare(object? x, object? y) => Compare((DiagnosticResult?)x, (DiagnosticResult?)y);
+ int IComparer.Compare(DiagnosticResult? x, DiagnosticResult? y) => Compare(x, y);
}
}
diff --git a/src/WTG.Analyzers.TestFramework/TestData/SampleDataSet.cs b/src/WTG.Analyzers.TestFramework/TestData/SampleDataSet.cs
index be1a2927..a4807ff6 100644
--- a/src/WTG.Analyzers.TestFramework/TestData/SampleDataSet.cs
+++ b/src/WTG.Analyzers.TestFramework/TestData/SampleDataSet.cs
@@ -188,10 +188,11 @@ static DiagnosticResult LoadResult(XElement element)
static T GetEnumValue(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)
{
diff --git a/src/WTG.Analyzers.TestFramework/WTG.Analyzers.TestFramework.csproj b/src/WTG.Analyzers.TestFramework/WTG.Analyzers.TestFramework.csproj
index 78962798..b7175b80 100644
--- a/src/WTG.Analyzers.TestFramework/WTG.Analyzers.TestFramework.csproj
+++ b/src/WTG.Analyzers.TestFramework/WTG.Analyzers.TestFramework.csproj
@@ -2,22 +2,22 @@
WTG Analyzers Test Framework
- netstandard2.0
+ net462;net6.0
..\..\bin
..\..\WTG.Analyzers.TestFramework.nuspec
enable
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/WTG.Analyzers.Utils.Test/.editorconfig b/src/WTG.Analyzers.Utils.Test/.editorconfig
new file mode 100644
index 00000000..283b3e7f
--- /dev/null
+++ b/src/WTG.Analyzers.Utils.Test/.editorconfig
@@ -0,0 +1,2 @@
+[*.cs]
+dotnet_diagnostic.CA1861.severity = none
diff --git a/src/WTG.Analyzers.Utils.Test/DocumentBatchedFixAllProviderTest.cs b/src/WTG.Analyzers.Utils.Test/DocumentBatchedFixAllProviderTest.cs
index e799643c..486abadc 100644
--- a/src/WTG.Analyzers.Utils.Test/DocumentBatchedFixAllProviderTest.cs
+++ b/src/WTG.Analyzers.Utils.Test/DocumentBatchedFixAllProviderTest.cs
@@ -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;
@@ -102,7 +103,7 @@ protected override async Task ApplyFixesAsync(Document originalDocumen
{
builder.AppendLine();
builder.Append("// ");
- builder.Append(diagnostic.GetMessage());
+ builder.Append(diagnostic.GetMessage(CultureInfo.InvariantCulture));
}
return documentToFix.WithText(SourceText.From(builder.ToString()));
diff --git a/src/WTG.Analyzers.Utils.Test/WTG.Analyzers.Utils.Test.csproj b/src/WTG.Analyzers.Utils.Test/WTG.Analyzers.Utils.Test.csproj
index 87295ec2..dcc8a9d0 100644
--- a/src/WTG.Analyzers.Utils.Test/WTG.Analyzers.Utils.Test.csproj
+++ b/src/WTG.Analyzers.Utils.Test/WTG.Analyzers.Utils.Test.csproj
@@ -2,24 +2,24 @@
WTG Analyzers Utils Test
- net472;net6.0
+ net472;net8.0
..\..\bin
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/WTG.Analyzers.Utils/WTG.Analyzers.Utils.csproj b/src/WTG.Analyzers.Utils/WTG.Analyzers.Utils.csproj
index a4af5eb2..69bc3624 100644
--- a/src/WTG.Analyzers.Utils/WTG.Analyzers.Utils.csproj
+++ b/src/WTG.Analyzers.Utils/WTG.Analyzers.Utils.csproj
@@ -9,11 +9,11 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/WTG.Analyzers/WTG.Analyzers.csproj b/src/WTG.Analyzers/WTG.Analyzers.csproj
index 6f0c0dd0..e060b8ae 100644
--- a/src/WTG.Analyzers/WTG.Analyzers.csproj
+++ b/src/WTG.Analyzers/WTG.Analyzers.csproj
@@ -9,11 +9,11 @@
10
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive