diff options
author | David Karlaš <david.karlas@gmail.com> | 2014-05-05 23:47:54 +0400 |
---|---|---|
committer | David Karlaš <david.karlas@gmail.com> | 2014-05-05 23:47:54 +0400 |
commit | ae7b137435893f1b06a57f674d297ded121d8945 (patch) | |
tree | 16ca7bf983847676509de334d1a5d304d894d7e5 /main/src/addins/MonoDevelop.Debugger.Win32 | |
parent | 0c8a231c2b26f98d879f51f7955275f7d3e0de7c (diff) |
[UnitTest] Adding more generic types resolving
[UnitTest] Adding mocking of TypeResolver
[Win32] Resolving nested classes
[Win32] Fixed caching bug for generic types
TextEditorResolverProvider can now resolve also generic types
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger.Win32')
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorObjectAdaptor.cs | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorObjectAdaptor.cs b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorObjectAdaptor.cs index b222bb2e79..7f09ee686e 100644 --- a/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorObjectAdaptor.cs +++ b/main/src/addins/MonoDevelop.Debugger.Win32/MonoDevelop.Debugger.Win32/CorObjectAdaptor.cs @@ -184,24 +184,44 @@ namespace MonoDevelop.Debugger.Win32 }
}
- Dictionary<string, CorType> typeCache = new Dictionary<string, CorType> ();
+ Dictionary<string, CorType> nameToTypeCache = new Dictionary<string, CorType> ();
+ Dictionary<CorType, string> typeToNameCache = new Dictionary<CorType, string> ();
+
+ string GetCacheName(string name, CorType[] typeArgs)
+ {
+ if (typeArgs == null || typeArgs.Length == 0)
+ return name;
+ string result = name + "<";
+ for (int i = 0; i < typeArgs.Length; i++) {
+ string currentTypeName;
+ if (!typeToNameCache.TryGetValue (typeArgs [i], out currentTypeName))
+ return null;//Unable to resolve? Don't cache. This should never happen.
+ result += currentTypeName;
+ if (i < typeArgs.Length - 1)
+ result += ",";
+ }
+ return result + ">";
+ }
+
public override object GetType (EvaluationContext gctx, string name, object[] gtypeArgs)
{
+ CorType[] typeArgs = CastArray<CorType> (gtypeArgs);
+ string cacheName = GetCacheName (name, typeArgs);
CorType fastRet;
- if (typeCache.TryGetValue (name, out fastRet))
+ if (!string.IsNullOrEmpty (cacheName) && nameToTypeCache.TryGetValue (cacheName, out fastRet))
return fastRet;
-
- CorType[] typeArgs = CastArray<CorType> (gtypeArgs);
-
- CorEvaluationContext ctx = (CorEvaluationContext) gctx;
+ CorEvaluationContext ctx = (CorEvaluationContext)gctx;
foreach (CorModule mod in ctx.Session.GetModules ()) {
CorMetadataImport mi = ctx.Session.GetMetadataForModule (mod.Name);
if (mi != null) {
foreach (Type t in mi.DefinedTypes) {
- if (t.FullName == name) {
+ if (t.FullName.Replace ('+', '.') == name.Replace ('+', '.')) {
CorClass cls = mod.GetClassFromToken (t.MetadataToken);
fastRet = cls.GetParameterizedType (CorElementType.ELEMENT_TYPE_CLASS, typeArgs);
- typeCache [name] = fastRet;
+ if (!string.IsNullOrEmpty (cacheName)) {
+ nameToTypeCache [cacheName] = fastRet;
+ typeToNameCache [fastRet] = cacheName;
+ }
return fastRet;
}
}
|