public static void AcceptVisitor <TResult> ( this TypeReference typeReference, MetadataVisitor <TResult> visitor) { if (!visitor.ShouldTraverseInto(visitor.VisitTypeReference(typeReference))) { return; } if (typeReference.IsGenericInstance && typeReference is GenericInstanceType genericTypeReference && genericTypeReference.HasGenericArguments) { foreach (var genericArgument in genericTypeReference.GenericArguments) { genericArgument.AcceptVisitor(visitor); } } var elementTypeReference = typeReference.GetElementType(); if (elementTypeReference != null && elementTypeReference != typeReference) { elementTypeReference.AcceptVisitor(visitor); } typeReference.DeclaringType?.AcceptVisitor(visitor); }