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), + }; + } } }