We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
For example, the generated extension for ID2D1Factory.CreateStrokeStyle is as follows:
ID2D1Factory.CreateStrokeStyle
internal static unsafe void CreateStrokeStyle(this winmdroot.Graphics.Direct2D.ID2D1Factory @this, in winmdroot.Graphics.Direct2D.D2D1_STROKE_STYLE_PROPERTIES strokeStyleProperties, float[] dashes, out winmdroot.Graphics.Direct2D.ID2D1StrokeStyle strokeStyle) { fixed (winmdroot.Graphics.Direct2D.D2D1_STROKE_STYLE_PROPERTIES* strokeStylePropertiesLocal = &strokeStyleProperties) { @this.CreateStrokeStyle(strokeStylePropertiesLocal, dashes, (uint )dashes.Length, out strokeStyle); } }
The official API documentation states dashes is [in, optional].
dashes
[in, optional]
when you call CreateStrokeStyle with dashes set to null, you get a NullReferenceException on (uint )dashes.Length.
CreateStrokeStyle
null
NullReferenceException
(uint )dashes.Length
The generated extension methods should test for null on optional array parameters.
NativeMethods.txt
ID2D1Factory
NativeMethods.json
{ "$schema": "https://aka.ms/CsWin32.schema.json", "public": false, "allowMarshaling": true }
0.3.18-beta
net7.0
LangVersion
The text was updated successfully, but these errors were encountered:
Thanks for the excellent report.
Sorry, something went wrong.
Fix NRE thrown from some COM extension methods
24fb7be
Fixes #1041
AArnott
Successfully merging a pull request may close this issue.
Actual behavior
For example, the generated extension for
ID2D1Factory.CreateStrokeStyle
is as follows:The official API documentation states
dashes
is[in, optional]
.when you call
CreateStrokeStyle
with dashes set tonull
, you get aNullReferenceException
on(uint )dashes.Length
.Expected behavior
The generated extension methods should test for
null
on optional array parameters.Repro steps
NativeMethods.txt
content:NativeMethods.json
content (if present):Context
0.3.18-beta
net7.0
LangVersion
(if explicitly set by project): n/aThe text was updated successfully, but these errors were encountered: