diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Deprecated.proto b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Deprecated.proto index 08843864..02bf2f53 100644 --- a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Deprecated.proto +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Deprecated.proto @@ -23,6 +23,19 @@ service Deprecated { // Test method rpc DeprecatedResponseMethod(Request) returns(DeprecatedMessageResponse); + + // Test method + rpc DeprecatedResourcesFieldPaginatedMethod(PaginatedRequest) returns(DeprecatedResourcesFieldPaginatedResponse) { + option (google.api.method_signature) = "name"; + }; + + // Test method + rpc DeprecatedPaginatedMethod(PaginatedRequest) returns(PaginatedResponse) { + option deprecated = true; + }; + + // Test method + rpc DeprecatedResponsePaginatedMethod(PaginatedRequest) returns(DeprecatedPaginatedResponse); } // A whole service that's deprecated this time. One RPC which is explicitly @@ -59,3 +72,26 @@ message DeprecatedMessageResponse { message Response { } + +message PaginatedRequest { + string name = 1; + int32 page_size = 2; + string page_token = 3; +} + +message DeprecatedResourcesFieldPaginatedResponse { + repeated Response items = 1 [deprecated = true]; + string next_page_token = 2; + repeated Response replacement_items = 3; +} + +message PaginatedResponse { + repeated Response items = 1; + string next_page_token = 2; +} + +message DeprecatedPaginatedResponse { + option deprecated = true; + repeated Response items = 1; + string next_page_token = 2; +} diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/DeprecatedFakes.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/DeprecatedFakes.cs index 952e0475..d2fa4ece 100644 --- a/Google.Api.Generator.Tests/ProtoTests/Deprecated/DeprecatedFakes.cs +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/DeprecatedFakes.cs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Google.Protobuf.Collections; using Google.Protobuf.Reflection; using Grpc.Core; using System; @@ -37,6 +38,12 @@ public DeprecatedClient(CallInvoker callInvoker) { } public virtual AsyncUnaryCall DeprecatedMethodAsync(Request request, CallOptions callOptions) => throw new NotImplementedException(); public virtual DeprecatedMessageResponse DeprecatedResponseMethod(Request request, CallOptions callOptions) => throw new NotImplementedException(); public virtual AsyncUnaryCall DeprecatedResponseMethodAsync(Request request, CallOptions callOptions) => throw new NotImplementedException(); + public virtual DeprecatedResourcesFieldPaginatedResponse DeprecatedResourcesFieldPaginatedMethod(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException(); + public virtual AsyncUnaryCall DeprecatedResourcesFieldPaginatedMethodAsync(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException(); + public virtual PaginatedResponse DeprecatedPaginatedMethod(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException(); + public virtual AsyncUnaryCall DeprecatedPaginatedMethodAsync(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException(); + public virtual DeprecatedPaginatedResponse DeprecatedResponsePaginatedMethod(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException(); + public virtual AsyncUnaryCall DeprecatedResponsePaginatedMethodAsync(PaginatedRequest request, CallOptions callOptions) => throw new NotImplementedException(); } } @@ -72,4 +79,32 @@ public class Request : ProtoMsgFake { } public class DeprecatedMessageResponse : ProtoMsgFake { } public class Response : ProtoMsgFake { } + + public partial class PaginatedRequest : ProtoMsgFake + { + public string Name { get; set; } + public int PageSize { get; set; } + public string PageToken { get; set; } + } + + public partial class DeprecatedResourcesFieldPaginatedResponse : ProtoMsgFake + { + [Obsolete] + public RepeatedField Items => throw new NotImplementedException(); + public string NextPageToken { get; set; } + public RepeatedField ReplacementItems => throw new NotImplementedException(); + } + + public partial class PaginatedResponse : ProtoMsgFake + { + public RepeatedField Items => throw new NotImplementedException(); + public string NextPageToken { get; set; } + } + + [Obsolete] + public partial class DeprecatedPaginatedResponse : ProtoMsgFake + { + public RepeatedField Items => throw new NotImplementedException(); + public string NextPageToken { get; set; } + } } diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedPaginatedMethodRequestObjectAsyncSnippet.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedPaginatedMethodRequestObjectAsyncSnippet.g.cs new file mode 100644 index 00000000..1385c4f5 --- /dev/null +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedPaginatedMethodRequestObjectAsyncSnippet.g.cs @@ -0,0 +1,80 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated code. DO NOT EDIT! + +namespace GoogleCSharpSnippets +{ + // [START deprecated_generated_Deprecated_DeprecatedPaginatedMethod_async] + using Google.Api.Gax; + using System; + using System.Threading.Tasks; + using Testing.Deprecated; + + public sealed partial class GeneratedDeprecatedClientSnippets + { + /// Snippet for DeprecatedPaginatedMethodAsync + /// + /// This snippet has been automatically generated and should be regarded as a code template only. + /// It will require modifications to work: + /// - It may require correct/in-range values for request initialization. + /// - It may require specifying regional endpoints when creating the service client as shown in + /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. + /// + public async Task DeprecatedPaginatedMethodRequestObjectAsync() + { + // Create client + DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request +#pragma warning disable CS0612 + PagedAsyncEnumerable response = deprecatedClient.DeprecatedPaginatedMethodAsync(request); +#pragma warning restore CS0612 + + // Iterate over all response items, lazily performing RPCs as required + await foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + await foreach (PaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = await response.ReadPageAsync(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + } + } + // [END deprecated_generated_Deprecated_DeprecatedPaginatedMethod_async] +} diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedPaginatedMethodRequestObjectSnippet.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedPaginatedMethodRequestObjectSnippet.g.cs new file mode 100644 index 00000000..b9589e28 --- /dev/null +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedPaginatedMethodRequestObjectSnippet.g.cs @@ -0,0 +1,79 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated code. DO NOT EDIT! + +namespace GoogleCSharpSnippets +{ + // [START deprecated_generated_Deprecated_DeprecatedPaginatedMethod_sync] + using Google.Api.Gax; + using System; + using Testing.Deprecated; + + public sealed partial class GeneratedDeprecatedClientSnippets + { + /// Snippet for DeprecatedPaginatedMethod + /// + /// This snippet has been automatically generated and should be regarded as a code template only. + /// It will require modifications to work: + /// - It may require correct/in-range values for request initialization. + /// - It may require specifying regional endpoints when creating the service client as shown in + /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. + /// + public void DeprecatedPaginatedMethodRequestObject() + { + // Create client + DeprecatedClient deprecatedClient = DeprecatedClient.Create(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request +#pragma warning disable CS0612 + PagedEnumerable response = deprecatedClient.DeprecatedPaginatedMethod(request); +#pragma warning restore CS0612 + + // Iterate over all response items, lazily performing RPCs as required + foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + foreach (PaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = response.ReadPage(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + } + } + // [END deprecated_generated_Deprecated_DeprecatedPaginatedMethod_sync] +} diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsyncSnippet.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsyncSnippet.g.cs new file mode 100644 index 00000000..7d9e7da0 --- /dev/null +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsyncSnippet.g.cs @@ -0,0 +1,78 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated code. DO NOT EDIT! + +namespace GoogleCSharpSnippets +{ + // [START deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_async_flattened] + using Google.Api.Gax; + using System; + using System.Threading.Tasks; + using Testing.Deprecated; + + public sealed partial class GeneratedDeprecatedClientSnippets + { + /// Snippet for DeprecatedResourcesFieldPaginatedMethodAsync + /// + /// This snippet has been automatically generated and should be regarded as a code template only. + /// It will require modifications to work: + /// - It may require correct/in-range values for request initialization. + /// - It may require specifying regional endpoints when creating the service client as shown in + /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. + /// + public async Task DeprecatedResourcesFieldPaginatedMethodAsync() + { + // Create client + DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync(); + // Initialize request argument(s) + string name = ""; + // Make the request + PagedAsyncEnumerable response = deprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsync(name); + + // Iterate over all response items, lazily performing RPCs as required + await foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + await foreach (DeprecatedResourcesFieldPaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = await response.ReadPageAsync(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + } + } + // [END deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_async_flattened] +} diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodRequestObjectAsyncSnippet.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodRequestObjectAsyncSnippet.g.cs new file mode 100644 index 00000000..19c18612 --- /dev/null +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodRequestObjectAsyncSnippet.g.cs @@ -0,0 +1,78 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated code. DO NOT EDIT! + +namespace GoogleCSharpSnippets +{ + // [START deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_async] + using Google.Api.Gax; + using System; + using System.Threading.Tasks; + using Testing.Deprecated; + + public sealed partial class GeneratedDeprecatedClientSnippets + { + /// Snippet for DeprecatedResourcesFieldPaginatedMethodAsync + /// + /// This snippet has been automatically generated and should be regarded as a code template only. + /// It will require modifications to work: + /// - It may require correct/in-range values for request initialization. + /// - It may require specifying regional endpoints when creating the service client as shown in + /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. + /// + public async Task DeprecatedResourcesFieldPaginatedMethodRequestObjectAsync() + { + // Create client + DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request + PagedAsyncEnumerable response = deprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsync(request); + + // Iterate over all response items, lazily performing RPCs as required + await foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + await foreach (DeprecatedResourcesFieldPaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = await response.ReadPageAsync(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + } + } + // [END deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_async] +} diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodRequestObjectSnippet.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodRequestObjectSnippet.g.cs new file mode 100644 index 00000000..eb04cf82 --- /dev/null +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodRequestObjectSnippet.g.cs @@ -0,0 +1,77 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated code. DO NOT EDIT! + +namespace GoogleCSharpSnippets +{ + // [START deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_sync] + using Google.Api.Gax; + using System; + using Testing.Deprecated; + + public sealed partial class GeneratedDeprecatedClientSnippets + { + /// Snippet for DeprecatedResourcesFieldPaginatedMethod + /// + /// This snippet has been automatically generated and should be regarded as a code template only. + /// It will require modifications to work: + /// - It may require correct/in-range values for request initialization. + /// - It may require specifying regional endpoints when creating the service client as shown in + /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. + /// + public void DeprecatedResourcesFieldPaginatedMethodRequestObject() + { + // Create client + DeprecatedClient deprecatedClient = DeprecatedClient.Create(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request + PagedEnumerable response = deprecatedClient.DeprecatedResourcesFieldPaginatedMethod(request); + + // Iterate over all response items, lazily performing RPCs as required + foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + foreach (DeprecatedResourcesFieldPaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = response.ReadPage(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + } + } + // [END deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_sync] +} diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodSnippet.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodSnippet.g.cs new file mode 100644 index 00000000..f4977fae --- /dev/null +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodSnippet.g.cs @@ -0,0 +1,77 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated code. DO NOT EDIT! + +namespace GoogleCSharpSnippets +{ + // [START deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_sync_flattened] + using Google.Api.Gax; + using System; + using Testing.Deprecated; + + public sealed partial class GeneratedDeprecatedClientSnippets + { + /// Snippet for DeprecatedResourcesFieldPaginatedMethod + /// + /// This snippet has been automatically generated and should be regarded as a code template only. + /// It will require modifications to work: + /// - It may require correct/in-range values for request initialization. + /// - It may require specifying regional endpoints when creating the service client as shown in + /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. + /// + public void DeprecatedResourcesFieldPaginatedMethod() + { + // Create client + DeprecatedClient deprecatedClient = DeprecatedClient.Create(); + // Initialize request argument(s) + string name = ""; + // Make the request + PagedEnumerable response = deprecatedClient.DeprecatedResourcesFieldPaginatedMethod(name); + + // Iterate over all response items, lazily performing RPCs as required + foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + foreach (DeprecatedResourcesFieldPaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = response.ReadPage(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + } + } + // [END deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_sync_flattened] +} diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResponsePaginatedMethodRequestObjectAsyncSnippet.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResponsePaginatedMethodRequestObjectAsyncSnippet.g.cs new file mode 100644 index 00000000..6c6c8d04 --- /dev/null +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResponsePaginatedMethodRequestObjectAsyncSnippet.g.cs @@ -0,0 +1,82 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated code. DO NOT EDIT! + +namespace GoogleCSharpSnippets +{ + // [START deprecated_generated_Deprecated_DeprecatedResponsePaginatedMethod_async] + using Google.Api.Gax; + using System; + using System.Threading.Tasks; + using Testing.Deprecated; + + public sealed partial class GeneratedDeprecatedClientSnippets + { + /// Snippet for DeprecatedResponsePaginatedMethodAsync + /// + /// This snippet has been automatically generated and should be regarded as a code template only. + /// It will require modifications to work: + /// - It may require correct/in-range values for request initialization. + /// - It may require specifying regional endpoints when creating the service client as shown in + /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. + /// + public async Task DeprecatedResponsePaginatedMethodRequestObjectAsync() + { + // Create client + DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request +#pragma warning disable CS0612 + PagedAsyncEnumerable response = deprecatedClient.DeprecatedResponsePaginatedMethodAsync(request); +#pragma warning restore CS0612 + + // Iterate over all response items, lazily performing RPCs as required + await foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page +#pragma warning disable CS0612 + await foreach (DeprecatedPaginatedResponse page in response.AsRawResponses()) +#pragma warning restore CS0612 + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = await response.ReadPageAsync(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + } + } + // [END deprecated_generated_Deprecated_DeprecatedResponsePaginatedMethod_async] +} diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResponsePaginatedMethodRequestObjectSnippet.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResponsePaginatedMethodRequestObjectSnippet.g.cs new file mode 100644 index 00000000..9818ba3b --- /dev/null +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/DeprecatedClient.DeprecatedResponsePaginatedMethodRequestObjectSnippet.g.cs @@ -0,0 +1,81 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Generated code. DO NOT EDIT! + +namespace GoogleCSharpSnippets +{ + // [START deprecated_generated_Deprecated_DeprecatedResponsePaginatedMethod_sync] + using Google.Api.Gax; + using System; + using Testing.Deprecated; + + public sealed partial class GeneratedDeprecatedClientSnippets + { + /// Snippet for DeprecatedResponsePaginatedMethod + /// + /// This snippet has been automatically generated and should be regarded as a code template only. + /// It will require modifications to work: + /// - It may require correct/in-range values for request initialization. + /// - It may require specifying regional endpoints when creating the service client as shown in + /// https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint. + /// + public void DeprecatedResponsePaginatedMethodRequestObject() + { + // Create client + DeprecatedClient deprecatedClient = DeprecatedClient.Create(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request +#pragma warning disable CS0612 + PagedEnumerable response = deprecatedClient.DeprecatedResponsePaginatedMethod(request); +#pragma warning restore CS0612 + + // Iterate over all response items, lazily performing RPCs as required + foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page +#pragma warning disable CS0612 + foreach (DeprecatedPaginatedResponse page in response.AsRawResponses()) +#pragma warning restore CS0612 + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = response.ReadPage(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + } + } + // [END deprecated_generated_Deprecated_DeprecatedResponsePaginatedMethod_sync] +} diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/snippet_metadata_testing.deprecated.json b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/snippet_metadata_testing.deprecated.json index 163923a6..19fa09bc 100644 --- a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/snippet_metadata_testing.deprecated.json +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.GeneratedSnippets/snippet_metadata_testing.deprecated.json @@ -500,6 +500,408 @@ } ] }, + { + "regionTag": "deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_sync", + "title": "DeprecatedResourcesFieldPaginatedMethodRequestObject", + "description": "Snippet for DeprecatedResourcesFieldPaginatedMethod", + "file": "DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodRequestObjectSnippet.g.cs", + "language": "C_SHARP", + "clientMethod": { + "shortName": "DeprecatedResourcesFieldPaginatedMethod", + "fullName": "Testing.Deprecated.DeprecatedClient.DeprecatedResourcesFieldPaginatedMethod", + "parameters": [ + { + "type": "Testing.Deprecated.PaginatedRequest", + "name": "request" + }, + { + "type": "Google.Api.Gax.Grpc.CallSettings", + "name": "callSettings" + } + ], + "resultType": "Google.Api.Gax.PagedEnumerable", + "client": { + "shortName": "DeprecatedClient", + "fullName": "Testing.Deprecated.DeprecatedClient" + }, + "method": { + "shortName": "DeprecatedResourcesFieldPaginatedMethod", + "fullName": "testing.deprecated.Deprecated.DeprecatedResourcesFieldPaginatedMethod", + "service": { + "shortName": "Deprecated", + "fullName": "testing.deprecated.Deprecated" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 75, + "type": "FULL" + }, + { + "start": 36, + "end": 73, + "type": "SHORT" + } + ] + }, + { + "regionTag": "deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_async", + "title": "DeprecatedResourcesFieldPaginatedMethodRequestObjectAsync", + "description": "Snippet for DeprecatedResourcesFieldPaginatedMethodAsync", + "file": "DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodRequestObjectAsyncSnippet.g.cs", + "language": "C_SHARP", + "clientMethod": { + "shortName": "DeprecatedResourcesFieldPaginatedMethodAsync", + "fullName": "Testing.Deprecated.DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsync", + "async": true, + "parameters": [ + { + "type": "Testing.Deprecated.PaginatedRequest", + "name": "request" + }, + { + "type": "Google.Api.Gax.Grpc.CallSettings", + "name": "callSettings" + } + ], + "resultType": "Google.Api.Gax.PagedAsyncEnumerable", + "client": { + "shortName": "DeprecatedClient", + "fullName": "Testing.Deprecated.DeprecatedClient" + }, + "method": { + "shortName": "DeprecatedResourcesFieldPaginatedMethod", + "fullName": "testing.deprecated.Deprecated.DeprecatedResourcesFieldPaginatedMethod", + "service": { + "shortName": "Deprecated", + "fullName": "testing.deprecated.Deprecated" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 76, + "type": "FULL" + }, + { + "start": 37, + "end": 74, + "type": "SHORT" + } + ] + }, + { + "regionTag": "deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_sync_flattened", + "title": "DeprecatedResourcesFieldPaginatedMethod", + "description": "Snippet for DeprecatedResourcesFieldPaginatedMethod", + "file": "DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodSnippet.g.cs", + "language": "C_SHARP", + "clientMethod": { + "shortName": "DeprecatedResourcesFieldPaginatedMethod", + "fullName": "Testing.Deprecated.DeprecatedClient.DeprecatedResourcesFieldPaginatedMethod", + "parameters": [ + { + "type": "System.String", + "name": "name" + }, + { + "type": "System.String", + "name": "pageToken" + }, + { + "type": "System.Nullable[System.Int32]", + "name": "pageSize" + }, + { + "type": "Google.Api.Gax.Grpc.CallSettings", + "name": "callSettings" + } + ], + "resultType": "Google.Api.Gax.PagedEnumerable", + "client": { + "shortName": "DeprecatedClient", + "fullName": "Testing.Deprecated.DeprecatedClient" + }, + "method": { + "shortName": "DeprecatedResourcesFieldPaginatedMethod", + "fullName": "testing.deprecated.Deprecated.DeprecatedResourcesFieldPaginatedMethod", + "service": { + "shortName": "Deprecated", + "fullName": "testing.deprecated.Deprecated" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 75, + "type": "FULL" + }, + { + "start": 36, + "end": 73, + "type": "SHORT" + } + ] + }, + { + "regionTag": "deprecated_generated_Deprecated_DeprecatedResourcesFieldPaginatedMethod_async_flattened", + "title": "DeprecatedResourcesFieldPaginatedMethodAsync", + "description": "Snippet for DeprecatedResourcesFieldPaginatedMethodAsync", + "file": "DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsyncSnippet.g.cs", + "language": "C_SHARP", + "clientMethod": { + "shortName": "DeprecatedResourcesFieldPaginatedMethodAsync", + "fullName": "Testing.Deprecated.DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsync", + "async": true, + "parameters": [ + { + "type": "System.String", + "name": "name" + }, + { + "type": "System.String", + "name": "pageToken" + }, + { + "type": "System.Nullable[System.Int32]", + "name": "pageSize" + }, + { + "type": "Google.Api.Gax.Grpc.CallSettings", + "name": "callSettings" + } + ], + "resultType": "Google.Api.Gax.PagedAsyncEnumerable", + "client": { + "shortName": "DeprecatedClient", + "fullName": "Testing.Deprecated.DeprecatedClient" + }, + "method": { + "shortName": "DeprecatedResourcesFieldPaginatedMethod", + "fullName": "testing.deprecated.Deprecated.DeprecatedResourcesFieldPaginatedMethod", + "service": { + "shortName": "Deprecated", + "fullName": "testing.deprecated.Deprecated" + } + } + }, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 76, + "type": "FULL" + }, + { + "start": 37, + "end": 74, + "type": "SHORT" + } + ] + }, + { + "regionTag": "deprecated_generated_Deprecated_DeprecatedPaginatedMethod_sync", + "title": "DeprecatedPaginatedMethodRequestObject", + "description": "Snippet for DeprecatedPaginatedMethod", + "file": "DeprecatedClient.DeprecatedPaginatedMethodRequestObjectSnippet.g.cs", + "language": "C_SHARP", + "clientMethod": { + "shortName": "DeprecatedPaginatedMethod", + "fullName": "Testing.Deprecated.DeprecatedClient.DeprecatedPaginatedMethod", + "parameters": [ + { + "type": "Testing.Deprecated.PaginatedRequest", + "name": "request" + }, + { + "type": "Google.Api.Gax.Grpc.CallSettings", + "name": "callSettings" + } + ], + "resultType": "Google.Api.Gax.PagedEnumerable", + "client": { + "shortName": "DeprecatedClient", + "fullName": "Testing.Deprecated.DeprecatedClient" + }, + "method": { + "shortName": "DeprecatedPaginatedMethod", + "fullName": "testing.deprecated.Deprecated.DeprecatedPaginatedMethod", + "service": { + "shortName": "Deprecated", + "fullName": "testing.deprecated.Deprecated" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 77, + "type": "FULL" + }, + { + "start": 36, + "end": 75, + "type": "SHORT" + } + ] + }, + { + "regionTag": "deprecated_generated_Deprecated_DeprecatedPaginatedMethod_async", + "title": "DeprecatedPaginatedMethodRequestObjectAsync", + "description": "Snippet for DeprecatedPaginatedMethodAsync", + "file": "DeprecatedClient.DeprecatedPaginatedMethodRequestObjectAsyncSnippet.g.cs", + "language": "C_SHARP", + "clientMethod": { + "shortName": "DeprecatedPaginatedMethodAsync", + "fullName": "Testing.Deprecated.DeprecatedClient.DeprecatedPaginatedMethodAsync", + "async": true, + "parameters": [ + { + "type": "Testing.Deprecated.PaginatedRequest", + "name": "request" + }, + { + "type": "Google.Api.Gax.Grpc.CallSettings", + "name": "callSettings" + } + ], + "resultType": "Google.Api.Gax.PagedAsyncEnumerable", + "client": { + "shortName": "DeprecatedClient", + "fullName": "Testing.Deprecated.DeprecatedClient" + }, + "method": { + "shortName": "DeprecatedPaginatedMethod", + "fullName": "testing.deprecated.Deprecated.DeprecatedPaginatedMethod", + "service": { + "shortName": "Deprecated", + "fullName": "testing.deprecated.Deprecated" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 78, + "type": "FULL" + }, + { + "start": 37, + "end": 76, + "type": "SHORT" + } + ] + }, + { + "regionTag": "deprecated_generated_Deprecated_DeprecatedResponsePaginatedMethod_sync", + "title": "DeprecatedResponsePaginatedMethodRequestObject", + "description": "Snippet for DeprecatedResponsePaginatedMethod", + "file": "DeprecatedClient.DeprecatedResponsePaginatedMethodRequestObjectSnippet.g.cs", + "language": "C_SHARP", + "clientMethod": { + "shortName": "DeprecatedResponsePaginatedMethod", + "fullName": "Testing.Deprecated.DeprecatedClient.DeprecatedResponsePaginatedMethod", + "parameters": [ + { + "type": "Testing.Deprecated.PaginatedRequest", + "name": "request" + }, + { + "type": "Google.Api.Gax.Grpc.CallSettings", + "name": "callSettings" + } + ], + "resultType": "Google.Api.Gax.PagedEnumerable", + "client": { + "shortName": "DeprecatedClient", + "fullName": "Testing.Deprecated.DeprecatedClient" + }, + "method": { + "shortName": "DeprecatedResponsePaginatedMethod", + "fullName": "testing.deprecated.Deprecated.DeprecatedResponsePaginatedMethod", + "service": { + "shortName": "Deprecated", + "fullName": "testing.deprecated.Deprecated" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 79, + "type": "FULL" + }, + { + "start": 36, + "end": 77, + "type": "SHORT" + } + ] + }, + { + "regionTag": "deprecated_generated_Deprecated_DeprecatedResponsePaginatedMethod_async", + "title": "DeprecatedResponsePaginatedMethodRequestObjectAsync", + "description": "Snippet for DeprecatedResponsePaginatedMethodAsync", + "file": "DeprecatedClient.DeprecatedResponsePaginatedMethodRequestObjectAsyncSnippet.g.cs", + "language": "C_SHARP", + "clientMethod": { + "shortName": "DeprecatedResponsePaginatedMethodAsync", + "fullName": "Testing.Deprecated.DeprecatedClient.DeprecatedResponsePaginatedMethodAsync", + "async": true, + "parameters": [ + { + "type": "Testing.Deprecated.PaginatedRequest", + "name": "request" + }, + { + "type": "Google.Api.Gax.Grpc.CallSettings", + "name": "callSettings" + } + ], + "resultType": "Google.Api.Gax.PagedAsyncEnumerable", + "client": { + "shortName": "DeprecatedClient", + "fullName": "Testing.Deprecated.DeprecatedClient" + }, + "method": { + "shortName": "DeprecatedResponsePaginatedMethod", + "fullName": "testing.deprecated.Deprecated.DeprecatedResponsePaginatedMethod", + "service": { + "shortName": "Deprecated", + "fullName": "testing.deprecated.Deprecated" + } + } + }, + "canonical": true, + "origin": "API_DEFINITION", + "segments": [ + { + "start": 20, + "end": 80, + "type": "FULL" + }, + { + "start": 37, + "end": 78, + "type": "SHORT" + } + ] + }, { "regionTag": "deprecated_generated_DeprecatedService_NonDeprecatedMethod_sync", "title": "NonDeprecatedMethodRequestObject", diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.Snippets/DeprecatedClientSnippets.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.Snippets/DeprecatedClientSnippets.g.cs index be2ae123..bc08fee8 100644 --- a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.Snippets/DeprecatedClientSnippets.g.cs +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated.Snippets/DeprecatedClientSnippets.g.cs @@ -16,6 +16,8 @@ namespace GoogleCSharpSnippets { + using Google.Api.Gax; + using System; using System.Threading.Tasks; using Testing.Deprecated; @@ -178,5 +180,377 @@ public async Task DeprecatedResponseMethodRequestObjectAsync() #pragma warning restore CS0612 // End snippet } + + /// Snippet for DeprecatedResourcesFieldPaginatedMethod + public void DeprecatedResourcesFieldPaginatedMethodRequestObject() + { + // Snippet: DeprecatedResourcesFieldPaginatedMethod(PaginatedRequest, CallSettings) + // Create client + DeprecatedClient deprecatedClient = DeprecatedClient.Create(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request + PagedEnumerable response = deprecatedClient.DeprecatedResourcesFieldPaginatedMethod(request); + + // Iterate over all response items, lazily performing RPCs as required + foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + foreach (DeprecatedResourcesFieldPaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = response.ReadPage(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + // End snippet + } + + /// Snippet for DeprecatedResourcesFieldPaginatedMethodAsync + public async Task DeprecatedResourcesFieldPaginatedMethodRequestObjectAsync() + { + // Snippet: DeprecatedResourcesFieldPaginatedMethodAsync(PaginatedRequest, CallSettings) + // Create client + DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request + PagedAsyncEnumerable response = deprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsync(request); + + // Iterate over all response items, lazily performing RPCs as required + await foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + await foreach (DeprecatedResourcesFieldPaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = await response.ReadPageAsync(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + // End snippet + } + + /// Snippet for DeprecatedResourcesFieldPaginatedMethod + public void DeprecatedResourcesFieldPaginatedMethod() + { + // Snippet: DeprecatedResourcesFieldPaginatedMethod(string, string, int?, CallSettings) + // Create client + DeprecatedClient deprecatedClient = DeprecatedClient.Create(); + // Initialize request argument(s) + string name = ""; + // Make the request + PagedEnumerable response = deprecatedClient.DeprecatedResourcesFieldPaginatedMethod(name); + + // Iterate over all response items, lazily performing RPCs as required + foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + foreach (DeprecatedResourcesFieldPaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = response.ReadPage(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + // End snippet + } + + /// Snippet for DeprecatedResourcesFieldPaginatedMethodAsync + public async Task DeprecatedResourcesFieldPaginatedMethodAsync() + { + // Snippet: DeprecatedResourcesFieldPaginatedMethodAsync(string, string, int?, CallSettings) + // Create client + DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync(); + // Initialize request argument(s) + string name = ""; + // Make the request + PagedAsyncEnumerable response = deprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsync(name); + + // Iterate over all response items, lazily performing RPCs as required + await foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + await foreach (DeprecatedResourcesFieldPaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = await response.ReadPageAsync(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + // End snippet + } + + /// Snippet for DeprecatedPaginatedMethod + public void DeprecatedPaginatedMethodRequestObject() + { + // Snippet: DeprecatedPaginatedMethod(PaginatedRequest, CallSettings) + // Create client + DeprecatedClient deprecatedClient = DeprecatedClient.Create(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request +#pragma warning disable CS0612 + PagedEnumerable response = deprecatedClient.DeprecatedPaginatedMethod(request); +#pragma warning restore CS0612 + + // Iterate over all response items, lazily performing RPCs as required + foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + foreach (PaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = response.ReadPage(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + // End snippet + } + + /// Snippet for DeprecatedPaginatedMethodAsync + public async Task DeprecatedPaginatedMethodRequestObjectAsync() + { + // Snippet: DeprecatedPaginatedMethodAsync(PaginatedRequest, CallSettings) + // Create client + DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request +#pragma warning disable CS0612 + PagedAsyncEnumerable response = deprecatedClient.DeprecatedPaginatedMethodAsync(request); +#pragma warning restore CS0612 + + // Iterate over all response items, lazily performing RPCs as required + await foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page + await foreach (PaginatedResponse page in response.AsRawResponses()) + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = await response.ReadPageAsync(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + // End snippet + } + + /// Snippet for DeprecatedResponsePaginatedMethod + public void DeprecatedResponsePaginatedMethodRequestObject() + { + // Snippet: DeprecatedResponsePaginatedMethod(PaginatedRequest, CallSettings) + // Create client + DeprecatedClient deprecatedClient = DeprecatedClient.Create(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request +#pragma warning disable CS0612 + PagedEnumerable response = deprecatedClient.DeprecatedResponsePaginatedMethod(request); +#pragma warning restore CS0612 + + // Iterate over all response items, lazily performing RPCs as required + foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page +#pragma warning disable CS0612 + foreach (DeprecatedPaginatedResponse page in response.AsRawResponses()) +#pragma warning restore CS0612 + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = response.ReadPage(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + // End snippet + } + + /// Snippet for DeprecatedResponsePaginatedMethodAsync + public async Task DeprecatedResponsePaginatedMethodRequestObjectAsync() + { + // Snippet: DeprecatedResponsePaginatedMethodAsync(PaginatedRequest, CallSettings) + // Create client + DeprecatedClient deprecatedClient = await DeprecatedClient.CreateAsync(); + // Initialize request argument(s) + PaginatedRequest request = new PaginatedRequest { Name = "", }; + // Make the request +#pragma warning disable CS0612 + PagedAsyncEnumerable response = deprecatedClient.DeprecatedResponsePaginatedMethodAsync(request); +#pragma warning restore CS0612 + + // Iterate over all response items, lazily performing RPCs as required + await foreach (Response item in response) + { + // Do something with each item + Console.WriteLine(item); + } + + // Or iterate over pages (of server-defined size), performing one RPC per page +#pragma warning disable CS0612 + await foreach (DeprecatedPaginatedResponse page in response.AsRawResponses()) +#pragma warning restore CS0612 + { + // Do something with each page of items + Console.WriteLine("A page of results:"); + foreach (Response item in page) + { + // Do something with each item + Console.WriteLine(item); + } + } + + // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required + int pageSize = 10; + Page singlePage = await response.ReadPageAsync(pageSize); + // Do something with the page of items + Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); + foreach (Response item in singlePage) + { + // Do something with each item + Console.WriteLine(item); + } + // Store the pageToken, for when the next page is required. + string nextPageToken = singlePage.NextPageToken; + // End snippet + } } } diff --git a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated/DeprecatedClient.g.cs b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated/DeprecatedClient.g.cs index 76c3df04..5bb87f67 100644 --- a/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated/DeprecatedClient.g.cs +++ b/Google.Api.Generator.Tests/ProtoTests/Deprecated/Testing.Deprecated/DeprecatedClient.g.cs @@ -21,6 +21,7 @@ using grpcinter = Grpc.Core.Interceptors; using mel = Microsoft.Extensions.Logging; using proto = Google.Protobuf; +using sc = System.Collections; using scg = System.Collections.Generic; using sco = System.Collections.ObjectModel; using st = System.Threading; @@ -48,6 +49,9 @@ private DeprecatedSettings(DeprecatedSettings existing) : base(existing) DeprecatedMessageMethodSettings = existing.DeprecatedMessageMethodSettings; DeprecatedMethodSettings = existing.DeprecatedMethodSettings; DeprecatedResponseMethodSettings = existing.DeprecatedResponseMethodSettings; + DeprecatedResourcesFieldPaginatedMethodSettings = existing.DeprecatedResourcesFieldPaginatedMethodSettings; + DeprecatedPaginatedMethodSettings = existing.DeprecatedPaginatedMethodSettings; + DeprecatedResponsePaginatedMethodSettings = existing.DeprecatedResponsePaginatedMethodSettings; OnCopy(existing); } @@ -101,6 +105,45 @@ private DeprecatedSettings(DeprecatedSettings existing) : base(existing) /// public gaxgrpc::CallSettings DeprecatedResponseMethodSettings { get; set; } = gaxgrpc::CallSettings.FromExpiration(gax::Expiration.None); + /// + /// for synchronous and asynchronous calls to + /// DeprecatedClient.DeprecatedResourcesFieldPaginatedMethod and + /// DeprecatedClient.DeprecatedResourcesFieldPaginatedMethodAsync. + /// + /// + /// + /// This call will not be retried. + /// No timeout is applied. + /// + /// + public gaxgrpc::CallSettings DeprecatedResourcesFieldPaginatedMethodSettings { get; set; } = gaxgrpc::CallSettings.FromExpiration(gax::Expiration.None); + + /// + /// for synchronous and asynchronous calls to + /// DeprecatedClient.DeprecatedPaginatedMethod and DeprecatedClient.DeprecatedPaginatedMethodAsync + /// . + /// + /// + /// + /// This call will not be retried. + /// No timeout is applied. + /// + /// + public gaxgrpc::CallSettings DeprecatedPaginatedMethodSettings { get; set; } = gaxgrpc::CallSettings.FromExpiration(gax::Expiration.None); + + /// + /// for synchronous and asynchronous calls to + /// DeprecatedClient.DeprecatedResponsePaginatedMethod and + /// DeprecatedClient.DeprecatedResponsePaginatedMethodAsync. + /// + /// + /// + /// This call will not be retried. + /// No timeout is applied. + /// + /// + public gaxgrpc::CallSettings DeprecatedResponsePaginatedMethodSettings { get; set; } = gaxgrpc::CallSettings.FromExpiration(gax::Expiration.None); + /// Creates a deep clone of this object, with all the same property values. /// A deep clone of this object. public DeprecatedSettings Clone() => new DeprecatedSettings(this); @@ -408,6 +451,126 @@ public virtual DeprecatedMessageResponse DeprecatedResponseMethod(Request reques public virtual stt::Task DeprecatedResponseMethodAsync(Request request, st::CancellationToken cancellationToken) => #pragma warning restore CS0612 DeprecatedResponseMethodAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken)); + + /// + /// Test method + /// + /// 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 virtual gax::PagedEnumerable DeprecatedResourcesFieldPaginatedMethod(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) => + throw new sys::NotImplementedException(); + + /// + /// Test method + /// + /// 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 virtual gax::PagedAsyncEnumerable DeprecatedResourcesFieldPaginatedMethodAsync(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) => + throw new sys::NotImplementedException(); + + /// + /// Test method + /// + /// + /// + /// + /// The token returned from the previous request. A value of null or an empty string retrieves the first + /// page. + /// + /// + /// The size of page to request. The response will not be larger than this, but may be smaller. A value of + /// null or 0 uses a server-defined page size. + /// + /// If not null, applies overrides to this RPC call. + /// A pageable sequence of resources. + public virtual gax::PagedEnumerable DeprecatedResourcesFieldPaginatedMethod(string name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + PaginatedRequest request = new PaginatedRequest { Name = name ?? "", }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return DeprecatedResourcesFieldPaginatedMethod(request, callSettings); + } + + /// + /// Test method + /// + /// + /// + /// + /// The token returned from the previous request. A value of null or an empty string retrieves the first + /// page. + /// + /// + /// The size of page to request. The response will not be larger than this, but may be smaller. A value of + /// null or 0 uses a server-defined page size. + /// + /// If not null, applies overrides to this RPC call. + /// A pageable asynchronous sequence of resources. + public virtual gax::PagedAsyncEnumerable DeprecatedResourcesFieldPaginatedMethodAsync(string name, string pageToken = null, int? pageSize = null, gaxgrpc::CallSettings callSettings = null) + { + PaginatedRequest request = new PaginatedRequest { Name = name ?? "", }; + if (pageToken != null) + { + request.PageToken = pageToken; + } + if (pageSize != null) + { + request.PageSize = pageSize.Value; + } + return DeprecatedResourcesFieldPaginatedMethodAsync(request, callSettings); + } + + /// + /// Test method + /// + /// 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. + [sys::ObsoleteAttribute] + public virtual gax::PagedEnumerable DeprecatedPaginatedMethod(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) => + throw new sys::NotImplementedException(); + + /// + /// Test method + /// + /// 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. + [sys::ObsoleteAttribute] + public virtual gax::PagedAsyncEnumerable DeprecatedPaginatedMethodAsync(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) => + throw new sys::NotImplementedException(); + + /// + /// Test method + /// + /// 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. + [sys::ObsoleteAttribute] +#pragma warning disable CS0612 + public virtual gax::PagedEnumerable DeprecatedResponsePaginatedMethod(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) => +#pragma warning restore CS0612 + throw new sys::NotImplementedException(); + + /// + /// Test method + /// + /// 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. + [sys::ObsoleteAttribute] +#pragma warning disable CS0612 + public virtual gax::PagedAsyncEnumerable DeprecatedResponsePaginatedMethodAsync(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) => +#pragma warning restore CS0612 + throw new sys::NotImplementedException(); } /// Deprecated client wrapper implementation, for convenient use. @@ -428,6 +591,14 @@ public sealed partial class DeprecatedClientImpl : DeprecatedClient private readonly gaxgrpc::ApiCall _callDeprecatedResponseMethod; #pragma warning restore CS0612 + private readonly gaxgrpc::ApiCall _callDeprecatedResourcesFieldPaginatedMethod; + + private readonly gaxgrpc::ApiCall _callDeprecatedPaginatedMethod; + +#pragma warning disable CS0612 + private readonly gaxgrpc::ApiCall _callDeprecatedResponsePaginatedMethod; +#pragma warning restore CS0612 + /// /// Constructs a client wrapper for the Deprecated service, with the specified gRPC client and settings. /// @@ -461,6 +632,19 @@ public DeprecatedClientImpl(Deprecated.DeprecatedClient grpcClient, DeprecatedSe #pragma warning restore CS0612 Modify_ApiCall(ref _callDeprecatedResponseMethod); Modify_DeprecatedResponseMethodApiCall(ref _callDeprecatedResponseMethod); + _callDeprecatedResourcesFieldPaginatedMethod = clientHelper.BuildApiCall("DeprecatedResourcesFieldPaginatedMethod", grpcClient.DeprecatedResourcesFieldPaginatedMethodAsync, grpcClient.DeprecatedResourcesFieldPaginatedMethod, effectiveSettings.DeprecatedResourcesFieldPaginatedMethodSettings); + Modify_ApiCall(ref _callDeprecatedResourcesFieldPaginatedMethod); + Modify_DeprecatedResourcesFieldPaginatedMethodApiCall(ref _callDeprecatedResourcesFieldPaginatedMethod); +#pragma warning disable CS0612 + _callDeprecatedPaginatedMethod = clientHelper.BuildApiCall("DeprecatedPaginatedMethod", grpcClient.DeprecatedPaginatedMethodAsync, grpcClient.DeprecatedPaginatedMethod, effectiveSettings.DeprecatedPaginatedMethodSettings); +#pragma warning restore CS0612 + Modify_ApiCall(ref _callDeprecatedPaginatedMethod); + Modify_DeprecatedPaginatedMethodApiCall(ref _callDeprecatedPaginatedMethod); +#pragma warning disable CS0612 + _callDeprecatedResponsePaginatedMethod = clientHelper.BuildApiCall("DeprecatedResponsePaginatedMethod", grpcClient.DeprecatedResponsePaginatedMethodAsync, grpcClient.DeprecatedResponsePaginatedMethod, effectiveSettings.DeprecatedResponsePaginatedMethodSettings); +#pragma warning restore CS0612 + Modify_ApiCall(ref _callDeprecatedResponsePaginatedMethod); + Modify_DeprecatedResponsePaginatedMethodApiCall(ref _callDeprecatedResponsePaginatedMethod); OnConstruction(grpcClient, effectiveSettings, clientHelper); } @@ -478,6 +662,14 @@ public DeprecatedClientImpl(Deprecated.DeprecatedClient grpcClient, DeprecatedSe partial void Modify_DeprecatedResponseMethodApiCall(ref gaxgrpc::ApiCall call); #pragma warning restore CS0612 + partial void Modify_DeprecatedResourcesFieldPaginatedMethodApiCall(ref gaxgrpc::ApiCall call); + + partial void Modify_DeprecatedPaginatedMethodApiCall(ref gaxgrpc::ApiCall call); + +#pragma warning disable CS0612 + partial void Modify_DeprecatedResponsePaginatedMethodApiCall(ref gaxgrpc::ApiCall call); +#pragma warning restore CS0612 + partial void OnConstruction(Deprecated.DeprecatedClient grpcClient, DeprecatedSettings effectiveSettings, gaxgrpc::ClientHelper clientHelper); /// The underlying gRPC Deprecated client @@ -491,6 +683,8 @@ public DeprecatedClientImpl(Deprecated.DeprecatedClient grpcClient, DeprecatedSe partial void Modify_Request(ref Request request, ref gaxgrpc::CallSettings settings); + partial void Modify_PaginatedRequest(ref PaginatedRequest request, ref gaxgrpc::CallSettings settings); + /// /// Test method /// @@ -600,5 +794,121 @@ public override DeprecatedMessageResponse DeprecatedResponseMethod(Request reque Modify_Request(ref request, ref callSettings); return _callDeprecatedResponseMethod.Async(request, callSettings); } + + /// + /// Test method + /// + /// 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 DeprecatedResourcesFieldPaginatedMethod(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) + { + Modify_PaginatedRequest(ref request, ref callSettings); + return new gaxgrpc::GrpcPagedEnumerable(_callDeprecatedResourcesFieldPaginatedMethod, request, callSettings); + } + + /// + /// Test method + /// + /// 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 DeprecatedResourcesFieldPaginatedMethodAsync(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) + { + Modify_PaginatedRequest(ref request, ref callSettings); + return new gaxgrpc::GrpcPagedAsyncEnumerable(_callDeprecatedResourcesFieldPaginatedMethod, request, callSettings); + } + + /// + /// Test method + /// + /// 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. + [sys::ObsoleteAttribute] + public override gax::PagedEnumerable DeprecatedPaginatedMethod(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) + { + Modify_PaginatedRequest(ref request, ref callSettings); + return new gaxgrpc::GrpcPagedEnumerable(_callDeprecatedPaginatedMethod, request, callSettings); + } + + /// + /// Test method + /// + /// 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. + [sys::ObsoleteAttribute] + public override gax::PagedAsyncEnumerable DeprecatedPaginatedMethodAsync(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) + { + Modify_PaginatedRequest(ref request, ref callSettings); + return new gaxgrpc::GrpcPagedAsyncEnumerable(_callDeprecatedPaginatedMethod, request, callSettings); + } + + /// + /// Test method + /// + /// 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. + [sys::ObsoleteAttribute] +#pragma warning disable CS0612 + public override gax::PagedEnumerable DeprecatedResponsePaginatedMethod(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) +#pragma warning restore CS0612 + { + Modify_PaginatedRequest(ref request, ref callSettings); +#pragma warning disable CS0612 + return new gaxgrpc::GrpcPagedEnumerable(_callDeprecatedResponsePaginatedMethod, request, callSettings); +#pragma warning restore CS0612 + } + + /// + /// Test method + /// + /// 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. + [sys::ObsoleteAttribute] +#pragma warning disable CS0612 + public override gax::PagedAsyncEnumerable DeprecatedResponsePaginatedMethodAsync(PaginatedRequest request, gaxgrpc::CallSettings callSettings = null) +#pragma warning restore CS0612 + { + Modify_PaginatedRequest(ref request, ref callSettings); +#pragma warning disable CS0612 + return new gaxgrpc::GrpcPagedAsyncEnumerable(_callDeprecatedResponsePaginatedMethod, request, callSettings); +#pragma warning restore CS0612 + } + } + + public partial class PaginatedRequest : gaxgrpc::IPageRequest + { + } + + public partial class DeprecatedResourcesFieldPaginatedResponse : gaxgrpc::IPageResponse + { + /// Returns an enumerator that iterates through the resources in this response. +#pragma warning disable CS0612 + public scg::IEnumerator GetEnumerator() => Items.GetEnumerator(); +#pragma warning restore CS0612 + + sc::IEnumerator sc::IEnumerable.GetEnumerator() => GetEnumerator(); + } + + public partial class PaginatedResponse : gaxgrpc::IPageResponse + { + /// Returns an enumerator that iterates through the resources in this response. + public scg::IEnumerator GetEnumerator() => Items.GetEnumerator(); + + sc::IEnumerator sc::IEnumerable.GetEnumerator() => GetEnumerator(); + } + + public partial class DeprecatedPaginatedResponse : gaxgrpc::IPageResponse + { + /// Returns an enumerator that iterates through the resources in this response. +#pragma warning disable CS0612 + public scg::IEnumerator GetEnumerator() => Items.GetEnumerator(); +#pragma warning restore CS0612 + + sc::IEnumerator sc::IEnumerable.GetEnumerator() => GetEnumerator(); } } diff --git a/Google.Api.Generator/Generation/MethodDetails.cs b/Google.Api.Generator/Generation/MethodDetails.cs index a9249b52..80e43bf1 100644 --- a/Google.Api.Generator/Generation/MethodDetails.cs +++ b/Google.Api.Generator/Generation/MethodDetails.cs @@ -81,6 +81,7 @@ public Paginated(ServiceDetails svc, MethodDescriptor desc, SyncGrpcType = Typ.Generic(typeof(GrpcPagedEnumerable<,,>), RequestTyp, ResponseTyp, ResourceTyp); AsyncGrpcType = Typ.Generic(typeof(GrpcPagedAsyncEnumerable<,,>), RequestTyp, ResponseTyp, ResourceTyp); ResourcesFieldName = responseResourceField.CSharpPropertyName(); + ResourcesFieldDesc = responseResourceField; PageSizeFieldNumber = pageSizeFieldNumber; PageTokenFieldNumber = pageTokenFieldNumber; } @@ -97,6 +98,7 @@ public Paginated(ServiceDetails svc, MethodDescriptor desc, public Typ SyncGrpcType { get; } public Typ AsyncGrpcType { get; } public string ResourcesFieldName { get; } + public FieldDescriptor ResourcesFieldDesc { get; } public int PageSizeFieldNumber { get; } public int PageTokenFieldNumber { get; } } diff --git a/Google.Api.Generator/Generation/ServiceCodeGenerator.cs b/Google.Api.Generator/Generation/ServiceCodeGenerator.cs index 4137c6db..687f377c 100644 --- a/Google.Api.Generator/Generation/ServiceCodeGenerator.cs +++ b/Google.Api.Generator/Generation/ServiceCodeGenerator.cs @@ -19,6 +19,7 @@ using Google.LongRunning; using Google.Protobuf.Reflection; using Grpc.Core; +using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using System; using System.Collections; @@ -69,9 +70,10 @@ private static IEnumerable PaginatedPartialClasses(Sour var cls = Class(Public | Partial, method.ResponseTyp, baseTypes: ctx.Type(Typ.Generic(typeof(IPageResponse<>), method.ResourceTyp))); using (ctx.InClass(cls)) { - var propertyName = method.ResourcesFieldName; + var resources = SyntaxFactory.IdentifierName(method.ResourcesFieldName) + .MaybeWithPragmaDisableObsoleteWarning(method.ResourcesFieldDesc.IsDeprecated()); var genericGetEnumerator = Method(Public, ctx.Type(Typ.Generic(typeof(IEnumerator<>), method.ResourceTyp)), "GetEnumerator")() - .WithBody(Property(Public, ctx.TypeDontCare, propertyName).Call(nameof(IEnumerable.GetEnumerator))()) + .WithBody(resources.Call(nameof(IEnumerable.GetEnumerator))()) .WithXmlDoc(XmlDoc.Summary("Returns an enumerator that iterates through the resources in this response.")); var getEnumerator = Method(None, ctx.Type(), "GetEnumerator")() .WithExplicitInterfaceSpecifier(ctx.Type())