Browse Source

Fix issue #1762

pull/1763/head
SilverFox 6 years ago
parent
commit
8c8dcf5630
  1. 1
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. 8
      ICSharpCode.Decompiler/CSharp/RequiredNamespaceCollector.cs
  3. 2
      ILSpy/LoadedAssembly.cs

1
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -783,6 +783,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -783,6 +783,7 @@ namespace ICSharpCode.Decompiler.CSharp
syntaxTree = new SyntaxTree();
foreach (var type in types) {
CancellationToken.ThrowIfCancellationRequested();
if (type.IsNil)
throw new ArgumentException("types contains null element");
RequiredNamespaceCollector.CollectNamespaces(type, module, decompileRun.Namespaces);

8
ICSharpCode.Decompiler/CSharp/RequiredNamespaceCollector.cs

@ -122,13 +122,13 @@ namespace ICSharpCode.Decompiler.CSharp @@ -122,13 +122,13 @@ namespace ICSharpCode.Decompiler.CSharp
break;
case IProperty property:
HandleAttributes(property.GetAttributes());
CollectNamespaces(property.Getter, module);
CollectNamespaces(property.Setter, module);
CollectNamespaces(property.Getter, module, mappingInfo);
CollectNamespaces(property.Setter, module, mappingInfo);
break;
case IEvent @event:
HandleAttributes(@event.GetAttributes());
CollectNamespaces(@event.AddAccessor, module);
CollectNamespaces(@event.RemoveAccessor, module);
CollectNamespaces(@event.AddAccessor, module, mappingInfo);
CollectNamespaces(@event.RemoveAccessor, module, mappingInfo);
break;
}
}

2
ILSpy/LoadedAssembly.cs

@ -156,7 +156,7 @@ namespace ICSharpCode.ILSpy @@ -156,7 +156,7 @@ namespace ICSharpCode.ILSpy
// runs on background thread
if (state is Stream stream) {
// Read the module from a precrafted stream
module = new PEFile(fileName, stream, metadataOptions: options);
module = new PEFile(fileName, stream, stream is MemoryStream ? PEStreamOptions.PrefetchEntireImage : PEStreamOptions.Default, metadataOptions: options);
} else {
// Read the module from disk (by default)
stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);

Loading…
Cancel
Save