internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(DiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, Symbol containingMember, BinderFlags location) { Debug.Assert(diagnostics != null); var kind = ObsoleteAttributeHelpers.GetObsoleteDiagnosticKind(symbol, containingMember); DiagnosticInfo info = null; switch (kind) { case ObsoleteDiagnosticKind.Diagnostic: info = ObsoleteAttributeHelpers.CreateObsoleteDiagnostic(symbol, location); break; case ObsoleteDiagnosticKind.Lazy: case ObsoleteDiagnosticKind.LazyPotentiallySuppressed: info = new LazyObsoleteDiagnosticInfo(symbol, containingMember, location); break; } if (info != null) { diagnostics.Add(info, node.GetLocation()); } return(kind); }
internal override DiagnosticInfo GetResolvedInfo() { if (_lazyActualObsoleteDiagnostic == null) { // A symbol's Obsoleteness may not have been calculated yet if the symbol is coming // from a different compilation's source. In that case, force completion of attributes. var symbol = (_symbolOrSymbolWithAnnotations as Symbol) ?? ((TypeWithAnnotations)_symbolOrSymbolWithAnnotations).Type; symbol.ForceCompleteObsoleteAttribute(); var kind = ObsoleteAttributeHelpers.GetObsoleteDiagnosticKind( symbol, _containingSymbol, forceComplete: true ); Debug.Assert(kind != ObsoleteDiagnosticKind.Lazy); Debug.Assert(kind != ObsoleteDiagnosticKind.LazyPotentiallySuppressed); var info = (kind == ObsoleteDiagnosticKind.Diagnostic) ? ObsoleteAttributeHelpers.CreateObsoleteDiagnostic(symbol, _binderFlags) : null; // If this symbol is not obsolete or is in an obsolete context, we don't want to report any diagnostics. // Therefore make this a Void diagnostic. Interlocked.CompareExchange( ref _lazyActualObsoleteDiagnostic, info ?? CSDiagnosticInfo.VoidDiagnosticInfo, null ); } return(_lazyActualObsoleteDiagnostic); }
protected override DiagnosticInfo ResolveInfo() { // A symbol's Obsoleteness may not have been calculated yet if the symbol is coming // from a different compilation's source. In that case, force completion of attributes. var symbol = (_symbolOrSymbolWithAnnotations as Symbol) ?? ((TypeWithAnnotations)_symbolOrSymbolWithAnnotations).Type; symbol.ForceCompleteObsoleteAttribute(); var kind = ObsoleteAttributeHelpers.GetObsoleteDiagnosticKind(symbol, _containingSymbol, forceComplete: true); Debug.Assert(kind != ObsoleteDiagnosticKind.Lazy); Debug.Assert(kind != ObsoleteDiagnosticKind.LazyPotentiallySuppressed); // If this symbol is not obsolete or is in an obsolete context, we don't want to report any diagnostics. // Therefore return null. return((kind == ObsoleteDiagnosticKind.Diagnostic) ? ObsoleteAttributeHelpers.CreateObsoleteDiagnostic(symbol, _binderFlags) : null); }