nullable pragmas cannot be used in .razor / .cshtml files #7480
Open
Description
Razor's codegen produces a bunch of #nullable restore
for compiler generated code. Unfortunately, this pragma restores the nullability context to the project's settings and not what was last state for that file:
#nullable restore: Restores the nullable annotation context and nullable warning context to the project settings.
This makes it impossible for a user to suppress nullability warnings on a per-file basis using pragmas inside a code-block.
I suspect we could remove the generated #nullable
pragmas now that the runtime is correctly annotated for nullability.