There is a custom attribute I created that I prescribe to classes for the markup extension.
I used to use the serialization mechanism through Newtonsoft.Json and I want to switch to Text.Json, but I ran into a problem that it throws exceptions when trying to serialize classes that inherit from Attribute
public class ConfigNameAttribute : Attribute
{
public ConfigNameAttribute(string name, bool enable)
{
this.name = name;
this.enable = enable;
}
public string name { get; set; }
public bool enable { get; set; }
}
var text = JsonSerializer.Serialize(temp);
throws an exception
System.InvalidOperationException: 'Method may only be called on a Type for which Type.IsGenericParameter is true.'
if you remove Attribute then everything is fine