Open sandermvanvliet-stack opened 9 months ago
@sandermvanvliet-stack thanks for the detailed analysis! That certainly seems like a plausible explanation for what is happening.
@jaredpar @danroth27 Runtime compilation lives in aspnetcore, but I guess we're the closest to its owners. Do we want to track issues for it here, or over there?
@jaredpar @danroth27 Runtime compilation lives in aspnetcore, but I guess we're the closest to its owners. Do we want to track issues for it here, or over there?
Let's track the issue in the repo where the corresponding code lives. If this is an issue with runtime compilation and not the compiler, then it should move to the aspnetcore repo.
If there is any additional info needed give me a shout 👍
I have an interesting case where I have Razor runtime compilation enabled and the view is in a project that has
<Nullable>enable</Nullable>
in the project file.What I'm seeing
Given a view like this:
where
MyModel
is:Project file is like this:
When enabling Razor runtime compilation and navigating to the route that uses this view I get the error:
(click for full stack trace)
When disabling Razor runtime compilation and navigating to the route that uses this view it will be rendered normally.
Suspicions
For (I think..) both runtime and build compilation, the view is passed through the Razor source generator exactly in the same way so should amount to the same code. By catching the exception (see above) I've managed to pull out the runtime generated code and using the
EmitCompilerGeneratedFiles
MSBuild property in the project I've also managed to capture the build time generated code.Comparing the two I can see some slight differences (namespace name and file paths) but otherwise they're similar.
My suspicion is that:
As it's not part of the actual project, the setting for
Nullable
isn't taken from that project which leads to this result that the compilation thinks thatNullable
is not enabled (where it is enabled in the actual project).Versions
Visual Studio Version 17.8.3
dotnet --info
:Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
Version 6.0.5