MUD0002
Identifies attributes set on MudBlazor components that don't match a defined pattern.
This helps prevent component parameter errors due to typos or changes in MudBlazor.
The warning will only indicate the correct .razor file, not the exact location.
Configure the analyzer by adding the code below to your
.csproj
file.
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> <MudAllowedAttributePattern>LowerCase</MudAllowedAttributePattern> </PropertyGroup>
| Option | Description | Default |
|---|---|---|
LowerCase |
Only allow lower case attributes | true |
HTMLAttributes |
Only allow a list of valid case sensitive HTML attributes and events including data-*, aria-* and role. The default list of attributes were mainly obtained from https://www.w3schools.com/tags/ref_attributes.asp and https://www.w3schools.com/jsref/dom_obj_event.asp | |
DataAndAria |
Only allow case sensitive data-*, aria-* and role attributes | |
None |
Don't allow any additional attributes | |
Any |
Allows any extra attributes in any case |
Custom Attribute List
The HTMLAttributes option can use a custom list of attributes.
Configure this by adding the code below to your
.csproj
file.
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> <MudAllowedAttributeList>attribute1,attribute2</MudAllowedAttributeList> </PropertyGroup>
Migration Hints
When the unknown attribute is a parameter that an earlier major version removed, the same MUD0002 warning also names its replacement, so you do not have to search the migration guides. The tables below list every removal the analyzer explains. Everything else, including changes that move a setting to another component or replace several parameters with one enum, is covered by the v7, v8, and v9 migration guides.
Renamed
The value carries over unchanged, so only the attribute name changes.
| Removed | Replacement | Components | Removed in |
|---|---|---|---|
Link | Href | MudButton, MudIconButton, MudFab, MudChip, MudMenuItem | v7 |
Icon | StartIcon | MudFab | v7 |
VerticalAlign | Vertical | MudButtonGroup | v7 |
Option | Value | MudRadio | v7 |
Outline | Outlined | MudToggleGroup | v7 |
Filter | CheckMark | MudChipSet | v7 |
AdornmentColor | ExpandIconColor | MudListItem | v7 |
OnClickHandlerPreventDefault | OnClickPreventDefault | MudListItem | v7 |
IsOpenChanged | OpenChanged | MudMenu, MudAutocomplete | v7 |
PositionAtCurser | PositionAtCursor | MudMenu | v7 |
ClassActions | ActionsClass | MudDialog, MudDatePicker, MudDateRangePicker, MudTimePicker, MudColorPicker | v7 |
ClassContent | ContentClass | MudDialog | v7 |
SelectOnClick | SelectOnActivation | MudAutocomplete | v7 |
InputIcon | AdornmentIcon | MudDatePicker, MudDateRangePicker, MudTimePicker, MudColorPicker | v7 |
InputVariant | Variant | MudDatePicker, MudDateRangePicker, MudTimePicker, MudColorPicker | v7 |
Minimum, Maximum | Min, Max | MudProgressCircular, MudProgressLinear | v7 |
ShowDelimiters, DelimitersColor, DelimitersClass, DelimiterTemplate | ShowBullets, BulletsColor, BulletsClass, BulletTemplate | MudCarousel | v7 |
IsEditable | Editable | PropertyColumn, TemplateColumn, MudTr | v7 |
IsCheckable | Checkable | MudTr, MudTHeadRow, MudTFootRow, MudTableGroupRow | v7 |
IsExpandable | Expandable | MudTr, MudTHeadRow, MudTFootRow | v7 |
CanHover | Hover | MudTreeView | v7 |
ActivatedValueChanged | SelectedValueChanged | MudTreeView | v7 |
ExpandedIconColor | ExpandButtonIconColor | MudTreeViewItem | v7 |
ItemIsDisabled | ItemDisabled | MudDropContainer, MudDropZone | v7 |
CancelledEditingItem | CanceledEditingItem | MudDataGrid | v8 |
XAxisLabels, InputLabels | ChartLabels | MudChart | v9 |
Two-way bindings
All of these were removed in v7.
Both halves of the binding were renamed, so the value, its callback, and the @bind- spelling all change: @bind-Checked becomes @bind-Value.
A generic component such as MudCheckBox needs an explicit T before the old binding reaches the analyzer; without one, the compiler reports that it cannot infer the type first.
| Removed | Replacement | Components |
|---|---|---|
Checked, CheckedChanged | Value, ValueChanged | MudCheckBox, MudSwitch |
SelectedOption, SelectedOptionChanged | Value, ValueChanged | MudRadioGroup |
IsVisible, IsVisibleChanged | Visible, VisibleChanged | MudDialog, MudMessageBox, MudTooltip |
IsHidden, IsHiddenChanged | Hidden, HiddenChanged | MudHidden |
IsExpanded, IsExpandedChanged | Expanded, ExpandedChanged | MudExpansionPanel |
IsChecked, IsCheckedChanged | Checked, CheckedChanged | MudTr |
Inverted booleans
The replacement means the opposite, so the value flips: DisableRipple="true" becomes Ripple="false", and DisableRipple="@expression" becomes Ripple="@(!expression)".
For the rows in this table, leaving the new parameter unset behaves like leaving the old one unset.
All of these were removed in v7.
| Removed | Replacement | Components |
|---|---|---|
DisableRipple | Ripple | MudButton, MudIconButton, MudFab, MudToggleIconButton, MudCheckBox, MudSwitch, MudRadio, MudToggleGroup, MudListItem, MudMenu, MudNavGroup, MudNavLink, MudTabs |
DisableElevation | DropShadow | MudButton, MudIconButton, MudFab, MudToggleIconButton, MudButtonGroup, MudMenu, MudPagination |
DisableGutters | Gutters | MudAppBar, MudToolBar, MudExpansionPanels, MudExpansionPanel, MudList, MudListSubheader |
DisableUnderLine | Underline | MudTextField, MudNumericField, MudSelect, MudAutocomplete, MudInput, MudField, MudDatePicker, MudDateRangePicker, MudTimePicker, MudColorPicker |
DisableToolbar | ShowToolbar | MudDatePicker, MudDateRangePicker, MudTimePicker, MudColorPicker, MudPickerToolbar |
DisableBorders | Outlined | MudExpansionPanels |
DisableSidePadding | Gutters | MudDialog |
DisableOverlay | Overlay | MudDrawer |
DisableSliderAnimation | SliderAnimation | MudTabs |
DisableModifiers | Modifiers | MudTimeline |
DisableSliders, DisablePreview, DisableModeSwitch, DisableInputs, DisableColorField, DisableAlpha | ShowSliders, ShowPreview, ShowModeSwitch, ShowInputs, ShowColorField, ShowAlpha | MudColorPicker |
DisableDragEffect | DragEffect | MudColorPicker |
DisableRowsPerPage | PageSizeSelector | MudDataGridPager |
Needs more than a rename
These change a default, a type, a unit, or a signature along with the name. Unless a row says otherwise, they were removed in v7.
| Removed | Replacement | What changes |
|---|---|---|
MudRating and MudRatingItem DisableRipple |
Ripple |
The value inverts, and Ripple now defaults to false.
A rating that never set DisableRipple needs Ripple="true" to keep its ripple.
|
MudList DisablePadding |
Padding |
The value inverts, and Padding defaults to false.
A list that never set DisablePadding needs Padding="true" to keep its padding.
|
MudList Clickable |
ReadOnly |
The value inverts: Clickable="true" becomes ReadOnly="false".
Lists are now interactive by default, so a list that never set Clickable needs ReadOnly="true" to stay static.
|
MudChip DisableRipple |
Ripple |
DisableRipple="true" becomes Ripple="false".
For DisableRipple="false", leave Ripple unset so the chip follows its MudChipSet, because Ripple="true" overrides the chip set.
An expression keeps that behavior as Ripple="@(expression ? false : null)".
|
MudListItem DisableGutters |
Gutters |
DisableGutters="true" becomes Gutters="false".
For DisableGutters="false", leave Gutters unset so the item follows its MudList, because Gutters="true" now overrides a list that sets Gutters="false".
An expression keeps that behavior as Gutters="@(expression ? false : null)".
|
MudExpansionPanel IsInitiallyExpanded, MudListItem InitiallyExpanded |
Expanded |
IsInitiallyExpanded="true" becomes Expanded="true".
Expanded holds the current state rather than a starting value, so merge it with any existing Expanded or @bind-Expanded instead of adding a second attribute.
|
MudCheckBox and MudSwitch LabelPosition |
LabelPlacement |
The type changes from LabelPosition to Placement: LabelPosition="LabelPosition.Start" becomes LabelPlacement="Placement.Start", and LabelPosition.End becomes Placement.End.
Removed in v8.
|
MudRadio Placement |
LabelPlacement |
The value carries over, but Placement.Left and Placement.Right no longer swap sides in right-to-left layouts, so use Placement.Start or Placement.End there.
Removed in v8.
|
MudAlert AlertTextPosition |
ContentAlignment |
The type changes to HorizontalAlignment, which has the same member names: AlertTextPosition="AlertTextPosition.Center" becomes ContentAlignment="HorizontalAlignment.Center".
|
MudTooltip Delayed |
Delay |
The unit changes from seconds to milliseconds: Delayed="0.5" becomes Delay="500", and Delayed="@seconds" becomes Delay="@(seconds * 1000)".
|
Input OnKeyPress |
OnKeyDown |
The handler receives the same KeyboardEventArgs, but OnKeyDown also fires for keys that type no character, such as Tab, Shift, and the arrow keys, so check the key in the handler.
|
MudTextField and MudInput AutoGrow |
Sizing |
AutoGrow="true" becomes Sizing="InputSizing.Auto", and AutoGrow="false" becomes Sizing="InputSizing.Fixed", which is the default.
An expression needs the equivalent conditional, such as Sizing="@(grow ? InputSizing.Auto : InputSizing.Fixed)".
Lines and MaxLines keep their meaning, and a masked MudTextField ignores Sizing just as it ignored AutoGrow.
Custom CSS that targets mud-input-auto-grow needs to target mud-input-sizing-auto instead.
Removed in v9.
|
MudAutocomplete SearchFuncWithCancel |
SearchFunc |
SearchFunc now takes the same cancellable delegate, so SearchFuncWithCancel="Search" becomes SearchFunc="Search".
An old SearchFunc without a CancellationToken parameter has to gain one; that is a compile error rather than this warning.
|
MudSelect OnOpen, OnClose |
OpenChanged |
One callback receives true when the list opens and false when it closes: OnOpen="Handler" becomes OpenChanged="@(open => { if (open) Handler(); })".
When the handler returns a Task, await it: OpenChanged="@(async open => { if (open) await Handler(); })".
It is raised only when the open state actually changes, and a select that used both needs a single handler.
Removed in v9.
|
MudTablePager DisableRowsPerPage |
HideRowsPerPage |
The value stays the same: DisableRowsPerPage="true" becomes HideRowsPerPage="true".
Only MudDataGridPager inverts this name.
|
MudTabs TabPanelClass, PanelClass |
TabButtonsClass, TabPanelsClass |
TabPanelClass always styled each tab button, and TabButtonsClass styles the same element.
PanelClass styled the wrapper around all panels, and TabPanelsClass styles the same element.
MudTabPanel's own PanelClass is a current parameter that styles a single panel, so it is not affected.
Removed in v9.
|
MudTreeViewItem ExpandedIcon |
ExpandButtonIcon |
The value is the icon on the expand button.
It is not IconExpanded, which replaces the item's own icon while the item is expanded.
|
A hint explains the replacement; it never rewrites your code, and there is no code fix for it.
The hint is attached to the existing warning, so configuration is unaffected: an attribute allowed by your pattern or custom list stays silent, and Any still disables MUD0002 entirely.
Hints are matched on the component's type, so a component of your own that derives from MudButton gets the same guidance, while an unrelated component with a similarly named attribute does not.
A component that declares its own parameter with the old name keeps using it and is not reported.
A few limits are worth knowing.
Only attributes the analyzer can see are reported: a removed parameter supplied through an @attributes dictionary, or written as a child element such as <DelimiterTemplate>, is never reported at all.
A changed default is only mentioned when the old attribute is still present, because a parameter you never set produces no warning.
And, as above, the warning points at the .razor file rather than the exact line.