diff options
author | Elinor Fung <elfung@microsoft.com> | 2021-04-24 03:16:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-24 03:16:02 +0300 |
commit | 842956952e12361390ad92960b6124738500272a (patch) | |
tree | 2483a9e903ca4c36be01498ca03cbec030401a56 /src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop | |
parent | 59aa9c7d37cb3c12d34017918116c495b0fdc7ff (diff) |
Rename MarshalEx.SetLastWin32Error -> SetLastPInvokeError (dotnet/runtimelab#1007)
Commit migrated from https://github.com/dotnet/runtimelab/commit/82735dd0fef4886ae2f0886267ef30822e17ee8a
Diffstat (limited to 'src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop')
-rw-r--r-- | src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs index 8a53af07090..716dcf28eec 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/Ancillary.Interop/MarshalEx.cs @@ -23,9 +23,15 @@ namespace System.Runtime.InteropServices /// <summary> /// Set the last platform invoke error on the thread /// </summary> - public static void SetLastWin32Error(int error) + public static void SetLastPInvokeError(int error) { - typeof(Marshal).GetMethod("SetLastWin32Error", BindingFlags.NonPublic | BindingFlags.Static)!.Invoke(null, new object[] { error }); + MethodInfo? method = typeof(Marshal).GetMethod("SetLastWin32Error", BindingFlags.NonPublic | BindingFlags.Static); + if (method == null) + { + method = typeof(Marshal).GetMethod("SetLastPInvokeError", BindingFlags.Public | BindingFlags.Static); + } + + method!.Invoke(null, new object[] { error }); } /// <summary> |