Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 14, 2025

This PR systematically updates MSBuild task classes in src/Xamarin.Android.Build.Tasks/Tasks/ to follow the repository's nullable reference types guidelines from copilot-instructions.md.

Changes Made

Successfully converted 5 MSBuild task files from #nullable disable to #nullable enable with proper nullable patterns:

Files Updated:

  • Lint.cs - Android Lint tool task
  • GenerateLibraryResources.cs - Library R.java generation task
  • GenerateJniRemappingNativeCode.cs - JNI remapping native code generation
  • ValidateJavaVersion.cs - Java version validation task
  • GenerateResourceDesignerIntermediateClass.cs - Resource designer class generation

Property Pattern Updates Applied:

Before:

#nullable disable

[Required]
public string RequiredProperty { get; set; }

public string NonRequiredProperty { get; set; }
public ITaskItem[] NonRequiredItemGroup { get; set; }

After:

#nullable enable

[Required]
public string RequiredProperty { get; set; } = "";

public string? NonRequiredProperty { get; set; }
public ITaskItem[]? NonRequiredItemGroup { get; set; }

Additional Improvements:

  • Converted string.IsNullOrEmpty() calls to extension method: property.IsNullOrEmpty()
  • Added null-coalescing operators for safe nullable handling: property ?? ""
  • Used null-forgiving operators where null checks exist: property!.Member
  • Updated constructor patterns to use new array syntax: = [] instead of Array.Empty<T>()
  • Fixed null checks in foreach loops and method parameters

Testing

  • ✅ All changes build successfully with .NET 10
  • ✅ No breaking changes to existing functionality
  • ✅ Follows repository coding standards and nullable patterns

Remaining Work

This is part of a larger effort to modernize all MSBuild tasks:

  • 9 remaining files with #nullable disable need conversion
  • 90 additional files without nullable directives need #nullable enable added

The patterns established in this PR provide a template for completing the remaining modernization work.

Addressing #10277.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 4 commits July 14, 2025 20:49
…able to #nullable enable

Co-authored-by: jonathanpeppers <[email protected]>
…ntermediateClass.cs from #nullable disable to #nullable enable

Co-authored-by: jonathanpeppers <[email protected]>
Copilot AI changed the title [WIP] Modernize MSBuild Task Properties with Nullable Reference Types Modernize MSBuild Task Properties with Nullable Reference Types Jul 14, 2025
Copilot AI requested a review from jonathanpeppers July 14, 2025 21:07
…ors, and simplify nullable patterns

Co-authored-by: jonathanpeppers <[email protected]>
Copilot AI requested a review from jonathanpeppers July 14, 2025 21:45
@jonathanpeppers jonathanpeppers marked this pull request as ready for review July 15, 2025 16:07
@jonathanpeppers jonathanpeppers merged commit c241488 into main Jul 15, 2025
59 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/fix-10277 branch July 15, 2025 16:11
@github-actions github-actions bot locked and limited conversation to collaborators Aug 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants