Skip to content

[Change Safety] Generator: emit GetDynamicParametersValue delegate + IDynamicParameters on write cmdlets (Stages C+D)#1548

Closed
YangAn-microsoft wants to merge 2 commits into
Azure:mainfrom
YangAn-microsoft:feature/change-safety-generator
Closed

[Change Safety] Generator: emit GetDynamicParametersValue delegate + IDynamicParameters on write cmdlets (Stages C+D)#1548
YangAn-microsoft wants to merge 2 commits into
Azure:mainfrom
YangAn-microsoft:feature/change-safety-generator

Conversation

@YangAn-microsoft

Copy link
Copy Markdown

Summary

Generator support for bringing the Change Safety feature (-AcquirePolicyToken / -ChangeReference) to AutoRest-generated cmdlets. Two commits:

  • Stage C (powershell/module/module-class.ts, powershell/generators/psm1.ts): the generated Module.cs gains a GetDynamicParametersValue VTable delegate property plus a GetDynamicParameters(invocationInfo, correlationId) wrapper method (mirroring the existing GetParameterValue/GetParameter pattern), and the generated .psm1 wires $instance.GetDynamicParametersValue = $VTable.GetDynamicParametersValue. Inert until a cmdlet calls it (Stage D).
  • Stage D (powershell/cmdlets/class.ts, powershell/internal/powershell-declarations.ts): generated write-verb cmdlets (HTTP PUT/POST/DELETE/PATCH) implement System.Management.Automation.IDynamicParameters and emit GetDynamicParameters() => Module.Instance.GetDynamicParameters(this.InvocationInformation, __correlationId). Read-verb cmdlets (GET/HEAD) get a zero diff. Emit is gated to azure projects (where the VTable / __correlationId exist).

Why / dependencies

AutoRest cmdlets don't inherit AzurePSCmdlet, so Change Safety is injected via the Register-AzModule VTable — the same mechanism as auth/telemetry/completers. This generator change is consumed by modules at regeneration time.

Verification

Built the generator, ESLint clean, unit tests pass. Smoke-generation of an azure spec confirms: a write cmdlet (New-*) implements IDynamicParameters and emits the wrapper call; a Get-* cmdlet has no such member (zero diff). The generated Module.cs exposes GetDynamicParametersValue + the GetDynamicParameters wrapper, and the .psm1 wires the delegate.

Rollout

Ships as a @autorest/powershell release; azure-powershell adopts it per-module at regeneration (pilot module first, then batched) — no module changes here.

@YangAn-microsoft

Copy link
Copy Markdown
Author

Superseded by #1549. The dynamic-parameter approach here (runtime-wired VTable GetDynamicParameters delegate + generated IDynamicParameters) was replaced, per review feedback, with codegen-owned static parameters — simpler and with no cross-repo runtime coupling. See #1549 and the design in Azure/CLIPS#408.

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.

1 participant