Skip to content

Conversation

ogazioglu
Copy link

@ogazioglu ogazioglu commented Feb 17, 2025

When nullable annotations are enabled and GenerateNullableReferenceTypes is true, the code below is generated and causes following compiler warning :

Actual Generated Code:

var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string));

Compiler Warning:

warning CS8600: Converting null literal or possible null value to non-nullable type.

But in this configuration, it should be generated as below:

Expected Generated Code:

var result_ = (string?)System.Convert.ChangeType(responseData_, typeof(string));

This fix correctly generates code and resolves the compiler warning.

@ogazioglu ogazioglu marked this pull request as draft March 19, 2025 11:03
@ogazioglu ogazioglu marked this pull request as ready for review March 19, 2025 11:07
@RicoSuter
Copy link
Owner

Is there a fix without using ? NRT as the generator should also work with pre-NRT C# versions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants