public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node) { if (node.Initializer != null) { var symbol = GetDeclaredSymbol(node); UsedSymbols.Add(symbol); StorePropertyAccess((IPropertySymbol)symbol, AccessorAccess.Set); } base.VisitPropertyDeclaration(node); }
public override void VisitIdentifierName(IdentifierNameSyntax node) { var symbols = GetSymbols(node, IsKnownIdentifier).ToList(); UsedSymbols.UnionWith(symbols); TryStorePropertyAccess(node, symbols); base.VisitIdentifierName(node); }
public override void VisitElementAccessExpression(ElementAccessExpressionSyntax node) { var symbols = GetSymbols(node, x => true).ToList(); UsedSymbols.UnionWith(symbols); TryStorePropertyAccess(node, symbols); base.VisitElementAccessExpression(node); }
public override void VisitConstructorDeclaration(ConstructorDeclarationSyntax node) { // We are visiting a ctor with no initializer and the compiler will automatically // call the default constructor of the type if declared, or the base type if the // current type does not declare a default constructor. if (node.Initializer == null) { var constructor = (IMethodSymbol)GetDeclaredSymbol(node); var implicitlyCalledConstructor = GetImplicitlyCalledConstructor(constructor); if (implicitlyCalledConstructor != null) { UsedSymbols.Add(implicitlyCalledConstructor); } } base.VisitConstructorDeclaration(node); }
// TupleExpression "(a, b) = qix" // ParenthesizedVariableDesignation "var (a, b) = quix" inside a DeclarationExpression public override void VisitAssignmentExpression(AssignmentExpressionSyntax node) { var leftTupleCount = GetTupleCount(node.Left); if (leftTupleCount != 0) { var assignmentRight = node.Right; var namedTypeSymbol = semanticModel.GetSymbolInfo(assignmentRight).Symbol?.GetSymbolType(); if (namedTypeSymbol != null) { var deconstructors = namedTypeSymbol.GetMembers("Deconstruct"); if (deconstructors.Length == 1) { UsedSymbols.Add(deconstructors.First()); } else if (deconstructors.Length > 1 && FindDeconstructor(deconstructors, leftTupleCount) is {} deconstructor) { UsedSymbols.Add(deconstructor); } } } base.VisitAssignmentExpression(node);
public override void VisitConstructorInitializer(ConstructorInitializerSyntax node) { UsedSymbols.UnionWith(GetSymbols(node, x => true)); base.VisitConstructorInitializer(node); }
public override void VisitGenericName(GenericNameSyntax node) { UsedSymbols.UnionWith(GetSymbols(node, IsKnownIdentifier)); base.VisitGenericName(node); }
public override void VisitObjectCreationExpression(ObjectCreationExpressionSyntax node) { UsedSymbols.UnionWith(GetSymbols(node, x => true)); base.VisitObjectCreationExpression(node); }