diff --git a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs index 4f08d5726..f0768e59b 100644 --- a/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs @@ -489,8 +489,12 @@ namespace ICSharpCode.Decompiler.CSharp }; syntaxTree = new SyntaxTree(); - foreach (var type in types) + foreach (var type in types) { + if (type.IsNil) + throw new ArgumentException("types contains null element"); RequiredNamespaceCollector.CollectNamespaces(type, typeSystem, decompileRun.Namespaces); + } + DoDecompileTypes(types, decompileRun, decompilationContext, syntaxTree); RunTransforms(syntaxTree, decompileRun, decompilationContext); return syntaxTree; @@ -708,7 +712,7 @@ namespace ICSharpCode.Decompiler.CSharp addNewModifier = members.Any(m => SignatureComparer.Ordinal.Equals(m, (IMember)entity)); break; default: - throw new NotSupportedException(); + throw new ArgumentOutOfRangeException(); } } diff --git a/ICSharpCode.Decompiler/Metadata/Dom.cs b/ICSharpCode.Decompiler/Metadata/Dom.cs index ccca23987..3186b5f50 100644 --- a/ICSharpCode.Decompiler/Metadata/Dom.cs +++ b/ICSharpCode.Decompiler/Metadata/Dom.cs @@ -87,7 +87,8 @@ namespace ICSharpCode.Decompiler.Metadata var headers = Module.Reader.PEHeaders; var resources = headers.CorHeader.ResourcesDirectory; int index = headers.GetContainingSectionIndex(resources.RelativeVirtualAddress); - if (index < 0) throw new NotSupportedException(); + if (index < 0) + throw new BadImageFormatException("RVA could not be found in any section!"); var sectionHeader = headers.SectionHeaders[index]; var sectionData = Module.Reader.GetEntireImage(); int totalOffset = resources.RelativeVirtualAddress + sectionHeader.PointerToRawData - sectionHeader.VirtualAddress;