New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log properties and items on ProjectEvaluationFinished #6287
Changes from all commits
79b4f41
0a517ea
ffb63ca
ad644b2
f953c0d
87d1d51
b7f5607
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,13 @@ | |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.IO; | ||
using System.Text; | ||
using Microsoft.Build.BackEnd; | ||
using Microsoft.Build.Framework; | ||
|
||
namespace Microsoft.Build.UnitTests.BackEnd | ||
{ | ||
|
@@ -104,5 +107,64 @@ internal static bool CompareExceptions(Exception left, Exception right) | |
|
||
return CompareExceptions(left.InnerException, right.InnerException); | ||
} | ||
|
||
internal static string GetPropertiesString(IEnumerable properties) | ||
{ | ||
var dictionary = properties | ||
.OfType<DictionaryEntry>() | ||
.ToDictionary( | ||
(Func<DictionaryEntry, string>)(d => d.Key.ToString()), | ||
(Func<DictionaryEntry, string>)(d => d.Value.ToString())); | ||
return ToString(dictionary); | ||
} | ||
|
||
internal static string GetMultiItemsString(IEnumerable items) | ||
{ | ||
var list = items | ||
.OfType<DictionaryEntry>() | ||
.Select(i => i.Key.ToString() + GetTaskItemString(i.Value)); | ||
var text = string.Join("\n", list); | ||
return text; | ||
} | ||
|
||
internal static string GetItemsString(IEnumerable items) | ||
{ | ||
var list = items | ||
.OfType<object>() | ||
.Select(i => GetTaskItemString(i)); | ||
var text = string.Join("\n", list); | ||
return text; | ||
} | ||
|
||
internal static string GetTaskItemString(object item) | ||
{ | ||
var sb = new StringBuilder(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ReusableStringBuilder? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests, we don't care ;) I doubt there will be a difference on the test data of this size. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right; didn't notice. |
||
|
||
if (item is ITaskItem taskItem) | ||
{ | ||
sb.Append(taskItem.ItemSpec); | ||
foreach (string name in taskItem.MetadataNames) | ||
{ | ||
var value = taskItem.GetMetadata(name); | ||
sb.Append($";{name}={value}"); | ||
} | ||
} | ||
else | ||
{ | ||
sb.Append(Convert.ToString(item)); | ||
} | ||
|
||
return sb.ToString(); | ||
} | ||
|
||
internal static string ToString(IDictionary<string, string> dictionary) | ||
{ | ||
if (dictionary == null) | ||
{ | ||
return "null"; | ||
} | ||
|
||
return string.Join(";", dictionary.Select(kvp => kvp.Key + "=" + kvp.Value)); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the context behind this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to be able to read and write the raw timestamp without reflection. protected wasn’t enough because I needed access from LogMessagePacketBase and binlog writer, so I’m adding protected internal. I was worried about exposing the field directly because who knows whether changing that field could break BinaryFormatter and I didn’t call it Timestamp because having identifiers that differ by case only would break CLS compliance (not sure how much we care).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means it can be accessed freely within the assembly or by classes that extend it but not other classes? Is that right?