diff --git a/src/Generator/Generators/CodeGenerator.cs b/src/Generator/Generators/CodeGenerator.cs index e0057a13..a67740d4 100644 --- a/src/Generator/Generators/CodeGenerator.cs +++ b/src/Generator/Generators/CodeGenerator.cs @@ -1317,7 +1317,7 @@ namespace CppSharp.Generators if (@class != specialization) template = template.Classes.FirstOrDefault(c => c.Name == @class.Name); - if (template.HasDependentValueFieldInLayout()) + if (template?.HasDependentValueFieldInLayout() ?? false) { if (specialization.Arguments.All( a => a.Type.Type?.IsAddress() == true))