Enable nullable reference types in XAJavaTypeScanner.cs#11455
Open
Copilot wants to merge 3 commits into
Open
Conversation
7 tasks
Agent-Logs-Url: https://github.com/dotnet/android/sessions/eefa7fb2-7f0f-4339-8339-2c48677c5f07 Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix nullable reference types in XAJavaTypeScanner.cs
Enable nullable reference types in XAJavaTypeScanner.cs
May 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR opts XAJavaTypeScanner.cs into file-level nullable context and updates a string null/empty check and parameter guarding to improve null-safety within Xamarin.Android.Build.Tasks.
Changes:
- Added
#nullable enableat the top ofXAJavaTypeScanner.cs. - Replaced
String.IsNullOrEmpty(...)with the nullable-aware.IsNullOrEmpty()extension. - Added null-argument guards to
AddJavaType(...).
ArgumentNullException.ThrowIfNull is not available in netstandard2.0, which Xamarin.Android.Build.Tasks targets. Replace with explicit null checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonathanpeppers
added a commit
that referenced
this pull request
May 22, 2026
…rowIfNull regressions PR #11455 emitted `ArgumentNullException.ThrowIfNull` into `Xamarin.Android.Build.Tasks.csproj` (which targets `netstandard2.0` where that API doesn't exist), breaking the build. Two changes to make sure that class of bug can't slip through again: 1. **01-nullable-reference-types.sh** now walks up from each candidate `.cs` file to find its owning `*.csproj` and prints the project's `<TargetFramework[s]>` value next to it. The agent literally cannot miss the TFM now — it's right there in the scan data. 2. **Phase 2.5 (TFM / Language-Version Sanity Check)** added to the prompt. A small `API → minimum TFM` table covers the most common compile-break sources (`ArgumentNullException.ThrowIfNull`/.NET 6, `string.Contains (char)`/netstandard2.1, collection expressions/C# 12, etc.) with safe fallbacks for older TFMs. The instruction explicitly cites PR #11455 so the precedent is on record. The script's nullable guidance heredoc also gained a CRITICAL section restating the .NET 6 rule with the regression's PR number so the agent reading the scan output sees the warning before the candidates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
simonrozsival
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opt
XAJavaTypeScanner.csinto#nullable enablefor compile-time null safety.#nullable enableas the first lineString.IsNullOrEmpty()with the.IsNullOrEmpty()extension method from xamarin-android-toolsArgumentNullException.ThrowIfNullguards on publicAddJavaTypeparameters