From b277e750b46e8a83c6651093cbe6d0b188681bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Sat, 14 Apr 2012 07:44:55 +0200 Subject: [PATCH] Fixed GetClassTypeReference resolving error. Use case: Lib uses System.Core 3.5, Project 4.0 - the 3.5 assembly can't be resolved in the project context. --- .../Implementation/GetClassTypeReference.cs | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs index b5b6da763b..081ac88219 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs @@ -73,25 +73,35 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public string Name { get { return name; } } public int TypeParameterCount { get { return typeParameterCount; } } + IType ResolveInContext(ITypeResolveContext context) + { + IType type = null; + var compilation = context.Compilation; + foreach (var asm in new[] { + context.CurrentAssembly + }.Concat (compilation.Assemblies)) { + if (asm != null) { + type = asm.GetTypeDefinition(nameSpace, name, typeParameterCount); + if (type != null) + return type; + } + } + return type; + } + public IType Resolve(ITypeResolveContext context) { if (context == null) throw new ArgumentNullException("context"); - IType type = null; if (assembly == null) { - var compilation = context.Compilation; - foreach (var asm in new[] { context.CurrentAssembly }.Concat(compilation.Assemblies)) { - if (asm != null) { - type = asm.GetTypeDefinition(nameSpace, name, typeParameterCount); - if (type != null) - return type; - } - } + type = ResolveInContext(context); } else { IAssembly asm = assembly.Resolve(context); if (asm != null) { type = asm.GetTypeDefinition(nameSpace, name, typeParameterCount); + } else { + type = ResolveInContext(context); } } return type ?? new UnknownType(nameSpace, name, typeParameterCount);