Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/NRefactory.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@xamarin.com>2014-08-09 10:18:14 +0400
committerMike Krüger <mkrueger@xamarin.com>2014-08-09 10:18:14 +0400
commitbdf8ef97ae5231333073684555c83b49ae7d562a (patch)
treea50d5cc481e7dbe8e6605073b532988f33d5822f /ICSharpCode.NRefactory
parent5118b41d3606a95a7e623dd06981a33b0d550c9d (diff)
Try to prevent infinite loop in resolving type references.
Diffstat (limited to 'ICSharpCode.NRefactory')
-rw-r--r--ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs38
1 files changed, 27 insertions, 11 deletions
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs
index d1de23d6..ee4fec92 100644
--- a/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs
+++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs
@@ -87,7 +87,28 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public string Name { get { return fullTypeName.Name; } }
[Obsolete("Use the FullTypeName property instead. GetClassTypeReference now supports nested types, where the Namespace/Name/TPC tripel isn't sufficient for identifying the type.")]
public int TypeParameterCount { get { return fullTypeName.TypeParameterCount; } }
-
+
+ [NonSerialized]
+ bool alreadyTriedToLookupInDifferentAssembly;
+
+ IType ResolveUsingTypeContext (ITypeResolveContext context)
+ {
+ IType type = null;
+
+ if (context.CurrentAssembly != null) {
+ type = context.CurrentAssembly.GetTypeDefinition (fullTypeName);
+ }
+ if (type == null) {
+ var compilation = context.Compilation;
+ foreach (var asm in compilation.Assemblies) {
+ type = asm.GetTypeDefinition (fullTypeName);
+ if (type != null)
+ break;
+ }
+ }
+ return type;
+ }
+
public IType Resolve(ITypeResolveContext context)
{
if (context == null)
@@ -95,23 +116,18 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
IType type = null;
if (assembly == null) {
- if (context.CurrentAssembly != null) {
- type = context.CurrentAssembly.GetTypeDefinition(fullTypeName);
- }
+ type = ResolveUsingTypeContext (context);
} else {
IAssembly asm = assembly.Resolve(context);
if (asm != null) {
type = asm.GetTypeDefinition(fullTypeName);
}
- }
- if (type == null) {
- var compilation = context.Compilation;
- foreach (var asm in compilation.Assemblies) {
- type = asm.GetTypeDefinition(fullTypeName);
- if (type != null)
- break;
+ if (!alreadyTriedToLookupInDifferentAssembly) {
+ alreadyTriedToLookupInDifferentAssembly = true;
+ type = ResolveUsingTypeContext (context);
}
}
+
return type ?? new UnknownType(fullTypeName);
}