static bool ProcessTaskParameter(MSBuildOutputProcessor processor, BuildMessageEventArgs e, StringInternPool stringPool) { if (e.Message.IndexOf('\n') == -1) { var message = stringPool.Add(e.Message, TaskParameterMessagePrefix.Length, e.Message.Length - TaskParameterMessagePrefix.Length); processor.CurrentNode.AddParameter(message, message); } else { string content = e.Message.Substring(TaskParameterMessagePrefix.Length); int equalSign = content.IndexOf('='); if (equalSign < 0) { return(false); } content = $"{content.Substring (0, equalSign).Trim ()}={content.Substring (equalSign + 1, content.Length - equalSign - 1).Trim ()}"; processor.CurrentNode.AddParameter(stringPool.Add(content), stringPool.Add(e.Message)); } return(true); }
private void BinLog_BuildStarted(object sender, BuildStartedEventArgs e) { var message = stringPool.Add(e.Message); AddNode(BuildOutputNodeType.Build, message, message, true, e.Timestamp); }
static void ProcessMessageEvent(MSBuildOutputProcessor processor, BuildMessageEventArgs e, StringInternPool stringPool) { if (String.IsNullOrEmpty(e.Message)) { return; } switch (e.Message[0]) { case 'S': if (e.Message.StartsWith(SkippingTargetMessagePrefix, StringComparison.Ordinal)) { // "Skipping target ..." messages if (e.Message [SkippingTargetMessagePrefix.Length] == '"') { int nextQuoteIndex = e.Message.IndexOf('"', SkippingTargetMessagePrefix.Length + 1); if (nextQuoteIndex >= 0) { if (processor.CurrentNode.NodeType == BuildOutputNodeType.Target && e.Message.IndexOf(processor.CurrentNode.Message, SkippingTargetMessagePrefix.Length + 1, nextQuoteIndex - 1 - SkippingTargetMessagePrefix.Length, StringComparison.Ordinal) == SkippingTargetMessagePrefix.Length + 1) { processor.CurrentNode.NodeType = BuildOutputNodeType.TargetSkipped; return; } } } } break; case 'T': if (e.Message.StartsWith(TaskParameterMessagePrefix, StringComparison.Ordinal)) { // Task parameters are added to a special folder if (ProcessTaskParameter(processor, e, stringPool)) { return; } } else if (e.Message.StartsWith(TargetMessagePrefix, StringComparison.Ordinal)) { // "Target ... skipped" messages int nextQuoteIndex = e.Message.IndexOf('"', TargetMessagePrefix.Length + 1); if (nextQuoteIndex >= 0) { if (e.Message.IndexOf(SkippedSuffix, nextQuoteIndex + 1, SkippedSuffix.Length, StringComparison.Ordinal) == nextQuoteIndex + 1) { processor.AddNode(BuildOutputNodeType.TargetSkipped, stringPool.Add(e.Message, TargetMessagePrefix.Length, nextQuoteIndex - TargetMessagePrefix.Length), stringPool.Add(e.Message), false, e.Timestamp); return; } } } break; } string shortMessage = stringPool.Add(e.Message); processor.AddNode(e.Importance == MessageImportance.Low ? BuildOutputNodeType.Diagnostics : BuildOutputNodeType.Message, shortMessage, shortMessage, false, e.Timestamp, !String.IsNullOrEmpty(e.File) ? stringPool.Add(e.File) : null, !String.IsNullOrEmpty(e.ProjectFile) ? stringPool.Add(e.ProjectFile) : null, e.LineNumber); }
public static object ConsumeUntilNewLine(ref object ws) { if (ws == null) { return(null); } var s = ws as string; if (s != null) { for (int n = s.Length - 1; n >= 0; n--) { var c = s [n]; if (c == '\r' || c == '\n') { if (n == s.Length - 1) { break; // Default case, consume the whole string } int len = n + 1; string res; lock (whitespacePool) { res = whitespacePool.Add(s, 0, len); ws = whitespacePool.Add(s, len, s.Length - len); } return(res); } } var result = ws; ws = null; return(result); } var sb = ws as StringBuilder; if (sb != null) { for (int n = sb.Length - 1; n >= 0; n--) { var c = sb [n]; if (c == '\r' || c == '\n') { if (n == sb.Length - 1) { break; // Default case, consume the whole string } var res = sb.ToString(0, n + 1); sb.Remove(0, n + 1); return(res); } } string result; lock (whitespacePool) { result = whitespacePool.Add(sb); } ws = null; return(result); } // It's a MSBuildWhitespace var mw = (MSBuildWhitespace)ws; mw.GenerateStrings(); var toSplit = mw.FindLastWithNewLine(); if (toSplit == null) { var result = ws; ws = null; return(result); } else { var remaining = toSplit.content; var result = ConsumeUntilNewLine(ref remaining); // Set the remaining value if (toSplit.next == null) { // New line found in last node. The remaining is just the split string ws = remaining; } else { if (remaining == null) { return(toSplit.next); // Consumed the whole string of this node. The remaining is the next node } // New line found in the middle of the chain. A new node with the remaining has to be created ws = new MSBuildWhitespace { content = remaining, next = toSplit.next }; } // Generate the consumed value if (toSplit != mw) { // New line found in the middle of the chain. Update the node content and split the chain. toSplit.content = result; toSplit.next = null; return(mw); } else { // New line found in first node. The result is just the consumed string. Nothing else to do. return(result); } } }