@@ -178,32 +178,28 @@ public bool Equals(ClassDeclarationSyntax? x, ClassDeclarationSyntax? y)
178178
179179 string xNamespace = GetNamespace ( x ) ;
180180 string yNamespace = GetNamespace ( y ) ;
181- string xParentClassName = GetParentClassName ( x ) ;
182- string yParentClassName = GetParentClassName ( y ) ;
183- return x . Identifier . ValueText == y . Identifier . ValueText && xNamespace == yNamespace && xParentClassName == yParentClassName ;
181+ return x . Identifier . ValueText == y . Identifier . ValueText && xNamespace == yNamespace ;
184182 }
185183
186184 public int GetHashCode ( ClassDeclarationSyntax obj )
187185 {
188186 if ( ReferenceEquals ( obj , null ) ) return 0 ;
189187
190- return $ "{ GetNamespace ( obj ) } .{ GetParentClassName ( obj ) } .{ obj . Identifier . ValueText } ". GetHashCode ( ) ;
188+ int hashClassName = obj . Identifier . ValueText . GetHashCode ( ) ;
189+ int hashNamespace = GetNamespace ( obj ) . GetHashCode ( ) ;
190+
191+ return hashClassName ^ hashNamespace ;
191192 }
192193
193194 private static string GetNamespace ( ClassDeclarationSyntax classDeclaration )
194195 {
195196 SyntaxNode ? namespaceDeclaration = classDeclaration . Parent ;
196- while ( namespaceDeclaration is { } nd && nd is not BaseNamespaceDeclarationSyntax )
197+ while ( namespaceDeclaration != null && namespaceDeclaration is not NamespaceDeclarationSyntax )
197198 {
198199 namespaceDeclaration = namespaceDeclaration . Parent ;
199200 }
200201
201- return namespaceDeclaration switch
202- {
203- NamespaceDeclarationSyntax namespaceSyntax => namespaceSyntax . Name . ToString ( ) ,
204- FileScopedNamespaceDeclarationSyntax fileScopedNamespaceSyntax => fileScopedNamespaceSyntax . Name . ToString ( ) ,
205- _ => string . Empty
206- } ;
202+ return namespaceDeclaration is NamespaceDeclarationSyntax namespaceSyntax ? namespaceSyntax . Name . ToString ( ) : string . Empty ;
207203 }
208204 }
209205 }
0 commit comments