File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 33// See the LICENSE file in the project root for more information.
44
55using System . Diagnostics . CodeAnalysis ;
6- using System . Linq ;
76using Microsoft . CodeAnalysis ;
87
98namespace CommunityToolkit . Mvvm . SourceGenerators . Extensions ;
@@ -26,8 +25,16 @@ internal static class SymbolInfoExtensions
2625 /// </remarks>
2726 public static bool TryGetAttributeTypeSymbol ( this SymbolInfo symbolInfo , [ NotNullWhen ( true ) ] out INamedTypeSymbol ? typeSymbol )
2827 {
29- if ( ( symbolInfo . Symbol ?? symbolInfo . CandidateSymbols . SingleOrDefault ( ) ) is not ISymbol attributeSymbol ||
30- ( attributeSymbol as INamedTypeSymbol ?? attributeSymbol . ContainingType ) is not INamedTypeSymbol resultingSymbol )
28+ ISymbol ? attributeSymbol = symbolInfo . Symbol ;
29+
30+ // If no symbol is selected and there is a single candidate symbol, use that
31+ if ( attributeSymbol is null && symbolInfo . CandidateSymbols is [ ISymbol candidateSymbol ] )
32+ {
33+ attributeSymbol = candidateSymbol ;
34+ }
35+
36+ // Extract the symbol from either the current one or the containing type
37+ if ( ( attributeSymbol as INamedTypeSymbol ?? attributeSymbol ? . ContainingType ) is not INamedTypeSymbol resultingSymbol )
3138 {
3239 typeSymbol = null ;
3340
You can’t perform that action at this time.
0 commit comments