diff --git a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/SourceGenerators/RazorCohostingOptions.cs b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/SourceGenerators/RazorCohostingOptions.cs
index fc1a8a78f1e..21db8554f0a 100644
--- a/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/SourceGenerators/RazorCohostingOptions.cs
+++ b/src/Compiler/Microsoft.CodeAnalysis.Razor.Compiler/src/SourceGenerators/RazorCohostingOptions.cs
@@ -5,5 +5,5 @@ internal static class RazorCohostingOptions
///
/// True if razor is running in the cohosting mode
///
- internal static bool UseRazorCohostServer { get; set; } = false;
+ internal static bool UseRazorCohostServer { get; set; } = true;
}
diff --git a/src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs b/src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs
index 5b04bc98047..035f5884e2f 100644
--- a/src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs
+++ b/src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTests.cs
@@ -10,6 +10,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Razor.Language.Syntax;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Test.Utilities;
@@ -2615,6 +2616,9 @@ public async Task SourceGenerator_DoesNotUpdateSources_WhenSourceGeneratorIsSupp
// start with the generator suppressed (this is the default state in VS)
driver = SetSuppressionState(true);
+ // Disable co-hosting, this test only applies to non-cohosting scenarios
+ RazorCohostingOptions.UseRazorCohostServer = false;
+
// results should be empty, and no recorded steps should have run
using var eventListener = new RazorEventListener();
var result = RunGenerator(compilation!, ref driver).VerifyPageOutput();
@@ -3457,6 +3461,7 @@ public async Task UseRazorCohostServer_CanOverride_Suppression()
["Component.Razor"] = "
Hello world
",
});
var compilation = await project.GetCompilationAsync();
+ RazorCohostingOptions.UseRazorCohostServer = false;
// Start with the generator suppressed
var (driver, additionalTexts, optionsProvider) = await GetDriverWithAdditionalTextAndProviderAsync(project, configureGlobalOptions: (o) =>