Skip to content

Commit

Permalink
Merge pull request aspnet#6363 from JamesNK/patch-1
Browse files Browse the repository at this point in the history
Return a shared contract resolver
  • Loading branch information
Eilon committed Jun 7, 2017
2 parents 8f883e8 + 07e975a commit 32e21e2
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public static class JsonSerializerSettingsProvider
{
private const int DefaultMaxDepth = 32;

// return shared resolver by default for perf so slow reflection logic is cached once
// developers can set their own resolver after the settings are returned if desired
private static readonly DefaultContractResolver SharedContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy(),
};

/// <summary>
/// Creates default <see cref="JsonSerializerSettings"/>.
/// </summary>
Expand All @@ -21,10 +28,7 @@ public static JsonSerializerSettings CreateSerializerSettings()
{
return new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy(),
},
ContractResolver = SharedContractResolver,

MissingMemberHandling = MissingMemberHandling.Ignore,

Expand All @@ -38,4 +42,4 @@ public static JsonSerializerSettings CreateSerializerSettings()
};
}
}
}
}

0 comments on commit 32e21e2

Please sign in to comment.