Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use IClrTypeName instead of sting in ReSharper runners

  • Loading branch information...
commit 269b8d253775e97ea6c437aa01de48548a24f4f6 1 parent 35c55ef
@kropp kropp authored agross committed
View
15 Source/Machine.Specifications.ReSharperRunner.6.0/Factories/BehaviorFactory.cs
@@ -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)
}
}
}
-}
+}
View
14 Source/Machine.Specifications.ReSharperRunner.6.0/Factories/BehaviorSpecificationFactory.cs
@@ -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)
{
View
14 Source/Machine.Specifications.ReSharperRunner.6.0/Factories/ContextFactory.cs
@@ -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
View
14 Source/Machine.Specifications.ReSharperRunner.6.0/Factories/ContextSpecificationFactory.cs
@@ -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);
}
}
-}
+}
View
10 Source/Machine.Specifications.ReSharperRunner.6.0/Factories/UnitTestTaskFactory.cs
@@ -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));
}
}
View
4 Source/Machine.Specifications.ReSharperRunner.6.0/Presentation/BehaviorElement.cs
@@ -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);
View
4 Source/Machine.Specifications.ReSharperRunner.6.0/Presentation/BehaviorSpecificationElement.cs
@@ -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
View
10 Source/Machine.Specifications.ReSharperRunner.6.0/Presentation/ContextElement.cs
@@ -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,
View
6 Source/Machine.Specifications.ReSharperRunner.6.0/Presentation/ContextSpecificationElement.cs
@@ -27,7 +27,7 @@ internal class ContextSpecificationElement : FieldElement
ContextElement context,
// ReSharper restore SuggestBaseTypeForParameter
ProjectModelElementEnvoy project,
- string declaringTypeName,
+ IClrTypeName declaringTypeName,
string fieldName,
IEnumerable<string> tags,
bool isIgnored)
@@ -83,7 +83,7 @@ public override IEnumerable<UnitTestElementCategory> Categories
#if RESHARPER_61
manager, psiModuleManager, cacheManager,
#endif
- project, context, ProjectModelElementEnvoy.Create(project), typeName, methodName, EmptyArray<string>.Instance, isIgnored);
+ project, context, ProjectModelElementEnvoy.Create(project), new ClrTypeName(typeName), methodName, EmptyArray<string>.Instance, isIgnored);
}
public override string Id
@@ -99,4 +99,4 @@ public static string CreateId(ContextElement contextElement, string fieldName)
return String.Format("{0}.{1}", contextElement.Id, fieldName);
}
}
-}
+}
View
10 Source/Machine.Specifications.ReSharperRunner.6.0/Presentation/Element.cs
@@ -16,7 +16,7 @@ namespace Machine.Specifications.ReSharperRunner.Presentation
{
public abstract class Element : IUnitTestElement
{
- readonly string _declaringTypeName;
+ readonly IClrTypeName _declaringTypeName;
readonly ProjectModelElementEnvoy _projectEnvoy;
readonly MSpecUnitTestProvider _provider;
readonly UnitTestTaskFactory _taskFactory;
@@ -29,7 +29,7 @@ public abstract class Element : IUnitTestElement
CacheManager cacheManager,
Element parent,
ProjectModelElementEnvoy projectEnvoy,
- string declaringTypeName,
+ IClrTypeName declaringTypeName,
bool isIgnored)
{
if (projectEnvoy == null && !Shell.Instance.IsTestShell)
@@ -65,7 +65,7 @@ public abstract class Element : IUnitTestElement
_taskFactory = new UnitTestTaskFactory(_provider.ID);
}
- public string TypeName { get; protected set; }
+ public IClrTypeName TypeName { get; protected set; }
public abstract string Kind { get; }
public abstract IEnumerable<UnitTestElementCategory> Categories { get; }
public string ExplicitReason { get; private set; }
@@ -119,7 +119,7 @@ public IProject GetProject()
public UnitTestNamespace GetNamespace()
{
- return new UnitTestNamespace(new ClrTypeName(_declaringTypeName).GetNamespaceName());
+ return new UnitTestNamespace(_declaringTypeName.GetNamespaceName());
}
public UnitTestElementDisposition GetDisposition()
@@ -277,7 +277,7 @@ protected ITypeElement GetDeclaredType()
return declarationsCache.GetTypeElementByCLRName(_declaringTypeName);
}
- public string GetTypeClrName()
+ public IClrTypeName GetTypeClrName()
{
return _declaringTypeName;
}
View
4 Source/Machine.Specifications.ReSharperRunner.6.0/Presentation/FieldElement.cs
@@ -21,7 +21,7 @@ public abstract class FieldElement : Element, ISerializableElement
CacheManager cacheManager,
Element parent,
ProjectModelElementEnvoy projectEnvoy,
- string declaringTypeName,
+ IClrTypeName declaringTypeName,
string fieldName,
bool isIgnored)
: base(provider, psiModuleManager, cacheManager, parent, projectEnvoy, declaringTypeName, isIgnored || parent.Explicit)
@@ -69,7 +69,7 @@ public override IDeclaredElement GetDeclaredElement()
public virtual void WriteToXml(XmlElement parent)
{
parent.SetAttribute("projectId", GetProject().GetPersistentID());
- parent.SetAttribute("typeName", TypeName);
+ parent.SetAttribute("typeName", TypeName.FullName);
parent.SetAttribute("methodName", FieldName);
parent.SetAttribute("isIgnored", Explicit.ToString());
}
Please sign in to comment.
Something went wrong with that request. Please try again.