fix(wrapper-generator): fail loudly on cmdlet file collisions - #3713
Open
Joywambui-maina wants to merge 1 commit into
Open
fix(wrapper-generator): fail loudly on cmdlet file collisions#3713Joywambui-maina wants to merge 1 commit into
Joywambui-maina wants to merge 1 commit into
Conversation
A second operation resolving to an already-written cmdlet file now fails generation with the full collision list instead of silently overwriting it, which is the silent-drop failure mode AutoRest had. OData cast list/item pairs (owners/graph.user) now merge like plain pairs, and the sweep's collisions land as cited NamingOverrides entries: termStore and agreement-file stitches, default-singleton renames (SubSite, DefaultDrive, DefaultCalendarEvent), and nested navs the SDK never shipped. Remaining families are tracked on #3704.
Joywambui-maina
requested review from
Peter Ombwa (peombwa) and
Ramses Sanchez-Hernandez (ramsessanchez)
and
a lite review from Copilot
August 11, 2026 17:34
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the WrapperGenerator to prevent silent cmdlet loss by detecting and failing on cmdlet file name collisions, and expands the naming-override data/model to encode published-SDK renames/suppressions (including broad “suffix” matching for recurring navigations). It also adjusts GET list/item pairing to merge OData cast list/item pairs into a single dispatcher cmdlet, and updates tests/docs accordingly.
Changes:
- Detect cmdlet
.g.csfile collisions during generation and fail with a consolidated, operation-identifying error message. - Extend
NamingOverridesto support exact/prefix/suffix path matching and add many oracle-/directive-cited rename/suppression entries to resolve known collisions. - Merge cast list/item GET pairs (e.g.,
.../owners/graph.userwith.../owners/{id}/graph.user) into one Get-* dispatcher; add regression/unit tests and documentation updates.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/WrapperGenerator/README.md | Updates documentation to reflect collision-guard behavior and expanded overrides/testing counts. |
| tools/WrapperGenerator/PowerShellWrapperGenerationService.cs | Tracks written files to detect collisions and throws a consolidated exception at end of generation. |
| tools/WrapperGenerator/NamingOverrides.cs | Reworks override matching to Exact/Prefix/Suffix and adds many new rename/suppression entries with citations. |
| tools/WrapperGenerator/edge-cases/naming-edge-cases.md | Documents collision families and how they’re handled/resolved. |
| tools/WrapperGenerator/CmdletNaming.cs | Enhances list/item merge detection to support OData cast list/item pairing. |
| tools/WrapperGenerator.Tests/NamingTests.cs | Adds unit coverage for new overrides and cast list/item pairing behavior. |
| tools/WrapperGenerator.Tests/GenerationServiceRegressionTests.cs | Adds regression test ensuring collisions fail loudly and identify both operations. |
| tools/Build-WrapperModule.ps1 | Improves failure capture to surface the generator exception text in build output summaries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -298,6 +316,15 @@ private async Task<int> EmitGetOperationsAsync(List<GetOperationRecord> getOpera | |||
| private async Task<int> WriteCmdletFileAsync(CmdletNaming naming, string source, CancellationToken cancellationToken) | |||
| { | |||
| var fileName = naming.ClassName.Replace("Command", "", StringComparison.Ordinal) + ".g.cs"; | |||
Comment on lines
+149
to
+151
| $lines = @($wrapperOut | ForEach-Object { "$_" }) | ||
| $exception = $lines | Where-Object { $_ -match 'Unhandled exception|Exception:' } | Select-Object -First 1 | ||
| $exceptionIndex = if ($exception) { $lines.IndexOf($exception) } else { -1 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request
Other links