-Minor fixes
This commit is contained in:
@@ -64,6 +64,10 @@ namespace Newtonsoft.Json.Tests.Utilities
|
||||
Assert.AreEqual("snA__kEcAsE", StringUtils.ToCamelCase("SnA__kEcAsE"));
|
||||
Assert.AreEqual("snA__ kEcAsE", StringUtils.ToCamelCase("SnA__ kEcAsE"));
|
||||
Assert.AreEqual("already_snake_case_ ", StringUtils.ToCamelCase("already_snake_case_ "));
|
||||
Assert.AreEqual("isJSONProperty", StringUtils.ToCamelCase("IsJSONProperty"));
|
||||
Assert.AreEqual("shoutinG_CASE", StringUtils.ToCamelCase("SHOUTING_CASE"));
|
||||
Assert.AreEqual("9999-12-31T23:59:59.9999999Z", StringUtils.ToCamelCase("9999-12-31T23:59:59.9999999Z"));
|
||||
Assert.AreEqual("hi!! This is text. Time to test.", StringUtils.ToCamelCase("Hi!! This is text. Time to test."));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -89,6 +93,10 @@ namespace Newtonsoft.Json.Tests.Utilities
|
||||
Assert.AreEqual("sn_a__k_ec_as_e", StringUtils.ToSnakeCase("SnA__kEcAsE"));
|
||||
Assert.AreEqual("sn_a__k_ec_as_e", StringUtils.ToSnakeCase("SnA__ kEcAsE"));
|
||||
Assert.AreEqual("already_snake_case_", StringUtils.ToSnakeCase("already_snake_case_ "));
|
||||
Assert.AreEqual("is_json_property", StringUtils.ToSnakeCase("IsJSONProperty"));
|
||||
Assert.AreEqual("shouting_case", StringUtils.ToSnakeCase("SHOUTING_CASE"));
|
||||
Assert.AreEqual("9999-12-31_t23:59:59.9999999_z", StringUtils.ToSnakeCase("9999-12-31T23:59:59.9999999Z"));
|
||||
Assert.AreEqual("hi!!_this_is_text._time_to_test.", StringUtils.ToSnakeCase("Hi!! This is text. Time to test."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ namespace Newtonsoft.Json
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection's items converter.
|
||||
/// Gets or sets the collection's items converter.
|
||||
/// </summary>
|
||||
/// <value>The collection's items converter.</value>
|
||||
public Type ItemConverterType { get; set; }
|
||||
@@ -70,7 +70,7 @@ namespace Newtonsoft.Json
|
||||
public object[] ItemConverterParameters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Type"/> of the <see cref="NamingStrategy"/>.
|
||||
/// Gets or sets the <see cref="Type"/> of the <see cref="NamingStrategy"/>.
|
||||
/// </summary>
|
||||
/// <value>The <see cref="Type"/> of the <see cref="NamingStrategy"/>.</value>
|
||||
public Type NamingStrategyType
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Newtonsoft.Json
|
||||
public object[] ItemConverterParameters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Type"/> of the <see cref="NamingStrategy"/>.
|
||||
/// Gets or sets the <see cref="Type"/> of the <see cref="NamingStrategy"/>.
|
||||
/// </summary>
|
||||
/// <value>The <see cref="Type"/> of the <see cref="NamingStrategy"/>.</value>
|
||||
public Type NamingStrategyType { get; set; }
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
/// </summary>
|
||||
/// <param name="name">The initial property name.</param>
|
||||
/// <param name="hasSpecifiedName">A flag indicating whether the property has had a name explicitly specfied.</param>
|
||||
/// <returns>A property name.</returns>
|
||||
/// <returns>The serialized property name.</returns>
|
||||
public virtual string GetPropertyName(string name, bool hasSpecifiedName)
|
||||
{
|
||||
if (hasSpecifiedName && !OverrideSpecifiedNames)
|
||||
@@ -38,7 +38,7 @@
|
||||
/// Gets the serialized key for a given dictionary key.
|
||||
/// </summary>
|
||||
/// <param name="key">The initial dictionary key.</param>
|
||||
/// <returns>A dictionary key.</returns>
|
||||
/// <returns>The serialized dictionary key.</returns>
|
||||
public virtual string GetDictionaryKey(string key)
|
||||
{
|
||||
if (!ProcessDictionaryKeys)
|
||||
|
||||
@@ -213,9 +213,13 @@ namespace Newtonsoft.Json.Utilities
|
||||
{
|
||||
case SnakeCaseState.Upper:
|
||||
bool hasNext = (i + 1 < s.Length);
|
||||
if (i > 0 && hasNext && !char.IsUpper(s[i + 1]))
|
||||
if (i > 0 && hasNext)
|
||||
{
|
||||
sb.Append('_');
|
||||
char nextChar = s[i + 1];
|
||||
if (!char.IsUpper(nextChar) && nextChar != '_')
|
||||
{
|
||||
sb.Append('_');
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SnakeCaseState.Lower:
|
||||
|
||||
Reference in New Issue
Block a user