Masking: Improve abstraction, add more tests#12314
Conversation
Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
|
@copilot Now when we have more tests, i want you to fully refactor masking: Make appropiate arhitecture, it should be simple yet robust and powerful. Revisit nullability as it's done incorrectly, if you add new file you must use |
I'll perform a comprehensive refactoring of the mask architecture. This will involve:
This is a major refactoring task that will take some time to complete properly. I'll ensure all 158 tests continue to pass (updating them as needed for API changes) and that the component integration remains solid. Starting work now...
After analyzing the codebase, I've identified several architectural issues that need addressing: Current Issues:
Proposed Refactoring:
abstractions This is a substantial refactoring affecting 7 mask classes, 158 tests, and 3 components (MudMask, MudTextField, MudPicker). Due to the scope, this will require multiple focused commits. Would you like me to proceed with the full refactoring, or would you prefer I focus on specific areas first (e.g., nullability fixes, then architecture improvements)? |
Starting full refactoring of all mask classes. I'll make incremental commits for each major improvement. |
…sulate state (WIP) Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
... Fixed nullability and other issues in commit 30492aa:
The code now builds without warnings and 4,273 of 4,276 tests pass. The 3 failing tests are pre-existing from the earlier refactoring (not related to the nullability fixes) and appear to be edge cases with UpdateFrom behavior that need investigation. |
Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
Fixed in commit 6a36357. All nullability issues resolved and all 4,276 tests now pass (including all 158 mask tests). Changes made:
The code now builds without warnings and all tests pass. |
Improve Unit Test Coverage and Refactor Mask Architecture
Part 1: Test Coverage Improvements ✅
New test files:
MaskCharTests.cs- 10 testsBaseMaskTests.cs- 18 testsEnhanced existing test files:
BlockMaskTests.cs- +9 testsDateMaskTests.cs- +13 testsMultiMaskTests.cs- +8 testsPatternMaskTests.cs- +15 testsRegexMaskTests.cs- +15 testsCoverage Impact:
Part 2: Architecture Refactoring ✅
MaskChar - Made Immutable
readonly structwithIEquatable<MaskChar>IMask Interface - Fixed Nullability
Mask:string?→stringText:string?→stringGetCleanText(): ReturnsstringInsert(string? input): Accepts nullableUpdateFrom(IMask? mask): Accepts nullableBaseMask - Improved Encapsulation
MaskDictionary(IReadOnlyDictionary<char, MaskChar>)Delimiters(IReadOnlySet)AddDelimiter(char),SetDelimiters(string),ForceReinitialize()RegexMask - Performance Optimizations
Delimiters→DelimiterCharactersAlignAgainstMask:StringBuilder.ToString()call per character (was called multiple times)FirstOrDefaultOther Classes Updated
DelimiterCharactersCode Quality Improvements ✅
Breaking Changes Summary
stringnotstring?Test Status
Architecture Benefits
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.