diff --git a/src/main/java/com/google/api/codegen/transformer/csharp/CSharpSurfaceNamer.java b/src/main/java/com/google/api/codegen/transformer/csharp/CSharpSurfaceNamer.java index 41c202f8be..b2c3fc482a 100644 --- a/src/main/java/com/google/api/codegen/transformer/csharp/CSharpSurfaceNamer.java +++ b/src/main/java/com/google/api/codegen/transformer/csharp/CSharpSurfaceNamer.java @@ -396,8 +396,10 @@ public String getAndSaveOperationResponseTypeName( Method method, ModelTypeTable typeTable, GapicMethodConfig methodConfig) { String responseTypeName = typeTable.getFullNameFor(methodConfig.getLongRunningConfig().getReturnType()); + String metaTypeName = + typeTable.getFullNameFor(methodConfig.getLongRunningConfig().getMetadataType()); return typeTable.getAndSaveNicknameForContainer( - "Google.LongRunning.Operation", responseTypeName); + "Google.LongRunning.Operation", responseTypeName, metaTypeName); } @Override diff --git a/src/main/java/com/google/api/codegen/util/csharp/CSharpTypeTable.java b/src/main/java/com/google/api/codegen/util/csharp/CSharpTypeTable.java index fc33337fdd..4b77533c31 100644 --- a/src/main/java/com/google/api/codegen/util/csharp/CSharpTypeTable.java +++ b/src/main/java/com/google/api/codegen/util/csharp/CSharpTypeTable.java @@ -46,6 +46,7 @@ public TypeName getTypeName(String fullName) { String containerTypeName = fullName.substring(0, firstGenericOpenIndex); List genericParamNames = Splitter.on(',') + .trimResults() .splitToList(fullName.substring(firstGenericOpenIndex + 1, lastGenericCloseIndex)); return getContainerTypeName( containerTypeName, genericParamNames.toArray(new String[genericParamNames.size()])); @@ -76,7 +77,7 @@ public TypeName getContainerTypeName(String containerFullName, String... element for (int i = 0; i < elementTypeNames.length; i++) { elementTypeNames[i] = getTypeName(elementFullNames[i]); } - String argPattern = Joiner.on(",").join(Collections.nCopies(elementTypeNames.length, "%i")); + String argPattern = Joiner.on(", ").join(Collections.nCopies(elementTypeNames.length, "%i")); String pattern = "%s<" + argPattern + ">"; return new TypeName( containerTypeName.getFullName(), diff --git a/src/test/java/com/google/api/codegen/testdata/csharp_gapic_client_library.baseline b/src/test/java/com/google/api/codegen/testdata/csharp_gapic_client_library.baseline index cd2a43d1b8..136ddb1681 100644 --- a/src/test/java/com/google/api/codegen/testdata/csharp_gapic_client_library.baseline +++ b/src/test/java/com/google/api/codegen/testdata/csharp_gapic_client_library.baseline @@ -3544,7 +3544,7 @@ namespace Google.Example.Library.V1 /// /// A Task containing the RPC response. /// - public virtual Task> GetBigBookAsync( + public virtual Task> GetBigBookAsync( BookName name, CallSettings callSettings = null) => GetBigBookAsync( new GetBookRequest @@ -3565,7 +3565,7 @@ namespace Google.Example.Library.V1 /// /// A Task containing the RPC response. /// - public virtual Task> GetBigBookAsync( + public virtual Task> GetBigBookAsync( BookName name, CancellationToken cancellationToken) => GetBigBookAsync( name, @@ -3583,7 +3583,7 @@ namespace Google.Example.Library.V1 /// /// The RPC response. /// - public virtual Operation GetBigBook( + public virtual Operation GetBigBook( BookName name, CallSettings callSettings = null) => GetBigBook( new GetBookRequest @@ -3604,7 +3604,7 @@ namespace Google.Example.Library.V1 /// /// A Task containing the RPC response. /// - public virtual Task> GetBigBookAsync( + public virtual Task> GetBigBookAsync( GetBookRequest request, CallSettings callSettings = null) { @@ -3617,9 +3617,9 @@ namespace Google.Example.Library.V1 /// The name of a previously invoked operation. Must not be null or empty. /// If not null, applies overrides to this RPC call. /// A task representing the result of polling the operation. - public virtual Task> PollOnceGetBigBookAsync( + public virtual Task> PollOnceGetBigBookAsync( string operationName, - CallSettings callSettings = null) => Operation.PollOnceFromNameAsync( + CallSettings callSettings = null) => Operation.PollOnceFromNameAsync( GaxPreconditions.CheckNotNullOrEmpty(operationName, nameof(operationName)), LongRunningOperationsClient, callSettings); @@ -3636,7 +3636,7 @@ namespace Google.Example.Library.V1 /// /// The RPC response. /// - public virtual Operation GetBigBook( + public virtual Operation GetBigBook( GetBookRequest request, CallSettings callSettings = null) { @@ -3649,9 +3649,9 @@ namespace Google.Example.Library.V1 /// The name of a previously invoked operation. Must not be null or empty. /// If not null, applies overrides to this RPC call. /// The result of polling the operation. - public virtual Operation PollOnceGetBigBook( + public virtual Operation PollOnceGetBigBook( string operationName, - CallSettings callSettings = null) => Operation.PollOnceFromName( + CallSettings callSettings = null) => Operation.PollOnceFromName( GaxPreconditions.CheckNotNullOrEmpty(operationName, nameof(operationName)), LongRunningOperationsClient, callSettings); @@ -3668,7 +3668,7 @@ namespace Google.Example.Library.V1 /// /// A Task containing the RPC response. /// - public virtual Task> GetBigNothingAsync( + public virtual Task> GetBigNothingAsync( BookName name, CallSettings callSettings = null) => GetBigNothingAsync( new GetBookRequest @@ -3689,7 +3689,7 @@ namespace Google.Example.Library.V1 /// /// A Task containing the RPC response. /// - public virtual Task> GetBigNothingAsync( + public virtual Task> GetBigNothingAsync( BookName name, CancellationToken cancellationToken) => GetBigNothingAsync( name, @@ -3707,7 +3707,7 @@ namespace Google.Example.Library.V1 /// /// The RPC response. /// - public virtual Operation GetBigNothing( + public virtual Operation GetBigNothing( BookName name, CallSettings callSettings = null) => GetBigNothing( new GetBookRequest @@ -3728,7 +3728,7 @@ namespace Google.Example.Library.V1 /// /// A Task containing the RPC response. /// - public virtual Task> GetBigNothingAsync( + public virtual Task> GetBigNothingAsync( GetBookRequest request, CallSettings callSettings = null) { @@ -3741,9 +3741,9 @@ namespace Google.Example.Library.V1 /// The name of a previously invoked operation. Must not be null or empty. /// If not null, applies overrides to this RPC call. /// A task representing the result of polling the operation. - public virtual Task> PollOnceGetBigNothingAsync( + public virtual Task> PollOnceGetBigNothingAsync( string operationName, - CallSettings callSettings = null) => Operation.PollOnceFromNameAsync( + CallSettings callSettings = null) => Operation.PollOnceFromNameAsync( GaxPreconditions.CheckNotNullOrEmpty(operationName, nameof(operationName)), LongRunningOperationsClient, callSettings); @@ -3760,7 +3760,7 @@ namespace Google.Example.Library.V1 /// /// The RPC response. /// - public virtual Operation GetBigNothing( + public virtual Operation GetBigNothing( GetBookRequest request, CallSettings callSettings = null) { @@ -3773,9 +3773,9 @@ namespace Google.Example.Library.V1 /// The name of a previously invoked operation. Must not be null or empty. /// If not null, applies overrides to this RPC call. /// The result of polling the operation. - public virtual Operation PollOnceGetBigNothing( + public virtual Operation PollOnceGetBigNothing( string operationName, - CallSettings callSettings = null) => Operation.PollOnceFromName( + CallSettings callSettings = null) => Operation.PollOnceFromName( GaxPreconditions.CheckNotNullOrEmpty(operationName, nameof(operationName)), LongRunningOperationsClient, callSettings); @@ -5559,7 +5559,7 @@ namespace Google.Example.Library.V1 Modify_DiscussBookRequestCallSettings(ref callSettings); BidirectionalStreamingSettings effectiveStreamingSettings = streamingSettings ?? _callDiscussBook.StreamingSettings; - AsyncDuplexStreamingCall call = + AsyncDuplexStreamingCall call = _callDiscussBook.Call(callSettings); BufferedClientStreamWriter writeBuffer = new BufferedClientStreamWriter( @@ -5581,7 +5581,7 @@ namespace Google.Example.Library.V1 /// instance associated with this streaming call. public DiscussBookStreamImpl( LibraryServiceClientImpl service, - AsyncDuplexStreamingCall call, + AsyncDuplexStreamingCall call, BufferedClientStreamWriter writeBuffer) { _service = service; @@ -5599,7 +5599,7 @@ namespace Google.Example.Library.V1 } /// - public override AsyncDuplexStreamingCall GrpcCall { get; } + public override AsyncDuplexStreamingCall GrpcCall { get; } /// public override Task TryWriteAsync(DiscussBookRequest message) => @@ -5762,12 +5762,12 @@ namespace Google.Example.Library.V1 /// /// A Task containing the RPC response. /// - public override async Task> GetBigBookAsync( + public override async Task> GetBigBookAsync( GetBookRequest request, CallSettings callSettings = null) { Modify_GetBookRequest(ref request, ref callSettings); - return new Operation( + return new Operation( await _callGetBigBook.Async(request, callSettings).ConfigureAwait(false), LongRunningOperationsClient); } @@ -5783,12 +5783,12 @@ namespace Google.Example.Library.V1 /// /// The RPC response. /// - public override Operation GetBigBook( + public override Operation GetBigBook( GetBookRequest request, CallSettings callSettings = null) { Modify_GetBookRequest(ref request, ref callSettings); - return new Operation( + return new Operation( _callGetBigBook.Sync(request, callSettings), LongRunningOperationsClient); } @@ -5804,12 +5804,12 @@ namespace Google.Example.Library.V1 /// /// A Task containing the RPC response. /// - public override async Task> GetBigNothingAsync( + public override async Task> GetBigNothingAsync( GetBookRequest request, CallSettings callSettings = null) { Modify_GetBookRequest(ref request, ref callSettings); - return new Operation( + return new Operation( await _callGetBigNothing.Async(request, callSettings).ConfigureAwait(false), LongRunningOperationsClient); } @@ -5825,12 +5825,12 @@ namespace Google.Example.Library.V1 /// /// The RPC response. /// - public override Operation GetBigNothing( + public override Operation GetBigNothing( GetBookRequest request, CallSettings callSettings = null) { Modify_GetBookRequest(ref request, ref callSettings); - return new Operation( + return new Operation( _callGetBigNothing.Sync(request, callSettings), LongRunningOperationsClient); } diff --git a/src/test/java/com/google/api/codegen/testdata/csharp_gapic_snippets_library.baseline b/src/test/java/com/google/api/codegen/testdata/csharp_gapic_snippets_library.baseline index e7899457fd..1c10e7cfe7 100644 --- a/src/test/java/com/google/api/codegen/testdata/csharp_gapic_snippets_library.baseline +++ b/src/test/java/com/google/api/codegen/testdata/csharp_gapic_snippets_library.baseline @@ -209,7 +209,7 @@ namespace Google.Example.Library.V1.Snippets // Create client LibraryServiceClient libraryServiceClient = await LibraryServiceClient.CreateAsync(); // Make the request - PagedAsyncEnumerable response = + PagedAsyncEnumerable response = libraryServiceClient.ListShelvesAsync(); // Iterate over all response items, lazily performing RPCs as required @@ -250,7 +250,7 @@ namespace Google.Example.Library.V1.Snippets // Create client LibraryServiceClient libraryServiceClient = LibraryServiceClient.Create(); // Make the request - PagedEnumerable response = + PagedEnumerable response = libraryServiceClient.ListShelves(); // Iterate over all response items, lazily performing RPCs as required @@ -293,7 +293,7 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) ListShelvesRequest request = new ListShelvesRequest(); // Make the request - PagedAsyncEnumerable response = + PagedAsyncEnumerable response = libraryServiceClient.ListShelvesAsync(request); // Iterate over all response items, lazily performing RPCs as required @@ -336,7 +336,7 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) ListShelvesRequest request = new ListShelvesRequest(); // Make the request - PagedEnumerable response = + PagedEnumerable response = libraryServiceClient.ListShelves(request); // Iterate over all response items, lazily performing RPCs as required @@ -685,7 +685,7 @@ namespace Google.Example.Library.V1.Snippets ShelfName name = new ShelfName("[SHELF_ID]"); string filter = ""; // Make the request - PagedAsyncEnumerable response = + PagedAsyncEnumerable response = libraryServiceClient.ListBooksAsync(name, filter); // Iterate over all response items, lazily performing RPCs as required @@ -729,7 +729,7 @@ namespace Google.Example.Library.V1.Snippets ShelfName name = new ShelfName("[SHELF_ID]"); string filter = ""; // Make the request - PagedEnumerable response = + PagedEnumerable response = libraryServiceClient.ListBooks(name, filter); // Iterate over all response items, lazily performing RPCs as required @@ -775,7 +775,7 @@ namespace Google.Example.Library.V1.Snippets ShelfName = new ShelfName("[SHELF_ID]"), }; // Make the request - PagedAsyncEnumerable response = + PagedAsyncEnumerable response = libraryServiceClient.ListBooksAsync(request); // Iterate over all response items, lazily performing RPCs as required @@ -821,7 +821,7 @@ namespace Google.Example.Library.V1.Snippets ShelfName = new ShelfName("[SHELF_ID]"), }; // Make the request - PagedEnumerable response = + PagedEnumerable response = libraryServiceClient.ListBooks(request); // Iterate over all response items, lazily performing RPCs as required @@ -1066,7 +1066,7 @@ namespace Google.Example.Library.V1.Snippets // Create client LibraryServiceClient libraryServiceClient = await LibraryServiceClient.CreateAsync(); // Make the request - PagedAsyncEnumerable response = + PagedAsyncEnumerable response = libraryServiceClient.ListStringsAsync(); // Iterate over all response items, lazily performing RPCs as required @@ -1107,7 +1107,7 @@ namespace Google.Example.Library.V1.Snippets // Create client LibraryServiceClient libraryServiceClient = LibraryServiceClient.Create(); // Make the request - PagedEnumerable response = + PagedEnumerable response = libraryServiceClient.ListStrings(); // Iterate over all response items, lazily performing RPCs as required @@ -1150,7 +1150,7 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) IResourceName name = new ShelfName("[SHELF_ID]"); // Make the request - PagedAsyncEnumerable response = + PagedAsyncEnumerable response = libraryServiceClient.ListStringsAsync(name); // Iterate over all response items, lazily performing RPCs as required @@ -1193,7 +1193,7 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) IResourceName name = new ShelfName("[SHELF_ID]"); // Make the request - PagedEnumerable response = + PagedEnumerable response = libraryServiceClient.ListStrings(name); // Iterate over all response items, lazily performing RPCs as required @@ -1236,7 +1236,7 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) ListStringsRequest request = new ListStringsRequest(); // Make the request - PagedAsyncEnumerable response = + PagedAsyncEnumerable response = libraryServiceClient.ListStringsAsync(request); // Iterate over all response items, lazily performing RPCs as required @@ -1279,7 +1279,7 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) ListStringsRequest request = new ListStringsRequest(); // Make the request - PagedEnumerable response = + PagedEnumerable response = libraryServiceClient.ListStrings(request); // Iterate over all response items, lazily performing RPCs as required @@ -1644,7 +1644,7 @@ namespace Google.Example.Library.V1.Snippets }; IEnumerable shelves = new List(); // Make the request - PagedAsyncEnumerable response = + PagedAsyncEnumerable response = libraryServiceClient.FindRelatedBooksAsync(names, shelves); // Iterate over all response items, lazily performing RPCs as required @@ -1691,7 +1691,7 @@ namespace Google.Example.Library.V1.Snippets }; IEnumerable shelves = new List(); // Make the request - PagedEnumerable response = + PagedEnumerable response = libraryServiceClient.FindRelatedBooks(names, shelves); // Iterate over all response items, lazily performing RPCs as required @@ -1740,7 +1740,7 @@ namespace Google.Example.Library.V1.Snippets ShelvesAsShelfNames = { }, }; // Make the request - PagedAsyncEnumerable response = + PagedAsyncEnumerable response = libraryServiceClient.FindRelatedBooksAsync(request); // Iterate over all response items, lazily performing RPCs as required @@ -1789,7 +1789,7 @@ namespace Google.Example.Library.V1.Snippets ShelvesAsShelfNames = { }, }; // Make the request - PagedEnumerable response = + PagedEnumerable response = libraryServiceClient.FindRelatedBooks(request); // Iterate over all response items, lazily performing RPCs as required @@ -1951,11 +1951,11 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) BookName name = new BookName("[SHELF_ID]", "[BOOK_ID]"); // Make the request - Operation response = + Operation response = await libraryServiceClient.GetBigBookAsync(name); // Poll until the returned long-running operation is complete - Operation completedResponse = + Operation completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Book result = completedResponse.Result; @@ -1963,7 +1963,7 @@ namespace Google.Example.Library.V1.Snippets // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name - Operation retrievedResponse = + Operation retrievedResponse = await libraryServiceClient.PollOnceGetBigBookAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) @@ -1982,11 +1982,11 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) BookName name = new BookName("[SHELF_ID]", "[BOOK_ID]"); // Make the request - Operation response = + Operation response = libraryServiceClient.GetBigBook(name); // Poll until the returned long-running operation is complete - Operation completedResponse = + Operation completedResponse = response.PollUntilCompleted(); // Retrieve the operation result Book result = completedResponse.Result; @@ -1994,7 +1994,7 @@ namespace Google.Example.Library.V1.Snippets // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name - Operation retrievedResponse = + Operation retrievedResponse = libraryServiceClient.PollOnceGetBigBook(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) @@ -2016,11 +2016,11 @@ namespace Google.Example.Library.V1.Snippets BookName = new BookName("[SHELF_ID]", "[BOOK_ID]"), }; // Make the request - Operation response = + Operation response = await libraryServiceClient.GetBigBookAsync(request); // Poll until the returned long-running operation is complete - Operation completedResponse = + Operation completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Book result = completedResponse.Result; @@ -2028,7 +2028,7 @@ namespace Google.Example.Library.V1.Snippets // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name - Operation retrievedResponse = + Operation retrievedResponse = await libraryServiceClient.PollOnceGetBigBookAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) @@ -2050,11 +2050,11 @@ namespace Google.Example.Library.V1.Snippets BookName = new BookName("[SHELF_ID]", "[BOOK_ID]"), }; // Make the request - Operation response = + Operation response = libraryServiceClient.GetBigBook(request); // Poll until the returned long-running operation is complete - Operation completedResponse = + Operation completedResponse = response.PollUntilCompleted(); // Retrieve the operation result Book result = completedResponse.Result; @@ -2062,7 +2062,7 @@ namespace Google.Example.Library.V1.Snippets // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name - Operation retrievedResponse = + Operation retrievedResponse = libraryServiceClient.PollOnceGetBigBook(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) @@ -2082,18 +2082,18 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) BookName name = new BookName("[SHELF_ID]", "[BOOK_ID]"); // Make the request - Operation response = + Operation response = await libraryServiceClient.GetBigNothingAsync(name); // Poll until the returned long-running operation is complete - Operation completedResponse = + Operation completedResponse = await response.PollUntilCompletedAsync(); // The long-running operation is now complete. // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name - Operation retrievedResponse = + Operation retrievedResponse = await libraryServiceClient.PollOnceGetBigNothingAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) @@ -2111,18 +2111,18 @@ namespace Google.Example.Library.V1.Snippets // Initialize request argument(s) BookName name = new BookName("[SHELF_ID]", "[BOOK_ID]"); // Make the request - Operation response = + Operation response = libraryServiceClient.GetBigNothing(name); // Poll until the returned long-running operation is complete - Operation completedResponse = + Operation completedResponse = response.PollUntilCompleted(); // The long-running operation is now complete. // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name - Operation retrievedResponse = + Operation retrievedResponse = libraryServiceClient.PollOnceGetBigNothing(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) @@ -2143,18 +2143,18 @@ namespace Google.Example.Library.V1.Snippets BookName = new BookName("[SHELF_ID]", "[BOOK_ID]"), }; // Make the request - Operation response = + Operation response = await libraryServiceClient.GetBigNothingAsync(request); // Poll until the returned long-running operation is complete - Operation completedResponse = + Operation completedResponse = await response.PollUntilCompletedAsync(); // The long-running operation is now complete. // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name - Operation retrievedResponse = + Operation retrievedResponse = await libraryServiceClient.PollOnceGetBigNothingAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) @@ -2175,18 +2175,18 @@ namespace Google.Example.Library.V1.Snippets BookName = new BookName("[SHELF_ID]", "[BOOK_ID]"), }; // Make the request - Operation response = + Operation response = libraryServiceClient.GetBigNothing(request); // Poll until the returned long-running operation is complete - Operation completedResponse = + Operation completedResponse = response.PollUntilCompleted(); // The long-running operation is now complete. // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name - Operation retrievedResponse = + Operation retrievedResponse = libraryServiceClient.PollOnceGetBigNothing(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted)