Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
40ecf45
init
live1206 Sep 13, 2024
7da2225
Merge branch 'main' into response-abstraction
live1206 Sep 13, 2024
d170d95
cleanup
live1206 Sep 13, 2024
88a4620
clean up
live1206 Sep 13, 2024
0c8c172
Merge branch 'main' into response-abstraction
live1206 Sep 14, 2024
634c06a
wip
live1206 Sep 18, 2024
5bbcd8a
update FromValue expression
live1206 Sep 18, 2024
93932af
rename
live1206 Sep 19, 2024
f1a9a3d
restructure
live1206 Sep 19, 2024
1169baf
revert type change
live1206 Sep 19, 2024
9752376
Merge branch 'main' into response-abstraction
live1206 Sep 19, 2024
f062d77
make static methods abstract
live1206 Sep 23, 2024
d1889c2
Merge branch 'response-abstraction' of https://github.com/live1206/ty…
live1206 Sep 23, 2024
9eb3b66
update Type to CSharpType
live1206 Sep 23, 2024
56e0f8a
make ErrorResultDefinition public
live1206 Sep 25, 2024
8f6e642
update
live1206 Sep 26, 2024
47a6427
Merge branch 'main' into response-abstraction
live1206 Sep 26, 2024
4a94206
Add more abstraction to make Azure plugin work
live1206 Sep 30, 2024
37295c0
regen tests
live1206 Sep 30, 2024
49ee47d
Merge branch 'main' into response-abstraction
live1206 Sep 30, 2024
eb32597
fix typo
live1206 Sep 30, 2024
c29e8c0
update
live1206 Sep 30, 2024
eb98948
Merge branch 'main' into response-abstraction
live1206 Oct 8, 2024
fcf7ee5
add interfaces
live1206 Oct 9, 2024
109e93e
revert changes for serialization
live1206 Oct 9, 2024
f8c7bbb
revert test change
live1206 Oct 9, 2024
b0d4fca
Merge branch 'main' into response-abstraction
live1206 Oct 9, 2024
a038db4
fix
live1206 Oct 9, 2024
f83dd0b
cleanup
live1206 Oct 9, 2024
a5a379f
make test pass
live1206 Oct 9, 2024
aa27a8d
Merge branch 'main' into response-abstraction
live1206 Oct 10, 2024
100328f
minor
live1206 Oct 10, 2024
14f87d0
Merge branch 'main' into response-abstraction
live1206 Oct 10, 2024
48449f4
Merge branch 'main' into response-abstraction
live1206 Oct 11, 2024
456f13a
resolve comments
live1206 Oct 11, 2024
71bf272
Merge branch 'main' into response-abstraction
live1206 Oct 11, 2024
0cfe54f
Add IExpressionApi<T>
live1206 Oct 14, 2024
1189b18
add constraint
live1206 Oct 14, 2024
cb6c50e
Add ParameterName to IHttpRequestOptionsApi
live1206 Oct 16, 2024
486104c
Add tests for abstraction and simplify the implementation
live1206 Oct 17, 2024
aba79be
Merge branch 'main' into response-abstraction
live1206 Oct 17, 2024
c8a8735
fix typo
live1206 Oct 17, 2024
e3c067a
more typo
live1206 Oct 17, 2024
55637ee
fix typo in test data file name
live1206 Oct 17, 2024
5f192fb
Merge branch 'main' into response-abstraction
live1206 Oct 18, 2024
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
Prev Previous commit
Next Next commit
update Type to CSharpType
  • Loading branch information
live1206 committed Sep 23, 2024
commit 9eb3b66c3863c01dfe055792fde90dd19bd4bcdd
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private MethodSignature GetProcessHeadAsBoolMessageSignature(bool isAsync)
isAsync ? "ProcessHeadAsBoolMessageAsync" : "ProcessHeadAsBoolMessage",
null,
modifiers,
isAsync ? new CSharpType(typeof(ValueTask<>), new CSharpType(ClientModelPlugin.Instance.TypeFactory.ClientResponseOfTType, typeof(bool))) : new CSharpType(ClientModelPlugin.Instance.TypeFactory.ClientResponseOfTType, typeof(bool)),
isAsync ? new CSharpType(typeof(ValueTask<>), new CSharpType(ClientModelPlugin.Instance.TypeFactory.ClientResponseOfTType.FrameworkType, typeof(bool))) : new CSharpType(ClientModelPlugin.Instance.TypeFactory.ClientResponseOfTType.FrameworkType, typeof(bool)),
null,
[_pipelineParam, _messageParam, _requestOptionsParam]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public ClientResultProvider(ValueExpression clientResult) : base(typeof(ClientRe
}

public override ValueExpression CreateAsync(HttpResponseApi response)
=> Static(ClientModelPlugin.Instance.TypeFactory.ClientResponseType).Invoke(nameof(CreateAsync), [response], true);
=> Static(ClientModelPlugin.Instance.TypeFactory.ClientResponseExceptionType).Invoke(nameof(CreateAsync), [response], true);

public override ValueExpression FromResponse(ValueExpression valueExpression)
=> Static(ClientModelPlugin.Instance.TypeFactory.ClientResponseExceptionType).Invoke(nameof(FromResponse), [valueExpression]);
=> Static(ClientModelPlugin.Instance.TypeFactory.ClientResponseType).Invoke(nameof(FromResponse), [valueExpression]);

public override ValueExpression FromValue(ValueExpression valueExpression, HttpResponseApi response)
=> Static(ClientModelPlugin.Instance.TypeFactory.ClientResponseType).Invoke(nameof(FromValue), [valueExpression, response]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected override CSharpType[] GetTypeArguments()

protected override CSharpType[] BuildImplements()
{
return [new CSharpType(ClientModelPlugin.Instance.TypeFactory.ClientResponseOfTType, _t)];
return [new CSharpType(ClientModelPlugin.Instance.TypeFactory.ClientResponseOfTType.FrameworkType, _t)];
}

protected override FieldProvider[] BuildFields()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ .. GetStackVariablesForReturnValueConversion(result, responseBodyType, isAsync,
}

var convenienceMethod = new ScmMethodProvider(methodSignature, methodBody, EnclosingType);
convenienceMethod.XmlDocs!.Exceptions.Add(new(ClientModelPlugin.Instance.TypeFactory.ClientResponseExceptionType, "Service returned a non-success status code.", []));
convenienceMethod.XmlDocs!.Exceptions.Add(new(ClientModelPlugin.Instance.TypeFactory.ClientResponseExceptionType.FrameworkType, "Service returned a non-success status code.", []));
return convenienceMethod;
}

Expand Down Expand Up @@ -400,7 +400,7 @@ private MethodProvider BuildProtocolMethod(MethodProvider createRequestMethod, b

var protocolMethod =
new ScmMethodProvider(methodSignature, methodBody, EnclosingType) { IsServiceCall = true };
protocolMethod.XmlDocs!.Exceptions.Add(new(ClientModelPlugin.Instance.TypeFactory.ClientResponseExceptionType, "Service returned a non-success status code.", []));
protocolMethod.XmlDocs!.Exceptions.Add(new(ClientModelPlugin.Instance.TypeFactory.ClientResponseExceptionType.FrameworkType, "Service returned a non-success status code.", []));
List<XmlDocStatement> listItems =
[
new XmlDocStatement("item", [], new XmlDocStatement("description", [$"This <see href=\"https://aka.ms/azsdk/net/protocol-methods\">protocol method</see> allows explicit creation of the request and processing of the response for advanced scenarios."]))
Expand All @@ -423,7 +423,7 @@ private static CSharpType GetConvenienceReturnType(IReadOnlyList<OperationRespon
responseBodyType = response?.BodyType is null ? null : ClientModelPlugin.Instance.TypeFactory.CreateCSharpType(response.BodyType);
return response is null || responseBodyType is null
? ClientModelPlugin.Instance.TypeFactory.ClientResponseType
: new CSharpType(ClientModelPlugin.Instance.TypeFactory.ClientResponseOfTType, responseBodyType);
: new CSharpType(ClientModelPlugin.Instance.TypeFactory.ClientResponseOfTType.FrameworkType, responseBodyType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public class ScmTypeFactory : TypeFactory

public virtual CSharpType TokenCredentialType => throw new NotImplementedException("Token credential is not supported in Scm libraries yet");

public virtual Type ClientResponseType => typeof(ClientResult);
public virtual CSharpType ClientResponseType => typeof(ClientResult);

public virtual Type ClientResponseOfTType => typeof(ClientResult<>);
public virtual CSharpType ClientResponseOfTType => typeof(ClientResult<>);

public virtual Type ClientResponseExceptionType => typeof(ClientResultException);
public virtual CSharpType ClientResponseExceptionType => typeof(ClientResultException);

public virtual Type HttpResponseType => typeof(PipelineResponse);
public virtual CSharpType HttpResponseType => typeof(PipelineResponse);

public virtual ClientResponseApi CreateClientResponse(ValueExpression original) => new ClientResultProvider(original.As<ClientResult>());

Expand Down