Browse Source

Merge pull request #522 from xistoso/master

closes #514.
pull/523/merge
João Matos 10 years ago
parent
commit
c55ffa990c
  1. 5
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  2. 10
      tests/CSharpTemp/CSharpTemp.Tests.cs

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

@ -401,9 +401,8 @@ namespace CppSharp.Generators.CSharp @@ -401,9 +401,8 @@ namespace CppSharp.Generators.CSharp
public bool VisitDelegateType(FunctionType function, string type)
{
Context.Return.Write("Marshal.GetFunctionPointerForDelegate({0})",
Context.Parameter.Name);
Context.Return.Write("{0} == null ? global::System.IntPtr.Zero : Marshal.GetFunctionPointerForDelegate({0})",
Context.Parameter.Name);
return true;
}

10
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -327,4 +327,14 @@ public class CSharpTempTests : GeneratorTestFixture @@ -327,4 +327,14 @@ public class CSharpTempTests : GeneratorTestFixture
dervClass = new TestParamToInterfacePass(dervClass + baseInterface);
Assert.AreEqual(dervClass.M, 2);
}
[Test]
public void TestNullAttributedFunctionPtr()
{
using (var foo = new Foo())
{
foo.AttributedFunctionPtr = null;
}
}
}
Loading…
Cancel
Save