Add maui errors list command for error code introspection#202
Conversation
Adds ErrorCodeDescriptor model, ErrorCodeCatalogue static catalogue, and the 'maui errors list [--category] [--prefix] [--json]' command. The catalogue covers all 23 registered error codes in ErrorCodes.cs. The reflection-based test Catalogue_CoversEveryConstantInErrorCodes will catch future drift when new codes are added. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Expert Code Review — PR #202Methodology: 3 independent reviewers with adversarial consensus (2-reviewer fallback — 1 reviewer's detailed output was unavailable) Result: 1 finding posted as inline comment (1 minor) CI Status✅ Build passes on both macOS and Windows Test Coverage✅ PR includes 17 unit tests with reflection-based drift detection covering the catalogue, filters, serialization, and command registration Discarded Findings (single-reviewer only, no consensus)
|
There was a problem hiding this comment.
Expert Review — maui errors list Command
Good addition overall. The reflection-based drift test (Catalogue_CoversEveryConstantInErrorCodes) is an excellent pattern. Two moderate issues worth addressing before merge:
Findings
| # | Severity | File | Line | Issue | Recommendation |
|---|---|---|---|---|---|
| 1 | 🟡 MODERATE | ErrorsCommands.cs |
50 | Non-Spectre formatter in non-JSON mode silently produces zero output and returns success. | Add fallback else branch (plain-text output or error). |
| 2 | 🟡 MODERATE | ErrorsCommands.cs |
33–37 | --category and --prefix supplied together silently ignores --prefix with no warning. |
Either enforce mutual exclusivity with an error, or compose both filters (AND semantics). |
| 3 | 🟡 MODERATE | ErrorsCommands.cs |
39–41 | JSON mode emits {"codes":[],"count":0} for empty results with no warning, while non-JSON mode prints a warning. Asymmetric UX for consumers. |
Document or harmonize behavior across output modes. |
| 4 | 🟢 MINOR | ErrorCodeCatalogue.cs |
38–42 | ByCategory/ByPrefix allocate a new list per call. |
Fine for CLI use; consider lazy IEnumerable if reused in hot paths. |
| 5 | 🟢 MINOR | MauiCliJsonContext.cs |
50 | List<ErrorCodeDescriptor> registration appears unused (property is IReadOnlyList). |
Remove or retain intentionally — no runtime impact. |
Generated by Expert Code Review (auto) for issue #202 · ● 7.5M
| IReadOnlyList<ErrorCodeDescriptor> codes = category is not null | ||
| ? ErrorCodeCatalogue.ByCategory(category) | ||
| : prefix is not null | ||
| ? ErrorCodeCatalogue.ByPrefix(prefix) | ||
| : ErrorCodeCatalogue.All; |
There was a problem hiding this comment.
🟢 MINOR · Consensus: 2/2 reviewers
--prefix is silently discarded when --category is also supplied.
maui errors list --category platform --prefix E21 silently ignores --prefix and returns all platform errors instead of only Android codes. The user receives no indication that one filter was dropped.
Suggestion: Either make the options mutually exclusive with a validation error, or AND the filters together:
IReadOnlyList<ErrorCodeDescriptor> codes = ErrorCodeCatalogue.All
.Where(d => category is null || d.Category.Equals(category, StringComparison.OrdinalIgnoreCase))
.Where(d => prefix is null || d.Code.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
.ToList();Previously --prefix was silently ignored when --category was supplied. Now filters apply intersectionally: --category narrows first, --prefix refines further. Resolves PR #202 minor finding. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Adds the \maui errors list [--json]\ command that emits the registered error code catalogue, enabling AI agents and IDE consumers to statically verify they handle every \MauiToolException\ error code.
Changes
Usage
\
maui errors list
maui errors list --category platform
maui errors list --prefix E21
maui errors list --json
\\
The \Catalogue_CoversEveryConstantInErrorCodes\ test uses reflection on \ErrorCodes\ to catch future drift when new codes are added.