Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
544fa8a
Update out-of-band generators to explicitly reference pinned versions…
jkoritzinsky Jan 15, 2022
1e4f98f
Update Roslyn and update the DllImportGenerator incremental generatio…
jkoritzinsky Jan 19, 2022
1f5ea02
Bump Roslyn to get the bugfix and finish updating the incremental gen…
jkoritzinsky Jan 21, 2022
cbe6dc2
Merge branch 'main' into update-roslyn
jkoritzinsky Jan 21, 2022
4e491b2
Merge branch 'main' of github.com:dotnet/runtime into update-roslyn
jkoritzinsky Feb 4, 2022
8cdb7d0
Escape per CS8981 throughout the repo.
jkoritzinsky Feb 4, 2022
c40fcb2
Fix build
jkoritzinsky Feb 7, 2022
0b06bd9
Import test_dependencies' nuget-generated props/targets since we don'…
jkoritzinsky Feb 9, 2022
bfc324a
Merge branch 'main' of github.com:dotnet/runtime into update-roslyn
jkoritzinsky Feb 9, 2022
cd57d2b
Unify roslyn version.
jkoritzinsky Feb 9, 2022
4a7b84d
Remove some extraneous escapes in comments
jkoritzinsky Feb 9, 2022
ea30f83
Fix build failures other than the binary/text issue.
jkoritzinsky Feb 10, 2022
979ca2f
Merge branch 'main' of github.com:dotnet/runtime into update-roslyn
jkoritzinsky Feb 18, 2022
1bb9514
Update compiler toolset to get dotnet/roslyn#59578
jkoritzinsky Feb 18, 2022
bfb3115
Update Roslyn version again to get latest fix.
jkoritzinsky Feb 23, 2022
100f65c
Merge branch 'main' into update-roslyn
jkoritzinsky Feb 24, 2022
b44c0ec
PR feedback and update Roslyn again now that Chris has actually put i…
jkoritzinsky Feb 28, 2022
cc60244
Disable capitalization warning in the src/tests tree
jkoritzinsky Mar 2, 2022
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
20 changes: 13 additions & 7 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<UsingToolMicrosoftNetILLinkTasks>true</UsingToolMicrosoftNetILLinkTasks>
<UsingToolIbcOptimization>false</UsingToolIbcOptimization>
<UsingToolXliff>false</UsingToolXliff>
<UsingToolMicrosoftNetCompilers>true</UsingToolMicrosoftNetCompilers>
<LastReleasedStableAssemblyVersion>$(AssemblyVersion)</LastReleasedStableAssemblyVersion>
</PropertyGroup>
<!--
Expand All @@ -39,18 +40,23 @@
<!-- Targeting packs are only patched in extreme cases. -->
<ProjectServicingConfiguration Include="Microsoft.NETCore.App.Ref" PatchVersion="0" />
</ItemGroup>
<!--
For source generator support we need to target multiple versions of Rolsyn in order to be able to run on older versions of Roslyn.
We pin these versions as we need to match them exactly for any scenarios that run Roslyn on .NET Framework, like Visual Studio.
-->
<PropertyGroup>
<!-- For source generator support we need to target multiple versions of Rolsyn in order to be able to run on older versions of Roslyn -->
<MicrosoftCodeAnalysisCSharpWorkspacesVersion_3_11>3.11.0</MicrosoftCodeAnalysisCSharpWorkspacesVersion_3_11>
<MicrosoftCodeAnalysisCSharpWorkspacesVersion>4.0.1</MicrosoftCodeAnalysisCSharpWorkspacesVersion>
<MicrosoftCodeAnalysisVersion>4.0.1</MicrosoftCodeAnalysisVersion>
<MicrosoftCodeAnalysisVersion_3_11>3.11.0</MicrosoftCodeAnalysisVersion_3_11>
<MicrosoftCodeAnalysisVersion_4_0>4.0.1</MicrosoftCodeAnalysisVersion_4_0>
</PropertyGroup>
<PropertyGroup>
<!-- Code analysis dependencies -->
<MicrosoftCodeAnalysisAnalyzersVersion>3.3.2</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>4.0.1</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisCSharpVersion>4.0.1</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisAnalyzersVersion>3.3.3</MicrosoftCodeAnalysisAnalyzersVersion>
<MicrosoftCodeAnalysisCSharpCodeStyleVersion>4.2.0-1.22070.6</MicrosoftCodeAnalysisCSharpCodeStyleVersion>
<MicrosoftCodeAnalysisCSharpWorkspacesVersion>4.2.0-1.22070.6</MicrosoftCodeAnalysisCSharpWorkspacesVersion>
<MicrosoftCodeAnalysisCSharpVersion>4.2.0-1.22070.6</MicrosoftCodeAnalysisCSharpVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>7.0.0-preview1.22067.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisVersion>4.2.0-1.22070.6</MicrosoftCodeAnalysisVersion>
<MicrosoftNetCompilersToolsetVersion>4.2.0-1.22070.6</MicrosoftNetCompilersToolsetVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Visual Studio does this require?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, using the toolset package doesn't require a given VS version to match, but I don't remember the specifics.

