Skip to content

support mudblazor v9.0.0-rc.1 ToDescriptionString removed#66

Merged
Anu6is merged 1 commit into0phois:masterfrom
pigwing:master
Feb 12, 2026
Merged

support mudblazor v9.0.0-rc.1 ToDescriptionString removed#66
Anu6is merged 1 commit into0phois:masterfrom
pigwing:master

Conversation

@pigwing
Copy link
Contributor

@pigwing pigwing commented Feb 12, 2026

Summary by CodeRabbit

  • Refactor
    • Enhanced enum description handling and color value representation in static input components to improve internal consistency.

@gemini-code-assist
Copy link

Summary of Changes

Hello @pigwing, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a breaking change in MudBlazor v9.0.0-rc.1 by replacing the removed ToDescriptionString() method with a custom-built extension. This ensures that components relying on enum description conversions continue to function correctly and maintain their intended display behavior, thereby preserving the application's compatibility and visual consistency with the updated library.

Highlights

  • MudBlazor v9.0.0-rc.1 Compatibility: The pull request updates the codebase to support the breaking changes introduced in MudBlazor v9.0.0-rc.1, specifically addressing the removal of the ToDescriptionString() extension method.
  • Custom Enum Extension Method: A new static extension method, ToEnumDescriptionString(), has been introduced to provide a custom implementation for retrieving enum descriptions, falling back to ToString().ToLower() if no DescriptionAttribute is present.
  • Component Updates: The MudStaticButton and MudStaticSwitch components have been updated to utilize the new ToEnumDescriptionString() or ToString().ToLower() methods for enum value conversions, ensuring compatibility with the latest MudBlazor version.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/Components/MudStaticButton.razor
    • Replaced ToDescriptionString() with ToEnumDescriptionString() for button type conversion.
  • src/Components/MudStaticSwitch.razor
    • Replaced ToDescriptionString() with ToEnumDescriptionString() for typography class generation.
  • src/Components/MudStaticSwitch.razor.cs
    • Replaced ToDescriptionString() with ToString().ToLower() for color class generation.
  • src/Enums/EnumExtensions.cs
    • Added a new static class EnumExtensions containing the ToEnumDescriptionString() method.
  • src/_Imports.razor
    • Added a using directive for the new MudBlazor.StaticInput.Enums namespace.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@qodo-code-review
Copy link
Contributor

Review Summary by Qodo

Support MudBlazor v9.0.0-rc.1 enum description string removal

✨ Enhancement 🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Replace removed ToDescriptionString() with custom ToEnumDescriptionString() extension method
• Create new EnumExtensions class to handle enum-to-string conversion with description attributes
• Update all enum conversions in MudStaticButton and MudStaticSwitch components
• Add namespace import for new Enums module in _Imports.razor
Diagram
flowchart LR
  A["MudBlazor v9.0.0-rc.1<br/>Removes ToDescriptionString"] -->|"Requires replacement"| B["Create EnumExtensions<br/>with ToEnumDescriptionString"]
  B -->|"Applied to"| C["MudStaticButton.razor"]
  B -->|"Applied to"| D["MudStaticSwitch.razor"]
  B -->|"Applied to"| E["MudStaticSwitch.razor.cs"]
  C -->|"Uses"| F["ButtonType enum conversion"]
  D -->|"Uses"| G["Typo enum conversion"]
  E -->|"Uses"| H["Color enum conversion"]
Loading

Grey Divider

File Changes

1. src/Enums/EnumExtensions.cs ✨ Enhancement +33/-0

New enum extension method for description conversion

• New file created to provide custom enum extension method
• ToEnumDescriptionString() method converts enum values to lowercase strings
• Checks for DescriptionAttribute on enum fields and returns description if present
• Falls back to ToString().ToLower() if no description attribute found

src/Enums/EnumExtensions.cs


2. src/Components/MudStaticSwitch.razor.cs 🐞 Bug fix +6/-6

Replace ToDescriptionString with ToString().ToLower()

• Replace all ToDescriptionString() calls with ToString().ToLower() for Color enums
• Updates 6 property definitions: CheckedTextColor, CheckedHoverColor, UncheckedTextColor,
 UncheckedHoverColor, CheckedColor, UnCheckedColor
• Maintains same functionality with direct string conversion instead of extension method

src/Components/MudStaticSwitch.razor.cs


3. src/Components/MudStaticButton.razor 🐞 Bug fix +4/-3

Update ButtonType enum conversion method

• Replace ToDescriptionString() calls with new ToEnumDescriptionString() method
• Updates GetButtonType() method for ButtonType enum conversions
• Applies to Submit, Reset, and default button type cases
• Add blank line after namespace declaration for formatting

src/Components/MudStaticButton.razor


View more (2)
4. src/Components/MudStaticSwitch.razor 🐞 Bug fix +2/-2

Update Typo enum conversion method

• Replace ToDescriptionString() calls with ToEnumDescriptionString() for Typo enum
• Updates two MudText component class bindings for label and child content
• Minor formatting adjustments to ternary operator spacing

src/Components/MudStaticSwitch.razor


5. src/_Imports.razor ⚙️ Configuration changes +2/-1

Add Enums namespace import

• Add new namespace import @using MudBlazor.StaticInput.Enums
• Enables access to EnumExtensions class throughout the project

src/_Imports.razor


Grey Divider

Qodo Logo

@what-the-diff
Copy link

what-the-diff bot commented Feb 12, 2026

PR Summary

  • Improvements to MudStaticButton
    The descriptions of button types have been updated to use consistent methodology in fetching enum type descriptions. This leads to less confusion and better maintenance.

  • Enhancements to MudStaticSwitch
    This has been updated to use a more efficient string conversion methodology from enum values when dealing with typography class names. The color name handling has also been simplified and is now straightforward.

  • Addition of EnumExtensions
    A new file has been added that includes a static class for retrieving enum descriptions. It harmonizes the way descriptions are fetched and also converts them to lower case if no description is found, reducing the risk of errors.

  • Update to _Imports.razor
    The namespace for the new EnumExtensions has been included, making this useful utility accessible to other components. This broadens the reach and utility of the EnumExtensions functionality across the project.

@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

These changes refactor enum description retrieval across UI components by introducing a new ToEnumDescriptionString() extension method while updating color representation in switch components from descriptor methods to lowercase string formatting. Additionally, namespace imports are expanded to support the new enum extensions.

Changes

Cohort / File(s) Summary
Enum Extension Infrastructure
src/Enums/EnumExtensions.cs, src/_Imports.razor
New ToEnumDescriptionString() extension method added to provide centralized enum description handling with fallback to lowercase enum names. Supporting namespace import added to global Razor imports.
Button Component
src/Components/MudStaticButton.razor
FormAction enum descriptions now retrieved via ToEnumDescriptionString() instead of ToDescriptionString() for improved consistency.
Switch Component
src/Components/MudStaticSwitch.razor, src/Components/MudStaticSwitch.razor.cs
Typography descriptions migrate to ToEnumDescriptionString() method; color properties switch from descriptor methods to ToString().ToLower() for lowercase color token representation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hopping through enums with newfound grace,
Description strings find their rightful place,
Colors in lowercase, so neat and divine,
Extensions now handle the heavy design,
Button and switch harmonize in refrain! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing removed ToDescriptionString() method calls with a new ToEnumDescriptionString() extension method to support MudBlazor v9.0.0-rc.1 compatibility.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/Enums/EnumExtensions.cs (2)

1-6: Remove unused using directives.

Lines 2, 4, 5, 6 import System.Collections.Generic, System.Linq, System.Text, and System.Threading.Tasks, none of which are used in this file. These look like template defaults.

♻️ Proposed cleanup
 using System;
-using System.Collections.Generic;
 using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;

12-16: Empty XML documentation.

The <summary>, <param>, and <returns> tags are all blank. Since this is a public extension method intended for reuse across the project, a brief description would be helpful.

📝 Suggested docs
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="value"></param>
-        /// <returns></returns>
+        /// <summary>
+        /// Returns the <see cref="DescriptionAttribute"/> value for the enum field,
+        /// or the lowercase enum name if no attribute is present.
+        /// </summary>
+        /// <param name="value">The enum value.</param>
+        /// <returns>A descriptive string for the enum value.</returns>
src/Components/MudStaticSwitch.razor.cs (1)

30-39: Use ToEnumDescriptionString() consistently with other files in this PR.

MudStaticButton.razor and MudStaticSwitch.razor use ToEnumDescriptionString(), but these color properties use ToString().ToLower() directly. ToEnumDescriptionString() safely inspects for DescriptionAttribute on enum values and falls back to ToString().ToLower() if none exist—bypassing this adds unnecessary risk if MudBlazor's Color enum has description attributes.

For consistency and defensive programming, use ToEnumDescriptionString() here as well:

♻️ Use ToEnumDescriptionString() consistently
-    private string CheckedTextColor => $"mud-{Color.ToString().ToLower()}-text";
-    private string CheckedHoverColor => $"hover:mud-{Color.ToString().ToLower()}-hover";
-    private string UncheckedTextColor => $"mud-{UncheckedColor.ToString().ToLower()}-text";
-    private string UncheckedHoverColor => $"hover:mud-{UncheckedColor.ToString().ToLower()}-hover";
+    private string CheckedTextColor => $"mud-{Color.ToEnumDescriptionString()}-text";
+    private string CheckedHoverColor => $"hover:mud-{Color.ToEnumDescriptionString()}-hover";
+    private string UncheckedTextColor => $"mud-{UncheckedColor.ToEnumDescriptionString()}-text";
+    private string UncheckedHoverColor => $"hover:mud-{UncheckedColor.ToEnumDescriptionString()}-hover";
     /*
      * Options for TrackClassname
      */
-    private string CheckedColor => $"mud-{Color.ToString().ToLower()}";
-    private string UnCheckedColor => $"mud-{UncheckedColor.ToString().ToLower()}";
+    private string CheckedColor => $"mud-{Color.ToEnumDescriptionString()}";
+    private string UnCheckedColor => $"mud-{UncheckedColor.ToEnumDescriptionString()}";

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link
Contributor

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (2) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. ToEnumDescriptionString null-unsafe 📘 Rule violation ⛯ Reliability
Description
The new ToEnumDescriptionString(this Enum value) extension does not handle null and will throw a
NullReferenceException at value.GetType() if called with a null receiver. This violates the
requirement to explicitly handle null/edge cases for potential failure points.
Code

src/Enums/EnumExtensions.cs[R17-23]

