Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Original file line number Diff line number Diff line change
@@ -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),
};
}
}
}
Original file line number Diff line number Diff line change
@@ -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)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Exe</OutputType>
<EnforceExtendedAnalyzerRules>false</EnforceExtendedAnalyzerRules>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>..\StyleCop.Analyzers.Internal.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\StyleCop.Analyzers.Test.CSharp14\StyleCop.Analyzers.Test.CSharp14.csproj" />
<ProjectReference Include="..\StyleCop.Analyzers.PrivateCodeFixes\StyleCop.Analyzers.PrivateCodeFixes.csproj" PrivateAssets="all" SetTargetFramework="TargetFramework=netstandard2.0" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ private static readonly ConcurrentDictionary<Type, ConcurrentDictionary<Operatio
public static bool SupportsCSharp14 { get; }
= Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp14));

public static bool SupportsCSharp15 { get; }
= Enum.GetNames(typeof(SyntaxKind)).Contains(nameof(SyntaxKindEx.UnionKeyword));

public static bool SupportsIOperation => SupportsCSharp73;

internal static bool CanWrapObject(object obj, Type underlyingType)
Expand Down
3 changes: 3 additions & 0 deletions StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
8 changes: 7 additions & 1 deletion StyleCopAnalyzers.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down