Skip to content

Add WrapperGenerator: a standalone cmdlet generator that reproduces published MS Graph cmdlet names - #3678

Open
Joywambui-maina wants to merge 7 commits into
powershell-v3from
feature/wrapper-generator
Open

Add WrapperGenerator: a standalone cmdlet generator that reproduces published MS Graph cmdlet names#3678
Joywambui-maina wants to merge 7 commits into
powershell-v3from
feature/wrapper-generator

Conversation

@Joywambui-maina

Copy link
Copy Markdown

Changes proposed in this pull request

  • Add tools/WrapperGenerator, a standalone .NET CLI that generates the C# cmdlet
    classes behind commands like Get-MgUserMessage from 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 PowerShellWrapper
    language 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.
  • Build cmdlet nouns from the URL path, singularized word by word, instead of from
    the operationId, so the same OpenAPI input always yields the same cmdlet name and
    naming and request routing share one source of truth.
  • Reproduce the published SDK's hand-tuned names as checked-in data
    (NamingOverrides.cs, 3 entries, each citing the AutoRest directive it mirrors),
    and skip operations the published SDK deliberately does not ship.
  • Emit paired list/item GETs the way the published SDK exposes them: one public
    dispatcher cmdlet with List/Get parameter sets forwarding to internal
    _List/_Get cmdlets.
  • Add 69 unit tests whose expected values are published Microsoft.Graph cmdlet
    names taken from MgCommandMetadata.json.
  • Add tools/Compare-WrapperCmdletNames.ps1, a parity gate that reconstructs each
    generated cmdlet's HTTP method + URI from its source and joins it against
    MgCommandMetadata.json (the inventory behind Find-MgGraphCommand), exiting
    non-zero on any name mismatch.
  • Document the naming algorithm rule by rule in 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 names
leak 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.
  • Parity gate on a regenerated Mail module:
    .\tools\Compare-WrapperCmdletNames.ps1Mail [v1.0]: 4 of 4 cmdlets match the oracle, exit code 0.
  • Generated files are source, not a built module; they compile only alongside the
    Kiota-generated client. Wiring both into a buildable module is documented as
    later work in the README.

gavinbarron and others added 6 commits July 21, 2026 13:18
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
@Joywambui-maina
Joywambui-maina requested a review from a team as a code owner July 28, 2026 22:45
@Joywambui-maina
Joywambui-maina changed the base branch from main to powershell-v3 July 28, 2026 23:20
@Joywambui-maina
Joywambui-maina requested a review from Copilot July 28, 2026 23:20
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

@Joywambui-maina please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
and conveys certain license rights to Microsoft Corporation and its affiliates (“Microsoft”) for Your
contributions to Microsoft open source projects. This Agreement is effective as of the latest signature
date below.

  1. Definitions.
    “Code” means the computer software code, whether in human-readable or machine-executable form,
    that is delivered by You to Microsoft under this Agreement.
    “Project” means any of the projects owned or managed by Microsoft and offered under a license
    approved by the Open Source Initiative (www.opensource.org).
    “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
    Project, including but not limited to communication on electronic mailing lists, source code control
    systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
    discussing and improving that Project, but excluding communication that is conspicuously marked or
    otherwise designated in writing by You as “Not a Submission.”
    “Submission” means the Code and any other copyrightable material Submitted by You, including any
    associated comments and documentation.
  2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
    Project. This Agreement covers any and all Submissions that You, now or in the future (except as
    described in Section 4 below), Submit to any Project.
  3. Originality of Work. You represent that each of Your Submissions is entirely Your original work.
    Should You wish to Submit materials that are not Your original work, You may Submit them separately
    to the Project if You (a) retain all copyright and license information that was in the materials as You
    received them, (b) in the description accompanying Your Submission, include the phrase “Submission
    containing materials of a third party:” followed by the names of the third party and any licenses or other
    restrictions of which You are aware, and (c) follow any other instructions in the Project’s written
    guidelines concerning Submissions.
  4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
    for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
    Submission is made in the course of Your work for an employer or Your employer has intellectual
    property rights in Your Submission by contract or applicable law, You must secure permission from Your
    employer to make the Submission before signing this Agreement. In that case, the term “You” in this
    Agreement will refer to You and the employer collectively. If You change employers in the future and
    desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
    and secure permission from the new employer before Submitting those Submissions.
  5. Licenses.
  • Copyright License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the
    Submission to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute
    the Submission and such derivative works, and to sublicense any or all of the foregoing rights to third
    parties.
  • Patent License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under
    Your patent claims that are necessarily infringed by the Submission or the combination of the
    Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
    import or otherwise dispose of the Submission alone or with the Project.
  • Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
    No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
    granted by implication, exhaustion, estoppel or otherwise.
  1. Representations and Warranties. You represent that You are legally entitled to grant the above
    licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
    have disclosed under Section 3). You represent that You have secured permission from Your employer to
    make the Submission in cases where Your Submission is made in the course of Your work for Your
    employer or Your employer has intellectual property rights in Your Submission by contract or applicable
    law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
    have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
    You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
    REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
    EXPRESSLY STATED IN SECTIONS 3, 4, AND 6, THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
    PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
    NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
  2. Notice to Microsoft. You agree to notify Microsoft in writing of any facts or circumstances of which
    You later become aware that would make Your representations in this Agreement inaccurate in any
    respect.
  3. Information about Submissions. You agree that contributions to Projects and information about
    contributions may be maintained indefinitely and disclosed publicly, including Your name and other
    information that You submit with Your Submission.
  4. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
    the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
    Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
    exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
    defenses of lack of personal jurisdiction and forum non-conveniens.
  5. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
    supersedes any and all prior agreements, understandings or communications, written or oral, between
    the parties relating to the subject matter hereof. This Agreement may be assigned by Microsoft.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) and tools/Compare-WrapperCmdletNames.ps1 parity gate against MgCommandMetadata.json.
  • Adds a new -LoginHint parameter to Connect-MgGraph and 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.

Comment on lines +3 to +6
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
Comment on lines +3 to +6
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<ImplicitUsings>disable</ImplicitUsings>
Comment on lines 199 to 203
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;
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.

4 participants