public void Initialize(IncrementalGeneratorInitializationContext context) { context.RegisterPostInitializationOutput(PostInitializationCallback); IncrementalValueProvider <ImmutableArray <MethodDeclarationSyntax> > syntaxProvider = context.SyntaxProvider .CreateSyntaxProvider(SyntaxProviderPredicate, SyntaxProviderTransform) .Where(static method => method is not null)
public void Initialize(IncrementalGeneratorInitializationContext context) { // Contains one entry per regex method, either the generated code for that regex method, // a diagnostic to fail with, or null if no action should be taken for that regex. IncrementalValueProvider<ImmutableArray<object?>> codeOrDiagnostics = context.SyntaxProvider // Find all MethodDeclarationSyntax nodes attributed with RegexGenerator .CreateSyntaxProvider(static (s, _) => IsSyntaxTargetForGeneration(s), static (ctx, _) => GetSemanticTargetForGeneration(ctx))
public void Initialize(IncrementalGeneratorInitializationContext context) { // To avoid invalidating the generator's output when anything from the compilation // changes, we will extract from it the only thing we care about: whether unsafe // code is allowed. IncrementalValueProvider <bool> allowUnsafeProvider = context.CompilationProvider .Select((x, _) => x.Options is CSharpCompilationOptions { AllowUnsafe: true });
public void Initialize(IncrementalGeneratorInitializationContext context) { // Produces one entry per generated regex. This may be: // - Diagnostic in the case of a failure that should end the compilation // - (RegexMethod regexMethod, string runnerFactoryImplementation, Dictionary<string, string[]> requiredHelpers) in the case of valid regex // - (RegexMethod regexMethod, string reason, Diagnostic diagnostic) in the case of a limited-support regex IncrementalValueProvider <ImmutableArray <object> > codeOrDiagnostics = context.SyntaxProvider // Find all MethodDeclarationSyntax nodes attributed with RegexGenerator and gather the required information. .CreateSyntaxProvider(IsSyntaxTargetForGeneration, GetSemanticTargetForGeneration) .Where(static m => m is not null)
internal static IncrementalValueProvider <T> WithLambdaComparer <T>(this IncrementalValueProvider <T> source, Func <T, T, bool> equal, Func <T, int> getHashCode) { var comparer = new LambdaComparer <T>(equal, getHashCode); return(source.WithComparer(comparer)); }
/// <inheritdoc/> public void Initialize(IncrementalGeneratorInitializationContext context) { // Check whether [SkipLocalsInit] can be used IncrementalValueProvider <bool> canUseSkipLocalsInit = context.CompilationProvider .Select(static (compilation, token) =>
/// <summary> /// Adds a comparer that will force the provider to be considered as cached if the razor options call for suppression /// </summary> internal static IncrementalValuesProvider <T> AsCachedIfSuppressed <T>(this IncrementalValuesProvider <T> provider, IncrementalValueProvider <bool> isSuppressedProvider) where T : notnull { return(provider.Combine(isSuppressedProvider).WithComparer(new RazorSourceGeneratorComparer <T>()).Select((pair, _) => pair.Left)); }
public static IncrementalValueProvider<(ApplicationConfig? ApplicationConfig, Diagnostic? Diagnostic)> ReadApplicationConfig(IncrementalValueProvider<AnalyzerConfigOptionsProvider> configOptionsProvider) => configOptionsProvider.Select(