Skip to content

Commit c60f1da

Browse files
authored
Apply suggestions from code review
1 parent 071e87c commit c60f1da

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/Json/EnumConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public EnumConverter(JsonContext context) : base(context)
3131
var valueDescriptor = enumDescriptor.FindValueByName(value);
3232
if (valueDescriptor == null)
3333
{
34-
throw new InvalidOperationException($"Invalid enum value: {value} for enum type: {typeToConvert}.");
34+
throw new InvalidOperationException($"Error converting value "{value}" to enum type {typeToConvert}.");
3535
}
3636

3737
return ConvertFromInteger(valueDescriptor.Number);

src/Grpc/JsonTranscoding/test/Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests/ConverterTests/JsonConverterReadTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void Enum_ReadString_NotAllowedValue()
145145

146146
var json = @"{ ""singleEnum"": ""INVALID"" }";
147147

148-
AssertReadJsonError<HelloRequest.Types.DataTypes>(json, ex => Assert.Equal("Invalid enum value: INVALID for enum type: Transcoding.HelloRequest+Types+DataTypes+Types+NestedEnum.", ex.Message), descriptorRegistry: serviceDescriptorRegistry, serializeOld: false);
148+
AssertReadJsonError<HelloRequest.Types.DataTypes>(json, ex => Assert.Equal("Error converting value "INVALID" to enum type Transcoding.HelloRequest+Types+DataTypes+Types+NestedEnum.", ex.Message), descriptorRegistry: serviceDescriptorRegistry, serializeOld: false);
149149
}
150150

151151
[Fact]
@@ -564,7 +564,7 @@ public void JsonNamePriority_FieldNameFallback()
564564
return objectNew;
565565
}
566566

567-
private void AssertReadJsonError<TValue>(string value, Action<Exception> assertException, GrpcJsonSettings? settings = null, DescriptorRegistry? descriptorRegistry = null, bool serializeOld = true) where TValue : IMessage, new()
567+
private void AssertReadJsonError<TValue>(string value, Action<Exception> assertException, GrpcJsonSettings? settings = null, DescriptorRegistry? descriptorRegistry = null, bool deserializeOld = true) where TValue : IMessage, new()
568568
{
569569
var typeRegistery = TypeRegistry.FromFiles(
570570
HelloRequest.Descriptor.File,
@@ -577,7 +577,7 @@ public void JsonNamePriority_FieldNameFallback()
577577
var ex = Assert.ThrowsAny<Exception>(() => JsonSerializer.Deserialize<TValue>(value, jsonSerializerOptions));
578578
assertException(ex);
579579

580-
if (serializeOld)
580+
if (deserializeOld)
581581
{
582582
var formatter = new JsonParser(new JsonParser.Settings(
583583
recursionLimit: int.MaxValue,

0 commit comments

Comments
 (0)