From 76cb4c6ab6e52354fb649a6379e1a610fbc89ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Hellander?= Date: Sat, 7 Dec 2024 11:56:07 +0100 Subject: [PATCH] Update the code analysis nuget in the c# 13 test project to the official 4.12.0 version --- .../LayoutRules/SA1504CSharp13UnitTests.cs | 8 ++++++++ .../StyleCop.Analyzers.Test.CSharp13.csproj | 2 +- .../LayoutRules/SA1504UnitTests.cs | 13 +++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp13/LayoutRules/SA1504CSharp13UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp13/LayoutRules/SA1504CSharp13UnitTests.cs index 1bc9d9d86..916b416e9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp13/LayoutRules/SA1504CSharp13UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp13/LayoutRules/SA1504CSharp13UnitTests.cs @@ -3,9 +3,17 @@ namespace StyleCop.Analyzers.Test.CSharp13.LayoutRules { + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.CSharp12.LayoutRules; public partial class SA1504CSharp13UnitTests : SA1504CSharp12UnitTests { + protected override DiagnosticResult[] GetExpectedResultAccessorWithoutBody() + { + return new DiagnosticResult[] + { + DiagnosticResult.CompilerError("CS8652").WithMessage("The feature 'field keyword' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version.").WithLocation(4, 16), + }; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp13/StyleCop.Analyzers.Test.CSharp13.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp13/StyleCop.Analyzers.Test.CSharp13.csproj index f6a068fd6..63396aa84 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp13/StyleCop.Analyzers.Test.CSharp13.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp13/StyleCop.Analyzers.Test.CSharp13.csproj @@ -18,7 +18,7 @@ - + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1504UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1504UnitTests.cs index 00c808438..9fb32f371 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1504UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1504UnitTests.cs @@ -303,11 +303,8 @@ public int Prop } } }"; - DiagnosticResult[] expected = - { - DiagnosticResult.CompilerError("CS0501").WithMessage("'Foo.Prop.get' must declare a body because it is not marked abstract, extern, or partial").WithLocation(6, 9), - }; + var expected = this.GetExpectedResultAccessorWithoutBody(); await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } @@ -387,5 +384,13 @@ public int Prop CodeActionIndex = 1, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } + + protected virtual DiagnosticResult[] GetExpectedResultAccessorWithoutBody() + { + return new DiagnosticResult[] + { + DiagnosticResult.CompilerError("CS0501").WithMessage("'Foo.Prop.get' must declare a body because it is not marked abstract, extern, or partial").WithLocation(6, 9), + }; + } } }