Skip to content

Enable nullability and warnings-as-errors globally#25292

Draft
rolfbjarne wants to merge 14 commits intomainfrom
dev/rolf/nullability-everywhere
Draft

Enable nullability and warnings-as-errors globally#25292
rolfbjarne wants to merge 14 commits intomainfrom
dev/rolf/nullability-everywhere

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

@rolfbjarne rolfbjarne commented Apr 30, 2026

Summary

Enable nullable reference types, treat-warnings-as-errors, and use the latest C# language version globally across the entire repository via Directory.Build.props.

Changes

Global settings (Directory.Build.props)

  • Set <Nullable>enable</Nullable> globally.
  • Set <TreatWarningsAsErrors>true</TreatWarningsAsErrors> globally.
  • Set <LangVersion>latest</LangVersion> globally (when not already set).

Cleanup: remove per-project redundant settings

  • Remove per-project <Nullable>enable</Nullable> from ~100+ .csproj files, since it's now set globally.
  • Remove per-project <TreatWarningsAsErrors> and <WarningsAsErrors> settings that are now redundant.
  • Remove per-project <LangVersion> settings that are now covered by the global default.

Fix nullability warnings in test code

  • bindings-test: Fix nullability issues in ProtocolTest.cs, Registrar.cs, RuntimeTest.cs.
  • dont-link: Fix nullability issues across multiple test files.
  • link all: Fix nullability issues in link-all tests.
  • link sdk: Fix nullability issues in link-sdk tests.
  • BundledResources: Fix nullability in ResourcesTest.cs.
  • F# tests: Fix nullability issues in F# test code.
  • Other: Minor nullability fix in generate-frameworks-constants.cs.

🤖 Pull request created by Copilot

With this change, nullability is fully enabled everywhere, so:

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #71b9d62] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 71b9d6217664cef7b4312842ddc9011bc391d1b1 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🔥 Failed to compare API and create generator diff 🔥

Failed to run apidiff

Pipeline on Agent
Hash: 71b9d6217664cef7b4312842ddc9011bc391d1b1 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #71b9d62] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 71b9d6217664cef7b4312842ddc9011bc391d1b1 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #71b9d62] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 71b9d6217664cef7b4312842ddc9011bc391d1b1 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🔥 [CI Build #71b9d62] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

2 tests crashed, 5 tests failed, 133 tests passed.

Failures

❌ dotnettests tests (iOS)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.AppIconTest.AlternateAppIcon(iOS,"ios-arm64"): 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/5/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • Xamarin.Tests.AppIconTest.AlternateAppIcon(iOS,"iossimulator-x64...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/5/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • Xamarin.Tests.AppIconTest.AlternateAppIcons(iOS,"ios-arm64"): 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/5/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • ... and 37 more

Html Report (VSDrops) Download

❌ dotnettests tests (MacCatalyst)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.AppSizeTest.MonoVM_Interpreter(MacCatalyst,"maccat...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/3/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • Xamarin.Tests.AppSizeTest.MonoVM(MacCatalyst,"maccatalyst-arm64"...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/3/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • Xamarin.Tests.AppSizeTest.NativeAOT(MacCatalyst,"maccatalyst-arm...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/3/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • ... and 8 more

Html Report (VSDrops) Download

❌ dotnettests tests (macOS)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.DotNetProjectTest.BuildProjectsWithExtensions(MacO...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/3/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • Xamarin.Tests.DotNetProjectTest.BuildProjectsWithExtensions(MacO...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/3/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • Xamarin.Tests.DotNetProjectTest.BuildProjectsWithExtensions(MacO...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/3/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • ... and 7 more

Html Report (VSDrops) Download

❌ dotnettests tests (tvOS)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.AppIconTest.AlternateAppIcon(TVOS,"tvos-arm64"): 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/4/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • Xamarin.Tests.AppIconTest.AlternateAppIcon(TVOS,"tvossimulator-x...: 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/4/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • Xamarin.Tests.AppIconTest.AlternateAppIcons(TVOS,"tvos-arm64"): 'dotnet build' failed with exit code 1
      Full command: /Users/builder/azdo/_work/4/s/macios/builds/downloads/dotnet-sdk-10.0.300-p...
    • ... and 28 more

Html Report (VSDrops) Download

❌ monotouch tests (MacCatalyst)

🔥 Failed catastrophically on VSTS: test results - monotouch_maccatalyst (no summary found).

Html Report (VSDrops) Download

❌ windows tests

🔥 Failed catastrophically on VSTS: test results - windows (no summary found).

Html Report (VSDrops) Download

❌ xtro tests

1 tests failed, 0 tests passed.

Failed tests

  • Xtro: BuildFailure

Html Report (VSDrops) Download

Successes

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 6 tests passed. Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 12 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 71b9d6217664cef7b4312842ddc9011bc391d1b1 [PR build]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Foundation] Missing nullability in some base types. Add C# 8 nullability annotations to bindings

2 participants