<!-- SDK dependencies -->
<MicrosoftDotNetCompatibilityVersion>2.0.0-alpha.1.21525.11</MicrosoftDotNetCompatibilityVersion>
<!-- Arcade dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static bool DepaddingRequired(PaddingMode padding)

public static int GetPaddingLength(ReadOnlySpan<byte> block, PaddingMode paddingMode, int blockSize)
{
int padBytes = 0;
int padBytes;

// See PadBlock for a description of the padding modes.
switch (paddingMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<DisableImplicitAssemblyReferences>false</DisableImplicitAssemblyReferences>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsPackable>true</IsPackable>
<!-- CS8981: The type name 'libc' only contains lower-cased ascii characters. Such names may become reserved for the language. -->
<NoWarn>$(NoWarn);CS8981</NoWarn>
</PropertyGroup>

<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AnalyzerRoslynVersion>3.11</AnalyzerRoslynVersion>
<RoslynApiVersion>$(MicrosoftCodeAnalysisCSharpWorkspacesVersion_3_11)</RoslynApiVersion>
<RoslynApiVersion>$(MicrosoftCodeAnalysisVersion_3_11)</RoslynApiVersion>
</PropertyGroup>

<Import Project="Microsoft.Extensions.Logging.Generators.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<AnalyzerRoslynVersion>4.0</AnalyzerRoslynVersion>
<RoslynApiVersion>$(MicrosoftCodeAnalysisCSharpWorkspacesVersion)</RoslynApiVersion>
<RoslynApiVersion>$(MicrosoftCodeAnalysisVersion_4_0)</RoslynApiVersion>
<DefineConstants>$(DefineConstants);ROSLYN4_0_OR_GREATER</DefineConstants>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RoslynApiVersion>$(MicrosoftCodeAnalysisCSharpWorkspacesVersion_3_11)</RoslynApiVersion>
<RoslynApiVersion>$(MicrosoftCodeAnalysisVersion_3_11)</RoslynApiVersion>
<IsHighAotMemoryUsageTest>true</IsHighAotMemoryUsageTest>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<RoslynApiVersion>$(MicrosoftCodeAnalysisCSharpWorkspacesVersion)</RoslynApiVersion>
<RoslynApiVersion>$(MicrosoftCodeAnalysisVersion_4_0)</RoslynApiVersion>
<DefineConstants>$(DefineConstants);ROSLYN4_0_OR_GREATER</DefineConstants>
<IsHighAotMemoryUsageTest>true</IsHighAotMemoryUsageTest>
<EmccLinkOptimizationFlag Condition="'$(ContinuousIntegrationBuild)' == 'true'">-O1</EmccLinkOptimizationFlag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ private static string PunycodeEncode(string unicode)
/* handled already. Find the next larger one: */
int j;
int m;
int test = 0;
int test;
for (m = c_maxint, j = iAfterLastDot;
j < iNextDot;
j += IsSupplementary(test) ? 2 : 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,14 @@ public override int GetHashCode()
}
}

public class IncrementalityTracker
public static class StepNames
{
public enum StepName
{
CalculateStubInformation,
GenerateSingleStub,
NormalizeWhitespace,
ConcatenateStubs,
OutputSourceFile
}

public record ExecutedStepInfo(StepName Step, object Input);

private readonly List<ExecutedStepInfo> _executedSteps = new();
public IEnumerable<ExecutedStepInfo> ExecutedSteps => _executedSteps;

internal void RecordExecutedStep(ExecutedStepInfo step) => _executedSteps.Add(step);
public const string CalculateStubInformation = nameof(CalculateStubInformation);
public const string GenerateSingleStub = nameof(GenerateSingleStub);
public const string NormalizeWhitespace = nameof(NormalizeWhitespace);
public const string ConcatenateStubs = nameof(ConcatenateStubs);
}

/// <summary>
/// This property provides a test-only hook to enable testing the incrementality of the source generator.
/// This will be removed when https://github.com/dotnet/roslyn/issues/54832 is implemented and can be consumed.
/// </summary>
public IncrementalityTracker? IncrementalTracker { get; set; }

public void Initialize(IncrementalGeneratorInitializationContext context)
{
var attributedMethods = context.SyntaxProvider
Expand Down Expand Up @@ -123,7 +106,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
});

