@@ -102,14 +102,11 @@ public void AnalyzeInvocation(CodeElement sourceElement, InvocationExpressionSyn
102102 }
103103 }
104104
105- public void AnalyzeAssignment ( CodeElement sourceElement , AssignmentExpressionSyntax assignmentExpression ,
105+ public void AnalyzeEventRegistrationAssignment ( CodeElement sourceElement , AssignmentExpressionSyntax assignmentExpression ,
106106 SemanticModel semanticModel )
107107 {
108- // Analyze the left side of the assignment (target)
109- AnalyzeExpressionForPropertyAccess ( sourceElement , assignmentExpression . Left , semanticModel ) ;
110-
111- // Analyze the right side of the assignment (value)
112- AnalyzeExpressionForPropertyAccess ( sourceElement , assignmentExpression . Right , semanticModel ) ;
108+ // Note: Property/field access on left and right sides is handled by the walker's normal traversal
109+ // (VisitIdentifierName and VisitMemberAccessExpression). We only need to handle event registration/unregistration here.
113110
114111 var isRegistration = assignmentExpression . IsKind ( SyntaxKind . AddAssignmentExpression ) ;
115112 var isUnregistration = assignmentExpression . IsKind ( SyntaxKind . SubtractAssignmentExpression ) ;
@@ -179,7 +176,7 @@ public void AnalyzeTypeSyntax(CodeElement sourceElement, SemanticModel semanticM
179176 /// <inheritdoc cref="ISyntaxNodeHandler.AnalyzeIdentifier" />
180177 /// </summary>
181178 public void AnalyzeIdentifier ( CodeElement sourceElement , IdentifierNameSyntax identifierSyntax ,
182- SemanticModel semanticModel )
179+ SemanticModel semanticModel , RelationshipType propertyAccessType = RelationshipType . Calls )
183180 {
184181 var symbolInfo = semanticModel . GetSymbolInfo ( identifierSyntax ) ;
185182 var symbol = symbolInfo . Symbol ;
@@ -190,14 +187,14 @@ public void AnalyzeIdentifier(CodeElement sourceElement, IdentifierNameSyntax id
190187 if ( symbol is IPropertySymbol propertySymbol )
191188 {
192189 var location = identifierSyntax . GetSyntaxLocation ( ) ;
193- AddPropertyCallRelationship ( sourceElement , propertySymbol , [ location ] , RelationshipAttribute . None ) ;
190+ AddRelationshipWithFallbackToContainingType ( sourceElement , propertySymbol , propertyAccessType , [ location ] , RelationshipAttribute . None ) ;
194191 }
195192 else if ( symbol is IFieldSymbol fieldSymbol )
196193 {
197194 var location = identifierSyntax . GetSyntaxLocation ( ) ;
198195 AddRelationshipWithFallbackToContainingType ( sourceElement , fieldSymbol , RelationshipType . Uses , [ location ] , RelationshipAttribute . None ) ;
199196 }
200- else if ( symbol is IEventSymbol eventSymbol )
197+ else if ( symbol is IEventSymbol eventSymbol )
201198 {
202199 var location = identifierSyntax . GetSyntaxLocation ( ) ;
203200 AddEventUsageRelationship ( sourceElement , eventSymbol , location ) ;
@@ -208,7 +205,7 @@ public void AnalyzeIdentifier(CodeElement sourceElement, IdentifierNameSyntax id
208205 /// <inheritdoc cref="ISyntaxNodeHandler.AnalyzeMemberAccess" />
209206 /// </summary>
210207 public void AnalyzeMemberAccess ( CodeElement sourceElement , MemberAccessExpressionSyntax memberAccessSyntax ,
211- SemanticModel semanticModel )
208+ SemanticModel semanticModel , RelationshipType propertyAccessType = RelationshipType . Calls )
212209 {
213210 // Analyze the member being accessed (the right side of the dot)
214211 var symbolInfo = semanticModel . GetSymbolInfo ( memberAccessSyntax ) ;
@@ -217,7 +214,7 @@ public void AnalyzeMemberAccess(CodeElement sourceElement, MemberAccessExpressio
217214 if ( symbol is IPropertySymbol propertySymbol )
218215 {
219216 var location = memberAccessSyntax . GetSyntaxLocation ( ) ;
220- AddPropertyCallRelationship ( sourceElement , propertySymbol , [ location ] , RelationshipAttribute . None ) ;
217+ AddRelationshipWithFallbackToContainingType ( sourceElement , propertySymbol , propertyAccessType , [ location ] , RelationshipAttribute . None ) ;
221218 }
222219 else if ( symbol is IFieldSymbol fieldSymbol )
223220 {
@@ -814,21 +811,6 @@ private void AddEventHandlerRelationship(IMethodSymbol handlerMethod, IEventSymb
814811 // $"Unable to add 'Handles' relationship: Handler {handlerMethod.Name} or Event {eventSymbol.Name} not found in codebase.");
815812 }
816813
817- private void AnalyzeExpressionForPropertyAccess ( CodeElement sourceElement , ExpressionSyntax expression ,
818- SemanticModel semanticModel )
819- {
820- switch ( expression )
821- {
822- case IdentifierNameSyntax identifierSyntax :
823- AnalyzeIdentifier ( sourceElement , identifierSyntax , semanticModel ) ;
824- break ;
825- case MemberAccessExpressionSyntax memberAccessSyntax :
826- AnalyzeMemberAccess ( sourceElement , memberAccessSyntax , semanticModel ) ;
827- break ;
828- // Add more cases if needed for other types of expressions
829- }
830- }
831-
832814 private void AddCallsRelationship ( CodeElement sourceElement , IMethodSymbol methodSymbol , SourceLocation location , RelationshipAttribute attributes )
833815 {
834816 //Debug.Assert(FindCodeElement(methodSymbol)!= null);
@@ -1006,15 +988,6 @@ private void AddNamedTypeRelationship(CodeElement sourceElement, INamedTypeSymbo
1006988 return _externalCodeElementCache . TryGetOrCreateExternalCodeElement ( symbol ) ;
1007989 }
1008990
1009- /// <summary>
1010- /// Calling a property is treated like calling a method.
1011- /// </summary>
1012- private void AddPropertyCallRelationship ( CodeElement sourceElement , IPropertySymbol propertySymbol ,
1013- List < SourceLocation > locations , RelationshipAttribute attributes )
1014- {
1015- AddRelationshipWithFallbackToContainingType ( sourceElement , propertySymbol , RelationshipType . Calls , locations , attributes ) ;
1016- }
1017-
1018991 /// <summary>
1019992 /// Adds a relationship to a symbol, with configurable fallback behavior for external symbols.
1020993 /// Tries in order: direct symbol → normalized symbol → containing type → external element
0 commit comments