Add WrapperGenerator: a standalone cmdlet generator that reproduces published MS Graph cmdlet names - #3678
Add WrapperGenerator: a standalone cmdlet generator that reproduces published MS Graph cmdlet names#3678Joywambui-maina wants to merge 7 commits into
Conversation
The 1ES Official template injects an SDL source-analysis stage that must run on a Windows pool; the template-level pool was Linux, causing 'Please specify a windows pool for SDLSources stage'. Set template-level pool to the Windows pool (1es-windows-ps-compute-m) and keep the Linux pool override on the container build job, mirroring sdk-release.yml. Copilot-Session: d3f8fec7-b00b-46be-ba39-7e1f3e7f7188 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…er Hub (#3671) On the network-isolated 1ES pool the agent cannot reach registry-1.docker.io, so 'docker run tonistiigi/binfmt' and 'docker buildx create' (which pull moby/buildkit) fail with a connection timeout. Replace the local docker/buildx path with a server-side 'az acr build': ACR pulls the base from MCR and pushes the result, with no local Docker daemon, no QEMU/binfmt, and no Docker Hub dependency. Copilot-Session: d3f8fec7-b00b-46be-ba39-7e1f3e7f7188 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add -LoginHint parameter to Connect-MgGraph Adds a new optional -LoginHint parameter to Connect-MgGraph (UserParameterSet) that pre-populates the account (login_hint) shown during interactive browser / WAM sign-in. This lets callers go straight to the preferred sign-in method for a known account instead of navigating the WAM account picker. - Flow the login hint through IAuthContext / AuthContext and onto InteractiveBrowserCredentialOptions.LoginHint. - Persist a per-account AuthenticationRecord (keyed by a hashed, normalized login hint) so repeat sign-ins for the same account are picker-free, while never silently reusing a different user's record. Existing shared records are migrated to per-account records only when the username matches the supplied hint. - Scope cache clearing and auth-record deletion on Disconnect-MgGraph to the correct per-account record. - Add unit tests and parameter-set tests, plus docs and an example. Closes #3605 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 04338979-a6b1-4abe-9ffe-42eb16b07442 * Document -LoginHint parameter in Connect-MgGraph help Add the missing -LoginHint parameter block to the Connect-MgGraph markdown docs and generated MAML help (syntax + parameter list), which the earlier docs regeneration omitted because the module DLL predated the new parameter. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 04338979-a6b1-4abe-9ffe-42eb16b07442 * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ramses Sanchez-Hernandez <63934382+ramsessanchez@users.noreply.github.com>
Co-authored-by: Microsoft Graph DevX Tooling <GraphTooling@service.microsoft.com>
* commit verified beta-openapi files * Revert changes to beta CloudCommunications OpenAPI doc Restore openApiDocs/beta/CloudCommunications.yml to its state on main, reverting the changes introduced in 4f94630. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e1b9ad7f-768f-4a7d-ba78-e57c8d36c1d2 * verified open api v1 docs * Revert changes to openApiDocs/v1.0/Files.yml to match main Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 96aee07c-3d37-40de-9eb7-fd2658ad9825 * update xunit versions --------- Co-authored-by: Microsoft Graph DevX Tooling <GraphTooling@service.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e1b9ad7f-768f-4a7d-ba78-e57c8d36c1d2 Copilot-Session: 96aee07c-3d37-40de-9eb7-fd2658ad9825
…h cmdlet-name parity checks and unit tests
|
@Joywambui-maina please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Adds a new standalone tools/WrapperGenerator .NET CLI that generates Microsoft Graph PowerShell wrapper cmdlets with deterministic, path-based naming intended to exactly match the published SDK cmdlet surface, along with parity validation tooling and a set of unit tests. The PR also extends Connect-MgGraph to support -LoginHint for interactive sign-in and updates related authentication docs/specs and pipeline assets.
Changes:
- Introduces
tools/WrapperGenerator(naming engine + emitter) andtools/Compare-WrapperCmdletNames.ps1parity gate againstMgCommandMetadata.json. - Adds a new
-LoginHintparameter toConnect-MgGraphand updates auth record persistence to support per-account auth record reuse/migration. - Updates various docs and OpenAPI description files, plus an Azure Pipelines image refresh pipeline tweak.
Reviewed changes
Copilot reviewed 35 out of 104 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/WrapperGenerator/WrapperGenerator.csproj | New CLI project definition for WrapperGenerator (TFM/packages). |
| tools/WrapperGenerator/Singularizer.cs | Implements per-word singularization rules used to derive nouns from URL path segments. |
| tools/WrapperGenerator/SchemaProperties.cs | Extracts shallow primitive body properties into cmdlet parameters for New/Update emitters. |
| tools/WrapperGenerator/README.md | Documents the naming algorithm, list/item GET pairing behavior, and current limitations. |
| tools/WrapperGenerator/Program.cs | CLI entry point: reads OpenAPI, applies include-path filtering, runs generation, writes lock file. |
| tools/WrapperGenerator/PowerShellWrapperGenerationService.cs | Orchestrates generation across operations; handles GET pairing and schema/type resolution. |
| tools/WrapperGenerator/OperationInfo.cs | Operation metadata record used for naming/emission decisions. |
| tools/WrapperGenerator/NamingOverrides.cs | Data-driven naming suppressions/overrides to mirror published SDK directives. |
| tools/WrapperGenerator/IncludePathFilter.cs | Implements --include-path glob + method filtering on the OpenAPI document. |
| tools/WrapperGenerator/GeneratorExtensions.cs | Shared string/schema helper extensions (case conversion, $ref id access). |
| tools/WrapperGenerator/GeneratorConfig.cs | Run configuration record (client namespace + output path). |
| tools/WrapperGenerator/EmitContext.cs | Emitter context (client namespace, cmdlet namespace). |
| tools/WrapperGenerator/CmdletNaming.cs | Builds cmdlet verb/noun/class names and Kiota builder expressions from operations/paths. |
| tools/WrapperGenerator.Tests/WrapperGenerator.Tests.csproj | New test project for WrapperGenerator naming/emission behavior. |
| tools/WrapperGenerator.Tests/SchemaPropertiesTests.cs | Unit tests for primitive property extraction and passwordProfile detection. |
| tools/WrapperGenerator.Tests/NamingTests.cs | Unit tests pinning naming/builder-expression behavior to published SDK names. |
| tools/WrapperGenerator.Tests/GenerationServiceRegressionTests.cs | Regression tests ensuring unsupported shapes are skipped without throwing. |
| tools/WrapperGenerator.Tests/EmitterTests.cs | Tests for correct escaping of spec-derived string literals in emitted C#. |
| tools/Compare-WrapperCmdletNames.ps1 | Parity gate that reconstructs Method+URI from generated sources and joins against the oracle. |
| src/Authentication/examples/Connect-MgGraph.md | Adds an example showing -LoginHint usage. |
| src/Authentication/docs/Set-MgRequestContext.md | Updates docs (incl. ProgressAction common parameter content). |
| src/Authentication/docs/Set-MgGraphOption.md | Adds a sovereign-cloud/WAM workaround example and updates ProgressAction text. |
| src/Authentication/docs/Set-MgEnvironment.md | Updates docs (incl. ProgressAction common parameter content). |
| src/Authentication/docs/Remove-MgEnvironment.md | Updates docs (incl. ProgressAction common parameter content). |
| src/Authentication/docs/Microsoft.Graph.Authentication.md | Updates module metadata and Set-MgGraphOption description wording. |
| src/Authentication/docs/Invoke-MgGraphRequest.md | Updates docs (incl. ProgressAction common parameter content). |
| src/Authentication/docs/Get-MgRequestContext.md | Updates docs (incl. ProgressAction common parameter content). |
| src/Authentication/docs/Get-MgGraphOption.md | Updates docs (incl. ProgressAction text and WAM note). |
| src/Authentication/docs/Get-MgEnvironment.md | Updates environment list example and adds ProgressAction parameter docs. |
| src/Authentication/docs/Get-MgContext.md | Updates docs to include ProgressAction common parameter section. |
| src/Authentication/docs/Disconnect-MgGraph.md | Reorders/updates parameter documentation (ProgressAction + SignOutFromBroker). |
| src/Authentication/docs/Connect-MgGraph.md | Documents -LoginHint, adds sovereign cloud examples, and updates syntax blocks. |
| src/Authentication/docs/Add-MgEnvironment.md | Updates docs (incl. ProgressAction common parameter content). |
| src/Authentication/Authentication/test/Connect-MgGraph.Tests.ps1 | Adds assertions that LoginHint exists only in UserParameterSet. |
| src/Authentication/Authentication/Models/AuthContext.cs | Adds LoginHint to the auth context model. |
| src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 | Updates module version and generated-on metadata. |
| src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec | Bumps package version to 2.38.1. |
| src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj | Bumps project version to 2.38.1. |
| src/Authentication/Authentication/Microsoft.Graph.Authentication-help.xml | Help text formatting updates (line wrapping/paragraph reflow). |
| src/Authentication/Authentication/Constants.cs | Adds help message string for the new LoginHint parameter. |
| src/Authentication/Authentication/Cmdlets/ConnectMgGraph.cs | Adds -LoginHint parameter and wires it into the delegated interactive auth flow. |
| src/Authentication/Authentication.Test/Microsoft.Graph.Authentication.Test.csproj | Updates test project/package versions. |
| src/Authentication/Authentication.Test/Helpers/AuthenticationHelpersTests.cs | Adds tests for per-account auth record paths and login-hint-based record resolution. |
| src/Authentication/Authentication.Core/Utilities/AuthenticationHelpers.cs | Implements login hint plumbing for InteractiveBrowserCredential and per-account auth record storage/migration. |
| src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj | Bumps core library version to 2.38.1. |
| src/Authentication/Authentication.Core/Interfaces/IAuthContext.cs | Adds LoginHint to the auth context interface. |
| src/Applications/beta/examples/Get-MgBetaServicePrincipalSynchronizationTemplate.md | Removes an example markdown file. |
| openApiDocs/v1.0/Users.Functions.yml | OpenAPI description updates (property description changes/metadata tweaks). |
| openApiDocs/v1.0/Users.Actions.yml | OpenAPI description updates (property description changes/metadata tweaks). |
| openApiDocs/v1.0/Search.yml | OpenAPI description updates (enum/member additions and description tweaks). |
| openApiDocs/v1.0/SchemaExtensions.yml | Minor OpenAPI wording change (“doesn't” vs “does not”). |
| openApiDocs/v1.0/Reports.yml | OpenAPI description wording updates for several endpoints. |
| openApiDocs/v1.0/Devices.ServiceAnnouncement.yml | OpenAPI wording/read-only wording updates. |
| openApiDocs/v1.0/Devices.CorporateManagement.yml | OpenAPI schema updates (new props/descriptions/read-only wording). |
| openApiDocs/v1.0/CrossDeviceExperiences.yml | OpenAPI description addition for JSON blob schema. |
| openApiDocs/v1.0/ConfigurationManagement.yml | OpenAPI description addition for JSON blob schema. |
| openApiDocs/v1.0/Compliance.yml | OpenAPI schema wording/description updates. |
| openApiDocs/v1.0/CloudCommunications.yml | OpenAPI wording updates and some schema description removals. |
| openApiDocs/v1.0/Calendar.yml | OpenAPI schema updates (placeId/servicePlans/service plan schema). |
| openApiDocs/v1.0/Bookings.yml | OpenAPI wording updates and new backup/notification-related schemas. |
| openApiDocs/v1.0/BackupRestore.yml | Adds emailNotificationsSetting endpoints/schemas under /solutions/backupRestore. |
| openApiDocs/beta/Search.yml | Beta OpenAPI additions (informationProtectionLabel, enum member, wording). |
| openApiDocs/beta/Migrations.yml | Beta OpenAPI wording updates and removal of deprecated validate action path. |
| openApiDocs/beta/Devices.ServiceAnnouncement.yml | Beta OpenAPI wording/read-only wording updates. |
| openApiDocs/beta/ChangeNotifications.yml | Adds Web Push-related subscription properties in beta schema. |
| openApiDocs/beta/Calendar.yml | Removes outdated placeId description text in beta schema. |
| openApiDocs/beta/Bookings.yml | Beta OpenAPI schema additions/description updates. |
| openApiDocs/beta/BackupRestore.yml | Beta OpenAPI schema additions (structuredQueryExpression/error/enums). |
| .gitignore | Adds sweep_results.json to ignored artifacts. |
| .azure-pipelines/docker-image-refresh.yml | Switches docker image refresh to ACR Tasks (az acr build) and adds pool parameters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <ImplicitUsings>disable</ImplicitUsings> |
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <OutputType>Exe</OutputType> | ||
| <ImplicitUsings>disable</ImplicitUsings> |
| authContext.ContextScope = this.IsParameterBound(nameof(ContextScope)) ? ContextScope : ContextScope.CurrentUser; | ||
| } | ||
| if (this.IsParameterBound(nameof(LoginHint)) && !string.IsNullOrWhiteSpace(LoginHint)) | ||
| authContext.LoginHint = LoginHint; | ||
| authContext.TokenCredentialType = UseDeviceCode ? TokenCredentialType.DeviceCode : TokenCredentialType.InteractiveBrowser; |
Changes proposed in this pull request
tools/WrapperGenerator, a standalone .NET CLI that generates the C# cmdletclasses behind commands like
Get-MgUserMessagefrom Graph's OpenAPI description.The generated cmdlets call a Kiota-generated C# client (produced separately by
kiota generate). This was previously prototyped as a-l PowerShellWrapperlanguage option inside kiota itself (PowerShell wrapper Phase 1: cmdlet generation for the first 15 Graph modules microsoft/kiota#7986, closed); it moves here
because the naming rules are Graph-specific — they mirror this repo's module
configs and command inventory — so they belong next to the SDK, not in a
general-purpose generator.
the operationId, so the same OpenAPI input always yields the same cmdlet name and
naming and request routing share one source of truth.
(
NamingOverrides.cs, 3 entries, each citing the AutoRest directive it mirrors),and skip operations the published SDK deliberately does not ship.
dispatcher cmdlet with
List/Getparameter sets forwarding to internal_List/_Getcmdlets.names taken from
MgCommandMetadata.json.tools/Compare-WrapperCmdletNames.ps1, a parity gate that reconstructs eachgenerated cmdlet's HTTP method + URI from its source and joins it against
MgCommandMetadata.json(the inventory behindFind-MgGraphCommand), exitingnon-zero on any name mismatch.
tools/WrapperGenerator/README.md,with a shipping cmdlet as evidence for each rule, plus known gaps (no module
wiring yet, shallow body binding, no
$count/$ref/delta/actions).Why
Customer scripts depend on the exact cmdlet names the SDK ships —
Get-MgUserMessage,not
Get-MgUsersMessages. When nouns are derived from operationIds, generated namesleak whatever plurality the spec author chose, and the current AutoRest pipeline has
quietly dropped cmdlets when names collided. For a regenerated module to be a drop-in
replacement, name parity is the hard requirement, so most of this tool is a naming
engine: deterministic path-based nouns, per-word singularization rules, and the few
genuinely hand-tuned published names kept as reviewable data with a cited source each
rather than special cases in code.
Validation
dotnet test tools/WrapperGenerator.Tests— Passed: 69, Failed: 0..\tools\Compare-WrapperCmdletNames.ps1→Mail [v1.0]: 4 of 4 cmdlets match the oracle, exit code 0.Kiota-generated client. Wiring both into a buildable module is documented as
later work in the README.