Esempio n. 1
0
        public void LogMessage(MessageContainer message)
        {
            if (!LogMessages || message == MessageContainer.Empty)
            {
                return;
            }

            if (message.Category == MessageCategory.Warning &&
                NoWarn.Contains((uint)message.Code))
            {
                // This warning was turned off by --nowarn.
                return;
            }

            // Note: message.Version is nullable. The comparison is false if it is null.
            // Unversioned warnings are not controlled by WarnVersion.
            // Error messages are guaranteed to only have a version if they were created for a warning due to warnaserror.
            if ((message.Category == MessageCategory.Warning || message.Category == MessageCategory.Error) &&
                message.Version > WarnVersion)
            {
                // This warning was turned off by --warn.
                return;
            }

            if (OutputWarningSuppressions && message.Category == MessageCategory.Warning && message.Origin?.MemberDefinition != null)
            {
                WarningSuppressionWriter.AddWarning(message.Code.Value, message.Origin?.MemberDefinition);
            }

            Logger?.LogMessage(message);
        }
Esempio n. 2
0
        private static async Task <IEnumerable <Diagnostic> > GetCompilerDiagnosticsAsync(Document document)
        {
            var model = await document.GetSemanticModelAsync();

            return(model
                   .GetDiagnostics()
                   .Where(d => !NoWarn.Contains(d.Id)));
        }
Esempio n. 3
0
        public bool IsWarningSuppressed(int warningCode, MessageOrigin origin)
        {
            // This warning was turned off by --nowarn.
            if (NoWarn.Contains(warningCode))
            {
                return(true);
            }

            if (Suppressions == null)
            {
                return(false);
            }

            return(Suppressions.IsSuppressed(warningCode, origin, out _));
        }