diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8b29cab85..ded594ee5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -15,7 +15,7 @@ jobs:
matrix:
configuration: [ 'Debug', 'Release' ]
os: [ 'windows-latest' ]
- testversion: [ '6', '7', '8', '9', '10', '11', '12', '13', '14' ]
+ testversion: [ '6', '7', '8', '9', '10', '11', '12', '13', '14', '15' ]
fail-fast: false
runs-on: ${{ matrix.os }}
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs
index 51a4b5bfa..a09a0a911 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs
@@ -21,4 +21,5 @@
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp12")]
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp13")]
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp14")]
+[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp15")]
[assembly: InternalsVisibleTo("StyleCopTester")]
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1600CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1600CSharp15UnitTests.cs
new file mode 100644
index 000000000..18b3269a9
--- /dev/null
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1600CSharp15UnitTests.cs
@@ -0,0 +1,59 @@
+// Copyright (c) Contributors to the New StyleCop Analyzers project.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+namespace StyleCop.Analyzers.Test.CSharp15.DocumentationRules
+{
+ using Microsoft.CodeAnalysis.Testing;
+ using StyleCop.Analyzers.Test.CSharp14.DocumentationRules;
+ using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier<
+ StyleCop.Analyzers.DocumentationRules.SA1600ElementsMustBeDocumented,
+ StyleCop.Analyzers.DocumentationRules.SA1600CodeFixProvider>;
+
+ public partial class SA1600CSharp15UnitTests : SA1600CSharp14UnitTests
+ {
+ protected override DiagnosticResult[] GetExpectedResultTestRegressionMethodGlobalNamespace(string code)
+ {
+ if (code == "public void {|#0:TestMember|}() { }")
+ {
+ return new[]
+ {
+ // /0/Test0.cs(4,1): error CS0106: The modifier 'public' is not valid for this item
+ DiagnosticResult.CompilerError("CS0106").WithSpan(4, 1, 4, 7).WithArguments("public"),
+
+ // /0/Test0.cs(4,1): error CS8805: Program using top-level statements must be an executable.
+ DiagnosticResult.CompilerError("CS8805").WithSpan(4, 1, 4, 29),
+ };
+ }
+
+ if (code.StartsWith("public string {|#0:this"))
+ {
+ return new[]
+ {
+ // /0/Test0.cs(4,15): error CS9348: A compilation unit cannot directly contain members such as fields, methods or properties
+ DiagnosticResult.CompilerError("CS9348").WithSpan(4, 15, 4, 19),
+
+ Diagnostic().WithLocation(0),
+ };
+ }
+
+ if (code.StartsWith("public string"))
+ {
+ return new[]
+ {
+ // /0/Test0.cs(4,15): error CS9348: A compilation unit cannot directly contain members such as fields, methods or properties
+ DiagnosticResult.CompilerError("CS9348").WithSpan(4, 15, 4, 25),
+
+ Diagnostic().WithLocation(0),
+ };
+ }
+
+ return new[]
+ {
+ // /0/Test0.cs(4,27): error CS9348: A compilation unit cannot directly contain members such as fields, methods or properties
+ DiagnosticResult.CompilerError("CS9348").WithSpan(4, 27, 4, 37),
+
+ Diagnostic().WithLocation(0),
+ };
+ }
+ }
+}
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..40ae97b2f
--- /dev/null
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/Properties/AssemblyInfo.cs
@@ -0,0 +1,12 @@
+// Copyright (c) Contributors to the New StyleCop Analyzers project.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
+using System;
+using System.Runtime.InteropServices;
+
+[assembly: CLSCompliant(false)]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj
new file mode 100644
index 000000000..61c21cf46
--- /dev/null
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj
@@ -0,0 +1,27 @@
+
+
+
+
+ net48
+ Exe
+ false
+ true
+ true
+
+
+
+ ..\StyleCop.Analyzers.Internal.ruleset
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Properties/AssemblyInfo.cs
index 39c8e1dfd..0bb41ac9c 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Properties/AssemblyInfo.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Properties/AssemblyInfo.cs
@@ -20,3 +20,4 @@
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp12")]
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp13")]
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp14")]
+[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp15")]
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Verifiers/StyleCopCodeFixVerifier`2.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Verifiers/StyleCopCodeFixVerifier`2.cs
index f4718f190..583fd9a56 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Verifiers/StyleCopCodeFixVerifier`2.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Verifiers/StyleCopCodeFixVerifier`2.cs
@@ -368,6 +368,12 @@ private void UpdateGlobalAnalyzerConfig()
// NOTE: If needed, this method can be temporarily updated to default to a preview version
private LanguageVersion? GetDefaultLanguageVersion()
{
+ // Temporary fix since c# 15 is not yet the default language version in the c# 15 test project.
+ if (LightupHelpers.SupportsCSharp15)
+ {
+ return LanguageVersionEx.Preview;
+ }
+
return null;
}
}
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Verifiers/StyleCopDiagnosticVerifier`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Verifiers/StyleCopDiagnosticVerifier`1.cs
index 6e8fd4d0a..0b66cb567 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Verifiers/StyleCopDiagnosticVerifier`1.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp6/Verifiers/StyleCopDiagnosticVerifier`1.cs
@@ -83,6 +83,12 @@ protected override ParseOptions CreateParseOptions()
// NOTE: If needed, this method can be temporarily updated to default to a preview version
private LanguageVersion? GetDefaultLanguageVersion()
{
+ // Temporary fix since c# 15 is not yet the default language version in the c# 15 test project.
+ if (LightupHelpers.SupportsCSharp15)
+ {
+ return LanguageVersionEx.Preview;
+ }
+
return null;
}
}
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs
index bc465e63f..dd72fa704 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs
@@ -58,6 +58,9 @@ private static readonly ConcurrentDictionary SupportsCSharp73;
internal static bool CanWrapObject(object obj, Type underlyingType)
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs
index 20ce8e069..9a88cf1c9 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs
@@ -17,6 +17,7 @@ internal static class SyntaxKindEx
public const SyntaxKind UnmanagedKeyword = (SyntaxKind)8446;
public const SyntaxKind RequiredKeyword = (SyntaxKind)8447;
public const SyntaxKind FileKeyword = (SyntaxKind)8449;
+ public const SyntaxKind UnionKeyword = (SyntaxKind)8452;
public const SyntaxKind NullableKeyword = (SyntaxKind)8486;
public const SyntaxKind EnableKeyword = (SyntaxKind)8487;
public const SyntaxKind WarningsKeyword = (SyntaxKind)8488;
@@ -74,5 +75,7 @@ internal static class SyntaxKindEx
public const SyntaxKind RecordStructDeclaration = (SyntaxKind)9068;
public const SyntaxKind CollectionExpression = (SyntaxKind)9076;
public const SyntaxKind ExtensionBlockDeclaration = (SyntaxKind)9079;
+ public const SyntaxKind WithElement = (SyntaxKind)9081;
+ public const SyntaxKind UnionDeclaration = (SyntaxKind)9082;
}
}
diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs
index fddb574f9..a340239a1 100644
--- a/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs
+++ b/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs
@@ -25,4 +25,5 @@
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp12")]
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp13")]
[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp14")]
+[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp15")]
[assembly: InternalsVisibleTo("StyleCopTester")]
diff --git a/StyleCopAnalyzers.sln b/StyleCopAnalyzers.sln
index 845c9162f..7db58dd85 100644
--- a/StyleCopAnalyzers.sln
+++ b/StyleCopAnalyzers.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
-VisualStudioVersion = 18.6.11828.311 oobstable
+VisualStudioVersion = 18.6.11828.311
MinimumVisualStudioVersion = 17.0.31903.59
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers", "StyleCop.Analyzers\StyleCop.Analyzers\StyleCop.Analyzers.csproj", "{3B052737-06CE-4182-AE0F-08EB82DFA73E}"
EndProject
@@ -279,6 +279,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Test.CSh
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StyleCop.Analyzers.Test.CSharp14", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp14\StyleCop.Analyzers.Test.CSharp14.csproj", "{2DBCAA9D-7302-D41B-67F7-3005BCC1281C}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StyleCop.Analyzers.Test.CSharp15", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp15\StyleCop.Analyzers.Test.CSharp15.csproj", "{F86DD736-F70E-7311-18F0-CDE98C5F03C6}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -349,6 +351,10 @@ Global
{2DBCAA9D-7302-D41B-67F7-3005BCC1281C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DBCAA9D-7302-D41B-67F7-3005BCC1281C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DBCAA9D-7302-D41B-67F7-3005BCC1281C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F86DD736-F70E-7311-18F0-CDE98C5F03C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F86DD736-F70E-7311-18F0-CDE98C5F03C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F86DD736-F70E-7311-18F0-CDE98C5F03C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F86DD736-F70E-7311-18F0-CDE98C5F03C6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE