{"record":{"id":"25b268df1a4f02db","repo":"tui-cs/Terminal.Gui","slug":"omitclassname-is-not-allowed-when-scope-is-appsett","errorCode":null,"errorMessage":"OmitClassName is not allowed when Scope is AppSettingsScope to ensure property names are globally unique.","messagePattern":"OmitClassName is not allowed when Scope is AppSettingsScope to ensure property names are globally unique\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/ConfigurationPropertyAttribute.cs","lineNumber":35,"sourceCode":"\n    private Type? _scope;\n\n    /// <summary>Specifies the scope of the property. If <see langword=\"null\"/> then <see cref=\"AppSettingsScope\"/> will be used.</summary>\n    public Type? Scope\n    {\n        get\n        {\n            if (_scope is { })\n            {\n                return _scope;\n            }\n            return typeof (AppSettingsScope);\n        }\n        set\n        {\n            if (value == typeof (AppSettingsScope) && OmitClassName)\n            {\n                throw new ArgumentException (\"OmitClassName is not allowed when Scope is AppSettingsScope to ensure property names are globally unique.\");\n            }\n            _scope = value;\n        }\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":41,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/ConfigurationPropertyAttribute.cs#L17-L41","documentation":"Thrown by the ConfigurationPropertyAttribute.Scope setter: setting Scope to typeof(AppSettingsScope) while OmitClassName is true is rejected. AppSettingsScope keys must include the declaring class name to stay globally unique, so omitting it is forbidden. (Scope defaults to AppSettingsScope when unset, but the explicit-set path enforces the rule.)","triggerScenarios":"A property declared as [ConfigurationProperty(OmitClassName = true, Scope = typeof(AppSettingsScope))]. The combination is rejected at attribute construction / setter time.","commonSituations":"A developer wants a short key for an app-scoped property and sets both flags; copy-paste of a theme-scoped attribute pattern onto an app-scoped property.","solutions":["Either set OmitClassName = false (default), so the key is ClassName.Property (globally unique),","or change Scope to a non-AppSettings scope (e.g. a theme scope) where OmitClassName is permitted.","Do not combine OmitClassName = true with Scope = typeof(AppSettingsScope)."],"exampleFix":"// before\n[ConfigurationProperty (OmitClassName = true, Scope = typeof (AppSettingsScope))]\npublic static string? MyKey { get; set; }\n// after\n[ConfigurationProperty (Scope = typeof (AppSettingsScope))]\npublic static string? MyKey { get; set; }","handlingStrategy":"validation","validationCode":"// Fail fast at attribute setup: never set both flags.\nif (attr.OmitClassName && attr.Scope == typeof (AppSettingsScope))\n    throw new ArgumentException (\"OmitClassName cannot be true for AppSettingsScope.\");","typeGuard":"static bool IsLegalAttributeCombo (ConfigurationPropertyAttribute a) =>\n    !(a.OmitClassName && a.Scope == typeof (AppSettingsScope));","tryCatchPattern":"try { var a = new ConfigurationPropertyAttribute { OmitClassName = true, Scope = typeof (AppSettingsScope) }; }\ncatch (ArgumentException) { /* pick one: OmitClassName=false, or a different Scope */ }","preventionTips":["Never combine OmitClassName=true with AppSettingsScope.","For short keys, use a non-app scope (e.g. theme scope)."],"tags":["configuration","attribute","appsettings-scope","validation"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}