diff --git a/osu.Framework.SourceGeneration.Tests/GeneratorTestHelper.cs b/osu.Framework.SourceGeneration.Tests/GeneratorTestHelper.cs index 9769eff76..8acaa934f 100644 --- a/osu.Framework.SourceGeneration.Tests/GeneratorTestHelper.cs +++ b/osu.Framework.SourceGeneration.Tests/GeneratorTestHelper.cs @@ -76,7 +76,7 @@ namespace osu.Framework.SourceGeneration.Tests { Compilation = CSharpCompilation.Create("test", references: new[] { MetadataReference.CreateFromFile(typeof(object).Assembly.Location) }, - options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); + options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel: OptimizationLevel.Release)); } public GeneratorDriverRunResult RunGenerators(ref GeneratorDriver driver) diff --git a/osu.Framework.SourceGeneration.Tests/Verifiers/CSharpMultiPhaseSourceGeneratorVerifier_Test.cs b/osu.Framework.SourceGeneration.Tests/Verifiers/CSharpMultiPhaseSourceGeneratorVerifier_Test.cs index 6b4e071cd..781da8938 100644 --- a/osu.Framework.SourceGeneration.Tests/Verifiers/CSharpMultiPhaseSourceGeneratorVerifier_Test.cs +++ b/osu.Framework.SourceGeneration.Tests/Verifiers/CSharpMultiPhaseSourceGeneratorVerifier_Test.cs @@ -35,8 +35,6 @@ namespace osu.Framework.SourceGeneration.Tests.Verifiers driver = CSharpGeneratorDriver.Create(generator = new TSourceGenerator()); driver = driver.WithUpdatedParseOptions(CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion)); - generator.ForceRun = true; - this.commonSources = commonSources; this.commonGenerated = commonGenerated; this.multiPhaseSources = multiPhaseSources; diff --git a/osu.Framework.SourceGeneration.Tests/Verifiers/CSharpSourceGeneratorVerifier_Test.cs b/osu.Framework.SourceGeneration.Tests/Verifiers/CSharpSourceGeneratorVerifier_Test.cs index 3a7417030..a18203f56 100644 --- a/osu.Framework.SourceGeneration.Tests/Verifiers/CSharpSourceGeneratorVerifier_Test.cs +++ b/osu.Framework.SourceGeneration.Tests/Verifiers/CSharpSourceGeneratorVerifier_Test.cs @@ -20,6 +20,11 @@ namespace osu.Framework.SourceGeneration.Tests.Verifiers protected override IEnumerable GetSourceGenerators() => [typeof(TSourceGenerator)]; + protected override CompilationOptions CreateCompilationOptions() + { + return base.CreateCompilationOptions().WithOptimizationLevel(OptimizationLevel.Release); + } + protected override ParseOptions CreateParseOptions() { return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(LanguageVersion); diff --git a/osu.Framework.SourceGeneration/Generators/AbstractIncrementalGenerator.cs b/osu.Framework.SourceGeneration/Generators/AbstractIncrementalGenerator.cs index bb88eaf0d..60bd8c9bd 100644 --- a/osu.Framework.SourceGeneration/Generators/AbstractIncrementalGenerator.cs +++ b/osu.Framework.SourceGeneration/Generators/AbstractIncrementalGenerator.cs @@ -14,11 +14,6 @@ namespace osu.Framework.SourceGeneration.Generators { public readonly GeneratorEventDriver EventDriver = new GeneratorEventDriver(); - /// - /// Whether the generator should be forcefully run, even if building as debug. - /// - public bool ForceRun; - public void Initialize(IncrementalGeneratorInitializationContext context) { // Stage 1: Create SyntaxTarget objects for all classes. @@ -28,7 +23,7 @@ namespace osu.Framework.SourceGeneration.Generators (ctx, _) => returnWithEvent(new IncrementalSyntaxTarget((ClassDeclarationSyntax)ctx.Node, ctx.SemanticModel), EventDriver.OnSyntaxTargetCreated)) .Select((t, _) => t.WithName()) .Combine(context.CompilationProvider) - .Where(c => ForceRun || c.Right.Options.OptimizationLevel == OptimizationLevel.Release) + .Where(c => c.Right.Options.OptimizationLevel == OptimizationLevel.Release) .Select((t, _) => t.Item1) .Select((t, _) => returnWithEvent(t.WithSemanticTarget(CreateSemanticTarget), EventDriver.OnSemanticTargetCreated));