/// <summary> /// Returns the C# <see cref="Type"/> that represents this <paramref name="class"/>. /// </summary> /// <param name="class"></param> /// <returns></returns> public static Type EquivalentType(this java.lang.Class @class) { if (EquivalentCache.ContainsKey(@class)) { return(EquivalentCache[@class]); } //Type.GetType() string className = @class.getCanonicalName(); // Different from C#: inner classes still use a dot. // In java's raw form, a $ is used. // In C#, a + is used. // Now this is fine and all, issue is I have to do two searches. Type t = Type.GetType(className); if (t == null) { // Okay, null. Try this. if (className.Contains(".")) { int lastPeriodIndex = className.LastIndexOf('.'); string innerName = className.Substring(lastPeriodIndex + 1); className = className.Substring(0, lastPeriodIndex); t = Type.GetType(className + "+" + innerName); } } EquivalentCache[@class] = t; return(t); }