Skip to content

Commit

Permalink
#47
Browse files Browse the repository at this point in the history
  • Loading branch information
mfidemraizer committed Dec 30, 2016
1 parent 8a8d1b6 commit 8c437c8
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 32 deletions.
4 changes: 2 additions & 2 deletions TrackerDog.Signed/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.5.0")]
[assembly: AssemblyFileVersion("2.1.5.0")]
[assembly: AssemblyVersion("2.1.6.0")]
[assembly: AssemblyFileVersion("2.1.6.0")]

[assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)]
[assembly: InternalsVisibleTo("TrackerDog.Test.Signed, PublicKey=00240000048000009400000006020000002400005253413100040000010001001ffcf2febdbe56c43afff66e091d7220aa0e53b1638c84e8ae732b444410137f0cc754459f5691f74313921820a490e8761982edac1f051ba141be96bb9f82b4ea4a80b6b87e8c99831fdb69473821dbda3622a8cd3c439ddf3b76cba5ff89809423b7e02ea2b55a12f2b2f5ce0ce377bb2bb4831ce02f7a71cce368e346ecba")]
4 changes: 2 additions & 2 deletions TrackerDog.Signed/TrackerDog.Signed.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@
<Compile Include="..\TrackerDog\ReflectionExtensions.cs">
<Link>ReflectionExtensions.cs</Link>
</Compile>
<Compile Include="..\TrackerDog\Serialization\Json\DynamicObjectContractResolver.cs">
<Link>Serialization\Json\DynamicObjectContractResolver.cs</Link>
<Compile Include="..\TrackerDog\Serialization\Json\CustomObjectContractResolver.cs">
<Link>Serialization\Json\CustomObjectContractResolver.cs</Link>
</Compile>
<Compile Include="..\TrackerDog\Serialization\Json\DynamicObjectWithDeclaredPropertiesConverter.cs">
<Link>Serialization\Json\DynamicObjectWithDeclaredPropertiesConverter.cs</Link>
Expand Down
11 changes: 11 additions & 0 deletions TrackerDog.Test/CollectionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,16 @@ IReadOnlyChangeTrackableCollection trackableCollection
Assert.AreEqual(0, trackableCollection.AddedItems.Count);
Assert.AreEqual(0, trackableCollection.RemovedItems.Count);
}

[TestMethod]
public void DictionaryKeysAreNotMessedUp()
{
E e = TrackableObjectFactory.CreateOf<E>();
e.Dictionary.Add("Hey", "Oops!");

E untrackedE = e.ToUntracked();

Assert.AreEqual("Hey", e.Dictionary.First().Key);
}
}
}
2 changes: 1 addition & 1 deletion TrackerDog/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static object CloneIt(this object some, Type type)
{
JsonSerializer serializer = new JsonSerializer();
serializer.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
serializer.ContractResolver = new DynamicObjectContractResolver();
serializer.ContractResolver = new CustomObjectContractResolver();

return JObject.FromObject(some, serializer).ToObject(type, serializer);
}
Expand Down
6 changes: 3 additions & 3 deletions TrackerDog/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TrackerDog")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,7 +32,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.5.0")]
[assembly: AssemblyFileVersion("2.1.5.0")]
[assembly: AssemblyVersion("2.1.6.0")]
[assembly: AssemblyFileVersion("2.1.6.0")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
[assembly: InternalsVisibleTo("TrackerDog.Test")]
28 changes: 28 additions & 0 deletions TrackerDog/Serialization/Json/CustomObjectContractResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Newtonsoft.Json.Serialization;
using System;
using System.Dynamic;

namespace TrackerDog.Serialization.Json
{
internal class CustomObjectContractResolver : CamelCasePropertyNamesContractResolver
{
protected override JsonContract CreateContract(Type objectType)
{
if (typeof(IDynamicMetaObjectProvider).IsAssignableFrom(objectType))
{
return CreateObjectContract(objectType);
}

return base.CreateContract(objectType);
}

protected override JsonDictionaryContract CreateDictionaryContract(Type objectType)
{
JsonDictionaryContract contract = base.CreateDictionaryContract(objectType);

contract.DictionaryKeyResolver = propertyName => propertyName;

return contract;
}
}
}
23 changes: 0 additions & 23 deletions TrackerDog/Serialization/Json/DynamicObjectContractResolver.cs

This file was deleted.

2 changes: 1 addition & 1 deletion TrackerDog/TrackerDog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
<Compile Include="PropertyInfoEqualityComparer.cs" />
<Compile Include="ReflectionExtensions.cs" />
<Compile Include="CollectionHandling\SetChangeInterceptor.cs" />
<Compile Include="Serialization\Json\DynamicObjectContractResolver.cs" />
<Compile Include="Serialization\Json\CustomObjectContractResolver.cs" />
<Compile Include="Serialization\Json\DynamicObjectWithDeclaredPropertiesConverter.cs" />
<Compile Include="TrackableObjectFactoryInternal.cs" />
<Compile Include="ObjectChangeTracking.cs" />
Expand Down

0 comments on commit 8c437c8

Please sign in to comment.