when run code in linqpad using json.net:
var x = jobject.parse( @"{ ""data"" : [ { ""id"" : ""bbab529ecefe58569c2b301a"", ""name"" : ""sample name"", ""group"" : ""8b618be8dc064e653daf62f9"", ""description"" : ""sample name"", ""payloadtype"" : ""geolocation"", ""contract"" : ""a9da09a7f4a7e7becf961865"", ""keepalive"" : 0 } ] }"); x.dump();
an ambiguousmatchexception
thrown when trying dump parsed json linqpad's output window. why? far can tell legitimate json. http://jsonlint.com/ says it's valid, too.
this problem how .dump()
implemented likely.
if check stack trace:
at system.runtimetype.getinterface(string fullname, boolean ignorecase) @ system.type.getinterface(string name) @ userquery.main() ...
we can see method throwing exception system.runtimetype.getinterface
.
system.runtimetype
1 of concrete classes used represent type
objects when reflection used @ runtime, let's check type.getinterface(string, boolean)
has say:
ambiguousmatchexception
current type represents type implements same generic interface different type arguments.
so looks getinterface
method called type of interface implemented more once, different t
's or similar.
to provoke same error, replace x.dump();
this:
var type = x.gettype().getinterface("system.collections.generic.ienumerable`1", true);
this throw same exception.
here's simpler linqpad example shows underlying problem:
void main() { var type = typeof(problem).getinterface("system.collections.generic.ienumerable`1", true); } public class problem : ienumerable<string>, ienumerable<int> { ienumerator ienumerable.getenumerator() => ((ienumerable<string>)this).getenumerator(); ienumerator<string> ienumerable<string>.getenumerator() => enumerable.empty<string>().getenumerator(); ienumerator<int> ienumerable<int>.getenumerator() => enumerable.empty<int>().getenumerator(); }
this example throw exact same exception.
conclusion: there nothing wrong json, nor json.net, problem how linqpad tries figure out best way dump object output window.
Comments
Post a Comment