-
Notifications
You must be signed in to change notification settings - Fork 122
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
Why is MemorySize
applied to WriteFile
?
#1555
Comments
See also microsoft/CsWin32#913 where this caused a bug in CsWin32. |
MemorySize is being applied instead of NativeArrayInfo when the SAL annotations use byteCount instead of elementCount. |
Ok. I'll go forward with CsWin32's approach of special cases |
I think the generic way of thinking of MemorySize is whatever you're passing in for this parameter, pass its size to the parameter indicated by BytesParamIndex. |
MemorySize
applied to CreateFile
?MemorySize
applied to WriteFile
?
I expect arrays to be identified with the
NativeArrayInfoAttribute
, butWriteFile
'slpBuffer
parameter usesMemorySizeAttribute
instead.MemorySizeAttribute
is already used elsewhere for a different purpose. Instead of describing the length of a byte array, it describes the size of just one struct as inSHGetFileInfo
:So it seems
MemorySizeAttribute
plays dual roles: it is used on pointers to arrays likelpBuffer
and indicates the length of the array, and also on pointers to a single struct likepsfi
and indicates the size of one struct.It is impossible to discern whether a pointer parameter with this attribute applied is an array or not without building some discrimination into it (e.g.
byte*
must mean length of an array, and all other parameter types must mean size of one struct).Is this really by design? Or should we fix
WriteFile
to useNativeArrayInfo
instead?The text was updated successfully, but these errors were encountered: