Newtonsoft JsonConverter annotations

Answered

Creating a custom JsonConverter, R# tells me to annotate the following methods:

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)

which produces:

[CanBeNull]
public override object ReadJson([NotNull] JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)

public override void WriteJson([NotNull] JsonWriter writer, [CanBeNull] object value, JsonSerializer serializer)

It then complains that the "base declaration has the same annotation", and instructs me to remove the attributes.

Removing the attributes takes me right back to the "Annotate [method|parameter] with ..." warnings.

It seems it is impossible to write a JsonConverter which R# will not complain about.

R# v2021.1.3
VS2019 v16.10.2
Newtonsoft.Json v13.0.1 (referenced via NuGet)

0
1 comment
Official comment

Hello Richard Deeming,

Thank you for contacting us.

I discussed this issue with our development team and opened a corresponding issue - https://youtrack.jetbrains.com/issue/RSRP-485421

Feel free to comment or vote for it.

Please sign in to leave a comment.