From 3339c3794010b37618cf6fce124d1fe3a2ddcb54 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Thu, 1 Mar 2018 14:42:55 -0500 Subject: [PATCH] Traits: This caches values of various environment variables which act as .. switches to control features like logging imports. For use with tests, this caching can be disabled but that is enabled only for DEBUG builds. Which means that any tests trying to toggle and test those environment variable dependent features will work only for debug builds. This is also controlled by the environment variable, `MSBUILDRELOADTRAITSONEACHACCESS`, which is no longer required. @cdmihai: I remember that in the past, we relied on the env var as a way for tests to communicate to the Traits to refresh themselves. We needed the var because Traits is compiled into every assembly, so every assembly has it's own copy of the object, and we had no easy way of addressing all of them. But now we use reflection as a single source of truth, which makes me believe we don't need the env var at all. (https://github.com/Microsoft/msbuild/pull/3385#issuecomment-397376338) --- src/Shared/Traits.cs | 4 +--- src/Shared/UnitTests/TestEnvironment.cs | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Shared/Traits.cs b/src/Shared/Traits.cs index 7f0dd0ec3f6..de37c11c566 100644 --- a/src/Shared/Traits.cs +++ b/src/Shared/Traits.cs @@ -18,12 +18,10 @@ public static Traits Instance { get { -#if DEBUG - if (BuildEnvironmentHelper.Instance.RunningTests && Environment.GetEnvironmentVariable("MSBUILDRELOADTRAITSONEACHACCESS") == "1") + if (BuildEnvironmentHelper.Instance.RunningTests) { return new Traits(); } -#endif return _instance; } } diff --git a/src/Shared/UnitTests/TestEnvironment.cs b/src/Shared/UnitTests/TestEnvironment.cs index 17bde2a2d92..da5464dcbfa 100644 --- a/src/Shared/UnitTests/TestEnvironment.cs +++ b/src/Shared/UnitTests/TestEnvironment.cs @@ -47,8 +47,6 @@ public static TestEnvironment Create(ITestOutputHelper output = null, bool ignor env.WithInvariant(new BuildFailureLogInvariant()); } - env.SetEnvironmentVariable("MSBUILDRELOADTRAITSONEACHACCESS", "1"); - return env; }