Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1566,5 +1566,11 @@ describe("Test isFileType propagation", () => {
strictEqual(bodyType.kind, "model");
strictEqual(bodyType.crossLanguageDefinitionId, "TypeSpec.Http.File");
strictEqual(bodyType.isFileType, true);

const contentTypeParam = method.operation.parameters.find((p) => p.name === "contentType");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot why are these changes needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions cover the file-upload fix shipped in TCGC 0.72.0 (Azure/typespec-azure#5306): an unspecified content type becomes an optional string defaulting to application/octet-stream. They failed on 0.71.2 (constant instead of string) and pass on 0.72.0. They aren't required to perform the bump; they're focused regression coverage confirming that the C# emitter preserves the new behavior.

ok(contentTypeParam);
strictEqual(contentTypeParam.type.kind, "string");
strictEqual(contentTypeParam.optional, true);
strictEqual(contentTypeParam.defaultValue?.value, "application/octet-stream");
});
});
4 changes: 4 additions & 0 deletions packages/http-client-csharp/eng/scripts/Generation.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function Get-TspCommand {
)
$emitterDir = Resolve-Path (Join-Path $PSScriptRoot '..' '..')
$command = "npx tsp compile $specFile"
$customizationFile = Join-Path $generationDir "client.tsp"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot why are these changes needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pinned @typespec/http-specs@0.1.0-alpha.42 contains both Streaming.Sse.Unnamed.Info and Streaming.Sse.Protocol.Info. Regeneration overwrites Info.cs and produces duplicate model-factory signatures, breaking the build. This hook loads the scenario-local customization that renames only the new model to ProtocolInfo, preserving the existing API in both generation and Spector tests. Once we consume a published spec package containing #11920, this customization and hook can be removed.

