CppSharp
CppSharp copied to clipboard
Lack of tests with `MarshalCharAsManagedChar = false` is causing issues now and will in the future
CSharp test projects wont build
// A value of type 'char' cannot be used as a default parameter because there are no standard
public void DefaultChar(sbyte c = 'a')
public sbyte** Names {
get {
// Cannot take the address of, get the size of, or declare a conversions to type 'sbyte'
return (string*) ((global::CSharp.TestPointers.__Internal*) __Instance)->Names;
}
}
// error CS1503: Argument 1: cannot convert from 'char' to 'sbyte'
Assert.That(*CSharp.CSharp.TakeConstCharRef(z), Is.EqualTo(z));
// error CS1503: Argument 1: cannot convert from 'char*' to 'sbyte*'
Assert.That(*CSharp.CSharp.TakeCharPointer(&c), Is.EqualTo(c));
These other bugs would have been found much sooner with MarshalCharAsManagedChar set to false
https://github.com/mono/CppSharp/issues/1417 https://github.com/mono/CppSharp/issues/1420 https://github.com/mono/CppSharp/issues/1409
@ddobrev We should definitely add a new CI test configuration to keep this tested.
As for the testing assertion errors, perhaps the best way to fix them would be add an #ifdef MARSHAL_AS_MANAGED_CHAR option I guess to conditionally use a different type.