[Config Registry] 6/6 Forbid use of System.Environment methods and adapt everywhere #7905
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.
Context
Part of Configuration Inversion (Step 6) - Stack progress:
I'll update the PR summary to mention the YAML documentation file:
Summary of changes
Banned direct
System.Environment.GetEnvironmentVariable()usage and migrated all environment variable access to useEnvironmentHelperswith strongly-typed ConfigurationKeys andPlatformKeysconstants.Key changes:
System.Environment.GetEnvironmentVariable()viaBannedApiAnalyzersEnvironmentGetEnvironmentVariableAnalyzer(DD0009) to enforce ConfigurationKeys/PlatformKeysusage onlyPlatformKeysby category (Ci, Aws, AzureAppService, ServiceFabric, DotNet)Reason for change
Direct
System.Environment.GetEnvironmentVariable()calls with string literals are error-prone. Centralizing throughEnvironmentHelperswith strongly-typed constants provides compile-time validation, discoverability, and refactoring safety.Implementation details
BannedSymbols.txtand configured.editorconfigto treat RS0030 as error (vendored code excluded)EnvironmentHelperscalls accept only ConfigurationKeys/PlatformKeysconstants, rejecting hardcoded stringsTest coverage
System.EnvironmentusageOther details
+2,600/-940 lines. No breaking changes, negligible performance impact.