{{ message }}
Simplify in-process env isolation to snapshot/restore - #1929
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
SteveSandersonMS
force-pushed
the
stevesa/simplify-inprocess-env-isolation
branch
from
July 7, 2026 09:16
4c27c48 to
4c3e781
Compare
This comment has been minimized.
This comment has been minimized.
SteveSandersonMS
force-pushed
the
stevesa/simplify-inprocess-env-isolation
branch
from
July 7, 2026 09:21
4c3e781 to
f0084e2
Compare
This comment has been minimized.
This comment has been minimized.
Replace the targeted per-name pristine tracking (s_pristineByName, Mirror/Restore) with a blanket load-time environment snapshot restored after every test. The attribute now blanks leaky CI credentials before each test and reverts the whole process environment afterwards, regardless of transport, so per-test mirrors and fixture-teardown backstops in E2ETestContext are no longer needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SteveSandersonMS
force-pushed
the
stevesa/simplify-inprocess-env-isolation
branch
from
July 7, 2026 09:27
f0084e2 to
8d191fd
Compare
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies the .NET E2E test harness’s process environment isolation for the in-process (FFI) transport by taking a single “ambient environment” snapshot at assembly load and restoring that snapshot after each test via an assembly-level xUnit attribute.
Changes:
- Added a net472 polyfill for
[ModuleInitializer]so the harness can snapshot environment at module load across TFMs. - Replaced per-variable pristine tracking with a single load-time snapshot plus per-test restore, and updated credential suppression to unset variables.
- Centralized env restore behavior in the
InProcessEnvIsolationAttribute, removing the fixture-level restore backstops and simplifying cleanup logic.
Show a summary per file
| File | Description |
|---|---|
| dotnet/test/Harness/ModuleInitializerAttribute.cs | Adds a net472 [ModuleInitializer] attribute polyfill to support assembly-load snapshotting. |
| dotnet/test/Harness/InProcessEnvIsolation.cs | Implements load-time env snapshot + per-test restore; updates suppression/restore mechanics and xUnit hook. |
| dotnet/test/Harness/E2ETestContext.cs | Switches mirroring to Apply(...) and removes explicit restore calls from cleanup/teardown paths. |
| dotnet/test/AssemblyInfo.cs | Keeps assembly-level env isolation attribute, trimming now-obsolete commentary. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Low
Comment on lines
+290
to
+294
3 tasks
edburns
pushed a commit
that referenced
this pull request
Aug 4, 2026
edburns
pushed a commit
that referenced
this pull request
Aug 4, 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.

Simplifies the E2E test environment-variable isolation machinery (
InProcessEnvIsolation.cs).What changed
s_pristineByName,Mirror/Restore) with a single environment snapshot captured at assembly load ([ModuleInitializer]) and restored after every test. The snapshot must be load-time because the sharedIClassFixturemirrors per-test env onto the process before the first test'sBeforehook runs.InProcessEnvIsolationAttributenow neutralizes ambient credentials before each test and restores the full environment afterwards regardless of transport. RemovedIsActiveand the per-test / fixture-teardownRestore()backstops inE2ETestContext(restoration is now centralized). The graceful-vs-force stop decision inStopClientForCleanupAsyncinlines its own connection check.string?;nulluniformly means "unset" (no coercion to""). Credential suppression now unsets rather than blanking.CaptureEnvironmentis a one-line LINQ projection;SuppressEnvVarsrenamed fromLeakyCredentialVars; comments trimmed.Verification
ClientE2ETestswith a simulated ambientCOPILOT_HMAC_KEYset (confirms neutralization prevents live-API auth).This is still TEMPORARY test-only scaffolding — the whole file is deletable once the runtime stops reading the ambient process environment host-side over the in-process FFI transport.
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com