Skip to content

Commit

Permalink
Fixed generation of explicit enum strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwadams committed Jan 23, 2024
1 parent 0b18872 commit 821d82b
Show file tree
Hide file tree
Showing 136 changed files with 2,259 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,16 @@ private static string GetRawTextAsQuotedString(JsonAny? value)
throw new ArgumentNullException(nameof(value));
}

private static string GetRawStringValueAsQuotedString(JsonAny? value)
{
if (value is JsonAny actualValue && actualValue.ValueKind == JsonValueKind.String)
{
return Formatting.FormatLiteralOrNull(actualValue.AsJsonElement.GetRawText()[1..^1], true);
}

throw new ArgumentNullException(nameof(value));
}

private bool MatchType(string typeToMatch)
{
if (this.TypeDeclaration.Schema().Type.IsNotUndefined())
Expand Down Expand Up @@ -2727,6 +2737,7 @@ public EnumValue(JsonAny value)
this.IsArray = value.ValueKind == JsonValueKind.Array;
this.IsNull = value.IsNull();
this.SerializedValue = GetRawTextAsQuotedString(value);
this.RawStringValue = value.ValueKind == JsonValueKind.String ? GetRawStringValueAsQuotedString(value) : null;
this.AsPropertyName = Formatting.ToPascalCaseWithReservedWords(this.SerializedValue.Trim('"')).ToString();
}

Expand Down Expand Up @@ -2765,6 +2776,11 @@ public EnumValue(JsonAny value)
/// </summary>
public string SerializedValue { get; }

/// <summary>
/// Gets the raw value of a string value, as a quoted string. This will be null if the value was not a string.
/// </summary>
public string? RawStringValue { get; }

/// <summary>
/// Gets the serialized value as a property name.
/// </summary>
Expand Down
Loading

0 comments on commit 821d82b

Please sign in to comment.