Permalink
Browse files

Use IClrTypeName instead of sting in ReSharper runners

  • Loading branch information...
1 parent 35c55ef commit 269b8d253775e97ea6c437aa01de48548a24f4f6 @kropp kropp committed with agross Jan 24, 2013
@@ -4,6 +4,7 @@
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Caches;
+using JetBrains.ReSharper.Psi.Impl.Reflection2;
using JetBrains.ReSharper.UnitTestFramework;
#if RESHARPER_61
using JetBrains.ReSharper.UnitTestFramework.Elements;
@@ -20,6 +21,7 @@ internal class BehaviorFactory
readonly ElementCache _cache;
readonly IProject _project;
#if RESHARPER_61
+ readonly ReflectionTypeNameCache _reflectionTypeNameCache = new ReflectionTypeNameCache();
readonly IUnitTestElementManager _manager;
readonly PsiModuleManager _psiModuleManager;
readonly CacheManager _cacheManager;
@@ -65,7 +67,7 @@ public BehaviorElement CreateBehavior(IDeclaredElement field)
_project,
_projectEnvoy,
context,
- clazz.GetClrName().FullName,
+ clazz.GetClrName(),
field.ShortName,
field.IsIgnored(),
fullyQualifiedTypeName);
@@ -93,7 +95,12 @@ public BehaviorElement CreateBehavior(ContextElement context, IMetadataField beh
_project,
_projectEnvoy,
context,
- behavior.DeclaringType.FullyQualifiedName,
+#if RESHARPER_61
+ _reflectionTypeNameCache.GetClrName(behavior.DeclaringType),
+#else
+ new ClrTypeName(behavior.DeclaringType.FullyQualifiedName), // may work incorrect in ReSharper 6.0
+#endif
+
behavior.Name,
behavior.IsIgnored() || typeContainingBehaviorSpecifications.IsIgnored(),
fullyQualifiedTypeName);
@@ -110,7 +117,7 @@ public BehaviorElement CreateBehavior(ContextElement context, IMetadataField beh
IProject project,
ProjectModelElementEnvoy projectEnvoy,
ContextElement context,
- string declaringTypeName,
+ IClrTypeName declaringTypeName,
string fieldName,
bool isIgnored,
string fullyQualifiedTypeName)
@@ -158,4 +165,4 @@ public void UpdateChildState(IDeclaredElement field)
}
}
}
-}
+}
@@ -4,6 +4,7 @@
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Caches;
+using JetBrains.ReSharper.Psi.Impl.Reflection2;
using JetBrains.ReSharper.UnitTestFramework;
#if RESHARPER_61
using JetBrains.ReSharper.UnitTestFramework.Elements;
@@ -19,6 +20,7 @@ internal class BehaviorSpecificationFactory
readonly MSpecUnitTestProvider _provider;
readonly IProject _project;
#if RESHARPER_61
+ readonly ReflectionTypeNameCache _reflectionTypeNameCache = new ReflectionTypeNameCache();
readonly IUnitTestElementManager _manager;
readonly PsiModuleManager _psiModuleManager;
readonly CacheManager _cacheManager;
@@ -61,8 +63,8 @@ public BehaviorSpecificationFactory(MSpecUnitTestProvider provider, IProject pro
_project,
behavior,
_projectEnvoy,
- behavior.FullyQualifiedTypeName ?? ((ITypeMember)behaviorSpecification).GetContainingType().GetClrName().FullName,
- behaviorSpecification.ShortName,
+ ((ITypeMember)behaviorSpecification).GetContainingType().GetClrName().GetPersistent(),
+ behaviorSpecification.ShortName,
behaviorSpecification.IsIgnored());
}
@@ -76,7 +78,11 @@ public BehaviorSpecificationFactory(MSpecUnitTestProvider provider, IProject pro
_project,
behavior,
_projectEnvoy,
- behavior.FullyQualifiedTypeName ?? behaviorSpecification.DeclaringType.FullyQualifiedName,
+#if RESHARPER_61
+ _reflectionTypeNameCache.GetClrName(behaviorSpecification.DeclaringType),
+#else
+ new ClrTypeName(behaviorSpecification.DeclaringType.FullyQualifiedName), // may work incorrect in ReSharper 6.0
+#endif
behaviorSpecification.Name,
behaviorSpecification.IsIgnored());
}
@@ -90,7 +96,7 @@ public BehaviorSpecificationFactory(MSpecUnitTestProvider provider, IProject pro
IProject project,
BehaviorElement behavior,
ProjectModelElementEnvoy projectEnvoy,
- string declaringTypeName,
+ IClrTypeName declaringTypeName,
string fieldName,
bool isIgnored)
{
@@ -6,6 +6,7 @@
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Caches;
+using JetBrains.ReSharper.Psi.Impl.Reflection2;
using JetBrains.ReSharper.UnitTestFramework;
#if RESHARPER_61
using JetBrains.ReSharper.UnitTestFramework.Elements;
@@ -24,6 +25,7 @@ internal class ContextFactory
readonly ElementCache _cache;
readonly IProject _project;
#if RESHARPER_61
+ readonly ReflectionTypeNameCache _reflectionTypeNameCache = new ReflectionTypeNameCache();
readonly IUnitTestElementManager _manager;
readonly PsiModuleManager _psiModuleManager;
readonly CacheManager _cacheManager;
@@ -56,7 +58,7 @@ public ContextElement CreateContext(ITypeElement type)
#endif
_project,
_projectEnvoy,
- type.GetClrName().FullName,
+ type.GetClrName().GetPersistent(),
_assemblyPath,
type.GetSubjectString(),
type.GetTags(),
@@ -81,7 +83,11 @@ public ContextElement CreateContext(IMetadataTypeInfo type)
#endif
_project,
_projectEnvoy,
- type.FullyQualifiedName,
+#if RESHARPER_61
+ _reflectionTypeNameCache.GetClrName(type),
+#else
+ new ClrTypeName(type.FullyQualifiedName), // may work incorrect in ReSharper 6.0
+#endif
_assemblyPath,
type.GetSubjectString(),
type.GetTags(),
@@ -96,13 +102,13 @@ public ContextElement CreateContext(IMetadataTypeInfo type)
#endif
IProject project,
ProjectModelElementEnvoy projectEnvoy,
- string typeName,
+ IClrTypeName typeName,
string assemblyLocation,
string subject,
ICollection<string> tags,
bool isIgnored)
{
- var id = ContextElement.CreateId(subject, typeName, tags);
+ var id = ContextElement.CreateId(subject, typeName.FullName, tags);
#if RESHARPER_61
var contextElement = manager.GetElementById(project, id) as ContextElement;
#else
@@ -4,6 +4,7 @@
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Caches;
+using JetBrains.ReSharper.Psi.Impl.Reflection2;
using JetBrains.ReSharper.UnitTestFramework;
#if RESHARPER_61
using JetBrains.ReSharper.UnitTestFramework.Elements;
@@ -20,6 +21,7 @@ internal class ContextSpecificationFactory
readonly ElementCache _cache;
readonly IProject _project;
#if RESHARPER_61
+ readonly ReflectionTypeNameCache _reflectionTypeNameCache = new ReflectionTypeNameCache();
readonly IUnitTestElementManager _manager;
readonly PsiModuleManager _psiModuleManager;
readonly CacheManager _cacheManager;
@@ -63,7 +65,7 @@ public ContextSpecificationElement CreateContextSpecification(IDeclaredElement f
_project,
context,
_projectEnvoy,
- clazz.GetClrName().FullName,
+ clazz.GetClrName().GetPersistent(),
field.ShortName,
clazz.GetTags(),
field.IsIgnored());
@@ -78,7 +80,11 @@ public ContextSpecificationElement CreateContextSpecification(ContextElement con
_project,
context,
_projectEnvoy,
- specification.DeclaringType.FullyQualifiedName,
+#if RESHARPER_61
+ _reflectionTypeNameCache.GetClrName(specification.DeclaringType),
+#else
+ new ClrTypeName(specification.DeclaringType.FullyQualifiedName), // may work incorrect in ReSharper 6.0
+#endif
specification.Name,
specification.DeclaringType.GetTags(),
specification.IsIgnored());
@@ -93,7 +99,7 @@ public ContextSpecificationElement CreateContextSpecification(ContextElement con
IProject project,
ContextElement context,
ProjectModelElementEnvoy projectEnvoy,
- string declaringTypeName,
+ IClrTypeName declaringTypeName,
string fieldName,
ICollection<string> tags,
bool isIgnored)
@@ -125,4 +131,4 @@ public ContextSpecificationElement CreateContextSpecification(ContextElement con
isIgnored);
}
}
-}
+}
@@ -27,7 +27,7 @@ public UnitTestTask CreateContextTask(ContextElement context, bool isExplicit)
return new UnitTestTask(context,
new ContextTask(_providerId,
context.AssemblyLocation,
- context.GetTypeClrName(),
+ context.GetTypeClrName().FullName,
false));
}
@@ -38,7 +38,7 @@ public UnitTestTask CreateContextTask(ContextElement context, bool isExplicit)
return new UnitTestTask(contextSpecification,
new ContextSpecificationTask(_providerId,
context.AssemblyLocation,
- context.GetTypeClrName(),
+ context.GetTypeClrName().FullName,
contextSpecification.FieldName,
false));
}
@@ -48,7 +48,7 @@ public UnitTestTask CreateBehaviorTask(ContextElement context, BehaviorElement b
return new UnitTestTask(behavior,
new BehaviorTask(_providerId,
context.AssemblyLocation,
- context.GetTypeClrName(),
+ context.GetTypeClrName().FullName,
behavior.FullyQualifiedTypeName,
behavior.FieldName,
false));
@@ -61,10 +61,10 @@ public UnitTestTask CreateBehaviorTask(ContextElement context, BehaviorElement b
return new UnitTestTask(behaviorSpecification,
new BehaviorSpecificationTask(_providerId,
context.AssemblyLocation,
- context.GetTypeClrName(),
+ context.GetTypeClrName().FullName,
behaviorSpecification.Behavior.FieldName,
behaviorSpecification.FieldName,
- behaviorSpecification.GetTypeClrName(),
+ behaviorSpecification.GetTypeClrName().FullName,
false));
}
}
@@ -23,7 +23,7 @@ public class BehaviorElement : FieldElement
ContextElement context,
// ReSharper restore SuggestBaseTypeForParameter
ProjectModelElementEnvoy projectEnvoy,
- string declaringTypeName,
+ IClrTypeName declaringTypeName,
string fieldName,
bool isIgnored,
string fullyQualifiedTypeName)
@@ -92,7 +92,7 @@ public override void WriteToXml(XmlElement parent)
project,
ProjectModelElementEnvoy.Create(project),
context,
- typeName,
+ new ClrTypeName(typeName),
methodName,
isIgnored,
fullyQualifiedTypeName);
@@ -25,7 +25,7 @@ public class BehaviorSpecificationElement : FieldElement
BehaviorElement behavior,
// ReSharper restore SuggestBaseTypeForParameter
ProjectModelElementEnvoy projectEnvoy,
- string declaringTypeName,
+ IClrTypeName declaringTypeName,
string fieldName,
bool isIgnored)
: base(provider, psiModuleManager, cacheManager, behavior, projectEnvoy, declaringTypeName, fieldName, isIgnored || behavior.Explicit)
@@ -75,7 +75,7 @@ public override IEnumerable<UnitTestElementCategory> Categories
#if RESHARPER_61
manager, psiModuleManager, cacheManager,
#endif
- project, behavior, ProjectModelElementEnvoy.Create(project), typeName, methodName, isIgnored);
+ project, behavior, ProjectModelElementEnvoy.Create(project), new ClrTypeName(typeName), methodName, isIgnored);
}
public override string Id
@@ -28,14 +28,14 @@ public class ContextElement : Element, ISerializableElement
PsiModuleManager psiModuleManager,
CacheManager cacheManager,
ProjectModelElementEnvoy projectEnvoy,
- string typeName,
+ IClrTypeName typeName,
string assemblyLocation,
string subject,
IEnumerable<string> tags,
bool isIgnored)
: base(provider, psiModuleManager, cacheManager, null, projectEnvoy, typeName, isIgnored)
{
- _id = CreateId(subject, TypeName, tags);
+ _id = CreateId(subject, TypeName.FullName, tags);
_assemblyLocation = assemblyLocation;
_subject = subject;
@@ -57,7 +57,7 @@ public string AssemblyLocation
public override string GetPresentation()
{
- return GetSubject() + new ClrTypeName(GetTypeClrName()).ShortName.ToFormat();
+ return GetSubject() + GetTypeClrName().ShortName.ToFormat();
}
string GetSubject()
@@ -88,7 +88,7 @@ public override IEnumerable<UnitTestElementCategory> Categories
public void WriteToXml(XmlElement parent)
{
parent.SetAttribute("projectId", GetProject().GetPersistentID());
- parent.SetAttribute("typeName", TypeName);
+ parent.SetAttribute("typeName", TypeName.FullName);
parent.SetAttribute("assemblyLocation", AssemblyLocation);
parent.SetAttribute("isIgnored", Explicit.ToString());
parent.SetAttribute("subject", _subject);
@@ -118,7 +118,7 @@ public void WriteToXml(XmlElement parent)
#endif
project,
ProjectModelElementEnvoy.Create(project),
- typeName,
+ new ClrTypeName(typeName),
assemblyLocation,
subject,
EmptyArray<string>.Instance,
Oops, something went wrong.

0 comments on commit 269b8d2

Please sign in to comment.