{"record":{"id":"2d1ce1baa68b628d","repo":"dotnet/wpf","slug":"sr-incorrectgetterparamnum","errorCode":null,"errorMessage":"SR.IncorrectGetterParamNum","messagePattern":"SR\\.IncorrectGetterParamNum","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlMember.cs","lineNumber":849,"sourceCode":"                {\n                    result = LookupIsWritePublic();\n                    _reflector.SetFlag(BoolMemberBits.WritePublic, result.Value);\n                }\n\n                return result.Value;\n            }\n        }\n\n        private static void ValidateGetter(MethodInfo method, string argumentName)\n        {\n            if (method is null)\n            {\n                return;\n            }\n\n            if ((method.GetParameters().Length != 1) || (method.ReturnType == typeof(void)))\n            {\n                throw new ArgumentException(SR.IncorrectGetterParamNum, argumentName);\n            }\n        }\n\n        private static void ValidateSetter(MethodInfo method, string argumentName)\n        {\n            if ((method is not null) && (method.GetParameters().Length != 2))\n            {\n                throw new ArgumentException(SR.IncorrectSetterParamNum, argumentName);\n            }\n        }\n\n        // This property needs to be checked before any attribute lookups on _reflector. It's not\n        // only informational, it also ensures that the right state is initialized.\n        private bool AreAttributesAvailable\n        {\n            get\n            {\n                EnsureReflector();","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlMember.cs#L831-L867","documentation":"ValidateGetter rejects getter MethodInfo objects that do not have exactly one parameter and a non-void return type, throwing ArgumentException with SR.IncorrectGetterParamNum. A valid attachable getter must take the owning object and return the value.","triggerScenarios":"Constructing an attachable-property XamlMember with a getter MethodInfo whose GetParameters().Length != 1 or whose ReturnType == typeof(void).","commonSituations":"Hand-written or code-generated Get<Property> methods with wrong arity or void return, often after signature refactors.","solutions":["Change the getter to accept exactly one parameter (the object) and return the property value.","Pass a different, correct MethodInfo.","If only a setter is valid, omit the getter by passing null instead of an invalid one."],"exampleFix":"// before\npublic static void GetMyProp(object o) { ... }  // void return\n// after\npublic static string GetMyProp(object o) { return ...; }","handlingStrategy":"validation","validationCode":"if (getter is not null && (getter.GetParameters().Length != 1 || getter.ReturnType == typeof(void))) throw new ArgumentException(\"Getter must take 1 parameter and return non-void\");","typeGuard":"bool IsValidGetter(MethodInfo m) => m is null || (m.GetParameters().Length == 1 && m.ReturnType != typeof(void));","tryCatchPattern":null,"preventionTips":["Write attachable getters as public static T GetX(object owner).","Validate method signatures with unit tests after refactors."],"tags":["xaml","argument-exception","method-signature"],"backgroundTag":"invalid-argument-value","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"}