tui-cs/Terminal.Gui · error · JsonException

{propertyName}: Unknown property name.

Error message

{propertyName}: Unknown property name.

What it means

A property name in a scope (Settings/Theme) is neither a recognized hardcoded config property (from GetHardCodedProperty) nor a [JsonInclude]-annotated property on the scope type (like $schema). Unknown names are rejected to catch typos and stale config keys.

Source

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

                                                                         return p.Name == propertyName;
                                                                     }

                                                                     return false;
                                                                 })
                                                         .FirstOrDefault ();

                if (property is { })
                {
                    // Set the value of propertyName on the scopeT.
                    PropertyInfo prop = typeof (TScopeT).GetProperty (propertyName!)!;

                    prop.SetValue (scope, JsonSerializer.Deserialize (ref reader, prop.PropertyType, TuiSerializerContext.Instance));
                }
                else
                {
                    // Unknown property
                    throw new JsonException ($"{propertyName}: Unknown property name.");
                }
            }
        }

        throw new JsonException ($"{propertyName}: Json error in ScopeJsonConverter");
    }

    [UnconditionalSuppressMessage ("AOT",
                                   "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.",
                                   Justification =
                                       "Arbitrary property-level converter fallback is guarded by RuntimeFeature.IsDynamicCodeSupported and is unreachable under NativeAOT.")]
    [UnconditionalSuppressMessage ("Trimming",
                                   "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
                                   Justification =
                                       "Arbitrary property-level converter fallback is only used when a consumer opts into a custom property-level JsonConverter on JIT-supported runtimes.")]
    public override void Write (Utf8JsonWriter writer, TScopeT scope, JsonSerializerOptions options)
    {
        writer.WriteStartObject ();

View on GitHub (pinned to 2e47b11478)

Solutions

  1. Check the property name against the current version's known config properties (GetHardCodedProperty keys).
  2. Remove the unknown property, or correct the spelling.
  3. Regenerate config from the current library defaults after an upgrade.

Example fix

// before
{ "Themess": { ... } }
// after
{ "Themes": { ... } }
Defensive patterns

Strategy: validation

Validate before calling

// Compare config keys against the scope's known config properties
foreach (string key in configFileKeys)
{
    if (scope.GetHardCodedProperty (key) is null) /* unknown key */
}

Try / catch

try { ConfigurationManager.Apply (); }
catch (JsonException ex) when (ex.Message.Contains ("Unknown property name"))
{ /* ex.Message names the unrecognized key */ }

Prevention

When it happens

Trigger: A config file with a misspelled or removed key, e.g. "Themess" instead of "Themes", or a key from a different Terminal.Gui version that does not exist in this version.

Common situations: Version mismatch between config and library; typos; copying config from docs written for a different version.

Related errors


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