diff --git a/ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs b/ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs index 8da603016..d1b642a30 100644 --- a/ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs +++ b/ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs @@ -222,29 +222,40 @@ namespace ICSharpCode.Decompiler.Metadata public bool IsWindowsRuntime => (entry.Flags & AssemblyFlags.WindowsRuntime) != 0; public bool IsRetargetable => (entry.Flags & AssemblyFlags.Retargetable) != 0; + string? name; + string? fullName; + public string Name { get { - try - { - return Metadata.GetString(entry.Name); - } - catch (BadImageFormatException) + if (name == null) { - return $"AR:{Handle}"; + try + { + name = Metadata.GetString(entry.Name); + } + catch (BadImageFormatException) + { + name = $"AR:{Handle}"; + } } + return name; } } public string FullName { get { - try - { - return entry.GetFullAssemblyName(Metadata); - } - catch (BadImageFormatException) + if (fullName == null) { - return $"fullname(AR:{Handle})"; + try + { + fullName = entry.GetFullAssemblyName(Metadata); + } + catch (BadImageFormatException) + { + fullName = $"fullname(AR:{Handle})"; + } } + return fullName; } }