Skip to content

Tighten NodeLaunchData.EnvironmentOverrides nullability to IDictionary<string, string?>?#13815

Merged
OvesN merged 3 commits into
mainfrom
copilot/fix-nullability-mismatch-environment-overrides-again
Jun 4, 2026
Merged

Tighten NodeLaunchData.EnvironmentOverrides nullability to IDictionary<string, string?>?#13815
OvesN merged 3 commits into
mainfrom
copilot/fix-nullability-mismatch-environment-overrides-again

Conversation

Copilot AI commented May 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #13761

Context

DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides() returns IDictionary<string, string?>? where null values are intentional sentinels meaning "remove this variable from the child environment" (consumed by ApplyEnvironmentOverridesenvironment.Remove(key) to clear DOTNET_ROOT_* arch-specific variants). But NodeLaunchData.EnvironmentOverrides was typed IDictionary<string, string>?, forcing both call sites to paper over the mismatch — MSBuildClient.cs with !, NodeProviderOutOfProc.cs via #nullable disable.

Changes Made

  • INodeLauncher.cs: EnvironmentOverridesIDictionary<string, string?>?.
  • DotnetHostEnvironmentHelper.cs: ApplyEnvironmentOverrides overrides param and foreach KVP retyped; drop stray null! (target dict is already Dictionary<string, string?>).
  • MSBuildClient.cs: drop ! and the #13761 workaround comment.
  • NodeLauncher.BuildEnvironmentBlock, DetouredNodeLauncher.CreateEnvironmentVariables: param retyped. Files are #nullable disable, so the signature is wrapped in a narrow #nullable enable annotations / #nullable disable annotations block rather than flipping the whole file.
  • NodeProviderOutOfProcTaskHost.cs: local switched to var to flow the nullable element type through without touching the file's #nullable disable context.

Testing

Full repo build (net472 + net10.0) clean with 0 warnings. AppHostSupport_Tests pass.

Notes

Type-system tightening only — no runtime behavior change. The #nullable enable annotations scoping in NodeLauncher.cs / DetouredNodeLauncher.cs is a deliberately minimal alternative to converting those files to #nullable enable wholesale.

@dotnet-policy-service

Copy link
Copy Markdown
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.

Copilot AI changed the title [WIP] Fix nullability mismatch in NodeLaunchData.EnvironmentOverrides Tighten NodeLaunchData.EnvironmentOverrides nullability to IDictionary<string, string?>? May 19, 2026
Copilot AI requested a review from OvesN May 19, 2026 13:09
Copilot finished work on behalf of OvesN May 19, 2026 13:09
@OvesN OvesN requested a review from AlesProkop June 1, 2026 10:38
@AlesProkop AlesProkop marked this pull request as ready for review June 1, 2026 13:51
Copilot AI review requested due to automatic review settings June 1, 2026 13:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) to IDictionary<string, string?>? to encode null-as-sentinel semantics in the type system.
  • Updates DotnetHostEnvironmentHelper.ApplyEnvironmentOverrides to accept nullable values and removes a stray null!.
  • Removes the ! suppression and workaround comment from MSBuildClient, and adjusts a #nullable disable call site via var.

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.

Comment thread src/Build/BackEnd/Components/Communications/NodeLauncher.cs
Comment thread src/Build/BackEnd/Components/Communications/DetouredNodeLauncher.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@OvesN OvesN left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@OvesN OvesN merged commit 1fa667f into main Jun 4, 2026
10 checks passed
@OvesN OvesN deleted the copilot/fix-nullability-mismatch-environment-overrides-again branch June 4, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nullability mismatch: NodeLaunchData.EnvironmentOverrides should be IDictionary<string, string?>?

4 participants