Skip to content

Commit 6ed75ff

Browse files
azure-sdkUbuntujorgerangel-msft
authored
Update UnbrandedGeneratorVersion to 1.0.0-alpha.20251210.1 (#54410)
* Update UnbrandedGeneratorVersion to 1.0.0-alpha.20251209.2 * fix * update hook implementation * simplify and use comparer * build: Update UnbrandedGeneratorVersion to 1.0.0-alpha.20251210.1 --------- Co-authored-by: Ubuntu <cloudtest@15c9b478c000009.tkkhlgj2u51eln3mcb0lygmbye.dx.internal.cloudapp.net> Co-authored-by: Jorge Rangel <[email protected]>
1 parent 562420c commit 6ed75ff

File tree

7 files changed

+32
-25
lines changed

7 files changed

+32
-25
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@
494494

495495
<PropertyGroup>
496496
<TestProxyVersion>1.0.0-dev.20250930.1</TestProxyVersion>
497-
<UnbrandedGeneratorVersion>1.0.0-alpha.20251208.2</UnbrandedGeneratorVersion>
497+
<UnbrandedGeneratorVersion>1.0.0-alpha.20251210.1</UnbrandedGeneratorVersion>
498498
<AzureGeneratorVersion>1.0.0-alpha.20251205.1</AzureGeneratorVersion>
499499
</PropertyGroup>
500500
</Project>

eng/http-client-csharp-emitter-package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/http-client-csharp-emitter-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"main": "dist/src/index.js",
33
"dependencies": {
44
"client-plugin": "file:../../../../eng/packages/plugins/client",
5-
"@typespec/http-client-csharp": "1.0.0-alpha.20251208.2"
5+
"@typespec/http-client-csharp": "1.0.0-alpha.20251210.1"
66
},
77
"devDependencies": {
88
"@azure-tools/typespec-client-generator-core": "0.62.0",

eng/packages/http-client-csharp/generator/Azure.Generator/src/AzureTypeFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected override string BuildServiceName()
124124

125125
/// <inheritdoc/>
126126
public override ValueExpression DeserializeJsonValue(
127-
Type valueType,
127+
CSharpType valueType,
128128
ScopedApi<JsonElement> element,
129129
ScopedApi<BinaryData> data,
130130
ScopedApi<ModelReaderWriterOptions> mrwOptionsParameter,
@@ -135,7 +135,7 @@ public override ValueExpression DeserializeJsonValue(
135135
}
136136

137137
private ValueExpression? DeserializeJsonValueCore(
138-
Type valueType,
138+
CSharpType valueType,
139139
ScopedApi<JsonElement> element,
140140
ScopedApi<BinaryData> data,
141141
ScopedApi<ModelReaderWriterOptions> mrwOptionsParameter,
@@ -147,7 +147,7 @@ public override ValueExpression DeserializeJsonValue(
147147
}
148148

149149
/// <inheritdoc/>
150-
public override MethodBodyStatement SerializeJsonValue(Type valueType, ValueExpression value, ScopedApi<Utf8JsonWriter> utf8JsonWriter, ScopedApi<ModelReaderWriterOptions> mrwOptionsParameter, SerializationFormat serializationFormat)
150+
public override MethodBodyStatement SerializeJsonValue(CSharpType valueType, ValueExpression value, ScopedApi<Utf8JsonWriter> utf8JsonWriter, ScopedApi<ModelReaderWriterOptions> mrwOptionsParameter, SerializationFormat serializationFormat)
151151
{
152152
var statement = SerializeValueTypeCore(serializationFormat, value, valueType, utf8JsonWriter, mrwOptionsParameter);
153153
return statement ?? base.SerializeJsonValue(valueType, value, utf8JsonWriter, mrwOptionsParameter, serializationFormat);
@@ -156,7 +156,7 @@ public override MethodBodyStatement SerializeJsonValue(Type valueType, ValueExpr
156156
private MethodBodyStatement? SerializeValueTypeCore(SerializationFormat serializationFormat, ValueExpression value, CSharpType valueType, ScopedApi<Utf8JsonWriter> utf8JsonWriter, ScopedApi<ModelReaderWriterOptions> mrwOptionsParameter)
157157
{
158158
return KnownAzureTypes.TryGetJsonSerializationExpression(valueType, out var serializationExpression) ?
159-
serializationExpression(value, utf8JsonWriter, mrwOptionsParameter, serializationFormat) :
159+
serializationExpression(valueType, value, utf8JsonWriter, mrwOptionsParameter, serializationFormat) :
160160
null;
161161
}
162162

eng/packages/http-client-csharp/generator/Azure.Generator/src/Primitives/KnownAzureTypes.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@
1515
using System.Net;
1616
using System.Text;
1717
using System.Text.Json;
18+
using static Microsoft.TypeSpec.Generator.Primitives.CSharpType;
1819
using static Microsoft.TypeSpec.Generator.Snippets.Snippet;
1920

2021
namespace Azure.Generator.Primitives
2122
{
2223
internal static class KnownAzureTypes
2324
{
24-
public delegate MethodBodyStatement SerializationExpression(ValueExpression value, ScopedApi<Utf8JsonWriter> writer, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format);
25+
public delegate MethodBodyStatement SerializationExpression(CSharpType valueType, ValueExpression value, ScopedApi<Utf8JsonWriter> writer, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format);
2526
public delegate ValueExpression DeserializationExpression(CSharpType valueType, ScopedApi<JsonElement> element, ScopedApi<BinaryData> data, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format);
2627

2728
private const string UuidId = "Azure.Core.uuid";
@@ -33,19 +34,25 @@ internal static class KnownAzureTypes
3334
private const string AzureError = "Azure.Core.Foundations.Error";
3435
private const string EmbeddingVector = "Azure.Core.EmbeddingVector";
3536

36-
private static MethodBodyStatement SerializeTypeWithImplicitOperatorToString(ValueExpression value, ScopedApi<Utf8JsonWriter> writer, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format)
37-
=> writer.WriteStringValue(value);
37+
private static MethodBodyStatement SerializeTypeWithImplicitOperatorToString(CSharpType valueType, ValueExpression value, ScopedApi<Utf8JsonWriter> writer, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format)
38+
{
39+
value = value.NullableStructValue(valueType);
40+
return writer.WriteStringValue(value);
41+
}
3842

3943
private static ValueExpression DeserializeNewInstanceStringLikeType(CSharpType valueType, ScopedApi<JsonElement> element, ScopedApi<BinaryData> data, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format)
4044
=> New.Instance(valueType, element.GetString());
4145

42-
private static MethodBodyStatement SerializeTypeWithToString(ValueExpression value, ScopedApi<Utf8JsonWriter> writer, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format)
43-
=> writer.WriteStringValue(value.InvokeToString());
46+
private static MethodBodyStatement SerializeTypeWithToString(CSharpType valueType, ValueExpression value, ScopedApi<Utf8JsonWriter> writer, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format)
47+
{
48+
value = value.NullableStructValue(valueType);
49+
return writer.WriteStringValue(value.InvokeToString());
50+
}
4451

4552
private static ValueExpression DeserializeParsableStringLikeType(CSharpType valueType, ScopedApi<JsonElement> element, ScopedApi<BinaryData> data, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format)
4653
=> Static(valueType).Invoke("Parse", element.GetString());
4754

48-
private static MethodBodyStatement SerializeResponseError(ValueExpression value, ScopedApi<Utf8JsonWriter> writer, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format)
55+
private static MethodBodyStatement SerializeResponseError(CSharpType valueType, ValueExpression value, ScopedApi<Utf8JsonWriter> writer, ScopedApi<ModelReaderWriterOptions> options, SerializationFormat format)
4956
{
5057
var asJsonModel = value.CastTo(typeof(IJsonModel<ResponseError>));
5158
return asJsonModel.Invoke(nameof(IJsonModel<ResponseError>.Write), writer, options).Terminate();
@@ -80,7 +87,7 @@ private static ValueExpression DeserializeResponseError(
8087
[EmbeddingVector] = typeof(ReadOnlyMemory<>)
8188
};
8289

83-
private static readonly IReadOnlyDictionary<CSharpType, SerializationExpression> _typeToSerializationExpression = new Dictionary<CSharpType, SerializationExpression>
90+
private static readonly IReadOnlyDictionary<CSharpType, SerializationExpression> _typeToSerializationExpression = new Dictionary<CSharpType, SerializationExpression>(new CSharpTypeIgnoreNullableComparer())
8491
{
8592
[typeof(Guid)] = SerializeTypeWithImplicitOperatorToString,
8693
[typeof(IPAddress)] = SerializeTypeWithToString,
@@ -90,7 +97,7 @@ private static ValueExpression DeserializeResponseError(
9097
[typeof(ResponseError)] = SerializeResponseError,
9198
};
9299

93-
private static readonly IReadOnlyDictionary<CSharpType, DeserializationExpression> _typeToDeserializationExpression = new Dictionary<CSharpType, DeserializationExpression>
100+
private static readonly IReadOnlyDictionary<CSharpType, DeserializationExpression> _typeToDeserializationExpression = new Dictionary<CSharpType, DeserializationExpression>(new CSharpTypeIgnoreNullableComparer())
94101
{
95102
[typeof(Guid)] = DeserializeNewInstanceStringLikeType,
96103
[typeof(IPAddress)] = DeserializeParsableStringLikeType,

eng/packages/http-client-csharp/package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/packages/http-client-csharp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"dist/generator/**"
3939
],
4040
"dependencies": {
41-
"@typespec/http-client-csharp": "1.0.0-alpha.20251208.2"
41+
"@typespec/http-client-csharp": "1.0.0-alpha.20251210.1"
4242
},
4343
"devDependencies": {
4444
"@azure-tools/azure-http-specs": "0.1.0-alpha.32",

0 commit comments

Comments
 (0)