Skip to content

Fix build warnings in Xamarin.ProjectTools#11978

Merged
jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/fix-xamarin-projecttools-warnings
Jul 6, 2026
Merged

Fix build warnings in Xamarin.ProjectTools#11978
jonathanpeppers merged 1 commit into
mainfrom
dev/simonrozsival/fix-xamarin-projecttools-warnings

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Jul 4, 2026

Copy link
Copy Markdown
Member

This PR fixes the following build warning:

 Xamarin.ProjectTools net10.0 succeeded with 1 warning(s) (2.6s) → src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/bin/Debug/net10.0/Xamarin.ProjectTools.dll
   /.../src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.cs(19,21): warning CA1416: This call site is reachable on all platforms. 'Registry.GetValue(string, string?, object?)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Copilot AI review requested due to automatic review settings July 4, 2026 10:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Removes a platform analyzer warning (CA1416) from Xamarin.ProjectTools by using an OS guard pattern recognized by the .NET analyzers, and re-enables warnings-as-errors enforcement for that project in CI/local strict builds.

Changes:

  • Replace TestEnvironment.IsWindows with OperatingSystem.IsWindows() to properly guard the Windows-only Registry.GetValue call and eliminate CA1416.
  • Remove the Directory.Build.props exemption that allowed Xamarin.ProjectTools to build with warnings under TreatWarningsAsErrors.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.cs Uses OperatingSystem.IsWindows() to satisfy CA1416 platform guard requirements for Registry.GetValue.
Directory.Build.props Removes the Xamarin.ProjectTools.csproj warning allowance so warnings become errors when TreatWarningsAsErrors is enabled.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Jul 4, 2026
@jonathanpeppers jonathanpeppers merged commit 1a8fcab into main Jul 6, 2026
43 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/simonrozsival/fix-xamarin-projecttools-warnings branch July 6, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants