Browse Source

Cache AssemblyReference.Name and AssemblyReference.FullName

pull/2643/head
Siegfried Pammer 3 years ago
parent
commit
04387d247c
  1. 19
      ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs

19
ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs

@ -222,30 +222,41 @@ namespace ICSharpCode.Decompiler.Metadata
public bool IsWindowsRuntime => (entry.Flags & AssemblyFlags.WindowsRuntime) != 0; public bool IsWindowsRuntime => (entry.Flags & AssemblyFlags.WindowsRuntime) != 0;
public bool IsRetargetable => (entry.Flags & AssemblyFlags.Retargetable) != 0; public bool IsRetargetable => (entry.Flags & AssemblyFlags.Retargetable) != 0;
string? name;
string? fullName;
public string Name { public string Name {
get { get {
if (name == null)
{
try try
{ {
return Metadata.GetString(entry.Name); name = Metadata.GetString(entry.Name);
} }
catch (BadImageFormatException) catch (BadImageFormatException)
{ {
return $"AR:{Handle}"; name = $"AR:{Handle}";
} }
} }
return name;
}
} }
public string FullName { public string FullName {
get { get {
if (fullName == null)
{
try try
{ {
return entry.GetFullAssemblyName(Metadata); fullName = entry.GetFullAssemblyName(Metadata);
} }
catch (BadImageFormatException) catch (BadImageFormatException)
{ {
return $"fullname(AR:{Handle})"; fullName = $"fullname(AR:{Handle})";
} }
} }
return fullName;
}
} }
public Version? Version => entry.Version; public Version? Version => entry.Version;

Loading…
Cancel
Save