/// <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/main/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> internal static MessageContainer?CreateWarningMessage(Logger context, string text, int code, MessageOrigin origin, 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, subcategory)); }
private static MessageContainer?CreateWarningMessageContainer(Logger context, string text, int code, MessageOrigin origin, string subcategory = MessageSubCategory.None) { if (context.IsWarningSuppressed(code, origin)) { return(null); } if (context.IsWarningAsError(code)) { return(new MessageContainer(MessageCategory.WarningAsError, text, code, subcategory, origin)); } return(new MessageContainer(MessageCategory.Warning, text, code, subcategory, origin)); }
private static MessageContainer?CreateWarningMessageContainer(Logger context, MessageOrigin origin, DiagnosticId id, string subcategory, params string[] args) { if (context.IsWarningSuppressed((int)id, origin)) { return(null); } if (TryLogSingleWarning(context, (int)id, origin, subcategory)) { return(null); } if (context.IsWarningAsError((int)id)) { return(new MessageContainer(MessageCategory.WarningAsError, id, subcategory, origin, args)); } return(new MessageContainer(MessageCategory.Warning, id, subcategory, origin, args)); }