Skip to content

Commit 1f2d63c

Browse files
committed
Remove AttributeInfo array builder use
1 parent 7f85c37 commit 1f2d63c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/Models/AttributeInfo.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,15 @@ public static AttributeInfo From(AttributeData attributeData)
3939
.ToImmutableArray();
4040

4141
// Get the named arguments
42-
ImmutableArray<(string, TypedConstantInfo)>.Builder namedArguments = ImmutableArray.CreateBuilder<(string, TypedConstantInfo)>();
43-
44-
foreach (KeyValuePair<string, TypedConstant> arg in attributeData.NamedArguments)
45-
{
46-
namedArguments.Add((arg.Key, TypedConstantInfo.From(arg.Value)));
47-
}
42+
ImmutableArray<(string, TypedConstantInfo)> namedArguments =
43+
attributeData.NamedArguments
44+
.Select(static arg => (arg.Key, TypedConstantInfo.From(arg.Value)))
45+
.ToImmutableArray();
4846

4947
return new(
5048
typeName,
5149
constructorArguments,
52-
namedArguments.ToImmutable());
50+
namedArguments);
5351
}
5452

5553
/// <summary>

0 commit comments

Comments
 (0)