-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into analyze-change-ts
- Loading branch information
Showing
81 changed files
with
5,920 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
packages/http-client-csharp/eng/scripts/Test-CadlRanch.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# cspell:ignore cadlranch | ||
|
||
#Requires -Version 7.0 | ||
|
||
Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force; | ||
|
||
$packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..') | ||
|
||
Refresh-Build | ||
|
||
$specsDirectory = "$packageRoot/node_modules/@azure-tools/cadl-ranch-specs" | ||
$cadlRanchRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch' | ||
$directories = Get-ChildItem -Path "$cadlRanchRoot" -Directory -Recurse | ||
$cadlRanchCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch.Tests' 'TestProjects.CadlRanch.Tests.csproj' | ||
$runSettings = Join-Path $packageRoot 'eng' 'test-configurations' 'cadlranch.runsettings' | ||
|
||
function IsGenerated { | ||
param ( | ||
[string]$dir | ||
) | ||
|
||
if (-not ($dir.EndsWith("Generated"))) { | ||
return $false | ||
} | ||
|
||
$csFiles = Get-ChildItem -Path $directory -Filter *.cs -File | ||
return $csFiles.Count -gt 0 | ||
} | ||
|
||
function Capitalize-FirstLetter { | ||
param ( | ||
[string]$inputString | ||
) | ||
|
||
if ([string]::IsNullOrEmpty($inputString)) { | ||
return $inputString | ||
} | ||
|
||
$firstChar = $inputString[0].ToString().ToUpper() | ||
$restOfString = $inputString.Substring(1) | ||
|
||
return $firstChar + $restOfString | ||
} | ||
|
||
function Get-Namespace { | ||
param ( | ||
[string]$dir | ||
) | ||
|
||
$words = $dir.Split('-') | ||
$namespace = "" | ||
foreach ($word in $words) { | ||
$namespace += Capitalize-FirstLetter $word | ||
} | ||
return $namespace | ||
} | ||
|
||
foreach ($directory in $directories) { | ||
if (-not (IsGenerated $directory.FullName)) { | ||
continue | ||
} | ||
|
||
$outputDir = $directory.FullName.Substring(0, $directory.FullName.IndexOf("src") - 1) | ||
$subPath = $outputDir.Substring($cadlRanchRoot.Length + 1) | ||
$folders = $subPath.Split([System.IO.Path]::DirectorySeparatorChar) | ||
|
||
$testFilter = "TestProjects.CadlRanch.Tests" | ||
foreach ($folder in $folders) { | ||
$testFilter += ".$(Get-Namespace $folder)" | ||
} | ||
|
||
Write-Host "Regenerating $subPath" -ForegroundColor Cyan | ||
|
||
$specFile = Join-Path $specsDirectory $subPath "main.tsp" | ||
|
||
$command = Get-TspCommand $specFile $outputDir | ||
Invoke $command | ||
# exit if the generation failed | ||
if ($LASTEXITCODE -ne 0) { | ||
exit $LASTEXITCODE | ||
} | ||
|
||
Write-Host "Testing $subPath" -ForegroundColor Cyan | ||
$command = "dotnet test $cadlRanchCsproj --filter `"FullyQualifiedName~$testFilter`" --settings $runSettings" | ||
Invoke $command | ||
# exit if the generation failed | ||
if ($LASTEXITCODE -ne 0) { | ||
exit $LASTEXITCODE | ||
} | ||
|
||
Write-Host "Restoring $subPath" -ForegroundColor Cyan | ||
$command = "git clean -xfd $outputDir" | ||
Invoke $command | ||
# exit if the generation failed | ||
if ($LASTEXITCODE -ne 0) { | ||
exit $LASTEXITCODE | ||
} | ||
$command = "git restore $outputDir" | ||
Invoke $command | ||
# exit if the generation failed | ||
if ($LASTEXITCODE -ne 0) { | ||
exit $LASTEXITCODE | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/http-client-csharp/eng/test-configurations/cadlranch.runsettings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<RunSettings> | ||
<TestRunParameters> | ||
<Parameter name="RunCadlRanch" value="true" /> | ||
</TestRunParameters> | ||
</RunSettings> |
25 changes: 25 additions & 0 deletions
25
...arp.ClientModel.StubLibrary/src/Microsoft.Generator.CSharp.ClientModel.StubLibrary.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<PackageId>StubPlugin</PackageId> | ||
<Version>1.0.0-beta.1</Version> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.ClientModel" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Microsoft.Generator.CSharp.ClientModel\src\Microsoft.Generator.CSharp.ClientModel.csproj" /> | ||
</ItemGroup> | ||
|
||
<!-- Copy output to package dist path for local execution and --> | ||
<Target Name="CopyForNpmPackage" AfterTargets="Build"> | ||
<Message Text="Copying output to dist path" Importance="high" /> | ||
<ItemGroup> | ||
<SourceDir Include="$(OutputPath)**\*Stub*.*" /> | ||
</ItemGroup> | ||
<Copy SourceFiles="@(SourceDir)" DestinationFolder="$(MSBuildThisFileDirectory)..\..\..\dist\generator\%(RecursiveDir)" /> | ||
</Target> | ||
|
||
</Project> |
Oops, something went wrong.