Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d1595f

Browse files
authored
Merge branch 'Azure:main' into main
2 parents c240fee + ecbf39e commit 3d1595f

File tree

598 files changed

+11733
-10629
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

598 files changed

+11733
-10629
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@
258258
</ItemGroup>
259259

260260
<ItemGroup Condition="'$(IsGeneratorLibrary)' == 'true'">
261-
<PackageReference Update="Microsoft.Generator.CSharp.ClientModel" Version="1.0.0-alpha.20250123.2" />
261+
<PackageReference Update="Microsoft.Generator.CSharp.ClientModel" Version="1.0.0-alpha.20250127.1" />
262262
</ItemGroup>
263263

264264
<!--

eng/common/TestResources/New-TestResources.ps1

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,14 @@ try {
320320
# Make sure the provisioner OID is set so we can pass it through to the deployment.
321321
if (!$ProvisionerApplicationId -and !$ProvisionerApplicationOid) {
322322
if ($context.Account.Type -eq 'User') {
323-
# Use -Mail as the lookup works in both corp and TME tenants
323+
# Support corp tenant and TME tenant user id lookups
324324
$user = Get-AzADUser -Mail $context.Account.Id
325+
if ($user -eq $null -or !$user.Id) {
326+
$user = Get-AzADUser -UserPrincipalName $context.Account.Id
327+
}
328+
if ($user -eq $null -or !$user.Id) {
329+
throw "Failed to find entra object ID for the current user"
330+
}
325331
$ProvisionerApplicationOid = $user.Id
326332
} elseif ($context.Account.Type -eq 'ServicePrincipal') {
327333
$sp = Get-AzADServicePrincipal -ApplicationId $context.Account.Id
@@ -391,8 +397,14 @@ try {
391397
Write-Warning "The specified TestApplicationId '$TestApplicationId' will be ignored when -ServicePrincipalAutth is not set."
392398
}
393399

394-
# Use -Mail as the lookup works in both corp and TME tenants
400+
# Support corp tenant and TME tenant user id lookups
395401
$userAccount = (Get-AzADUser -Mail (Get-AzContext).Account.Id)
402+
if ($userAccount -eq $null -or !$userAccount.Id) {
403+
$userAccount = (Get-AzADUser -UserPrincipalName (Get-AzContext).Account)
404+
}
405+
if ($userAccount -eq $null -or !$userAccount.Id) {
406+
throw "Failed to find entra object ID for the current user"
407+
}
396408
$TestApplicationOid = $userAccount.Id
397409
$TestApplicationId = $testApplicationOid
398410
$userAccountName = $userAccount.UserPrincipalName

eng/common/pipelines/templates/jobs/generate-job-matrix.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ parameters:
5454
- name: PRMatrixIndirectFilters
5555
type: object
5656
default: []
57+
- name: PRMatrixSparseIndirect
58+
type: boolean
59+
default: true
5760
# Mappings to OS name required at template compile time by 1es pipeline templates
5861
- name: Pools
5962
type: object
@@ -142,7 +145,8 @@ jobs:
142145
-Filters '${{ join(''',''', parameters.MatrixFilters) }}', 'container=^$', 'SupportedClouds=^$|${{ parameters.CloudConfig.Cloud }}', 'Pool=${{ pool.filter }}' `
143146
-IndirectFilters '${{ join(''',''', parameters.PRMatrixIndirectFilters) }}' `
144147
-Replace '${{ join(''',''', parameters.MatrixReplace) }}' `
145-
-PackagesPerPRJob ${{ parameters.PRJobBatchSize }}
148+
-PackagesPerPRJob ${{ parameters.PRJobBatchSize }} `
149+
-SparseIndirect $${{ parameters.PRMatrixSparseIndirect }}
146150
displayName: Create ${{ pool.name }} PR Matrix
147151
name: vm_job_matrix_pr_${{ pool.name }}
148152

eng/common/scripts/job-matrix/Create-PrJobMatrix.ps1

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ param (
4444
[Parameter(Mandatory = $False)][array] $Filters,
4545
[Parameter(Mandatory = $False)][array] $IndirectFilters,
4646
[Parameter(Mandatory = $False)][array] $Replace,
47+
[Parameter(Mandatory = $False)][bool] $SparseIndirect = $true,
4748
[Parameter(Mandatory = $False)][int] $PackagesPerPRJob = 10,
4849
[Parameter()][switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID)
4950
)
@@ -72,7 +73,8 @@ function QueuePop([ref]$queue) {
7273

7374
function GeneratePRMatrixForBatch {
7475
param (
75-
[Parameter(Mandatory = $true)][array] $Packages
76+
[Parameter(Mandatory = $true)][array] $Packages,
77+
[Parameter(Mandatory = $false)][bool] $FullSparseMatrix = $false
7678
)
7779

7880
$OverallResult = @()
@@ -85,6 +87,8 @@ function GeneratePRMatrixForBatch {
8587
$directBatch = $Packages[0].IncludedForValidation -eq $false
8688
Write-Host "Generating matrix for $($directBatch ? 'direct' : 'indirect') packages"
8789

90+
$batchNamePrefix = $($directBatch ? 'b' : 'ib')
91+
8892
# The key here is that after we group the packages by the matrix config objects, we can use the first item's MatrixConfig
8993
# to generate the matrix for the group, no reason to have to parse the key value backwards to get the matrix config.
9094
$matrixBatchesByConfig = Group-ByObjectKey $Packages "CIMatrixConfigs"
@@ -134,10 +138,10 @@ function GeneratePRMatrixForBatch {
134138
# we only need to modify the generated job name if there is more than one matrix config + batch
135139
$matrixSuffixNecessary = $matrixBatchesByConfig.Keys.Count -gt 1
136140

137-
# if we are doing direct packages, we need to walk the batches and duplicate the matrix config for each batch, fully assigning
141+
# if we are doing direct packages (or a full indirect matrix), we need to walk the batches and duplicate the matrix config for each batch, fully assigning
138142
# the each batch's packages to the matrix config. This will generate a _non-sparse_ matrix for the incoming packages
139-
if ($directBatch) {
140-
$batchSuffixNecessary = $packageBatches.Length -gt 1
143+
if ($directBatch -or $FullSparseMatrix) {
144+
$batchSuffixNecessary = $packageBatches.Length -gt $($directBatch ? 1 : 0)
141145
$batchCounter = 1
142146

143147
foreach ($batch in $packageBatches) {
@@ -155,7 +159,7 @@ function GeneratePRMatrixForBatch {
155159
}
156160

157161
if ($batchSuffixNecessary) {
158-
$outputItem["name"] = $outputItem["name"] + "_b$batchCounter"
162+
$outputItem["name"] = $outputItem["name"] + "$batchNamePrefix$batchCounter"
159163
}
160164

161165
$OverallResult += $outputItem
@@ -180,7 +184,7 @@ function GeneratePRMatrixForBatch {
180184
}
181185

182186
if ($batchSuffixNecessary) {
183-
$outputItem["name"] = $outputItem["name"] + "_ib$batchCounter"
187+
$outputItem["name"] = $outputItem["name"] + "_$batchNamePrefix$batchCounter"
184188
}
185189
# now we need to take an item from the front of the matrix results, clone it, and add it to the back of the matrix results
186190
# we will add the cloned version to OverallResult
@@ -236,7 +240,7 @@ if ($indirectPackages) {
236240
foreach($artifact in $indirectPackages) {
237241
Write-Host "-> $($artifact.ArtifactName)"
238242
}
239-
$OverallResult += GeneratePRMatrixForBatch -Packages $indirectPackages
243+
$OverallResult += GeneratePRMatrixForBatch -Packages $indirectPackages -FullSparseMatrix (-not $SparseIndirect)
240244
}
241245
$serialized = SerializePipelineMatrix $OverallResult
242246

eng/packages/http-client-csharp/eng/scripts/Generate.ps1

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
param(
33
$filter,
44
[bool]$Stubbed = $true,
5-
[bool]$LaunchOnly = $false
5+
[bool]$LaunchOnly = $false,
6+
[switch]$ForceNewProject = $false
67
)
78

89
Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force;
@@ -20,14 +21,14 @@ if (-not $LaunchOnly) {
2021
$unbrandedTypespecTestProject = Join-Path $testProjectsLocalDir "Basic-TypeSpec"
2122
$unbrandedTypespecTestProject = $unbrandedTypespecTestProject
2223

23-
Invoke (Get-TspCommand "$unbrandedTypespecTestProject/Basic-TypeSpec.tsp" $unbrandedTypespecTestProject)
24+
Invoke (Get-TspCommand "$unbrandedTypespecTestProject/Basic-TypeSpec.tsp" $unbrandedTypespecTestProject -forceNewProject $ForceNewProject)
2425

2526
# exit if the generation failed
2627
if ($LASTEXITCODE -ne 0) {
2728
exit $LASTEXITCODE
2829
}
2930

30-
Write-Host "Building UnbrandedTypeSpec" -ForegroundColor Cyan
31+
Write-Host "Building BasicTypeSpec" -ForegroundColor Cyan
3132
Invoke "dotnet build $packageRoot/generator/TestProjects/Local/Basic-TypeSpec/src/BasicTypeSpec.csproj"
3233

3334
# exit if the generation failed
@@ -39,7 +40,7 @@ if (-not $LaunchOnly) {
3940

4041
$specsDirectory = "$packageRoot/node_modules/@typespec/http-specs"
4142
$azureSpecsDirectory = "$packageRoot/node_modules/@azure-tools/azure-http-specs"
42-
$cadlRanchRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch'
43+
$spectorRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector'
4344

4445
function IsSpecDir {
4546
param (
@@ -95,9 +96,9 @@ $azureAllowSpecs = @(
9596
Join-Path 'http' 'resiliency' 'srv-driven'
9697
)
9798

98-
$cadlRanchLaunchProjects = @{}
99+
$spectorLaunchProjects = @{}
99100

100-
# Loop through all directories and subdirectories of the cadl ranch specs
101+
# Loop through all directories and subdirectories of the spector specs
101102
$directories = @(Get-ChildItem -Path "$specsDirectory/specs" -Directory -Recurse)
102103
$directories += @(Get-ChildItem -Path "$azureSpecsDirectory/specs" -Directory -Recurse)
103104
foreach ($directory in $directories) {
@@ -128,7 +129,7 @@ foreach ($directory in $directories) {
128129
continue
129130
}
130131

131-
$generationDir = $cadlRanchRoot
132+
$generationDir = $spectorRoot
132133
foreach ($folder in $folders) {
133134
$generationDir = Join-Path $generationDir $folder
134135
}
@@ -140,26 +141,26 @@ foreach ($directory in $directories) {
140141

141142
if ($folders.Contains("versioning")) {
142143
Generate-Versioning $directory.FullName $generationDir -generateStub $stubbed
143-
$cadlRanchLaunchProjects.Add($($folders -join "-") + "-v1", $("TestProjects/CadlRanch/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v1")
144-
$cadlRanchLaunchProjects.Add($($folders -join "-") + "-v2", $("TestProjects/CadlRanch/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v2")
144+
$spectorLaunchProjects.Add($($folders -join "-") + "-v1", $("TestProjects/Spector/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v1")
145+
$spectorLaunchProjects.Add($($folders -join "-") + "-v2", $("TestProjects/Spector/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v2")
145146
continue
146147
}
147148

148149
# srv-driven contains two separate specs, for two separate clients. We need to generate both.
149150
if ($folders.Contains("srv-driven")) {
150151
Generate-Srv-Driven $directory.FullName $generationDir -generateStub $stubbed
151-
$cadlRanchLaunchProjects.Add($($folders -join "-") + "-v1", $("TestProjects/CadlRanch/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v1")
152-
$cadlRanchLaunchProjects.Add($($folders -join "-") + "-v2", $("TestProjects/CadlRanch/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v2")
152+
$spectorLaunchProjects.Add($($folders -join "-") + "-v1", $("TestProjects/Spector/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v1")
153+
$spectorLaunchProjects.Add($($folders -join "-") + "-v2", $("TestProjects/Spector/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))") + "/v2")
153154
continue
154155
}
155156

156-
$cadlRanchLaunchProjects.Add(($folders -join "-"), ("TestProjects/CadlRanch/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))"))
157+
$spectorLaunchProjects.Add(($folders -join "-"), ("TestProjects/Spector/$($subPath.Replace([System.IO.Path]::DirectorySeparatorChar, '/'))"))
157158
if ($LaunchOnly) {
158159
continue
159160
}
160161

161162
Write-Host "Generating $subPath" -ForegroundColor Cyan
162-
Invoke (Get-TspCommand $specFile $generationDir $stubbed)
163+
Invoke (Get-TspCommand $specFile $generationDir $stubbed -forceNewProject $ForceNewProject)
163164

164165
# exit if the generation failed
165166
if ($LASTEXITCODE -ne 0) {
@@ -181,7 +182,7 @@ if ($null -eq $filter) {
181182
$launchSettings["profiles"]["Basic-TypeSpec"].Add("commandName", "Executable")
182183
$launchSettings["profiles"]["Basic-TypeSpec"].Add("executablePath", "dotnet")
183184

184-
foreach ($kvp in $cadlRanchLaunchProjects.GetEnumerator()) {
185+
foreach ($kvp in $spectorLaunchProjects.GetEnumerator()) {
185186
$launchSettings["profiles"].Add($kvp.Key, @{})
186187
$launchSettings["profiles"][$kvp.Key].Add("commandLineArgs", "`$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.dll `$(SolutionDir)/$($kvp.Value) -p AzureStubPlugin")
187188
$launchSettings["profiles"][$kvp.Key].Add("commandName", "Executable")
@@ -207,5 +208,5 @@ if ($null -eq $filter) {
207208
# Write the launch settings to the launchSettings.json file
208209
$launchSettingsPath = Join-Path $solutionDir "Azure.Generator" "src" "Properties" "launchSettings.json"
209210
# Write the settings to JSON and normalize line endings to Unix style (LF)
210-
$sortedLaunchSettings | ConvertTo-Json | ForEach-Object { $_ -replace "`r`n", "`n" } | Set-Content $launchSettingsPath
211+
$sortedLaunchSettings | ConvertTo-Json | ForEach-Object { ($_ -replace "`r`n", "`n") + "`n" } | Set-Content -NoNewline $launchSettingsPath
211212
}

eng/packages/http-client-csharp/eng/scripts/Generation.psm1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function Get-TspCommand {
2626
[string]$generationDir,
2727
[bool]$generateStub = $false,
2828
[string]$namespaceOverride = $null,
29-
[string]$apiVersion = $null
29+
[string]$apiVersion = $null,
30+
[bool]$forceNewProject = $false
3031
)
3132
$command = "npx tsp compile $specFile"
3233
$command += " --trace @azure-typespec/http-client-csharp"
@@ -49,6 +50,10 @@ function Get-TspCommand {
4950
$command += " --option @azure-typespec/http-client-csharp.api-version=$apiVersion"
5051
}
5152

53+
if ($forceNewProject) {
54+
$command += " --option @azure-typespec/http-client-csharp.new-project=true"
55+
}
56+
5257
return $command
5358
}
5459

eng/packages/http-client-csharp/eng/scripts/Get-CadlRanch-Coverage.ps1 renamed to eng/packages/http-client-csharp/eng/scripts/Get-Spector-Coverage.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#Requires -Version 7.0
22

33
Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force;
4-
Import-Module "$PSScriptRoot\CadlRanch-Helper.psm1" -DisableNameChecking -Force;
4+
Import-Module "$PSScriptRoot\Spector-Helper.psm1" -DisableNameChecking -Force;
55

66
$packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..')
77

88
Refresh-Build
99

1010
$specsDirectory = Join-Path $packageRoot 'node_modules' '@typespec' 'http-specs' 'specs'
1111
$azureSpecsDirectory = Join-Path $packageRoot 'node_modules' '@azure-tools' 'azure-http-specs' 'specs'
12-
$cadlRanchRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch' 'http'
13-
$directories = Get-ChildItem -Path "$cadlRanchRoot" -Directory -Recurse
14-
$cadlRanchCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch.Tests' 'TestProjects.CadlRanch.Tests.csproj'
12+
$spectorRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector' 'http'
13+
$directories = Get-ChildItem -Path "$spectorRoot" -Directory -Recurse
14+
$spectorCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector.Tests' 'TestProjects.Spector.Tests.csproj'
1515

1616
$coverageDir = Join-Path $packageRoot 'generator' 'artifacts' 'coverage'
1717

@@ -26,7 +26,7 @@ foreach ($directory in $directories) {
2626
}
2727

2828
$outputDir = $directory.FullName.Substring(0, $directory.FullName.IndexOf("src") - 1)
29-
$subPath = $outputDir.Substring($cadlRanchRoot.Length + 1)
29+
$subPath = $outputDir.Substring($spectorRoot.Length + 1)
3030

3131
Write-Host "Regenerating $subPath" -ForegroundColor Cyan
3232

@@ -66,8 +66,8 @@ foreach ($directory in $directories) {
6666
}
6767

6868
# test all
69-
Write-Host "Generating CadlRanch coverage" -ForegroundColor Cyan
70-
$command = "dotnet test $cadlRanchCsproj"
69+
Write-Host "Generating Spector coverage" -ForegroundColor Cyan
70+
$command = "dotnet test $spectorCsproj"
7171
Invoke $command
7272
# exit if the testing failed
7373
if ($LASTEXITCODE -ne 0) {
@@ -81,7 +81,7 @@ foreach ($directory in $directories) {
8181
}
8282

8383
$outputDir = $directory.FullName.Substring(0, $directory.FullName.IndexOf("src") - 1)
84-
$subPath = $outputDir.Substring($cadlRanchRoot.Length + 1)
84+
$subPath = $outputDir.Substring($spectorRoot.Length + 1)
8585

8686
Write-Host "Restoring $subPath" -ForegroundColor Cyan
8787
$command = "git clean -xfd $outputDir"
File renamed without changes.

eng/packages/http-client-csharp/eng/scripts/Test-CadlRanch.ps1 renamed to eng/packages/http-client-csharp/eng/scripts/Test-Spector.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
param($filter)
44

55
Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force;
6-
Import-Module "$PSScriptRoot\CadlRanch-Helper.psm1" -DisableNameChecking -Force;
6+
Import-Module "$PSScriptRoot\Spector-Helper.psm1" -DisableNameChecking -Force;
77

88
$packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..')
99

1010
Refresh-Build
1111

1212
$specsDirectory = Join-Path $packageRoot 'node_modules' '@typespec' 'http-specs' 'specs'
1313
$azureSpecsDirectory = Join-Path $packageRoot 'node_modules' '@azure-tools' 'azure-http-specs' 'specs'
14-
$cadlRanchRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch'
15-
$cadlRanchRootHttp = Join-Path $cadlRanchRoot 'http'
16-
$directories = Get-ChildItem -Path "$cadlRanchRootHttp" -Directory -Recurse
17-
$cadlRanchCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch.Tests' 'TestProjects.CadlRanch.Tests.csproj'
14+
$spectorRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector'
15+
$spectorRootHttp = Join-Path $spectorRoot 'http'
16+
$directories = Get-ChildItem -Path "$spectorRootHttp" -Directory -Recurse
17+
$spectorCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'Spector.Tests' 'TestProjects.Spector.Tests.csproj'
1818

1919
$coverageDir = Join-Path $packageRoot 'generator' 'artifacts' 'coverage'
2020

@@ -28,15 +28,15 @@ foreach ($directory in $directories) {
2828
}
2929

3030
$outputDir = $directory.FullName.Substring(0, $directory.FullName.IndexOf("src") - 1)
31-
$subPath = $outputDir.Substring($cadlRanchRootHttp.Length + 1)
31+
$subPath = $outputDir.Substring($spectorRootHttp.Length + 1)
3232
$folders = $subPath.Split([System.IO.Path]::DirectorySeparatorChar)
3333

3434
if (-not (Compare-Paths $subPath $filter)) {
3535
continue
3636
}
3737

38-
$testPath = Join-Path "$cadlRanchRoot.Tests" "Http"
39-
$testFilter = "TestProjects.CadlRanch.Tests.Http"
38+
$testPath = Join-Path "$spectorRoot.Tests" "Http"
39+
$testFilter = "TestProjects.Spector.Tests.Http"
4040
foreach ($folder in $folders) {
4141
$segment = "$(Get-Namespace $folder)"
4242

@@ -87,7 +87,7 @@ foreach ($directory in $directories) {
8787
}
8888

8989
Write-Host "Testing $subPath" -ForegroundColor Cyan
90-
$command = "dotnet test $cadlRanchCsproj --filter `"FullyQualifiedName~$testFilter`""
90+
$command = "dotnet test $spectorCsproj --filter `"FullyQualifiedName~$testFilter`""
9191
Invoke $command
9292
# exit if the testing failed
9393
if ($LASTEXITCODE -ne 0) {

0 commit comments

Comments
 (0)