Код: Выделить всё
public class TimestampStringConverter : JsonConverter
{
public sealed override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
bool existingIsNull = existingValue == null;
if (!(existingIsNull || existingValue is T))
{
throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
}
return ReadJson(reader, objectType, existingIsNull ? default : (T?)existingValue, !existingIsNull, serializer);
}
}
и это Код в файле NewtonsoftJson:
Код: Выделить всё
public abstract class JsonConverter : JsonConverter
{
///
/// Writes the JSON representation of the object.
///
///
The to write to.
/// The value.
/// The calling serializer.
public sealed override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
if (!(value != null ? value is T : ReflectionUtils.IsNullable(typeof(T))))
{
throw new JsonSerializationException("Converter cannot write specified value to JSON. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
}
WriteJson(writer, (T?)value, serializer);
}
///
/// Writes the JSON representation of the object.
///
/// The to write to.
/// The value.
/// The calling serializer.
public abstract void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer);
///
/// Reads the JSON representation of the object.
///
/// The to read from.
/// Type of the object.
/// The existing value of object being read.
/// The calling serializer.
/// The object value.
public sealed override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
bool existingIsNull = existingValue == null;
if (!(existingIsNull || existingValue is T))
{
throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
}
return ReadJson(reader, objectType, existingIsNull ? default : (T?)existingValue, !existingIsNull, serializer);
}
---- rest of the file
что я делаю не так?
Метод находится в базовом классе, я скопировал даже исходную подпись в новый класс - тем не менее VS.NET продолжает говорить "CS0115"
Это ошибка в IDE?
Независимо от какая функция из базового класса: VS.NET всегда утверждает, что нет метода, который я мог бы перезаписать, хотя я ясно вижу их в файле из NewtonsoftJson?
Есть идеи?
- Я ожидал, что смогу реализовать абстрактный класс и переопределить все его функции
- Я уже поискал в Google, чтобы проверить, есть ли у кого-нибудь еще эта проблема, так как это похоже на ошибку в VS.NET
Подробнее здесь: https://stackoverflow.com/questions/791 ... s-newtonso