-
Notifications
You must be signed in to change notification settings - Fork 191
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
Create static method for structures which require initialization #8
Comments
I can definitely do this for this particular structure. I have done it elsewhere in the library as constructors and would likely follow that same pattern here. |
The problem is that you cannot overload empty constructor in struct, so using static method is a better way IMO. |
I think this would help me also. My P/Invoke isn't that strong and I'm trying to get my feet wet with Authz API by calling AuthzEnumerateSecurityEventSources. I call it once to get back a count of 12 |
I think I found what I needed in the AuthzEnumerateSecurityEventSourcesTest method but I'm not sure it's best practice to just assume 200 is big enough. I was assuming I'd have to call the API once to get the count and then allocate that many. But I don't really know this API well enough to say that for a fact. |
I need to spend some time investigating this, but my guess is that it is an error on my part. I'm traveling this week and may not be able to validate or invalidate this very quickly. |
@chrpai Please see the new issue I created from your last message. There is no bug and I provided and example of how to use the method without overallocating memory. |
I'm closing this as I have been adding a |
PInvoke library has a convenient Create method for structures where there is a need for some default initialization.
This library should have this too.
For instance:
https://github.com/AArnott/pinvoke/blob/bc4c6830f1918f5af28e76e075dd0750f27d3c61/src/Kernel32/desktop/Kernel32%2BStartupInfo.cs#L127
The text was updated successfully, but these errors were encountered: