Skip to content

nullable pragmas cannot be used in .razor / .cshtml files #7480

Open
@pranavkm

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.

Metadata

Assignees

No one assigned

    Labels

    area-compilerUmbrella for all compiler issuesbugSomething isn't workinguntriaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions