private void AddMessage(IAssetsLogMessage message) { var logToMsBuild = true; var targetGraphs = message.GetTargetGraphs(LockFile); targetGraphs = targetGraphs.Any() ? targetGraphs : new LockFileTarget[] { null }; foreach (var target in targetGraphs) { var targetLib = message.LibraryId == null ? null : target?.GetTargetLibrary(message.LibraryId); Diagnostics.Add( message.Code.ToString(), message.Message, message.FilePath, FromLogLevel(message.Level), message.StartLineNumber, message.StartColumnNumber, message.EndLineNumber, message.EndColumnNumber, target?.Name, targetLib == null ? null : $"{targetLib.Name}/{targetLib.Version.ToNormalizedString()}", logToMsBuild); logToMsBuild = false; // only write first instance of this diagnostic to msbuild } }
/// <summary> /// Get the library from each target graph it exists in. /// </summary> public static IEnumerable <LockFileTargetLibrary> GetTargetLibraries(this IAssetsLogMessage message, LockFile assetsFile) { if (message == null) { throw new ArgumentNullException(nameof(message)); } if (assetsFile == null) { throw new ArgumentNullException(nameof(assetsFile)); } return(message.GetTargetGraphs(assetsFile).Select(target => target.GetTargetLibrary(message.LibraryId))); }
private void AddMessage(IAssetsLogMessage message) { var targetGraphs = message.GetTargetGraphs(LockFile); targetGraphs = targetGraphs.Any() ? targetGraphs : new LockFileTarget[] { null }; foreach (var target in targetGraphs) { var targetLib = message.LibraryId == null ? null : target?.GetTargetLibrary(message.LibraryId); _diagnostics.Add( message.Code.ToString(), message.Message, message.FilePath, FromLogLevel(message.Level), message.StartLineNumber, message.StartColumnNumber, message.EndLineNumber, message.EndColumnNumber, target?.Name, targetLib == null ? null : $"{targetLib.Name}/{targetLib.Version.ToNormalizedString()}"); } }