Skip to content

Commit a394895

Browse files
authored
Only track steps when needed (#12479)
1 parent 4746f4e commit a394895

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2611,7 +2611,7 @@ public async Task SourceGenerator_DoesNotUpdateSources_WhenSourceGeneratorIsSupp
26112611
});
26122612

26132613
var compilation = await project.GetCompilationAsync();
2614-
var (driver, additionalTexts, optionsProvider) = await GetDriverWithAdditionalTextAndProviderAsync(project);
2614+
var (driver, additionalTexts, optionsProvider) = await GetDriverWithAdditionalTextAndProviderAsync(project, trackSteps: true);
26152615

26162616
// start with the generator suppressed (this is the default state in VS)
26172617
driver = SetSuppressionState(true);

src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTestsBase.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ protected static async ValueTask<GeneratorDriver> GetDriverAsync(Project project
5757
return (result.Item1, result.Item2);
5858
}
5959

60-
protected static async ValueTask<(GeneratorDriver, ImmutableArray<AdditionalText>, TestAnalyzerConfigOptionsProvider)> GetDriverWithAdditionalTextAndProviderAsync(Project project, Action<TestAnalyzerConfigOptionsProvider>? configureGlobalOptions = null, bool hostOutputs = false)
60+
protected static async ValueTask<(GeneratorDriver, ImmutableArray<AdditionalText>, TestAnalyzerConfigOptionsProvider)> GetDriverWithAdditionalTextAndProviderAsync(Project project, Action<TestAnalyzerConfigOptionsProvider>? configureGlobalOptions = null, bool hostOutputs = false, bool trackSteps = false)
6161
{
6262
var razorSourceGenerator = new RazorSourceGenerator(testUniqueIds: "test").AsSourceGenerator();
6363
var disabledOutputs = hostOutputs ? IncrementalGeneratorOutputKind.None : (IncrementalGeneratorOutputKind)0b100000;
64-
var driver = (GeneratorDriver)CSharpGeneratorDriver.Create(new[] { razorSourceGenerator }, parseOptions: (CSharpParseOptions)project.ParseOptions!, driverOptions: new GeneratorDriverOptions(disabledOutputs, true));
64+
var driver = (GeneratorDriver)CSharpGeneratorDriver.Create(new[] { razorSourceGenerator }, parseOptions: (CSharpParseOptions)project.ParseOptions!, driverOptions: new GeneratorDriverOptions(disabledOutputs, trackSteps));
6565

6666
var optionsProvider = new TestAnalyzerConfigOptionsProvider();
6767
optionsProvider.TestGlobalOptions["build_property.RazorConfiguration"] = "Default";
@@ -483,6 +483,9 @@ public static void VerifyTextMatchesBaseline(string actualText, string fileName,
483483
[Conditional("GENERATE_BASELINES")]
484484
private static void GenerateOutputBaseline(string baselinePath, string text)
485485
{
486+
var directory = Path.GetDirectoryName(baselinePath)!;
487+
Directory.CreateDirectory(directory);
488+
486489
text = text.Replace("\r", "").Replace("\n", "\r\n");
487490
File.WriteAllText(baselinePath, text, _baselineEncoding);
488491
}

0 commit comments

Comments
 (0)