Skip to content

Commit

Permalink
Ignore SendMessageTimeout failures on Windows Nano Server (#80099)
Browse files Browse the repository at this point in the history
* Ignore SendMessageTimeout failures on Windows Nano Server

* Fix tests

Fixes #30566
  • Loading branch information
jkotas authored Jan 3, 2023
1 parent e574fbe commit 6c2b939
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ private static void SetEnvironmentVariableFromRegistry(string variable, string?
{
IntPtr unused;
IntPtr r = Interop.User32.SendMessageTimeout(new IntPtr(Interop.User32.HWND_BROADCAST), Interop.User32.WM_SETTINGCHANGE, IntPtr.Zero, (IntPtr)lParam, 0, 1000, &unused);
Debug.Assert(r != IntPtr.Zero, $"SetEnvironmentVariable failed: {Marshal.GetLastPInvokeError()}");

// SendMessageTimeout message is a empty stub on Windows Nano Server that fails with both result and last error 0.
Debug.Assert(r != IntPtr.Zero || Marshal.GetLastPInvokeError() == 0, $"SetEnvironmentVariable failed: {Marshal.GetLastPInvokeError()}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ public void EnumerateEnvironmentVariables(EnvironmentVariableTarget target)
bool lookForSetValue = (target == EnvironmentVariableTarget.Process)
|| (PlatformDetection.IsWindows && PlatformDetection.IsPrivilegedProcess);

// [ActiveIssue("https://github.com/dotnet/runtime/issues/30566")]
if (PlatformDetection.IsWindowsNanoServer && target == EnvironmentVariableTarget.User)
if (target == EnvironmentVariableTarget.User && PlatformDetection.IsWindowsNanoServer)
{
// Windows Nano Server does not have full per-user registry hives
lookForSetValue = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public class SetEnvironmentVariable

internal static bool IsSupportedTarget(EnvironmentVariableTarget target)
{
// [ActiveIssue("https://github.com/dotnet/runtime/issues/30566")]
if (target == EnvironmentVariableTarget.User && PlatformDetection.IsWindowsNanoServer)
{
// Windows Nano Server does not have full per-user registry hives
return false;
}

Expand Down
4 changes: 0 additions & 4 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,6 @@
<!-- https://github.com/dotnet/runtime/issues/72908 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Reflection.MetadataLoadContext\tests\System.Reflection.MetadataLoadContext.Tests.csproj" />

<!-- https://github.com/dotnet/runtime/issues/30566 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.Extensions\tests\System.Runtime.Extensions.Tests.csproj"
Condition="'$(RuntimeConfiguration)' == 'checked' and '$(TargetOS)' == 'windows'" />

<!-- Test needs to copy .so file: https://github.com/dotnet/runtime/issues/72987 -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.IO.Ports\tests\System.IO.Ports.Tests.csproj"
Condition="'$(TargetOS)' != 'windows'" />
Expand Down

0 comments on commit 6c2b939

Please sign in to comment.