/// <summary> /// Display a warning message to the end user. /// </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> public void LogWarning(string text, int code, MessageOrigin origin, string subcategory = MessageSubCategory.None) { if (!LogMessages) { return; } var warning = MessageContainer.CreateWarningMessage(this, text, code, origin, subcategory); LogMessage(warning); }
/// <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); }
public void UnrecognizedReflectionAccessPattern(MethodDefinition sourceMethod, Instruction reflectionMethodCall, IMetadataTokenProvider accessedItem, string message) { _context.LogMessage(MessageContainer.CreateWarningMessage(message, 2006, "Unrecognized reflection pattern", reflectionMethodCall != null ? MessageOrigin.TryGetOrigin(sourceMethod, reflectionMethodCall.Offset) : null)); }