示例#1
0
        /// <summary>
        /// Gets the <see cref="SuppressionInfo"/> for suppressed diagnostics, i.e. <see cref="IsSuppressed"/> = true.
        /// Otherwise, returns null.
        /// </summary>
        public SuppressionInfo GetSuppressionInfo(Compilation compilation)
        {
            if (!IsSuppressed)
            {
                return(null);
            }

            SuppressMessageAttributeState suppressMessageState = new SuppressMessageAttributeState(compilation);

            if (!suppressMessageState.IsDiagnosticSuppressed(this, out AttributeData attribute))
            {
                attribute = null;
            }

            return(new SuppressionInfo(this.Id, attribute));
        }
示例#2
0
        public SuppressionInfo?GetSuppressionInfo(Compilation compilation)
        {
            if (!IsSuppressed)
            {
                return(null);
            }

            AttributeData?attribute;
            var           suppressMessageState = new SuppressMessageAttributeState(compilation);

            if (!suppressMessageState.IsDiagnosticSuppressed(
                    this,
                    getSemanticModel: (compilation, tree) => compilation.GetSemanticModel(tree),
                    out attribute))
            {
                attribute = null;
            }

            return(new SuppressionInfo(this.Id, attribute));
        }