Provide an additional friendly overload with raw unconvertible handles when necessary#1693
Provide an additional friendly overload with raw unconvertible handles when necessary#1693DoctorKrolic wants to merge 1 commit into
Conversation
|
There is already a safeHandles knob in NativeMethods.json. How is this different than letting the consumer choose a different form of the projection? More overloads can just be more confusing. It sounds like from the description this is limited to "complex" handles, could you give some concrete examples for those and how this would help? |
The added test functions show this quite well. In order to enumerate WFP filters you need to open an enum handle via |
|
@jevansaks PTAL |
|
DoctorKrolic, maybe don't ping and hassle maintainers? There's already not a lot of development occuring with this project, and being hassled is a sure fire way (at least for me) to put soemthing like this at the absolute bottom of my pile. |
|
I've noodled on this and I am not a fan of this approach. It's easy enough for callers to make a non-owning SafeHandle to pass in (e.g. If this is a hardship, can we talk about what it takes to project the methods which return raw handles as the appropriate generated SafeHandle type? IIRC from other threads the CloseHandle method takes multiple parameters so is the right thing for the generated code to somehow get the other parameters passed in or from some available context? |
Previously if friendly overload accepted a handle with a known release method CsWin32 would always "promote" it to a
SafeHandle. This works well if CsWin32 can trivially represent that handle as aSafeHandleso that function that opens/creates the handle in the first place returns it a a custom generatedSafeHandle. However, if release method is a complicated one and CsWin32 cannot generate a trivialSafeHandlewrapper based on it user was forced to declare such safe handle type on their own to use it in other friendly overloads. This might not be ideal e.g. if the handle is used whithin one method frame so that declaring a safe handle type for it is an overkill. Now CsWin32 generates another overload with such handles represented as "raw" handles so that user has a choice either to use the raw handle or to declare their own safe handle type and use it instead