Created
May 5, 2025 10:35
-
-
Save usausa/4fed21613f802bfb9d50bb6fccefeb60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class IncrementalGeneratorInitializationContextExtensions | |
{ | |
public static IncrementalValuesProvider<T> ForAttributeWithMetadataNameWithOptions<T>( | |
this IncrementalGeneratorInitializationContext context, | |
string fullyQualifiedMetadataName, | |
Func<SyntaxNode, CancellationToken, bool> predicate, | |
Func<GeneratorAttributeSyntaxContext, AnalyzerConfigOptions, CancellationToken, T> transform) | |
{ | |
var syntaxContext = context.SyntaxProvider.ForAttributeWithMetadataName( | |
fullyQualifiedMetadataName, | |
predicate, | |
static (context, _) => context); | |
var configOptions = context.AnalyzerConfigOptionsProvider.Select(static (provider, _) => provider.GlobalOptions); | |
return syntaxContext.Combine(configOptions).Select((input, token) => transform(input.Left, input.Right, token)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment