From: Atsushi Kanamori Date: Tue, 20 Jun 2017 23:44:56 +0000 (-0700) Subject: Stub Environment from registry apis inside app-containers. (CoreCLR) (dotnet/coreclr... X-Git-Tag: submit/tizen/20210909.063632~11030^2~6925^2~378 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78c5fff2cc1f7e738fdead33a0f590063b404c47;p=platform%2Fupstream%2Fdotnet%2Fruntime.git 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 --- 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;