From 3e259dec2d37f88356795fdabe28a04923c8faeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Hellander?= Date: Sat, 27 Apr 2024 13:50:39 +0200 Subject: [PATCH] Update some tests to not use a fixed language version --- .../OrderingRules/SA1206CSharp7UnitTests.cs | 7 +++---- .../OrderingRules/SA1207CSharp7UnitTests.cs | 5 ++--- .../ReadabilityRules/SA1131CSharp7UnitTests.cs | 5 ++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7UnitTests.cs index 459a81db7..f7d363259 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7UnitTests.cs @@ -1,14 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. -#nullable disable - namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.OrderingRules; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< @@ -34,7 +33,7 @@ public async Task TestReadonlyRefKeywordInStructDeclarationAsync(string keywords }} }} "; - await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_2, testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_2.OrLaterDefault(), testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } [Fact] @@ -53,7 +52,7 @@ readonly private struct BitHelper { Diagnostic().WithLocation(3, 14).WithArguments("private", "readonly"), }; - await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_2, testCode, expected, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_2.OrLaterDefault(), testCode, expected, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1207CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1207CSharp7UnitTests.cs index 4d6dfc0fc..bf9279527 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1207CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1207CSharp7UnitTests.cs @@ -1,13 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. -#nullable disable - namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.OrderingRules; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< @@ -38,7 +37,7 @@ public class TestClass "; var expectedDiagnostic = Diagnostic().WithArguments("private", "protected").WithLocation(5, 19); - await VerifyCSharpFixAsync(LanguageVersion.CSharp7_2, testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_2.OrLaterDefault(), testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1131CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1131CSharp7UnitTests.cs index 09260b565..166b62605 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1131CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1131CSharp7UnitTests.cs @@ -1,14 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. -#nullable disable - namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.ReadabilityRules; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< @@ -58,7 +57,7 @@ struct TestStruct }} "; DiagnosticResult expected = Diagnostic().WithLocation(8, 18); - await VerifyCSharpFixAsync(LanguageVersion.CSharp7_1, testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_1.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } } }