closes #514.
@ -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})",
return true;
}
@ -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;