* Refactoring `GeneratedKind.Generated` to `GeneratedKind.MarkedGenerated`,...

* Refactoring `GeneratedKind.Generated` to `GeneratedKind.MarkedGenerated`, giving us better future ability to add something like `InferredGenerated` if we want to expose a heuristic.
* Added documentation comments.
上级 c1ea403e
......@@ -725,7 +725,7 @@ internal bool IsGeneratedCode(SyntaxTreeOptionsProvider? provider, CancellationT
return provider?.IsGenerated(this, cancellationToken) switch
{
null or GeneratedKind.Unknown => isGeneratedHeuristic(),
GeneratedKind kind => kind == GeneratedKind.Generated
GeneratedKind kind => kind == GeneratedKind.MarkedGenerated
};
bool isGeneratedHeuristic()
......@@ -737,10 +737,10 @@ bool isGeneratedHeuristic()
this,
isComment: trivia => trivia.Kind() == SyntaxKind.SingleLineCommentTrivia || trivia.Kind() == SyntaxKind.MultiLineCommentTrivia,
cancellationToken: default);
_lazyIsGeneratedCode = isGenerated ? GeneratedKind.Generated : GeneratedKind.NotGenerated;
_lazyIsGeneratedCode = isGenerated ? GeneratedKind.MarkedGenerated : GeneratedKind.NotGenerated;
}
return _lazyIsGeneratedCode == GeneratedKind.Generated;
return _lazyIsGeneratedCode == GeneratedKind.MarkedGenerated;
}
}
......
......@@ -5711,10 +5711,10 @@ static void J(object x)
#pragma warning restore CS0618
var syntaxOptions = new TestSyntaxTreeOptionsProvider(
(source1, GeneratedKind.Generated),
(source1, GeneratedKind.MarkedGenerated),
(source2, GeneratedKind.NotGenerated),
(source3, GeneratedKind.Unknown),
(source4, GeneratedKind.Generated)
(source4, GeneratedKind.MarkedGenerated)
);
var comp = CreateCompilation(new[] { source1, source2, source3, source4 },
......@@ -6,8 +6,17 @@ namespace Microsoft.CodeAnalysis
{
public enum GeneratedKind
{
/// <summary>
/// Whether the <see cref="SyntaxTree"/> is automatically generated is unknown.
/// </summary>
Unknown,
/// <summary>
/// The <see cref="SyntaxTree"/> is not automatically generated.
/// </summary>
NotGenerated,
Generated
/// <summary>
/// The <see cref="SyntaxTree"/> is marked as automatically generated.
/// </summary>
MarkedGenerated
}
}
......@@ -154,7 +154,7 @@ internal static GeneratedKind GetIsGeneratedCodeFromOptions(ImmutableDictionary<
if (options.TryGetValue("generated_code", out string? optionValue) &&
bool.TryParse(optionValue, out var boolValue))
{
return boolValue ? GeneratedKind.Generated : GeneratedKind.NotGenerated;
return boolValue ? GeneratedKind.MarkedGenerated : GeneratedKind.NotGenerated;
}
// Either no explicit user configuration or we don't recognize the option value.
......
......@@ -16,7 +16,7 @@ Microsoft.CodeAnalysis.Diagnostics.CompilationWithAnalyzers.GetAnalysisResultAsy
Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.AdditionalFileActionsCount.get -> int
Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.AdditionalFileActionsCount.set -> void
Microsoft.CodeAnalysis.GeneratedKind
Microsoft.CodeAnalysis.GeneratedKind.Generated = 2 -> Microsoft.CodeAnalysis.GeneratedKind
Microsoft.CodeAnalysis.GeneratedKind.MarkedGenerated = 2 -> Microsoft.CodeAnalysis.GeneratedKind
Microsoft.CodeAnalysis.GeneratedKind.NotGenerated = 1 -> Microsoft.CodeAnalysis.GeneratedKind
Microsoft.CodeAnalysis.GeneratedKind.Unknown = 0 -> Microsoft.CodeAnalysis.GeneratedKind
Microsoft.CodeAnalysis.GeneratorDriver.RemoveAdditionalTexts(System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.AdditionalText> additionalTexts) -> Microsoft.CodeAnalysis.GeneratorDriver
......@@ -84,4 +84,4 @@ Microsoft.CodeAnalysis.GeneratorRunResult.Generator.get -> Microsoft.CodeAnalysi
*REMOVED*Microsoft.CodeAnalysis.SourceGeneratorContext.SyntaxReceiver.get -> Microsoft.CodeAnalysis.ISyntaxReceiver
*REMOVED*Microsoft.CodeAnalysis.GeneratorDriver.RunFullGeneration(Microsoft.CodeAnalysis.Compilation compilation, out Microsoft.CodeAnalysis.Compilation outputCompilation, out System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Diagnostic> diagnostics, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.GeneratorDriver
*REMOVED*Microsoft.CodeAnalysis.InitializationContext.InitializationContext() -> void
*REMOVED*Microsoft.CodeAnalysis.SourceGeneratorContext.SourceGeneratorContext() -> void
\ No newline at end of file
*REMOVED*Microsoft.CodeAnalysis.SourceGeneratorContext.SourceGeneratorContext() -> void
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册