Ejemplo n.º 1
0
        public bool IsWarningAsError(int warningCode)
        {
            bool value;

            if (GeneralWarnAsError)
            {
                return(!WarnAsError.TryGetValue(warningCode, out value) || value);
            }

            return(WarnAsError.TryGetValue(warningCode, out value) && value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Display a warning message to the end user.
        /// This API is used for warnings defined in the linker, not by custom steps. Warning
        /// versions are inferred from the code, and every warning that we define is versioned.
        /// </summary>
        /// <param name="text">Humanly readable message describing the warning</param>
        /// <param name="code">Unique warning ID. Please see https://github.com/mono/linker/blob/master/doc/error-codes.md for the list of warnings and possibly add a new one</param>
        /// <param name="origin">Filename or member where the warning is coming from</param>
        /// <param name="subcategory">Optionally, further categorize this warning</param>
        /// <returns>New MessageContainer of 'Warning' category</returns>
        public void LogWarning(string text, int code, MessageOrigin origin, string subcategory = MessageSubCategory.None)
        {
            if (!LogMessages)
            {
                return;
            }

            var version = GetWarningVersion(code);

            if ((GeneralWarnAsError && (!WarnAsError.TryGetValue((uint)code, out var warnAsError) || warnAsError)) ||
                (!GeneralWarnAsError && (WarnAsError.TryGetValue((uint)code, out warnAsError) && warnAsError)))
            {
                LogError(text, code, subcategory, origin, isWarnAsError: true, version: version);
                return;
            }

            var warning = MessageContainer.CreateWarningMessage(this, text, code, origin, subcategory, version);

            LogMessage(warning);
        }