{"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/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/Reflection/ComponentProperties.cs#L222-L258","documentation":"ThrowForCaptureUnmatchedValuesConflict fires when a single property is annotated with [Parameter(CaptureUnmatchedValues = true)] (making it the unmatched-attributes sink) AND the framework is also asked to set that same property explicitly with a direct value. The sink property cannot simultaneously hold explicit assigned state and unmatched attributes; Blazor rejects the conflicting usage to prevent ambiguous data.","triggerScenarios":"Declaring [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object> Attributes { get; set; } and then in markup writing <MyComponent Attributes=\"...\" /> (passing Attributes explicitly). The framework detects both an explicit assignment target and the unmatched-capture role on the same property.","commonSituations":"Adding a splat-attributes sink named 'Attributes' and then accidentally also setting 'Attributes' as a regular parameter in markup. Component libraries whose public surface exposes the capture property by a name consumers also pass.","solutions":["Do not pass the capture-sink property name explicitly in markup; let it receive only unmatched attributes.","If you need to set that dictionary explicitly, remove CaptureUnmatchedValues = true and handle unmatched attributes separately.","Rename the sink property to avoid collision with any explicitly-supplied parameter name."],"exampleFix":"// before\n// Component: [Parameter(CaptureUnmatchedValues = true)]\n//            public Dictionary<string,object>? Attributes { get; set; }\n<MyComponent Attributes=\"@(new Dictionary<string,object>())\" />\n\n// after\n<MyComponent class=\"btn\" data-foo=\"bar\" /> // unmatched only; Attributes auto-populated","handlingStrategy":"validation","validationCode":"// Detect capture-sink collision before rendering.\nvar sinkProp = typeof(MyComponent).GetProperties()\n    .FirstOrDefault(p => p.GetCustomAttribute<ParameterAttribute>()?.CaptureUnmatchedValues == true);\nif (sinkProp != null && suppliedParameterNames.Contains(sinkProp.Name))\n    throw new InvalidOperationException($\"Do not pass '{sinkProp.Name}' explicitly; it captures unmatched values.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass the capture-sink property name explicitly in markup.","Name the sink property to avoid collision (e.g., 'Attributes', 'AdditionalAttributes').","Document the sink's role so consumers splat attributes rather than setting it."],"tags":["blazor","parameters","capture-unmatched","binding"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}