Skip to content

[9.0-preview.1] Request Delegate Generator emits nullable annotations when Nullable Reference Types not enabled #54020

@martincostello

Description

@martincostello

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If an application does not use nullable reference types but does use the request delegate generator, the application fails to compile due to RDG emitting code with nullable annotations.

Expected Behavior

RDG does not emit nullable annotations if the project does not use nullable reference types.

Steps To Reproduce

Exceptions (if any)

Example error:

dotnet build
MSBuild version 17.10.0-preview-24101-01+07fd5d51f for .NET
Restore complete (1.0s)
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
  SignInWithApple failed with errors (1.3s)
    C:\Coding\martincostello\SignInWithAppleSample\src\SignInWithApple\Microsoft.AspNetCore.Http.RequestDelegateGenerator\Microsoft.AspNetCore.Http.RequestDelegateGenerator.RequestDelegateGenerator\GeneratedRouteBuilderExtensions.g.cs(281,32): error CS8669: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. [C:\Coding\martincostello\SignInWithAppleSample\src\SignInWithApple\SignInWithApple.csproj]

.NET Version

9.0.100-preview.1.24101.2

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-rdg

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions