From 691588aa0d7e561760c0576703aa49068d043c73 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 2 Apr 2026 16:53:05 -0500 Subject: [PATCH 1/2] Update nullable review rule to check project-level setting Skip flagging missing per-file #nullable enable when the project's .csproj already has enable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/skills/android-reviewer/references/review-rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/skills/android-reviewer/references/review-rules.md b/.github/skills/android-reviewer/references/review-rules.md index c684709b45c..b91af33a9f0 100644 --- a/.github/skills/android-reviewer/references/review-rules.md +++ b/.github/skills/android-reviewer/references/review-rules.md @@ -48,7 +48,7 @@ cause performance regressions, or silently delete files. | Check | What to look for | |-------|-----------------| -| **`#nullable enable`** | New files should have `#nullable enable` at the top with no preceding blank lines. | +| **`#nullable enable`** | New files should have `#nullable enable` at the top with no preceding blank lines — **unless** the project's `.csproj` already has `enable`, in which case it is not needed per-file. | | **Never use `!` (null-forgiving operator)** | The postfix `!` null-forgiving operator (e.g., `foo!.Bar`) is banned. If the value can be null, add a proper null check. If it can't be null, make the type non-nullable. AI-generated code frequently sprinkles `!` to silence warnings — this turns compile-time safety into runtime `NullReferenceException`s. Note: this rule is about the postfix `!` operator, not the logical negation `!` (e.g., `if (!someBool)` or `if (!string.IsNullOrEmpty (s))`). | | **Use `IsNullOrEmpty()` extension** | Use the `NullableExtensions` instance methods (`str.IsNullOrEmpty()`, `str.IsNullOrWhiteSpace()`) instead of the static `string.IsNullOrEmpty(str)` / `string.IsNullOrWhiteSpace(str)` — they integrate with `[NotNullWhen]` for NRT flow analysis. | | **`ArgumentNullException.ThrowIfNull`** | Android-targeted code (.NET 10+) should use `ArgumentNullException.ThrowIfNull(param)`. | From 9266b2189fe95c8ce9165105246e1f62923c70ae Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 2 Apr 2026 17:00:07 -0500 Subject: [PATCH 2/2] Update .github/skills/android-reviewer/references/review-rules.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/skills/android-reviewer/references/review-rules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/skills/android-reviewer/references/review-rules.md b/.github/skills/android-reviewer/references/review-rules.md index b91af33a9f0..e9b1bfc727f 100644 --- a/.github/skills/android-reviewer/references/review-rules.md +++ b/.github/skills/android-reviewer/references/review-rules.md @@ -48,7 +48,7 @@ cause performance regressions, or silently delete files. | Check | What to look for | |-------|-----------------| -| **`#nullable enable`** | New files should have `#nullable enable` at the top with no preceding blank lines — **unless** the project's `.csproj` already has `enable`, in which case it is not needed per-file. | +| **`#nullable enable`** | New files should have `#nullable enable` at the top with no preceding blank lines — **unless** nullable is already enabled at the project level (for example via the `Nullable` MSBuild property in the project or imported props), in which case it is not needed per-file. | | **Never use `!` (null-forgiving operator)** | The postfix `!` null-forgiving operator (e.g., `foo!.Bar`) is banned. If the value can be null, add a proper null check. If it can't be null, make the type non-nullable. AI-generated code frequently sprinkles `!` to silence warnings — this turns compile-time safety into runtime `NullReferenceException`s. Note: this rule is about the postfix `!` operator, not the logical negation `!` (e.g., `if (!someBool)` or `if (!string.IsNullOrEmpty (s))`). | | **Use `IsNullOrEmpty()` extension** | Use the `NullableExtensions` instance methods (`str.IsNullOrEmpty()`, `str.IsNullOrWhiteSpace()`) instead of the static `string.IsNullOrEmpty(str)` / `string.IsNullOrWhiteSpace(str)` — they integrate with `[NotNullWhen]` for NRT flow analysis. | | **`ArgumentNullException.ThrowIfNull`** | Android-targeted code (.NET 10+) should use `ArgumentNullException.ThrowIfNull(param)`. |