示例#1
0
 internal SyntaxValueProvider(
     IncrementalGeneratorInitializationContext context,
     ArrayBuilder <SyntaxInputNode> inputNodes,
     Action <IIncrementalGeneratorOutputNode> registerOutput,
     ISyntaxHelper syntaxHelper)
 {
     _context        = context;
     _inputNodes     = inputNodes;
     _registerOutput = registerOutput;
     _syntaxHelper   = syntaxHelper;
 }
        public void Initialize(IncrementalGeneratorInitializationContext context)
        {
            GeneratorInitializationContext generatorInitContext = new GeneratorInitializationContext(CancellationToken.None);

            SourceGenerator.Initialize(generatorInitContext);

            if (generatorInitContext.Callbacks.PostInitCallback is object)
            {
                context.RegisterPostInitializationOutput(generatorInitContext.Callbacks.PostInitCallback);
            }

            var contextBuilderSource = context.CompilationProvider
                                       .Select((c, _) => new GeneratorContextBuilder(c))
                                       .Combine(context.ParseOptionsProvider).Select((p, _) => p.Item1 with {
                ParseOptions = p.Item2
            })