コード例 #1
0
ファイル: MessageContainer.cs プロジェクト: mikem8361/runtime
        private static MessageContainer CreateWarningMessageContainer(LinkContext context, MessageOrigin origin, DiagnosticId id, WarnVersion version, string subcategory, params string[] args)
        {
            if (!(version >= WarnVersion.ILLink0 && version <= WarnVersion.Latest))
            {
                throw new ArgumentException($"The provided warning version '{version}' is invalid.");
            }

            if (context.IsWarningSuppressed((int)id, origin))
            {
                return(Empty);
            }

            if (version > context.WarnVersion)
            {
                return(Empty);
            }

            if (TryLogSingleWarning(context, (int)id, origin, subcategory))
            {
                return(Empty);
            }

            if (context.IsWarningAsError((int)id))
            {
                return(new MessageContainer(MessageCategory.WarningAsError, id, subcategory, origin, args));
            }

            return(new MessageContainer(MessageCategory.Warning, id, subcategory, origin, args));
        }
コード例 #2
0
ファイル: MessageContainer.cs プロジェクト: mikem8361/runtime
        /// <summary>
        /// Create a custom warning message.
        /// </summary>
        /// <param name="context">Context with the relevant warning suppression info.</param>
        /// <param name="text">Humanly readable message describing the warning</param>
        /// <param name="code">A custom warning ID. This code should be greater than or equal to 6001
        /// to avoid any collisions with existing and future linker warnings</param>
        /// <param name="origin">Filename or member where the warning is coming from</param>
        /// <param name="version">Optional warning version number. Versioned warnings can be controlled with the
        /// warning wave option --warn VERSION. Unversioned warnings are unaffected by this option</param>
        /// <param name="subcategory"></param>
        /// <returns>Custom MessageContainer of 'Warning' category</returns>
        public static MessageContainer CreateCustomWarningMessage(LinkContext context, string text, int code, MessageOrigin origin, WarnVersion version, string subcategory = MessageSubCategory.None)
        {
#if DEBUG
            Debug.Assert(Assembly.GetCallingAssembly() != typeof(MessageContainer).Assembly,
                         "'CreateCustomWarningMessage' is intended to be used by external assemblies only. Use 'CreateWarningMessage' instead.");
#endif
            if (code <= 6000)
            {
                throw new ArgumentOutOfRangeException(nameof(code), $"The provided code '{code}' does not fall into the permitted range for external warnings. To avoid possible collisions " +
                                                      $"with existing and future {Constants.ILLink} warnings, external messages should use codes starting from 6001.");
            }

            return(CreateWarningMessageContainer(context, text, code, origin, version, subcategory));
        }
コード例 #3
0
ファイル: MessageContainer.cs プロジェクト: mikem8361/runtime
        private static MessageContainer CreateWarningMessageContainer(LinkContext context, string text, int code, MessageOrigin origin, WarnVersion version, string subcategory = MessageSubCategory.None)
        {
            if (!(version >= WarnVersion.ILLink0 && version <= WarnVersion.Latest))
            {
                throw new ArgumentException($"The provided warning version '{version}' is invalid.");
            }

            if (context.IsWarningSuppressed(code, origin))
            {
                return(Empty);
            }

            if (version > context.WarnVersion)
            {
                return(Empty);
            }

            if (TryLogSingleWarning(context, code, origin, subcategory))
            {
                return(Empty);
            }

            if (context.IsWarningAsError(code))
            {
                return(new MessageContainer(MessageCategory.WarningAsError, text, code, subcategory, origin));
            }

            return(new MessageContainer(MessageCategory.Warning, text, code, subcategory, origin));
        }
コード例 #4
0
ファイル: MessageContainer.cs プロジェクト: mikem8361/runtime
        /// <summary>
        /// Create a warning message.
        /// </summary>
        /// <param name="context">Context with the relevant warning suppression info.</param>
        /// <param name="text">Humanly readable message describing the warning</param>
        /// <param name="code">Unique warning ID. Please see https://github.com/dotnet/linker/blob/main/docs/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>
        /// <param name="version">Optional warning version number. Versioned warnings can be controlled with the
        /// warning wave option --warn VERSION. Unversioned warnings are unaffected by this option. </param>
        /// <returns>New MessageContainer of 'Warning' category</returns>
        internal static MessageContainer CreateWarningMessage(LinkContext context, string text, int code, MessageOrigin origin, WarnVersion version, string subcategory = MessageSubCategory.None)
        {
            if (!(code > 2000 && code <= 6000))
            {
                throw new ArgumentOutOfRangeException(nameof(code), $"The provided code '{code}' does not fall into the warning category, which is in the range of 2001 to 6000 (inclusive).");
            }

            return(CreateWarningMessageContainer(context, text, code, origin, version, subcategory));
        }
コード例 #5
0
        /// <summary>
        /// Create a warning message.
        /// </summary>
        /// <param name="context">Context with the relevant warning suppression info.</param>
        /// <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>
        /// <param name="version">Optional warning version number. Versioned warnings can be controlled with the
        /// warning wave option --warn VERSION. Unversioned warnings are unaffected by this option. </param>
        /// <returns>New MessageContainer of 'Warning' category</returns>
        public static MessageContainer CreateWarningMessage(LinkContext context, string text, int code, MessageOrigin origin, WarnVersion version, string subcategory = MessageSubCategory.None)
        {
            if (!(code > 2000 && code <= 6000))
            {
                throw new ArgumentException($"The provided code '{code}' does not fall into the warning category, which is in the range of 2001 to 6000 (inclusive).");
            }

            if (!(version >= WarnVersion.ILLink0 && version <= WarnVersion.Latest))
            {
                throw new ArgumentException($"The provided warning version '{version}' is invalid.");
            }

            if (context.IsWarningSuppressed(code, origin))
            {
                return(Empty);
            }

            if (version > context.WarnVersion)
            {
                return(Empty);
            }

            if (context.IsWarningAsError(code))
            {
                return(new MessageContainer(MessageCategory.WarningAsError, text, code, subcategory, origin));
            }

            return(new MessageContainer(MessageCategory.Warning, text, code, subcategory, origin));
        }
コード例 #6
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 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, string origin, string subcategory = MessageSubCategory.None)
        {
            MessageOrigin _origin = new MessageOrigin(origin);

            LogWarning(text, code, _origin, subcategory);
        }
コード例 #7
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">Type 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, IMemberDefinition origin, int?ilOffset = null, string subcategory = MessageSubCategory.None)
        {
            MessageOrigin _origin = new MessageOrigin(origin, ilOffset);

            LogWarning(text, code, _origin, subcategory);
        }
コード例 #8
0
ファイル: MessageContainer.cs プロジェクト: midopooler/linker
        /// <summary>
        /// Create a warning message.
        /// </summary>
        /// <param name="context">Context with the relevant warning suppression info.</param>
        /// <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">Type 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>
        internal static MessageContainer CreateWarningMessage(LinkContext context, string text, int code, IMemberDefinition origin, string subcategory = MessageSubCategory.None)
        {
            MessageOrigin _origin = new MessageOrigin(origin);

            return(CreateWarningMessage(context, text, code, _origin, subcategory));
        }