Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify the extension type parameter when we call the extension method #5619

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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 @@ -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; }

Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ValueExpression> parameters)
=> field.Invoke(methodName, parameters, false, false);
public static InvokeMethodExpression Invoke(this FieldProvider field, string methodName, IEnumerable<ValueExpression> parameters, CSharpType? extensionType = null)
=> field.Invoke(methodName, parameters, false, false, extensionType: extensionType);

public static InvokeMethodExpression Invoke(this FieldProvider field,
string methodName,
IEnumerable<ValueExpression> 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<ValueExpression> 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<bool> NotEqual(this ParameterProvider parameter, ValueExpression other)
Expand Down
Loading