I'm using Newtonsoft JSON library and I'm trying to deserialize a JSON. The problem is that when I use [JsonConverter(typeof(StringEnumConverter))] I get this error: Cannot apply attribute class 'JsonConverter' because it is abstract.
Here are my classes:
public class ActionRepository { [JsonConverter(typeof(StringEnumConverter))] public enum AllowedActions { FINDWINDOW, } public enum AllowedParameters { WINDOWNAME, } } public class Action { public AllowedActions Name { get; set; } public List<Parameter> Parameters { get; set; } } I get the squiggly line under the JsonConverter.
EDIT: The JsonConverter class is indeed abstract if I navigate to the class (ctrl+click in VS). I'm using .NET for Windows Universal.
[JsonConverter(typeof(StringEnumConverter))]doesn't apply an attribute of typeJsonConverter, it applies the attributeJsonConverterAttributewhich is not abstract.Attribute. An attribute_name of the form type_name may either include or omit this suffix. If an attribute class is found both with and without this suffix, an ambiguity is present, and a compile-time error results. So it's odd that the IDE somehow thoughtJsonConverterwas being applied rather thanJsonConverterAttribute. Possibly an IDE bug here?