Browse Source

closes #514.

test added to tests/CSharpTemp/CSharpTemp.Tests.cs
pull/522/head
Pedro Miguel Casaleiro Dias 10 years ago
parent
commit
ed3e0bd54a
  1. 3
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  2. 10
      tests/CSharpTemp/CSharpTemp.Tests.cs

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

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

10
tests/CSharpTemp/CSharpTemp.Tests.cs

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