public void Adding_Another_Generator_Makes_TryApplyEdits_Fail() { var source = @" class C { } "; var parseOptions = TestOptions.Regular; Compilation compilation = CreateCompilation(source, options: TestOptions.DebugDll, parseOptions: parseOptions); compilation.VerifyDiagnostics(); Assert.Single(compilation.SyntaxTrees); SingleFileTestGenerator testGenerator1 = new SingleFileTestGenerator("public class D { }"); SingleFileTestGenerator2 testGenerator2 = new SingleFileTestGenerator2("public class E { }"); GeneratorDriver driver = new CSharpGeneratorDriver(parseOptions, generators: ImmutableArray.Create <ISourceGenerator>(testGenerator1), optionsProvider: CompilerAnalyzerConfigOptionsProvider.Empty, additionalTexts: ImmutableArray <AdditionalText> .Empty); driver = driver.RunFullGeneration(compilation, out var outputCompilation, out _); Assert.Equal(2, outputCompilation.SyntaxTrees.Count()); // try apply edits driver = driver.TryApplyEdits(compilation, out _, out bool success); Assert.True(success); // add another generator driver = driver.AddGenerators(ImmutableArray.Create <ISourceGenerator>(testGenerator2)); // try apply changes should now fail driver = driver.TryApplyEdits(compilation, out _, out success); Assert.False(success); // full generation driver = driver.RunFullGeneration(compilation, out outputCompilation, out _); Assert.Equal(3, outputCompilation.SyntaxTrees.Count()); // try apply changes should now succeed driver.TryApplyEdits(compilation, out _, out success); Assert.True(success); }