Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking change]: Support environment variables with empty value #41471

Closed
1 of 3 tasks
jkotas opened this issue Jun 18, 2024 · 2 comments · Fixed by #41725
Closed
1 of 3 tasks

[Breaking change]: Support environment variables with empty value #41471

jkotas opened this issue Jun 18, 2024 · 2 comments · Fixed by #41725
Assignees
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 9 Work items for the .NET 9 release doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@jkotas
Copy link
Member

jkotas commented Jun 18, 2024

Description

Add support for setting the environment variable to an empty value in Environment.SetEnvironment and ProcessInfo.Environment APIs.

Version

.NET 9 Preview 6

Previous behavior

Both Environment.SetEnvironment("TEST", string.Empty) and Environment.SetEnvironment("TEST", null) deleted the environment variable.

Both ProcessInfo.Environment["TEST"] = string.Empty and ProcessInfo.Environment["TEST"] = null set the environment variable in the child process to an empty value.

New behavior

Environment.SetEnvironment("TEST", string.Empty) sets the environment variable value to an empty value. Environment.SetEnvironment("TEST", null) behavior is unchanged, it still deletes the environment variable.

ProcessInfo.Environment["TEST"] = null deletes the environment variable. ProcessInfo.Environment["TEST"] = string.Empty behavior is unchanged, it still sets the environment variable the environment variable value to an empty value.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

Before this change, it was not possible to use Environment.SetEnvironment to set the environment variable to an empty value that is a valid environment variable value on all supported platforms.

Recommended action

Change code to pass null instead of string.Empty as the value argument to Environment.SetEnvironment API to delete the environment variable.

Change code to pass string.Empty instead of null as the value to ProcessStartInfo.Environment, ProcessStartInfo.EnvironmentVariables APIs to set the environment variable to an empty value.

Feature area

Core .NET libraries

Affected APIs

Environment.SetEnvironmentVariable, ProcessStartInfo.Environment, ProcessStartInfo.EnvironmentVariables


Associated WorkItem - 281896

@jkotas jkotas added doc-idea Indicates issues that are suggestions for new topics [org][type][category] breaking-change Indicates a .NET Core breaking change Pri1 High priority, do before Pri2 and Pri3 labels Jun 18, 2024
@dotnet-bot dotnet-bot added ⌚ Not Triaged Not triaged labels Jun 18, 2024
@gewarren
Copy link
Contributor

@jkotas Did you mean to select .NET 9 instead of .NET 8? Also, will this be in Preview 6 or 7?

@jkotas
Copy link
Member Author

jkotas commented Jun 18, 2024

Did you mean to select .NET 9 instead of .NET 8? Also, will this be in Preview 6 or 7?

Fixed - .NET 9 Preview 6.

@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jun 18, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jun 18, 2024
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jul 9, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jul 9, 2024
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jul 9, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jul 9, 2024
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jul 9, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jul 9, 2024
@gewarren gewarren removed the ⌚ Not Triaged Not triaged label Jul 9, 2024
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jul 9, 2024
@gewarren gewarren added 🏁 Release: .NET 9 Work items for the .NET 9 release 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Jul 9, 2024
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label Jul 9, 2024
@sequestor sequestor bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change 🏁 Release: .NET 9 Work items for the .NET 9 release doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants