[System.ServiceModel.Web] Fix issue with types explicitly implementing IDictionary...
commit13ff02dc31eede8085adbd1af0eaca49dcf1dbb0
authorSebastien Pouliot <sebastien@xamarin.com>
Mon, 26 May 2014 21:27:26 +0000 (26 17:27 -0400)
committerSebastien Pouliot <sebastien@xamarin.com>
Mon, 26 May 2014 21:27:26 +0000 (26 17:27 -0400)
tree5355cb733315b88253b88c3e418a431b170e440d
parent122a67e4c88064d4a67434e59fd9191260bfcd91
[System.ServiceModel.Web] Fix issue with types explicitly implementing IDictionary or IDictionary<,>

Issue: The previous code, with new tests [1], failed when the linker was
enabled.

That was caused because the code looks for the Keys and Item properties
getter using reflection. The linker handled that imperfectly (it left
some holes), in part because:

* System.Collections.Generic.IDictionary`2 does not implement
  System.Collections.IDictionary; and

* It preserved the explicit methods - not the implicit one that were
  used the the reflection-based code;

That later fact is also a bug (without the linker involvment) and solved
by this commit. A unit test was added to show the issue (NRE).

The patch also avoid the use of reflection for IDictionary since we can
simply typecast to get the same result (without the additional cost).
mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/JsonSerializationWriter.cs
mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/DataContractJsonSerializerTest.cs