Repository navigation
Conversation
|
xtqqczze Isn't |
|
It is true that in .NET 7, |
|
error SYSLIB1051: The type 'IntPtr' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of parameter 'lpSecurityAttributes'. [D:\a\1\s\src\System.Management.Automation\System.Management.Automation.csproj] |
Dongbo Wang (@daxian-dbw) I guess that's why Ilya (@iSazonov) replaced I think the best option here is to use |
CreateHardLink pinvoke
CreateHardLink PInvoke
|
The old style (using IntPtr and void*) forces using unsafe context.
|
There was a problem hiding this comment.
Is there any benefit to using a custom BOOL enum here? Dotnet can handle all that for you as it was before. Why use void* when IntPtr or nint would suffice (as mentioned above) and remove the need for the unsafe context.
There was a problem hiding this comment.
I've removed the enum and explained (#18707 (comment)) why we shouldn't avoid unsafe context.
Now while I did want to clarify that point... if we're never going to actually use the parameter then I agree that |
|
I'm really confused 😅 Can someone please explain the following questions to me?
|
Yes. From design docs referenced above
We have no need the PR. The intention of the .Net team is to explicitly use nint where pointer arithmetic is used and most likely in other cases (although there are doubts about readability)
|
|
Thanks Ilya (@iSazonov). In this case then, xtqqczze shall we close this PR? |
There is no reason to avoid unsafe contexts in Pinvokes. In fact, it is an error (SYSLIB1062) to use LibraryImportAttribute without AllowUnsafeBlocks set to true. |
I believe the .NET team recommends replacing IntPtr with actual pointer types if the parameter is a pointer, e.g. dotnet/runtime@c77f524 |
This I agree. With regard to the reference dotnet code dotnet/runtime@c77f524, it changes to |
Yep that’s correct, and it being null is the same as IntPtr.Zero here. If you wanted to actually strictly type it you would need to define |
To be clear - the PR uses "unsafe" keyword even though it is not necessary. Programming languages exist precisely to avoid unverifiable constructs and
We have no need to do any operations with pointers in the PR.
Correct.
|
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment. |
WIP