From 518987a371a83676c8cdee51f4ae6c1f492e6331 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Fri, 10 Dec 2021 12:18:11 -0800 Subject: [PATCH 1/6] Serialize hashtables. --- .../csharp/json/Customizations/IJsonSerializable.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/powershell/resources/runtime/csharp/json/Customizations/IJsonSerializable.cs b/powershell/resources/runtime/csharp/json/Customizations/IJsonSerializable.cs index 6ff62c02a44..ceb12aa7026 100644 --- a/powershell/resources/runtime/csharp/json/Customizations/IJsonSerializable.cs +++ b/powershell/resources/runtime/csharp/json/Customizations/IJsonSerializable.cs @@ -157,6 +157,14 @@ internal static JsonNode ToJsonValue(object value) return Microsoft.Rest.ClientRuntime.JsonSerializable.ToJson(dictionary, null); } + // hashtables are converted to dictionaries for serialization + if (value is System.Collections.Hashtable hashtable) + { + var dict = new System.Collections.Generic.Dictionary(); + DictionaryExtensions.HashTableToDictionary(hashtable, dict); + return Microsoft.Rest.ClientRuntime.JsonSerializable.ToJson(dict, null); + } + // enumerable collections are handled like arrays (again, fallback to ToJson()/ToJsonString() or literal JsonString) if (value is System.Collections.IEnumerable enumerableValue) { From dcc0f498ff46e70b656cf51e445bb378fa6d0c8e Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Fri, 10 Dec 2021 12:24:39 -0800 Subject: [PATCH 2/6] Bump version. --- powershell/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powershell/package.json b/powershell/package.json index fbc8b2852c4..db47313add4 100644 --- a/powershell/package.json +++ b/powershell/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/powershell", - "version": "2.1.600", + "version": "2.1.700", "description": "AutoRest PowerShell Cmdlet Generator", "main": "dist/exports.js", "typings": "dist/exports.d.ts", From 9a0da0114cd175dcadbde826c7c2aa17667a858c Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Thu, 16 Dec 2021 14:55:32 -0800 Subject: [PATCH 3/6] Add missing LicenseSet HashSet. --- .../psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/powershell/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs b/powershell/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs index 7208166d164..60d61efcbcc 100644 --- a/powershell/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs +++ b/powershell/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs @@ -90,6 +90,7 @@ protected override void ProcessRecord() # limitations under the License. # ---------------------------------------------------------------------------------- "); + HashSet LicenseSet = new HashSet(); foreach (var variantGroup in variantGroups) { var parameterGroups = variantGroup.ParameterGroups.ToList(); @@ -162,7 +163,9 @@ protected override void ProcessRecord() WriteMarkdowns(variantGroupsByProfile, moduleInfo, docsFolder, examplesFolder, ExcludeExampleTemplates); } } - } catch (Exception ee) { + } + catch (Exception ee) + { Console.WriteLine($"${ee.GetType().Name}/{ee.StackTrace}"); throw ee; } From 4fde921f78b5611e619a238f4e291ea68e84bb06 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Thu, 16 Dec 2021 15:03:10 -0800 Subject: [PATCH 4/6] Bump nodeJS range. --- rush.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rush.json b/rush.json index a0f9d82a4b3..e1fce153abd 100644 --- a/rush.json +++ b/rush.json @@ -2,7 +2,7 @@ * This is the main configuration file for Rush. * For full documentation, please see https://rushjs.io */ -{ + { "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", /** * (Required) This specifies the version of the Rush engine to be used in this repo. @@ -15,7 +15,7 @@ * path segment in the "$schema" field for all your Rush config files. This will ensure * correct error-underlining and tab-completion for editors such as VS Code. */ - "rushVersion": "5.34.3", + "rushVersion": "5.50.0", /** * The next field selects which package manager should be installed and determines its version. * Rush installs its own local copy of the package manager to ensure that your build process @@ -24,7 +24,7 @@ * Specify one of: "pnpmVersion", "npmVersion", or "yarnVersion". See the Rush documentation * for details about these alternatives. */ - "pnpmVersion": "5.9.0", + "pnpmVersion": "6.14.7", /** * Options that are only used when the PNPM package manager is selected */ @@ -49,7 +49,7 @@ * Specify a SemVer range to ensure developers use a NodeJS version that is appropriate * for your repo. */ - "nodeSupportedVersionRange": ">=8.9.4 <11.0.0", + "nodeSupportedVersionRange": ">=8.9.4 <15.0.0", "ensureConsistentVersions": true, "projectFolderMinDepth": 1, "projectFolderMaxDepth": 2, From f856fbddf7b497d1a9ceae742babb7da03546f42 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Thu, 21 Apr 2022 11:00:16 -0700 Subject: [PATCH 5/6] Apply pagination by loop to MSGraph branch. --- powershell/cmdlets/class.ts | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/powershell/cmdlets/class.ts b/powershell/cmdlets/class.ts index d27c3254b7c..0c00950adb2 100644 --- a/powershell/cmdlets/class.ts +++ b/powershell/cmdlets/class.ts @@ -8,7 +8,7 @@ import { escapeString, docComment, serialize, pascalCase, DeepPartial } from '@a import { items, values, Dictionary, length } from '@azure-tools/linq'; import { Access, Attribute, BackedProperty, Catch, Class, ClassType, Constructor, dotnet, Else, Expression, Finally, ForEach, If, LambdaProperty, LiteralExpression, LocalVariable, Method, Modifier, Namespace, OneOrMoreStatements, Parameter, Property, Return, Statements, BlockStatement, StringExpression, - Switch, System, TerminalCase, toExpression, Try, Using, valueOf, Field, IsNull, Or, ExpressionOrLiteral, TerminalDefaultCase, xmlize, TypeDeclaration, And, IsNotNull, PartialMethod, Case + Switch, System, TerminalCase, toExpression, Try, Using, valueOf, Field, IsNull, Or, ExpressionOrLiteral, TerminalDefaultCase, xmlize, TypeDeclaration, And, IsNotNull, PartialMethod, Case, While } from '@azure-tools/codegen-csharp'; import { ClientRuntime, EventListener, Schema, ArrayOf, EnumImplementation } from '../llcsharp/exports'; import { Alias, ArgumentCompleterAttribute, AsyncCommandRuntime, AsyncJob, CmdletAttribute, ErrorCategory, ErrorRecord, Events, InvocationInfo, OutputTypeAttribute, ParameterAttribute, PSCmdlet, PSCredential, SwitchParameter, ValidateNotNull, verbEnum, GeneratedAttribute, DescriptionAttribute, CategoryAttribute, ParameterCategory, ProfileAttribute, PSObject, InternalExportAttribute, ExportAsAttribute, DefaultRunspace, RunspaceFactory, AllowEmptyCollectionAttribute } from '../internal/powershell-declarations'; @@ -719,14 +719,27 @@ export class CmdletClass extends Class { } const nl = getVirtualPropertyFromPropertyName(each.schema.details.csharp.virtualProperties, nextLinkProperty.serializedName); if (nl) { + $this.add(new Field('_isFirst', dotnet.Bool, { + access: Access.Private, + initialValue: new LiteralExpression(`true`), + description: `A flag to tell whether it is the first onOK call.` + })); + $this.add(new Field('_nextLink', dotnet.String, { + access: Access.Private, + description: `Link to retrieve next page.` + })); const nextLinkName = `${result.value}.${nl.name}`; - yield (If(`${nextLinkName} != null`, - If('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () { - yield `requestMessage = requestMessage.Clone(new global::System.Uri( ${nextLinkName} ),${ClientRuntime.Method.Get} );`; - yield $this.eventListener.signal(Events.FollowingNextLink); - yield `await this.${$this.$('Client').invokeMethod(`${apiCall.details.csharp.name}_Call`, ...[toExpression('requestMessage'), ...callbackMethods, dotnet.This, pipeline]).implementation}`; - }) - )); + yield `_nextLink = ${nextLinkName};` + yield (If(`_isFirst`, function* () { + yield `_isFirst = false;` + yield (While(`_nextLink != null`, + If('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () { + yield `requestMessage = requestMessage.Clone(new global::System.Uri( ${nextLinkName} ),${ClientRuntime.Method.Get} );`; + yield $this.eventListener.signal(Events.FollowingNextLink); + yield `await this.${$this.$('Client').invokeMethod(`${apiCall.details.csharp.name}_Call`, ...[toExpression('requestMessage'), ...callbackMethods, dotnet.This, pipeline]).implementation}`; + }) + )) + })); } return; } else if (valueProperty) { From 7e3154b087cbb75b0d3ff4f03148f1d612f14013 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Thu, 21 Apr 2022 12:10:49 -0700 Subject: [PATCH 6/6] Fix request message nextLink URI. --- powershell/cmdlets/class.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powershell/cmdlets/class.ts b/powershell/cmdlets/class.ts index 0c00950adb2..1d2067efe58 100644 --- a/powershell/cmdlets/class.ts +++ b/powershell/cmdlets/class.ts @@ -734,7 +734,7 @@ export class CmdletClass extends Class { yield `_isFirst = false;` yield (While(`_nextLink != null`, If('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () { - yield `requestMessage = requestMessage.Clone(new global::System.Uri( ${nextLinkName} ),${ClientRuntime.Method.Get} );`; + yield `requestMessage = requestMessage.Clone(new global::System.Uri( _nextLink ),${ClientRuntime.Method.Get} );`; yield $this.eventListener.signal(Events.FollowingNextLink); yield `await this.${$this.$('Client').invokeMethod(`${apiCall.details.csharp.name}_Call`, ...[toExpression('requestMessage'), ...callbackMethods, dotnet.This, pipeline]).implementation}`; })