-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Marshal.Get(Last)PInvokeErrorMessage()
APIs.
#70685
Implement Marshal.Get(Last)PInvokeErrorMessage()
APIs.
#70685
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsThe behavior of this API is to return the same value as Fixes #67872 /cc @danmoseley @dotnet/interop-contrib
|
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs
Outdated
Show resolved
Hide resolved
There are other places using Interop.Kernel32.GetMessage. It'd be nice to have them changed (where possible) to just call Marshal.GetPInvokeErrorMessage, e.g.
runtime/src/libraries/System.Private.CoreLib/src/System/Environment.Variables.Windows.cs Lines 51 to 54 in a103efd
There are also places doing Line 134 in 4277bc5
Line 155 in 4277bc5
Line 632 in a103efd
|
...InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PInvokeErrorMessageTests.cs
Show resolved
Hide resolved
...ibraries/System.Security.Principal.Windows/src/System/Security/Principal/WindowsPrincipal.cs
Outdated
Show resolved
Hide resolved
The behavior of this API is to return the same value as new Win32Exception(error).Message, while avoiding the instantion of an exception.
Marshal implementation to handle the P/Invoke call. Consume new API in places where possible.
3464441
to
f498fcc
Compare
Marshal.GetPInvokeErrorMessage()
API.Marshal.Get(Last)PInvokeErrorMessage()
APIs.
...InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PInvokeErrorMessageTests.cs
Show resolved
Hide resolved
...InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/PInvokeErrorMessageTests.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement, thanks
The behavior of this API is to return the same value as
new Win32Exception(error).Message
, while avoiding theinstantiation of an exception.
Fixes #67872
/cc @danmoseley @dotnet/interop-contrib