Skip to content

Commit

Permalink
Merge branch 'main' into http-client-java_pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Dec 19, 2024
2 parents b8d4106 + 7dc64d8 commit 97b44d2
Show file tree
Hide file tree
Showing 24 changed files with 1,717 additions and 1,135 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/tadelesh-patch-1-2024-11-18-16-37-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-specs"
---

fix missing `@list` decorator for unbranded pageable operation
4 changes: 2 additions & 2 deletions eng/emitters/pipelines/templates/steps/test-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ steps:
displayName: "Upload Cadl Ranch Standard Coverage Report"
condition: and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'), eq('${{ parameters.EmitArtifacts }}', true))
inputs:
azureSubscription: "Cadl Ranch Storage"
azureSubscription: "TypeSpec Storage"
scriptType: "bash"
scriptLocation: "inlineScript"
inlineScript: npx cadl-ranch upload-coverage --coverageFile ./generator/artifacts/coverage/cadl-ranch-coverage-${{ parameters.LanguageShortName }}-standard.json --generatorName ${{ coalesce(parameters.CadlRanchName, parameters.LanguageShortName) }} --storageAccountName azuresdkcadlranch --generatorVersion $(node -p -e "require('./package.json').version") --generatorMode standard
inlineScript: npx tsp-spector upload-coverage --coverageFile ./generator/artifacts/coverage/tsp-spector-coverage-${{ parameters.LanguageShortName }}-standard.json --generatorName ${{ coalesce(parameters.CadlRanchName, parameters.LanguageShortName) }} --storageAccountName typespec --generatorVersion $(node -p -e "require('./package.json').version") --generatorMode standard
workingDirectory: $(selfRepositoryPath)${{ parameters.PackagePath }}
23 changes: 19 additions & 4 deletions packages/http-client-csharp/eng/scripts/Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ if (-not $LaunchOnly) {
}
}

$specsDirectory = "$packageRoot/node_modules/@azure-tools/cadl-ranch-specs"
$specsDirectory = "$packageRoot/node_modules/@typespec/http-specs"
$azureSpecsDirectory = "$packageRoot/node_modules/@azure-tools/azure-http-specs"
$cadlRanchRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch'

