Skip to content

fix: preserve nullable null branches in generated rewrites - #51

Merged
ycherkes merged 2 commits into
mainfrom
fix/nullable-rewrite-null-branch
Sep 2, 2026
Merged

ycherkes merged 2 commits into
mainfrom
fix/nullable-rewrite-null-branch

Conversation

@ycherkes

@ycherkes ycherkes commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Preserve nullable null branches in generated rewrites

Summary

Fix generated CS8600 warnings in the Experiment project without restoring nullable-warning suppression.

The null-conditional Rewrite path previously emitted a null branch cast to a non-nullable reference type when Roslyn reported a non-nullable converted type. That produced generated syntax such as:

(global::Example.AddressDto)null

The rewriter now preserves the nullable result type of the conditional access:

(global::Example.AddressDto?)null

This is type-correct for a null-conditional branch and avoids warnings without adding ! or null!.

Changes

  • Use the already computed nullable cast type for every Rewrite null branch.
  • Preserve project-level nullable-flow behavior; no warning suppression was reintroduced.
  • Update the prior nullable-policy PR summary to reflect the warning-free Experiment build.

Validation

  • dotnet build AlephMapper.slnx --configuration Release — 0 warnings, 0 errors
  • dotnet test AlephMapper.slnx --configuration Release — 97 passed

@ycherkes
ycherkes merged commit 4dea094 into main Sep 2, 2026
1 check passed
@ycherkes
ycherkes deleted the fix/nullable-rewrite-null-branch branch September 2, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant