Skip to content

Commit d90a602

Browse files
Copilotdavidwengier
andcommitted
Add explanatory comment for service scope usage
Add comment explaining why service scope is necessary to handle scoped services properly and avoid DI validation issues. Co-authored-by: davidwengier <[email protected]>
1 parent 8cdc34f commit d90a602

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ protected static async Task<string> RenderRazorPageAsync(Compilation compilation
151151
});
152152
var app = appBuilder.Build();
153153

154+
// Create a service scope to properly handle scoped services like IViewBufferScope.
155+
// ASP.NET Core's DI validation prevents resolving scoped services from the root provider.
154156
using var scope = app.Services.CreateScope();
155157
var httpContext = new DefaultHttpContext
156158
{

0 commit comments

Comments
 (0)