-Fixed serializing IListSource implementations
This commit is contained in:
@@ -96,6 +96,42 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
[TestFixture]
|
||||
public class JsonSerializerTest : TestFixtureBase
|
||||
{
|
||||
public class ListSourceTest : IListSource
|
||||
{
|
||||
private string str;
|
||||
|
||||
public string strprop
|
||||
{
|
||||
get { return str; }
|
||||
set { str = value; }
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool ContainsListCollection
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public IList GetList()
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ListSourceSerialize()
|
||||
{
|
||||
ListSourceTest c = new ListSourceTest();
|
||||
c.strprop = "test";
|
||||
string json = JsonConvert.SerializeObject(c);
|
||||
|
||||
Assert.AreEqual(@"{""strprop"":""test""}", json);
|
||||
|
||||
ListSourceTest c2 = JsonConvert.DeserializeObject<ListSourceTest>(json);
|
||||
|
||||
Assert.AreEqual("test", c2.strprop);
|
||||
}
|
||||
|
||||
public struct ImmutableStruct
|
||||
{
|
||||
public ImmutableStruct(string value)
|
||||
|
||||
@@ -79,8 +79,9 @@ namespace Newtonsoft.Json.Serialization
|
||||
{
|
||||
Type converterType = typeConverter.GetType();
|
||||
|
||||
if (converterType.FullName != "System.ComponentModel.ComponentConverter"
|
||||
&& converterType.FullName != "System.ComponentModel.ReferenceConverter"
|
||||
if (!string.Equals(converterType.FullName, "System.ComponentModel.ComponentConverter", StringComparison.Ordinal)
|
||||
&& !string.Equals(converterType.FullName, "System.ComponentModel.ReferenceConverter", StringComparison.Ordinal)
|
||||
&& !string.Equals(converterType.FullName, "System.Windows.Forms.Design.DataSourceConverter", StringComparison.Ordinal)
|
||||
&& converterType != typeof(TypeConverter))
|
||||
{
|
||||
return typeConverter.CanConvertTo(typeof(string));
|
||||
|
||||
Reference in New Issue
Block a user