IncrementalValueProvider<DllImportGeneratorOptions> stubOptions = context.AnalyzerConfigOptionsProvider
.Select((options, ct) => new DllImportGeneratorOptions(options.GlobalOptions));
.Select(static (options, ct) => new DllImportGeneratorOptions(options.GlobalOptions));

IncrementalValueProvider<StubEnvironment> stubEnvironment = compilationAndTargetFramework
.Combine(stubOptions)
Expand All @@ -146,34 +129,24 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
Environment = data.Right
})
.Select(
(data, ct) =>
{
IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.CalculateStubInformation, data));
return (data.Syntax, StubContext: CalculateStubInformation(data.Symbol, data.Environment, ct));
}
static (data, ct) => (data.Syntax, StubContext: CalculateStubInformation(data.Symbol, data.Environment, ct))
)
.WithComparer(Comparers.CalculatedContextWithSyntax)
.WithTrackingName(StepNames.CalculateStubInformation)
.Combine(stubOptions)
.Select(
(data, ct) =>
{
IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.GenerateSingleStub, data));
return GenerateSource(data.Left.StubContext, data.Left.Syntax, data.Right);
}
static (data, ct) => GenerateSource(data.Left.StubContext, data.Left.Syntax, data.Right)
)
.WithComparer(Comparers.GeneratedSyntax)
.WithTrackingName(StepNames.GenerateSingleStub)
// Handle NormalizeWhitespace as a separate stage for incremental runs since it is an expensive operation.
.Select(
(data, ct) =>
{
IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.NormalizeWhitespace, data));
return (data.Item1.NormalizeWhitespace().ToFullString(), data.Item2);
})
static (data, ct) => (data.Item1.NormalizeWhitespace().ToFullString(), data.Item2))
.WithTrackingName(StepNames.NormalizeWhitespace)
.Collect()
.WithComparer(Comparers.GeneratedSourceSet)
.Select((generatedSources, ct) =>
.Select(static (generatedSources, ct) =>
{
IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.ConcatenateStubs, generatedSources));
StringBuilder source = new();
// Mark in source that the file is auto-generated.
source.AppendLine("// <auto-generated/>");
Expand All @@ -185,12 +158,12 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
}
return (source: source.ToString(), diagnostics: diagnostics.ToImmutable());
})
.WithComparer(Comparers.GeneratedSource);
.WithComparer(Comparers.GeneratedSource)
.WithTrackingName(StepNames.ConcatenateStubs);

context.RegisterSourceOutput(methodSourceAndDiagnostics,
(context, data) =>
static (context, data) =>
{
IncrementalTracker?.RecordExecutedStep(new IncrementalityTracker.ExecutedStepInfo(IncrementalityTracker.StepName.OutputSourceFile, data));
foreach (Diagnostic diagnostic in data.Item2)
{
context.ReportDiagnostic(diagnostic);
Expand Down Expand Up @@ -447,7 +420,7 @@ private static IncrementalStubGenerationContext CalculateStubInformation(IMethod
return new IncrementalStubGenerationContext(environment, dllImportStub, additionalAttributes.ToImmutableArray(), stubDllImportData, generatorDiagnostics.Diagnostics.ToImmutableArray());
}

private (MemberDeclarationSyntax, ImmutableArray<Diagnostic>) GenerateSource(
private static (MemberDeclarationSyntax, ImmutableArray<Diagnostic>) GenerateSource(
IncrementalStubGenerationContext dllImportStub,
MethodDeclarationSyntax originalSyntax,
DllImportGeneratorOptions options)
Expand Down Expand Up @@ -502,7 +475,7 @@ private static IncrementalStubGenerationContext CalculateStubInformation(IMethod
return (PrintGeneratedSource(originalSyntax, dllImportStub.StubContext, code), dllImportStub.Diagnostics.AddRange(diagnostics.Diagnostics));
}

private MemberDeclarationSyntax PrintForwarderStub(MethodDeclarationSyntax userDeclaredMethod, IncrementalStubGenerationContext stub)
private static MemberDeclarationSyntax PrintForwarderStub(MethodDeclarationSyntax userDeclaredMethod, IncrementalStubGenerationContext stub)
{
SyntaxTokenList modifiers = StripTriviaFromModifiers(userDeclaredMethod.Modifiers);
modifiers = AddToModifiers(modifiers, SyntaxKind.ExternKeyword);
Expand Down
Loading