Skip to content

[tests] Enable nullability in msbuild test projects.#25045

Merged
rolfbjarne merged 9 commits intomainfrom
dev/rolf/tests-nullability-msbuild
Apr 2, 2026
Merged

[tests] Enable nullability in msbuild test projects.#25045
rolfbjarne merged 9 commits intomainfrom
dev/rolf/tests-nullability-msbuild

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

And fix any build issues.

rolfbjarne and others added 7 commits March 30, 2026 17:42
- Logger.cs: Add = null! to event list properties initialized in
  Initialize(), make Parameters nullable to match ILogger interface,
  add null coalescing for Message properties
- TestBase.cs: Make engine/paths fields nullable (they're reset to null
  in SetUp), add = null! to ProjectPaths properties
- TestEngine.cs: Make GetRegisteredTaskObject/UnregisterTaskObject
  return object? to match IBuildEngine4 interface
- AssemblySetup.cs: Add ?? string.Empty for Path.GetDirectoryName
  which returns string?

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add = null! to test properties initialized in Setup (Plist, CompiledPlist, Task)
- Use ?. for nullable Get<T>() return values in assertion chains
- Use ?? throw for PDictionary.FromFile which returns nullable
- Use ! for Task.AppManifest/CompiledAppManifest (set in ConfigureTask, non-null at runtime)
- Change PArray to PArray? for TryGetValue out parameter in iOS tests
- Use ?.Method() == true pattern for nullable PArray.Any() calls

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…acDev.Tests

Add #nullable enable to shared files tests/common/Tool.cs and
tests/common/mac/ProjectTestHelpers.cs. Fix all nullable warnings in
these files and in project-only files MSBuildProject.cs, TestBase.cs,
DetectSigningIdentityTests.cs, and TargetTests.cs. Also fix the
downstream BGenTool.cs which was affected by EnvironmentVariables
becoming nullable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fix CS8600/CS8601/CS8602/CS8603/CS8604/CS8625 errors across 7 test files:
- ACToolTaskTest: Use null-conditional on PartialAppManifest
- BGenTaskTest: Suppress CS8625 for deliberate null test
- CollectITunesArtworkTaskTests: Handle nullable Path.GetDirectoryName
- GetPropertyListValueTaskTests: Make expected parameter nullable
- LocalizationStringTest: Handle nullable reflection/XML APIs
- MergeAppBundleTaskTest: Nullable dict values, params, GetDirectoryName
- PropertyListEditorTaskTests: Nullable params, explicit PString, null guards

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ull env var

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables nullable reference types in the MSBuild test projects and updates test helpers/tests to satisfy nullable warnings and avoid null-related runtime exceptions.

Changes:

  • Enable <Nullable>enable</Nullable> in Xamarin.MacDev.Tests and Xamarin.MacDev.Tasks.Tests test projects.
  • Update MSBuild test helpers and task tests with nullable annotations and defensive null handling (e.g., ?., ??, Argument/XML node checks).
  • Tighten a few plist/test utilities to avoid null dereferences when reading plist/MSBuild log data.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/msbuild/Xamarin.MacDev.Tests/Xamarin.MacDev.Tests.csproj Enables nullable reference types for the MSBuild tests project.
tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/TestBase.cs Annotates nullable fields/params and adds null-safe plist parsing and log iteration.
tests/msbuild/Xamarin.MacDev.Tests/TestHelpers/MSBuildProject.cs Adds null checks/throws for XML node selection and annotates optional metadata.
tests/msbuild/Xamarin.MacDev.Tests/TargetTests/DetectSigningIdentityTests.cs Uses null-safe message matching/handling for MSBuild log messages.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/Xamarin.MacDev.Tasks.Tests.csproj Enables nullable reference types for the MSBuild tasks tests project.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TestHelpers/TestEngine.cs Adjusts IBuildEngine4 implementations to allow null returns.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TestHelpers/TestBase.cs Makes cached fields nullable and adjusts helper project path initialization.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TestHelpers/Logger.cs Initializes logger collections for nullable compliance and null-safe message formatting.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/PropertyListEditorTaskTests.cs Updates plist test construction and task invocation for nullable compliance.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/MergeAppBundleTaskTest.cs Updates environment variable dictionary/value handling and path creation null-safety.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/LocalizationStringTest.cs Adds null-safe access to error messages/resources and updates resource enumeration.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GetPropertyListValueTaskTests.cs Allows nullable expected value in helper.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_iOS_AppExtension.cs Uses null-safe access to plist values.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_iOS.cs Uses nullable locals and null-safe assertions for plist arrays/values.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/GeneratePlistTaskTests/GeneratePlistTaskTests_Core.cs Initializes properties for nullable compliance and adds null checks/throws when loading plists.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CollectITunesArtworkTaskTests.cs Adds null-safe directory derivation for assembly location.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/BGenTaskTest.cs Uses pragmas around intentional null assignment for regression coverage.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/ACToolTaskTest.cs Uses null-safe access to PartialAppManifest/ItemSpec in assertions.
tests/msbuild/Xamarin.MacDev.Tasks.Tests/AssemblySetup.cs Makes derived environment path null-safe.
tests/generator/BGenTool.cs Guards against null EnvironmentVariables when running in-process.
tests/common/mac/ProjectTestHelpers.cs Enables nullable context and annotates/builds env dictionaries and file paths null-safely.
tests/common/Tool.cs Enables nullable context and initializes message fields/parameters defensively.

@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

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

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

This comment has been minimized.

@rolfbjarne rolfbjarne marked this pull request as ready for review April 2, 2026 08:03
@rolfbjarne rolfbjarne enabled auto-merge (squash) April 2, 2026 08:03
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #e4e3dd7] Build passed (Build packages) ✅

Pipeline on Agent
Hash: e4e3dd7c304faf8db1458e731cd5a302ad1221f9 [PR build]

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

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

Pipeline on Agent
Hash: e4e3dd7c304faf8db1458e731cd5a302ad1221f9 [PR build]

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

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: e4e3dd7c304faf8db1458e731cd5a302ad1221f9 [PR build]

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

✅ [CI Build #e4e3dd7] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: e4e3dd7c304faf8db1458e731cd5a302ad1221f9 [PR build]

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

🚀 [CI Build #e4e3dd7] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 156 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): 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 (MacCatalyst): All 15 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
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 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: e4e3dd7c304faf8db1458e731cd5a302ad1221f9 [PR build]

@rolfbjarne rolfbjarne merged commit 2f12105 into main Apr 2, 2026
48 checks passed
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.

4 participants