I am new to Unity so sorry in advance if this is a very trivial/known issue.
I have few non-monobehavior utility classes. From one of the monobehaviour I call a static method from the non mono utility class. What I have noticed is that the IList collection items are null. The count of the collections are as expected but on inspecting the items get a message,
Unknown type ‘System.Collections.Generic.collectionDebuggerView`1, mscorlib.dll’
I have tries to simplify the code a bit…here it goes
public class MyBehaviour : MonoBehaviour
{
void Solver()
{
List<List<string>> solution = BasicSolver.GetSolution(str);
//Use the solution list further...never reaches here
}
//...
}
public class BasicSolver
{
CustomClass _obj
//Members and other methods
//Constructors
public BasicSolver(string str) : this()
{
//additional initializations
}
public BasicSolver() : this(CustomClass.GetIntialObject()) { }
public BasicSolver(CustomClass obj)
{
//Initialize all the members.
_obj = obj;
}
//method
public static List<List<string>> GetSolution(string str)
{
BasicSolver solver = new BasicSolver(str);
return solver.GetSolution();
}
public List<List<string>> GetSolution()
{
//Fills a new list using _obj.Items
//Inscecting _obj.Iteams[0] will return null.
//But the _obj.Count is a valid expected value.
return List<List<string>>
}
public class CustomClass
{
private List<anotherCustomClass> _list;
}
}
You can patch Unity Monodevelop source to fix this bug and rebuild some dlls.
I did that and uploaded dlls, you can just download and replace:
There are Dlls for Monodevelop version 2.8.2 and 4.0.1
These dlls work for me, if you get problems, you can download Unity Monodevelop source and build them manually (I will point what needs to be added below).
In this dlls there are two fixes:
First for not showing enum, and second for not showing generic collections saying
“unknown type 'System.Collections.Generic.CollectionDebuggerView’1 mscorlib”.
Fix for inspecting collections is just ignoring custom Debugger Proxy class and using plain inspector, so you will see all inner members of List and Dictionary.
Fix for Enum:
in SoftDebuggerAdaptor.cs TryCast function you can “eat” AppDomainUnloadedException and continue
if (valueType is TypeMirror) {
fromType = (TypeMirror) valueType;
try {
if (toType != null && toType.IsAssignableFrom (fromType))
return obj;
}
catch (AppDomainUnloadedException excep) {
}
// Try casting the primitive type of the enum
EnumMirror em = obj as EnumMirror;
Fix for generic collections:
In ObjectValueAdaptor.cs GetProxyObject function instead of throwing if Proxy Object could not be loaded, return plain object it ignores proxy attribute for List, Dictionary, etc:
try
{
if (ttype == null)
return obj;
object val = CreateValue (ctx, ttype, obj);
return val ?? obj;
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
return obj;
}
Temporarily store it as an array and use that array to analyse your values stored.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Example : MonoBehaviour {
List<GameObject> list = new List<GameObject>();
void Start ()
{
GameObject[] tempArray = list.ToArray();
Debug.Log(tempArray);
Debug.Break();
}
}