Skip to content

Fix CS8632: remove nullable annotations from #nullable disable context in Element.cs#34751

Merged
StephaneDelcroix merged 1 commit intonet11.0from
fix/nullable-element-cs8632
Mar 31, 2026
Merged

Fix CS8632: remove nullable annotations from #nullable disable context in Element.cs#34751
StephaneDelcroix merged 1 commit intonet11.0from
fix/nullable-element-cs8632

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description

Removes ? nullable annotations from ElementEventArgs parameters in OnDescendantAddedCore and OnDescendantRemovedCore in Element.cs.

The file starts with #nullable disable, so nullable reference type annotations are invalid and produce CS8632 warnings. MAUI CI sets TreatWarningsAsErrors=false so these pass silently, but downstream consumers like dotnet/android build with TreatWarningsAsErrors=true, causing build failures.

Introduced in #34134.

Fix

Simply remove the ? from the ElementEventArgs parameter types. Under #nullable disable, reference types are already implicitly nullable, so the behavior is unchanged.

Remove '?' from ElementEventArgs parameters in OnDescendantAddedCore
and OnDescendantRemovedCore. The file has '#nullable disable' at the
top, so nullable reference type annotations are invalid and cause
CS8632 warnings which become errors when TreatWarningsAsErrors=true
(e.g. in dotnet/android CI).

Introduced in #34134.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 31, 2026 08:05
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34751

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34751"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes nullable reference type annotations (?) from local-function parameters in Element.cs, which is compiled under #nullable disable, to avoid CS8632 warnings in consumers that treat warnings as errors.

Changes:

  • Update OnDescendantAddedCore to take ElementEventArgs instead of ElementEventArgs?.
  • Update OnDescendantRemovedCore to take ElementEventArgs instead of ElementEventArgs?.

@simonrozsival simonrozsival enabled auto-merge (squash) March 31, 2026 09:21
@StephaneDelcroix StephaneDelcroix merged commit affd1ed into net11.0 Mar 31, 2026
36 of 40 checks passed
@StephaneDelcroix StephaneDelcroix deleted the fix/nullable-element-cs8632 branch March 31, 2026 12:49
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.

3 participants