From a48fad7bf7636acded84d056cbf015629e21ed36 Mon Sep 17 00:00:00 2001 From: Morgan Leroi Date: Wed, 7 Feb 2024 15:46:03 +0100 Subject: [PATCH] review --- templates/csharp/modelOneOf.mustache | 4 ++-- templates/csharp/tests/requests/requests.mustache | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/csharp/modelOneOf.mustache b/templates/csharp/modelOneOf.mustache index f598f2e6b5..a6da7bbe98 100644 --- a/templates/csharp/modelOneOf.mustache +++ b/templates/csharp/modelOneOf.mustache @@ -242,7 +242,7 @@ /// JSON Serializer public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - writer.WriteRawValue((string)(typeof({{classname}}{{#vendorExtensions.x-has-child-generic}}{{/vendorExtensions.x-has-child-generic}}).GetMethod("ToJson")?.Invoke(value, null))); + writer.WriteRawValue((string)value?.GetType().GetMethod("ToJson")?.Invoke(value, null)); } /// @@ -257,7 +257,7 @@ { if(reader.TokenType != JsonToken.Null) { - return objectType.GetMethod("FromJson")?.Invoke(null, new object[] { JObject.Load(reader).ToString(Formatting.None) }); + return objectType.GetMethod("FromJson")?.Invoke(null, new object[] { JToken.Load(reader).ToString(Formatting.None) }); } return null; } diff --git a/templates/csharp/tests/requests/requests.mustache b/templates/csharp/tests/requests/requests.mustache index 4cd0ce4bf2..d71867c632 100644 --- a/templates/csharp/tests/requests/requests.mustache +++ b/templates/csharp/tests/requests/requests.mustache @@ -48,7 +48,7 @@ private readonly {{client}} _client{{#hasE2E}}, _e2eClient{{/hasE2E}}; [Fact(DisplayName = "{{{testName}}}")] public async Task {{#lambda.pascalcase}}{{method}}Test{{testIndex}}{{/lambda.pascalcase}}() { - await _client.{{#lambda.pascalcase}}{{method}}{{/lambda.pascalcase}}Async{{#isGeneric}}{{/isGeneric}}({{#parametersWithDataType}}{{> tests/generateParams}}{{^-last}},{{/-last}}{{/parametersWithDataType}}{{#hasRequestOptions}}, new RequestOptions(){ + await _client.{{#lambda.pascalcase}}{{method}}{{/lambda.pascalcase}}Async{{#isGeneric}}{{/isGeneric}}({{#parametersWithDataType}}{{> tests/generateParams}}{{^-last}},{{/-last}}{{/parametersWithDataType}}{{#hasRequestOptions}}, new RequestOptions(){ {{#requestOptions.queryParameters.parametersWithDataType}} QueryParameters = new Dictionary(){ {"{{{key}}}", {{> tests/requests/requestOptionsParams}} }}, {{/requestOptions.queryParameters.parametersWithDataType}} @@ -101,7 +101,7 @@ private readonly {{client}} _client{{#hasE2E}}, _e2eClient{{/hasE2E}}; {{#response}} // e2e try { - var resp = await _e2eClient.{{#lambda.pascalcase}}{{method}}{{/lambda.pascalcase}}Async{{#isGeneric}}{{/isGeneric}}({{#parametersWithDataType}}{{> tests/generateParams}}{{^-last}},{{/-last}}{{/parametersWithDataType}}{{#hasRequestOptions}}, new RequestOptions(){ + var resp = await _e2eClient.{{#lambda.pascalcase}}{{method}}{{/lambda.pascalcase}}Async{{#isGeneric}}{{/isGeneric}}({{#parametersWithDataType}}{{> tests/generateParams}}{{^-last}},{{/-last}}{{/parametersWithDataType}}{{#hasRequestOptions}}, new RequestOptions(){ {{#requestOptions.queryParameters.parametersWithDataType}} QueryParameters = new Dictionary(){ {"{{{key}}}", {{> tests/requests/requestOptionsParams}} }}, {{/requestOptions.queryParameters.parametersWithDataType}}