Skip to content

Commit 29d219d

Browse files
committed
fix the content type issue
1 parent d251ab1 commit 29d219d

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Primitives/ScmKnownParameters.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Threading;
88
using System.Xml;
99
using System.Xml.Linq;
10+
using Microsoft.Generator.CSharp.Input;
1011
using Microsoft.Generator.CSharp.Primitives;
1112
using Microsoft.Generator.CSharp.Providers;
1213
using static Microsoft.Generator.CSharp.Snippets.Snippet;
@@ -56,6 +57,6 @@ public static ParameterProvider ClientOptions(CSharpType clientOptionsType)
5657
DefaultValue = Static(typeof(DateTimeOffset)).Property(nameof(DateTimeOffset.Now))
5758
};
5859

59-
public static readonly ParameterProvider ContentType = new("contentType", $"The contentType to use which has the multipart/form-data boundary.", typeof(string));
60+
public static readonly ParameterProvider ContentType = new("contentType", $"The contentType to use which has the multipart/form-data boundary.", typeof(string), wireInfo: new PropertyWireInformation(SerializationFormat.Default, true, false, false, false, "Content-Type"));
6061
}
6162
}

packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ClientProvider.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,14 @@ private IReadOnlyList<FieldProvider> BuildAdditionalClientFields()
254254
FieldModifiers.Private | FieldModifiers.ReadOnly,
255255
type.WithNullable(!p.IsRequired),
256256
"_" + p.Name.ToVariableName(),
257-
this);
257+
this,
258+
wireInfo: new PropertyWireInformation(
259+
ClientModelPlugin.Instance.TypeFactory.GetSerializationFormat(p.Type),
260+
p.IsRequired,
261+
false,
262+
p.Type is InputNullableType,
263+
false,
264+
p.NameInRequest));
258265
if (p.IsApiVersion)
259266
{
260267
_apiVersionField = field;

packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/RestClientProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private MethodProvider BuildCreateRequestMethod(InputOperation operation)
9999

100100
foreach (var param in ClientProvider.ClientParameters)
101101
{
102-
paramMap[param.Name] = param;
102+
paramMap[param.WireInfo.SerializedName] = param;
103103
}
104104

105105
var classifier = GetClassifier(operation);

packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/FieldProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public FieldProvider(
4949
string name,
5050
TypeProvider enclosingType,
5151
FormattableString? description = null,
52-
ValueExpression? initializationValue = null)
52+
ValueExpression? initializationValue = null,
53+
PropertyWireInformation? wireInfo = null)
5354
{
5455
Modifiers = modifiers;
5556
Type = type;
@@ -58,6 +59,7 @@ public FieldProvider(
5859
InitializationValue = initializationValue;
5960
XmlDocs = Description is not null ? new XmlDocProvider() { Summary = new XmlDocSummaryStatement([Description]) } : null;
6061
EnclosingType = enclosingType;
62+
WireInfo = wireInfo;
6163

6264
InitializeParameter();
6365
}
@@ -66,7 +68,7 @@ public FieldProvider(
6668
private void InitializeParameter()
6769
{
6870
_parameter = new(() => new ParameterProvider(
69-
Name.ToVariableName(), Description ?? FormattableStringHelpers.Empty, Type, field: this));
71+
Name.ToVariableName(), Description ?? FormattableStringHelpers.Empty, Type, field: this, wireInfo: WireInfo));
7072
}
7173

7274
private MemberExpression? _asMember;

0 commit comments

Comments
 (0)