Skip to content

Commit 9877132

Browse files
committed
Revert Roslyn to '4.3.0'
1 parent 4293074 commit 9877132

File tree

8 files changed

+24
-25
lines changed

8 files changed

+24
-25
lines changed

src/PolySharp.SourceGenerators/Diagnostics/Analyzers/UnsupportedCSharpLanguageVersionAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace PolySharp.SourceGenerators;
1818
public sealed partial class UnsupportedCSharpLanguageVersionAnalyzer : DiagnosticAnalyzer
1919
{
2020
/// <inheritdoc/>
21-
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = [UnsupportedCSharpLanguageVersionError];
21+
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create(UnsupportedCSharpLanguageVersionError);
2222

2323
/// <inheritdoc/>
2424
public override void Initialize(AnalysisContext context)

src/PolySharp.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using Microsoft.CodeAnalysis;
66
using Microsoft.CodeAnalysis.CSharp;
77

8+
#pragma warning disable IDE0090 // Use 'new DiagnosticDescriptor(...)'
9+
810
namespace PolySharp.SourceGenerators.Diagnostics;
911

1012
/// <summary>
@@ -18,7 +20,7 @@ internal static class DiagnosticDescriptors
1820
/// Format: <c>"The value "{0}" is not valid for property "{1}" (it has to be a valid MSBuild bool value)"</c>.
1921
/// </para>
2022
/// </summary>
21-
public static readonly DiagnosticDescriptor InvalidBoolMSBuildProperty = new(
23+
public static readonly DiagnosticDescriptor InvalidBoolMSBuildProperty = new DiagnosticDescriptor(
2224
id: "POLYSP0001",
2325
title: "Invalid PolySharp bool MSBuild property",
2426
messageFormat: "The value \"{0}\" is not valid for property \"{1}\" (it has to be a valid MSBuild bool value)",
@@ -34,7 +36,7 @@ internal static class DiagnosticDescriptors
3436
/// Format: <c>"The fully qualified metadata name "{0}" used in property "{1}" is not valid, and it does not match any available polyfill type"</c>.
3537
/// </para>
3638
/// </summary>
37-
public static readonly DiagnosticDescriptor InvalidPolyfillFullyQualifiedMetadataName = new(
39+
public static readonly DiagnosticDescriptor InvalidPolyfillFullyQualifiedMetadataName = new DiagnosticDescriptor(
3840
id: "POLYSP0002",
3941
title: "Invalid fully qualified metadata name for polyfill",
4042
messageFormat: "The fully qualified metadata name \"{0}\" used in property \"{1}\" is not a valid fully qualified type name, or it does not match any available polyfill type",
@@ -47,14 +49,13 @@ internal static class DiagnosticDescriptors
4749
/// <summary>
4850
/// Gets a <see cref="DiagnosticDescriptor"/> indicating when an unsupported C# language version is being used.
4951
/// </summary>
50-
public static readonly DiagnosticDescriptor UnsupportedCSharpLanguageVersionError = new(
52+
public static readonly DiagnosticDescriptor UnsupportedCSharpLanguageVersionError = new DiagnosticDescriptor(
5153
id: "POLYSP0003",
5254
title: "Unsupported C# language version",
5355
messageFormat: "The source generator features from PolySharp require consuming projects to set the C# language version to at least C# 8.0",
5456
category: typeof(CSharpParseOptions).FullName,
5557
defaultSeverity: DiagnosticSeverity.Warning,
5658
isEnabledByDefault: true,
5759
description: "The source generator features from PolySharp require consuming projects to set the C# language version to at least C# 8.0. Make sure to add <LangVersion>8.0</LangVersion> (or above) to your .csproj file.",
58-
helpLinkUri: "https://github.com/Sergio0694/PolySharp",
59-
customTags: WellKnownDiagnosticTags.CompilationEnd);
60+
helpLinkUri: "https://github.com/Sergio0694/PolySharp");
6061
}

src/PolySharp.SourceGenerators/Extensions/AnalyzerConfigOptionsProviderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ public static ImmutableArray<string> GetStringArrayMSBuildProperty(this Analyzer
7171
return builder.ToImmutable();
7272
}
7373

74-
return [];
74+
return ImmutableArray<string>.Empty;
7575
}
7676
}

src/PolySharp.SourceGenerators/Extensions/DiagnosticsExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace PolySharp.SourceGenerators.Extensions;
66

77
/// <summary>
8-
/// Extension methods for <see cref="DiagnosticInfo"/>, in various scenarios.
8+
/// Extension methods for <see cref="GeneratorExecutionContext"/>, specifically for reporting diagnostics.
99
/// </summary>
1010
internal static class DiagnosticsExtensions
1111
{

src/PolySharp.SourceGenerators/PolySharp.SourceGenerators.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" PrivateAssets="all" Pack="false" />
10+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" PrivateAssets="all" Pack="false" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

src/PolySharp.SourceGenerators/PolySharp.targets

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</ItemGroup>
88
</Target>
99

10-
<!-- Remove the analyzer if using Roslyn < 4.14 (PolySharp's generators require Roslyn 4.14) -->
10+
<!-- Remove the analyzer if using Roslyn < 4.3 (PolySharp's generators require Roslyn 4.3) -->
1111
<Target Name="_PolySharpRemoveAnalyzersForRoslyn3"
1212
Condition="'$(CSharpCoreTargetsPath)' != ''"
1313
AfterTargets="ResolvePackageDependenciesForBuild;ResolveNuGetPackageAssets"
@@ -29,10 +29,10 @@
2929
<PolySharpCurrentCompilerVersion>@(PolySharpCurrentCompilerAssemblyIdentity->'%(Version)')</PolySharpCurrentCompilerVersion>
3030

3131
<!-- The CurrentCompilerVersionIsNotNewEnough property can now be defined based on the Roslyn assembly version -->
32-
<PolySharpCurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(PolySharpCurrentCompilerVersion), 4.14))">true</PolySharpCurrentCompilerVersionIsNotNewEnough>
32+
<PolySharpCurrentCompilerVersionIsNotNewEnough Condition="$([MSBuild]::VersionLessThan($(PolySharpCurrentCompilerVersion), 4.3))">true</PolySharpCurrentCompilerVersionIsNotNewEnough>
3333
</PropertyGroup>
3434

35-
<!-- If the Roslyn version is < 4.14, disable the source generators -->
35+
<!-- If the Roslyn version is < 4.3, disable the source generators -->
3636
<ItemGroup Condition ="'$(PolySharpCurrentCompilerVersionIsNotNewEnough)' == 'true'">
3737
<Analyzer Remove="@(_PolySharpAnalyzer)"/>
3838
</ItemGroup>
@@ -44,7 +44,7 @@
4444
-->
4545
<Error Condition ="'$(PolySharpCurrentCompilerVersionIsNotNewEnough)' == 'true'"
4646
Code="POLYSPCFG0001"
47-
Text="The PolySharp source generators have been disabled on the current configuration, as they need Roslyn 4.14 in order to work. PolySharp requires the source generators to run in order to generate polyfills, so the library cannot be used without a more up to date IDE (eg. VS 2022 17.14 or greater) or .NET SDK version (.NET 8.0.411 SDK or greater)."/>
47+
Text="The PolySharp source generators have been disabled on the current configuration, as they need Roslyn 4.3 in order to work. PolySharp requires the source generators to run in order to generate polyfills, so the library cannot be used without a more up to date IDE (eg. VS 2022 17.3 or greater) or .NET SDK version (.NET 6.0.400 SDK or greater)."/>
4848
</Target>
4949

5050
<!-- Remove the analyzer if Roslyn is missing -->

src/PolySharp.SourceGenerators/PolyfillsGenerator.Polyfills.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,23 @@ from string resourceName in typeof(PolyfillsGenerator).Assembly.GetManifestResou
3535
/// <summary>
3636
/// The collection of fully qualified type names for language support types.
3737
/// </summary>
38-
private static readonly ImmutableArray<string> LanguageSupportTypeNames = [..
38+
private static readonly ImmutableArray<string> LanguageSupportTypeNames = ImmutableArray.CreateRange(
3939
from KeyValuePair<string, string> resource in FullyQualifiedTypeNamesToResourceNames
4040
where resource.Value.StartsWith("PolySharp.SourceGenerators.EmbeddedResources.LanguageSupport.")
41-
select resource.Key];
41+
select resource.Key);
4242

4343
/// <summary>
4444
/// The collection of fully qualified type names for runtime supported types.
4545
/// </summary>
46-
private static readonly ImmutableArray<string> RuntimeSupportedTypeNames = [..
46+
private static readonly ImmutableArray<string> RuntimeSupportedTypeNames = ImmutableArray.CreateRange(
4747
from KeyValuePair<string, string> resource in FullyQualifiedTypeNamesToResourceNames
4848
where resource.Value.StartsWith("PolySharp.SourceGenerators.EmbeddedResources.RuntimeSupported.")
49-
select resource.Key];
49+
select resource.Key);
5050

5151
/// <summary>
5252
/// The collection of all fully qualified type names for available polyfill types.
5353
/// </summary>
54-
private static readonly ImmutableArray<string> AllSupportTypeNames = [.. LanguageSupportTypeNames.Concat(RuntimeSupportedTypeNames)];
54+
private static readonly ImmutableArray<string> AllSupportTypeNames = ImmutableArray.CreateRange(LanguageSupportTypeNames.Concat(RuntimeSupportedTypeNames));
5555

5656
/// <summary>
5757
/// The <see cref="Regex"/> to find all <see cref="System.Runtime.CompilerServices.MethodImplOptions"/> uses.
@@ -117,7 +117,7 @@ private static ImmutableArray<AvailableType> GetAvailableTypes(Compilation compi
117117
// A minimum of C# 8.0 is required to benefit from the polyfills
118118
if (!compilation.HasLanguageVersionAtLeastEqualTo(LanguageVersion.CSharp8))
119119
{
120-
return [];
120+
return ImmutableArray<AvailableType>.Empty;
121121
}
122122

123123
// Helper function to check whether a type is available

src/PolySharp.SourceGenerators/PolyfillsGenerator.TypeForwards.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ partial class PolyfillsGenerator
1414
/// <summary>
1515
/// The collection of fully qualified type names for types that could require a <c>modreq</c>.
1616
/// </summary>
17-
private static readonly ImmutableArray<string> ModreqCandidateFullyQualifiedTypeNames =
18-
[
17+
private static readonly ImmutableArray<string> ModreqCandidateFullyQualifiedTypeNames = ImmutableArray.Create(
1918
"System.Index",
2019
"System.Range",
2120
"System.Runtime.CompilerServices.IsExternalInit",
22-
"System.Runtime.CompilerServices.RequiresLocationAttribute",
23-
];
21+
"System.Runtime.CompilerServices.RequiresLocationAttribute");
2422

2523
/// <summary>
2624
/// Gets the types from the BCL that should potentially receive type forwards.
@@ -33,7 +31,7 @@ private static ImmutableArray<string> GetCoreLibTypes(Compilation compilation, C
3331
// Same check as when generating polyfills (if none can be generated, there's no need for type forwards)
3432
if (!compilation.HasLanguageVersionAtLeastEqualTo(LanguageVersion.CSharp8))
3533
{
36-
return [];
34+
return ImmutableArray<string>.Empty;
3735
}
3836

3937
IAssemblySymbol coreLibAssemblySymbol = compilation.GetSpecialType(SpecialType.System_Object).ContainingAssembly;

0 commit comments

Comments
 (0)