void RemoveID(IdentifierNameSyntax identifierExpression) { string id = identifierExpression.Identifier.ValueText; if (IDs.ContainsKey(id)) { IDs.Remove(id); } }
void RemoveID(IdentifierNameSyntax identifierExpression, string callerName, bool isProperty = true) { string id = identifierExpression.Identifier.ValueText; if (IDs.ContainsKey(id)) { bool isProblematicCaller = isProperty ? IsProblematicProperty(IDs[id], callerName) : IsProblematicMethod(IDs[id], callerName); if (!isProblematicCaller) { IDs.Remove(id); } } }
public override void VisitVariableDeclarator(VariableDeclaratorSyntax node) { string id = node.Identifier.ValueText; if (IDs.ContainsKey(id)) { var initializer = node.Initializer as EqualsValueClauseSyntax; if (initializer != null && !(initializer.Value is ObjectCreationExpressionSyntax)) { IDs.Remove(id); } } base.VisitVariableDeclarator(node); }
public override void VisitVariableDeclaration(VariableDeclarationSyntax node) { string type = GetType(node.Type.ToString()); if (IsRequiredType(type) && !IsInUsing(node)) { var variableIds = node.Variables.Select(v => v.Identifier.ValueText); foreach (var variableId in variableIds) { if (!IDs.ContainsKey(variableId)) { IDs.Add(variableId, type); } } } base.VisitVariableDeclaration(node); }
bool IsDisposedCalled(string id, string methodName) { return(IDs.ContainsKey(id) && methodName == "Dispose"); }