-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Avoid Marshal.PtrToStructure
in NativeWrapper
#118996
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
base: main
Are you sure you want to change the base?
Conversation
Avoids an unnecessary cast to long on 32-bit systems, which could introduce inefficiency without providing any benefit.
Tagging subscribers to this area: @dotnet/area-system-diagnostics-eventlog |
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs
Show resolved
Hide resolved
NativeWrapper
Marshal.PtrToStructure
in NativeWrapper
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/Reader/NativeWrapper.cs
Outdated
Show resolved
Hide resolved
{ | ||
bool status = UnsafeNativeMethods.EvtRender(contextHandle, eventHandle, flag, 0, IntPtr.Zero, out bufferNeeded, out propCount); | ||
bool status = UnsafeNativeMethods.EvtRender(contextHandle, eventHandle, flag, 0, (UnsafeNativeMethods.EvtVariant*)null, out int bufferNeeded, out int propCount); |
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.
bool status = UnsafeNativeMethods.EvtRender(contextHandle, eventHandle, flag, 0, (UnsafeNativeMethods.EvtVariant*)null, out int bufferNeeded, out int propCount); | |
bool status = UnsafeNativeMethods.EvtRender(contextHandle, eventHandle, flag, 0, null, out int bufferNeeded, out int propCount); |
Why do we need to cast here? Many other places pass in null just fine.
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.
Ah ok, I see there is an ambiguous overload. There seem to be more places that have the same problem.
Avoids an unnecessary cast to long on 32-bit systems, which could introduce inefficiency without providing any benefit.
Best reviewed hiding whitespace changes.