@autorest/powershell 4.0.0-dev.3 → 4.0.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +36 -33
- package/.rush/temp/shrinkwrap-deps.json +13 -19
- package/dist/cmdlets/class.d.ts +1 -0
- package/dist/cmdlets/class.d.ts.map +1 -1
- package/dist/cmdlets/class.js +128 -79
- package/dist/cmdlets/class.js.map +1 -1
- package/dist/cmdlets/namespace.d.ts.map +1 -1
- package/dist/cmdlets/namespace.js +2 -1
- package/dist/cmdlets/namespace.js.map +1 -1
- package/dist/enums/namespace.js.map +1 -1
- package/dist/generators/inputhandler.custom.d.ts +3 -0
- package/dist/generators/inputhandler.custom.d.ts.map +1 -0
- package/dist/generators/inputhandler.custom.js +32 -0
- package/dist/generators/inputhandler.custom.js.map +1 -0
- package/dist/generators/psm1.js +1 -1
- package/dist/generators/psm1.js.map +1 -1
- package/dist/internal/project.d.ts +11 -9
- package/dist/internal/project.d.ts.map +1 -1
- package/dist/internal/project.js +5 -2
- package/dist/internal/project.js.map +1 -1
- package/dist/llcsharp/clientruntime.d.ts +2 -0
- package/dist/llcsharp/clientruntime.d.ts.map +1 -1
- package/dist/llcsharp/clientruntime.js +2 -0
- package/dist/llcsharp/clientruntime.js.map +1 -1
- package/dist/llcsharp/enums/enum.js +1 -1
- package/dist/llcsharp/enums/enum.js.map +1 -1
- package/dist/llcsharp/model/interface.d.ts.map +1 -1
- package/dist/llcsharp/model/interface.js.map +1 -1
- package/dist/llcsharp/model/model-class.js +7 -8
- package/dist/llcsharp/model/model-class.js.map +1 -1
- package/dist/llcsharp/operation/method.d.ts.map +1 -1
- package/dist/llcsharp/operation/method.js +6 -6
- package/dist/llcsharp/operation/method.js.map +1 -1
- package/dist/llcsharp/project.d.ts.map +1 -1
- package/dist/llcsharp/project.js +2 -1
- package/dist/llcsharp/project.js.map +1 -1
- package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
- package/dist/llcsharp/schema/date-time.js.map +1 -1
- package/dist/llcsharp/schema/password.js +1 -1
- package/dist/llcsharp/schema/password.js.map +1 -1
- package/dist/llcsharp/schema/primitive.js.map +1 -1
- package/dist/llcsharp/schema/string.d.ts.map +1 -1
- package/dist/llcsharp/schema/string.js.map +1 -1
- package/dist/models/model-extensions.js +6 -6
- package/dist/models/model-extensions.js.map +1 -1
- package/dist/module/module-class.js.map +1 -1
- package/dist/plugins/create-commands-v2.d.ts.map +1 -1
- package/dist/plugins/create-commands-v2.js.map +1 -1
- package/dist/plugins/cs-namer-v2.js +1 -1
- package/dist/plugins/cs-namer-v2.js.map +1 -1
- package/dist/plugins/modifiers-v2.d.ts +4 -0
- package/dist/plugins/modifiers-v2.d.ts.map +1 -1
- package/dist/plugins/modifiers-v2.js +65 -10
- package/dist/plugins/modifiers-v2.js.map +1 -1
- package/dist/plugins/plugin-tweak-m4-model.js +2 -2
- package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
- package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
- package/dist/plugins/plugin-tweak-model.js +2 -2
- package/dist/plugins/plugin-tweak-model.js.map +1 -1
- package/dist/plugins/powershell-v2.d.ts.map +1 -1
- package/dist/plugins/powershell-v2.js +2 -0
- package/dist/plugins/powershell-v2.js.map +1 -1
- package/dist/utils/command-operation.d.ts +1 -0
- package/dist/utils/command-operation.d.ts.map +1 -1
- package/dist/utils/command-operation.js.map +1 -1
- package/dist/utils/powershell-comment.js +10 -10
- package/dist/utils/powershell-comment.js.map +1 -1
- package/package.json +3 -3
- package/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs +2 -2
- package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +5 -1
- package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +2 -0
- package/resources/runtime/csharp/client/Context.cs +33 -0
- package/resources/runtime/csharp/client/InfoAttribute.cs +1 -0
- package/resources/runtime/csharp/client/InputHandler.cs +22 -0
package/dist/cmdlets/class.js
CHANGED
|
@@ -160,7 +160,7 @@ function NewAddCompleterInfo(targetProperty, parameter) {
|
|
|
160
160
|
exports.NewAddCompleterInfo = NewAddCompleterInfo;
|
|
161
161
|
function addParameterBreakingChange(targetProperty, parameter) {
|
|
162
162
|
if (parameter.breakingChange) {
|
|
163
|
-
|
|
163
|
+
const parameters = [];
|
|
164
164
|
parameters.push(`"${parameter.breakingChange.parameterName}"`);
|
|
165
165
|
if (parameter.breakingChange.deprecateByVersion) {
|
|
166
166
|
parameters.push(`"${parameter.breakingChange.deprecateByVersion}"`);
|
|
@@ -180,7 +180,7 @@ function addParameterBreakingChange(targetProperty, parameter) {
|
|
|
180
180
|
}
|
|
181
181
|
else {
|
|
182
182
|
// for primitive types, should use name, otherwise use fullname which contains namespace
|
|
183
|
-
parameters.push(`OldParamaterType="${parameter.schema.language.csharp.fullname.startsWith(
|
|
183
|
+
parameters.push(`OldParamaterType="${parameter.schema.language.csharp.fullname.startsWith('<') ? parameter.schema.language.csharp.name : parameter.schema.language.csharp.fullname}"`);
|
|
184
184
|
}
|
|
185
185
|
parameters.push(`NewParameterType="${parameter.breakingChange.newParameterType}"`);
|
|
186
186
|
}
|
|
@@ -202,7 +202,8 @@ function addDefaultInfo(targetProperty, parameter) {
|
|
|
202
202
|
parameters: [
|
|
203
203
|
new codegen_csharp_1.LiteralExpression(`\nName = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo.name || '').value}`),
|
|
204
204
|
new codegen_csharp_1.LiteralExpression(`\nDescription =${new codegen_csharp_1.StringExpression(parameter.defaultInfo.description || '').value}`),
|
|
205
|
-
new codegen_csharp_1.LiteralExpression(`\nScript = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo.script).value}`)
|
|
205
|
+
new codegen_csharp_1.LiteralExpression(`\nScript = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo.script).value}`),
|
|
206
|
+
new codegen_csharp_1.LiteralExpression(`\nSetCondition = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo['set-condition'] || '').value}`)
|
|
206
207
|
]
|
|
207
208
|
}));
|
|
208
209
|
}
|
|
@@ -322,6 +323,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
322
323
|
this.variantName = variantName;
|
|
323
324
|
this.hasStreamOutput = false;
|
|
324
325
|
this.interfaces.push(exports_1.ClientRuntime.IEventListener);
|
|
326
|
+
this.interfaces.push(exports_1.ClientRuntime.IContext);
|
|
325
327
|
this.eventListener = new exports_1.EventListener(new codegen_csharp_1.LiteralExpression(`((${exports_1.ClientRuntime.IEventListener})this)`), true);
|
|
326
328
|
this.isViaIdentity = variantName.indexOf('ViaIdentity') > 0;
|
|
327
329
|
this.clientsidePagination = !!operation.details.csharp.clientsidePagination && !!((_a = operation.callGraph[0].language.csharp) === null || _a === void 0 ? void 0 : _a.pageable);
|
|
@@ -338,7 +340,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
338
340
|
*body() {
|
|
339
341
|
if ($this.state.project.azure) {
|
|
340
342
|
yield `var telemetryId = ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.GetTelemetryId.Invoke();`;
|
|
341
|
-
yield codegen_csharp_1.If('telemetryId != "" && telemetryId != "internal"',
|
|
343
|
+
yield codegen_csharp_1.If('telemetryId != "" && telemetryId != "internal"', '__correlationId = telemetryId;');
|
|
342
344
|
}
|
|
343
345
|
yield 'Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);';
|
|
344
346
|
yield codegen_csharp_1.If($this.$('Break'), `${exports_1.ClientRuntime.AttachDebugger}.Break();`);
|
|
@@ -356,6 +358,8 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
356
358
|
this.NewAddPowershellParameters(this.operation);
|
|
357
359
|
// implement IEventListener
|
|
358
360
|
this.implementIEventListener();
|
|
361
|
+
// implement part of the IContext
|
|
362
|
+
this.implementIContext();
|
|
359
363
|
// add constructors
|
|
360
364
|
this.implementConstructors();
|
|
361
365
|
// processRecord
|
|
@@ -411,7 +415,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
411
415
|
this.processRecordId = this.add(new codegen_csharp_1.Field('__processRecordId', codegen_csharp_1.dotnet.String, { description: 'A unique id generatd for the this cmdlet when ProcessRecord() is called.', access: codegen_csharp_1.Access.Private }));
|
|
412
416
|
}
|
|
413
417
|
// pipeline property
|
|
414
|
-
this.add(new codegen_csharp_1.Property('Pipeline', exports_1.ClientRuntime.HttpPipeline, { getAccess: codegen_csharp_1.Access.
|
|
418
|
+
this.add(new codegen_csharp_1.Property('Pipeline', exports_1.ClientRuntime.HttpPipeline, { getAccess: codegen_csharp_1.Access.Public, setAccess: codegen_csharp_1.Access.Public, description: `The instance of the <see cref="${exports_1.ClientRuntime.HttpPipeline}" /> that the remote call will use.` }));
|
|
415
419
|
// client API property (gs01: fill this in correctly)
|
|
416
420
|
const clientAPI = new codegen_csharp_1.ClassType((_a = this.state.model.language.csharp) === null || _a === void 0 ? void 0 : _a.namespace, ((_b = this.state.model.language.csharp) === null || _b === void 0 ? void 0 : _b.name) || '');
|
|
417
421
|
this.add(new codegen_csharp_1.LambdaProperty('Client', clientAPI, new codegen_csharp_1.LiteralExpression(`${this.state.project.serviceNamespace.moduleClass.declaration}.Instance.ClientAPI`), { description: 'The reference to the client API class.' }));
|
|
@@ -563,14 +567,37 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
563
567
|
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletGetPipeline);
|
|
564
568
|
const pipeline = $this.$('Pipeline');
|
|
565
569
|
if ($this.state.project.azure) {
|
|
566
|
-
yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, ${$this.correlationId}, ${$this.processRecordId}, this.ParameterSetName)`));
|
|
570
|
+
yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, ${$this.correlationId}, ${$this.processRecordId}, this.ParameterSetName, this.ExtensibleParameters)`));
|
|
567
571
|
}
|
|
568
572
|
else {
|
|
569
|
-
yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, this.ParameterSetName)`));
|
|
573
|
+
yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, this.ParameterSetName, this.ExtensibleParameters)`));
|
|
570
574
|
}
|
|
571
575
|
yield codegen_csharp_1.If(codegen_csharp_1.IsNotNull($this.$('HttpPipelinePrepend')), pipeline.invokeMethod('Prepend', codegen_csharp_1.toExpression(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelinePrepend')}) ?? ${$this.$('HttpPipelinePrepend')}`)));
|
|
572
576
|
yield codegen_csharp_1.If(codegen_csharp_1.IsNotNull($this.$('HttpPipelineAppend')), pipeline.invokeMethod('Append', codegen_csharp_1.toExpression(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelineAppend')}) ?? ${$this.$('HttpPipelineAppend')}`)));
|
|
573
577
|
yield '// get the client instance';
|
|
578
|
+
// Add input pipeline if it is configured by developers.
|
|
579
|
+
if ($this.operation.extensions.inputPipe) {
|
|
580
|
+
const handlers = $this.operation.extensions.inputPipe;
|
|
581
|
+
// default priority is 100
|
|
582
|
+
handlers.sort((a, b) => { return (a.priority || 100) - (b.priority || 100); });
|
|
583
|
+
for (const { index, handler } of handlers.map((handler, index) => ({ index, handler }))) {
|
|
584
|
+
yield `var handler_${index} = new ${handler.name}();`;
|
|
585
|
+
if (index > 0) {
|
|
586
|
+
yield `handler_${index - 1}.SetNextHandler(handler_${index});`;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
yield 'handler_0.Process(this);';
|
|
590
|
+
}
|
|
591
|
+
const vps = $this.operation.details.csharp.virtualParameters || {
|
|
592
|
+
body: [],
|
|
593
|
+
operation: [],
|
|
594
|
+
};
|
|
595
|
+
for (const vParam of [...vps.body, ...vps.operation]) {
|
|
596
|
+
if (vParam.hidden) {
|
|
597
|
+
const td = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vParam.schema, true, $this.state);
|
|
598
|
+
yield codegen_csharp_1.If(`true == this.MyInvocation?.BoundParameters?.ContainsKey("${vParam.name}")`, `${vParam.name} = (${td.declaration})this.MyInvocation.BoundParameters["${vParam.name}"];`);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
574
601
|
const apiCall = operation.callGraph[0];
|
|
575
602
|
// find each parameter to the method, and find out where the value is going to come from.
|
|
576
603
|
const operationParameters = linq_1.values(apiCall.parameters).
|
|
@@ -626,7 +653,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
626
653
|
parameters.push(new codegen_csharp_1.Parameter('headers', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: each.language.csharp.headerType }), { description: `the header result as a <see cref="${each.language.csharp.headerType}" /> from the remote call` }));
|
|
627
654
|
}
|
|
628
655
|
if (isBinary) {
|
|
629
|
-
parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: 'global::System.IO.Stream' }), { description:
|
|
656
|
+
parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: 'global::System.IO.Stream' }), { description: 'the body result as a <see cref="global::System.IO.Stream" /> from the remote call' }));
|
|
630
657
|
}
|
|
631
658
|
const override = `override${codegen_1.pascalCase(((_f = each.language.csharp) === null || _f === void 0 ? void 0 : _f.name) || '')}`;
|
|
632
659
|
const returnNow = new codegen_csharp_1.Parameter('returnNow', codegen_csharp_1.System.Threading.Tasks.Task(codegen_csharp_1.dotnet.Bool), { modifier: codegen_csharp_2.ParameterModifier.Ref, description: `/// Determines if the rest of the ${(_g = each.language.csharp) === null || _g === void 0 ? void 0 : _g.name} method should be processed, or if the method should return immediately (set to true to skip further processing )` });
|
|
@@ -728,15 +755,15 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
728
755
|
const vp = schema_1.getVirtualPropertyFromPropertyName((_m = schema.language.csharp) === null || _m === void 0 ? void 0 : _m.virtualProperties, valueProperty.serializedName);
|
|
729
756
|
if (vp) {
|
|
730
757
|
if ($this.clientsidePagination) {
|
|
731
|
-
yield (codegen_csharp_1.If(
|
|
732
|
-
yield (
|
|
758
|
+
yield (codegen_csharp_1.If('(ulong)result.Value.Length <= this.PagingParameters.Skip', function* () {
|
|
759
|
+
yield ('this.PagingParameters.Skip = this.PagingParameters.Skip - (ulong)result.Value.Length;');
|
|
733
760
|
}));
|
|
734
761
|
yield codegen_csharp_1.Else(function* () {
|
|
735
|
-
yield (
|
|
736
|
-
yield (
|
|
737
|
-
yield (
|
|
738
|
-
yield (
|
|
739
|
-
yield (
|
|
762
|
+
yield ('ulong toRead = Math.Min(this.PagingParameters.First, (ulong)result.Value.Length - this.PagingParameters.Skip);');
|
|
763
|
+
yield ('var requiredResult = result.Value.SubArray((int)this.PagingParameters.Skip, (int)toRead);');
|
|
764
|
+
yield ('WriteObject(requiredResult, true);');
|
|
765
|
+
yield ('this.PagingParameters.Skip = 0;');
|
|
766
|
+
yield ('this.PagingParameters.First = this.PagingParameters.First <= toRead ? 0 : this.PagingParameters.First - toRead;');
|
|
740
767
|
});
|
|
741
768
|
}
|
|
742
769
|
else {
|
|
@@ -747,18 +774,18 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
747
774
|
if (nl) {
|
|
748
775
|
$this.add(new codegen_csharp_1.Field('_isFirst', codegen_csharp_1.dotnet.Bool, {
|
|
749
776
|
access: codegen_csharp_1.Access.Private,
|
|
750
|
-
initialValue: new codegen_csharp_1.LiteralExpression(
|
|
751
|
-
description:
|
|
777
|
+
initialValue: new codegen_csharp_1.LiteralExpression('true'),
|
|
778
|
+
description: 'A flag to tell whether it is the first onOK call.'
|
|
752
779
|
}));
|
|
753
780
|
$this.add(new codegen_csharp_1.Field('_nextLink', codegen_csharp_1.dotnet.String, {
|
|
754
781
|
access: codegen_csharp_1.Access.Private,
|
|
755
|
-
description:
|
|
782
|
+
description: 'Link to retrieve next page.'
|
|
756
783
|
}));
|
|
757
784
|
const nextLinkName = `${result.value}.${nl.name}`;
|
|
758
785
|
yield `_nextLink = ${nextLinkName};`;
|
|
759
|
-
|
|
760
|
-
yield (codegen_csharp_1.If(
|
|
761
|
-
yield
|
|
786
|
+
const nextLinkCondition = $this.clientsidePagination ? '_nextLink != null && this.PagingParameters.First > 0' : '_nextLink != null';
|
|
787
|
+
yield (codegen_csharp_1.If('_isFirst', function* () {
|
|
788
|
+
yield '_isFirst = false;';
|
|
762
789
|
yield (codegen_csharp_1.While(nextLinkCondition, codegen_csharp_1.If('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () {
|
|
763
790
|
var _a;
|
|
764
791
|
yield `requestMessage = requestMessage.Clone(new global::System.Uri( _nextLink ),${exports_1.ClientRuntime.Method.Get} );`;
|
|
@@ -824,21 +851,21 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
824
851
|
}
|
|
825
852
|
// in m4, there will be no schema deinfed for the binary response, instead, we will have a field called binary with value true.
|
|
826
853
|
if ('binary' in each) {
|
|
827
|
-
yield
|
|
854
|
+
yield '// (await response) // should be global::System.IO.Stream';
|
|
828
855
|
if ($this.hasStreamOutput && $this.outFileParameter) {
|
|
829
856
|
const outfile = $this.outFileParameter;
|
|
830
857
|
const provider = codegen_csharp_2.Local('provider');
|
|
831
858
|
provider.initializer = undefined;
|
|
832
|
-
const paths = codegen_csharp_2.Local('paths',
|
|
859
|
+
const paths = codegen_csharp_2.Local('paths', 'new global::System.Collections.ObjectModel.Collection<global::System.String>()');
|
|
833
860
|
yield paths.declarationStatement;
|
|
834
861
|
yield codegen_csharp_1.Try(function* () {
|
|
835
862
|
yield `${paths.value} = this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression});`;
|
|
836
863
|
yield codegen_csharp_1.If(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
|
|
837
864
|
yield codegen_csharp_1.If(`${paths.value}.Count > 1`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
|
|
838
865
|
});
|
|
839
|
-
const notfound = new codegen_csharp_1.Parameter('', { declaration:
|
|
866
|
+
const notfound = new codegen_csharp_1.Parameter('', { declaration: 'global::System.Management.Automation.ItemNotFoundException' });
|
|
840
867
|
yield codegen_csharp_1.Catch(notfound, function* () {
|
|
841
|
-
yield
|
|
868
|
+
yield '// If the file does not exist, we will try to create it';
|
|
842
869
|
yield `${paths.value}.Add(${outfile.value});`;
|
|
843
870
|
});
|
|
844
871
|
// this is a stream output. write to outfile
|
|
@@ -868,7 +895,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
868
895
|
yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletBeforeAPICall);
|
|
869
896
|
const idOpParams = operationParameters.filter(each => !each.isPathParam);
|
|
870
897
|
const idschema = linq_1.values($this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
|
|
871
|
-
|
|
898
|
+
let serializationMode = null;
|
|
872
899
|
if ($this.bodyParameter) {
|
|
873
900
|
if ($this.operation.operationType === command_operation_1.OperationType.Create) {
|
|
874
901
|
serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeCreate;
|
|
@@ -926,8 +953,8 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
926
953
|
}
|
|
927
954
|
};
|
|
928
955
|
if (idschema && linq_1.values(idschema.properties).first(each => { var _a; return ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.uid) === 'universal-parameter:resource identity'; })) {
|
|
929
|
-
|
|
930
|
-
if (
|
|
956
|
+
const parameters = [codegen_csharp_1.toExpression('InputObject.Id'), ...idOpParams.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
|
|
957
|
+
if (serializationMode) {
|
|
931
958
|
parameters.push(serializationMode);
|
|
932
959
|
}
|
|
933
960
|
yield codegen_csharp_1.If('InputObject?.Id != null', `await this.${$this.$('Client').invokeMethod(`${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}ViaIdentity`, ...parameters).implementation}`);
|
|
@@ -938,8 +965,8 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
938
965
|
}
|
|
939
966
|
}
|
|
940
967
|
else {
|
|
941
|
-
|
|
942
|
-
if (
|
|
968
|
+
const parameters = [...operationParameters.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
|
|
969
|
+
if (serializationMode) {
|
|
943
970
|
parameters.push(serializationMode);
|
|
944
971
|
}
|
|
945
972
|
yield `await this.${$this.$('Client').invokeMethod(`${(_b = apiCall.language.csharp) === null || _b === void 0 ? void 0 : _b.name}`, ...parameters).implementation}`;
|
|
@@ -1002,6 +1029,16 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1002
1029
|
// default constructor
|
|
1003
1030
|
this.add(new codegen_csharp_1.Constructor(this, { description: `Intializes a new instance of the <see cref="${this.name}" /> cmdlet class.` }));
|
|
1004
1031
|
}
|
|
1032
|
+
implementIContext() {
|
|
1033
|
+
const extensibleParameters = this.add(new codegen_csharp_1.Field('_extensibleParameters', codegen_csharp_1.System.Collections.Generic.Dictionary(codegen_csharp_1.System.String, codegen_csharp_1.System.Object), {
|
|
1034
|
+
access: codegen_csharp_1.Access.Private,
|
|
1035
|
+
initialValue: new codegen_csharp_1.LiteralExpression('new System.Collections.Generic.Dictionary<string, object>()'),
|
|
1036
|
+
description: 'A dictionary to carry over additional data for pipeline.'
|
|
1037
|
+
}));
|
|
1038
|
+
const extensibleParametersProp = new codegen_csharp_1.Property('ExtensibleParameters', codegen_csharp_1.System.Collections.Generic.IDictionary(codegen_csharp_1.System.String, codegen_csharp_1.System.Object), { description: 'Accessor for extensibleParameters.' });
|
|
1039
|
+
extensibleParametersProp.get = codegen_csharp_1.toExpression(`${extensibleParameters.value} `);
|
|
1040
|
+
this.add(extensibleParametersProp);
|
|
1041
|
+
}
|
|
1005
1042
|
implementIEventListener() {
|
|
1006
1043
|
const $this = this;
|
|
1007
1044
|
const cts = this.add(new codegen_csharp_1.Field('_cancellationTokenSource', codegen_csharp_1.System.Threading.CancellationTokenSource, {
|
|
@@ -1009,6 +1046,10 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1009
1046
|
initialValue: new codegen_csharp_1.LiteralExpression(`new ${codegen_csharp_1.System.Threading.CancellationTokenSource.declaration}()`),
|
|
1010
1047
|
description: `The <see cref="${codegen_csharp_1.System.Threading.CancellationTokenSource}" /> for this operation.`
|
|
1011
1048
|
}));
|
|
1049
|
+
const cancellationTokenSource = new codegen_csharp_1.Property('CancellationTokenSource', codegen_csharp_1.System.Threading.CancellationTokenSource, { description: 'Accessor for cancellationTokenSource.' });
|
|
1050
|
+
cancellationTokenSource.get = codegen_csharp_1.toExpression(`${cts.value} `);
|
|
1051
|
+
cancellationTokenSource.set = new codegen_csharp_1.Statements(cts.assign('value'));
|
|
1052
|
+
this.add(cancellationTokenSource);
|
|
1012
1053
|
this.add(new codegen_csharp_1.LambdaProperty(`${exports_1.ClientRuntime.IEventListener}.Token`, codegen_csharp_1.System.Threading.CancellationToken, new codegen_csharp_1.LiteralExpression(`${cts.value}.Token`), { getAccess: codegen_csharp_1.Access.Default, setAccess: codegen_csharp_1.Access.Default, description: `<see cref="${exports_1.ClientRuntime}.IEventListener" /> cancellation token.` }));
|
|
1013
1054
|
this.cancellationToken = codegen_csharp_1.toExpression(`((${exports_1.ClientRuntime.IEventListener})this).Token`);
|
|
1014
1055
|
this.add(new codegen_csharp_1.LambdaProperty(`${exports_1.ClientRuntime.IEventListener}.Cancel`, codegen_csharp_1.System.Action(), new codegen_csharp_1.LiteralExpression(`${cts.value}.Cancel`), { getAccess: codegen_csharp_1.Access.Default, setAccess: codegen_csharp_1.Access.Default, description: `<see cref="${exports_1.ClientRuntime}.IEventListener" /> cancellation delegate. Stops the cmdlet when called.` }));
|
|
@@ -1142,7 +1183,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1142
1183
|
}
|
|
1143
1184
|
if (this.dropBodyParameter && parameter.details.csharp.isBodyParameter) {
|
|
1144
1185
|
// we're supposed to use parameters for the body parameter instead of a big object
|
|
1145
|
-
const expandedBodyParameter = this.add(new codegen_csharp_1.Field(
|
|
1186
|
+
const expandedBodyParameter = this.add(new codegen_csharp_1.Field('_' + codegen_1.camelCase(parameter.details.csharp.name), td, {
|
|
1146
1187
|
description: parameter.details.csharp.description,
|
|
1147
1188
|
initialValue: (parameter.schema.type === codemodel_1.SchemaType.Array) ? codegen_csharp_1.dotnet.Null : `new ${(_a = parameter.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.fullname}()`,
|
|
1148
1189
|
access: codegen_csharp_1.Access.Private
|
|
@@ -1228,7 +1269,6 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1228
1269
|
this.addDoNotExport(cmdletParameter, vParam);
|
|
1229
1270
|
}
|
|
1230
1271
|
const isEnum = propertyType instanceof exports_1.EnumImplementation;
|
|
1231
|
-
;
|
|
1232
1272
|
const hasEnum = propertyType instanceof exports_1.ArrayOf && propertyType.elementType instanceof exports_1.EnumImplementation;
|
|
1233
1273
|
if (isEnum || hasEnum) {
|
|
1234
1274
|
cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
|
|
@@ -1286,52 +1326,65 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1286
1326
|
// skip 'Host'
|
|
1287
1327
|
continue;
|
|
1288
1328
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
//
|
|
1294
|
-
this.add(new codegen_csharp_1.BackedProperty(vParam.name, codegen_csharp_1.
|
|
1295
|
-
metadata: {
|
|
1296
|
-
parameterDefinition: origin.details.csharp.httpParameter
|
|
1297
|
-
},
|
|
1298
|
-
description: vParam.description
|
|
1299
|
-
})) :
|
|
1300
|
-
// everything else
|
|
1301
|
-
this.add(new codegen_csharp_1.BackedProperty(vParam.name, propertyType, {
|
|
1302
|
-
metadata: {
|
|
1303
|
-
parameterDefinition: origin.details.csharp.httpParameter
|
|
1304
|
-
},
|
|
1329
|
+
let regularCmdletParameter;
|
|
1330
|
+
let origin = null;
|
|
1331
|
+
let propertyType = null;
|
|
1332
|
+
if (vParam.type) {
|
|
1333
|
+
// Handle parameters added through directives
|
|
1334
|
+
regularCmdletParameter = this.add(new codegen_csharp_1.BackedProperty(vParam.name, new codegen_csharp_1.ClassType('', vParam.type), {
|
|
1305
1335
|
description: vParam.description
|
|
1306
1336
|
}));
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1337
|
+
}
|
|
1338
|
+
else {
|
|
1339
|
+
const vSchema = vParam.schema;
|
|
1340
|
+
propertyType = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, true, this.state);
|
|
1341
|
+
origin = vParam.origin;
|
|
1342
|
+
regularCmdletParameter = (this.state.project.azure && vParam.name === 'SubscriptionId' && operation.details.csharp.verb.toLowerCase() === 'get') ?
|
|
1343
|
+
// special case for subscription id
|
|
1344
|
+
this.add(new codegen_csharp_1.BackedProperty(vParam.name, codegen_csharp_1.dotnet.StringArray, {
|
|
1345
|
+
metadata: {
|
|
1346
|
+
parameterDefinition: origin.details.csharp.httpParameter
|
|
1347
|
+
},
|
|
1348
|
+
description: vParam.description
|
|
1349
|
+
})) :
|
|
1350
|
+
// everything else
|
|
1351
|
+
this.add(new codegen_csharp_1.BackedProperty(vParam.name, propertyType, {
|
|
1352
|
+
metadata: {
|
|
1353
|
+
parameterDefinition: origin.details.csharp.httpParameter
|
|
1354
|
+
},
|
|
1355
|
+
description: vParam.description
|
|
1356
|
+
}));
|
|
1357
|
+
const dictSchema = vSchema.type === codemodel_1.SchemaType.Dictionary ? vSchema :
|
|
1358
|
+
vSchema.type === codemodel_1.SchemaType.Object ? (_j = (_h = vSchema.parents) === null || _h === void 0 ? void 0 : _h.immediate) === null || _j === void 0 ? void 0 : _j.find((s) => s.type === codemodel_1.SchemaType.Dictionary) :
|
|
1359
|
+
undefined;
|
|
1360
|
+
if (dictSchema) {
|
|
1361
|
+
// we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
|
|
1362
|
+
// if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
|
|
1363
|
+
// if it's a standalone dictionary, we can just use hashtable instead
|
|
1364
|
+
if (linq_1.length(vSchema.properties) === 0) {
|
|
1365
|
+
// it's a pure dictionary
|
|
1366
|
+
// change the property type to hashtable.
|
|
1367
|
+
// add an attribute to change the exported type.
|
|
1368
|
+
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExportAsAttribute, { parameters: [`typeof(${codegen_csharp_1.System.Collections.Hashtable})`] }));
|
|
1369
|
+
}
|
|
1370
|
+
else {
|
|
1371
|
+
// it's a hybrid. We need to add an additional property that puts its items into the target container
|
|
1372
|
+
}
|
|
1322
1373
|
}
|
|
1323
1374
|
}
|
|
1324
1375
|
this.thingsToSerialize.push(regularCmdletParameter);
|
|
1325
1376
|
const parameters = [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${codegen_1.escapeString(vParam.description) || '.'}"`)];
|
|
1326
|
-
if (origin.details.csharp.isBodyParameter) {
|
|
1377
|
+
if (!!origin && origin.details.csharp.isBodyParameter) {
|
|
1327
1378
|
parameters.push(new codegen_csharp_1.LiteralExpression('ValueFromPipeline = true'));
|
|
1328
1379
|
this.bodyParameter = regularCmdletParameter;
|
|
1329
1380
|
}
|
|
1330
1381
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters }));
|
|
1331
|
-
if (vParam.schema.type === codemodel_1.SchemaType.Array) {
|
|
1382
|
+
if (!vParam.type && vParam.schema.type === codemodel_1.SchemaType.Array) {
|
|
1332
1383
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.AllowEmptyCollectionAttribute));
|
|
1333
1384
|
}
|
|
1334
|
-
|
|
1385
|
+
if (!!origin && !!propertyType) {
|
|
1386
|
+
NewAddInfoAttribute(regularCmdletParameter, propertyType, (_k = vParam.required, (_k !== null && _k !== void 0 ? _k : false)), false, vParam.description, origin.name);
|
|
1387
|
+
}
|
|
1335
1388
|
NewAddCompleterInfo(regularCmdletParameter, vParam);
|
|
1336
1389
|
addParameterBreakingChange(regularCmdletParameter, vParam);
|
|
1337
1390
|
addPreviewMessage(regularCmdletParameter, vParam);
|
|
@@ -1341,7 +1394,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1341
1394
|
if (linq_1.length(vParam.alias) > 0) {
|
|
1342
1395
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
|
|
1343
1396
|
}
|
|
1344
|
-
const httpParam = origin.details.csharp.httpParameter;
|
|
1397
|
+
const httpParam = origin ? origin.details.csharp.httpParameter : null;
|
|
1345
1398
|
//const uid = httpParam ? httpParam.details.csharp.uid : 'no-parameter';
|
|
1346
1399
|
if (httpParam) {
|
|
1347
1400
|
// xichen: Is it safe to compare by csharp serializedName? Because we no longer have uid
|
|
@@ -1350,13 +1403,9 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1350
1403
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.${codegen_1.pascalCase(((_m = cat.protocol.http) === null || _m === void 0 ? void 0 : _m.in))}`] }));
|
|
1351
1404
|
}
|
|
1352
1405
|
}
|
|
1353
|
-
if (origin.details.csharp.completer) {
|
|
1354
|
-
// add the completer to this class and tag this parameter with the completer.
|
|
1355
|
-
// regularCmdletParameter.add(new Attribute(ArgumentCompleterAttribute, { parameters: [`typeof(${this.declaration})`] }));
|
|
1356
|
-
}
|
|
1357
1406
|
const isEnum = propertyType instanceof exports_1.EnumImplementation;
|
|
1358
1407
|
const hasEnum = propertyType instanceof exports_1.ArrayOf && propertyType.elementType instanceof exports_1.EnumImplementation;
|
|
1359
|
-
if (isEnum || hasEnum) {
|
|
1408
|
+
if (propertyType && (isEnum || hasEnum)) {
|
|
1360
1409
|
regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
|
|
1361
1410
|
}
|
|
1362
1411
|
}
|
|
@@ -1473,9 +1522,9 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1473
1522
|
}
|
|
1474
1523
|
//add breaking change attributes for cmdlet, variant, output type
|
|
1475
1524
|
if (operation.details.csharp.breakingChange) {
|
|
1476
|
-
|
|
1525
|
+
const breakingChange = operation.details.csharp.breakingChange;
|
|
1477
1526
|
if (breakingChange.cmdlet) {
|
|
1478
|
-
|
|
1527
|
+
const parameters = [];
|
|
1479
1528
|
if (breakingChange.cmdlet.deprecateByVersion) {
|
|
1480
1529
|
parameters.push(`"${breakingChange.cmdlet.deprecateByVersion}"`);
|
|
1481
1530
|
if (breakingChange.cmdlet.changeInEfectByDate)
|
|
@@ -1488,7 +1537,7 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1488
1537
|
this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.CmdletBreakingChangeAttribute, { parameters: parameters }));
|
|
1489
1538
|
}
|
|
1490
1539
|
if (breakingChange.variant) {
|
|
1491
|
-
|
|
1540
|
+
const parameters = [];
|
|
1492
1541
|
parameters.push(`new string[] {"${breakingChange.variant.name}"}`);
|
|
1493
1542
|
if (breakingChange.variant.deprecateByVersion) {
|
|
1494
1543
|
parameters.push(`"${breakingChange.variant.deprecateByVersion}"`);
|
|
@@ -1500,13 +1549,13 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1500
1549
|
this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.ParameterSetBreakingChangeAttribute, { parameters: parameters }));
|
|
1501
1550
|
}
|
|
1502
1551
|
if (breakingChange.output) {
|
|
1503
|
-
|
|
1552
|
+
const parameters = [];
|
|
1504
1553
|
// if deprecated output types are set in directive, use it
|
|
1505
1554
|
if (breakingChange.output.deprecatedCmdLetOutputType) {
|
|
1506
1555
|
parameters.push(`"${breakingChange.output.deprecatedCmdLetOutputType}"`);
|
|
1507
1556
|
}
|
|
1508
1557
|
else {
|
|
1509
|
-
parameters.push(`"${outputTypes.values().next().value.replace(/typeof\((.*)\)/,
|
|
1558
|
+
parameters.push(`"${outputTypes.values().next().value.replace(/typeof\((.*)\)/, '$1')}"`);
|
|
1510
1559
|
}
|
|
1511
1560
|
if (breakingChange.output.deprecateByVersion) {
|
|
1512
1561
|
parameters.push(`"${breakingChange.output.deprecateByVersion}"`);
|
|
@@ -1516,12 +1565,12 @@ class CmdletClass extends codegen_csharp_1.Class {
|
|
|
1516
1565
|
if (breakingChange.output.replacement)
|
|
1517
1566
|
parameters.push(`ReplacementCmdletOutputType="${breakingChange.output.replacement}"`);
|
|
1518
1567
|
if (breakingChange.output.deprecatedOutputProperties) {
|
|
1519
|
-
|
|
1568
|
+
const properties = Object.assign([], breakingChange.output.deprecatedOutputProperties);
|
|
1520
1569
|
properties.forEach((element, index) => properties[index] = '"' + element + '"');
|
|
1521
1570
|
parameters.push(`DeprecatedOutputProperties=new string[] {${properties.join(',')}}`);
|
|
1522
1571
|
}
|
|
1523
1572
|
if (breakingChange.output.newOutputProperties) {
|
|
1524
|
-
|
|
1573
|
+
const properties = Object.assign([], breakingChange.output.newOutputProperties);
|
|
1525
1574
|
properties.forEach((element, index) => properties[index] = '"' + element + '"');
|
|
1526
1575
|
parameters.push(`NewOutputProperties=new string[] {${properties.join(',')}}`);
|
|
1527
1576
|
}
|