Skip to content

Commit

Permalink
Remove explicit language version configuration in test cases for c# 9…
Browse files Browse the repository at this point in the history
…, so that they will be run with the expected (later) language version in later test projects

DotNetAnalyzers#3493
  • Loading branch information
bjornhellander committed May 9, 2022
1 parent c211127 commit 2e8680d
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.LayoutRules;
using Xunit;
Expand Down Expand Up @@ -36,7 +35,7 @@ public async Task TestUsingAndGlobalStatementSpacingInTopLevelProgramAsync()
return 0;
";

var test = new CSharpTest(LanguageVersion.CSharp9)
var test = new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestState =
Expand All @@ -63,7 +62,7 @@ public async Task TestGlobalStatementSpacingInTopLevelProgramAsync()
return i;
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestState =
Expand All @@ -90,7 +89,7 @@ public async Task TestGlobalStatementAndRecordSpacingInTopLevelProgramAsync()
record A();
";

var test = new CSharpTest(LanguageVersion.CSharp9)
var test = new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestState =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules;
using Xunit;
Expand Down Expand Up @@ -35,7 +34,7 @@ public object TestMethod(Foo n, int a)
}
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestCode = testCode,
Expand Down Expand Up @@ -71,7 +70,7 @@ public object TestMethod(Foo n, int a)
}
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestCode = testCode,
Expand Down Expand Up @@ -113,7 +112,7 @@ public void TestMethod(Foo n, int a)
}
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestCode = testCode,
Expand Down Expand Up @@ -147,7 +146,7 @@ public object TestMethod(Foo n, int a)
}}
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestCode = testCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules;
using Xunit;
Expand Down Expand Up @@ -64,7 +63,7 @@ void M()
}
";

await VerifyCSharpFixAsync(LanguageVersion.CSharp9, testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false);
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.NamingRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.NamingRules;
using StyleCop.Analyzers.Test.Verifiers;
Expand Down Expand Up @@ -41,7 +40,7 @@ public R(int a, int b)
}
";

var test = new CSharpTest(LanguageVersion.CSharp9)
var test = new CSharpTest()
{
ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet50,
TestCode = testCode,
Expand Down Expand Up @@ -75,7 +74,7 @@ public R(int a, int b)
}
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet50,
TestCode = testCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.NamingRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using StyleCop.Analyzers.Test.CSharp8.NamingRules;
using StyleCop.Analyzers.Test.Verifiers;
using Xunit;
Expand Down Expand Up @@ -42,7 +41,7 @@ public R(int a, int b)
}
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet50,
TestCode = testCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.OrderingRules;
using Xunit;
Expand All @@ -33,7 +32,7 @@ public async Task TestValidUsingStatementsInTopLevelProgramAsync()
return 0;
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestState =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.OrderingRules;
using Xunit;
Expand All @@ -33,7 +32,7 @@ public async Task TestValidUsingStatementsInTopLevelProgramAsync()
return 0;
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestState =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.OrderingRules;
using Xunit;
Expand All @@ -33,7 +32,7 @@ public async Task TestValidUsingStatementsInTopLevelProgramAsync()
return 0;
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestState =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules;
using StyleCop.Analyzers.Test.Verifiers;
using Xunit;
Expand All @@ -32,7 +31,7 @@ public A UpdateA(A value)
}
}";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet50,
TestCode = testCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules;
using Xunit;
Expand All @@ -23,7 +22,7 @@ public async Task TestNoDiagnosticForEmptyRecordDeclarationAsync()
{
var testCode = @"public record Result(int Value);";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestCode = testCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules;
using Xunit;
Expand Down Expand Up @@ -39,7 +38,7 @@ r with
}
}";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestCode = testCode,
Expand Down Expand Up @@ -71,7 +70,7 @@ r with
}
}";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestCode = testCode,
Expand Down Expand Up @@ -103,7 +102,7 @@ public void MyCallingFunction(int index, MyObject myObject)
}
}";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
TestCode = testCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules
{
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.SpacingRules;
using Xunit;
Expand All @@ -18,7 +17,7 @@ public async Task TestTargetTypedNewAsync()
{
string statementWithoutSpace = "int a = new();";

await this.TestKeywordStatementAsync(statementWithoutSpace, DiagnosticResult.EmptyDiagnosticResults, statementWithoutSpace, languageVersion: LanguageVersion.CSharp9).ConfigureAwait(false);
await this.TestKeywordStatementAsync(statementWithoutSpace, DiagnosticResult.EmptyDiagnosticResults, statementWithoutSpace).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.SpacingRules;
using Xunit;
Expand Down Expand Up @@ -43,7 +42,7 @@ void Method(int b)
}
}";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
ExpectedDiagnostics =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.SpacingRules;
using Xunit;
Expand All @@ -33,7 +32,7 @@ public record MyQuery1() : BaseQuery<object>;
public record MyQuery2() : BaseQuery<object>;
public record MyQuery3() : BaseQuery<object>;";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
ExpectedDiagnostics =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.SpacingRules;
using StyleCop.Analyzers.Test.Verifiers;
using Xunit;
Expand Down Expand Up @@ -42,7 +40,7 @@ public async Task TestFunctionPointerParameterInvalidSpacingAsync()
Diagnostic(DescriptorNotFollowed).WithLocation(1),
};

await VerifyCSharpFixAsync(LanguageVersion.CSharp9, testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
Expand Down Expand Up @@ -70,7 +68,7 @@ public async Task TestFunctionPointerTypeInvalidSpacingAsync()
}
";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = GenericAnalyzerTest.ReferenceAssembliesNet50,
TestCode = testCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp8.SpacingRules;
using Xunit;
Expand All @@ -33,7 +32,7 @@ public record MyQuery1() : BaseQuery<object>;
public record MyQuery2() : BaseQuery<object>;
public record MyQuery3() : BaseQuery<object>;";

await new CSharpTest(LanguageVersion.CSharp9)
await new CSharpTest()
{
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
ExpectedDiagnostics =
Expand Down

0 comments on commit 2e8680d

Please sign in to comment.