protected override StringBuilder AppendGenericType(StringBuilder buf, TypeReference type, DynamicParserContext context, bool appendGeneric = true, bool useTypeProjection = false) { List <TypeReference> decls = DocUtils.GetDeclaringTypes( type is GenericInstanceType ? type.GetElementType() : type); List <TypeReference> genArgs = GetGenericArguments(type); int argIndex = 0; int previouslyAppliedCount = 0; bool insertNested = false; foreach (var decl in decls) { TypeReference declDef; try { declDef = decl.Resolve() ?? decl; } catch { //Resolve() can fail as sometimes Cecil understands types as .net //needs to ignore those errors declDef = decl; } if (insertNested) { buf.Append(NestedTypeSeparator); } insertNested = true; AppendTypeName(buf, declDef, context); int argumentCount = DocUtils.GetGenericArgumentCount(declDef); int countLeftUnapplied = argumentCount - previouslyAppliedCount; previouslyAppliedCount = argumentCount; var lastItem = decls.Last(); if (countLeftUnapplied > 0 && (appendGeneric //this is to add generic syntax for parent classes in declaration of nested class //eg, ref class MyList<T>::Helper -> needs to add <T> to MyList class || decls.Count >= 2 && decl != lastItem) ) { buf.Append(GenericTypeContainer[0]); var origState = MemberFormatterState; MemberFormatterState = MemberFormatterState.WithinGenericTypeParameters; var item = genArgs[argIndex++]; _AppendTypeName(buf, item, context, useTypeProjection: useTypeProjection); if (declDef.GenericParameters.All(x => x.FullName != item.FullName)) { AppendHat(buf, item, AppendHatOnReturn); } for (int i = 1; i < countLeftUnapplied; ++i) { var newItem = genArgs[argIndex++]; _AppendTypeName(buf.Append(", "), newItem, context); if (declDef.GenericParameters.All(x => x.FullName != newItem.FullName)) { //add hat only for non-generic types AppendHat(buf, newItem); } } MemberFormatterState = origState; buf.Append(GenericTypeContainer[1]); } } return(buf); }