if (Test-Path $customizationFile) {
$command += " --import $customizationFile"
}
$command += " --trace @typespec/http-client-csharp"
$command += " --emit $emitterDir"
$configFile = Join-Path $generationDir "tspconfig.yaml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
"commandName": "Executable",
"executablePath": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.exe"
},
"http-response-body-or-no-content": {
"commandLineArgs": "$(SolutionDir)/TestProjects/Spector/http/response/body-or-no-content -g StubLibraryGenerator",
"commandName": "Executable",
"executablePath": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.exe"
},
"http-response-status-code-range": {
"commandLineArgs": "$(SolutionDir)/TestProjects/Spector/http/response/status-code-range -g StubLibraryGenerator",
"commandName": "Executable",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"package-name": "Response.BodyOrNoContent"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<ItemGroup>
<JsonSchemaSegment Include="$(MSBuildThisFileDirectory)..\..\ConfigurationSchema.json"
FilePathPattern="appsettings.*.json" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="src/Response.BodyOrNoContent.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// <auto-generated/>

#nullable disable

using System;
using System.ClientModel;
using System.ClientModel.Primitives;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;

namespace Response.BodyOrNoContent
{
public partial class BodyOrNoContentClient
{
public BodyOrNoContentClient() : this(new Uri("http://localhost:3000"), new BodyOrNoContentClientOptions()) => throw null;

internal BodyOrNoContentClient(AuthenticationPolicy authenticationPolicy, Uri endpoint, BodyOrNoContentClientOptions options) => throw null;

public BodyOrNoContentClient(Uri endpoint, BodyOrNoContentClientOptions options) : this(null, endpoint, options) => throw null;

[Experimental("SCME0002")]
public BodyOrNoContentClient(BodyOrNoContentClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Endpoint, settings?.Options) => throw null;

public ClientPipeline Pipeline => throw null;

public virtual ClientResult GetBody(RequestOptions options) => throw null;

public virtual Task<ClientResult> GetBodyAsync(RequestOptions options) => throw null;

public virtual ClientResult<BlobLayout> GetBody(CancellationToken cancellationToken = default) => throw null;

public virtual Task<ClientResult<BlobLayout>> GetBodyAsync(CancellationToken cancellationToken = default) => throw null;

public virtual ClientResult GetNoContent(RequestOptions options) => throw null;

public virtual Task<ClientResult> GetNoContentAsync(RequestOptions options) => throw null;

public virtual ClientResult<BlobLayout> GetNoContent(CancellationToken cancellationToken = default) => throw null;

public virtual Task<ClientResult<BlobLayout>> GetNoContentAsync(CancellationToken cancellationToken = default) => throw null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// <auto-generated/>

#nullable disable

using System.ClientModel.Primitives;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;

namespace Response.BodyOrNoContent
{
public partial class BodyOrNoContentClientOptions : ClientPipelineOptions
{
public BodyOrNoContentClientOptions() => throw null;

[Experimental("SCME0002")]
internal BodyOrNoContentClientOptions(IConfigurationSection section) : base(section) => throw null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// <auto-generated/>

#nullable disable

using System;
using System.ClientModel.Primitives;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;

namespace Response.BodyOrNoContent
{
[Experimental("SCME0002")]
public partial class BodyOrNoContentClientSettings : ClientSettings
{
public Uri Endpoint
{
get => throw null;
set => throw null;
}

public BodyOrNoContentClientOptions Options
{
get => throw null;
set => throw null;
}

protected override void BindCore(IConfigurationSection section) => throw null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// <auto-generated/>

#nullable disable

using System;
using System.ClientModel;
using System.ClientModel.Primitives;
using System.Text.Json;

namespace Response.BodyOrNoContent
{
public partial class BlobLayout : IJsonModel<BlobLayout>
{
internal BlobLayout() => throw null;

protected virtual BlobLayout PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null;

protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null;

BinaryData IPersistableModel<BlobLayout>.Write(ModelReaderWriterOptions options) => throw null;

BlobLayout IPersistableModel<BlobLayout>.Create(BinaryData data, ModelReaderWriterOptions options) => throw null;

string IPersistableModel<BlobLayout>.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null;

public static explicit operator BlobLayout(ClientResult result) => throw null;

void IJsonModel<BlobLayout>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null;

protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null;

BlobLayout IJsonModel<BlobLayout>.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null;

protected virtual BlobLayout JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// <auto-generated/>

#nullable disable

namespace Response.BodyOrNoContent
{
public partial class BlobLayout
{
public string Content => throw null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// <auto-generated/>

#nullable disable

using System.ClientModel.Primitives;

namespace Response.BodyOrNoContent
{
[ModelReaderWriterBuildable(typeof(BlobLayout))]
public partial class ResponseBodyOrNoContentContext : ModelReaderWriterContext
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// <auto-generated/>

#nullable disable

namespace Response.BodyOrNoContent
{
public static partial class ResponseBodyOrNoContentModelFactory
{
public static BlobLayout BlobLayout(string content = default) => throw null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"type": "object",
"properties": {
"Clients": {
"type": "object",
"properties": {
"BodyOrNoContentClient": {
"type": "object",
"description": "Configuration for BodyOrNoContentClient.",
"properties": {
"Endpoint": {
"type": "string",
"format": "uri",
"description": "Gets or sets the Endpoint."
},
"Credential": {
"$ref": "#/definitions/credential"
},
"Options": {
"$ref": "#/definitions/bodyOrNoContentClientOptions"
}
}
}
},
"additionalProperties": {
"type": "object",
"description": "Configuration for a named client instance."
}
}
},
"definitions": {
"bodyOrNoContentClientOptions": {
"allOf": [
{
"$ref": "#/definitions/options"
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>This is the Response.BodyOrNoContent client library for developing .NET applications with rich experience.</Description>
<AssemblyTitle>SDK Code Generation Response.BodyOrNoContent</AssemblyTitle>
<Version>1.0.0-beta.1</Version>
<PackageTags>Response.BodyOrNoContent</PackageTags>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.ClientModel" Version="1.15.0" />
</ItemGroup>

<ItemGroup>
<None Include="Generated\schema\ConfigurationSchema.json" Pack="true" PackagePath="\" />
<None Include="..\Response.BodyOrNoContent.NuGet.targets" Pack="true" PackagePath="buildTransitive\netstandard2.0\Response.BodyOrNoContent.targets" />
</ItemGroup>
</Project>
Loading
Loading