We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eab7a0c commit 92f774aCopy full SHA for 92f774a
src/Generator/Generators/CSharp/CSharpSources.cs
@@ -2384,6 +2384,13 @@ private void GenerateNativeConstructor(Class @class)
2384
@class.NeedsBase && !@class.BaseClass.IsInterface ? "new " : string.Empty,
2385
printedClass, Helpers.CreateInstanceIdentifier, TypePrinter.IntPtrType);
2386
WriteOpenBraceAndIndent();
2387
+
2388
+ if (@class.IsRefType)
2389
+ {
2390
+ WriteLine($"if (native == {TypePrinter.IntPtrType}.Zero)");
2391
+ WriteLineIndent("return null;");
2392
+ }
2393
2394
var suffix = @class.IsAbstract ? "Internal" : string.Empty;
2395
var ctorCall = $"{printedClass.Type}{suffix}{printedClass.NameSuffix}";
2396
WriteLine("return new {0}(native.ToPointer(), skipVTables);", ctorCall);
0 commit comments