{"record":{"id":"1f65d4408ae1f384","repo":"dotnet/aspnetcore","slug":"the-property-parametername-on-component-type-1f65d4","errorCode":null,"errorMessage":"The property '{parameterName}' on component type '{targetType.FullName}' cannot be set explicitly when also used to capture unmatched values. Unmatched values:","messagePattern":"The property '(.+?)' on component type '(.+?)' cannot be set explicitly when also used to capture unmatched values\\. Unmatched values:","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/Reflection/ComponentProperties.cs","lineNumber":240,"sourceCode":"    private static void ThrowForSettingCascadingParameterWithNonCascadingValue(Type targetType, string parameterName)\n    {\n        throw new InvalidOperationException(\n            $\"The property '{parameterName}' on component type '{targetType.FullName}' cannot be set \" +\n            $\"explicitly because it only accepts cascading values.\");\n    }\n\n    [DoesNotReturn]\n    private static void ThrowForSettingParameterWithCascadingValue(Type targetType, string parameterName)\n    {\n        throw new InvalidOperationException(\n            $\"The property '{parameterName}' on component type '{targetType.FullName}' cannot be set \" +\n            $\"using a cascading value.\");\n    }\n\n    [DoesNotReturn]\n    private static void ThrowForCaptureUnmatchedValuesConflict(Type targetType, string parameterName, Dictionary<string, object> unmatched)\n    {\n        throw new InvalidOperationException(\n            $\"The property '{parameterName}' on component type '{targetType.FullName}' cannot be set explicitly \" +\n            $\"when also used to capture unmatched values. Unmatched values:\" + Environment.NewLine +\n            string.Join(Environment.NewLine, unmatched.Keys));\n    }\n\n    [DoesNotReturn]\n    private static void ThrowForMultipleCaptureUnmatchedValuesParameters([DynamicallyAccessedMembers(Component)] Type targetType)\n    {\n        var propertyNames = new List<string>();\n        foreach (var property in targetType.GetProperties(BindablePropertyFlags))\n        {\n            if (property.GetCustomAttribute<ParameterAttribute>()?.CaptureUnmatchedValues == true)\n            {\n                propertyNames.Add(property.Name);\n            }\n        }\n\n        propertyNames.Sort(StringComparer.Ordinal);","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/Reflection/ComponentProperties.cs#L222-L258","documentation":"Thrown by ComponentProperties.ThrowForCaptureUnmatchedValuesConflict when a component has a [Parameter(CaptureUnmatchedValues = true)] property that the user sets explicitly in markup AND there are also unmatched (splat) attributes destined for the same dictionary. The framework refuses to either mutate the user-supplied value or silently copy it.","triggerScenarios":"<Child Attributes=\"@myDict\" extra-attr=\"x\" /> where Attributes is the CaptureUnmatchedValues parameter and extra-attr is unmatched.","commonSituations":"Combining an explicit attributes pass-through with additional splatted attributes on the same element; forwarding @attributes while also binding the catch-all parameter directly.","solutions":["Do not set the CaptureUnmatchedValues parameter explicitly if you also splat other attributes - let the framework populate it.","If you need to merge, combine the dictionaries in code and pass only the merged dictionary, removing the extra unmatched attributes from markup.","Use @attributes=\"@attrs\" on an element inside the component rather than binding the component's own catch-all."],"exampleFix":"// before\n<Child Attributes=\"@attrs\" data-foo=\"bar\" />\n\n// after - merge in code, no extra splatted attribute\n@code {\n    private readonly Dictionary<string, object> _merged =\n        new(attrs) { [\"data-foo\"] = \"bar\" };\n}\n<Child Attributes=\"@_merged\" />","handlingStrategy":"validation","validationCode":"// Do not set the CaptureUnmatchedValues parameter explicitly when also splatting attrs.\n// Detect the catch-all parameter name to warn callers.\nstatic string? GetCaptureUnmatchedValuesPropertyName(Type componentType)\n{\n    foreach (var p in componentType.GetProperties())\n    {\n        if (p.GetCustomAttribute<ParameterAttribute>()?.CaptureUnmatchedValues == true)\n            return p.Name;\n    }\n    return null;\n}","typeGuard":"static bool IsCaptureUnmatchedValuesProperty(PropertyInfo p)\n    => p.GetCustomAttribute<ParameterAttribute>()?.CaptureUnmatchedValues == true;","tryCatchPattern":null,"preventionTips":["Never bind the catch-all parameter explicitly while also splatting other attributes.","Merge attribute dictionaries in code and pass a single dictionary.","Use @attributes on inner elements instead of binding the component's own catch-all.","Keep the catch-all parameter name documented so callers avoid direct binding."],"tags":["blazor","parameters","capture-unmatched","attributes","rendering"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}