Permalink
Browse files

Fix #1282: Decompiling types in non-main modules - should throw a Not…

…SupportedException.
  • Loading branch information...
siegfriedpammer committed Oct 11, 2018
1 parent 6da7d80 commit dd5fb5a78badb178a0e893481551f2f8b88cc0c2
Showing with 3 additions and 0 deletions.
  1. +3 −0 ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
@@ -678,12 +678,15 @@ public string DecompileTypesAsString(IEnumerable<TypeDefinitionHandle> types)
/// </summary>
/// <remarks>
/// Unlike Decompile(IMemberDefinition[]), this method will add namespace declarations around the type definition.
/// Note that decompiling types from modules other than the main module is not supported.
/// </remarks>
public SyntaxTree DecompileType(FullTypeName fullTypeName)
{
var type = typeSystem.FindType(fullTypeName.TopLevelTypeName).GetDefinition();
if (type == null)
throw new InvalidOperationException($"Could not find type definition {fullTypeName} in type system.");
if (type.ParentModule != typeSystem.MainModule)
throw new NotSupportedException("Decompiling types that are not part of the main module is not supported.");
var decompilationContext = new SimpleTypeResolveContext(typeSystem.MainModule);
var decompileRun = new DecompileRun(settings) {
DocumentationProvider = DocumentationProvider ?? CreateDefaultDocumentationProvider(),

0 comments on commit dd5fb5a

Please sign in to comment.