{"record":{"id":"7711a9ac3096492d","repo":"dotnet/wpf","slug":"sr-unsupportedproperty-propertycondition","errorCode":null,"errorMessage":"SR.UnsupportedProperty","messagePattern":"SR\\.UnsupportedProperty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/PropertyCondition.cs","lineNumber":127,"sourceCode":"        #endregion Public Properties\n\n\n        //------------------------------------------------------\n        //\n        //  Private Methods\n        //\n        //------------------------------------------------------\n\n        #region Private Methods\n\n        private void Init(AutomationProperty property, object val, PropertyConditionFlags flags )\n        {\n            ArgumentNullException.ThrowIfNull(property);\n\n            AutomationPropertyInfo info;\n            if (!Schema.GetPropertyInfo(property, out info))\n            {\n                throw new ArgumentException(SR.UnsupportedProperty);\n            }\n\n            // Check type is appropriate: NotSupported is allowed against any property,\n            // null is allowed for any reference type (ie not for value types), otherwise\n            // type must be assignable from expected type.\n            Type expectedType = info.Type;\n            if (val != AutomationElement.NotSupported &&\n                ((val == null && expectedType.IsValueType)\n                || (val != null && !expectedType.IsAssignableFrom(val.GetType()))))\n            {\n                throw new ArgumentException(SR.Format(SR.PropertyConditionIncorrectType, property.ProgrammaticName, expectedType.Name));\n            }\n\n            if ((flags & PropertyConditionFlags.IgnoreCase) != 0)\n            {\n                Misc.ValidateArgument(val is string, nameof(SR.IgnoreCaseRequiresString));\n            }\n","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/PropertyCondition.cs#L109-L145","documentation":"The PropertyCondition constructor validates the given AutomationProperty against Schema.GetPropertyInfo; unknown properties throw ArgumentException(SR.UnsupportedProperty). PropertyCondition can only be built from properties the UI Automation client schema knows about, because it must map to an unmanaged UIA condition.","triggerScenarios":"new PropertyCondition(customOrUnknownProperty, value); passing a property identifier obtained from LookupById for an id not in the client schema; passing an AutomationProperty from a different UIA surface.","commonSituations":"Constructing search conditions dynamically from config where property names don't map to schema properties; using provider-side or custom-registered properties in client-side conditions; typos in property identifier selection.","solutions":["Build conditions only with known identifiers like AutomationElement.NameProperty or pattern identifier properties","Validate the property id against AutomationProperty references in the schema before constructing the condition","For custom provider properties, search client-side by enumerating elements instead of using PropertyCondition"],"exampleFix":"// before\nvar cond = new PropertyCondition(myCustomProperty, \"value\"); // ArgumentException\n// after\nvar cond = new PropertyCondition(AutomationElement.AutomationIdProperty, \"value\");","handlingStrategy":"validation","validationCode":"var known = new[]{ AutomationElement.NameProperty, AutomationElement.AutomationIdProperty, AutomationElement.ControlTypeProperty };\nif (!known.Contains(property)) return null; // don't build the condition","typeGuard":null,"tryCatchPattern":"try { var c = new PropertyCondition(p, v); } catch (ArgumentException) { /* fall back to client-side filter */ }","preventionTips":["Build PropertyCondition only from schema-known identifiers","Validate dynamic property sources before constructing","Use client-side filtering for custom provider properties"],"tags":["uiautomation","propertycondition","unsupported-property","argument-exception"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}