Skip to content

Commit 68d87b3

Browse files
chunyu3lirenhe
andauthored
Typespec renaming (#3199)
* typespec rename and upgrade to typespec 0.41.0 * update typespec projects in testProjects * upgrade cadl-ranch * update cadl-ranch projects and emitter test projects * update readme * update test * update emitter unit test * typespec renaming test projects * rename cadl ranch test * rename emitter testproject * rename cadlRanchProjects.Tests * upgrade emitter version to 0.2.0 * Update eng/CadlGenerate.ps1 Co-authored-by: Renhe Li <[email protected]> * rename script name * update document and the build target --------- Co-authored-by: Renhe Li <[email protected]>
1 parent 6699bcc commit 68d87b3

File tree

303 files changed

+2024
-1703
lines changed

Some content is hidden

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

303 files changed

+2024
-1703
lines changed

eng/ExecuteCadlEmitterUnitTests.ps1 renamed to eng/ExecuteTypespecEmitterUnitTests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ $ErrorActionPreference = 'Stop'
44
Set-StrictMode -Version 1
55

66
Write-Host 'Generating test CADL json...'
7-
& (Join-Path $PSScriptRoot 'CadlGenerate.ps1')
7+
& (Join-Path $PSScriptRoot 'TypespecGenerate.ps1')
88

99
Write-Host 'Checking generated file differences...'
1010
git -c core.safecrlf=false diff --ignore-space-at-eol --exit-code
1111
if ($LastExitCode -ne 0)
1212
{
13-
Write-Error 'Generated code is not up to date, please run CadlGenerate.ps1'
13+
Write-Error 'Generated code is not up to date, please run TypespecGenerate.ps1'
1414
}

eng/Generate.ps1

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $sharedSource = Join-Path $repoRoot 'src' 'assets'
1919
$configurationPath = Join-Path $repoRoot 'readme.md'
2020
$testServerSwaggerPath = Join-Path $repoRoot 'node_modules' '@microsoft.azure' 'autorest.testserver' 'swagger'
2121
$cadlRanchFilePath = Join-Path $repoRoot 'node_modules' '@azure-tools' 'cadl-ranch-specs' 'http'
22-
$cadlEmitOptions = '--option @azure-tools/cadl-csharp.save-inputs=true --option @azure-tools/cadl-csharp.clear-output-folder=true'
22+
$cadlEmitOptions = '--option @azure-tools/typespec-csharp.save-inputs=true --option @azure-tools/typespec-csharp.clear-output-folder=true'
2323

2424
function Add-Swagger ([string]$name, [string]$output, [string]$arguments) {
2525
$swaggerDefinitions[$name] = @{
@@ -37,7 +37,7 @@ function Add-Swagger-Test ([string]$name, [string]$output, [string]$arguments) {
3737
}
3838
}
3939

40-
function Add-Cadl([string]$name, [string]$output, [string]$mainFile="", [string]$arguments="") {
40+
function Add-Typespec([string]$name, [string]$output, [string]$mainFile="", [string]$arguments="") {
4141
$cadlDefinitions[$name] = @{
4242
'projectName'=$name;
4343
'output'=$output;
@@ -53,11 +53,11 @@ function Add-TestServer-Swagger ([string]$testName, [string]$projectSuffix, [str
5353
Add-Swagger "$testName$projectSuffix" $projectDirectory "--require=$configurationPath --try-require=$inputReadme --input-file=$inputFile $additionalArgs"
5454
}
5555

56-
function Add-CadlRanch-Cadl([string]$testName, [string]$projectPrefix, [string]$cadlRanchProjectsDirectory, [boolean]$generateConvenience) {
56+
function Add-CadlRanch-Typespec([string]$testName, [string]$projectPrefix, [string]$cadlRanchProjectsDirectory, [boolean]$generateConvenience) {
5757
$projectDirectory = Join-Path $cadlRanchProjectsDirectory $testName
5858
$cadlMain = Join-Path $cadlRanchFilePath $testName "main.cadl"
59-
$convenienceOption = If ($generateConvenience) {""} Else {" --option @azure-tools/cadl-csharp.generate-convenience-methods=false"}
60-
Add-Cadl "$projectPrefix$testName" $projectDirectory $cadlMain "--option @azure-tools/cadl-csharp.unreferenced-types-handling=keepAll$convenienceOption"
59+
$convenienceOption = If ($generateConvenience) {""} Else {" --option @azure-tools/typespec-csharp.generate-convenience-methods=false"}
60+
Add-Typespec "$projectPrefix$testName" $projectDirectory $cadlMain "--option @azure-tools/typespec-csharp.unreferenced-types-handling=keepAll$convenienceOption"
6161
}
6262

6363
$testNames =
@@ -168,8 +168,8 @@ function Add-Directory ([string]$testName, [string]$directory, [boolean]$forTest
168168
Add-Swagger-Test $testName $directory $testArguments
169169
}
170170
else {
171-
if ($testName.EndsWith("Cadl")) {
172-
Add-Cadl $testName $directory
171+
if ($testName.EndsWith("Typespec")) {
172+
Add-Typespec $testName $directory
173173
} else {
174174
Add-Swagger $testName $directory $testArguments
175175
}
@@ -194,8 +194,8 @@ if (!($Exclude -contains "TestProjects"))
194194
Add-Directory $testName $testsFolder $TRUE
195195
continue
196196
}
197-
if ($testName.EndsWith("Cadl")) {
198-
Add-Cadl $testName $directory "" "--option @azure-tools/cadl-csharp.generate-convenience-methods=false"
197+
if ($testName.EndsWith("Typespec")) {
198+
Add-Typespec $testName $directory "" "--option @azure-tools/typespec-csharp.generate-convenience-methods=false"
199199
} else {
200200
if (Test-Path $readmeConfigurationPath)
201201
{
@@ -244,14 +244,14 @@ if (!($Exclude -contains "Samples"))
244244
foreach ($projectName in $cadlSampleProjectName)
245245
{
246246
$projectDirectory = Join-Path $repoRoot 'samples' $projectName
247-
$cadlMain = Join-Path $projectDirectory "main.cadl"
248-
$cadlClient = Join-Path $projectDirectory "client.cadl"
249-
$mainCadlFile = If (Test-Path "$cadlClient") { Resolve-Path "$cadlClient" } Else { Resolve-Path "$cadlMain"}
250-
Add-Cadl $projectName $projectDirectory $mainCadlFile
247+
$tspMain = Join-Path $projectDirectory "main.tsp"
248+
$tspClient = Join-Path $projectDirectory "client.tsp"
249+
$mainTspFile = If (Test-Path "$tspClient") { Resolve-Path "$tspClient" } Else { Resolve-Path "$tspMain"}
250+
Add-Typespec $projectName $projectDirectory $mainTspFile
251251
}
252252
}
253253

254-
# Cadl projects
254+
# Typespec projects
255255
$cadlRanchProjectDirectory = Join-Path $repoRoot 'test' 'CadlRanchProjects'
256256
$cadlRanchProjectPathsWithoutConvenience = # Needs justification to add item
257257
'enums/extensible', # https://github.com/Azure/autorest.csharp/issues/3079
@@ -271,17 +271,17 @@ if (!($Exclude -contains "CadlRanchProjects"))
271271
{
272272
foreach ($testPath in $cadlRanchProjectPaths)
273273
{
274-
Add-CadlRanch-Cadl $testPath "cadl-" $cadlRanchProjectDirectory $TRUE
274+
Add-CadlRanch-Typespec $testPath "typespec-" $cadlRanchProjectDirectory $TRUE
275275
}
276276

277277
foreach ($testPath in $cadlRanchProjectPathsWithoutConvenience)
278278
{
279-
Add-CadlRanch-Cadl $testPath "cadl-" $cadlRanchProjectDirectory $FALSE
279+
Add-CadlRanch-Typespec $testPath "typespec-" $cadlRanchProjectDirectory $FALSE
280280
}
281281
}
282282

283283
# TODO: remove later after cadl-ranch fixes the discriminator tests
284-
Add-Cadl "inheritance-cadl" (Join-Path $cadlRanchProjectDirectory "inheritance")
284+
Add-Typespec "inheritance-typespec" (Join-Path $cadlRanchProjectDirectory "inheritance")
285285

286286
# Smoke tests
287287
if (!($Exclude -contains "SmokeTests"))
@@ -380,7 +380,7 @@ if ($reset -or $env:TF_BUILD)
380380

381381
if ($cadlCount -gt 0)
382382
{
383-
Invoke-CadlSetup
383+
Invoke-TypespecSetup
384384
}
385385
}
386386

@@ -411,6 +411,6 @@ $keys | %{ $swaggerTestDefinitions[$_] } | ForEach-Object -Parallel {
411411
$keys | %{ $cadlDefinitions[$_] } | ForEach-Object -Parallel {
412412
if ($_.output -ne $null) {
413413
Import-Module "$using:PSScriptRoot\Generation.psm1" -DisableNameChecking;
414-
Invoke-Cadl $_.output $_.projectName $_.mainFile $_.arguments $using:sharedSource $using:fast $using:debug;
414+
Invoke-Typespec $_.output $_.projectName $_.mainFile $_.arguments $using:sharedSource $using:fast $using:debug;
415415
}
416416
} -ThrottleLimit $parallel

eng/Generation.psm1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function AutoRest-Reset()
5050
Invoke "$script:autoRestBinary --reset"
5151
}
5252

53-
function Invoke-Cadl($baseOutput, $projectName, $mainFile, $arguments="", $sharedSource="", $fast="", $debug="")
53+
function Invoke-Typespec($baseOutput, $projectName, $mainFile, $arguments="", $sharedSource="", $fast="", $debug="")
5454
{
5555
if (!(Test-Path $baseOutput)) {
5656
New-Item $baseOutput -ItemType Directory
@@ -81,8 +81,8 @@ function Invoke-Cadl($baseOutput, $projectName, $mainFile, $arguments="", $share
8181
$autorestCsharpBinPath = Join-Path $repoRootPath "artifacts/bin/AutoRest.CSharp/Debug/net6.0/AutoRest.CSharp.dll"
8282
Try
8383
{
84-
$cadlFileName = $mainFile ? $mainFile : "$baseOutput/$projectName.cadl"
85-
$emitCommand = "npx cadl compile $cadlFileName --emit @azure-tools/cadl-csharp --option @azure-tools/cadl-csharp.emitter-output-dir=$outputPath --option @azure-tools/cadl-csharp.csharpGeneratorPath=$autorestCsharpBinPath $arguments"
84+
$cadlFileName = $mainFile ? $mainFile : "$baseOutput/$projectName.tsp"
85+
$emitCommand = "npx tsp compile $cadlFileName --emit @azure-tools/typespec-csharp --option @azure-tools/typespec-csharp.emitter-output-dir=$outputPath --option @azure-tools/typespec-csharp.csharpGeneratorPath=$autorestCsharpBinPath $arguments"
8686
Invoke $emitCommand $outputPath
8787
}
8888
Finally
@@ -94,7 +94,7 @@ function Invoke-Cadl($baseOutput, $projectName, $mainFile, $arguments="", $share
9494
Invoke "dotnet build $baseOutput --verbosity quiet /nologo"
9595
}
9696

97-
function Invoke-CadlSetup()
97+
function Invoke-TypespecSetup()
9898
{
9999
# build emitter
100100
$emitterPath = Join-Path $PSScriptRoot ".." "src" "CADL.Extension" "Emitter.Csharp"
@@ -133,5 +133,5 @@ Export-ModuleMember -Function "Invoke"
133133
Export-ModuleMember -Function "Invoke-AutoRest"
134134
Export-ModuleMember -Function "AutoRest-Reset"
135135
Export-ModuleMember -Function "Get-AutoRestProject"
136-
Export-ModuleMember -Function "Invoke-Cadl"
137-
Export-ModuleMember -Function "Invoke-CadlSetup"
136+
Export-ModuleMember -Function "Invoke-Typespec"
137+
Export-ModuleMember -Function "Invoke-TypespecSetup"

eng/CadlGenerate.ps1 renamed to eng/TypespecGenerate.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ foreach ($directory in Get-ChildItem $testEmitterPath -Directory)
2323
{
2424
Remove-Item $projectPath/Generated -Force -Recurse
2525
}
26-
node node_modules/@cadl-lang/compiler/dist/core/cli.js compile $projectPath/$testName.cadl --emit @azure-tools/cadl-csharp --option @azure-tools/cadl-csharp.emitter-output-dir=$projectPath --option @azure-tools/cadl-csharp.skipSDKGeneration=true --option @azure-tools/cadl-csharp.save-inputs=true
26+
node node_modules/@typespec/compiler/dist/core/cli/cli.js compile $projectPath/$testName.tsp --emit @azure-tools/typespec-csharp --option @azure-tools/typespec-csharp.emitter-output-dir=$projectPath --option @azure-tools/typespec-csharp.skipSDKGeneration=true --option @azure-tools/typespec-csharp.save-inputs=true
2727
if (!$?) {
2828
Pop-Location
2929
throw "Failed to emit cadl model for $testName."
@@ -47,10 +47,10 @@ foreach ($directory in Get-ChildItem $samplePath -Directory)
4747
{
4848
Remove-Item $projectPath/Generated -Force -Recurse
4949
}
50-
node node_modules/@cadl-lang/compiler/dist/core/cli.js compile $projectPath/$testName.cadl --emit @azure-tools/cadl-csharp --option @azure-tools/cadl-csharp.emitter-output-dir=$projectPath --option @azure-tools/cadl-csharp.skipSDKGeneration=true --option @azure-tools/cadl-csharp.save-inputs=true
50+
node node_modules/@typespec/compiler/dist/core/cli/cli.js compile $projectPath/$testName.tsp --emit @azure-tools/typespec-csharp --option @azure-tools/typespec-csharp.emitter-output-dir=$projectPath --option @azure-tools/typespec-csharp.skipSDKGeneration=true --option @azure-tools/typespec-csharp.save-inputs=true
5151
if (!$?) {
5252
Pop-Location
53-
throw "Failed to emit cadl model for $testName."
53+
throw "Failed to emit typespec model for $testName."
5454
}
5555
}
5656

eng/UpdateGeneratorMetadata.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ $PackagesProps = "$SdkRepoRoot\eng\Packages.Data.props"
2323

2424
$CadlEmitterProps = "$SdkRepoRoot\eng\emitter-package.json"
2525
(Get-Content -Raw $CadlEmitterProps) -replace `
26-
'"@azure-tools/cadl-csharp": ".*?"',
27-
"`"@azure-tools/cadl-csharp`": `"$CadlEmitterVersion`"" | `
26+
'"@azure-tools/typespec-csharp": ".*?"',
27+
"`"@azure-tools/typespec-csharp`": `"$CadlEmitterVersion`"" | `
2828
Set-Content $CadlEmitterProps -NoNewline

eng/pipelines/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ stages:
100100
command: custom
101101
customCommand: run build
102102
workingDir: $(Build.SourcesDirectory)/autorest.csharp/src/CADL.Extension/Emitter.Csharp
103-
- pwsh: ./eng/ExecuteCadlEmitterUnitTests.ps1
103+
- pwsh: ./eng/ExecuteTypespecEmitterUnitTests.ps1
104104
displayName: 'E2E Test for CADL emitter'
105105
workingDirectory: $(Build.SourcesDirectory)/autorest.csharp
106106
- script: |

eng/pipelines/cadl-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ stages:
7676
command: custom
7777
customCommand: pack
7878
workingDir: $(Build.SourcesDirectory)/src/CADL.Extension/Emitter.Csharp
79-
- pwsh: ./eng/ExecuteCadlEmitterUnitTests.ps1
80-
displayName: 'E2E_Test for CADL emitter'
79+
- pwsh: ./eng/ExecuteTypespecEmitterUnitTests.ps1
80+
displayName: 'E2E_Test for TypeSpec emitter'
8181
workingDirectory: $(Build.SourcesDirectory)
8282
- script: |
8383
npm run test --prefix src/CADL.Extension/Emitter.Csharp
8484
displayName: 'Unit Test'
8585
workingDirectory: $(Build.SourcesDirectory)
8686
- script: |
8787
mkdir -p $(VAR_BUILD_ARTIFACT_STAGING_DIRECTORY)/packages
88-
cp azure-tools-cadl-csharp-*.tgz $(VAR_BUILD_ARTIFACT_STAGING_DIRECTORY)/packages/
88+
cp azure-tools-typespec-csharp-*.tgz $(VAR_BUILD_ARTIFACT_STAGING_DIRECTORY)/packages/
8989
displayName: 'Copy CADL Csharp emitter library to staging dir'
9090
workingDirectory: $(Build.SourcesDirectory)/src/CADL.Extension/Emitter.Csharp
9191
- task: PublishBuildArtifacts@1

0 commit comments

Comments
 (0)