From 78c5fff2cc1f7e738fdead33a0f590063b404c47 Mon Sep 17 00:00:00 2001 From: Atsushi Kanamori Date: Tue, 20 Jun 2017 16:44:56 -0700 Subject: [PATCH] Stub Environment from registry apis inside app-containers. (CoreCLR) (dotnet/coreclr#12390) We're not going to get exemptions for these inside appcontainers so we'll change them to behave as they do on Unix (present an empty reg key that eats writes requests.) Commit migrated from https://github.com/dotnet/coreclr/commit/c1456fe280d5ea5e3e2f99024d905ce85439493c --- src/coreclr/src/mscorlib/src/System/Environment.cs | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/coreclr/src/mscorlib/src/System/Environment.cs b/src/coreclr/src/mscorlib/src/System/Environment.cs index cd25967..e634341 100644 --- a/src/coreclr/src/mscorlib/src/System/Environment.cs +++ b/src/coreclr/src/mscorlib/src/System/Environment.cs @@ -585,9 +585,13 @@ namespace System if (target == EnvironmentVariableTarget.Process) return GetEnvironmentVariableCore(variable); -#if !FEATURE_WIN32_REGISTRY - return null; -#else +#if FEATURE_WIN32_REGISTRY + if (AppDomain.IsAppXModel()) +#endif + { + return null; + } +#if FEATURE_WIN32_REGISTRY RegistryKey baseKey; string keyName; @@ -670,11 +674,15 @@ namespace System internal static IEnumerable> EnumerateEnvironmentVariablesFromRegistry(EnvironmentVariableTarget target) { -#if !FEATURE_WIN32_REGISTRY - // Without registry support we have nothing to return - ValidateTarget(target); - yield break; -#else +#if FEATURE_WIN32_REGISTRY + if (AppDomain.IsAppXModel()) +#endif + { + // Without registry support we have nothing to return + ValidateTarget(target); + yield break; + } +#if FEATURE_WIN32_REGISTRY RegistryKey baseKey; string keyName; if (target == EnvironmentVariableTarget.Machine) @@ -740,10 +748,14 @@ namespace System return; } -#if !FEATURE_WIN32_REGISTRY - // other targets ignored - return; -#else +#if FEATURE_WIN32_REGISTRY + if (AppDomain.IsAppXModel()) +#endif + { + // other targets ignored + return; + } +#if FEATURE_WIN32_REGISTRY // explicitly null out value if is the empty string. if (string.IsNullOrEmpty(value) || value[0] == '\0') value = null; -- 2.7.4