private void CheckNewModifier(Symbol symbol, bool isNew, DiagnosticBag diagnostics) { // for error cases if ((object)this.BaseTypeNoUseSiteDiagnostics == null) { return; } // Do not give warnings about missing 'new' modifier for implicitly declared members, // e.g. backing fields for auto-properties if (symbol.IsImplicitlyDeclared) { return; } int symbolArity = symbol.GetMemberArity(); Location symbolLocation = symbol.Locations.FirstOrDefault(); bool unused = false; NamedTypeSymbol currType = this.BaseTypeNoUseSiteDiagnostics; while ((object)currType != null) { foreach (var hiddenMember in currType.GetMembers(symbol.Name)) { if (hiddenMember.Kind == SymbolKind.Method && !((MethodSymbol)hiddenMember).CanBeHiddenByMemberKind(symbol.Kind)) { continue; } HashSet<DiagnosticInfo> useSiteDiagnostics = null; bool isAccessible = AccessCheck.IsSymbolAccessible(hiddenMember, this, ref useSiteDiagnostics); diagnostics.Add(symbolLocation, useSiteDiagnostics); if (isAccessible && hiddenMember.GetMemberArity() == symbolArity) { if (!isNew) { diagnostics.Add(ErrorCode.WRN_NewRequired, symbolLocation, symbol, hiddenMember); } AddHidingAbstractDiagnostic(symbol, symbolLocation, hiddenMember, diagnostics, ref unused); return; } } currType = currType.BaseTypeNoUseSiteDiagnostics; } if (isNew) { diagnostics.Add(ErrorCode.WRN_NewNotRequired, symbolLocation, symbol); } }