Browse Source

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.
newNRvisualizers
Mike Krüger 13 years ago
parent
commit
b277e750b4
  1. 22
      ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs

22
ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs

@ -73,25 +73,35 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public string Name { get { return name; } } public string Name { get { return name; } }
public int TypeParameterCount { get { return typeParameterCount; } } public int TypeParameterCount { get { return typeParameterCount; } }
public IType Resolve(ITypeResolveContext context) IType ResolveInContext(ITypeResolveContext context)
{ {
if (context == null)
throw new ArgumentNullException("context");
IType type = null; IType type = null;
if (assembly == null) {
var compilation = context.Compilation; var compilation = context.Compilation;
foreach (var asm in new[] { context.CurrentAssembly }.Concat(compilation.Assemblies)) { foreach (var asm in new[] {
context.CurrentAssembly
}.Concat (compilation.Assemblies)) {
if (asm != null) { if (asm != null) {
type = asm.GetTypeDefinition(nameSpace, name, typeParameterCount); type = asm.GetTypeDefinition(nameSpace, name, typeParameterCount);
if (type != null) if (type != null)
return type; return type;
} }
} }
return type;
}
public IType Resolve(ITypeResolveContext context)
{
if (context == null)
throw new ArgumentNullException("context");
IType type = null;
if (assembly == null) {
type = ResolveInContext(context);
} else { } else {
IAssembly asm = assembly.Resolve(context); IAssembly asm = assembly.Resolve(context);
if (asm != null) { if (asm != null) {
type = asm.GetTypeDefinition(nameSpace, name, typeParameterCount); type = asm.GetTypeDefinition(nameSpace, name, typeParameterCount);
} else {
type = ResolveInContext(context);
} }
} }
return type ?? new UnknownType(nameSpace, name, typeParameterCount); return type ?? new UnknownType(nameSpace, name, typeParameterCount);

Loading…
Cancel
Save