Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/StructuredLogger/BinaryLogger/BinaryLogRecordKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public enum BinaryLogRecordKind
ProjectEvaluationFinished,
ProjectImported,
ProjectImportArchive,
TargetSkipped
TargetSkipped,
PropertyReassignment,
UninitializedPropertyRead,
EnvironmentVariableRead,
PropertyInitialValueSet
}
}
8 changes: 7 additions & 1 deletion src/StructuredLogger/BinaryLogger/BinaryLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ public sealed class BinaryLogger : ILogger
// - Ids and parent ids for the evaluation locations
// version 7:
// - Include ProjectStartedEventArgs.GlobalProperties
internal const int FileFormatVersion = 7;
// version 8
// - New record kinds:
// - EnvironmentVariableRead
// - PropertyInitialValueSet
// - PropertyReassignment
// - UninitializedPropertyRead
internal const int FileFormatVersion = 8;

private Stream stream;
private BinaryWriter binaryWriter;
Expand Down
90 changes: 90 additions & 0 deletions src/StructuredLogger/BinaryLogger/BuildEventArgsReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ public BuildEventArgs Read()
case BinaryLogRecordKind.TargetSkipped:
result = ReadTargetSkippedEventArgs();
break;
case BinaryLogRecordKind.PropertyReassignment:
result = ReadPropertyReassignmentEventArgs();
break;
case BinaryLogRecordKind.UninitializedPropertyRead:
result = ReadUninitializedPropertyReadEventArgs();
break;
case BinaryLogRecordKind.EnvironmentVariableRead:
result = ReadEnvironmentVariableReadEventArgs();
break;
case BinaryLogRecordKind.PropertyInitialValueSet:
result = ReadPropertyInitialValueSetEventArgs();
break;
default:
break;
}
Expand Down Expand Up @@ -189,6 +201,84 @@ private BuildEventArgs ReadTargetSkippedEventArgs()
return e;
}

private BuildEventArgs ReadPropertyReassignmentEventArgs()
{
var fields = ReadBuildEventArgsFields();
var importance = (MessageImportance)ReadInt32();
string propertyName = ReadString();
string previousValue = ReadString();
string newValue = ReadString();
string location = ReadString();

var e = new PropertyReassignmentEventArgs(
propertyName,
previousValue,
newValue,
location,
fields.Message,
fields.HelpKeyword,
fields.SenderName,
importance);
SetCommonFields(e, fields);

return e;
}
private BuildEventArgs ReadUninitializedPropertyReadEventArgs()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have an empty line between methods

{
var fields = ReadBuildEventArgsFields();
var importance = (MessageImportance)ReadInt32();
string propertyName = ReadString();

var e = new UninitializedPropertyReadEventArgs(
propertyName,
fields.Message,
fields.HelpKeyword,
fields.SenderName,
importance);
SetCommonFields(e, fields);

return e;
}

private BuildEventArgs ReadPropertyInitialValueSetEventArgs()
{
var fields = ReadBuildEventArgsFields();
var importance = (MessageImportance)ReadInt32();
string propertyName = ReadString();
string propertyValue = ReadString();
string propertySource = ReadString();

var e = new PropertyInitialValueSetEventArgs(
propertyName,
propertyValue,
propertySource,
fields.Message,
fields.HelpKeyword,
fields.SenderName,
importance);
SetCommonFields(e, fields);

return e;
}

private BuildEventArgs ReadEnvironmentVariableReadEventArgs()
{
var fields = ReadBuildEventArgsFields();
var importance = (MessageImportance)ReadInt32();

var environmentVariableName = ReadString();

var e = new EnvironmentVariableReadEventArgs(
environmentVariableName,
fields.Message,
fields.HelpKeyword,
fields.SenderName,
importance);
SetCommonFields(e, fields);

return e;
}

private BuildEventArgs ReadBuildStartedEventArgs()
{
var fields = ReadBuildEventArgsFields();
Expand Down
55 changes: 55 additions & 0 deletions src/StructuredLogger/BinaryLogger/BuildEventArgsWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,29 @@ private void Write(BuildMessageEventArgs e)
Write((TargetSkippedEventArgs)e);
return;
}
if (e is PropertyReassignmentEventArgs)
{
Write((PropertyReassignmentEventArgs)e);
return;
}

if (e is UninitializedPropertyReadEventArgs)
{
Write((UninitializedPropertyReadEventArgs)e);
return;
}

if (e is EnvironmentVariableReadEventArgs)
{
Write((EnvironmentVariableReadEventArgs)e);
return;
}

if (e is PropertyInitialValueSetEventArgs)
{
Write((PropertyInitialValueSetEventArgs)e);
return;
}

Write(BinaryLogRecordKind.Message);
WriteMessageFields(e);
Expand All @@ -352,6 +375,38 @@ private void Write(TargetSkippedEventArgs e)
Write((int)e.BuildReason);
}

private void Write(PropertyReassignmentEventArgs e)
{
Write(BinaryLogRecordKind.PropertyReassignment);
WriteMessageFields(e);
Write(e.PropertyName);
Write(e.PreviousValue);
Write(e.NewValue);
Write(e.Location);
}
private void Write(UninitializedPropertyReadEventArgs e)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well

