Skip to content

Commit 3ddc6f4

Browse files
author
azurepowershell
committed
Sync tools folder from main branch to generation branch
1 parent c1f3222 commit 3ddc6f4

File tree

9 files changed

+32
-92
lines changed

9 files changed

+32
-92
lines changed

tools/ExecuteCIStep.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ If ($StaticAnalysisUX)
327327
If ("" -Ne $UXModuleList)
328328
{
329329
Write-Host "Running static analysis for UX metadata..."
330-
.("$PSScriptRoot/StaticAnalysis/UXMetadataAnalyzer/PrepareUXMetadata.ps1") -RepoArtifacts $RepoArtifacts -Configuration $Configuration
331330
dotnet $RepoArtifacts/StaticAnalysis/StaticAnalysis.Netcore.dll -p $RepoArtifacts/$Configuration -r $StaticAnalysisOutputDirectory --analyzers ux -u -m $UXModuleList
332331
}
333332
Return

tools/Gen2Master/MoveFromGeneration2Master.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,12 @@ Function Move-Generation2MasterHybrid {
259259
}
260260

261261
#copy generated docs to help folder
262-
Copy-Item -Path ("$SourcePath\{0}\docs\*" -f $submoduleDir.Name) -Destination "$DestPath\$ModuleName\help" -Filter *-*
262+
#Assume psd1 and help are in the same folder.
263+
$Psd1FolderPostfix = '';
264+
if (-not (Test-Path (Join-Path -Path (Join-Path -Path $DestPath -ChildPath $ModuleName) -ChildPath "Az.$ModuleName.psd1"))) {
265+
$Psd1FolderPostfix = '.Management'
266+
}
267+
Copy-Item -Path ("$SourcePath\{0}\docs\*" -f $submoduleDir.Name) -Destination "$DestPath\$ModuleName$Psd1FolderPostfix\help" -Filter *-*
263268

264269
#Region generate-info.json Here have a issue that user may not use latest version to generate the code.
265270
$generateInfo = @{}
@@ -299,10 +304,6 @@ Function Move-Generation2MasterHybrid {
299304
dotnet sln $SolutionPath add (Join-Path -Path (Join-Path -Path $DestPath -ChildPath $submoduleDir.Name) -ChildPath Az.$submoduleName.csproj)
300305

301306
# Update psd1
302-
$Psd1FolderPostfix = '';
303-
if (-not (Test-Path (Join-Path -Path (Join-Path -Path $DestPath -ChildPath $ModuleName) -ChildPath "Az.$ModuleName.psd1"))) {
304-
$Psd1FolderPostfix = '.Management'
305-
}
306307
$DestPsd1Path = Join-Path -Path (Join-Path -Path $DestPath -ChildPath $ModuleName$Psd1FolderPostfix) -ChildPath "Az.$ModuleName.psd1"
307308
$Psd1Metadata = Import-LocalizedData -BaseDirectory (Join-Path -Path $DestPath -ChildPath $ModuleName$Psd1FolderPostfix) -FileName "Az.$ModuleName.psd1"
308309
$SubModulePsd1MetaData = Import-LocalizedData -BaseDirectory (Join-Path -Path $SourcePath -ChildPath $submoduleDir.Name) -FileName "Az.$submoduleName.psd1"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"Module","Severity","ResourceType","SubResourceType","Command","Description"
2+
"Az.Compute","1","Microsoft.Compute","virtualMachineScaleSets","Stop-AzVmss","The value of -StayProvisioned is not defined."
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"Module","Severity","ResourceType","SubResourceType","Command","Description"
2+
"Az.KeyVault","1","Microsoft.KeyVault","vaults","Get-AzKeyVaultKey","resourceGroupName is defined in path but cannot find in example"
3+
"Az.KeyVault","1","Microsoft.KeyVault","vaults","Get-AzKeyVaultCertificate","resourceGroupName is defined in path but cannot find in example"
4+
"Az.KeyVault","1","Microsoft.KeyVault","vaults","Get-AzKeyVaultSecret","resourceGroupName is defined in path but cannot find in example"

tools/StaticAnalysis/Exceptions/Az.MobileNetwork/SignatureIssues.csv

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"Module","Severity","ResourceType","SubResourceType","Command","Description"
2+
"Az.RedisEnterpriseCache","1","Microsoft.Cache","redisEnterprise-databases","Invoke-AzRedisEnterpriseCacheForceDatabaseUnlink","Cannot find a matched parameter set for example of Invoke-AzRedisEnterpriseCacheForceDatabaseUnlink"
3+
"Az.RedisEnterpriseCache","1","Microsoft.Cache","redisEnterprise-databases","Invoke-AzRedisEnterpriseCacheForceDatabaseUnlink","databaseName is defined in path but cannot find in example"

tools/StaticAnalysis/UXMetadataAnalyzer/PrepareUXMetadata.ps1

Lines changed: 0 additions & 66 deletions
This file was deleted.

tools/StaticAnalysis/UXMetadataAnalyzer/UXMetadataAnalyzer.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,19 @@ public void Analyze(
111111
continue;
112112
}
113113
string moduleName = Path.GetFileName(directory);
114-
114+
string moduleFolder = Path.Combine(savedDirectory, "src", moduleName.Replace("Az.", ""));
115115
Directory.SetCurrentDirectory(directory);
116116

117117
var moduleMetadata = MetadataLoader.GetModuleMetadata(moduleName);
118118

119-
string UXFolder = Path.Combine(directory, "UX");
120-
if (!Directory.Exists(UXFolder))
121-
{
122-
continue;
123-
}
124-
125-
var UXMetadataPathList = Directory.EnumerateFiles(UXFolder, "*.json", SearchOption.AllDirectories);
126-
foreach (var UXMetadataPath in UXMetadataPathList)
119+
string[] UXFolders = Directory.GetDirectories(moduleFolder, "UX", SearchOption.AllDirectories);
120+
foreach (var UXFolder in UXFolders)
127121
{
128-
ValidateUXMetadata(moduleName, UXMetadataPath, moduleMetadata, issueLogger);
122+
var UXMetadataPathList = Directory.EnumerateFiles(UXFolder, "*.json", SearchOption.AllDirectories);
123+
foreach (var UXMetadataPath in UXMetadataPathList)
124+
{
125+
ValidateUXMetadata(moduleName, UXMetadataPath, moduleMetadata, issueLogger);
126+
}
129127
}
130128
Directory.SetCurrentDirectory(savedDirectory);
131129
}
@@ -261,8 +259,15 @@ private void ValidateParametersDefinedInPathContainsInExample(IssueLoggerContext
261259
private void ValidateParametersInExampleDefinedInPath(IssueLoggerContext context, HashSet<string> parametersFromHttpPath, UXMetadataCommandExample example, ReportLogger<UXMetadataIssue> issueLogger)
262260
{
263261
var exampleParameterPathRegex = new Regex(@"path\.([\w]+)");
264-
foreach (string parameterInExample in example.Parameters.Select(x => x.Value))
262+
foreach (var parameter in example.Parameters)
265263
{
264+
string parameterInExample = parameter.Value;
265+
if (parameterInExample == null)
266+
{
267+
string description = string.Format("The value of {0} is not defined.", parameter.Name);
268+
issueLogger.LogUXMetadataIssue(context, 1, description);
269+
continue;
270+
}
266271
var match = exampleParameterPathRegex.Match(parameterInExample);
267272
if (!match.Success)
268273
{

tools/StaticAnalysis/UXMetadataAnalyzer/UXMetadataIssue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public bool Match(IReportRecord other)
5858

5959
public IReportRecord Parse(string line)
6060
{
61-
var matcher = "\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\"";
61+
var matcher = "\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]*)\",\"([^\"]+)\"";
6262
var match = Regex.Match(line, matcher);
6363
if (!match.Success || match.Groups.Count < 7)
6464
{

0 commit comments

Comments
 (0)