Skip to content

Commit 90b91f8

Browse files
committed
Improve boolean type checks
1 parent 56e218f commit 90b91f8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

CommunityToolkit.Mvvm.SourceGenerators/Input/RelayCommandGenerator.Execute.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ private static bool TryGetCanExecuteExpressionFromSymbol(
785785
if (canExecuteSymbol is IMethodSymbol canExecuteMethodSymbol)
786786
{
787787
// The return type must always be a bool
788-
if (!canExecuteMethodSymbol.ReturnType.HasFullyQualifiedMetadataName("System.Boolean"))
788+
if (canExecuteMethodSymbol.ReturnType is not { SpecialType: SpecialType.System_Boolean })
789789
{
790790
goto Failure;
791791
}
@@ -820,7 +820,7 @@ private static bool TryGetCanExecuteExpressionFromSymbol(
820820
else if (canExecuteSymbol is IPropertySymbol { GetMethod: not null } canExecutePropertySymbol)
821821
{
822822
// The property type must always be a bool
823-
if (!canExecutePropertySymbol.Type.HasFullyQualifiedMetadataName("System.Boolean"))
823+
if (canExecutePropertySymbol.Type is not { SpecialType: SpecialType.System_Boolean })
824824
{
825825
goto Failure;
826826
}
@@ -860,8 +860,7 @@ private static bool TryGetCanExecuteMemberFromGeneratedProperty(
860860
foreach (ISymbol memberSymbol in containingType.GetAllMembers())
861861
{
862862
// Only look for instance fields of bool type
863-
if (memberSymbol is not IFieldSymbol { IsStatic: false } fieldSymbol ||
864-
!fieldSymbol.Type.HasFullyQualifiedMetadataName("System.Boolean"))
863+
if (memberSymbol is not IFieldSymbol { IsStatic: false, Type.SpecialType: SpecialType.System_Boolean } fieldSymbol)
865864
{
866865
continue;
867866
}

0 commit comments

Comments
 (0)