ObjectExporter
ObjectExporter copied to clipboard
Visual Studio 2015 - List Traversal broken
Object Exporter in VS2015 seems to be broken when it hits generic lists. It will not traverse down them. I tested the same code in 2013 and it worked perfectly. Here's my test case
namespace TestObjectExporter
{
internal class Program
{
private static void Main(string[] args)
{
var test = new Data1
{
Name = "Data1",
DataTwos = new List<Data2>
{
new Data2
{
Name = "Data2",
DataThrees = new List<Data3>
{
new Data3
{
Name = "Data3"
},
new Data3
{
Name = "Data3"
},
new Data3
{
Name = "Data3"
}
}
},
new Data2
{
Name = "Data2",
DataThrees = new List<Data3>
{
new Data3
{
Name = "Data3"
},
new Data3
{
Name = "Data3"
},
new Data3
{
Name = "Data3"
}
}
},
new Data2
{
Name = "Data2",
DataThrees = new List<Data3>
{
new Data3
{
Name = "Data3"
},
new Data3
{
Name = "Data3"
},
new Data3
{
Name = "Data3"
}
}
}
}
};
var count = test.DataTwos.Count;
//breakpoint here
}
}
public class Data1
{
public string Name { get; set; }
public List<Data2> DataTwos { get; set; }
}
public class Data2
{
public string Name { get; set; }
public List<Data3> DataThrees { get; set; }
}
public class Data3
{
public string Name { get; set; }
}
}
When I do an export with Max Object Depth = 7 Exclude private properties and fields = Checked
var test = new TestObjectExporter.Data1
{
DataTwos = new System.Collections.Generic.List<TestObjectExporter.Data2>
{
Capacity = 4,
Count = 3,
System.Collections.Generic.ICollection<TestObjectExporter.Data2>.IsReadOnly = false,
System.Collections.ICollection.IsSynchronized = false,
System.Collections.ICollection.SyncRoot = {object},
System.Collections.IList.IsFixedSize = false,
System.Collections.IList.IsReadOnly = false,
_items = new TestObjectExporter.Data2[]
{
},
_size = 3,
_syncRoot = {object},
_version = 3
},
Name = "Data1"
};
Thanks for reporting the issue Jeff. So the issue only appears in 2015? And for VS2013 it appears to work correctly?
I'll look into the issue asap.
Yes, it works in 2013 but not in 2015. I'm up to date with all the extensions and updates.I have tested with Resharper disabled and also does not function properly.
Alright, just wanted to confirm. I'll look into this issue and update any information on this post. Once again thank you for the bug report and thanks for providing a good test case.
@jeffklawiter it seems like there may be something else at work here. Did you attempt running one in Debug mode vs Release mode or any other configurations?
I ran your testcase on vs2015 and received the following:
var test = new WebApplication2.Data1
{
DataTwos = new System.Collections.Generic.List<WebApplication2.Data2>
{
new WebApplication2.Data2
{
DataThrees = new System.Collections.Generic.List<WebApplication2.Data3>
{
new WebApplication2.Data3
{
Name = "Data3"
},
new WebApplication2.Data3
{
Name = "Data3"
},
new WebApplication2.Data3
{
Name = "Data3"
}
},
Name = "Data2"
},
new WebApplication2.Data2
{
DataThrees = new System.Collections.Generic.List<WebApplication2.Data3>
{
new WebApplication2.Data3
{
Name = "Data3"
},
new WebApplication2.Data3
{
Name = "Data3"
},
new WebApplication2.Data3
{
Name = "Data3"
}
},
Name = "Data2"
},
new WebApplication2.Data2
{
DataThrees = new System.Collections.Generic.List<WebApplication2.Data3>
{
new WebApplication2.Data3
{
Name = "Data3"
},
new WebApplication2.Data3
{
Name = "Data3"
},
new WebApplication2.Data3
{
Name = "Data3"
}
},
Name = "Data2"
}
},
Name = "Data1"
};
Are there any news on this issue, because I think it's related to mine. I'm using VS2015 Professional. I get a whole bunch of illegal constructs and missing data when trying to export an object.
{
ActionId = 1,
new BatchDetailsDto
{
Aql = 0,
...
should be
{
ActionId = 1,
Batch = new BatchDetailsDto
{
Aql = 0,
...
An empty array is serialized as
CallOfOrders = {CallOffOrderDto[0]},
which is exactly the same way it is represented in the built-in debug object browser...
If the array contains data it is instead serialized as [ ], e.g. all subdata is missing.
I just installed this tool to generate unit testing mock data, and it has got the potential to be a fantastic tool for this!
I'm still having the issue on multiple machines, but have been unable to determine the cause. It's happening on one installation with no extra extensions installed.
@bolddp sorry for the delay in responding to this, i don't believe your problem is related to the current issue. But i'm aware of the problem and it will be resolved soon. The codebase has been through a major refactor so i wasn't able to add new features/fix bugs for a while. I appreciate you reporting the problem, a new release should be out in two weeks which should hopefully address both issues. And thanks for your comment.