Browse Source

When decompiling a single method, don't fully-qualify type names in the current namespace.

pull/924/head
Daniel Grunwald 8 years ago
parent
commit
7cacd005a6
  1. 9
      ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs

9
ICSharpCode.Decompiler/CSharp/Transforms/IntroduceUsingDeclarations.cs

@ -78,7 +78,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -78,7 +78,7 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
public FindRequiredImports(TransformContext context)
{
this.currentNamespace = context.DecompiledTypeDefinition != null ? context.DecompiledTypeDefinition.Namespace : string.Empty;
this.currentNamespace = context.DecompiledTypeDefinition?.Namespace ?? string.Empty;
}
bool IsParentOfCurrentNamespace(string ns)
@ -123,7 +123,12 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -123,7 +123,12 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
public FullyQualifyAmbiguousTypeNamesVisitor(TransformContext context, UsingScope usingScope)
{
this.context = new Stack<CSharpTypeResolveContext>();
var currentContext = new CSharpTypeResolveContext(context.TypeSystem.MainAssembly, usingScope.Resolve(context.TypeSystem.Compilation));
if (!string.IsNullOrEmpty(context.DecompiledTypeDefinition?.Namespace)) {
foreach (string ns in context.DecompiledTypeDefinition.Namespace.Split('.')) {
usingScope = new UsingScope(usingScope, ns);
}
}
var currentContext = new CSharpTypeResolveContext(context.TypeSystem.MainAssembly, usingScope.Resolve(context.TypeSystem.Compilation), context.DecompiledTypeDefinition);
this.context.Push(currentContext);
this.astBuilder = CreateAstBuilder(currentContext);
}

Loading…
Cancel
Save