Browse Source

Generate exception on broken struct set op

pull/1778/head
Salvage 3 years ago
parent
commit
ec16bcfa41
No known key found for this signature in database
GPG Key ID: 1362C7A680BA7451
  1. 3
      src/Generator/Types/Std/Stdlib.CSharp.cs
  2. 1
      tests/dotnet/CSharp/CSharp.Tests.cs
  3. 5
      tests/dotnet/CSharp/CSharp.h

3
src/Generator/Types/Std/Stdlib.CSharp.cs

@ -331,6 +331,9 @@ namespace CppSharp.Types.Std @@ -331,6 +331,9 @@ namespace CppSharp.Types.Std
string var;
if (ctx.ReturnVarName.LastIndexOf('.') > ctx.ReturnVarName.LastIndexOf("->"))
{
ctx.Before.WriteLine("throw new NotImplementedException(\"This method cannot currently be called because it would " +
"leave the object in an invalid state. See https://github.com/mono/CppSharp/issues/1777\");");
var = Generator.GeneratedIdentifier(ctx.ArgName);
ctx.Before.WriteLine($"fixed (void* {var} = &{ctx.ReturnVarName})");
ctx.Before.WriteOpenBraceAndIndent();

1
tests/dotnet/CSharp/CSharp.Tests.cs

@ -2027,6 +2027,7 @@ public unsafe class CSharpTests @@ -2027,6 +2027,7 @@ public unsafe class CSharpTests
}
[Test]
[Ignore("https://github.com/mono/CppSharp/issues/1730")]
public void TestString()
{
var test = new CSharp.ValueType();

5
tests/dotnet/CSharp/CSharp.h

@ -1642,8 +1642,11 @@ public: @@ -1642,8 +1642,11 @@ public:
inline void DLL_API InstantiateOptionalTemplate(Optional<unsigned int>, Optional<std::string>,
Optional<TestComparison>, Optional<char*>, Optional<UnionTester>) { }
CS_VALUE_TYPE class DLL_API value_type {
CS_VALUE_TYPE class DLL_API ValueType {
public:
// Parameterless ctors are currently not generated for value types.
ValueType(int) { }
std::string string_member;
const char* char_ptr_member;
};

Loading…
Cancel
Save