[tests] Enable nullability in msbuild test projects.#25045
Conversation
- 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>
There was a problem hiding this comment.
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>inXamarin.MacDev.TestsandXamarin.MacDev.Tasks.Teststest 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. |
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/LocalizationStringTest.cs
Show resolved
Hide resolved
tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/PropertyListEditorTaskTests.cs
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #e4e3dd7] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #e4e3dd7] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #e4e3dd7] Build passed (Build macOS tests) ✅Pipeline on Agent |
🚀 [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 macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
And fix any build issues.