Browse Source

Fix #1777 and part 2 of #1776: Add more null checks

pull/1790/head
Siegfried Pammer 6 years ago
parent
commit
e104f4ce6e
  1. 5
      ILSpy/MainWindow.xaml.cs
  2. 10
      ILSpy/TextView/DecompilerTextView.cs

5
ILSpy/MainWindow.xaml.cs

@ -399,6 +399,11 @@ namespace ICSharpCode.ILSpy @@ -399,6 +399,11 @@ namespace ICSharpCode.ILSpy
static bool CanResolveTypeInPEFile(PEFile module, ITypeReference typeRef, out EntityHandle typeHandle)
{
if (module == null) {
typeHandle = default;
return false;
}
switch (typeRef) {
case GetPotentiallyNestedClassTypeReference topLevelType:
typeHandle = topLevelType.ResolveInPEFile(module);

10
ILSpy/TextView/DecompilerTextView.cs

@ -345,14 +345,20 @@ namespace ICSharpCode.ILSpy.TextView @@ -345,14 +345,20 @@ namespace ICSharpCode.ILSpy.TextView
}
return new FlowDocumentTooltip(renderer.CreateDocument());
} else if (segment.Reference is IEntity entity) {
return new FlowDocumentTooltip(CreateTooltipForEntity(entity));
var document = CreateTooltipForEntity(entity);
if (document == null)
return null;
return new FlowDocumentTooltip(document);
} else if (segment.Reference is ValueTuple<PEFile, System.Reflection.Metadata.EntityHandle> unresolvedEntity) {
var typeSystem = new DecompilerTypeSystem(unresolvedEntity.Item1, unresolvedEntity.Item1.GetAssemblyResolver(), TypeSystemOptions.Default | TypeSystemOptions.Uncached);
try {
IEntity resolved = typeSystem.MainModule.ResolveEntity(unresolvedEntity.Item2);
if (resolved == null)
return null;
return new FlowDocumentTooltip(CreateTooltipForEntity(resolved));
var document = CreateTooltipForEntity(resolved);
if (document == null)
return null;
return new FlowDocumentTooltip(document);
} catch (BadImageFormatException) {
return null;
}

Loading…
Cancel
Save