+        public static string ToEnumDescriptionString(this Enum value)
+        {
+            var field = value.GetType().GetField(value.ToString());
+            if (field is null)
+            {
+                return value.ToString().ToLower();
+            }
Evidence
PR Compliance ID 3 requires explicit handling of null/edge cases; the new extension method
dereferences value without a null check, creating an unhandled edge case that can crash callers.

Rule 3: Generic: Robust Error Handling and Edge Case Management
src/Enums/EnumExtensions.cs[17-23]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`ToEnumDescriptionString(this Enum value)` dereferences `value` without checking for null, which can throw at runtime if the extension is invoked with a null receiver.

## Issue Context
Compliance requires explicit handling of null/edge cases at potential failure points.

## Fix Focus Areas
- src/Enums/EnumExtensions.cs[17-23]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Culture-sensitive ToLower() used 📘 Rule violation ⛯ Reliability
Description
New enum-to-CSS-string generation uses ToString().ToLower() which is culture-sensitive and can
produce unexpected output in non-English locales. This is an edge-case robustness issue for UI
classnames and should use ToLowerInvariant() (and ideally a single consistent enum-to-string
helper).
Code

src/Components/MudStaticSwitch.razor.cs[R30-39]

+    private string CheckedTextColor => $"mud-{Color.ToString().ToLower()}-text";
+    private string CheckedHoverColor => $"hover:mud-{Color.ToString().ToLower()}-hover";
+    private string UncheckedTextColor => $"mud-{UncheckedColor.ToString().ToLower()}-text";
+    private string UncheckedHoverColor => $"hover:mud-{UncheckedColor.ToString().ToLower()}-hover";

    /*
     * Options for TrackClassname
     */
-    private string CheckedColor => $"mud-{Color.ToDescriptionString()}";
-    private string UnCheckedColor => $"mud-{UncheckedColor.ToDescriptionString()}";
+    private string CheckedColor => $"mud-{Color.ToString().ToLower()}";
+    private string UnCheckedColor => $"mud-{UncheckedColor.ToString().ToLower()}";
Evidence
PR Compliance ID 3 requires explicit edge-case management; culture-sensitive casing can change
outputs depending on current culture, creating hard-to-debug failures in generated CSS class names.

Rule 3: Generic: Robust Error Handling and Edge Case Management
src/Components/MudStaticSwitch.razor.cs[30-33]
src/Components/MudStaticSwitch.razor.cs[38-39]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Enum-to-string conversion for CSS classnames uses culture-sensitive `ToLower()`, which can change outputs in some locales.

## Issue Context
Generated CSS class names should be deterministic across cultures. This is considered an edge case that should be handled explicitly.

## Fix Focus Areas
- src/Components/MudStaticSwitch.razor.cs[30-33]
- src/Components/MudStaticSwitch.razor.cs[38-39]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Uncached enum reflection 🐞 Bug ➹ Performance
Description
ToEnumDescriptionString uses reflection (GetField + GetCustomAttributes) on every call and is
invoked during component rendering, which can add avoidable overhead in pages with many
components/rerenders.
Code

src/Enums/EnumExtensions.cs[R17-30]

+        public static string ToEnumDescriptionString(this Enum value)
+        {
+            var field = value.GetType().GetField(value.ToString());
+            if (field is null)
+            {
+                return value.ToString().ToLower();
+            }
+
+            var attributes = Attribute.GetCustomAttributes(field, typeof(DescriptionAttribute), false) as DescriptionAttribute[];
+
+            return attributes is { Length: > 0 }
+                ? attributes[0].Description
+                : value.ToString().ToLower();
+        }
Evidence
The extension method performs reflection each time it is called. It is used directly in Razor markup
for Typo and ButtonType, so it runs as part of render output generation.

src/Enums/EnumExtensions.cs[17-29]
src/Components/MudStaticSwitch.razor[27-36]
src/Components/MudStaticButton.razor[53-58]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`ToEnumDescriptionString` does reflection on every invocation and is called during rendering. This can cause avoidable overhead on component-heavy pages.

### Issue Context
Calls occur from Razor markup (`Typo.Value.ToEnumDescriptionString()`) and from button rendering (`ButtonType.Submit.ToEnumDescriptionString()`).

### Fix Focus Areas
- src/Enums/EnumExtensions.cs[17-30]
- src/Components/MudStaticSwitch.razor[27-36]
- src/Components/MudStaticButton.razor[53-58]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the codebase to support MudBlazor v9.0.0-rc.1 by replacing the removed ToDescriptionString method with a new ToEnumDescriptionString extension method and direct ToString().ToLower() calls where appropriate. The changes are correct and address the breaking change. I've added a few suggestions to improve the new extension method's performance and documentation, and to enhance code readability in one of the Razor components.

@Anu6is Anu6is merged commit 1191f1e into 0phois:master Feb 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants