Improve nullability.#1586
Merged
vitek-karas merged 5 commits intodotnet:mainfrom Apr 14, 2026
Merged
Conversation
Sprinkle nullability information in a number of places where it makes sense.
There was a problem hiding this comment.
Pull request overview
This PR adds/adjusts C# nullable annotations across XHarness shared iOS and common components to better model where values may legitimately be absent (e.g., platform/configuration and environment variables), improving static null-safety across the codebase.
Changes:
- Made many
platform/configurationparameters nullable inProjectFileExtensionsAPIs. - Updated process execution APIs to allow environment variable values to be nullable (
Dictionary<string, string?>), enabling explicit removal of variables. - Updated logging and simulator-selection APIs with additional nullability annotations.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.DotNet.XHarness.iOS.Shared/Utilities/ProjectFileExtensions.cs | Marks platform/configuration inputs as nullable across project XML helpers. |
| src/Microsoft.DotNet.XHarness.iOS.Shared/IResultParser.cs | Updates result parser API to allow nullable variation. |
| src/Microsoft.DotNet.XHarness.iOS.Shared/Hardware/SimulatorLoader.cs | Adjusts simulator selection enumerable nullability. |
| src/Microsoft.DotNet.XHarness.iOS.Shared/Execution/MlaunchProcessManager.cs | Allows nullable env-var values in mlaunch process execution APIs. |
| src/Microsoft.DotNet.XHarness.iOS.Shared/Execution/IMlaunchProcessManager.cs | Keeps interface in sync with mlaunch manager env-var nullability changes. |
| src/Microsoft.DotNet.XHarness.Common/Logging/NullLog.cs | Accepts nullable strings/args in the no-op logger implementation. |
| src/Microsoft.DotNet.XHarness.Common/Logging/Log.cs | Broadens logger write APIs and WriteImpl nullability. |
| src/Microsoft.DotNet.XHarness.Common/Logging/ILog.cs | Broadens logger interface to accept nullable strings/args. |
| src/Microsoft.DotNet.XHarness.Common/Execution/ProcessManager.cs | Allows nullable env-var values (with removal behavior when null). |
| src/Microsoft.DotNet.XHarness.Common/Execution/IProcessManager.cs | Keeps interface in sync with ProcessManager env-var nullability changes. |
| src/Microsoft.DotNet.XHarness.Apple/AppOperations/AppRunnerBase.cs | Allows passing nullable env-var dictionary into Mac Catalyst app runner. |
Comments suppressed due to low confidence (1)
src/Microsoft.DotNet.XHarness.Common/Logging/Log.cs:27
Write(string? value)can pass null through toWriteImpl(e.g., whenTimestampis false andvalueis null). Many existingWriteImploverrides currently take a non-nullstringand may warn (nullability mismatch) or throw if they start receiving null. Consider coalescingvaluetostring.Emptybefore callingWriteImpl(and keepWriteImplnon-nullable), or update all overrides to accept/handlestring?safely.
public void Write(string? value)
{
if (Timestamp)
{
value = "[" + DateTime.Now.ToString("HH:mm:ss.fffffff") + "] " + value;
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Skip null-valued env vars when building Apple mlaunch arguments so the new nullable contract doesn't fail at runtime. Add regression tests covering the run and test simulator paths. Co-authored-by: Copilot <[email protected]>
vitek-karas
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sprinkle nullability information in a number of places where it makes sense.