Skip to content

Commit bfd21a2

Browse files
committed
Removed unnecessary ConstructUnboundGenericType() calls
1 parent e5af579 commit bfd21a2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Microsoft.Toolkit.Mvvm.SourceGenerators/Messaging/IMessengerRegisterAllGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void Initialize(GeneratorInitializationContext context)
3232
public void Execute(GeneratorExecutionContext context)
3333
{
3434
// Get the symbol for the IRecipient<T> interface type
35-
INamedTypeSymbol iRecipientSymbol = context.Compilation.GetTypeByMetadataName("Microsoft.Toolkit.Mvvm.Messaging.IRecipient`1")!.ConstructUnboundGenericType();
35+
INamedTypeSymbol iRecipientSymbol = context.Compilation.GetTypeByMetadataName("Microsoft.Toolkit.Mvvm.Messaging.IRecipient`1")!;
3636

3737
// Find all the class symbols with at least one IRecipient<T> usage, that are not generic
3838
IEnumerable<INamedTypeSymbol> classSymbols =
@@ -44,7 +44,7 @@ from classDeclaration in syntaxTree.GetRoot().DescendantNodes().OfType<ClassDecl
4444
classSymbol is { IsGenericType: false } &&
4545
classSymbol.AllInterfaces.Any(i =>
4646
i.IsGenericType &&
47-
SymbolEqualityComparer.Default.Equals(i.ConstructUnboundGenericType(), iRecipientSymbol))
47+
SymbolEqualityComparer.Default.Equals(i.ConstructedFrom, iRecipientSymbol))
4848
select classSymbol;
4949

5050
// Prepare the attributes to add to the first class declaration
@@ -172,7 +172,7 @@ private static IEnumerable<StatementSyntax> EnumerateRegistrationStatements(INam
172172
foreach (var interfaceSymbol in classSymbol.AllInterfaces)
173173
{
174174
if (!interfaceSymbol.IsGenericType ||
175-
!SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructUnboundGenericType(), iRecipientSymbol))
175+
!SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructedFrom, iRecipientSymbol))
176176
{
177177
continue;
178178
}
@@ -207,7 +207,7 @@ private static IEnumerable<StatementSyntax> EnumerateRegistrationStatementsWithT
207207
foreach (var interfaceSymbol in classSymbol.AllInterfaces)
208208
{
209209
if (!interfaceSymbol.IsGenericType ||
210-
!SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructUnboundGenericType(), iRecipientSymbol))
210+
!SymbolEqualityComparer.Default.Equals(interfaceSymbol.ConstructedFrom, iRecipientSymbol))
211211
{
212212
continue;
213213
}

0 commit comments

Comments
 (0)