diff --git a/src/Compilers/CSharp/Portable/CommandLine/CSharpCompiler.cs b/src/Compilers/CSharp/Portable/CommandLine/CSharpCompiler.cs index 2be61b2562537..a9a55c15a7b5a 100644 --- a/src/Compilers/CSharp/Portable/CommandLine/CSharpCompiler.cs +++ b/src/Compilers/CSharp/Portable/CommandLine/CSharpCompiler.cs @@ -375,7 +375,7 @@ protected override void ResolveEmbeddedFilesFromExternalSourceDirectives( private protected override GeneratorDriver CreateGeneratorDriver(string baseDirectory, ParseOptions parseOptions, ImmutableArray generators, AnalyzerConfigOptionsProvider analyzerConfigOptionsProvider, ImmutableArray additionalTexts) { - return CSharpGeneratorDriver.Create(generators, additionalTexts, (CSharpParseOptions)parseOptions, analyzerConfigOptionsProvider, driverOptions: new GeneratorDriverOptions(disabledOutputs: IncrementalGeneratorOutputKind.Host) { BaseDirectory = baseDirectory }); + return CSharpGeneratorDriver.Create(generators, additionalTexts, (CSharpParseOptions)parseOptions, analyzerConfigOptionsProvider, driverOptions: new GeneratorDriverOptions(disabledOutputs: IncrementalGeneratorOutputKind.Host, baseDirectory: baseDirectory)); } private protected override void DiagnoseBadAccesses(TextWriter consoleOutput, ErrorLogger? errorLogger, Compilation compilation, ImmutableArray diagnostics) diff --git a/src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs b/src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs index 81186331e0965..8add99ff84be8 100644 --- a/src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs +++ b/src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs @@ -807,7 +807,11 @@ class XAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create( + [generator], + parseOptions: parseOptions, + driverOptions: TestOptions.GeneratorDriverOptions); + driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; diff --git a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs index 73b6015837bdd..3389f2b5169e8 100644 --- a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests.cs @@ -1688,7 +1688,7 @@ class C { } })); // run the generator once, and check it was passed the compilation - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1737,7 +1737,7 @@ class C { } })); // run the generator once, and check it was passed the compilation - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, additionalTexts: new[] { text1 }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, additionalTexts: new[] { text1 }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1997,7 +1997,7 @@ class C { } })); // run the generator once, and check it was passed the compilation + additional texts - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, additionalTexts: texts, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, additionalTexts: texts, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -2302,7 +2302,7 @@ public void M() var parseOptions = TestOptions.RegularPreview; Compilation compilation = CreateCompilation(new[] { source1, source2 }, options: TestOptions.DebugExeThrowing, parseOptions: parseOptions); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); verify(ref driver, compilation, new[] { "// WriteLine", @@ -2396,7 +2396,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -2492,7 +2492,11 @@ class C { } })); // run the generator once, and check it was passed the parse options - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(disabledOutputs: IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create( + [generator], + parseOptions: parseOptions, + driverOptions: TestOptions.GeneratorDriverOptions); + driver = driver.RunGenerators(compilation); GeneratorRunResult runResult = driver.GetRunResult().Results[0]; Assert.Single(runResult.TrackedSteps["ParseOptions"]); @@ -2558,7 +2562,11 @@ class C { } })); // run the generator once - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(disabledOutputs: IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create( + [generator], + parseOptions: parseOptions, + driverOptions: new GeneratorDriverOptions(disabledOutputs: IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + driver = driver.RunGenerators(compilation); Assert.True(driver.GetRunResult().Diagnostics.IsEmpty); @@ -2622,7 +2630,7 @@ class C { } var optionsProvider = new CompilerAnalyzerConfigOptionsProvider(ImmutableDictionary.Empty, new DictionaryAnalyzerConfigOptions(builder.ToImmutable())); // run the generator once, and check it was passed the configs - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, optionsProvider: optionsProvider, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, optionsProvider: optionsProvider, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; Assert.Collection(runResult.TrackedSteps["AnalyzerConfig"], @@ -2700,7 +2708,7 @@ class C { } })); // run the generator once and check we saw the additional file - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, additionalTexts: new[] { additionalText1, additionalText2, additionalText3 }, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, additionalTexts: new[] { additionalText1, additionalText2, additionalText3 }, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; Assert.Collection(runResult.TrackedSteps["Paths"], @@ -2890,7 +2898,7 @@ class C { } })); // run the generator once and check we saw the additional file - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, additionalTexts: new[] { additionalText }, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, additionalTexts: new[] { additionalText }, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; Assert.Collection(runResult.TrackedSteps["Path"], @@ -3080,7 +3088,11 @@ class C { } ctx.RegisterHostOutput(ctx.CompilationOptionsProvider, (context, ct) => context.AddOutput("Host", "")); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator.AsSourceGenerator() }, driverOptions: new GeneratorDriverOptions(disabledOutput), parseOptions: parseOptions); + GeneratorDriver driver = CSharpGeneratorDriver.Create( + generators: [generator.AsSourceGenerator()], + driverOptions: new GeneratorDriverOptions(disabledOutput), + parseOptions: parseOptions); + driver = driver.RunGenerators(compilation); var result = driver.GetRunResult(); @@ -3094,7 +3106,7 @@ class C { } if (kind == IncrementalGeneratorOutputKind.None) continue; - if (disabledOutput.HasFlag((IncrementalGeneratorOutputKind)kind)) + if (disabledOutput.HasFlag(kind)) { if (kind == IncrementalGeneratorOutputKind.Host) { @@ -3144,7 +3156,7 @@ class C { } ctx.RegisterImplementationSourceOutput(ctx.MetadataReferencesProvider, (context, ct) => { }); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator.AsSourceGenerator() }, parseOptions: parseOptions, additionalTexts: new[] { new InMemoryAdditionalText("text.txt", "") }, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator.AsSourceGenerator() }, parseOptions: parseOptions, additionalTexts: new[] { new InMemoryAdditionalText("text.txt", "") }, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -3191,7 +3203,7 @@ class C { } ctx.RegisterSourceOutput(ctx.AdditionalTextsProvider, (context, ct) => { }); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator1.AsSourceGenerator(), generator2.AsSourceGenerator() }, parseOptions: parseOptions, additionalTexts: new[] { additionalText }, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator1.AsSourceGenerator(), generator2.AsSourceGenerator() }, parseOptions: parseOptions, additionalTexts: new[] { additionalText }, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); GeneratorDriverRunResult runResult = driver.GetRunResult(); Assert.All(runResult.Results, @@ -3278,7 +3290,7 @@ class C { ctx.RegisterImplementationSourceOutput(ctx.MetadataReferencesProvider, (context, ct) => { }); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator.AsSourceGenerator() }, parseOptions: parseOptions, additionalTexts: new[] { new InMemoryAdditionalText("text.txt", "") }, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator.AsSourceGenerator() }, parseOptions: parseOptions, additionalTexts: new[] { new InMemoryAdditionalText("text.txt", "") }, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); driver.GetRunResult(); } @@ -3307,7 +3319,7 @@ public void Binary_Additional_Files_Do_Not_Throw_When_Compared() GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator.AsSourceGenerator() }, parseOptions: parseOptions, additionalTexts: new[] { additionalText1, additionalText2 }, - driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var result = driver.GetRunResult(); @@ -3346,7 +3358,7 @@ public void Incremental_Generators_Can_Recover_From_Exceptions() GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator.AsSourceGenerator() }, parseOptions: parseOptions, - driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var result = driver.GetRunResult(); @@ -3380,7 +3392,7 @@ public void Timing_Info_Is_Empty_If_Not_Run() }); }).AsSourceGenerator(); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); var timing = driver.GetTimingInfo(); @@ -3409,7 +3421,7 @@ public void Can_Get_Timing_Info() }); }).AsSourceGenerator(); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var timing = driver.GetTimingInfo(); @@ -3449,7 +3461,7 @@ public void Can_Get_Timing_Info_From_Multiple_Generators() }); }).AsSourceGenerator(); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator, generator2 }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator, generator2 }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var timing = driver.GetTimingInfo(); @@ -3488,7 +3500,7 @@ public void Timing_Info_Only_Includes_Last_Run() }); }).AsSourceGenerator(); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); // run once driver = driver.RunGenerators(compilation); @@ -3531,7 +3543,7 @@ public void Returning_Null_From_SelectMany_Gives_Empty_Array() }).AsSourceGenerator(); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult(); @@ -3559,7 +3571,7 @@ class D { (int, bool) _field; }"; ctx.RegisterPostInitializationOutput(c => c.AddSource("D", postInitSource)); }).AsSourceGenerator(); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out compilation, out var diagnostics); compilation.VerifyDiagnostics(); Assert.Empty(diagnostics); @@ -4135,6 +4147,7 @@ public void GetInterceptsLocationSpecifier_01() var generator = new IncrementalGeneratorWrapper(new InterceptorGenerator1()); var parseOptions = TestOptions.RegularPreview.WithFeature("InterceptorsNamespaces", "global"); + var projectDir = TempRoot.Root; var source1 = (""" public class Program @@ -4152,11 +4165,15 @@ namespace System.Runtime.CompilerServices { public class InterceptsLocationAttribute : Attribute { public InterceptsLocationAttribute(int version, string data) { } } } - """, PlatformInformation.IsWindows ? @"C:\project\src\Program.cs" : "/project/src/Program.cs"); + """, Path.Combine(projectDir, "src", "Program.cs")); Compilation compilation = CreateCompilation([source1], options: TestOptions.DebugExe, parseOptions: parseOptions); - GeneratorDriver driver = CSharpGeneratorDriver.Create([generator], parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions() { BaseDirectory = PlatformInformation.IsWindows ? @"C:\project\obj\" : "/project/obj" }); + GeneratorDriver driver = CSharpGeneratorDriver.Create( + [generator], + parseOptions: parseOptions, + driverOptions: new GeneratorDriverOptions(baseDirectory: Path.Combine(projectDir, "obj"))); + verify(ref driver, compilation); void verify(ref GeneratorDriver driver, Compilation compilation) @@ -4518,7 +4535,10 @@ public void GeneratorDriver_No_HostOutputs_WhenDisabled() var parseOptions = CSharpParseOptions.Default; var compilation = CreateCompilation("class Compilation1{}", parseOptions: parseOptions); - GeneratorDriver driver = CSharpGeneratorDriver.Create([generator.AsSourceGenerator()], parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.Host)); + GeneratorDriver driver = CSharpGeneratorDriver.Create( + [generator.AsSourceGenerator()], + parseOptions: parseOptions, + driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.Host)); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult(); diff --git a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_FullyQualifiedName.cs b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_FullyQualifiedName.cs index e671ee50f8dd6..0b80d60c8f2d4 100644 --- a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_FullyQualifiedName.cs +++ b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_FullyQualifiedName.cs @@ -75,7 +75,7 @@ class XAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -117,7 +117,7 @@ class XAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -154,7 +154,7 @@ class XAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -184,7 +184,7 @@ public void FindAssemblyAttribute1(string attribute) ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -214,7 +214,7 @@ public void FindModuleAttribute1(string attribute) ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -241,7 +241,7 @@ public void FindAssemblyAttribute2(string source2) ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -268,7 +268,7 @@ public void FindAssemblyAttribute3(string source1) ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -296,7 +296,7 @@ public void FindAssemblyAttribute4() ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -327,7 +327,7 @@ void LocalFunc() ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -363,7 +363,7 @@ void LocalFunc() ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -402,7 +402,7 @@ void LocalFunc() ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -431,7 +431,7 @@ class C<[CLSCompliant(true)] T> ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -464,7 +464,7 @@ void M() ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -497,7 +497,7 @@ void M() ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -529,7 +529,7 @@ internal partial void M() { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -561,7 +561,7 @@ internal partial void M() { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -592,7 +592,7 @@ class C ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -623,7 +623,7 @@ class C ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -656,7 +656,7 @@ class C ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -687,7 +687,7 @@ class C ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -716,7 +716,7 @@ public void FindParenthesizedLambdaAttribute1() ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -750,7 +750,7 @@ int Prop ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -779,7 +779,7 @@ class C<[CLSCompliant(true)]T> ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -816,7 +816,7 @@ public class InnerAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -853,7 +853,7 @@ public class InnerAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -890,7 +890,7 @@ public class InnerAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -927,7 +927,7 @@ public class InnerAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -964,7 +964,7 @@ public class InnerAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1000,7 +1000,7 @@ public class InnerAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1035,7 +1035,7 @@ class XAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { counter++; }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1072,7 +1072,7 @@ class XAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { counter++; }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1110,7 +1110,7 @@ class YAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { counter++; }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1148,7 +1148,7 @@ class YAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { counter++; }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1186,7 +1186,7 @@ class YAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { counter++; }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1224,7 +1224,7 @@ class YAttribute : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { counter++; }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1337,7 +1337,7 @@ class LibraryImportAttribute(string s) : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - var driver = CSharpGeneratorDriver.Create([generator], parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + var driver = CSharpGeneratorDriver.Create([generator], parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); var runResult = driver.RunGenerators(compilation).GetRunResult().Results[0]; Assert.Collection(runResult.TrackedSteps["result_ForAttributeWithMetadataName"], @@ -1383,7 +1383,7 @@ class LibraryImportAttribute(string s) : System.Attribute { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - var driver = CSharpGeneratorDriver.Create([generator], parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + var driver = CSharpGeneratorDriver.Create([generator], parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); var runResult = driver.RunGenerators(compilation).GetRunResult().Results[0]; Assert.Collection(runResult.TrackedSteps["result_ForAttributeWithMetadataName"], @@ -1421,7 +1421,7 @@ class XAttribute : System.Attribute ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1468,7 +1468,7 @@ class XAttribute : System.Attribute ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1515,7 +1515,7 @@ class XAttribute : System.Attribute ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1558,7 +1558,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1606,7 +1606,7 @@ class C2 { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1659,7 +1659,7 @@ class C2 { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1718,7 +1718,7 @@ class XAttribute : System.Attribute ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1770,7 +1770,7 @@ class XAttribute : System.Attribute ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; diff --git a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_SimpleName.cs b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_SimpleName.cs index 9698bd6ec6414..b0882d7a80536 100644 --- a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_SimpleName.cs +++ b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_SimpleName.cs @@ -6,6 +6,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; +using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Roslyn.Test.Utilities.TestGenerators; using Roslyn.Utilities; @@ -45,7 +46,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -77,7 +78,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -103,7 +104,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -128,7 +129,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -153,7 +154,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -181,7 +182,7 @@ class D { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -213,7 +214,7 @@ class D { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -245,7 +246,7 @@ class D { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -279,7 +280,7 @@ class D { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -312,7 +313,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -338,7 +339,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -364,7 +365,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -390,7 +391,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -423,7 +424,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -451,7 +452,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -479,7 +480,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -506,7 +507,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -537,7 +538,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -570,7 +571,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -602,7 +603,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -634,7 +635,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -662,7 +663,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -690,7 +691,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -718,7 +719,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -745,7 +746,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -772,7 +773,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -801,7 +802,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -832,7 +833,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -862,7 +863,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -891,7 +892,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -919,7 +920,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -947,7 +948,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -976,7 +977,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1008,7 +1009,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1048,7 +1049,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1094,7 +1095,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1147,7 +1148,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1198,7 +1199,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1253,7 +1254,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1306,7 +1307,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1364,7 +1365,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1412,7 +1413,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1457,7 +1458,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1508,7 +1509,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1559,7 +1560,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; @@ -1620,7 +1621,7 @@ class C { } ctx.RegisterSourceOutput(input, (spc, node) => { }); })); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new ISourceGenerator[] { generator }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var runResult = driver.GetRunResult().Results[0]; diff --git a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/SyntaxAwareGeneratorTests.cs b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/SyntaxAwareGeneratorTests.cs index f7cd4a38fb1e4..a170eee006f41 100644 --- a/src/Compilers/CSharp/Test/Semantic/SourceGeneration/SyntaxAwareGeneratorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/SourceGeneration/SyntaxAwareGeneratorTests.cs @@ -12,6 +12,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Roslyn.Test.Utilities; using Roslyn.Test.Utilities.TestGenerators; @@ -1019,7 +1020,7 @@ class D }); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var results = driver.GetRunResult(); @@ -1094,7 +1095,7 @@ class D }); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var results = driver.GetRunResult(); @@ -1227,7 +1228,7 @@ class E }); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var results = driver.GetRunResult(); @@ -1310,7 +1311,11 @@ class E }); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: false)); + GeneratorDriver driver = CSharpGeneratorDriver.Create( + [new IncrementalGeneratorWrapper(testGenerator)], + parseOptions: parseOptions, + driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: false)); + driver = driver.RunGenerators(compilation); var results = driver.GetRunResult(); @@ -1397,7 +1402,7 @@ class E GeneratorDriver driver = CSharpGeneratorDriver.Create( new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, - driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var results = driver.GetRunResult(); @@ -1517,7 +1522,7 @@ class C GeneratorDriver driver = CSharpGeneratorDriver.Create( new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, - driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var results = driver.GetRunResult(); Assert.Collection(results.Results[0].TrackedSteps["Fields"], @@ -1686,7 +1691,7 @@ class C }); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); // verify we ran the syntax transform once, but fed both outputs @@ -1745,7 +1750,7 @@ class C }); }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var results = driver.GetRunResult(); @@ -1799,7 +1804,7 @@ class C }); - GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + GeneratorDriver driver = CSharpGeneratorDriver.Create(new[] { new IncrementalGeneratorWrapper(testGenerator) }, parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions); driver = driver.RunGenerators(compilation); var results = driver.GetRunResult(); diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index c58db5b5930de..4a90d1416e3c9 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -4,6 +4,8 @@ Microsoft.CodeAnalysis.GeneratorDriver.RunGenerators(Microsoft.CodeAnalysis.Comp Microsoft.CodeAnalysis.GeneratorDriver.RunGenerators(Microsoft.CodeAnalysis.Compilation! compilation, System.Func? generatorFilter, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.GeneratorDriver! Microsoft.CodeAnalysis.GeneratorDriver.RunGenerators(Microsoft.CodeAnalysis.Compilation! compilation, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.GeneratorDriver! *REMOVED*Microsoft.CodeAnalysis.GeneratorDriver.RunGenerators(Microsoft.CodeAnalysis.Compilation! compilation, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.GeneratorDriver! +Microsoft.CodeAnalysis.GeneratorDriverOptions.BaseDirectory.get -> string? +Microsoft.CodeAnalysis.GeneratorDriverOptions.GeneratorDriverOptions(Microsoft.CodeAnalysis.IncrementalGeneratorOutputKind disabledOutputs = Microsoft.CodeAnalysis.IncrementalGeneratorOutputKind.None, bool trackIncrementalGeneratorSteps = false, string? baseDirectory = null) -> void Microsoft.CodeAnalysis.GeneratorFilterContext Microsoft.CodeAnalysis.GeneratorFilterContext.CancellationToken.get -> System.Threading.CancellationToken Microsoft.CodeAnalysis.GeneratorFilterContext.Generator.get -> Microsoft.CodeAnalysis.ISourceGenerator! diff --git a/src/Compilers/Core/Portable/SourceGeneration/GeneratorDriverOptions.cs b/src/Compilers/Core/Portable/SourceGeneration/GeneratorDriverOptions.cs index b7f013cab5905..5bc7a522d47e4 100644 --- a/src/Compilers/Core/Portable/SourceGeneration/GeneratorDriverOptions.cs +++ b/src/Compilers/Core/Portable/SourceGeneration/GeneratorDriverOptions.cs @@ -3,13 +3,12 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; -using System.Text; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis { /// - /// Options passed to a during creation + /// Options passed to a during creation. /// public readonly struct GeneratorDriverOptions { @@ -17,7 +16,11 @@ public readonly struct GeneratorDriverOptions public readonly bool TrackIncrementalGeneratorSteps; - internal string? BaseDirectory { get; init; } + /// + /// Absolute path to directory that generated source file paths are rooted with, or null to use relative paths for the generated files. + /// Usually the project's output directory unless is specified. + /// + public string? BaseDirectory { get; } public GeneratorDriverOptions(IncrementalGeneratorOutputKind disabledOutputs) : this(disabledOutputs, false) @@ -29,5 +32,24 @@ public GeneratorDriverOptions(IncrementalGeneratorOutputKind disabledOutputs, bo DisabledOutputs = disabledOutputs; TrackIncrementalGeneratorSteps = trackIncrementalGeneratorSteps; } + + /// + /// Creates . + /// + /// + /// + /// Absolute path to the base directory used for file paths of generated files. + /// is not an absolute path. + public GeneratorDriverOptions(IncrementalGeneratorOutputKind disabledOutputs = IncrementalGeneratorOutputKind.None, bool trackIncrementalGeneratorSteps = false, string? baseDirectory = null) + { + if (baseDirectory != null && !PathUtilities.IsAbsolute(baseDirectory)) + { + throw new ArgumentException(message: CodeAnalysisResources.AbsolutePathExpected, nameof(baseDirectory)); + } + + DisabledOutputs = disabledOutputs; + TrackIncrementalGeneratorSteps = trackIncrementalGeneratorSteps; + BaseDirectory = baseDirectory; + } } } diff --git a/src/Compilers/Test/Utilities/CSharp/TestOptions.cs b/src/Compilers/Test/Utilities/CSharp/TestOptions.cs index c46642528406e..6396ba202c979 100644 --- a/src/Compilers/Test/Utilities/CSharp/TestOptions.cs +++ b/src/Compilers/Test/Utilities/CSharp/TestOptions.cs @@ -10,6 +10,7 @@ using System.Linq; using Roslyn.Test.Utilities; using Microsoft.CodeAnalysis.Emit; +using Microsoft.CodeAnalysis.Test.Utilities; namespace Microsoft.CodeAnalysis.CSharp.Test.Utilities { @@ -100,6 +101,8 @@ public static class TestOptions public static readonly EmitOptions NativePdbEmit = EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.Pdb); + public static readonly GeneratorDriverOptions GeneratorDriverOptions = new GeneratorDriverOptions(trackIncrementalGeneratorSteps: true, baseDirectory: TempRoot.Root); + public static CSharpParseOptions WithStrictFeature(this CSharpParseOptions options) { return options.WithFeatures(options.Features.Concat(new[] { new KeyValuePair("strict", "true") })); diff --git a/src/Compilers/Test/Utilities/VisualBasic/TestOptions.vb b/src/Compilers/Test/Utilities/VisualBasic/TestOptions.vb index 15fac0d085b5d..84c370aa213f7 100644 --- a/src/Compilers/Test/Utilities/VisualBasic/TestOptions.vb +++ b/src/Compilers/Test/Utilities/VisualBasic/TestOptions.vb @@ -4,6 +4,7 @@ Imports System.Runtime.CompilerServices Imports Microsoft.CodeAnalysis.Diagnostics +Imports Microsoft.CodeAnalysis.Test.Utilities Imports Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax Imports Roslyn.Test.Utilities @@ -37,6 +38,8 @@ Public Class TestOptions Public Shared ReadOnly SigningDebugDll As VisualBasicCompilationOptions = DebugDll.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider) Public Shared ReadOnly SigningDebugExe As VisualBasicCompilationOptions = DebugExe.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider) Public Shared ReadOnly SigningReleaseModule As VisualBasicCompilationOptions = ReleaseModule.WithStrongNameProvider(SigningTestHelpers.DefaultDesktopStrongNameProvider) + + Public Shared ReadOnly GeneratorDriverOptions As GeneratorDriverOptions = New GeneratorDriverOptions(trackIncrementalGeneratorSteps:=True, baseDirectory:=TempRoot.Root) End Class Friend Module TestOptionExtensions diff --git a/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCompiler.vb b/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCompiler.vb index 7d5a888b72909..b4625091c45b3 100644 --- a/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCompiler.vb +++ b/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCompiler.vb @@ -298,7 +298,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Sub Private Protected Overrides Function CreateGeneratorDriver(baseDirectory As String, parseOptions As ParseOptions, generators As ImmutableArray(Of ISourceGenerator), analyzerConfigOptionsProvider As AnalyzerConfigOptionsProvider, additionalTexts As ImmutableArray(Of AdditionalText)) As GeneratorDriver - Return VisualBasicGeneratorDriver.Create(generators, additionalTexts, DirectCast(parseOptions, VisualBasicParseOptions), analyzerConfigOptionsProvider, driverOptions:=New GeneratorDriverOptions(disabledOutputs:=IncrementalGeneratorOutputKind.Host) With {.BaseDirectory = baseDirectory}) + Return VisualBasicGeneratorDriver.Create(generators, additionalTexts, DirectCast(parseOptions, VisualBasicParseOptions), analyzerConfigOptionsProvider, + driverOptions:=New GeneratorDriverOptions(disabledOutputs:=IncrementalGeneratorOutputKind.Host, baseDirectory:=baseDirectory)) End Function Private Protected Overrides Sub DiagnoseBadAccesses(consoleOutput As TextWriter, errorLogger As ErrorLogger, compilation As Compilation, diagnostics As ImmutableArray(Of Diagnostic)) diff --git a/src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_FullyQualifiedName.vb b/src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_FullyQualifiedName.vb index 4a2fed5d7a313..11049a6730796 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_FullyQualifiedName.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_FullyQualifiedName.vb @@ -81,7 +81,7 @@ end namespace End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -122,7 +122,7 @@ end namespace End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -165,7 +165,7 @@ end namespace End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -193,7 +193,7 @@ Imports System End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -222,7 +222,7 @@ Imports System End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -248,7 +248,7 @@ Imports System End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -279,7 +279,7 @@ End Class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -308,7 +308,7 @@ End Class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -337,7 +337,7 @@ End Class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -366,7 +366,7 @@ End Class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -397,7 +397,7 @@ End Class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -440,7 +440,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -481,7 +481,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -521,7 +521,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -560,7 +560,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -599,7 +599,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -639,7 +639,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -675,7 +675,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -712,7 +712,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -749,7 +749,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -786,7 +786,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -823,7 +823,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -860,7 +860,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -896,7 +896,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -943,7 +943,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -990,7 +990,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1033,7 +1033,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1082,7 +1082,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1135,7 +1135,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1193,7 +1193,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1247,7 +1247,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) diff --git a/src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_SimpleName.vb b/src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_SimpleName.vb index bb1840e773129..6bd8efbe6c381 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_SimpleName.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests_Attributes_SimpleName.vb @@ -52,7 +52,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -84,7 +84,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -110,7 +110,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -135,7 +135,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -160,7 +160,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -189,7 +189,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -221,7 +221,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -253,7 +253,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -285,7 +285,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -316,7 +316,7 @@ end namespace End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -342,7 +342,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -368,7 +368,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -394,7 +394,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -427,7 +427,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -455,7 +455,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -483,7 +483,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -510,7 +510,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -540,7 +540,7 @@ end namespace End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -571,7 +571,7 @@ end namespace End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -601,7 +601,7 @@ end namespace End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -631,7 +631,7 @@ end namespace End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -659,7 +659,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -687,7 +687,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -715,7 +715,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -742,7 +742,7 @@ imports A = XAttribute End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -769,7 +769,7 @@ imports AAttribute = XAttribute End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -796,7 +796,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -823,7 +823,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -852,7 +852,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -881,7 +881,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -908,7 +908,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -934,7 +934,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -963,7 +963,7 @@ imports B = AAttribute End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -991,7 +991,7 @@ global imports BAttribute = AAttribute End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1017,7 +1017,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1044,7 +1044,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1076,7 +1076,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1116,7 +1116,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1157,7 +1157,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1197,7 +1197,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1239,7 +1239,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1285,7 +1285,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1322,7 +1322,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1362,7 +1362,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1403,7 +1403,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1445,7 +1445,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) @@ -1497,7 +1497,7 @@ end class End Sub) End Sub)) - Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=New GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps:=True)) + Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions) driver = driver.RunGenerators(compilation) Dim runResult = driver.GetRunResult().Results(0) diff --git a/src/Features/Core/Portable/EditAndContinue/EditSession.cs b/src/Features/Core/Portable/EditAndContinue/EditSession.cs index 464434736f223..b2ca1a49e750c 100644 --- a/src/Features/Core/Portable/EditAndContinue/EditSession.cs +++ b/src/Features/Core/Portable/EditAndContinue/EditSession.cs @@ -818,9 +818,8 @@ public async ValueTask EmitSolutionUpdateAsync(Solution solution var hasEmitErrors = false; foreach (var newProject in solution.Projects) { - if (newProject.FilePath == null) + if (!newProject.SupportsEditAndContinue(log)) { - log.Write("Skipping project '{0}' without a file path", newProject.Name); continue; } diff --git a/src/Features/Core/Portable/EditAndContinue/Utilities/Extensions.cs b/src/Features/Core/Portable/EditAndContinue/Utilities/Extensions.cs index 88e9891d095b6..09e1958cf7f5f 100644 --- a/src/Features/Core/Portable/EditAndContinue/Utilities/Extensions.cs +++ b/src/Features/Core/Portable/EditAndContinue/Utilities/Extensions.cs @@ -36,21 +36,38 @@ public static SourceSpan ToSourceSpan(this LinePositionSpan span) /// /// True if the project supports Edit and Continue. /// Only depends on the language of the project and never changes. + /// + /// Source generated files in the project must match the paths used by the compiler, otherwise + /// different metadata might be emitted for file-scoped classes between compilation and EnC. /// - public static bool SupportsEditAndContinue(this Project project) - => project.Services.GetService() != null; - - // Note: source generated files have relative paths: https://github.com/dotnet/roslyn/issues/51998 - public static bool SupportsEditAndContinue(this TextDocumentState textDocumentState) + public static bool SupportsEditAndContinue(this Project project, TraceLog? log = null) { - if (textDocumentState.Attributes.DesignTimeOnly) + if (project.FilePath == null) { + log?.Write("Project '{0}' (id '{1}') doesn't support EnC: no file path", project.Name, project.Id); return false; } - if (textDocumentState is SourceGeneratedDocumentState { FilePath: not null }) + if (project.Services.GetService() == null) { - return true; + log?.Write("Project '{0}' doesn't support EnC: no EnC service", project.FilePath); + return false; + } + + if (!project.CompilationOutputInfo.HasEffectiveGeneratedFilesOutputDirectory) + { + log?.Write("Project '{0}' doesn't support EnC: no generated files output directory", project.FilePath); + return false; + } + + return true; + } + + public static bool SupportsEditAndContinue(this TextDocumentState textDocumentState) + { + if (textDocumentState.Attributes.DesignTimeOnly) + { + return false; } if (!PathUtilities.IsAbsolute(textDocumentState.FilePath)) diff --git a/src/Features/Lsif/Generator/CompilerInvocation.cs b/src/Features/Lsif/Generator/CompilerInvocation.cs index 632672a977983..faaa64cb2e950 100644 --- a/src/Features/Lsif/Generator/CompilerInvocation.cs +++ b/src/Features/Lsif/Generator/CompilerInvocation.cs @@ -79,10 +79,12 @@ public static async Task CreateFromInvocationInfoAsync(CompilerInvocati name: Path.GetFileNameWithoutExtension(invocationInfo.ProjectFilePath), assemblyName: parsedCommandLine.CompilationName!, language: languageName, - compilationOutputInfo: default, + compilationOutputInfo: new CompilationOutputInfo( + assemblyPath: parsedCommandLine.OutputFileName != null ? Path.Combine(parsedCommandLine.OutputDirectory, parsedCommandLine.OutputFileName) : null, + generatedFilesOutputDirectory: parsedCommandLine.GeneratedFilesOutputDirectory), checksumAlgorithm: parsedCommandLine.ChecksumAlgorithm, filePath: invocationInfo.ProjectFilePath, - outputFilePath: parsedCommandLine.OutputFileName), + outputRefFilePath: parsedCommandLine.OutputRefFilePath), parsedCommandLine.CompilationOptions, parsedCommandLine.ParseOptions, parsedCommandLine.SourceFiles.Select(s => CreateDocumentInfo(unmappedPath: s.Path)), diff --git a/src/Features/Lsif/GeneratorTest/CompilerInvocationTests.vb b/src/Features/Lsif/GeneratorTest/CompilerInvocationTests.vb index 2d5af6872c5e6..59b7e24433769 100644 --- a/src/Features/Lsif/GeneratorTest/CompilerInvocationTests.vb +++ b/src/Features/Lsif/GeneratorTest/CompilerInvocationTests.vb @@ -119,7 +119,7 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests }] }") - Dim compilation = Await Project.GetCompilationAsync() + Dim compilation = Await project.GetCompilationAsync() Dim syntaxTree = Assert.Single(compilation.SyntaxTrees) Assert.Equal("T:\Directory\SourceFile.cs", syntaxTree.FilePath) @@ -160,7 +160,7 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests Public Async Function TestSourceGeneratorOutputIncludedInCompilation() As Task Dim sourceGeneratorLocation = GetType(TestSourceGenerator.HelloWorldGenerator).Assembly.Location - Dim project = Await Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.CompilerInvocation.CreateFromJsonAsync(" + Dim project = Await CompilerInvocation.CreateFromJsonAsync(" { ""tool"": ""csc"", ""arguments"": ""/noconfig /analyzer:\""" + sourceGeneratorLocation.Replace("\", "\\") + "\"" /out:Output.dll"", diff --git a/src/Features/Test/EditAndContinue/CompileTimeSolutionProviderTests.cs b/src/Features/Test/EditAndContinue/CompileTimeSolutionProviderTests.cs index b491f3b2dc364..5c4da72a8fea0 100644 --- a/src/Features/Test/EditAndContinue/CompileTimeSolutionProviderTests.cs +++ b/src/Features/Test/EditAndContinue/CompileTimeSolutionProviderTests.cs @@ -32,7 +32,7 @@ public async Task TryGetCompileTimeDocumentAsync(string kind) var designTimeFilePath = Path.Combine(TempRoot.Root, "a", $"X.{kind}.g.cs"); var generator = new TestSourceGenerator() { ExecuteImpl = context => context.AddSource($"a_X_{kind}.g.cs", "") }; - var sourceGeneratedPathPrefix = Path.Combine(typeof(TestSourceGenerator).Assembly.GetName().Name!, typeof(TestSourceGenerator).FullName); + var sourceGeneratedPathPrefix = Path.Combine(TempRoot.Root, typeof(TestSourceGenerator).Assembly.GetName().Name!, typeof(TestSourceGenerator).FullName); var analyzerConfigId = DocumentId.CreateNewId(projectId); var documentId = DocumentId.CreateNewId(projectId); var additionalDocumentId = DocumentId.CreateNewId(projectId); @@ -40,6 +40,9 @@ public async Task TryGetCompileTimeDocumentAsync(string kind) var designTimeSolution = workspace.CurrentSolution. AddProject(ProjectInfo.Create(projectId, VersionStamp.Default, "proj", "proj", LanguageNames.CSharp, filePath: projectFilePath)). + WithProjectCompilationOutputInfo(projectId, new CompilationOutputInfo( + assemblyPath: Path.Combine(TempRoot.Root, "proj"), + generatedFilesOutputDirectory: null)). WithProjectMetadataReferences(projectId, TargetFrameworkUtil.GetReferences(TargetFramework.NetStandard20)). AddAnalyzerReference(projectId, new TestGeneratorReference(generator)). AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: additionalFilePath). @@ -105,11 +108,14 @@ public async Task GeneratorOutputCachedBetweenAcrossCompileTimeSolutions() var analyzerConfigText = "is_global = true\r\nbuild_property.SuppressRazorSourceGenerator = true"; - workspace.SetCurrentSolution(s => s. - AddProject(ProjectInfo.Create(projectId, VersionStamp.Default, "proj", "proj", LanguageNames.CSharp)). - AddAnalyzerReference(projectId, new TestGeneratorReference(generator)). - AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: "additional.razor"). - AddAnalyzerConfigDocument(analyzerConfigId, "config", SourceText.From(analyzerConfigText), filePath: "Z:\\RazorSourceGenerator.razorencconfig"), + workspace.SetCurrentSolution(s => s + .AddProject(ProjectInfo.Create(projectId, VersionStamp.Default, "proj", "proj", LanguageNames.CSharp)) + .WithProjectCompilationOutputInfo(projectId, new CompilationOutputInfo( + assemblyPath: Path.Combine(TempRoot.Root, "proj"), + generatedFilesOutputDirectory: null)) + .AddAnalyzerReference(projectId, new TestGeneratorReference(generator)) + .AddAdditionalDocument(additionalDocumentId, "additional", SourceText.From(""), filePath: "additional.razor") + .AddAnalyzerConfigDocument(analyzerConfigId, "config", SourceText.From(analyzerConfigText), filePath: "Z:\\RazorSourceGenerator.razorencconfig"), WorkspaceChangeKind.SolutionAdded); // Fetch a compilation first for the base solution; we're doing this because currently if we try to move the diff --git a/src/Features/Test/EditAndContinue/EditAndContinueWorkspaceServiceTests.cs b/src/Features/Test/EditAndContinue/EditAndContinueWorkspaceServiceTests.cs index 06b5bdba4ec25..c185b9d7660eb 100644 --- a/src/Features/Test/EditAndContinue/EditAndContinueWorkspaceServiceTests.cs +++ b/src/Features/Test/EditAndContinue/EditAndContinueWorkspaceServiceTests.cs @@ -231,7 +231,7 @@ public async Task ProjectThatDoesNotSupportEnC(bool breakMode) { using var _ = CreateWorkspace(out var solution, out var service, [typeof(NoCompilationLanguageService)]); var project = solution.AddProject("dummy_proj", "dummy_proj", NoCompilationConstants.LanguageName); - var document = project.AddDocument("test", CreateText("dummy1")); + var document = project.AddDocument("test", "dummy1"); solution = document.Project.Solution; var debuggingSession = await StartDebuggingSessionAsync(service, solution); @@ -259,6 +259,47 @@ public async Task ProjectThatDoesNotSupportEnC(bool breakMode) Assert.Empty(diagnostics); } + [Fact] + public async Task ProjectWithoutEffectiveGeneratedFilesOutputDirectory() + { + var sourceV1 = """ + /* GENERATE: class G { int F(int x) => 1; } */ + + class C { int Y => 1; } + """; + + var sourceV2 = """ + /* GENERATE: class G { int F() => 1; } */ + + class C { int Y => 2; } + """; + + var generator = new TestSourceGenerator() { ExecuteImpl = GenerateSource }; + + using var _ = CreateWorkspace(out var solution, out var service); + (solution, var document) = AddDefaultTestProject(solution, sourceV1, generator: generator); + solution = solution.WithProjectCompilationOutputInfo(document.Project.Id, new CompilationOutputInfo(assemblyPath: null, generatedFilesOutputDirectory: null)); + + var debuggingSession = await StartDebuggingSessionAsync(service, solution); + EnterBreakState(debuggingSession); + + // change the source: + var document1 = solution.Projects.Single().Documents.Single(); + solution = solution.WithDocumentText(document1.Id, CreateText(sourceV2)); + + var generatedDocument = (await solution.Projects.Single().GetSourceGeneratedDocumentsAsync()).Single(); + + var diagnostics1 = await service.GetDocumentDiagnosticsAsync(generatedDocument, s_noActiveSpans, CancellationToken.None); + Assert.Empty(diagnostics1); + + var (updates, emitDiagnostics) = await EmitSolutionUpdateAsync(debuggingSession, solution); + Assert.Equal(ModuleUpdateStatus.None, updates.Status); + Assert.Empty(updates.Updates); + Assert.Empty(emitDiagnostics); + + EndDebuggingSession(debuggingSession); + } + [Fact] public async Task DesignTimeOnlyDocument() { @@ -354,14 +395,12 @@ public async Task DesignTimeOnlyDocument_Wpf([CombinatorialValues(LanguageNames. // [added == false] a version of the source that's not updated with the output of single file generator (or design-time build): // [added == true] without the output of single file generator (design-time build has not completed) - var projectId = ProjectId.CreateNewId(); - var documentId = DocumentId.CreateNewId(projectId); - var designTimeOnlyDocumentId = DocumentId.CreateNewId(projectId); - solution = solution. - AddProject(projectId, "test", "test", language). - AddMetadataReferences(projectId, TargetFrameworkUtil.GetReferences(TargetFramework.Mscorlib40)). - AddDocument(documentId, sourceFileName, CreateText(source), filePath: sourceFilePath); + AddTestProject("test", language, out var projectId). + AddMetadataReferences(TargetFrameworkUtil.GetReferences(TargetFramework.Mscorlib40)). + AddTestDocument(source, path: sourceFilePath, out var documentId).Project.Solution; + + var designTimeOnlyDocumentId = DocumentId.CreateNewId(projectId); if (!designTimeOnlyAddedAfterSessionStarts) { @@ -655,9 +694,9 @@ public async Task FileAdded(bool breakMode) } // add a source file: - var documentB = project.AddDocument("file2.cs", CreateText(sourceB), filePath: sourceFileB.Path); + var documentB = project.AddTestDocument(sourceB, path: sourceFileB.Path); solution = documentB.Project.Solution; - documentB = solution.GetDocument(documentB.Id); + documentB = solution.GetRequiredDocument(documentB.Id); var diagnostics2 = await service.GetDocumentDiagnosticsAsync(documentB, s_noActiveSpans, CancellationToken.None); Assert.Empty(diagnostics2); @@ -734,7 +773,7 @@ public async Task ModuleDisallowsEditAndContinue_NoChanges(bool breakMode) sourceFile.WriteAllText(source1, Encoding.UTF8); // source0 is loaded to workspace before session starts: - var document0 = project.AddDocument("a.cs", CreateText(source0), filePath: sourceFile.Path); + var document0 = project.AddTestDocument(source0, path: sourceFile.Path); solution = document0.Project.Solution; var debuggingSession = await StartDebuggingSessionAsync(service, solution, initialState: CommittedSolution.DocumentState.None); @@ -1108,7 +1147,7 @@ public async Task RudeEdits_DocumentOutOfSync(bool breakMode) sourceFile.WriteAllText(source1, Encoding.UTF8); // source1 is reflected in workspace before session starts: - var document1 = project.AddDocument("a.cs", CreateText(source1), filePath: sourceFile.Path); + var document1 = project.AddTestDocument(source1, path: sourceFile.Path); solution = document1.Project.Solution; var debuggingSession = await StartDebuggingSessionAsync(service, solution, initialState: CommittedSolution.DocumentState.None); @@ -1421,7 +1460,7 @@ public async Task HasChanges() // add a project: oldSolution = solution; - var projectD = solution.AddProject("D", "D", "C#"); + var projectD = solution.AddTestProject("D"); solution = projectD.Solution; Assert.True(await EditSession.HasChangesAsync(oldSolution, solution, CancellationToken.None)); @@ -1432,7 +1471,7 @@ public async Task HasChanges() // add a project that doesn't support EnC: oldSolution = solution; - var projectE = solution.AddProject("E", "E", NoCompilationConstants.LanguageName); + var projectE = solution.AddTestProject("E", language: NoCompilationConstants.LanguageName); solution = projectE.Solution; Assert.False(await EditSession.HasChangesAsync(oldSolution, solution, CancellationToken.None)); @@ -1485,7 +1524,11 @@ public async Task HasChanges_Documents(DocumentKind documentKind) } }; - var project = solution.AddProject("A", "A", "C#").AddDocument("A.cs", "", filePath: pathA).Project; + var project = solution + .AddTestProject("A") + .AddTestDocument(source: "", path: pathA) + .Project; + var projectId = project.Id; solution = project.Solution.AddAnalyzerReference(projectId, new TestGeneratorReference(generator)); project = solution.GetRequiredProject(projectId); @@ -1638,7 +1681,7 @@ public async Task HasChanges_SourceGeneratorFailure() }; var project = solution - .AddProject("A", "A", "C#") + .AddTestProject("A") .AddAdditionalDocument("A.txt", "text", filePath: pathA) .Project; @@ -1738,8 +1781,8 @@ public async Task Project_Add() // add project that matches assembly B and update the document: var documentB2 = solution. - AddProject("B", "B", LanguageNames.CSharp). - AddDocument("b.cs", CreateText(sourceB2), filePath: sourceFileB.Path); + AddTestProject("B"). + AddTestDocument(sourceB2, path: sourceFileB.Path); solution = documentB2.Project.Solution; @@ -1904,7 +1947,7 @@ int M() using var _ = CreateWorkspace(out var solution, out var service); (solution, var document1) = AddDefaultTestProject(solution, sourceV1, generator); - var moduleId = EmitLibrary(sourceV1, generator: generator); + var moduleId = EmitLibrary(sourceV1, generatorProject: document1.Project); LoadLibraryToDebuggee(moduleId); // attached to processes that doesn't allow creating new types @@ -2602,15 +2645,16 @@ partial class C { int Y = 2; } [Theory] [CombinatorialData] + [WorkItem("https://github.com/dotnet/roslyn/issues/72331")] internal async Task ValidSignificantChange_SourceGenerators_DocumentUpdate_GeneratedDocumentUpdate(SourceGeneratorExecutionPreference executionPreference) { var sourceV1 = @" -/* GENERATE: class G { int X => 1; } */ +/* GENERATE: file class G { int X => 1; } */ class C { int Y => 1; } "; var sourceV2 = @" -/* GENERATE: class G { int X => 2; } */ +/* GENERATE: file class G { int X => 2; } */ class C { int Y => 2; } "; @@ -2623,7 +2667,7 @@ class C { int Y => 2; } (solution, var document1) = AddDefaultTestProject(solution, sourceV1, generator); - var moduleId = EmitLibrary(sourceV1, generator: generator); + var moduleId = EmitLibrary(sourceV1, generatorProject: document1.Project); LoadLibraryToDebuggee(moduleId); // Trigger initial source generation before debugging session starts. @@ -2680,7 +2724,7 @@ class C { int Y => 2; } (solution, var document1) = AddDefaultTestProject(solution, sourceV1, generator); - var moduleId = EmitLibrary(sourceV1, generator: generator); + var moduleId = EmitLibrary(sourceV1, generatorProject: document1.Project); LoadLibraryToDebuggee(moduleId); // Trigger initial source generation before debugging session starts. @@ -2700,9 +2744,15 @@ class C { int Y => 2; } var results = (await debuggingSession.EmitSolutionUpdateAsync(solution, s_noActiveSpans, CancellationToken.None).ConfigureAwait(false)).Dehydrate(); var diagnostics = results.GetAllDiagnostics(); + var generatedFilePath = Path.Combine( + TempRoot.Root, + "Microsoft.CodeAnalysis.Test.Utilities", + "Roslyn.Test.Utilities.TestGenerators.TestSourceGenerator", + "Generated_test1.cs"); + AssertEx.Equal( [ - @"ENC0021: 'Microsoft.CodeAnalysis.Test.Utilities\Roslyn.Test.Utilities.TestGenerators.TestSourceGenerator\Generated_test1.cs' (0,0)-(0,56): " + + $@"ENC0021: '{generatedFilePath}' (0,0)-(0,56): " + string.Format(FeaturesResources.Adding_0_requires_restarting_the_application, FeaturesResources.attribute), ], diagnostics.Select(d => $"{d.Id}: '{d.FilePath}' {d.Span.GetDebuggerDisplay()}: {d.Message}")); @@ -2744,7 +2794,7 @@ int M() using var _ = CreateWorkspace(out var solution, out var service); (solution, var document1) = AddDefaultTestProject(solution, sourceV1, generator); - var moduleId = EmitLibrary(sourceV1, generator: generator); + var moduleId = EmitLibrary(sourceV1, generatorProject: document1.Project); LoadLibraryToDebuggee(moduleId); var debuggingSession = await StartDebuggingSessionAsync(service, solution); @@ -2792,7 +2842,7 @@ partial class C { int X = 1; } using var _ = CreateWorkspace(out var solution, out var service); (solution, var document1) = AddDefaultTestProject(solution, sourceV1, generator); - var moduleId = EmitLibrary(sourceV1, generator: generator); + var moduleId = EmitLibrary(sourceV1, generatorProject: document1.Project); LoadLibraryToDebuggee(moduleId); var debuggingSession = await StartDebuggingSessionAsync(service, solution); @@ -2839,7 +2889,7 @@ class C { int Y => 1; } using var _ = CreateWorkspace(out var solution, out var service); (solution, var document) = AddDefaultTestProject(solution, source, generator, additionalFileText: additionalSourceV1); - var moduleId = EmitLibrary(source, generator: generator, additionalFileText: additionalSourceV1); + var moduleId = EmitLibrary(source, generatorProject: document.Project, additionalFileText: additionalSourceV1); LoadLibraryToDebuggee(moduleId); var debuggingSession = await StartDebuggingSessionAsync(service, solution); @@ -2883,7 +2933,7 @@ class C { int Y => 1; } using var _ = CreateWorkspace(out var solution, out var service); (solution, var document) = AddDefaultTestProject(solution, source, generator, analyzerConfig: configV1); - var moduleId = EmitLibrary(source, generator: generator, analyzerOptions: configV1); + var moduleId = EmitLibrary(source, generatorProject: document.Project, analyzerOptions: configV1); LoadLibraryToDebuggee(moduleId); var debuggingSession = await StartDebuggingSessionAsync(service, solution); @@ -2925,7 +2975,7 @@ public async Task ValidSignificantChange_SourceGenerators_DocumentRemove() using var _ = CreateWorkspace(out var solution, out var service); (solution, var document1) = AddDefaultTestProject(solution, source1, generator); - var moduleId = EmitLibrary(source1, generator: generator); + var moduleId = EmitLibrary(source1, generatorProject: document1.Project); LoadLibraryToDebuggee(moduleId); var debuggingSession = await StartDebuggingSessionAsync(service, solution); @@ -3440,7 +3490,7 @@ public async Task ActiveStatements_LinkedDocuments() DocumentId AddProjectAndLinkDocument(string projectName, Document doc, SourceText text) { - var p = solution.AddProject(projectName, projectName, "C#"); + var p = solution.AddTestProject(projectName); var linkedDocId = DocumentId.CreateNewId(p.Id, projectName + "->" + doc.Name); solution = p.Solution.AddDocument(linkedDocId, doc.Name, text, filePath: doc.FilePath); return linkedDocId; @@ -3486,7 +3536,7 @@ DocumentId AddProjectAndLinkDocument(string projectName, Document doc, SourceTex Assert.Equal(0x06000001, s.InstructionId.Method.Token); Assert.Equal(module1, s.InstructionId.Method.Module); - var spans = await debuggingSession.GetBaseActiveStatementSpansAsync(solution, ImmutableArray.Create(doc1.Id, doc2.Id, docId3, docId4, docId5), CancellationToken.None); + var spans = await debuggingSession.GetBaseActiveStatementSpansAsync(solution, [doc1.Id, doc2.Id, docId3, docId4, docId5], CancellationToken.None); AssertEx.Equal( [ @@ -3631,7 +3681,7 @@ void F() var generatedDocument1 = (await solution.Projects.Single().GetSourceGeneratedDocumentsAsync().ConfigureAwait(false)).Single(); - var moduleId = EmitLibrary(source1, generator: generator, additionalFileText: additionalFileSourceV1); + var moduleId = EmitLibrary(source1, generatorProject: document1.Project, additionalFileText: additionalFileSourceV1); LoadLibraryToDebuggee(moduleId); var debuggingSession = await StartDebuggingSessionAsync(service, solution); diff --git a/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs b/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs index c3d1e45a08f0c..83dedbd3788c9 100644 --- a/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs +++ b/src/Features/TestUtilities/EditAndContinue/EditAndContinueWorkspaceTestBase.cs @@ -223,18 +223,19 @@ internal void LoadLibraryToDebuggee(Guid moduleId, ManagedHotReloadAvailability _debuggerService.LoadedModules!.Add(moduleId, availability); } - public Guid EmitLibrary( + internal Guid EmitLibrary( string source, string? sourceFilePath = null, Encoding? encoding = null, SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default, string assemblyName = "", DebugInformationFormat pdbFormat = DebugInformationFormat.PortablePdb, - ISourceGenerator? generator = null, + Project? generatorProject = null, string? additionalFileText = null, IEnumerable<(string, string)>? analyzerOptions = null) { - return EmitLibrary(new[] { (source, sourceFilePath ?? Path.Combine(TempRoot.Root, "test1.cs")) }, encoding, checksumAlgorithm, assemblyName, pdbFormat, generator, additionalFileText, analyzerOptions); + var sources = new[] { (source, sourceFilePath ?? Path.Combine(TempRoot.Root, "test1.cs")) }; + return EmitLibrary(sources, encoding, checksumAlgorithm, assemblyName, pdbFormat, generatorProject, additionalFileText, analyzerOptions); } internal Guid EmitLibrary( @@ -243,7 +244,7 @@ internal Guid EmitLibrary( SourceHashAlgorithm checksumAlgorithm = SourceHashAlgorithms.Default, string assemblyName = "", DebugInformationFormat pdbFormat = DebugInformationFormat.PortablePdb, - ISourceGenerator? generator = null, + Project? generatorProject = null, string? additionalFileText = null, IEnumerable<(string, string)>? analyzerOptions = null) { @@ -259,11 +260,19 @@ internal Guid EmitLibrary( Compilation compilation = CSharpTestBase.CreateCompilation(trees.ToArray(), options: TestOptions.DebugDll, targetFramework: DefaultTargetFramework, assemblyName: assemblyName); - if (generator != null) + if (generatorProject != null) { + var generators = generatorProject.AnalyzerReferences.SelectMany(r => r.GetGenerators(language: generatorProject.Language)); + var optionsProvider = (analyzerOptions != null) ? new EditAndContinueTestAnalyzerConfigOptionsProvider(analyzerOptions) : null; var additionalTexts = (additionalFileText != null) ? new[] { new InMemoryAdditionalText("additional_file", additionalFileText) } : null; - var generatorDriver = CSharpGeneratorDriver.Create([generator], additionalTexts, parseOptions, optionsProvider); + var generatorDriver = CSharpGeneratorDriver.Create( + generators, + additionalTexts, + parseOptions, + optionsProvider, + driverOptions: new GeneratorDriverOptions(baseDirectory: generatorProject.CompilationOutputInfo.GetEffectiveGeneratedFilesOutputDirectory()!)); + generatorDriver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation, out var generatorDiagnostics); generatorDiagnostics.Verify(); compilation = outputCompilation; diff --git a/src/Features/TestUtilities/EditAndContinue/Extensions.cs b/src/Features/TestUtilities/EditAndContinue/Extensions.cs index 5516756a60f49..ac5df24da0eb4 100644 --- a/src/Features/TestUtilities/EditAndContinue/Extensions.cs +++ b/src/Features/TestUtilities/EditAndContinue/Extensions.cs @@ -6,12 +6,14 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection.Metadata; using System.Text; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Test.Utilities; using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnitTests; using Microsoft.CodeAnalysis.VisualBasic; @@ -62,6 +64,19 @@ public static Project AddTestProject(this Solution solution, string projectName, return solution.AddProject(info).GetRequiredProject(id = info.Id); } + public static Document AddTestDocument(this Project project, string source, string path) + => project.AddTestDocument(source, path, out _); + + public static Document AddTestDocument(this Project project, string source, string path, out DocumentId id) + => project.Solution.AddTestDocument(project.Id, source, path, out id); + + public static Document AddTestDocument(this Solution solution, ProjectId projectId, string source, string path, out DocumentId id) + => solution.AddDocument( + id = DocumentId.CreateNewId(projectId), + name: PathUtilities.GetFileName(path), + SourceText.From(source, Encoding.UTF8, SourceHashAlgorithms.Default), + filePath: path).GetRequiredDocument(id); + public static Guid CreateProjectTelemetryId(string projectName) { Assert.True(Encoding.UTF8.GetByteCount(projectName) <= 20, "Use shorter project names in tests"); @@ -89,6 +104,9 @@ public static ProjectInfo CreateProjectInfo(string projectName, string language NoCompilationConstants.LanguageName => ".noproj", _ => throw ExceptionUtilities.UnexpectedValue(language) }) + .WithCompilationOutputInfo(new CompilationOutputInfo( + assemblyPath: Path.Combine(TempRoot.Root, projectName + ".dll"), + generatedFilesOutputDirectory: null)) .WithTelemetryId(CreateProjectTelemetryId(projectName)); } diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs index c2e7f749d2367..c41713fb1ac6a 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs @@ -135,6 +135,7 @@ public void Dispose() _projectSystemProject.DisplayName = projectDisplayName; _projectSystemProject.OutputFilePath = newProjectInfo.OutputFilePath; _projectSystemProject.OutputRefFilePath = newProjectInfo.OutputRefFilePath; + _projectSystemProject.GeneratedFilesOutputDirectory = newProjectInfo.GeneratedFilesOutputDirectory; _projectSystemProject.CompilationOutputAssemblyFilePath = newProjectInfo.IntermediateOutputFilePath; if (newProjectInfo.TargetFrameworkIdentifier != null) diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/WorkspaceProject.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/WorkspaceProject.cs index e8b9ed22b7088..daa449f14596d 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/WorkspaceProject.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/WorkspaceProject.cs @@ -169,6 +169,7 @@ public Task SetBuildSystemPropertiesAsync(IReadOnlyDictionary pr case "RunAnalyzersDuringLiveAnalysis": _project.RunAnalyzersDuringLiveAnalysis = bool.Parse(valueOrNull ?? bool.TrueString); break; case "TargetPath": _project.OutputFilePath = GetFullyQualifiedPath(valueOrNull); break; case "TargetRefPath": _project.OutputRefFilePath = GetFullyQualifiedPath(valueOrNull); break; + case "CompilerGeneratedFilesOutputPath": _project.GeneratedFilesOutputDirectory = GetFullyQualifiedPath(valueOrNull); break; case "TargetFrameworkIdentifier": _targetFrameworkManager.UpdateIdentifierForProject(_project.Id, valueOrNull); break; } } diff --git a/src/VisualStudio/Core/Def/ProjectSystem/BuildPropertyNames.cs b/src/VisualStudio/Core/Def/ProjectSystem/BuildPropertyNames.cs index 9dc700d1977b7..7c683c2855385 100644 --- a/src/VisualStudio/Core/Def/ProjectSystem/BuildPropertyNames.cs +++ b/src/VisualStudio/Core/Def/ProjectSystem/BuildPropertyNames.cs @@ -22,6 +22,7 @@ internal static class BuildPropertyNames public const string RunAnalyzersDuringLiveAnalysis = nameof(RunAnalyzersDuringLiveAnalysis); public const string TemporaryDependencyNodeTargetIdentifier = nameof(TemporaryDependencyNodeTargetIdentifier); public const string TargetRefPath = nameof(TargetRefPath); + public const string CompilerGeneratedFilesOutputPath = nameof(CompilerGeneratedFilesOutputPath); // Properties requested at project creation time. diff --git a/src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProject_IWorkspaceProjectContext.cs b/src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProject_IWorkspaceProjectContext.cs index 0a36ebeb63eb5..ef5797d9d8e96 100644 --- a/src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProject_IWorkspaceProjectContext.cs +++ b/src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProject_IWorkspaceProjectContext.cs @@ -197,6 +197,10 @@ public void SetProperty(string name, string? value) } } } + else if (name == BuildPropertyNames.CompilerGeneratedFilesOutputPath) + { + _projectSystemProject.GeneratedFilesOutputDirectory = string.IsNullOrWhiteSpace(value) ? null : value; + } } public void AddMetadataReference(string referencePath, MetadataReferenceProperties properties) diff --git a/src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs b/src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs index 7017305b4ede9..512a6ab9edd6c 100644 --- a/src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs +++ b/src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs @@ -429,6 +429,9 @@ private static async Task TestInProcAndRemoteWorkspaceWorker( var project = localWorkspace.CurrentSolution .AddProject(ProjectInfo.Create(projectId, VersionStamp.Default, name: "Test", assemblyName: "Test", language: LanguageNames.CSharp)) .GetRequiredProject(projectId) + .WithCompilationOutputInfo(new CompilationOutputInfo( + assemblyPath: Path.Combine(TempRoot.Root, "Test.dll"), + generatedFilesOutputDirectory: null)) .AddAnalyzerReference(analyzerReference); var tempDoc = project.AddDocument("X.cs", SourceText.From("// ")); tempDocId = tempDoc.Id; @@ -765,6 +768,9 @@ private static DocumentId AddSimpleDocument(TestWorkspace workspace, CallbackGen var project = workspace.CurrentSolution .AddProject(ProjectInfo.Create(projectId, VersionStamp.Default, name: "Test", assemblyName: "Test", language: LanguageNames.CSharp)) .GetRequiredProject(projectId) + .WithCompilationOutputInfo(new CompilationOutputInfo( + assemblyPath: Path.Combine(TempRoot.Root, "Test.dll"), + generatedFilesOutputDirectory: null)) .AddAnalyzerReference(analyzerReference); var tempDoc = project.AddDocument("X.cs", SourceText.From("// ")); diff --git a/src/VisualStudio/Core/Test.Next/Services/SolutionServiceTests.cs b/src/VisualStudio/Core/Test.Next/Services/SolutionServiceTests.cs index f84016f18145c..7acae046c03eb 100644 --- a/src/VisualStudio/Core/Test.Next/Services/SolutionServiceTests.cs +++ b/src/VisualStudio/Core/Test.Next/Services/SolutionServiceTests.cs @@ -245,9 +245,10 @@ await VerifySolutionUpdate(workspace, [Fact] public async Task ProjectProperties() { + var dir = Path.GetDirectoryName(typeof(SolutionServiceTests).Assembly.Location); using var workspace = TestWorkspace.CreateCSharp(""); - static Solution SetProjectProperties(Solution solution, int version) + Solution SetProjectProperties(Solution solution, int version) { var projectId = solution.ProjectIds.Single(); return solution @@ -256,14 +257,14 @@ static Solution SetProjectProperties(Solution solution, int version) .WithProjectFilePath(projectId, "FilePath" + version) .WithProjectOutputFilePath(projectId, "OutputFilePath" + version) .WithProjectOutputRefFilePath(projectId, "OutputRefFilePath" + version) - .WithProjectCompilationOutputInfo(projectId, new CompilationOutputInfo("AssemblyPath" + version)) + .WithProjectCompilationOutputInfo(projectId, new CompilationOutputInfo("AssemblyPath" + version, dir + version)) .WithProjectDefaultNamespace(projectId, "DefaultNamespace" + version) .WithProjectChecksumAlgorithm(projectId, SourceHashAlgorithm.Sha1 + version) .WithHasAllInformation(projectId, (version % 2) != 0) .WithRunAnalyzers(projectId, (version % 2) != 0); } - static void ValidateProperties(Solution solution, int version) + void ValidateProperties(Solution solution, int version) { var project = solution.Projects.Single(); Assert.Equal("Name" + version, project.Name); @@ -271,6 +272,7 @@ static void ValidateProperties(Solution solution, int version) Assert.Equal("FilePath" + version, project.FilePath); Assert.Equal("OutputFilePath" + version, project.OutputFilePath); Assert.Equal("OutputRefFilePath" + version, project.OutputRefFilePath); + Assert.Equal(dir + version, project.CompilationOutputInfo.GeneratedFilesOutputDirectory); Assert.Equal("AssemblyPath" + version, project.CompilationOutputInfo.AssemblyPath); Assert.Equal("DefaultNamespace" + version, project.DefaultNamespace); Assert.Equal(SourceHashAlgorithm.Sha1 + version, project.State.ChecksumAlgorithm); diff --git a/src/VisualStudio/Core/Test/Progression/CallsGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/CallsGraphQueryTests.vb index 5cabed499210e..7ae2fc97e7581 100644 --- a/src/VisualStudio/Core/Test/Progression/CallsGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/CallsGraphQueryTests.vb @@ -42,7 +42,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) @@ -86,7 +86,7 @@ class A - + ) @@ -122,7 +122,7 @@ class A - + ) End Using @@ -175,7 +175,7 @@ class C - + ) @@ -226,7 +226,7 @@ class Test - + ) End Using diff --git a/src/VisualStudio/Core/Test/Progression/ContainsGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/ContainsGraphQueryTests.vb index 9c7719504da71..eaf1373204612 100644 --- a/src/VisualStudio/Core/Test/Progression/ContainsGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/ContainsGraphQueryTests.vb @@ -59,7 +59,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using @@ -104,7 +104,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using @@ -158,7 +158,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using @@ -200,7 +200,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using @@ -233,7 +233,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using @@ -264,7 +264,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using @@ -295,7 +295,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using @@ -383,7 +383,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using diff --git a/src/VisualStudio/Core/Test/Progression/GraphNodeCreationTests.vb b/src/VisualStudio/Core/Test/Progression/GraphNodeCreationTests.vb index 1a3bb6183c6cc..b2854f9dd0195 100644 --- a/src/VisualStudio/Core/Test/Progression/GraphNodeCreationTests.vb +++ b/src/VisualStudio/Core/Test/Progression/GraphNodeCreationTests.vb @@ -35,42 +35,42 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestSimpleType() As Task - Await AssertCreatedNodeIsAsync("namespace N { class $$C { } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C)", + Await AssertCreatedNodeIsAsync("namespace N { class $$C { } }", "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C)", - + ) End Function Public Async Function TestNamespaceType() As Task - Await AssertCreatedNodeIsAsync("namespace $$N { class C { } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N)", + Await AssertCreatedNodeIsAsync("namespace $$N { class C { } }", "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N)", - + ) End Function Public Async Function TestLongNamespaceType() As Task - Await AssertCreatedNodeIsAsync("namespace N.$$N1.N11 { class C { } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N.N1)", + Await AssertCreatedNodeIsAsync("namespace N.$$N1.N11 { class C { } }", "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N.N1)", - + ) End Function @@ -78,14 +78,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestSimpleParameterType() As Task Await AssertCreatedNodeIsAsync("namespace N { class C { void M(int $$x) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]) ParameterIdentifier=x)", + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]) ParameterIdentifier=x)", - + ) @@ -94,14 +94,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestDelegateType() As Task Await AssertCreatedNodeIsAsync("namespace N { delegate void D(string $$m); }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=D Member=(Name=Invoke OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=String)]) ParameterIdentifier=m)", + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=D Member=(Name=Invoke OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=String)]) ParameterIdentifier=m)", - + ) @@ -110,14 +110,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestLambdaParameterType() As Task Await AssertCreatedNodeIsAsync("namespace N { class C { void M(Func $$x) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/CSharpAssembly1.dll Type=(Name=Func GenericParameterCount=2 GenericArguments=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32),(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]))]) ParameterIdentifier=x)", + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/bin/CSharpAssembly1.dll Type=(Name=Func GenericParameterCount=2 GenericArguments=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32),(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]))]) ParameterIdentifier=x)", - + ) @@ -125,28 +125,28 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestLocalType() As Task - Await AssertCreatedNodeIsAsync("namespace N { class C { int M() { int $$y = 0; return y; } } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=M LocalVariable=y)", + Await AssertCreatedNodeIsAsync("namespace N { class C { int M() { int $$y = 0; return y; } } }", "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=M LocalVariable=y)", - + ) End Function Public Async Function TestFirstLocalWithSameNameType() As Task - Await AssertCreatedNodeIsAsync("namespace N { class C { int M() { { int $$y = 0; } { int y = 1;} } } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=M LocalVariable=y)", + Await AssertCreatedNodeIsAsync("namespace N { class C { int M() { { int $$y = 0; } { int y = 1;} } } }", "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=M LocalVariable=y)", - + ) End Function @@ -154,14 +154,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestSecondLocalWithSameNameType() As Task Await AssertCreatedNodeIsAsync("namespace N { class C { int M() { { int y = 0; } { int $$y = 1;} } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=M LocalVariable=y LocalVariableIndex=1)", + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=M LocalVariable=y LocalVariableIndex=1)", - + ) End Function @@ -170,14 +170,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestErrorType() As Task Await AssertCreatedNodeIsAsync( "Class $$C : Inherits D : End Class", - "(Assembly=file:///Z:/VisualBasicAssembly1.dll Type=C)", + "(Assembly=file:///Z:/bin/VisualBasicAssembly1.dll Type=C)", - + , LanguageNames.VisualBasic) @@ -206,14 +206,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestReferenceParameterSymbolTest() As Task Await AssertCreatedNodeIsAsync("namespace N { class C { void $$Goo(ref int i) { i = i + 1; } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=Goo OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32 ParamKind=Ref)]))", + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=Goo OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32 ParamKind=Ref)]))", - + ) @@ -222,14 +222,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestReferenceOutParameterSymbolTest() As Task Await AssertCreatedNodeIsAsync("namespace N { class C { void $$Goo(out int i) { i = 1; } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=Goo OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32 ParamKind=Ref)]))", + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=Goo OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32 ParamKind=Ref)]))", - + ) @@ -265,7 +265,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) @@ -303,7 +303,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) @@ -336,7 +336,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) @@ -370,7 +370,7 @@ End Module - + ) End Using @@ -403,7 +403,7 @@ End Module - + ) End Using @@ -440,7 +440,7 @@ End Module - + ) End Using @@ -477,7 +477,7 @@ End Module - + ) End Using @@ -531,7 +531,7 @@ End Module - + ) End Using @@ -585,7 +585,7 @@ End Module - + ) End Using @@ -638,7 +638,7 @@ End Module - + ) End Using @@ -667,7 +667,7 @@ End Module - + ) End Using @@ -725,7 +725,7 @@ End Module - + ) End Using @@ -760,7 +760,7 @@ End Module - + ) End Using @@ -801,7 +801,7 @@ End Class - + ) diff --git a/src/VisualStudio/Core/Test/Progression/GraphNodeIdTests.vb b/src/VisualStudio/Core/Test/Progression/GraphNodeIdTests.vb index 4c37568faca53..79e1b53c52cbf 100644 --- a/src/VisualStudio/Core/Test/Progression/GraphNodeIdTests.vb +++ b/src/VisualStudio/Core/Test/Progression/GraphNodeIdTests.vb @@ -29,96 +29,96 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression Public Async Function TestSimpleType() As Task - Await AssertMarkedNodeIdIsAsync("namespace N { class $$C { } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C)") + Await AssertMarkedNodeIdIsAsync("namespace N { class $$C { } }", "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C)") End Function Public Async Function TestNestedType() As Task - Await AssertMarkedNodeIdIsAsync("namespace N { class C { class $$E { } } }", "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(Name=E ParentType=C))") + Await AssertMarkedNodeIdIsAsync("namespace N { class C { class $$E { } } }", "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(Name=E ParentType=C))") End Function Public Async Function TestMemberWithSimpleArrayType() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(int[] p) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=(Name=Int32 ArrayRank=1 ParentType=Int32))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=(Name=Int32 ArrayRank=1 ParentType=Int32))]))") End Function Public Async Function TestMemberWithNestedArrayType() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(int[][,] p) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=(Name=Int32 ArrayRank=1 ParentType=(Name=Int32 ArrayRank=2 ParentType=Int32)))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=(Name=Int32 ArrayRank=1 ParentType=(Name=Int32 ArrayRank=2 ParentType=Int32)))]))") End Function Public Async Function TestMemberWithPointerType() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { struct S { } unsafe void $$M(S** p) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(Name=S Indirection=2 ParentType=C))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(Name=S Indirection=2 ParentType=C))]))") End Function Public Async Function TestMemberWithVoidPointerType() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { unsafe void $$M(void* p) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=(Name=Void Indirection=1))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=(Name=Void Indirection=1))]))") End Function Public Async Function TestMemberWithGenericTypeParameters() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(T t, U u) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(Name=C GenericParameterCount=1) Member=(Name=M GenericParameterCount=1 OverloadingParameters=[(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(Name=C GenericParameterCount=1) ParameterIdentifier=0),(ParameterIdentifier=0)]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(Name=C GenericParameterCount=1) Member=(Name=M GenericParameterCount=1 OverloadingParameters=[(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(Name=C GenericParameterCount=1) ParameterIdentifier=0),(ParameterIdentifier=0)]))") End Function Public Async Function TestMemberWithParameterTypeConstructedWithMemberTypeParameter() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(T t, System.Func u) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M GenericParameterCount=1 OverloadingParameters=[(ParameterIdentifier=0),(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=(Name=Func GenericParameterCount=2 GenericArguments=[(ParameterIdentifier=0),(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M GenericParameterCount=1 OverloadingParameters=[(ParameterIdentifier=0),(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=(Name=Func GenericParameterCount=2 GenericArguments=[(ParameterIdentifier=0),(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]))]))") End Function Public Async Function TestMemberWithArraysOfGenericTypeParameters() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(T[] t, U[] u) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(Name=C GenericParameterCount=1) Member=(Name=M GenericParameterCount=1 OverloadingParameters=[(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(ArrayRank=1 ParentType=(Type=(Name=C GenericParameterCount=1) ParameterIdentifier=0))),(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(ArrayRank=1 ParentType=(ParameterIdentifier=0)))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(Name=C GenericParameterCount=1) Member=(Name=M GenericParameterCount=1 OverloadingParameters=[(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(ArrayRank=1 ParentType=(Type=(Name=C GenericParameterCount=1) ParameterIdentifier=0))),(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(ArrayRank=1 ParentType=(ParameterIdentifier=0)))]))") End Function Public Async Function TestMemberWithArraysOfGenericTypeParameters2() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(T[][,] t, U[][,] u) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(Name=C GenericParameterCount=1) Member=(Name=M GenericParameterCount=1 OverloadingParameters=[(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(ArrayRank=1 ParentType=(ArrayRank=2 ParentType=(Type=(Name=C GenericParameterCount=1) ParameterIdentifier=0)))),(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=(ArrayRank=1 ParentType=(ArrayRank=2 ParentType=(ParameterIdentifier=0))))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(Name=C GenericParameterCount=1) Member=(Name=M GenericParameterCount=1 OverloadingParameters=[(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(ArrayRank=1 ParentType=(ArrayRank=2 ParentType=(Type=(Name=C GenericParameterCount=1) ParameterIdentifier=0)))),(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=(ArrayRank=1 ParentType=(ArrayRank=2 ParentType=(ParameterIdentifier=0))))]))") End Function Public Async Function TestMemberWithGenericType() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(System.Collections.Generic.List p) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System.Collections.Generic Type=(Name=List GenericParameterCount=1 GenericArguments=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System.Collections.Generic Type=(Name=List GenericParameterCount=1 GenericArguments=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System Type=Int32)]))]))") End Function Public Async Function TestMemberWithDynamicType() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(dynamic d) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Namespace=System Type=Object)]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Namespace=System Type=Object)]))") End Function Public Async Function TestMemberWithGenericTypeOfDynamicType() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(System.Collections.Generic.List p) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System.Collections.Generic Type=(Name=List GenericParameterCount=1 GenericArguments=[(Namespace=System Type=Object)]))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Assembly=file:///Z:/FxReferenceAssembliesUri Namespace=System.Collections.Generic Type=(Name=List GenericParameterCount=1 GenericArguments=[(Namespace=System Type=Object)]))]))") End Function Public Async Function TestMemberWithArrayOfDynamicType() As Task Await AssertMarkedNodeIdIsAsync( "namespace N { class C { void $$M(dynamic[] d) { } } }", - "(Assembly=file:///Z:/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Namespace=System Type=(Name=Object ArrayRank=1 ParentType=Object))]))") + "(Assembly=file:///Z:/bin/CSharpAssembly1.dll Namespace=N Type=C Member=(Name=M OverloadingParameters=[(Namespace=System Type=(Name=Object ArrayRank=1 ParentType=Object))]))") End Function diff --git a/src/VisualStudio/Core/Test/Progression/ImplementedByGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/ImplementedByGraphQueryTests.vb index f041252b27a9c..fa776780712f6 100644 --- a/src/VisualStudio/Core/Test/Progression/ImplementedByGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/ImplementedByGraphQueryTests.vb @@ -63,7 +63,7 @@ class Goo2 : Base, IBlah - + ) End Using diff --git a/src/VisualStudio/Core/Test/Progression/ImplementsGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/ImplementsGraphQueryTests.vb index e9eeb14818fcb..1cce66f485dc7 100644 --- a/src/VisualStudio/Core/Test/Progression/ImplementsGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/ImplementsGraphQueryTests.vb @@ -37,7 +37,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) @@ -77,7 +77,7 @@ class Goo : IComparable - + ) diff --git a/src/VisualStudio/Core/Test/Progression/InheritedByGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/InheritedByGraphQueryTests.vb index b354de0f5acef..333c3bbf6ef51 100644 --- a/src/VisualStudio/Core/Test/Progression/InheritedByGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/InheritedByGraphQueryTests.vb @@ -67,7 +67,7 @@ class ReallyDerived : Goo // should not be shown as inherited by Base - + ) End Using @@ -115,7 +115,7 @@ interface I3 : I2 // should not be shown as inherited by I - + ) End Using @@ -175,7 +175,7 @@ End Class - + ) End Using @@ -228,7 +228,7 @@ End Interface - + ) End Using diff --git a/src/VisualStudio/Core/Test/Progression/InheritsFromGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/InheritsFromGraphQueryTests.vb index 37c17c1fecc2d..8379a19d621f2 100644 --- a/src/VisualStudio/Core/Test/Progression/InheritsFromGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/InheritsFromGraphQueryTests.vb @@ -36,7 +36,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) @@ -68,7 +68,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using @@ -105,8 +105,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - - + + ) End Using diff --git a/src/VisualStudio/Core/Test/Progression/IsCalledByGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/IsCalledByGraphQueryTests.vb index ef68863f351d5..e25024ffc3003 100644 --- a/src/VisualStudio/Core/Test/Progression/IsCalledByGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/IsCalledByGraphQueryTests.vb @@ -56,7 +56,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) End Using diff --git a/src/VisualStudio/Core/Test/Progression/IsUsedByGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/IsUsedByGraphQueryTests.vb index 192cc02f2e131..7c1914ffe879c 100644 --- a/src/VisualStudio/Core/Test/Progression/IsUsedByGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/IsUsedByGraphQueryTests.vb @@ -49,7 +49,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression - + ) diff --git a/src/VisualStudio/Core/Test/Progression/OverriddenByGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/OverriddenByGraphQueryTests.vb index 6b798f34b6650..2dc28dc9c5bb0 100644 --- a/src/VisualStudio/Core/Test/Progression/OverriddenByGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/OverriddenByGraphQueryTests.vb @@ -47,7 +47,7 @@ class Goo : Base, IComparable - + ) @@ -92,7 +92,7 @@ class Goo : Base, IComparable - + ) diff --git a/src/VisualStudio/Core/Test/Progression/OverridesGraphQueryTests.vb b/src/VisualStudio/Core/Test/Progression/OverridesGraphQueryTests.vb index cb33dc15b64a2..ef9f77e03ca9d 100644 --- a/src/VisualStudio/Core/Test/Progression/OverridesGraphQueryTests.vb +++ b/src/VisualStudio/Core/Test/Progression/OverridesGraphQueryTests.vb @@ -50,7 +50,7 @@ class Goo : Base, IComparable - + ) @@ -92,7 +92,7 @@ class Goo : Base, IComparable - + ) diff --git a/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpCompilationFactoryService.cs b/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpCompilationFactoryService.cs index a41480b270449..fdacae470f2ba 100644 --- a/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpCompilationFactoryService.cs +++ b/src/Workspaces/CSharp/Portable/Workspace/LanguageServices/CSharpCompilationFactoryService.cs @@ -53,8 +53,6 @@ CompilationOptions ICompilationFactoryService.GetDefaultCompilationOptions() return new CSharpCompilationOptions(outputKind: outputKind); } - GeneratorDriver ICompilationFactoryService.CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray additionalTexts) - { - return CSharpGeneratorDriver.Create(generators, additionalTexts, (CSharpParseOptions)parseOptions, optionsProvider); - } + GeneratorDriver ICompilationFactoryService.CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray additionalTexts, string? generatedFilesBaseDirectory) + => CSharpGeneratorDriver.Create(generators, additionalTexts, (CSharpParseOptions)parseOptions, optionsProvider, new GeneratorDriverOptions(baseDirectory: generatedFilesBaseDirectory)); } diff --git a/src/Workspaces/Core/MSBuild.BuildHost/MSBuild/Constants/PropertyNames.cs b/src/Workspaces/Core/MSBuild.BuildHost/MSBuild/Constants/PropertyNames.cs index bd5d2d46f7833..95f57a92100ca 100644 --- a/src/Workspaces/Core/MSBuild.BuildHost/MSBuild/Constants/PropertyNames.cs +++ b/src/Workspaces/Core/MSBuild.BuildHost/MSBuild/Constants/PropertyNames.cs @@ -65,6 +65,7 @@ internal static class PropertyNames public const string TargetFrameworkVersion = nameof(TargetFrameworkVersion); public const string TargetPath = nameof(TargetPath); public const string TargetRefPath = nameof(TargetRefPath); + public const string CompilerGeneratedFilesOutputPath = nameof(CompilerGeneratedFilesOutputPath); public const string TreatWarningsAsErrors = nameof(TreatWarningsAsErrors); public const string VbRuntime = nameof(VbRuntime); public const string WarningLevel = nameof(WarningLevel); diff --git a/src/Workspaces/Core/MSBuild.BuildHost/MSBuild/ProjectFile/ProjectFile.cs b/src/Workspaces/Core/MSBuild.BuildHost/MSBuild/ProjectFile/ProjectFile.cs index 7aad5f1121ef8..f869df293b45e 100644 --- a/src/Workspaces/Core/MSBuild.BuildHost/MSBuild/ProjectFile/ProjectFile.cs +++ b/src/Workspaces/Core/MSBuild.BuildHost/MSBuild/ProjectFile/ProjectFile.cs @@ -131,6 +131,11 @@ private ProjectFileInfo CreateProjectFileInfo(MSB.Execution.ProjectInstance proj outputRefFilePath = GetAbsolutePathRelativeToProject(outputRefFilePath); } + var generatedFilesOutputDirectory = project.ReadPropertyString(PropertyNames.CompilerGeneratedFilesOutputPath); + generatedFilesOutputDirectory = RoslynString.IsNullOrWhiteSpace(generatedFilesOutputDirectory) + ? null + : GetAbsolutePathRelativeToProject(generatedFilesOutputDirectory); + var intermediateOutputFilePath = project.GetItems(ItemNames.IntermediateAssembly).FirstOrDefault()?.EvaluatedInclude; if (!RoslynString.IsNullOrWhiteSpace(intermediateOutputFilePath)) { @@ -176,26 +181,29 @@ private ProjectFileInfo CreateProjectFileInfo(MSB.Execution.ProjectInstance proj var fileGlobs = _loadedProject?.GetAllGlobs().Select(GetFileGlobs).ToImmutableArray() ?? []; - return ProjectFileInfo.Create( - Language, - project.FullPath, - outputFilePath, - outputRefFilePath, - intermediateOutputFilePath, - defaultNamespace, - targetFramework, - targetFrameworkIdentifier, - targetFrameworkVersion, - projectAssetsFilePath, - commandLineArgs, - docs, - additionalDocs, - analyzerConfigDocs, - project.GetProjectReferences().ToImmutableArray(), - packageReferences, - projectCapabilities, - contentFileInfo, - fileGlobs); + return new ProjectFileInfo() + { + Language = Language, + FilePath = project.FullPath, + OutputFilePath = outputFilePath, + OutputRefFilePath = outputRefFilePath, + GeneratedFilesOutputDirectory = generatedFilesOutputDirectory, + IntermediateOutputFilePath = intermediateOutputFilePath, + DefaultNamespace = defaultNamespace, + TargetFramework = targetFramework, + TargetFrameworkIdentifier = targetFrameworkIdentifier, + TargetFrameworkVersion = targetFrameworkVersion, + ProjectAssetsFilePath = projectAssetsFilePath, + CommandLineArgs = commandLineArgs, + Documents = docs, + AdditionalDocuments = additionalDocs, + AnalyzerConfigDocuments = analyzerConfigDocs, + ProjectReferences = project.GetProjectReferences().ToImmutableArray(), + PackageReferences = packageReferences, + ProjectCapabilities = projectCapabilities, + ContentFilePaths = contentFileInfo, + FileGlobs = fileGlobs + }; static FileGlobs GetFileGlobs(GlobResult g) { diff --git a/src/Workspaces/Core/MSBuild.BuildHost/Rpc/Contracts/ProjectFileInfo.cs b/src/Workspaces/Core/MSBuild.BuildHost/Rpc/Contracts/ProjectFileInfo.cs index ea1f3fc969f5a..f792098d8f47b 100644 --- a/src/Workspaces/Core/MSBuild.BuildHost/Rpc/Contracts/ProjectFileInfo.cs +++ b/src/Workspaces/Core/MSBuild.BuildHost/Rpc/Contracts/ProjectFileInfo.cs @@ -16,38 +16,41 @@ namespace Microsoft.CodeAnalysis.MSBuild [DataContract] internal sealed class ProjectFileInfo { - [DataMember(Order = 0)] - public bool IsEmpty { get; } + [DataMember] + public bool IsEmpty { get; init; } /// /// The language of this project. /// - [DataMember(Order = 1)] - public string Language { get; } + [DataMember] + public required string Language { get; init; } /// /// The path to the project file for this project. /// - [DataMember(Order = 2)] - public string? FilePath { get; } + [DataMember] + public string? FilePath { get; init; } /// /// The path to the output file this project generates. /// - [DataMember(Order = 3)] - public string? OutputFilePath { get; } + [DataMember] + public string? OutputFilePath { get; init; } /// /// The path to the reference assembly output file this project generates. /// - [DataMember(Order = 4)] - public string? OutputRefFilePath { get; } + [DataMember] + public string? OutputRefFilePath { get; init; } /// /// The path to the intermediate output file this project generates. /// - [DataMember(Order = 5)] - public string? IntermediateOutputFilePath { get; } + [DataMember] + public string? IntermediateOutputFilePath { get; init; } + + [DataMember] + public string? GeneratedFilesOutputDirectory { get; init; } /// /// The default namespace of the project ("" if not defined, which means global namespace), @@ -60,200 +63,106 @@ internal sealed class ProjectFileInfo /// In the future, we might consider officially exposing "default namespace" for VB project /// (e.g. through a "defaultnamespace" msbuild property) /// - [DataMember(Order = 6)] - public string? DefaultNamespace { get; } + [DataMember] + public string? DefaultNamespace { get; init; } /// /// The target framework of this project. /// This takes the form of the 'short name' form used by NuGet (e.g. net46, netcoreapp2.0, etc.) /// - [DataMember(Order = 7)] - public string? TargetFramework { get; } + [DataMember] + public string? TargetFramework { get; init; } /// /// The target framework identifier of this project. /// Used to determine if a project is targeting .net core. /// - [DataMember(Order = 8)] - public string? TargetFrameworkIdentifier { get; } + [DataMember] + public string? TargetFrameworkIdentifier { get; init; } /// /// The command line args used to compile the project. /// - [DataMember(Order = 9)] - public ImmutableArray CommandLineArgs { get; } + [DataMember] + public ImmutableArray CommandLineArgs { get; init; } /// /// The source documents. /// - [DataMember(Order = 10)] - public ImmutableArray Documents { get; } + [DataMember] + public ImmutableArray Documents { get; init; } /// /// The additional documents. /// - [DataMember(Order = 11)] - public ImmutableArray AdditionalDocuments { get; } + [DataMember] + public ImmutableArray AdditionalDocuments { get; init; } /// /// The analyzer config documents. /// - [DataMember(Order = 12)] - public ImmutableArray AnalyzerConfigDocuments { get; } + [DataMember] + public ImmutableArray AnalyzerConfigDocuments { get; init; } /// /// References to other projects. /// - [DataMember(Order = 13)] - public ImmutableArray ProjectReferences { get; } + [DataMember] + public ImmutableArray ProjectReferences { get; init; } /// /// The msbuild project capabilities. /// - [DataMember(Order = 14)] - public ImmutableArray ProjectCapabilities { get; } + [DataMember] + public ImmutableArray ProjectCapabilities { get; init; } /// /// The paths to content files included in the project. /// - [DataMember(Order = 15)] - public ImmutableArray ContentFilePaths { get; } + [DataMember] + public ImmutableArray ContentFilePaths { get; init; } /// /// The path to the project.assets.json path in obj/. /// - [DataMember(Order = 16)] - public string? ProjectAssetsFilePath { get; } + [DataMember] + public string? ProjectAssetsFilePath { get; init; } /// /// Any package references defined on the project. /// - [DataMember(Order = 17)] - public ImmutableArray PackageReferences { get; } + [DataMember] + public ImmutableArray PackageReferences { get; init; } /// /// Target framework version (for .net framework projects) /// - [DataMember(Order = 18)] - public string? TargetFrameworkVersion { get; } + [DataMember] + public string? TargetFrameworkVersion { get; init; } - [DataMember(Order = 19)] - public ImmutableArray FileGlobs { get; } + [DataMember] + public ImmutableArray FileGlobs { get; init; } public override string ToString() => RoslynString.IsNullOrWhiteSpace(TargetFramework) ? FilePath ?? string.Empty : $"{FilePath} ({TargetFramework})"; - public ProjectFileInfo( - bool isEmpty, - string language, - string? filePath, - string? outputFilePath, - string? outputRefFilePath, - string? intermediateOutputFilePath, - string? defaultNamespace, - string? targetFramework, - string? targetFrameworkIdentifier, - string? targetFrameworkVersion, - string? projectAssetsFilePath, - ImmutableArray commandLineArgs, - ImmutableArray documents, - ImmutableArray additionalDocuments, - ImmutableArray analyzerConfigDocuments, - ImmutableArray projectReferences, - ImmutableArray packageReferences, - ImmutableArray projectCapabilities, - ImmutableArray contentFilePaths, - ImmutableArray fileGlobs) - { - RoslynDebug.Assert(filePath != null); - - this.IsEmpty = isEmpty; - this.Language = language; - this.FilePath = filePath; - this.OutputFilePath = outputFilePath; - this.OutputRefFilePath = outputRefFilePath; - this.IntermediateOutputFilePath = intermediateOutputFilePath; - this.DefaultNamespace = defaultNamespace; - this.TargetFramework = targetFramework; - this.TargetFrameworkIdentifier = targetFrameworkIdentifier; - this.TargetFrameworkVersion = targetFrameworkVersion; - this.ProjectAssetsFilePath = projectAssetsFilePath; - this.CommandLineArgs = commandLineArgs; - this.Documents = documents; - this.AdditionalDocuments = additionalDocuments; - this.AnalyzerConfigDocuments = analyzerConfigDocuments; - this.ProjectReferences = projectReferences; - this.PackageReferences = packageReferences; - this.ProjectCapabilities = projectCapabilities; - this.ContentFilePaths = contentFilePaths; - this.FileGlobs = fileGlobs; - } - - public static ProjectFileInfo Create( - string language, - string? filePath, - string? outputFilePath, - string? outputRefFilePath, - string? intermediateOutputFilePath, - string? defaultNamespace, - string? targetFramework, - string? targetFrameworkIdentifier, - string? targetFrameworkVersion, - string? projectAssetsFilePath, - ImmutableArray commandLineArgs, - ImmutableArray documents, - ImmutableArray additionalDocuments, - ImmutableArray analyzerConfigDocuments, - ImmutableArray projectReferences, - ImmutableArray packageReferences, - ImmutableArray projectCapabilities, - ImmutableArray contentFilePaths, - ImmutableArray fileGlobs) - => new( - isEmpty: false, - language, - filePath, - outputFilePath, - outputRefFilePath, - intermediateOutputFilePath, - defaultNamespace, - targetFramework, - targetFrameworkIdentifier, - targetFrameworkVersion, - projectAssetsFilePath, - commandLineArgs, - documents, - additionalDocuments, - analyzerConfigDocuments, - projectReferences, - packageReferences, - projectCapabilities, - contentFilePaths, - fileGlobs); - public static ProjectFileInfo CreateEmpty(string language, string? filePath) - => new( - isEmpty: true, - language, - filePath, - outputFilePath: null, - outputRefFilePath: null, - intermediateOutputFilePath: null, - defaultNamespace: null, - targetFramework: null, - targetFrameworkIdentifier: null, - targetFrameworkVersion: null, - projectAssetsFilePath: null, - commandLineArgs: [], - documents: [], - additionalDocuments: [], - analyzerConfigDocuments: [], - projectReferences: [], - packageReferences: [], - projectCapabilities: [], - contentFilePaths: [], - fileGlobs: []); + => new() + { + IsEmpty = true, + Language = language, + FilePath = filePath, + CommandLineArgs = [], + Documents = [], + AdditionalDocuments = [], + AnalyzerConfigDocuments = [], + ProjectReferences = [], + PackageReferences = [], + ProjectCapabilities = [], + ContentFilePaths = [], + FileGlobs = [] + }; } } diff --git a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker.cs b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker.cs index 80965e8be4ffc..0ed0792b650fd 100644 --- a/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker.cs +++ b/src/Workspaces/Core/MSBuild/MSBuild/MSBuildProjectLoader.Worker.cs @@ -302,8 +302,10 @@ private Task CreateProjectInfoAsync(ProjectFileInfo projectFileInfo name: projectName, assemblyName: assemblyName, language: language, - compilationOutputInfo: new CompilationOutputInfo(projectFileInfo.IntermediateOutputFilePath), + compilationOutputInfo: new CompilationOutputInfo(projectFileInfo.IntermediateOutputFilePath, projectFileInfo.GeneratedFilesOutputDirectory), checksumAlgorithm: SourceHashAlgorithms.Default, + outputFilePath: projectFileInfo.OutputFilePath, + outputRefFilePath: projectFileInfo.OutputRefFilePath, filePath: projectPath), compilationOptions: compilationOptions, parseOptions: parseOptions)); @@ -370,7 +372,7 @@ private Task CreateProjectInfoAsync(ProjectFileInfo projectFileInfo projectName, assemblyName, language, - compilationOutputInfo: new CompilationOutputInfo(projectFileInfo.IntermediateOutputFilePath), + compilationOutputInfo: new CompilationOutputInfo(projectFileInfo.IntermediateOutputFilePath, projectFileInfo.GeneratedFilesOutputDirectory), checksumAlgorithm: commandLineArgs.ChecksumAlgorithm, filePath: projectPath, outputFilePath: projectFileInfo.OutputFilePath, @@ -385,8 +387,7 @@ private Task CreateProjectInfoAsync(ProjectFileInfo projectFileInfo additionalDocuments: additionalDocuments, hostObjectType: null) .WithDefaultNamespace(projectFileInfo.DefaultNamespace) - .WithAnalyzerConfigDocuments(analyzerConfigDocuments) - .WithCompilationOutputInfo(new CompilationOutputInfo(projectFileInfo.OutputFilePath)); + .WithAnalyzerConfigDocuments(analyzerConfigDocuments); }); } diff --git a/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt b/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt index 2ebc1a3610226..c946a98eac9b4 100644 --- a/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt @@ -1,3 +1,5 @@ +Microsoft.CodeAnalysis.CompilationOutputInfo.GeneratedFilesOutputDirectory.get -> string +Microsoft.CodeAnalysis.CompilationOutputInfo.WithGeneratedFilesOutputDirectory(string path) -> Microsoft.CodeAnalysis.CompilationOutputInfo Microsoft.CodeAnalysis.ProjectInfo.WithId(Microsoft.CodeAnalysis.ProjectId id) -> Microsoft.CodeAnalysis.ProjectInfo virtual Microsoft.CodeAnalysis.Host.HostLanguageServices.Dispose() -> void virtual Microsoft.CodeAnalysis.Host.HostWorkspaceServices.Dispose() -> void diff --git a/src/Workspaces/Core/Portable/Workspace/CommandLineProject.cs b/src/Workspaces/Core/Portable/Workspace/CommandLineProject.cs index 4696dc7f4770b..5e1cd4a722824 100644 --- a/src/Workspaces/Core/Portable/Workspace/CommandLineProject.cs +++ b/src/Workspaces/Core/Portable/Workspace/CommandLineProject.cs @@ -112,6 +112,8 @@ public static ProjectInfo CreateProjectInfo(string projectName, string language, // TODO (tomat): what should be the assemblyName when compiling a netmodule? Should it be /moduleassemblyname + var outputFilePath = commandLineArguments.OutputFileName != null ? commandLineArguments.GetOutputFilePath(commandLineArguments.OutputFileName) : null; + var projectInfo = ProjectInfo.Create( new ProjectInfo.ProjectAttributes( id: projectId, @@ -119,7 +121,9 @@ public static ProjectInfo CreateProjectInfo(string projectName, string language, name: projectName, assemblyName: assemblyName, language: language, - compilationOutputInfo: new CompilationOutputInfo(commandLineArguments.OutputFileName != null ? commandLineArguments.GetOutputFilePath(commandLineArguments.OutputFileName) : null), + compilationOutputInfo: new CompilationOutputInfo(outputFilePath, commandLineArguments.GeneratedFilesOutputDirectory), + outputFilePath: outputFilePath, + outputRefFilePath: commandLineArguments.OutputRefFilePath, checksumAlgorithm: commandLineArguments.ChecksumAlgorithm), compilationOptions: commandLineArguments.CompilationOptions .WithXmlReferenceResolver(xmlFileResolver) diff --git a/src/Workspaces/Core/Portable/Workspace/Host/CompilationFactory/ICompilationFactoryService.cs b/src/Workspaces/Core/Portable/Workspace/Host/CompilationFactory/ICompilationFactoryService.cs index 08d1886b64ecf..d7b3894c23cd6 100644 --- a/src/Workspaces/Core/Portable/Workspace/Host/CompilationFactory/ICompilationFactoryService.cs +++ b/src/Workspaces/Core/Portable/Workspace/Host/CompilationFactory/ICompilationFactoryService.cs @@ -15,5 +15,5 @@ internal interface ICompilationFactoryService : ILanguageService Compilation CreateSubmissionCompilation(string assemblyName, CompilationOptions options, Type? hostObjectType); CompilationOptions GetDefaultCompilationOptions(); CompilationOptions? TryParsePdbCompilationOptions(IReadOnlyDictionary compilationOptionsMetadata); - GeneratorDriver CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray additionalTexts); + GeneratorDriver CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray additionalTexts, string? generatedFilesBaseDirectory); } diff --git a/src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProject.cs b/src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProject.cs index c0e0f9ef61bd8..1773b57899252 100644 --- a/src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProject.cs +++ b/src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProject.cs @@ -80,6 +80,7 @@ internal sealed partial class ProjectSystemProject private string? _compilationOutputAssemblyFilePath; private string? _outputFilePath; private string? _outputRefFilePath; + private string? _generatedFilesOutputDirectory; private string? _defaultNamespace; /// @@ -376,6 +377,18 @@ internal string? CompilationOutputAssemblyFilePath s => s.WithProjectCompilationOutputInfo(Id, s.GetRequiredProject(Id).CompilationOutputInfo.WithAssemblyPath(value))); } + /// + /// The path to the source generated files. + /// + internal string? GeneratedFilesOutputDirectory + { + get => _generatedFilesOutputDirectory; + set => ChangeProjectOutputPath( + ref _generatedFilesOutputDirectory, + value, + s => s.WithProjectCompilationOutputInfo(Id, s.GetRequiredProject(Id).CompilationOutputInfo.WithGeneratedFilesOutputDirectory(value))); + } + public string? OutputFilePath { get => _outputFilePath; diff --git a/src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProjectFactory.cs b/src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProjectFactory.cs index b13bc77fbfa10..be792ae5846cf 100644 --- a/src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProjectFactory.cs +++ b/src/Workspaces/Core/Portable/Workspace/ProjectSystem/ProjectSystemProjectFactory.cs @@ -125,8 +125,10 @@ public async Task CreateAndAddToWorkspaceAsync(string proj name: projectSystemName, assemblyName, language, - compilationOutputInfo: new(creationInfo.CompilationOutputAssemblyFilePath), + // generatedFilesOutputDirectory to be updated when initializing project from command line: + compilationOutputInfo: new(creationInfo.CompilationOutputAssemblyFilePath, generatedFilesOutputDirectory: null), SourceHashAlgorithms.Default, // will be updated when command line is set + outputFilePath: creationInfo.CompilationOutputAssemblyFilePath, filePath: creationInfo.FilePath, telemetryId: creationInfo.TelemetryId), compilationOptions: creationInfo.CompilationOptions, diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/CompilationOutputFilePaths.cs b/src/Workspaces/Core/Portable/Workspace/Solution/CompilationOutputFilePaths.cs deleted file mode 100644 index daa915956f5a8..0000000000000 --- a/src/Workspaces/Core/Portable/Workspace/Solution/CompilationOutputFilePaths.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using Roslyn.Utilities; - -namespace Microsoft.CodeAnalysis; - -/// -/// Paths of files produced by the compilation. -/// -public readonly struct CompilationOutputInfo : IEquatable -{ - /// - /// Full path to the assembly or module produced by the compilation, or if unknown. - /// - public readonly string? AssemblyPath { get; } - - // TODO: https://github.com/dotnet/roslyn/issues/35065 - // The project system doesn't currently provide paths to the PDB or XML files that the compiler produces. - // public readonly string? PdbPath { get; } - // public readonly string? DocumentationCommentsPath { get; } - - internal CompilationOutputInfo(string? assemblyPath) - { - AssemblyPath = assemblyPath; - } - -#pragma warning disable CA1822 // Mark members as static - unshipped public API which will use instance members in future https://github.com/dotnet/roslyn/issues/35065 - public CompilationOutputInfo WithAssemblyPath(string? path) -#pragma warning restore CA1822 // Mark members as static - => new(assemblyPath: path); - - public override bool Equals(object? obj) - => obj is CompilationOutputInfo info && Equals(info); - - public bool Equals(CompilationOutputInfo other) - => AssemblyPath == other.AssemblyPath; - - public override int GetHashCode() - => AssemblyPath?.GetHashCode() ?? 0; - - public static bool operator ==(in CompilationOutputInfo left, in CompilationOutputInfo right) - => left.Equals(right); - - public static bool operator !=(in CompilationOutputInfo left, in CompilationOutputInfo right) - => !left.Equals(right); - - internal void WriteTo(ObjectWriter writer) - { - writer.WriteString(AssemblyPath); - } - - internal static CompilationOutputInfo ReadFrom(ObjectReader reader) - { - var assemblyPath = reader.ReadString(); - return new CompilationOutputInfo(assemblyPath); - } -} diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/CompilationOutputInfo.cs b/src/Workspaces/Core/Portable/Workspace/Solution/CompilationOutputInfo.cs new file mode 100644 index 0000000000000..768418b64b31e --- /dev/null +++ b/src/Workspaces/Core/Portable/Workspace/Solution/CompilationOutputInfo.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using Roslyn.Utilities; + +namespace Microsoft.CodeAnalysis; + +/// +/// Paths of files produced by the compilation. +/// +public readonly struct CompilationOutputInfo : IEquatable +{ + /// + /// Full path to the assembly or module produced by the compilation, or if unknown. + /// + public readonly string? AssemblyPath { get; } + + /// + /// Absolute path to the root directory of source generated files, or null if it is not known. + /// + public readonly string? GeneratedFilesOutputDirectory { get; } + + // TODO: https://github.com/dotnet/roslyn/issues/35065 + // The project system doesn't currently provide paths to the PDB or XML files that the compiler produces. + // public readonly string? PdbPath { get; } + // public readonly string? DocumentationCommentsPath { get; } + + internal CompilationOutputInfo(string? assemblyPath, string? generatedFilesOutputDirectory) + { + AssemblyPath = assemblyPath; + GeneratedFilesOutputDirectory = generatedFilesOutputDirectory; + } + + public CompilationOutputInfo WithAssemblyPath(string? path) + => new(assemblyPath: path, GeneratedFilesOutputDirectory); + + public CompilationOutputInfo WithGeneratedFilesOutputDirectory(string? path) + { + if (path != null && !PathUtilities.IsAbsolute(path)) + { + throw new ArgumentException(WorkspacesResources.AbsolutePathExpected, nameof(path)); + } + + return new(AssemblyPath, path); + } + + /// + /// True if the project has an absolute generated source file output path. + /// + /// Must be true for any workspace that supports EnC. If false, the compiler and IDE wouldn't agree on the file paths of source-generated files, + /// which might cause different metadata to be emitted for file-scoped classes between compilation and EnC. + /// + internal bool HasEffectiveGeneratedFilesOutputDirectory + => PathUtilities.IsAbsolute(GeneratedFilesOutputDirectory ?? AssemblyPath); + + /// + /// Absolute path of a directory used to produce absolute file paths of source generated files. + /// + internal string? GetEffectiveGeneratedFilesOutputDirectory() + => HasEffectiveGeneratedFilesOutputDirectory ? GeneratedFilesOutputDirectory ?? PathUtilities.GetDirectoryName(AssemblyPath) : null; + + public override bool Equals(object? obj) + => obj is CompilationOutputInfo info && Equals(info); + + public bool Equals(CompilationOutputInfo other) + => AssemblyPath == other.AssemblyPath && + GeneratedFilesOutputDirectory == other.GeneratedFilesOutputDirectory; + + public override int GetHashCode() + => Hash.Combine(GeneratedFilesOutputDirectory, Hash.Combine(AssemblyPath, 0)); + + public static bool operator ==(in CompilationOutputInfo left, in CompilationOutputInfo right) + => left.Equals(right); + + public static bool operator !=(in CompilationOutputInfo left, in CompilationOutputInfo right) + => !left.Equals(right); + + internal void WriteTo(ObjectWriter writer) + { + writer.WriteString(AssemblyPath); + writer.WriteString(GeneratedFilesOutputDirectory); + } + + internal static CompilationOutputInfo ReadFrom(ObjectReader reader) + { + var assemblyPath = reader.ReadString(); + var generatedFilesOutputDirectory = reader.ReadString(); + return new CompilationOutputInfo(assemblyPath, generatedFilesOutputDirectory); + } +} diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/Project.cs b/src/Workspaces/Core/Portable/Workspace/Solution/Project.cs index ea32cc1235445..db2397d2b47fd 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/Project.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/Project.cs @@ -579,6 +579,15 @@ public Project WithAssemblyName(string assemblyName) public Project WithDefaultNamespace(string defaultNamespace) => this.Solution.WithProjectDefaultNamespace(this.Id, defaultNamespace).GetRequiredProject(Id); + internal Project WithOutputFilePath(string? path) + => Solution.WithProjectOutputFilePath(Id, path).GetRequiredProject(Id); + + internal Project WithOutputRefFilePath(string? path) + => Solution.WithProjectOutputRefFilePath(Id, path).GetRequiredProject(Id); + + internal Project WithCompilationOutputInfo(in CompilationOutputInfo info) + => Solution.WithProjectCompilationOutputInfo(Id, info).GetRequiredProject(Id); + /// /// Creates a new instance of this project updated to have the specified compilation options. /// diff --git a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionCompilationState.RegularCompilationTracker_Generators.cs b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionCompilationState.RegularCompilationTracker_Generators.cs index 4eabb1b9fc8ab..c827c2c151279 100644 --- a/src/Workspaces/Core/Portable/Workspace/Solution/SolutionCompilationState.RegularCompilationTracker_Generators.cs +++ b/src/Workspaces/Core/Portable/Workspace/Solution/SolutionCompilationState.RegularCompilationTracker_Generators.cs @@ -390,6 +390,7 @@ await newGeneratedDocuments.States.Values.SelectAsArrayAsync( static GeneratorDriver CreateGeneratorDriver(ProjectState projectState) { + var generatedFilesBaseDirectory = projectState.CompilationOutputInfo.GetEffectiveGeneratedFilesOutputDirectory(); var additionalTexts = projectState.AdditionalDocumentStates.SelectAsArray(static documentState => documentState.AdditionalText); var compilationFactory = projectState.LanguageServices.GetRequiredService(); @@ -397,7 +398,8 @@ static GeneratorDriver CreateGeneratorDriver(ProjectState projectState) projectState.ParseOptions!, GetSourceGenerators(projectState), projectState.AnalyzerOptions.AnalyzerConfigOptionsProvider, - additionalTexts); + additionalTexts, + generatedFilesBaseDirectory); } [Conditional("DEBUG")] diff --git a/src/Workspaces/Core/Portable/WorkspacesResources.resx b/src/Workspaces/Core/Portable/WorkspacesResources.resx index bd123c49ad251..4d20a5721081b 100644 --- a/src/Workspaces/Core/Portable/WorkspacesResources.resx +++ b/src/Workspaces/Core/Portable/WorkspacesResources.resx @@ -507,4 +507,7 @@ Changing project between ordinary and interactive submission is not supported + + Absolute path expected + \ No newline at end of file diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf index 5ede56b6d31a2..fcfad4d663a1a 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.cs.xlf @@ -7,6 +7,11 @@ Projekt nemůže odkazovat sám na sebe. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. Přidávání dokumentů konfigurace analyzátoru se nepodporuje. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf index 85808bb74a52e..889e14b18dbba 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.de.xlf @@ -7,6 +7,11 @@ Ein Projekt darf nicht auf sich selbst verweisen. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. Das Hinzufügen von Konfigurationsdokumenten des Analysetools wird nicht unterstützt. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf index bf2cfc7516dc8..de445306709b7 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.es.xlf @@ -7,6 +7,11 @@ Un proyecto no puede hacer referencia a sí mismo. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. No se permite agregar documentos de configuración del analizador. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf index 386d783f1df4f..d64a78d3cb82b 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.fr.xlf @@ -7,6 +7,11 @@ Un projet ne peut pas se référencer lui-même. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. L'ajout de documents de configuration de l'analyseur n'est pas pris en charge. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf index 9102370fc1f72..fc54f45929d8b 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.it.xlf @@ -7,6 +7,11 @@ Un progetto non può fare riferimento a se stesso. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. L'aggiunta di documenti di configurazione dell'analizzatore non è supportata. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf index b120a0d4d039d..7b1763a4bbd65 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ja.xlf @@ -7,6 +7,11 @@ プロジェクトで自己参照はできません。 + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. アナライザー構成ドキュメントの追加はサポートされていません。 diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf index 233b805566db6..0044b995cbf88 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ko.xlf @@ -7,6 +7,11 @@ 프로젝트는 자신을 참조할 수 없습니다. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. 분석기 구성 문서 추가는 지원되지 않습니다. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf index ab1b7c8645e21..91892e846c02e 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pl.xlf @@ -7,6 +7,11 @@ Projekt może nie odwoływać się do siebie. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. Dodawanie dokumentów z konfiguracją analizatora nie jest obsługiwane. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf index e2d255ceb2c9d..6906d75ca65d4 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.pt-BR.xlf @@ -7,6 +7,11 @@ Um projeto não pode fazer referência a si mesmo. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. Não há suporte para a adição de documentos da configuração do analisador. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf index 1756299af7308..1cd8551adbaf9 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.ru.xlf @@ -7,6 +7,11 @@ Проект не может ссылаться на себя. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. Добавление документов конфигурации анализатора не поддерживается. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf index 0820b03b3cbbb..58c31592c9354 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.tr.xlf @@ -7,6 +7,11 @@ Bir proje kendisine başvuru içeremez. + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. Çözümleyici yapılandırma belgelerinin eklenmesi desteklenmiyor. diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf index e25958c5b134f..7f99716cfc878 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hans.xlf @@ -7,6 +7,11 @@ 项目不能引用项目本身。 + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. 不支持添加分析器配置文档。 diff --git a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf index 53905d008aac0..ae8188a6e4080 100644 --- a/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf +++ b/src/Workspaces/Core/Portable/xlf/WorkspacesResources.zh-Hant.xlf @@ -7,6 +7,11 @@ 專案不可參考自己本身。 + + Absolute path expected + Absolute path expected + + Adding analyzer config documents is not supported. 不支援新增分析器組態文件。 diff --git a/src/Workspaces/CoreTest/Host/LanguageServices/TestCSharpCompilationFactoryServiceWithIncrementalGeneratorTracking.cs b/src/Workspaces/CoreTest/Host/LanguageServices/TestCSharpCompilationFactoryServiceWithIncrementalGeneratorTracking.cs index 5105879a0c3e2..0b64bbe5dd498 100644 --- a/src/Workspaces/CoreTest/Host/LanguageServices/TestCSharpCompilationFactoryServiceWithIncrementalGeneratorTracking.cs +++ b/src/Workspaces/CoreTest/Host/LanguageServices/TestCSharpCompilationFactoryServiceWithIncrementalGeneratorTracking.cs @@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Test.Utilities; namespace Microsoft.CodeAnalysis.UnitTests { @@ -54,9 +55,9 @@ CompilationOptions ICompilationFactoryService.GetDefaultCompilationOptions() return new CSharpCompilationOptions(outputKind: outputKind); } - GeneratorDriver ICompilationFactoryService.CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray additionalTexts) + GeneratorDriver ICompilationFactoryService.CreateGeneratorDriver(ParseOptions parseOptions, ImmutableArray generators, AnalyzerConfigOptionsProvider optionsProvider, ImmutableArray additionalTexts, string? generatedFilesBaseDirectory) { - return CSharpGeneratorDriver.Create(generators, additionalTexts, (CSharpParseOptions)parseOptions, optionsProvider, new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true)); + return CSharpGeneratorDriver.Create(generators, additionalTexts, (CSharpParseOptions)parseOptions, optionsProvider, new GeneratorDriverOptions(IncrementalGeneratorOutputKind.None, trackIncrementalGeneratorSteps: true, baseDirectory: TempRoot.Root)); } } } diff --git a/src/Workspaces/CoreTest/SolutionTests/ProjectInfoTests.cs b/src/Workspaces/CoreTest/SolutionTests/ProjectInfoTests.cs index 92f2091cc21e4..0b04a4d145f39 100644 --- a/src/Workspaces/CoreTest/SolutionTests/ProjectInfoTests.cs +++ b/src/Workspaces/CoreTest/SolutionTests/ProjectInfoTests.cs @@ -6,8 +6,10 @@ using System; using System.Collections.Immutable; +using System.IO; using System.Linq; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Roslyn.Test.Utilities; using Xunit; @@ -189,7 +191,7 @@ public void TestProperties() SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithFilePath(value), opt => opt.FilePath, "New"); SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithOutputFilePath(value), opt => opt.OutputFilePath, "New"); SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithOutputRefFilePath(value), opt => opt.OutputRefFilePath, "New"); - SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithCompilationOutputInfo(value), opt => opt.CompilationOutputInfo, new CompilationOutputInfo("NewPath")); + SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithCompilationOutputInfo(value), opt => opt.CompilationOutputInfo, new CompilationOutputInfo("NewPath", TempRoot.Root)); SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithDefaultNamespace(value), opt => opt.DefaultNamespace, "New"); SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithChecksumAlgorithm(value), opt => opt.ChecksumAlgorithm, SourceHashAlgorithm.None); SolutionTestHelpers.TestProperty(instance, (old, value) => old.WithHasAllInformation(value), opt => opt.HasAllInformation, false); diff --git a/src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs b/src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs index 81169657802d4..bec0e3b1b02ed 100644 --- a/src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs +++ b/src/Workspaces/CoreTest/SolutionTests/SolutionTests.cs @@ -1072,6 +1072,8 @@ public void WithProjectInfo() var metadataReference = MetadataReference.CreateFromImage([], filePath: "meta"); var projectReference = new ProjectReference(projectId2); var analyzerReference = new TestAnalyzerReference(); + var generatedOutputDir = Path.Combine(TempRoot.Root, "obj"); + var assemblyPath = Path.Combine(TempRoot.Root, "bin", "assemblyName.dll"); var newInfo = ProjectInfo.Create( projectId, @@ -1112,7 +1114,8 @@ public void WithProjectInfo() // add new document: newConfigDocumentInfo3, // remove existing document (c2) - ]); + ]) + .WithCompilationOutputInfo(new CompilationOutputInfo(assemblyPath, generatedOutputDir)); var newSolution = solution.WithProjectInfo(newInfo); var newProject = newSolution.GetRequiredProject(projectId); @@ -1124,6 +1127,7 @@ public void WithProjectInfo() Assert.Equal(newInfo.Language, newProject.Language); Assert.Equal(newInfo.FilePath, newProject.FilePath); Assert.Equal(newInfo.OutputFilePath, newProject.OutputFilePath); + Assert.Equal(newInfo.CompilationOutputInfo, newProject.CompilationOutputInfo); Assert.Equal(newInfo.CompilationOptions!.OutputKind, newProject.CompilationOptions!.OutputKind); Assert.Equal(newInfo.CompilationOptions!.ModuleName, newProject.CompilationOptions!.ModuleName); Assert.Equal(newInfo.ParseOptions!.LanguageVersion, newProject.ParseOptions!.LanguageVersion); @@ -1378,10 +1382,42 @@ public void WithProjectOutputFilePath() (string?)path, defaultThrows: false); + Assert.Throws("projectId", () => solution.WithProjectOutputFilePath(null!, "x.dll")); Assert.Throws("projectId", () => solution.WithProjectOutputFilePath(null!, "x.dll")); Assert.Throws(() => solution.WithProjectOutputFilePath(ProjectId.CreateNewId(), "x.dll")); } + [Fact] + public void GetEffectiveGeneratedFilesOutputDirectory() + { + var projectId = ProjectId.CreateNewId(); + + var objDir = Path.Combine(TempRoot.Root, "obj"); + var binDir = Path.Combine(TempRoot.Root, "bin"); + var otherDir = Path.Combine(TempRoot.Root, "other"); + + using var workspace = CreateWorkspace(); + var solution = workspace.CurrentSolution.AddProject(projectId, "proj1", "proj1.dll", LanguageNames.CSharp); + var project = solution.GetRequiredProject(projectId); + + Assert.False(project.CompilationOutputInfo.HasEffectiveGeneratedFilesOutputDirectory); + + project = project + .WithOutputFilePath(Path.Combine(binDir, "output.dll")) + .WithCompilationOutputInfo(new CompilationOutputInfo( + assemblyPath: Path.Combine(objDir, "output.dll"), + generatedFilesOutputDirectory: null)); + + Assert.True(project.CompilationOutputInfo.HasEffectiveGeneratedFilesOutputDirectory); + AssertEx.AreEqual(objDir, project.CompilationOutputInfo.GetEffectiveGeneratedFilesOutputDirectory()); + + project = project.WithCompilationOutputInfo( + project.CompilationOutputInfo.WithGeneratedFilesOutputDirectory(otherDir)); + + Assert.True(project.CompilationOutputInfo.HasEffectiveGeneratedFilesOutputDirectory); + AssertEx.AreEqual(otherDir, project.CompilationOutputInfo.GetEffectiveGeneratedFilesOutputDirectory()); + } + [Fact] public void WithProjectOutputRefFilePath() { @@ -1415,17 +1451,17 @@ public void WithProjectCompilationOutputInfo() .AddProject(projectId, "proj1", "proj1.dll", LanguageNames.CSharp); // any character is allowed - var path = "\0<>a/b/*.dll"; + var info = new CompilationOutputInfo("\0<>a/b/*.dll", TempRoot.Root + "<>\0"); SolutionTestHelpers.TestProperty( solution, (s, value) => s.WithProjectCompilationOutputInfo(projectId, value), s => s.GetRequiredProject(projectId).CompilationOutputInfo, - new CompilationOutputInfo(path), + info, defaultThrows: false); - Assert.Throws("projectId", () => solution.WithProjectCompilationOutputInfo(null!, new CompilationOutputInfo("x.dll"))); - Assert.Throws(() => solution.WithProjectCompilationOutputInfo(ProjectId.CreateNewId(), new CompilationOutputInfo("x.dll"))); + Assert.Throws("projectId", () => solution.WithProjectCompilationOutputInfo(null!, info)); + Assert.Throws(() => solution.WithProjectCompilationOutputInfo(ProjectId.CreateNewId(), info)); } [Fact] @@ -5583,7 +5619,10 @@ public async Task TestFrozenPartialSolution6() public async Task TestFrozenPartialSolution7(bool freeze) { using var workspace = WorkspaceTestUtilities.CreateWorkspaceWithPartialSemantics(); - var project1 = workspace.CurrentSolution.AddProject("CSharpProject1", "CSharpProject1", LanguageNames.CSharp); + var project1 = workspace.CurrentSolution + .AddProject("CSharpProject1", "CSharpProject1", LanguageNames.CSharp) + .WithCompilationOutputInfo(new CompilationOutputInfo(assemblyPath: Path.Combine(TempRoot.Root, "assembly.dll"), generatedFilesOutputDirectory: null)); + project1 = project1.AddDocument("Doc1", SourceText.From("class Doc1 { }")).Project; var invokeIndex = 1; diff --git a/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs b/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs index 00343b9845a23..122e24500d06d 100644 --- a/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs +++ b/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs @@ -36,9 +36,13 @@ public async Task SourceGeneratorBasedOnAdditionalFileGeneratesSyntaxTrees( // This test is just the sanity test to make sure generators work at all. There's not a special scenario being // tested. + var generatedFilesOutputDir = Path.Combine(TempRoot.Root, "gendir"); + var assemblyPath = Path.Combine(TempRoot.Root, "assemblyDir", "assembly.dll"); + using var workspace = CreateWorkspace(testHost: testHost); var analyzerReference = new TestGeneratorReference(new GenerateFileForEachAdditionalFileWithContentsCommented()); var project = AddEmptyProject(workspace.CurrentSolution) + .WithCompilationOutputInfo(new CompilationOutputInfo(assemblyPath, generatedFilesOutputDir)) .AddAnalyzerReference(analyzerReference); // Optionally fetch the compilation first, which validates that we handle both running the generator @@ -58,7 +62,7 @@ public async Task SourceGeneratorBasedOnAdditionalFileGeneratesSyntaxTrees( var generatedTree = Assert.Single(newCompilation.SyntaxTrees); var generatorType = typeof(GenerateFileForEachAdditionalFileWithContentsCommented); - Assert.Equal($"{generatorType.Assembly.GetName().Name}\\{generatorType.FullName}\\Test.generated.cs", generatedTree.FilePath); + Assert.Equal(Path.Combine(generatedFilesOutputDir, generatorType.Assembly.GetName().Name!, generatorType.FullName!, "Test.generated.cs"), generatedTree.FilePath); var generatedDocument = Assert.Single(await project.GetSourceGeneratedDocumentsAsync()); Assert.Same(generatedTree, await generatedDocument.GetSyntaxTreeAsync()); @@ -386,6 +390,7 @@ public async Task DocumentIdGuidInDifferentProjectsIsDifferent(TestHost testHost static Solution AddProjectWithReference(Solution solution, TestGeneratorReference analyzerReference) { var project = AddEmptyProject(solution); + project = project.AddAnalyzerReference(analyzerReference); project = project.AddAdditionalDocument("Test.txt", "Hello, world!").Project; diff --git a/src/Workspaces/CoreTestUtilities/SolutionUtilities.cs b/src/Workspaces/CoreTestUtilities/SolutionUtilities.cs index 95cad77d7c826..bbedf94119bb1 100644 --- a/src/Workspaces/CoreTestUtilities/SolutionUtilities.cs +++ b/src/Workspaces/CoreTestUtilities/SolutionUtilities.cs @@ -4,8 +4,10 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.UnitTests @@ -109,7 +111,11 @@ public static Project AddEmptyProject(Solution solution, string languageName = L VersionStamp.Default, name: name, assemblyName: name, - language: languageName)).GetRequiredProject(id); + language: languageName) + .WithCompilationOutputInfo(new CompilationOutputInfo( + assemblyPath: Path.Combine(TempRoot.Root, name), + generatedFilesOutputDirectory: null))) + .GetRequiredProject(id); } } } diff --git a/src/Workspaces/CoreTestUtilities/Workspaces/AbstractTestHostProject.cs b/src/Workspaces/CoreTestUtilities/Workspaces/AbstractTestHostProject.cs index 440aaaf2b269a..4386053a286ff 100644 --- a/src/Workspaces/CoreTestUtilities/Workspaces/AbstractTestHostProject.cs +++ b/src/Workspaces/CoreTestUtilities/Workspaces/AbstractTestHostProject.cs @@ -4,6 +4,8 @@ #nullable disable +using System; +using System.IO; using Microsoft.CodeAnalysis.Host; namespace Microsoft.CodeAnalysis.Test.Utilities @@ -15,5 +17,25 @@ public abstract class AbstractTestHostProject public abstract HostLanguageServices LanguageServiceProvider { get; } public abstract string AssemblyName { get; } public abstract string Name { get; } + + public static string GetTestOutputDirectory(string projectFilePath) + { + var outputFilePath = @"Z:\"; + + try + { + outputFilePath = Path.GetDirectoryName(projectFilePath); + } + catch (ArgumentException) + { + } + + if (string.IsNullOrEmpty(outputFilePath)) + { + outputFilePath = @"Z:\"; + } + + return outputFilePath; + } } } diff --git a/src/Workspaces/CoreTestUtilities/Workspaces/TestHostDocument.cs b/src/Workspaces/CoreTestUtilities/Workspaces/TestHostDocument.cs index 1fea61aa70c0b..b5e05fcfc6710 100644 --- a/src/Workspaces/CoreTestUtilities/Workspaces/TestHostDocument.cs +++ b/src/Workspaces/CoreTestUtilities/Workspaces/TestHostDocument.cs @@ -99,6 +99,7 @@ internal TestHostDocument( ISourceGenerator? generator = null) { Contract.ThrowIfNull(filePath); + Contract.ThrowIfFalse(generator == null || PathUtilities.IsAbsolute(filePath)); ExportProvider = exportProvider; LanguageServiceProvider = languageServiceProvider; diff --git a/src/Workspaces/CoreTestUtilities/Workspaces/TestHostProject`1.cs b/src/Workspaces/CoreTestUtilities/Workspaces/TestHostProject`1.cs index f2df12d8dd1c8..f34aa48af30a3 100644 --- a/src/Workspaces/CoreTestUtilities/Workspaces/TestHostProject`1.cs +++ b/src/Workspaces/CoreTestUtilities/Workspaces/TestHostProject`1.cs @@ -81,8 +81,6 @@ public override string AssemblyName internal void OnProjectFilePathChanged(string filePath) => FilePath = filePath; - public string OutputFilePath { get; } - public string DefaultNamespace { get { return _defaultNamespace; } @@ -120,7 +118,6 @@ protected TestHostProject( HostObjectType = hostObjectType; Version = VersionStamp.Create(); FilePath = filePath; - OutputFilePath = GetTestOutputFilePath(filePath); _defaultNamespace = defaultNamespace; } @@ -156,7 +153,6 @@ protected TestHostProject( _analyzerReferences = analyzerReferences ?? SpecializedCollections.EmptyEnumerable(); _assemblyName = assemblyName ?? "TestProject"; Version = VersionStamp.Create(); - OutputFilePath = GetTestOutputFilePath(FilePath); _defaultNamespace = defaultNamespace; if (documents != null) @@ -251,7 +247,7 @@ public override HostLanguageServices LanguageServiceProvider public ProjectInfo ToProjectInfo() { - return ProjectInfo.Create( + var info = ProjectInfo.Create( new ProjectInfo.ProjectAttributes( Id, Version, @@ -262,7 +258,7 @@ public ProjectInfo ToProjectInfo() checksumAlgorithm: Text.SourceHashAlgorithms.Default, defaultNamespace: DefaultNamespace, filePath: FilePath, - outputFilePath: OutputFilePath, + outputFilePath: GetTestOutputFilePath(FilePath, "bin"), isSubmission: IsSubmission), CompilationOptions, ParseOptions, @@ -273,6 +269,15 @@ public ProjectInfo ToProjectInfo() additionalDocuments: AdditionalDocuments.Select(d => d.ToDocumentInfo()), analyzerConfigDocuments: AnalyzerConfigDocuments.Select(d => d.ToDocumentInfo()), HostObjectType); + + if (CompilationOptions != null) + { + info = info.WithCompilationOutputInfo(new CompilationOutputInfo( + assemblyPath: GetTestOutputFilePath(FilePath, "obj"), + generatedFilesOutputDirectory: null)); + } + + return info; } // It is identical with the internal extension method 'GetDefaultExtension' defined in OutputKind.cs. @@ -301,24 +306,9 @@ private static string GetDefaultExtension(OutputKind kind) } } - private string GetTestOutputFilePath(string filepath) + private string GetTestOutputFilePath(string projectFilePath, string subdir) { - var outputFilePath = @"Z:\"; - - try - { - outputFilePath = Path.GetDirectoryName(filepath); - } - catch (ArgumentException) - { - } - - if (string.IsNullOrEmpty(outputFilePath)) - { - outputFilePath = @"Z:\"; - } - - return this.CompilationOptions == null ? "" : Path.Combine(outputFilePath, this.AssemblyName + GetDefaultExtension(this.CompilationOptions.OutputKind)); + return CompilationOptions == null ? "" : Path.Combine(GetTestOutputDirectory(projectFilePath), subdir, AssemblyName + GetDefaultExtension(CompilationOptions.OutputKind)); } } } diff --git a/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace_XmlConsumption.cs b/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace_XmlConsumption.cs index 9bddc611e2816..596c68692ebe6 100644 --- a/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace_XmlConsumption.cs +++ b/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace_XmlConsumption.cs @@ -127,26 +127,28 @@ private TProject CreateProject( var assemblyName = GetAssemblyName(projectElement, ref projectId); - string filePath; + string projectFilePath; var projectName = projectElement.Attribute(ProjectNameAttribute)?.Value ?? assemblyName; if (projectElement.Attribute(FilePathAttributeName) != null) { - filePath = projectElement.Attribute(FilePathAttributeName).Value; - if (string.Compare(filePath, NullFilePath, StringComparison.Ordinal) == 0) + projectFilePath = projectElement.Attribute(FilePathAttributeName).Value; + if (string.Compare(projectFilePath, NullFilePath, StringComparison.Ordinal) == 0) { // allow explicit null file path - filePath = null; + projectFilePath = null; } } else { - filePath = projectName + + projectFilePath = projectName + (language == LanguageNames.CSharp ? ".csproj" : language == LanguageNames.VisualBasic ? ".vbproj" : ("." + language)); } + var projectOutputDir = AbstractTestHostProject.GetTestOutputDirectory(projectFilePath); + var languageServices = Services.GetLanguageServices(language); var parseOptions = GetParseOptions(projectElement, language, languageServices); @@ -188,7 +190,7 @@ private TProject CreateProject( MarkupTestFile.GetPositionAndSpans(markupCode, out var code, out var cursorPosition, out IDictionary> spans); - var documentFilePath = typeof(SingleFileTestGenerator).Assembly.GetName().Name + '\\' + typeof(SingleFileTestGenerator).FullName + '\\' + name; + var documentFilePath = Path.Combine(projectOutputDir, "obj", typeof(SingleFileTestGenerator).Assembly.GetName().Name, typeof(SingleFileTestGenerator).FullName, name); var document = CreateDocument(exportProvider, languageServices, code, name, documentFilePath, cursorPosition, spans, generator: testGenerator); documents.Add(document); @@ -225,7 +227,7 @@ private TProject CreateProject( analyzerConfigDocuments.Add(document); } - return CreateProject(languageServices, compilationOptions, parseOptions, assemblyName, projectName, references, documents, additionalDocuments, analyzerConfigDocuments, filePath: filePath, analyzerReferences: analyzers, defaultNamespace: rootNamespace); + return CreateProject(languageServices, compilationOptions, parseOptions, assemblyName, projectName, references, documents, additionalDocuments, analyzerConfigDocuments, filePath: projectFilePath, analyzerReferences: analyzers, defaultNamespace: rootNamespace); } private static ParseOptions GetParseOptions(XElement projectElement, string language, HostLanguageServices languageServices) diff --git a/src/Workspaces/MSBuildTest/NetCoreTests.cs b/src/Workspaces/MSBuildTest/NetCoreTests.cs index c24332066d2c9..237703378bdb5 100644 --- a/src/Workspaces/MSBuildTest/NetCoreTests.cs +++ b/src/Workspaces/MSBuildTest/NetCoreTests.cs @@ -72,12 +72,17 @@ public async Task TestOpenProject_NetCoreApp() CreateFiles(GetNetCoreAppFiles()); var projectFilePath = GetSolutionFileName("Project.csproj"); + var projectDir = Path.GetDirectoryName(projectFilePath); DotNetRestore("Project.csproj"); using var workspace = CreateMSBuildWorkspace(); var project = await workspace.OpenProjectAsync(projectFilePath); + Assert.Equal(Path.Combine(projectDir, "bin", "Debug", "netcoreapp3.1", "Project.dll"), project.OutputFilePath); + Assert.Equal(Path.Combine(projectDir, "obj", "Debug", "netcoreapp3.1", "Project.dll"), project.CompilationOutputInfo.AssemblyPath); + Assert.Null(project.CompilationOutputInfo.GeneratedFilesOutputDirectory); + // Assert that there is a single project loaded. Assert.Single(workspace.CurrentSolution.ProjectIds); diff --git a/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicCompilationFactoryService.vb b/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicCompilationFactoryService.vb index 7200a221eb673..2fe2586f12120 100644 --- a/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicCompilationFactoryService.vb +++ b/src/Workspaces/VisualBasic/Portable/Workspace/LanguageServices/VisualBasicCompilationFactoryService.vb @@ -60,8 +60,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Return New VisualBasicCompilationOptions(outputKind) End Function - Public Function CreateGeneratorDriver(parseOptions As ParseOptions, generators As ImmutableArray(Of ISourceGenerator), optionsProvider As AnalyzerConfigOptionsProvider, additionalTexts As ImmutableArray(Of AdditionalText)) As GeneratorDriver Implements ICompilationFactoryService.CreateGeneratorDriver - Return VisualBasicGeneratorDriver.Create(generators, additionalTexts, DirectCast(parseOptions, VisualBasicParseOptions), optionsProvider) + Public Function CreateGeneratorDriver( + parseOptions As ParseOptions, + generators As ImmutableArray(Of ISourceGenerator), + optionsProvider As AnalyzerConfigOptionsProvider, + additionalTexts As ImmutableArray(Of AdditionalText), + generatedFilesBaseDirectory As String) As GeneratorDriver Implements ICompilationFactoryService.CreateGeneratorDriver + Return VisualBasicGeneratorDriver.Create(generators, additionalTexts, DirectCast(parseOptions, VisualBasicParseOptions), optionsProvider, New GeneratorDriverOptions(baseDirectory:=generatedFilesBaseDirectory)) End Function End Class End Namespace