function IsSpecDir {
Expand All @@ -55,27 +56,41 @@ $failingSpecs = @(
Join-Path 'http' 'type' 'model' 'templated'
)

$azureAllowSpecs = @(
Join-Path 'http' 'client' 'naming'
Join-Path 'http' 'client' 'structure' 'client-operation-group'
Join-Path 'http' 'client' 'structure' 'default'
Join-Path 'http' 'client' 'structure' 'multi-client'
Join-Path 'http' 'client' 'structure' 'renamed-operation'
Join-Path 'http' 'client' 'structure' 'two-operation-group'
Join-Path 'http' 'resiliency' 'srv-driven'
)

$cadlRanchLaunchProjects = @{}

# Loop through all directories and subdirectories of the cadl ranch specs
$directories = Get-ChildItem -Path "$specsDirectory/http" -Directory -Recurse
$directories = @(Get-ChildItem -Path "$specsDirectory/specs" -Directory -Recurse)
$directories += @(Get-ChildItem -Path "$azureSpecsDirectory/specs" -Directory -Recurse)
foreach ($directory in $directories) {
if (-not (IsSpecDir $directory.FullName)) {
continue
}

$fromAzure = $directory.FullName.Contains("azure-http-specs")

$specFile = Join-Path $directory.FullName "client.tsp"
if (-not (Test-Path $specFile)) {
$specFile = Join-Path $directory.FullName "main.tsp"
}
$subPath = $directory.FullName.Substring($specsDirectory.Length + 1)
$subPath = if ($fromAzure) {$directory.FullName.Substring($azureSpecsDirectory.Length + 1)} else {$directory.FullName.Substring($specsDirectory.Length + 1)}
$subPath = $subPath -replace '^specs', 'http' # Keep consistent with the previous folder name because 'http' makes more sense then current 'specs'
$folders = $subPath.Split([System.IO.Path]::DirectorySeparatorChar)

if (-not (Compare-Paths $subPath $filter)) {
continue
}

if ($folders.Contains("azure")) {
if ($fromAzure -eq $true -and !$azureAllowSpecs.Contains($subPath)) {
continue
}

Expand Down
13 changes: 10 additions & 3 deletions packages/http-client-csharp/eng/scripts/Get-CadlRanch-Coverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ $packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..')

Refresh-Build

$specsDirectory = Join-Path $packageRoot 'node_modules' '@azure-tools' 'cadl-ranch-specs'
$cadlRanchRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch'
$specsDirectory = Join-Path $packageRoot 'node_modules' '@typespec' 'http-specs' 'specs'
$azureSpecsDirectory = Join-Path $packageRoot 'node_modules' '@azure-tools' 'azure-http-specs' 'specs'
$cadlRanchRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch' 'http'
$directories = Get-ChildItem -Path "$cadlRanchRoot" -Directory -Recurse
$cadlRanchCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch.Tests' 'TestProjects.CadlRanch.Tests.csproj'

Expand All @@ -33,6 +34,12 @@ foreach ($directory in $directories) {
if (-not (Test-Path $specFile)) {
$specFile = Join-Path $specsDirectory $subPath "main.tsp"
}
if (-not (Test-Path $specFile)) {
$specFile = Join-Path $azureSpecsDirectory $subPath "client.tsp"
}
if (-not (Test-Path $specFile)) {
$specFile = Join-Path $azureSpecsDirectory $subPath "main.tsp"
}

if ($subPath.Contains("versioning")) {
if ($subPath.Contains("v1")) {
Expand All @@ -45,7 +52,7 @@ foreach ($directory in $directories) {
if ($subPath.Contains("srv-driven")) {
if ($subPath.Contains("v1")) {
# this will generate v1 and v2 so we only need to call it once for one of the versions
Generate-Srv-Driven ($(Join-Path $specsDirectory $subPath) | Split-Path) $($outputDir | Split-Path) -createOutputDirIfNotExist $false
Generate-Srv-Driven ($(Join-Path $azureSpecsDirectory $subPath) | Split-Path) $($outputDir | Split-Path) -createOutputDirIfNotExist $false
}
continue
}
Expand Down
15 changes: 11 additions & 4 deletions packages/http-client-csharp/eng/scripts/Test-CadlRanch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ $packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..')

Refresh-Build

$specsDirectory = "$packageRoot/node_modules/@azure-tools/cadl-ranch-specs"
$cadlRanchRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch'
$specsDirectory = Join-Path $packageRoot 'node_modules' '@typespec' 'http-specs' 'specs'
$azureSpecsDirectory = Join-Path $packageRoot 'node_modules' '@azure-tools' 'azure-http-specs' 'specs'
$cadlRanchRoot = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch' 'http'
$directories = Get-ChildItem -Path "$cadlRanchRoot" -Directory -Recurse
$cadlRanchCsproj = Join-Path $packageRoot 'generator' 'TestProjects' 'CadlRanch.Tests' 'TestProjects.CadlRanch.Tests.csproj'

Expand Down Expand Up @@ -55,7 +56,13 @@ foreach ($directory in $directories) {
$specFile = Join-Path $specsDirectory $subPath "client.tsp"
if (-not (Test-Path $specFile)) {
$specFile = Join-Path $specsDirectory $subPath "main.tsp"
}
}
if (-not (Test-Path $specFile)) {
$specFile = Join-Path $azureSpecsDirectory $subPath "client.tsp"
}
if (-not (Test-Path $specFile)) {
$specFile = Join-Path $azureSpecsDirectory $subPath "main.tsp"
}

if ($subPath.Contains("versioning")) {
if ($subPath.Contains("v1")) {
Expand All @@ -65,7 +72,7 @@ foreach ($directory in $directories) {
}
elseif ($subPath.Contains("srv-driven")) {
if ($subPath.Contains("v1")) {
Generate-Srv-Driven ($(Join-Path $specsDirectory $subPath) | Split-Path) $($outputDir | Split-Path) -createOutputDirIfNotExist $false
Generate-Srv-Driven ($(Join-Path $azureSpecsDirectory $subPath) | Split-Path) $($outputDir | Split-Path) -createOutputDirIfNotExist $false
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using System.Diagnostics;
using System.IO;

namespace TestProjects.CadlRanch.Tests
{
public class CadlRanchServer : TestServerBase
{
public CadlRanchServer() : base(GetBaseDirectory(), $"serve {GetScenariosPath()} --port 0 --coverageFile {GetCoverageFilePath()}")
public CadlRanchServer() : base(GetProcessPath(), $"serve {string.Join(" ", GetScenariosPaths())} --port 0 --coverageFile {GetCoverageFilePath()}")
{
}

internal static string GetBaseDirectory()
internal static string GetProcessPath()
{
var nodeModules = GetNodeModulesDirectory();
return Path.Combine(nodeModules, "@azure-tools", "cadl-ranch");
return Path.Combine(nodeModules, "@typespec", "spector", "dist", "src", "cli", "cli.js");
}

internal static string GetSpecDirectory()
{
var nodeModules = GetNodeModulesDirectory();
return Path.Combine(nodeModules, "@azure-tools", "cadl-ranch-specs");
return Path.Combine(nodeModules, "@typespec", "http-specs");
}

internal static string GetScenariosPath()
internal static string GetAzureSpecDirectory()
{
return Path.Combine(GetSpecDirectory(), "http");
var nodeModules = GetNodeModulesDirectory();
return Path.Combine(nodeModules, "@azure-tools", "azure-http-specs");
}

internal static IEnumerable<string> GetScenariosPaths()
{
yield return Path.Combine(GetSpecDirectory(), "specs");
yield return Path.Combine(GetAzureSpecDirectory(), "specs");
}
internal static string GetCoverageFilePath()
{
return Path.Combine(GetCoverageDirectory(), "cadl-ranch-coverage-csharp-standard.json");
return Path.Combine(GetCoverageDirectory(), "tsp-spector-coverage-csharp-standard.json");
}

protected override void Stop(Process process)
{
Process.Start(new ProcessStartInfo("node", $"{Path.Combine(GetNodeModulesDirectory(), "@azure-tools", "cadl-ranch", "dist", "cli", "cli.js")} server stop --port {Port}"));
Process.Start(new ProcessStartInfo("node", $"{GetProcessPath()} server stop --port {Port}"));
process.WaitForExit();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ public class TestServerBase : IDisposable
public Uri Host { get; }
public string Port { get; }

public TestServerBase(string baseDirectory, string processArguments)
public TestServerBase(string processPath, string processArguments)
{
var portPhrase = "Started server on port ";
var startup = Path.Combine(baseDirectory, "dist", "cli", "cli.js");

var processStartInfo = new ProcessStartInfo("node", $"{startup} {processArguments}")
var processStartInfo = new ProcessStartInfo("node", $"{processPath} {processArguments}")
{
RedirectStandardOutput = true,
RedirectStandardError = true
Expand All @@ -41,7 +40,7 @@ public TestServerBase(string baseDirectory, string processArguments)
var s = _process.StandardOutput.ReadLine();
var indexOfPort = s?.IndexOf(portPhrase);
if (indexOfPort > 0)
{
{
Port = s!.Substring(indexOfPort.Value + portPhrase.Length).Trim();
Host = new Uri($"http://localhost:{Port}");
Client = new HttpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ namespace _Type.Property.Nullable.Models
{
public partial class BytesProperty
{
public string RequiredProperty => throw null;
public BytesProperty(string requiredProperty, BinaryData nullableProperty) => throw null;

public BinaryData NullableProperty => throw null;
public string RequiredProperty
{
get => throw null;
set => throw null;
}

public BinaryData NullableProperty
{
get => throw null;
set => throw null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@ namespace _Type.Property.Nullable.Models
{
public partial class CollectionsByteProperty
{
public string RequiredProperty => throw null;
public CollectionsByteProperty(string requiredProperty, IEnumerable<BinaryData> nullableProperty) => throw null;

public IList<BinaryData> NullableProperty => throw null;
public string RequiredProperty
{
get => throw null;
set => throw null;
}

public IList<BinaryData> NullableProperty
{
get => throw null;
set => throw null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ namespace _Type.Property.Nullable.Models
{
public partial class CollectionsModelProperty
{
public string RequiredProperty => throw null;
public CollectionsModelProperty(string requiredProperty, IEnumerable<InnerModel> nullableProperty) => throw null;

public IList<InnerModel> NullableProperty => throw null;
public string RequiredProperty
{
get => throw null;
set => throw null;
}

public IList<InnerModel> NullableProperty
{
get => throw null;
set => throw null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ namespace _Type.Property.Nullable.Models
{
public partial class DatetimeProperty
{
public string RequiredProperty => throw null;
public DatetimeProperty(string requiredProperty, DateTimeOffset? nullableProperty) => throw null;

public DateTimeOffset? NullableProperty => throw null;
public string RequiredProperty
{
get => throw null;
set => throw null;
}

public DateTimeOffset? NullableProperty
{
get => throw null;
set => throw null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ namespace _Type.Property.Nullable.Models
{
public partial class DurationProperty
{
public string RequiredProperty => throw null;
public DurationProperty(string requiredProperty, TimeSpan? nullableProperty) => throw null;

public TimeSpan? NullableProperty => throw null;
public string RequiredProperty
{
get => throw null;
set => throw null;
}

public TimeSpan? NullableProperty
{
get => throw null;
set => throw null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ namespace _Type.Property.Nullable.Models
{
public partial class InnerModel
{
public string Property => throw null;
public InnerModel(string @property) => throw null;

public string Property
{
get => throw null;
set => throw null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ namespace _Type.Property.Nullable.Models
{
public partial class StringProperty
{
public string RequiredProperty => throw null;
public StringProperty(string requiredProperty, string nullableProperty) => throw null;

public string NullableProperty => throw null;
public string RequiredProperty
{
get => throw null;
set => throw null;
}

public string NullableProperty
{
get => throw null;
set => throw null;
}
}
}
Loading

0 comments on commit 97b44d2

Please sign in to comment.