Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        /// <returns>
        /// True if the symbol is definitely obsolete.
        /// False if the symbol is definitely not obsolete.
        /// Unknown if the symbol may be obsolete.
        ///
        /// NOTE: The return value reflects obsolete-ness, not whether or not the diagnostic was reported.
        /// </returns>
        private static ThreeState ReportDiagnosticsIfObsoleteInternal(DiagnosticBag diagnostics, Symbol symbol, SyntaxNodeOrToken node, Symbol containingMember, BinderFlags location)
        {
            Debug.Assert(diagnostics != null);

            if (symbol.ObsoleteState == ThreeState.False)
            {
                return(ThreeState.False);
            }

            var data = symbol.ObsoleteAttributeData;

            if (data == null)
            {
                // Obsolete attribute has errors.
                return(ThreeState.False);
            }

            // If we haven't cracked attributes on the symbol at all or we haven't
            // cracked attribute arguments enough to be able to report diagnostics for
            // ObsoleteAttribute, store the symbol so that we can report diagnostics at a
            // later stage.
            if (symbol.ObsoleteState == ThreeState.Unknown)
            {
                diagnostics.Add(new LazyObsoleteDiagnosticInfo(symbol, containingMember, location), node.GetLocation());
                return(ThreeState.Unknown);
            }

            // After this point, always return True.

            var inObsoleteContext = ObsoleteAttributeHelpers.GetObsoleteContextState(containingMember);

            // If we are in a context that is already obsolete, there is no point reporting
            // more obsolete diagnostics.
            if (inObsoleteContext == ThreeState.True)
            {
                return(ThreeState.True);
            }
            // If the context is unknown, then store the symbol so that we can do this check at a
            // later stage
            else if (inObsoleteContext == ThreeState.Unknown)
            {
                diagnostics.Add(new LazyObsoleteDiagnosticInfo(symbol, containingMember, location), node.GetLocation());
                return(ThreeState.True);
            }

            // We have all the information we need to report diagnostics right now. So do it.
            var diagInfo = ObsoleteAttributeHelpers.CreateObsoleteDiagnostic(symbol, location);

            if (diagInfo != null)
            {
                diagnostics.Add(diagInfo, node.GetLocation());
                return(ThreeState.True);
            }

            return(ThreeState.True);
        }
Esempio n. 3
0
 internal static void Error(DiagnosticBag diagnostics, ErrorCode code, SyntaxNodeOrToken syntax, params object[] args)
 {
     Error(diagnostics, code, syntax.GetLocation(), args);
 }
Esempio n. 4
0
 internal static void Error(DiagnosticBag diagnostics, ErrorCode code, SyntaxNodeOrToken syntax)
 {
     Error(diagnostics, code, syntax.GetLocation());
 }