Skip to content

Commit 20559a6

Browse files
committed
Updating inbox source generators to Roslyn 4.4 and removing polyfill approach (dotnet#75717)
1 parent 3056135 commit 20559a6

17 files changed

Lines changed: 64 additions & 44 deletions

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ dotnet_style_object_initializer = true:suggestion
9494
dotnet_style_collection_initializer = true:suggestion
9595
dotnet_style_explicit_tuple_names = true:suggestion
9696
dotnet_style_coalesce_expression = true:suggestion
97-
dotnet_style_null_propagation = true:suggestion
97+
dotnet_style_null_propagation = false:suggestion # Turning off given new warnings that came with the new analyzers and we don't want to take the risk of changing those now
98+
dotnet_style_prefer_compound_assignment = false:suggestion
9899
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
99100
dotnet_style_prefer_inferred_tuple_names = true:suggestion
100101
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion

eng/Versions.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@
3939
This version is a moving target until we ship.
4040
It should never go ahead of the Roslyn version included in the SDK version in dotnet/arcade's global.json to avoid causing breaks in product construction.
4141
-->
42-
<MicrosoftCodeAnalysisVersion_4_X>4.3.0-2.final</MicrosoftCodeAnalysisVersion_4_X>
42+
<MicrosoftCodeAnalysisVersion_4_X>4.4.0-2.22423.18</MicrosoftCodeAnalysisVersion_4_X>
4343
</PropertyGroup>
4444
<PropertyGroup>
4545
<!-- Code analysis dependencies -->
4646
<MicrosoftCodeAnalysisAnalyzersVersion>3.3.3</MicrosoftCodeAnalysisAnalyzersVersion>
47-
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>4.3.0-2.final</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
48-
<MicrosoftCodeAnalysisCSharpWorkspacesVersion>4.3.0-2.final</MicrosoftCodeAnalysisCSharpWorkspacesVersion>
49-
<MicrosoftCodeAnalysisCSharpVersion>4.3.0-2.final</MicrosoftCodeAnalysisCSharpVersion>
47+
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>4.4.0-2.22423.18</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
48+
<MicrosoftCodeAnalysisCSharpWorkspacesVersion>4.4.0-2.22423.18</MicrosoftCodeAnalysisCSharpWorkspacesVersion>
49+
<MicrosoftCodeAnalysisCSharpVersion>4.4.0-2.22423.18</MicrosoftCodeAnalysisCSharpVersion>
5050
<MicrosoftCodeAnalysisNetAnalyzersVersion>7.0.0-preview1.22452.2</MicrosoftCodeAnalysisNetAnalyzersVersion>
51-
<MicrosoftCodeAnalysisVersion>4.3.0-2.final</MicrosoftCodeAnalysisVersion>
51+
<MicrosoftCodeAnalysisVersion>4.4.0-2.22423.18</MicrosoftCodeAnalysisVersion>
5252
<!--
5353
TODO: Remove pinned version once arcade supplies a compiler that enables the repo to compile.
5454
-->

src/libraries/Microsoft.Extensions.Logging.Abstractions/gen/LoggerMessageGenerator.Roslyn4.0.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
using System.Text;
88
using Microsoft.CodeAnalysis;
99
using Microsoft.CodeAnalysis.CSharp.Syntax;
10+
#if !ROSLYN4_4_OR_GREATER
1011
using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
12+
#endif
1113
using Microsoft.CodeAnalysis.Text;
1214

1315
[assembly: System.Resources.NeutralResourcesLanguage("en-us")]
@@ -21,7 +23,9 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
2123
{
2224
IncrementalValuesProvider<ClassDeclarationSyntax> classDeclarations = context.SyntaxProvider
2325
.ForAttributeWithMetadataName(
26+
#if !ROSLYN4_4_OR_GREATER
2427
context,
28+
#endif
2529
Parser.LoggerMessageAttribute,
2630
(node, _) => node is MethodDeclarationSyntax,
2731
(context, _) => context.TargetNode.Parent as ClassDeclarationSyntax)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<AnalyzerRoslynVersion>4.4</AnalyzerRoslynVersion>
5+
<RoslynApiVersion>$(MicrosoftCodeAnalysisVersion_4_X)</RoslynApiVersion>
6+
<DefineConstants>$(DefineConstants);ROSLYN4_0_OR_GREATER;ROSLYN4_4_OR_GREATER</DefineConstants>
7+
</PropertyGroup>
8+
9+
<Import Project="Microsoft.Extensions.Logging.Generators.targets" />
10+
11+
<ItemGroup>
12+
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ValueListBuilder.cs" Link="Production\ValueListBuilder.cs" />
13+
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ValueListBuilder.Pop.cs" Link="Production\ValueListBuilder.Pop.cs" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<Compile Remove="LoggerMessageGenerator.Roslyn3.11.cs" />
18+
</ItemGroup>
19+
20+
</Project>

src/libraries/Microsoft.Extensions.Logging.Abstractions/src/Microsoft.Extensions.Logging.Abstractions.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ Microsoft.Extensions.Logging.Abstractions.NullLogger</PackageDescription>
4545
<AnalyzerReference Include="..\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj"
4646
Pack="true"
4747
ReferenceAnalyzer="false" />
48+
<AnalyzerReference Include="..\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.4.csproj"
49+
Pack="true"
50+
ReferenceAnalyzer="false" />
4851
</ItemGroup>
4952

5053
</Project>

src/libraries/Microsoft.Internal.Runtime.AspNetCore.Transport/src/Microsoft.Internal.Runtime.AspNetCore.Transport.proj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
PrivateAssets="all"
2121
Private="true"
2222
IncludeReferenceAssemblyInPackage="true" />
23-
<!-- Only include the 4.0 version in the ref pack, since targeting net6.0 requires Roslyn 4.0 -->
24-
<AnalyzerReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.0.csproj"
23+
<!-- Only include the 4.4 version in the ref pack, since targeting net7.0 requires Roslyn 4.4 -->
24+
<AnalyzerReference Include="$(LibrariesProjectRoot)Microsoft.Extensions.Logging.Abstractions\gen\Microsoft.Extensions.Logging.Generators.Roslyn4.4.csproj"
2525
Pack="true"
2626
ReferenceAnalyzer="false" />
2727
</ItemGroup>

src/libraries/NetCoreAppLibrary.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
<NetCoreAppLibraryGenerator>
186186
LibraryImportGenerator;
187187
JSImportGenerator;
188-
System.Text.Json.SourceGeneration.Roslyn4.0;
188+
System.Text.Json.SourceGeneration.Roslyn4.4;
189189
System.Text.RegularExpressions.Generator;
190190
</NetCoreAppLibraryGenerator>
191191
<AspNetCoreAppLibrary>

src/libraries/System.Private.CoreLib/gen/EventSourceGenerator.Parser.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Threading;
1010
using Microsoft.CodeAnalysis;
1111
using Microsoft.CodeAnalysis.CSharp.Syntax;
12-
using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
1312

1413
namespace Generators
1514
{

src/libraries/System.Private.CoreLib/gen/EventSourceGenerator.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Threading;
88
using Microsoft.CodeAnalysis;
99
using Microsoft.CodeAnalysis.CSharp.Syntax;
10-
using Microsoft.CodeAnalysis.DotnetRuntime.Extensions;
1110

1211
namespace Generators
1312
{
@@ -40,7 +39,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
4039

4140
IncrementalValuesProvider<EventSourceClass> eventSourceClasses =
4241
context.SyntaxProvider.ForAttributeWithMetadataName(
43-
context,
4442
EventSourceAutoGenerateAttribute,
4543
(node, _) => node is ClassDeclarationSyntax,
4644
GetSemanticTargetForGeneration)

src/libraries/System.Private.CoreLib/gen/System.Private.CoreLib.Generators.csproj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,6 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<Compile Include="$(CommonPath)Roslyn\GetBestTypeByMetadataName.cs" Link="Common\Roslyn\GetBestTypeByMetadataName.cs" />
17-
<Compile Include="$(CommonPath)Roslyn\Hash.cs" Link="Common\Roslyn\Hash.cs" />
18-
<Compile Include="$(CommonPath)Roslyn\ISyntaxHelper.cs" Link="Common\Roslyn\ISyntaxHelper.cs" />
19-
<Compile Include="$(CommonPath)Roslyn\CSharpSyntaxHelper.cs" Link="Common\Roslyn\CSharpSyntaxHelper.cs" />
20-
<Compile Include="$(CommonPath)Roslyn\GlobalAliases.cs" Link="Common\Roslyn\GlobalAliases.cs" />
21-
<Compile Include="$(CommonPath)Roslyn\SyntaxNodeGrouping.cs" Link="Common\Roslyn\SyntaxNodeGrouping.cs" />
22-
<Compile Include="$(CommonPath)Roslyn\SyntaxValueProvider.ImmutableArrayValueComparer.cs" Link="Common\Roslyn\SyntaxValueProvider.ImmutableArrayValueComparer.cs" />
23-
<Compile Include="$(CommonPath)Roslyn\SyntaxValueProvider_ForAttributeWithMetadataName.cs" Link="Common\Roslyn\SyntaxValueProvider_ForAttributeWithMetadataName.cs" />
24-
<Compile Include="$(CommonPath)Roslyn\SyntaxValueProvider_ForAttributeWithSimpleName.cs" Link="Common\Roslyn\SyntaxValueProvider_ForAttributeWithSimpleName.cs" />
25-
2616
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ValueListBuilder.cs" Link="Production\ValueListBuilder.cs" />
2717
<Compile Include="$(CoreLibSharedDir)System\Collections\Generic\ValueListBuilder.Pop.cs" Link="Production\ValueListBuilder.Pop.cs" />
2818
</ItemGroup>

0 commit comments

Comments
 (0)