diff --git a/Google.Api.Generator.Tests/ProtoTests/Paginated/Testing.Paginated/PaginatedClient.g.cs b/Google.Api.Generator.Tests/ProtoTests/Paginated/Testing.Paginated/PaginatedClient.g.cs index ba369247..671ddf1d 100644 --- a/Google.Api.Generator.Tests/ProtoTests/Paginated/Testing.Paginated/PaginatedClient.g.cs +++ b/Google.Api.Generator.Tests/ProtoTests/Paginated/Testing.Paginated/PaginatedClient.g.cs @@ -65,14 +65,23 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable sequence of resources. - public virtual gax::PagedEnumerable SignatureMethod(string aString, int aNumber, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - SignatureMethod(new Request + public virtual gax::PagedEnumerable SignatureMethod(string aString, int aNumber, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + Request request = new Request { AString = aString ?? "", ANumber = aNumber, - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return SignatureMethod(request); + } /// /// Test a paginated RPC with a method signature. @@ -91,14 +100,23 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable asynchronous sequence of resources. - public virtual gax::PagedAsyncEnumerable SignatureMethodAsync(string aString, int aNumber, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - SignatureMethodAsync(new Request + public virtual gax::PagedAsyncEnumerable SignatureMethodAsync(string aString, int aNumber, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + Request request = new Request { AString = aString ?? "", ANumber = aNumber, - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return SignatureMethodAsync(request); + } /// /// Test a paginated RPC with a method signature. @@ -115,13 +133,22 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable sequence of resources. - public virtual gax::PagedEnumerable SignatureMethod(string aString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - SignatureMethod(new Request + public virtual gax::PagedEnumerable SignatureMethod(string aString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + Request request = new Request { AString = aString ?? "", - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return SignatureMethod(request); + } /// /// Test a paginated RPC with a method signature. @@ -138,13 +165,22 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable asynchronous sequence of resources. - public virtual gax::PagedAsyncEnumerable SignatureMethodAsync(string aString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - SignatureMethodAsync(new Request + public virtual gax::PagedAsyncEnumerable SignatureMethodAsync(string aString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + Request request = new Request { AString = aString ?? "", - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return SignatureMethodAsync(request); + } /// /// Test a paginated RPC with a method signature. @@ -159,12 +195,19 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable sequence of resources. - public virtual gax::PagedEnumerable SignatureMethod(string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - SignatureMethod(new Request + public virtual gax::PagedEnumerable SignatureMethod(string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + Request request = new Request { }; + if (pageToken != null) { - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return SignatureMethod(request); + } /// /// Test a paginated RPC with a method signature. @@ -179,12 +222,19 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable asynchronous sequence of resources. - public virtual gax::PagedAsyncEnumerable SignatureMethodAsync(string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - SignatureMethodAsync(new Request + public virtual gax::PagedAsyncEnumerable SignatureMethodAsync(string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + Request request = new Request { }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) { - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + request.PageSize = pageSize.Value; + } + return SignatureMethodAsync(request); + } /// /// Test rpc with duplicate response message, to make sure partial LRO response class is only generated once. @@ -240,13 +290,19 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable sequence of resources. - public virtual gax::PagedEnumerable ResourcedMethod(string name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ResourcedMethod(new ResourceRequest + public virtual gax::PagedEnumerable ResourcedMethod(string name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ResourceRequest request = new ResourceRequest { Name = name ?? "", }; + if (pageToken != null) { - Name = name ?? "", - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ResourcedMethod(request); + } /// /// Test a paginated RPC with a method signature that contains resource-names @@ -264,13 +320,19 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable asynchronous sequence of resources. - public virtual gax::PagedAsyncEnumerable ResourcedMethodAsync(string name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ResourcedMethodAsync(new ResourceRequest + public virtual gax::PagedAsyncEnumerable ResourcedMethodAsync(string name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ResourceRequest request = new ResourceRequest { Name = name ?? "", }; + if (pageToken != null) { - Name = name ?? "", - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ResourcedMethodAsync(request); + } /// /// Test a paginated RPC with a method signature that contains resource-names @@ -288,13 +350,19 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable sequence of resources. - public virtual gax::PagedEnumerable ResourcedMethod(ResourceName name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ResourcedMethod(new ResourceRequest + public virtual gax::PagedEnumerable ResourcedMethod(ResourceName name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ResourceRequest request = new ResourceRequest { ResourceName = name, }; + if (pageToken != null) { - ResourceName = name, - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ResourcedMethod(request); + } /// /// Test a paginated RPC with a method signature that contains resource-names @@ -312,13 +380,19 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable asynchronous sequence of resources. - public virtual gax::PagedAsyncEnumerable ResourcedMethodAsync(ResourceName name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ResourcedMethodAsync(new ResourceRequest + public virtual gax::PagedAsyncEnumerable ResourcedMethodAsync(ResourceName name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ResourceRequest request = new ResourceRequest { ResourceName = name, }; + if (pageToken != null) { - ResourceName = name, - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ResourcedMethodAsync(request); + } /// /// Test a paginated RPC with a method signature that contains resource-names @@ -338,14 +412,23 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable sequence of resources. - public virtual gax::PagedEnumerable ResourcedMethod(string name, string extraString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ResourcedMethod(new ResourceRequest + public virtual gax::PagedEnumerable ResourcedMethod(string name, string extraString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ResourceRequest request = new ResourceRequest { Name = name ?? "", ExtraString = extraString ?? "", - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ResourcedMethod(request); + } /// /// Test a paginated RPC with a method signature that contains resource-names @@ -365,14 +448,23 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable asynchronous sequence of resources. - public virtual gax::PagedAsyncEnumerable ResourcedMethodAsync(string name, string extraString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ResourcedMethodAsync(new ResourceRequest + public virtual gax::PagedAsyncEnumerable ResourcedMethodAsync(string name, string extraString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ResourceRequest request = new ResourceRequest { Name = name ?? "", ExtraString = extraString ?? "", - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ResourcedMethodAsync(request); + } /// /// Test a paginated RPC with a method signature that contains resource-names @@ -392,14 +484,23 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable sequence of resources. - public virtual gax::PagedEnumerable ResourcedMethod(ResourceName name, string extraString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ResourcedMethod(new ResourceRequest + public virtual gax::PagedEnumerable ResourcedMethod(ResourceName name, string extraString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ResourceRequest request = new ResourceRequest { ResourceName = name, ExtraString = extraString ?? "", - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ResourcedMethod(request); + } /// /// Test a paginated RPC with a method signature that contains resource-names @@ -419,99 +520,22 @@ public abstract class PaginatedClient /// /// If not null, applies overrides to this RPC call. /// A pageable asynchronous sequence of resources. - public virtual gax::PagedAsyncEnumerable ResourcedMethodAsync(ResourceName name, string extraString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ResourcedMethodAsync(new ResourceRequest + public virtual gax::PagedAsyncEnumerable ResourcedMethodAsync(ResourceName name, string extraString, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ResourceRequest request = new ResourceRequest { ResourceName = name, ExtraString = extraString ?? "", - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); - // TEST_END - } - - public sealed partial class PaginatedClientImpl : PaginatedClient - { - private readonly gaxgrpc::ApiCall _callSignatureMethod = null; - private readonly gaxgrpc::ApiCall _callSignatureMethod2 = null; - private readonly gaxgrpc::ApiCall _callResourcedMethod = null; - - partial void Modify_Request(ref Request request, ref gaxgrpc::CallSettings callSettings); - partial void Modify_ResourceRequest(ref ResourceRequest request, ref gaxgrpc::CallSettings callSettings); - - // TEST_START - /// - /// Test a paginated RPC with a method signature. - /// - /// The request object containing all of the parameters for the API call. - /// If not null, applies overrides to this RPC call. - /// A pageable sequence of resources. - public override gax::PagedEnumerable SignatureMethod(Request request, gaxgrpc::CallSettings callSettings = null) - { - Modify_Request(ref request, ref callSettings); - return new gaxgrpc::GrpcPagedEnumerable(_callSignatureMethod, request, callSettings); - } - - /// - /// Test a paginated RPC with a method signature. - /// - /// The request object containing all of the parameters for the API call. - /// If not null, applies overrides to this RPC call. - /// A pageable asynchronous sequence of resources. - public override gax::PagedAsyncEnumerable SignatureMethodAsync(Request request, gaxgrpc::CallSettings callSettings = null) - { - Modify_Request(ref request, ref callSettings); - return new gaxgrpc::GrpcPagedAsyncEnumerable(_callSignatureMethod, request, callSettings); - } - - /// - /// Test rpc with duplicate response message, to make sure partial LRO response class is only generated once. - /// - /// The request object containing all of the parameters for the API call. - /// If not null, applies overrides to this RPC call. - /// A pageable sequence of resources. - public override gax::PagedEnumerable SignatureMethod2(Request request, gaxgrpc::CallSettings callSettings = null) - { - Modify_Request(ref request, ref callSettings); - return new gaxgrpc::GrpcPagedEnumerable(_callSignatureMethod2, request, callSettings); - } - - /// - /// Test rpc with duplicate response message, to make sure partial LRO response class is only generated once. - /// - /// The request object containing all of the parameters for the API call. - /// If not null, applies overrides to this RPC call. - /// A pageable asynchronous sequence of resources. - public override gax::PagedAsyncEnumerable SignatureMethod2Async(Request request, gaxgrpc::CallSettings callSettings = null) - { - Modify_Request(ref request, ref callSettings); - return new gaxgrpc::GrpcPagedAsyncEnumerable(_callSignatureMethod2, request, callSettings); - } - - /// - /// Test a paginated RPC with a method signature that contains resource-names - /// in both the request and the response. - /// - /// The request object containing all of the parameters for the API call. - /// If not null, applies overrides to this RPC call. - /// A pageable sequence of resources. - public override gax::PagedEnumerable ResourcedMethod(ResourceRequest request, gaxgrpc::CallSettings callSettings = null) - { - Modify_ResourceRequest(ref request, ref callSettings); - return new gaxgrpc::GrpcPagedEnumerable(_callResourcedMethod, request, callSettings); - } - - /// - /// Test a paginated RPC with a method signature that contains resource-names - /// in both the request and the response. - /// - /// The request object containing all of the parameters for the API call. - /// If not null, applies overrides to this RPC call. - /// A pageable asynchronous sequence of resources. - public override gax::PagedAsyncEnumerable ResourcedMethodAsync(ResourceRequest request, gaxgrpc::CallSettings callSettings = null) - { - Modify_ResourceRequest(ref request, ref callSettings); - return new gaxgrpc::GrpcPagedAsyncEnumerable(_callResourcedMethod, request, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ResourcedMethodAsync(request); } // TEST_END } diff --git a/Google.Api.Generator.Tests/ProtoTests/Showcase/Google.Showcase.V1Beta1/MessagingClient.g.cs b/Google.Api.Generator.Tests/ProtoTests/Showcase/Google.Showcase.V1Beta1/MessagingClient.g.cs index e089cec1..3c9e5369 100644 --- a/Google.Api.Generator.Tests/ProtoTests/Showcase/Google.Showcase.V1Beta1/MessagingClient.g.cs +++ b/Google.Api.Generator.Tests/ProtoTests/Showcase/Google.Showcase.V1Beta1/MessagingClient.g.cs @@ -1372,13 +1372,22 @@ public virtual void DeleteBlurb(BlurbName name, gaxgrpc::CallSettings callSettin /// /// If not null, applies overrides to this RPC call. /// A pageable sequence of resources. - public virtual gax::PagedEnumerable ListBlurbs(string parent, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ListBlurbs(new ListBlurbsRequest + public virtual gax::PagedEnumerable ListBlurbs(string parent, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ListBlurbsRequest request = new ListBlurbsRequest { Parent = gax::GaxPreconditions.CheckNotNullOrEmpty(parent, nameof(parent)), - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ListBlurbs(request); + } /// /// Lists blurbs for a specific chat room or user profile depending on the @@ -1397,13 +1406,22 @@ public virtual void DeleteBlurb(BlurbName name, gaxgrpc::CallSettings callSettin /// /// If not null, applies overrides to this RPC call. /// A pageable asynchronous sequence of resources. - public virtual gax::PagedAsyncEnumerable ListBlurbsAsync(string parent, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ListBlurbsAsync(new ListBlurbsRequest + public virtual gax::PagedAsyncEnumerable ListBlurbsAsync(string parent, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ListBlurbsRequest request = new ListBlurbsRequest { Parent = gax::GaxPreconditions.CheckNotNullOrEmpty(parent, nameof(parent)), - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ListBlurbsAsync(request); + } /// /// Lists blurbs for a specific chat room or user profile depending on the @@ -1422,13 +1440,22 @@ public virtual void DeleteBlurb(BlurbName name, gaxgrpc::CallSettings callSettin /// /// If not null, applies overrides to this RPC call. /// A pageable sequence of resources. - public virtual gax::PagedEnumerable ListBlurbs(RoomName parent, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ListBlurbs(new ListBlurbsRequest + public virtual gax::PagedEnumerable ListBlurbs(RoomName parent, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ListBlurbsRequest request = new ListBlurbsRequest { ParentAsRoomName = gax::GaxPreconditions.CheckNotNull(parent, nameof(parent)), - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ListBlurbs(request); + } /// /// Lists blurbs for a specific chat room or user profile depending on the @@ -1447,13 +1474,22 @@ public virtual void DeleteBlurb(BlurbName name, gaxgrpc::CallSettings callSettin /// /// If not null, applies overrides to this RPC call. /// A pageable asynchronous sequence of resources. - public virtual gax::PagedAsyncEnumerable ListBlurbsAsync(RoomName parent, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) => - ListBlurbsAsync(new ListBlurbsRequest + public virtual gax::PagedAsyncEnumerable ListBlurbsAsync(RoomName parent, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + ListBlurbsRequest request = new ListBlurbsRequest { ParentAsRoomName = gax::GaxPreconditions.CheckNotNull(parent, nameof(parent)), - PageToken = pageToken ?? "", - PageSize = pageSize ?? 0, - }, callSettings); + }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return ListBlurbsAsync(request); + } /// /// This method searches through all blurbs across all rooms and profiles