diff --git a/Mono.Cecil/ExportedType.cs b/Mono.Cecil/ExportedType.cs index 8238a0c6d..8b7d00a27 100644 --- a/Mono.Cecil/ExportedType.cs +++ b/Mono.Cecil/ExportedType.cs @@ -225,9 +225,21 @@ public override string ToString () return FullName; } + private bool reentrancyGuard = false; + public TypeDefinition Resolve () { - return module.Resolve (CreateReference ()); + if (reentrancyGuard) { + throw new InvalidOperationException ($"Circularity when resolving exported type {this}"); + } + + reentrancyGuard = true; + try { + return module.Resolve (CreateReference ()); + } + finally { + reentrancyGuard = false; + } } internal TypeReference CreateReference ()