dahall / Vanara

A set of .NET libraries for Windows implementing PInvoke calls to many native Windows APIs with supporting wrappers.
MIT License
1.79k stars 193 forks source link

Annotations attributes #7

Closed NN--- closed 5 years ago

NN--- commented 6 years ago

What do you think about adding annotations attributes ? https://www.jetbrains.com/help/resharper/Reference__Code_Annotation_Attributes.html

dahall commented 6 years ago

I like the idea, but it would take an incredible amount of time since I would have to read the help for each of the 10,000 functions and annotate each one. Thoughts on automating that?

NN--- commented 6 years ago

Not sure what is the best way. If you look in SDK headers, they have several attributes specifying whether pointer is nullable or not for instance:

WINBASEAPI
BOOL
WINAPI
CreateProcessW(
    _In_opt_ LPCWSTR lpApplicationName,
    _Inout_opt_ LPWSTR lpCommandLine,
    _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
    _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
    _In_ BOOL bInheritHandles,
    _In_ DWORD dwCreationFlags,
    _In_opt_ LPVOID lpEnvironment,
    _In_opt_ LPCWSTR lpCurrentDirectory,
    _In_ LPSTARTUPINFOW lpStartupInfo,
    _Out_ LPPROCESS_INFORMATION lpProcessInformation
    );
dahall commented 5 years ago

I have used the [Optional] attribute on parameters that could be omitted by passing null in the 2.0 release. Using the JetBrains attributes are the next step, but I wanted to get 2.0 out.