public static void AddingPropertyToNonObjectJsonTypeInfoKindThrows(Type type, JsonTypeInfoKind expectedKind) { JsonSerializerOptions options = new(); DefaultJsonTypeInfoResolver resolver = new(); JsonTypeInfo typeInfo = resolver.GetTypeInfo(type, options); Assert.Equal(expectedKind, typeInfo.Kind); JsonPropertyInfo property = typeInfo.CreateJsonPropertyInfo(typeof(int), "test"); Assert.Throws <InvalidOperationException>(() => typeInfo.Properties.Add(property)); }
public static void ThrowInvalidOperationException_JsonTypeInfoOperationNotPossibleForKind(JsonTypeInfoKind kind) { throw new InvalidOperationException(SR.Format(SR.InvalidJsonTypeInfoOperationForKind, kind)); }
public static void ThrowInvalidOperationException_SerializationCallbacksNotSupported(JsonTypeInfoKind typeInfoKind) { throw GetInvalidOperationException(SR.Format(SR.SerializationCallbacksNotSupported, typeInfoKind)); }