0

I have a class as follows -

public class AppSettings
{
    [JsonConverter(typeof(SomeConverter))]
    public RestApiURL {get; set;}
}

and SomeConverter method is like -

class SomeConverter : JsonConverter
{
    public override bool CanConvert(Type objectType)
    {
        return true;
    }

    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        /*some logic*/
    }

    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
    {
        /*some logic*/
    }
}

When an object of AppSettings is created using IOption, I want to step into SomeConverter converter function through debugger. But it isn't reaching. I think it's not IDE specific.

demo
  • 6,038
  • 19
  • 75
  • 149
  • 4
    add breakpoints in `SomeConverter` and you will be there. https://social.msdn.microsoft.com/Forums/en-US/3fdf2136-df00-4c46-91d0-db5539aa2ec8/debugging-custom-attributes?forum=netfxtoolsdev – demo Dec 02 '19 at 12:55
  • https://stackoverflow.com/questions/22714541/debugger-is-not-entering-custom-attribute-class – demo Dec 02 '19 at 12:57
  • try to debug my post here: https://stackoverflow.com/a/59075887/2568863, you will see if your code has problem. – Dongdong Dec 02 '19 at 14:28
  • Looks like [`JsonConfigurationFileParser.cs`](https://github.com/aspnet/Extensions/blob/master/src/Configuration/Config.Json/src/JsonConfigurationFileParser.cs) doesn't use Json.NET, it uses [`JsonDocument`](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsondocument?view=netcore-3.0) from `System.Text.Json`. So your `SomeConverter` will never get instantiated or used. – dbc Dec 05 '19 at 17:50

0 Answers0