Tighten NodeLaunchData.EnvironmentOverrides nullability to IDictionary<string, string?>?#13815
Merged
OvesN merged 3 commits intoJun 4, 2026
Conversation
Contributor
|
Hello @copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
…y<string, string?>? Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/2e8dcdf9-a529-41ff-87b3-72b3b671a758 Co-authored-by: OvesN <150850103+OvesN@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix nullability mismatch in NodeLaunchData.EnvironmentOverrides
Tighten NodeLaunchData.EnvironmentOverrides nullability to IDictionary<string, string?>?
May 19, 2026
AlesProkop
approved these changes
Jun 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the nullability contract for node-launch environment overrides so that null values can be represented explicitly as “remove this environment variable” sentinels (used to clear DOTNET_ROOT_* variants during apphost bootstrap), eliminating previous null-forgiveness and #nullable disable workarounds.
Changes:
- Retypes
NodeLaunchData.EnvironmentOverrides(and related plumbing) toIDictionary<string, string?>?to encode null-as-sentinel semantics in the type system. - Updates
DotnetHostEnvironmentHelper.ApplyEnvironmentOverridesto accept nullable values and removes a straynull!. - Removes the
!suppression and workaround comment fromMSBuildClient, and adjusts a#nullable disablecall site viavar.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Framework/DotnetHostEnvironmentHelper.cs | Accept nullable override values and apply null-as-remove semantics; remove null!. |
| src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcTaskHost.cs | Uses var to preserve nullable element type flow in a #nullable disable context. |
| src/Build/BackEnd/Components/Communications/NodeLauncher.cs | Retypes environment override parameter for env-block construction (Windows). |
| src/Build/BackEnd/Components/Communications/INodeLauncher.cs | Updates NodeLaunchData.EnvironmentOverrides to IDictionary<string, string?>?. |
| src/Build/BackEnd/Components/Communications/DetouredNodeLauncher.cs | Retypes override parameter for BuildXL detoured launch environment creation. |
| src/Build/BackEnd/Client/MSBuildClient.cs | Drops null-forgiveness and related workaround comment when setting overrides. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This was referenced Jun 5, 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.
Fixes #13761
Context
DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides()returnsIDictionary<string, string?>?where null values are intentional sentinels meaning "remove this variable from the child environment" (consumed byApplyEnvironmentOverrides→environment.Remove(key)to clearDOTNET_ROOT_*arch-specific variants). ButNodeLaunchData.EnvironmentOverrideswas typedIDictionary<string, string>?, forcing both call sites to paper over the mismatch —MSBuildClient.cswith!,NodeProviderOutOfProc.csvia#nullable disable.Changes Made
INodeLauncher.cs:EnvironmentOverrides→IDictionary<string, string?>?.DotnetHostEnvironmentHelper.cs:ApplyEnvironmentOverridesoverrides param and foreach KVP retyped; drop straynull!(target dict is alreadyDictionary<string, string?>).MSBuildClient.cs: drop!and the#13761workaround comment.NodeLauncher.BuildEnvironmentBlock,DetouredNodeLauncher.CreateEnvironmentVariables: param retyped. Files are#nullable disable, so the signature is wrapped in a narrow#nullable enable annotations/#nullable disable annotationsblock rather than flipping the whole file.NodeProviderOutOfProcTaskHost.cs: local switched tovarto flow the nullable element type through without touching the file's#nullable disablecontext.Testing
Full repo build (net472 + net10.0) clean with 0 warnings.
AppHostSupport_Testspass.Notes
Type-system tightening only — no runtime behavior change. The
#nullable enable annotationsscoping inNodeLauncher.cs/DetouredNodeLauncher.csis a deliberately minimal alternative to converting those files to#nullable enablewholesale.