From 45fc75adf816ee7c00552f0841ff2eb62d830a70 Mon Sep 17 00:00:00 2001 From: derek Date: Tue, 25 Aug 2020 16:41:39 +0800 Subject: [PATCH 1/2] Enable two test cases, and drop the workaround for x-ms-enum --- tests-upgrade/Configuration.json | 2 ++ tests-upgrade/readme.azure.noprofile.md | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests-upgrade/Configuration.json b/tests-upgrade/Configuration.json index 380e8a9c98..9d25b6c293 100644 --- a/tests-upgrade/Configuration.json +++ b/tests-upgrade/Configuration.json @@ -23,6 +23,7 @@ "datamodels-datatypes-array", "datamodels-datatypes-integer", "datamodels-datatypes-string", + "datamodels-datatypes-object", "datamodels-combineschema", "directive-model", "directive-tableformat", @@ -30,6 +31,7 @@ "extension-ms-clientflatten", "extension-ms-clientname", "extension-ms-discriminatorvalue", + "extension-ms-enum", "extension-ms-examples", "extension-ms-longruningoperation", "extension-ms-mutability", diff --git a/tests-upgrade/readme.azure.noprofile.md b/tests-upgrade/readme.azure.noprofile.md index 31602028ac..82284693a1 100644 --- a/tests-upgrade/readme.azure.noprofile.md +++ b/tests-upgrade/readme.azure.noprofile.md @@ -44,7 +44,4 @@ directive: set: default: script: '(Get-AzContext).Subscription.Id' - - from: swagger-document - where: $ - transform: return $.replace(/"modelAsString":\ true/g, '"modelAsString":\ false') ``` \ No newline at end of file From 1ddd41aa2552814b28947de78e59d102b4cf7f87 Mon Sep 17 00:00:00 2001 From: derek Date: Mon, 31 Aug 2020 17:05:29 +0800 Subject: [PATCH 2/2] Add utils folder include a script to decrypt securestring --- powershell/autorest-configuration.md | 1 + powershell/generators/nuspec.ts | 1 + powershell/internal/project.ts | 4 ++++ powershell/plugins/powershell-v2.ts | 3 +++ .../resources/utils/Unprotect-SecureString.ps1 | 16 ++++++++++++++++ tests-upgrade/AutoRestUpgradeTest.ps1 | 7 +++++-- 6 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 powershell/resources/utils/Unprotect-SecureString.ps1 diff --git a/powershell/autorest-configuration.md b/powershell/autorest-configuration.md index 048f6282ca..2c9dd6aaca 100644 --- a/powershell/autorest-configuration.md +++ b/powershell/autorest-configuration.md @@ -63,6 +63,7 @@ module-folder: $(current-folder)/generated cmdlet-folder: $(module-folder)/cmdlets model-cmdlet-folder: $(module-folder)/model-cmdlets custom-cmdlet-folder: $(current-folder)/custom +utils-cmdlet-folder: $(current-folder)/utils internal-cmdlet-folder: $(current-folder)/internal test-folder: $(current-folder)/test runtime-folder: $(module-folder)/runtime diff --git a/powershell/generators/nuspec.ts b/powershell/generators/nuspec.ts index fb44a1df57..598b825041 100644 --- a/powershell/generators/nuspec.ts +++ b/powershell/generators/nuspec.ts @@ -41,6 +41,7 @@ export async function generateNuspec(project: Project | NewProject) { + `, undefined, 'source-file-other'); } diff --git a/powershell/internal/project.ts b/powershell/internal/project.ts index 1d0feb10bb..9afaf33d7e 100644 --- a/powershell/internal/project.ts +++ b/powershell/internal/project.ts @@ -92,6 +92,7 @@ export class Project extends codeDomProject { public cmdletFolder!: string; public customFolder!: string; + public utilsFolder!: string; public internalFolder!: string; public testFolder!: string; public runtimeFolder!: string; @@ -193,6 +194,7 @@ export class Project extends codeDomProject { this.cmdletFolder = await this.state.getValue('cmdlet-folder'); this.customFolder = await this.state.getValue('custom-cmdlet-folder'); + this.utilsFolder = await this.state.getValue('utils-cmdlet-folder'); this.internalFolder = await this.state.getValue('internal-cmdlet-folder'); this.testFolder = await this.state.getValue('test-folder'); this.runtimeFolder = await this.state.getValue('runtime-folder'); @@ -250,6 +252,7 @@ export class NewProject extends codeDomProject { public cmdletFolder!: string; public customFolder!: string; + public utilsFolder!: string; public internalFolder!: string; public testFolder!: string; public runtimeFolder!: string; @@ -353,6 +356,7 @@ export class NewProject extends codeDomProject { this.cmdletFolder = await this.state.getValue('cmdlet-folder'); this.customFolder = await this.state.getValue('custom-cmdlet-folder'); + this.utilsFolder = await this.state.getValue('utils-cmdlet-folder'); this.internalFolder = await this.state.getValue('internal-cmdlet-folder'); this.testFolder = await this.state.getValue('test-folder'); this.runtimeFolder = await this.state.getValue('runtime-folder'); diff --git a/powershell/plugins/powershell-v2.ts b/powershell/plugins/powershell-v2.ts index 12d8802b7b..b92c5643a4 100644 --- a/powershell/plugins/powershell-v2.ts +++ b/powershell/plugins/powershell-v2.ts @@ -32,6 +32,9 @@ async function copyRequiredFiles(project: NewProject) { // Runtime files await copyResources(join(resources, 'psruntime'), async (fname, content) => project.state.writeFile(join(project.runtimeFolder, fname), content, undefined, sourceFileCSharp), project.overrides, transformOutput); + // utils cmdlets + await copyResources(join(resources, 'utils'), async (fname, content) => project.state.writeFile(join(project.utilsFolder, fname), content, undefined, sourceFileCSharp), project.overrides, transformOutput); + // Modules files await copyBinaryResources(join(resources, 'modules'), async (fname, content) => project.state.writeFile(join(project.dependencyModuleFolder, fname), content, undefined, 'binary-file')); diff --git a/powershell/resources/utils/Unprotect-SecureString.ps1 b/powershell/resources/utils/Unprotect-SecureString.ps1 new file mode 100644 index 0000000000..cb05b51a62 --- /dev/null +++ b/powershell/resources/utils/Unprotect-SecureString.ps1 @@ -0,0 +1,16 @@ +#This script converts securestring to plaintext + +param( + [Parameter(Mandatory, ValueFromPipeline)] + [System.Security.SecureString] + ${SecureString} +) + +$ssPtr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString) +try { + $plaintext = [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($ssPtr) +} finally { + [System.Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ssPtr) +} + +return $plaintext \ No newline at end of file diff --git a/tests-upgrade/AutoRestUpgradeTest.ps1 b/tests-upgrade/AutoRestUpgradeTest.ps1 index 938758f39b..66c2e79605 100644 --- a/tests-upgrade/AutoRestUpgradeTest.ps1 +++ b/tests-upgrade/AutoRestUpgradeTest.ps1 @@ -66,6 +66,9 @@ function IsNeedIgnore([string]$inputFileName , [Array]$ignoreArray) { $Ignore =$True break + } elseif ($ignoreDetail.Contains("*.") -and $inputFileName.EndsWith($ignoreDetail.Split(".")[-1])) { + $Ignore =$True + break } } return $Ignore @@ -117,8 +120,8 @@ function CompareGeneratedCode([string]$inputSourcePath,[string]$inputTargetPath, #in m3Path cd $inputSourcePath $initFileList = Get-ChildItem -Recurse -force - $initIgnoreFileList = (($inputSourcePath+'\generated\modules'), ($inputSourcePath+'\.gitignore'),($inputSourcePath+'\tools\Resources\.gitignore')) - $targetIgnoreFileList = (($inputTargetPath+'\generated\modules'), ($inputTargetPath+'\.gitignore'),($inputTargetPath+'\tools\Resources\.gitignore')) + $initIgnoreFileList = (($inputSourcePath+'\generated\modules'), ($inputSourcePath+'\utils'), ($inputSourcePath+'\*.nuspec'), ($inputSourcePath+'\.gitignore'),($inputSourcePath+'\tools\Resources\.gitignore')) + $targetIgnoreFileList = (($inputTargetPath+'\generated\modules'), ($inputTargetPath+'\utils'),($inputTargetPath+'\*.nuspec'),($inputTargetPath+'\.gitignore'),($inputTargetPath+'\tools\Resources\.gitignore')) #foreach initFileList and get the hashcode of them foreach( $initFile in $initFileList) {