public static HashSet <AssignedInfo> GetAssignedAndRelease(MakeMemberReadOnlyWalker walker) { HashSet <AssignedInfo> assigned = walker.Assigned; Release(walker); return(assigned); }
public virtual HashSet <ISymbol> GetFixableSymbols( SymbolAnalysisContext context, INamedTypeSymbol containingType, HashSet <ISymbol> symbols) { CancellationToken cancellationToken = context.CancellationToken; ImmutableArray <SyntaxReference> syntaxReferences = containingType.DeclaringSyntaxReferences; for (int i = 0; i < syntaxReferences.Length; i++) { var typeDeclaration = (TypeDeclarationSyntax)syntaxReferences[i].GetSyntax(cancellationToken); SemanticModel semanticModel = context.Compilation.GetSemanticModel(typeDeclaration.SyntaxTree); foreach (MemberDeclarationSyntax memberDeclaration in typeDeclaration.Members) { MakeMemberReadOnlyWalker walker = MakeMemberReadOnlyWalkerCache.Acquire(); walker.Visit(memberDeclaration); HashSet <AssignedInfo> assigned = MakeMemberReadOnlyWalkerCache.GetAssignedAndRelease(walker); if (assigned != null) { foreach (AssignedInfo info in assigned) { foreach (ISymbol symbol in symbols) { if (symbol.Name == info.NameText && ((symbol.IsStatic) ? !info.IsInStaticConstructor : !info.IsInInstanceConstructor)) { ISymbol nameSymbol = semanticModel.GetSymbol(info.Name, cancellationToken); if (ValidateSymbol(nameSymbol) && symbols.Remove(nameSymbol.OriginalDefinition)) { if (symbols.Count == 0) { return(symbols); } break; } } } } } } } return(symbols); }
public static MakeMemberReadOnlyWalker Acquire() { MakeMemberReadOnlyWalker walker = _cachedInstance; if (walker != null) { _cachedInstance = null; walker.Clear(); return(walker); } return(new MakeMemberReadOnlyWalker()); }
public static void Release(MakeMemberReadOnlyWalker walker) { _cachedInstance = walker; }