From 034bdcc7d93b708f73218606c714ccad5d18e7fc Mon Sep 17 00:00:00 2001 From: Dapeng Zhang Date: Wed, 15 Jan 2025 14:31:40 +0800 Subject: [PATCH] fix the issue --- .../Providers/ScmMethodProviderCollection.cs | 3 ++- .../src/Snippets/Snippet.cs | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs index 27218215a3..02aab0bd4d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs @@ -23,6 +23,7 @@ public class ScmMethodProviderCollection : MethodProviderCollection { private string _cleanOperationName; private readonly MethodProvider _createRequestMethod; + private static readonly ClientPipelineExtensionsDefinition _clientPipelineExtensionsDefinition = new(); private ClientProvider Client { get; } @@ -432,7 +433,7 @@ private ScmMethodProvider BuildProtocolMethod(MethodProvider createRequestMethod MethodBodyStatement[] methodBody = [ UsingDeclare("message", ClientModelPlugin.Instance.TypeFactory.HttpMessageApi.HttpMessageType, This.Invoke(createRequestMethod.Signature, [.. requiredParameters, ..optionalParameters, requestOptionsParameter]), out var message), - Return(ClientModelPlugin.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse(client.PipelineProperty.Invoke(processMessageName, [message, requestOptionsParameter], isAsync, true))), + Return(ClientModelPlugin.Instance.TypeFactory.ClientResponseApi.ToExpression().FromResponse(client.PipelineProperty.Invoke(processMessageName, [message, requestOptionsParameter], isAsync, true, extensionType: _clientPipelineExtensionsDefinition.Type))), ]; var protocolMethod = diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Snippets/Snippet.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Snippets/Snippet.cs index d1a5355c4a..37ca8310a1 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Snippets/Snippet.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Snippets/Snippet.cs @@ -120,28 +120,33 @@ public static InvokeMethodExpression Invoke(this ParameterProvider parameter, st public static ValueExpression Property(this ParameterProvider parameter, string propertyName, bool nullConditional = false) => new MemberExpression(nullConditional ? new NullConditionalExpression(parameter) : parameter, propertyName); - public static InvokeMethodExpression Invoke(this FieldProvider field, string methodName, IEnumerable parameters) - => field.Invoke(methodName, parameters, false, false); + public static InvokeMethodExpression Invoke(this FieldProvider field, string methodName, IEnumerable parameters, CSharpType? extensionType = null) + => field.Invoke(methodName, parameters, false, false, extensionType: extensionType); public static InvokeMethodExpression Invoke(this FieldProvider field, string methodName, IEnumerable parameters, bool isAsync, - bool configureAwait) + bool configureAwait, + CSharpType? extensionType = null) => new InvokeMethodExpression(field, methodName, [.. parameters]) { - CallAsAsync = isAsync, AddConfigureAwaitFalse = configureAwait + CallAsAsync = isAsync, + AddConfigureAwaitFalse = configureAwait, + ExtensionType = extensionType }; public static ValueExpression Invoke(this PropertyProvider property, string methodName, IEnumerable parameters, bool isAsync, - bool configureAwait) + bool configureAwait, + CSharpType? extensionType = null) => new InvokeMethodExpression(property, methodName, [.. parameters]) { CallAsAsync = isAsync, - AddConfigureAwaitFalse = configureAwait + AddConfigureAwaitFalse = configureAwait, + ExtensionType = extensionType }; public static ScopedApi NotEqual(this ParameterProvider parameter, ValueExpression other)