Skip to content

Commit

Permalink
Removed custom concat implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
  • Loading branch information
m3nax committed Aug 9, 2024
1 parent e002cee commit a3a3e68
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 32 deletions.
6 changes: 3 additions & 3 deletions src/Dapr.Actors.Generators/ActorClientGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ static void GenerateActorClientCode(SourceProductionContext context, ActorClient
.Select(member => GenerateMethodImplementation(member, actorMethodAttributeSymbol, cancellationTokenSymbol));

var actorMembers = new List<MemberDeclarationSyntax>()
.Concat(actorProxyFieldDeclaration)
.Concat(actorCtor)
.Append(actorProxyFieldDeclaration)
.Append(actorCtor)
.Concat(actorMethods);

var actorClientClassModifiers = new List<SyntaxKind>()
.Concat(SyntaxFactoryHelpers.GetSyntaxKinds(descriptor.Accessibility))
.Concat(SyntaxKind.SealedKeyword)
.Append(SyntaxKind.SealedKeyword)
.Select(sk => SyntaxFactory.Token(sk));

var actorClientClassDeclaration = SyntaxFactory.ClassDeclaration(descriptor.ClientTypeName)
Expand Down
12 changes: 0 additions & 12 deletions src/Dapr.Actors.Generators/Extensions/IEnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,5 @@ internal static int IndexOf<T>(this IEnumerable<T> source, Func<T, bool> predica

return -1;
}

/// <summary>
/// Concatenates the specified item to the end of the sequence.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="source"></param>
/// <param name="item"></param>
/// <returns></returns>
internal static IEnumerable<T> Concat<T>(this IEnumerable<T> source, T item)
{
return source.Concat(new[] { item });
}
}
}
5 changes: 2 additions & 3 deletions src/Dapr.Actors.Generators/Helpers/SyntaxFactoryHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Dapr.Actors.Generators.Extensions;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;

Expand Down Expand Up @@ -99,7 +98,7 @@ public static InvocationExpressionSyntax ActorProxyInvokeMethodAsync(
// Define the arguments to pass to the actor proxy method invocation.
var proxyInvocationArguments = new List<ArgumentSyntax>()
// 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))));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit a3a3e68

Please sign in to comment.