@@ -30,6 +30,7 @@ $ExceptionList = @()
30
30
$SavePath = $PWD
31
31
32
32
$MissReadMe = 9000
33
+ $AutorestCSharpDetected = 9080
33
34
$GenSdkChanged = 9090
34
35
35
36
function EnsureModuleName {
@@ -47,7 +48,8 @@ function Get-NonExceptionSdkRecord{
47
48
)
48
49
$exceptionPaths = " $PSScriptRoot \..\..\..\tools\StaticAnalysis\Exceptions"
49
50
$errors = @ ()
50
- foreach ($record in $records ){
51
+ foreach ($record in $records ){
52
+ $needAdd = $true
51
53
$exceptionPath = Join-Path - Path $exceptionPaths - ChildPath (EnsureModuleName($record.Module )) - AdditionalChildPath " GeneratedSdkIssues.csv"
52
54
if (Test-Path - Path $exceptionPath ){
53
55
$exceptionContents = Import-Csv - Path $exceptionPath
72
74
# Collect Sdk paths whose files under Generated folder change.
73
75
$ChangedSdks = New-Object System.Collections.Generic.List[System.Object ]
74
76
foreach ($_ in $FilesChanged ) {
75
- $ChangedSdks.Add ($_.Substring (0 , $_.IndexOf (' .Sdk' ))+ ' .Sdk' )
77
+ $ChangedSdks.Add ($_.Substring (0 , $_.IndexOf (' .Sdk' , [ System.StringComparison ]::OrdinalIgnoreCase ))+ ' .Sdk' )
76
78
}
77
79
# Remove duplicated Sdks.
78
80
$ChangedSdks = $ChangedSdks | select - unique
@@ -107,10 +109,27 @@ try {
107
109
Write-Host " Using autorest powershell v4:`n Re-generating SDK under Generated folder for $ModuleName ..."
108
110
npx autorest
109
111
}
112
+ elseif ([regex ]::Matches($readMeContent , ' \s*csharp\s*:\s*true\s*' ))
113
+ {
114
+ $ExceptionList += [GeneratedSdkIssue ]@ {
115
+ Module = $ModuleName ;
116
+ Sdk = $_ ;
117
+ Severity = 1 ;
118
+ ProblemId = $AutorestCSharpDetected
119
+ Description = " Do not support updating SDK using autorest csharp v3."
120
+ Remediation = " Please update the Readme.md to generate code by autorest powershell v4."
121
+ }
122
+ }
110
123
else
111
124
{
112
- Write-Host " Using autorest csharp v3:`n Re-generating SDK under Generated folder for $ModuleName ..."
113
- npx autorest -- use:@microsoft.azure / autorest.csharp@2.3.90 -- memory= 16g
125
+ $ExceptionList += [GeneratedSdkIssue ]@ {
126
+ Module = $ModuleName ;
127
+ Sdk = $_ ;
128
+ Severity = 1 ;
129
+ ProblemId = $GenSdkChanged
130
+ Description = " Do not find correct autorest version, please check Readme.md"
131
+ Remediation = " Please determine autorest v4 in Readme file."
132
+ }
114
133
}
115
134
116
135
If (($LASTEXITCODE -ne 0 ) -and ($LASTEXITCODE -ne $null ))
@@ -148,6 +167,7 @@ try {
148
167
}
149
168
}
150
169
170
+
151
171
# See if the code is completely the same as we generated
152
172
$changes = git status " .\Generated" -- porcelain
153
173
if ($changes -ne $null ){
0 commit comments