diff --git a/src/Generator/Generators/C/CppTypePrinter.cs b/src/Generator/Generators/C/CppTypePrinter.cs index 28b9334e..f032f69f 100644 --- a/src/Generator/Generators/C/CppTypePrinter.cs +++ b/src/Generator/Generators/C/CppTypePrinter.cs @@ -5,6 +5,7 @@ using System.Linq; using CppSharp.AST; using CppSharp.AST.Extensions; using CppSharp.Generators.CSharp; +using CppSharp.Passes; using CppSharp.Types; namespace CppSharp.Generators.C @@ -577,11 +578,11 @@ namespace CppSharp.Generators.C args.Add(arg.Declaration.Visit(this)); break; case TemplateArgument.ArgumentKind.Integral: - Class template = specialization.TemplatedDecl.TemplatedClass; - var nonTypeTemplateParameter = template.TemplateParameters[i] + ClassTemplate template = specialization.TemplatedDecl; + var nonTypeTemplateParameter = template.Parameters[i] as NonTypeTemplateParameter; if (!(nonTypeTemplateParameter?.DefaultArgument is - BuiltinTypeExpressionObsolete builtinExpression) || + BuiltinTypeExpressionObsolete builtinExpression) || builtinExpression.Value != arg.Integral) { args.Add(arg.Integral.ToString(CultureInfo.InvariantCulture)); diff --git a/tests/CSharp/CSharpTemplates.h b/tests/CSharp/CSharpTemplates.h index b43c76a5..b25d902d 100644 --- a/tests/CSharp/CSharpTemplates.h +++ b/tests/CSharp/CSharpTemplates.h @@ -944,3 +944,22 @@ public: }; const FloatArrayF<6> I6{ 1., 1., 1., 0., 0., 0. }; + +// KEEP ORDER OTHERWISE TEST WONT WORK +namespace IncompleteClassTemplatesTests +{ + template + struct StructSizeT {}; + + template + struct StructT + { + template + struct Inc { }; + }; + + struct Instantiation + { + StructT> st; + }; +} \ No newline at end of file