Browse Source

Workaround Mono crasher bug when handling P/Invokes with fixed arrays.

https://bugzilla.xamarin.com/show_bug.cgi?id=33571
pull/547/head
triton 11 years ago
parent
commit
6623161200
  1. 20
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs

20
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -745,6 +745,26 @@ namespace CppSharp.Generators.CSharp
} }
PopBlock(NewLineKind.BeforeNextBlock); PopBlock(NewLineKind.BeforeNextBlock);
// Workaround a bug in Mono when handling fixed arrays in P/Invoke declarations.
// https://bugzilla.xamarin.com/show_bug.cgi?id=33571
var arrayType = field.Type.Desugar() as ArrayType;
if (arrayType != null && arrayType.SizeType == ArrayType.ArraySize.Constant &&
arrayType.Size > 0)
{
for (var i = 1; i < arrayType.Size; ++i)
{
var dummy = new Field
{
Name = string.Format("{0}_{1}_{2}", Helpers.DummyIdentifier,
safeIdentifier, i),
QualifiedType = new QualifiedType(arrayType.Type),
Offset = (uint)(field.Offset + (i * arrayType.ElementSize))
};
GenerateClassInternalsField(dummy);
}
}
} }
private void GenerateClassField(Field field, bool @public = false) private void GenerateClassField(Field field, bool @public = false)

Loading…
Cancel
Save