{
Write(BinaryLogRecordKind.UninitializedPropertyRead);
WriteMessageFields(e);
Write(e.PropertyName);
}

private void Write(PropertyInitialValueSetEventArgs e)
{
Write(BinaryLogRecordKind.PropertyInitialValueSet);
WriteMessageFields(e);
Write(e.PropertyName);
Write(e.PropertyValue);
Write(e.PropertySource);
}

private void Write(EnvironmentVariableReadEventArgs e)
{
Write(BinaryLogRecordKind.EnvironmentVariableRead);
WriteMessageFields(e);
Write(e.EnvironmentVariableName);
}

private void Write(CriticalBuildMessageEventArgs e)
{
Write(BinaryLogRecordKind.CriticalBuildMessage);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;

namespace Microsoft.Build.Framework
{
public class EnvironmentVariableReadEventArgs : BuildMessageEventArgs
{
/// <summary>
/// Initializes a new instance of the EnvironmentVariableReadEventArgs class.
/// </summary>
#if FEATURE_BINARY_SERIALIZATION
[Serializable]
#endif
public EnvironmentVariableReadEventArgs()
{
}

/// <summary>
/// Initializes a new instance of the EnvironmentVariableReadEventArgs class.
/// </summary>
public EnvironmentVariableReadEventArgs
(
string environmentVariableName,
string message,
string helpKeyword=null,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a space on both sides of =

string senderName=null,
MessageImportance importance = MessageImportance.Low,
params object[] messageArgs
)
: base(null, null, null, 0, 0, 0, 0, message, helpKeyword, senderName, importance, DateTime.UtcNow, messageArgs)
{
EnvironmentVariableName = environmentVariableName;
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no two consecutive empty lines in .cs files


public string EnvironmentVariableName { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;

namespace Microsoft.Build.Framework
{
public class PropertyInitialValueSetEventArgs : BuildMessageEventArgs
{
/// <summary>
/// Initializes a new instance of the UninitializedPropertyRead class.
/// </summary>
#if FEATURE_BINARY_SERIALIZATION
[Serializable]
#endif
public PropertyInitialValueSetEventArgs()
{
}

/// <summary>
/// Initializes a new instance of the UninitializedPropertyRead class.
/// </summary>
public PropertyInitialValueSetEventArgs
(
string propertyName,
string propertyValue,
string propertySource,
string message,
string helpKeyword = null,
string senderName = null,
MessageImportance importance = MessageImportance.Low
) : base(message, helpKeyword, senderName, importance)
{
this.PropertyName = propertyName;
this.PropertySource = propertySource;
this.PropertyValue = propertyValue;
}

public string PropertyName { get; set; }

public string PropertySource { get; set; }

public string PropertyValue { get; set; }
}
}
62 changes: 62 additions & 0 deletions src/StructuredLogger/BinaryLogger/PropertyReassignmentEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;

namespace Microsoft.Build.Framework
{
public class PropertyReassignmentEventArgs : BuildMessageEventArgs
{
/// <summary>
/// Initializes a new instance of the PropertyReassignment class.
/// </summary>
#if FEATURE_BINARY_SERIALIZATION
[Serializable]
#endif
public PropertyReassignmentEventArgs()
{
}

/// <summary>
/// Creates an instance of the PropertyReassignmentEventArgs class.
/// </summary>
/// <param name="propertyName">The name of the property whose value was reassigned.</param>
/// <param name="previousValue">The previous value of the reassigned property.</param>
/// <param name="newValue">The new value of the reassigned property.</param>
/// <param name="location">The location of the reassignment.</param>
public PropertyReassignmentEventArgs
(
string propertyName,
string previousValue,
string newValue,
string location,
string message,
string helpKeyword = null,
string senderName = null,
MessageImportance importance = MessageImportance.Low
) : base(message, helpKeyword, senderName, importance)
{
this.PropertyName = propertyName;
this.PreviousValue = previousValue;
this.NewValue = newValue;
this.Location = location;
}

/// <summary>
/// The name of the property whose value was reassigned.
/// </summary>
public string PropertyName { get; set; }

/// <summary>
/// The previous value of the reassigned property.
/// </summary>
public string PreviousValue { get; set; }

/// <summary>
/// The new value of the reassigned property.
/// </summary>
public string NewValue { get; set; }

/// <summary>
/// The location of the reassignment.
/// </summary>
public string Location { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.Build.Logging.StructuredLogger;
using System;

namespace Microsoft.Build.Framework
{
public class UninitializedPropertyReadEventArgs : BuildMessageEventArgs
{
/// <summary>
/// Initializes a new instance of the UninitializedPropertyRead class.
/// </summary>
#if FEATURE_BINARY_SERIALIZATION
[Serializable]
#endif
public UninitializedPropertyReadEventArgs()
{
}

/// <summary>
/// Initializes a new instance of the UninitializedPropertyRead class.
/// </summary>
public UninitializedPropertyReadEventArgs
(
string propertyName,
string message,
string helpKeyword=null,
string senderName=null,
MessageImportance importance = MessageImportance.Low,
params object[] messageArgs
) : base(message, helpKeyword, senderName, importance)
{
this.PropertyName = propertyName;
}

public string PropertyName { get; set; }
}
}