Browse Source

Fix non-void returning functions with value-type out parameters

Also fixes indentation
pull/1775/head
Salvage 2 years ago
parent
commit
125d652dd9
No known key found for this signature in database
GPG Key ID: 1362C7A680BA7451
  1. 2
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  2. 2
      tests/dotnet/CSharp/CSharp.Tests.cs
  3. 3
      tests/dotnet/CSharp/CSharp.cpp
  4. 2
      tests/dotnet/CSharp/CSharp.h

2
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -637,9 +637,9 @@ namespace CppSharp.Generators.CSharp @@ -637,9 +637,9 @@ namespace CppSharp.Generators.CSharp
Context.Before.WriteLine("fixed ({0}.{1}* {2} = &{3}.{4})",
Context.Parameter.QualifiedType, Helpers.InternalStruct,
arg, Context.Parameter.Name, Helpers.InstanceIdentifier);
Context.HasCodeBlock = true;
Context.Before.WriteOpenBraceAndIndent();
Context.Return.Write($"new {typePrinter.IntPtrType}({arg})");
Context.Cleanup.UnindentAndWriteCloseBrace();
}
else
{

2
tests/dotnet/CSharp/CSharp.Tests.cs

@ -1999,7 +1999,7 @@ public unsafe class CSharpTests @@ -1999,7 +1999,7 @@ public unsafe class CSharpTests
[Test]
public void TestValueTypeOutParameter()
{
CSharp.CSharp.ValueTypeOutParameter(out var unionTestA, out var unionTestB);
Assert.AreEqual(2, CSharp.CSharp.ValueTypeOutParameter(out var unionTestA, out var unionTestB));
Assert.AreEqual(2, unionTestA.A);
Assert.AreEqual(2, unionTestB.B);
}

3
tests/dotnet/CSharp/CSharp.cpp

@ -1792,8 +1792,9 @@ bool PointerTester::IsValid() @@ -1792,8 +1792,9 @@ bool PointerTester::IsValid()
PointerTester* PointerToClass = &internalPointerTesterInstance;
void ValueTypeOutParameter(UnionTester* testerA, UnionTester* testerB)
int ValueTypeOutParameter(UnionTester* testerA, UnionTester* testerB)
{
testerA->a = 2;
testerB->b = 2;
return 2;
}

2
tests/dotnet/CSharp/CSharp.h

@ -1609,4 +1609,4 @@ union DLL_API UnionTester { @@ -1609,4 +1609,4 @@ union DLL_API UnionTester {
int b;
};
void DLL_API ValueTypeOutParameter(CS_OUT UnionTester* testerA, CS_OUT UnionTester* testerB);
int DLL_API ValueTypeOutParameter(CS_OUT UnionTester* testerA, CS_OUT UnionTester* testerB);

Loading…
Cancel
Save