Skip to content

Commit

Permalink
Review error messages in JSON (#72254)
Browse files Browse the repository at this point in the history
* Review error messages in JSON

* Clarify SerializerContextOptionsImmutable

* Update src/libraries/System.Text.Json/src/Resources/Strings.resx

Co-authored-by: Stephen Toub <[email protected]>

* Update src/libraries/System.Text.Json/src/Resources/Strings.resx

Co-authored-by: Eirik Tsarpalis <[email protected]>

Co-authored-by: Stephen Toub <[email protected]>
Co-authored-by: Eirik Tsarpalis <[email protected]>
  • Loading branch information
3 people authored Jul 15, 2022
1 parent 8e4fe9a commit 0fe98fc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
10 changes: 2 additions & 8 deletions src/libraries/System.Text.Json/src/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
<value>The requested operation requires an element of type '{0}', but the target element has type '{1}'.</value>
</data>
<data name="TypeInfoResolverImmutable" xml:space="preserve">
<value>Default TypeInfoResolver and custom TypeInfoResolver cannot be changed after first usage.</value>
<value>Cannot add callbacks to the 'Modifiers' property after the resolver has been used for the first time.</value>
</data>
<data name="TypeInfoImmutable" xml:space="preserve">
<value>JsonTypeInfo cannot be changed after first usage.</value>
Expand Down Expand Up @@ -576,7 +576,7 @@
<value>An item with the same key has already been added. Key: {0}</value>
</data>
<data name="SerializerContextOptionsImmutable" xml:space="preserve">
<value>A 'JsonSerializerOptions' instance associated with a 'JsonSerializerContext' instance cannot be mutated once the context has been instantiated.</value>
<value>JsonSerializerOptions instances cannot be modified once encapsulated by a JsonSerializerContext. Such encapsulation can happen either when calling 'JsonSerializerOptions.AddContext' or when passing the options instance to a JsonSerializerContext constructor.</value>
</data>
<data name="ConverterForPropertyMustBeValid" xml:space="preserve">
<value>The generic type of the converter for property '{0}.{1}' must match with the specified converter type '{2}'. The converter must not be 'null'.</value>
Expand All @@ -599,15 +599,9 @@
<data name="NodeJsonObjectCustomConverterNotAllowedOnExtensionProperty" xml:space="preserve">
<value>A custom converter for JsonObject is not allowed on an extension property.</value>
</data>
<data name="MetadataInitFuncsNull" xml:space="preserve">
<value>Invalid configuration provided for 'propInitFunc', 'ctorParamInitFunc' and 'serializeFunc'.</value>
</data>
<data name="NoMetadataForTypeProperties" xml:space="preserve">
<value>TypeInfoResolver '{0}' did not provide property metadata for type '{1}'.</value>
</data>
<data name="NoDefaultOptionsForContext" xml:space="preserve">
<value>To specify a serialization implementation for type '{0}'', context '{0}' must specify default options.</value>
</data>
<data name="FieldCannotBeVirtual" xml:space="preserve">
<value>A 'field' member cannot be 'virtual'. See arguments for the '{0}' and '{1}' parameters. </value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,6 @@ public static void ThrowInvalidOperationException_SerializerOptionsImmutable(Jso
throw new InvalidOperationException(message);
}

[DoesNotReturn]
public static void ThrowInvalidOperationException_SerializerContextOptionsImmutable()
{
throw new InvalidOperationException(SR.SerializerContextOptionsImmutable);
}

[DoesNotReturn]
public static void ThrowInvalidOperationException_TypeInfoResolverImmutable()
{
Expand Down Expand Up @@ -662,12 +656,6 @@ public static void ThrowInvalidOperationException_NoMetadataForType(Type type, I
throw new InvalidOperationException(SR.Format(SR.NoMetadataForType, type, resolver?.GetType().FullName ?? "<null>"));
}

[DoesNotReturn]
public static void ThrowInvalidOperationException_MetadatInitFuncsNull()
{
throw new InvalidOperationException(SR.Format(SR.MetadataInitFuncsNull));
}

public static void ThrowInvalidOperationException_NoMetadataForTypeProperties(IJsonTypeInfoResolver? resolver, Type type)
{
throw new InvalidOperationException(SR.Format(SR.NoMetadataForTypeProperties, resolver?.GetType().FullName ?? "<null>", type));
Expand All @@ -678,11 +666,6 @@ public static void ThrowInvalidOperationException_NoMetadataForTypeCtorParams(IJ
throw new InvalidOperationException(SR.Format(SR.NoMetadataForTypeCtorParams, resolver?.GetType().FullName ?? "<null>", type));
}

public static void ThrowInvalidOperationException_NoDefaultOptionsForContext(JsonSerializerContext context, Type type)
{
throw new InvalidOperationException(SR.Format(SR.NoDefaultOptionsForContext, context.GetType(), type));
}

[DoesNotReturn]
public static void ThrowMissingMemberException_MissingFSharpCoreMember(string missingFsharpCoreMember)
{
Expand Down

0 comments on commit 0fe98fc

Please sign in to comment.