Skip to content

Enable nullable reference types in Microsoft.Android.Build.BaseTasks #343

@jonathanpeppers

Description

@jonathanpeppers

The Microsoft.Android.Build.BaseTasks project does not enable nullable reference types (no <Nullable>enable</Nullable> in the .csproj and no per-file #nullable enable directives). This means the compiler cannot catch null dereference bugs at compile time — for example, the bug fixed in #342 where an as cast was dereferenced without a null check.

Proposed work

  1. Add <Nullable>enable</Nullable> to Microsoft.Android.Build.BaseTasks.csproj (or add per-file #nullable enable incrementally).
  2. Resolve all resulting warnings — annotate parameters/returns with ? where null is valid, add guards where it isn't.
  3. Enable <WarningsAsErrors>nullable</WarningsAsErrors>
  4. Verify build and tests pass clean.

Context

Adding #nullable enable to just Files.cs produces ~12 warnings (CS8600, CS8603, CS8625) across the file, so this should be done as a dedicated cleanup pass rather than piecemeal.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions