From a3a3e68286e5ab8d0035dc9b9d0c78f9e06894d6 Mon Sep 17 00:00:00 2001 From: Manuel Menegazzo <65919883+m3nax@users.noreply.github.com.> Date: Thu, 8 Aug 2024 13:41:11 +0200 Subject: [PATCH] Removed custom concat implementation Signed-off-by: Manuel Menegazzo --- src/Dapr.Actors.Generators/ActorClientGenerator.cs | 6 +++--- .../Extensions/IEnumerableExtensions.cs | 12 ------------ .../Helpers/SyntaxFactoryHelpers.cs | 5 ++--- .../Extensions/IEnumerableExtensionsTests.cs | 14 -------------- 4 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/Dapr.Actors.Generators/ActorClientGenerator.cs b/src/Dapr.Actors.Generators/ActorClientGenerator.cs index b4cf4f098..50c022a9f 100644 --- a/src/Dapr.Actors.Generators/ActorClientGenerator.cs +++ b/src/Dapr.Actors.Generators/ActorClientGenerator.cs @@ -153,13 +153,13 @@ static void GenerateActorClientCode(SourceProductionContext context, ActorClient .Select(member => GenerateMethodImplementation(member, actorMethodAttributeSymbol, cancellationTokenSymbol)); var actorMembers = new List() - .Concat(actorProxyFieldDeclaration) - .Concat(actorCtor) + .Append(actorProxyFieldDeclaration) + .Append(actorCtor) .Concat(actorMethods); var actorClientClassModifiers = new List() .Concat(SyntaxFactoryHelpers.GetSyntaxKinds(descriptor.Accessibility)) - .Concat(SyntaxKind.SealedKeyword) + .Append(SyntaxKind.SealedKeyword) .Select(sk => SyntaxFactory.Token(sk)); var actorClientClassDeclaration = SyntaxFactory.ClassDeclaration(descriptor.ClientTypeName) diff --git a/src/Dapr.Actors.Generators/Extensions/IEnumerableExtensions.cs b/src/Dapr.Actors.Generators/Extensions/IEnumerableExtensions.cs index 844a088fc..e9c093f96 100644 --- a/src/Dapr.Actors.Generators/Extensions/IEnumerableExtensions.cs +++ b/src/Dapr.Actors.Generators/Extensions/IEnumerableExtensions.cs @@ -30,17 +30,5 @@ internal static int IndexOf(this IEnumerable source, Func predica return -1; } - - /// - /// Concatenates the specified item to the end of the sequence. - /// - /// - /// - /// - /// - internal static IEnumerable Concat(this IEnumerable source, T item) - { - return source.Concat(new[] { item }); - } } } diff --git a/src/Dapr.Actors.Generators/Helpers/SyntaxFactoryHelpers.cs b/src/Dapr.Actors.Generators/Helpers/SyntaxFactoryHelpers.cs index a1d2a23fd..34f0604fb 100644 --- a/src/Dapr.Actors.Generators/Helpers/SyntaxFactoryHelpers.cs +++ b/src/Dapr.Actors.Generators/Helpers/SyntaxFactoryHelpers.cs @@ -1,5 +1,4 @@ -using Dapr.Actors.Generators.Extensions; -using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -99,7 +98,7 @@ public static InvocationExpressionSyntax ActorProxyInvokeMethodAsync( // Define the arguments to pass to the actor proxy method invocation. var proxyInvocationArguments = new List() // Name of remote method to invoke. - .Concat(SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(remoteMethodName)))) + .Append(SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(remoteMethodName)))) // Actor method arguments, including the CancellationToken if it exists. .Concat(remoteMethodParameters.Select(p => SyntaxFactory.Argument(SyntaxFactory.IdentifierName(p.Name)))); diff --git a/test/Dapr.Actors.Generators.Test/Extensions/IEnumerableExtensionsTests.cs b/test/Dapr.Actors.Generators.Test/Extensions/IEnumerableExtensionsTests.cs index d753eb000..97dbcfe1e 100644 --- a/test/Dapr.Actors.Generators.Test/Extensions/IEnumerableExtensionsTests.cs +++ b/test/Dapr.Actors.Generators.Test/Extensions/IEnumerableExtensionsTests.cs @@ -48,19 +48,5 @@ public void IndexOf_WhenItemExists_ReturnsIndexOfItem(int[] source, int item, in // Assert Assert.Equal(expected, index); } - - [Fact] - public void Concat_WhenItemIsNotNull_ReturnsConcatenatedSequence() - { - // Arrange - var source = new[] { "a", "b", "c" }; - string item = "d"; - - // Act - var result = source.Concat(item); - - // Assert - Assert.Equal(new[] { "a", "b", "c", "d" }, result); - } } }