Beispiel #1
0
                public override GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver)
                {
                    var oldText = _oldState.AdditionalText;
                    var newText = _newState.AdditionalText;

                    return(generatorDriver.ReplaceAdditionalText(oldText, newText));
                }
Beispiel #2
0
                public override GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver)
                {
                    var oldText = _oldState.AdditionalText;
                    var newText = _newState.AdditionalText;

                    // TODO: have the compiler add an API for replacing an additional text
                    // https://github.com/dotnet/roslyn/issues/54087
                    return(generatorDriver.RemoveAdditionalTexts(ImmutableArray.Create(oldText))
                           .AddAdditionalTexts(ImmutableArray.Create(newText)));
                }
Beispiel #3
0
 public override GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver)
 {
     if (_isAnalyzerConfigChange)
     {
         return(generatorDriver.WithUpdatedAnalyzerConfigOptions(_state.AnalyzerOptions.AnalyzerConfigOptionsProvider));
     }
     else
     {
         // Changing any other option is fine and the driver can be reused. The driver
         // will get the new compilation once we pass it to it.
         return(generatorDriver);
     }
 }
Beispiel #4
0
 public override GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver)
 {
     if (_isParseOptionChange)
     {
         RoslynDebug.AssertNotNull(_state.ParseOptions);
         return(generatorDriver.WithUpdatedParseOptions(_state.ParseOptions));
     }
     else
     {
         // We are using this as a way to reorder syntax trees -- we don't need to do anything as the driver
         // will get the new compilation once we pass it to it.
         return(generatorDriver);
     }
 }
                public override GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver)
                {
                    if (!_referencesToRemove.IsDefaultOrEmpty)
                    {
                        generatorDriver = generatorDriver.RemoveGenerators(_referencesToRemove.SelectMany(r => r.GetGenerators(_language)).ToImmutableArray());
                    }

                    if (!_referencesToAdd.IsDefaultOrEmpty)
                    {
                        generatorDriver = generatorDriver.AddGenerators(_referencesToAdd.SelectMany(r => r.GetGenerators(_language)).ToImmutableArray());
                    }

                    return(generatorDriver);
                }
Beispiel #6
0
 public override GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver)
 {
     if (_isAnalyzerConfigChange)
     {
         // TODO: update the existing generator driver; the compiler needs to add an API for that.
         // In the mean time, drop it and we'll recreate it from scratch.
         // https://github.com/dotnet/roslyn/issues/54087
         return(null);
     }
     else
     {
         // Changing any other option is fine and the driver can be reused. The driver
         // will get the new compilation once we pass it to it.
         return(generatorDriver);
     }
 }
Beispiel #7
0
 public override GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver)
 {
     if (_isParseOptionChange)
     {
         // TODO: update the existing generator driver; the compiler needs to add an API for that.
         // In the mean time, drop it and we'll recreate it from scratch.
         // https://github.com/dotnet/roslyn/issues/54087
         return(null);
     }
     else
     {
         // We are using this as a way to reorder syntax trees -- we don't need to do anything as the driver
         // will get the new compilation once we pass it to it.
         return(generatorDriver);
     }
 }
Beispiel #8
0
 public override GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver)
 {
     return(generatorDriver.RemoveAdditionalTexts(_additionalDocuments.SelectAsArray(static documentState => documentState.AdditionalText)));
Beispiel #9
0
 public override GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver)
 {
     return(generatorDriver.RemoveGenerators(_analyzerReferences.SelectMany(r => r.GetGenerators(_language)).ToImmutableArray()));
 }
 public virtual GeneratorDriver?TransformGeneratorDriver(GeneratorDriver generatorDriver) => generatorDriver;
Beispiel #11
0
 public void CacheGenerator(string cacheKey, GeneratorDriver driver) => AddOrUpdateMostRecentlyUsed(cacheKey, driver);
 internal TrackedGeneratorDriver(GeneratorDriver generatorDriver, bool needsFullGeneration)
 {
     GeneratorDriver     = generatorDriver;
     NeedsFullGeneration = needsFullGeneration;
 }