Skip to content

Conversation

@captainsafia
Copy link
Member

  • Enable nullability in RDG project and fix warnings
  • Regenerate baselines directory

internal static void EmitJsonPreparation(this EndpointResponse endpointResponse, CodeWriter codeWriter)
{
if (endpoint.Response.IsSerializable)
if (endpointResponse is { IsSerializable: true, ResponseType: {} responseType })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we are checking ResponseType for null here, but not below in EmitJsonResponse?

Copy link
Member Author

@captainsafia captainsafia Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call EmitJsonResponse from the the main request handler where we do null checking on the type earlier on (ref).

We use null coalescing when we call EmitJsonPreparation here so the null check isn't really required there.

Side note: I'm doing a lot of shuffling in this codepath in another branch as I'm working through a bug I found in writing JSON response for certain async handlers.

Edit: You're talking about ResponseType not Response 🤦🏽‍♀️

}

private static string EmitResponseWritingCall(this Endpoint endpoint)
private static string? EmitResponseWritingCall(this EndpointResponse endpointResponse, bool isAwaitable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this method ever return null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed. Will update.

@captainsafia captainsafia requested review from a team and wtgodbe as code owners March 13, 2023 20:37
@captainsafia captainsafia enabled auto-merge (squash) March 13, 2023 20:52
<DefineConstants>$(DefineConstants),INTERNAL_NULLABLE_ATTRIBUTES</DefineConstants>
<NoWarn>$(NoWarn);nullable</NoWarn>
<!-- Repo-specific property to enable nullability warnings for ns2.0 -->
<NoWarn Condition=" '$(WarnOnNullable)' != 'true' ">$(NoWarn);nullable</NoWarn>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many projects break if we omitted this check? Do many other netstandard2.0 projects even have nullability enabled? I wonder if we should invert this to opt out rather than in, so new netstandard2.0 projects get warnings as soon as we enable nullability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see how many projects were impacted but there were about ~150 warnings throughout the repo when I removed this. I filed #47179 to look at this.

I wonder if we should invert this to opt out rather than in, so new netstandard2.0 projects get warnings as soon as we enable nullability.

Yeah, that might be a prudent idea. I'll link to this comment in the issue above since it would be a good first step towards addressing the problem in the repo.

@captainsafia captainsafia merged commit 9b3e79d into main Mar 13, 2023
@captainsafia captainsafia deleted the safia/rdg-nullability branch March 13, 2023 22:06
@ghost ghost added this to the 8.0-preview3 milestone Mar 13, 2023
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants