tui-cs/Terminal.Gui · error · JsonException

{propertyType.Name}: Error reading property with converter "

Error message

{propertyType.Name}: Error reading property with converter "{converterType.FullName}".

What it means

Thrown by TryReadWithDynamicConverter when a property-level JsonConverter's Read method throws NotSupportedException while reading a value. The original NotSupportedException is wrapped as the InnerException of a JsonException so the caller sees which property type and which converter failed. This path only runs when RuntimeFeature.IsDynamicCodeSupported is true (JIT present).

Source

Thrown at Terminal.Gui/Configuration/ScopeJsonConverter.cs:309

        object converter = Activator.CreateInstance (converterType)!;

        if (converter is JsonConverterFactory factory && factory.CanConvert (propertyType))
        {
            converter = factory.CreateConverter (propertyType, options)!;
        }

        try
        {
            Type helperType = typeof (ReadHelper<>).MakeGenericType (typeof (TScopeT), propertyType);
            var readHelper = (ReadHelper)Activator.CreateInstance (helperType, converter)!;
            value = readHelper.Read (ref reader, propertyType, options);

            return true;
        }
        catch (NotSupportedException e)
        {
            throw new JsonException ($"{propertyType.Name}: Error reading property with converter \"{converterType.FullName}\".", e);
        }
        catch (TargetInvocationException)
        {
            value = JsonSerializer.Deserialize (ref reader, propertyType, options);

            return true;
        }
    }

    private static bool TryReadWithKnownConverter (ref Utf8JsonReader reader,
                                                   Type propertyType,
                                                   Type converterType,
                                                   JsonSerializerOptions options,
                                                   out object? value)
    {
        if (converterType == typeof (ConcurrentDictionaryJsonConverter<ThemeScope>))
        {
            value = new ConcurrentDictionaryJsonConverter<ThemeScope> ().Read (ref reader, propertyType, options);

View on GitHub (pinned to 2e47b11478)

Solutions

  1. Inspect the InnerException (NotSupportedException) for the real cause and fix the converter's Read to handle the incoming token.
  2. Correct the JSON so the token matches what the converter expects (object vs array vs scalar).
  3. Remove the [JsonConverter] from the property if read support isn't needed, or replace it with a JsonConverterFactory that produces a readable converter.

Example fix

// before
public class MyConverter : JsonConverter<Foo>
{
    public override Foo Read (ref Utf8JsonReader r, Type t, JsonSerializerOptions o)
        => throw new NotSupportedException (); // or base.Read -> throws
}

// after
public override Foo Read (ref Utf8JsonReader r, Type t, JsonSerializerOptions o)
{
    if (r.TokenType != JsonTokenType.StartObject)
        throw new JsonException ("Expected object");
    // ...parse Foo...
    return foo;
}
Defensive patterns

Strategy: try-catch

Try / catch

try { /* load config */ }
catch (JsonException ex) when (ex.Message.Contains ("Error reading property with converter"))
{
    // ex.InnerException is the real NotSupportedException; inspect it
    Logging.Error ($"Converter read failed: {ex.InnerException?.Message}");
}

Prevention

When it happens

Trigger: A config property has a custom JsonConverter whose Read throws NotSupportedException (the default behavior of System.Text.Json's JsonConverter<T> base when not overridden, or when the converter doesn't handle the incoming token). Triggered during deserialization of that property from any config source.

Common situations: A converter was applied to a type but its Read override was forgotten or returns base.Read(); the JSON token shape doesn't match what the converter expects (e.g. array vs object); a third-party converter that doesn't support reading.

Related errors


AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13). Data as JSON: /api/errors/d47b2bc6e37ac657. Report an issue: GitHub.