How to marshall pointer to array inside struct
I have the following struct
Here
I am using
[StructLayout(LayoutKind.Sequential)]
public unsafe struct Font
{
public int BaseSize;
public int GlyphCount;
public int GlyphPadding;
public Texture Texture;
public Rectangle* Recs;
public GlyphInfo* Glyphs;
}[StructLayout(LayoutKind.Sequential)]
public unsafe struct Font
{
public int BaseSize;
public int GlyphCount;
public int GlyphPadding;
public Texture Texture;
public Rectangle* Recs;
public GlyphInfo* Glyphs;
}Here
RecsRecs and GlyphsGlyphs are C like arrays iirc. I want to marshal them to managed ones but I get the following error[StructLayout(LayoutKind.Sequential)]
public unsafe struct Font
{
public int BaseSize;
public int GlyphCount;
public int GlyphPadding;
public Texture Texture;
// Already tried [MarshalAs(UnmanagedType.ByValArray)]
public Rectangle[] Recs;
public GlyphInfo[] Glyphs;
}[StructLayout(LayoutKind.Sequential)]
public unsafe struct Font
{
public int BaseSize;
public int GlyphCount;
public int GlyphPadding;
public Texture Texture;
// Already tried [MarshalAs(UnmanagedType.ByValArray)]
public Rectangle[] Recs;
public GlyphInfo[] Glyphs;
}Error SYSLIB1051 : The type 'MyNamespace.Font' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of parameter 'font'.Error SYSLIB1051 : The type 'MyNamespace.Font' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of parameter 'font'.I am using
LibraryImportLibraryImport
