Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c7e5c0a
Log environment variables read as properties
Forgind Mar 22, 2022
418b210
Only log random environment variables if asked
Forgind Mar 23, 2022
fb96241
Don't write a full (empty) dictionary
Forgind Mar 23, 2022
cf9c722
Only log nonempty env vars
Forgind Mar 23, 2022
d7c03b2
Fix NRE
Forgind Mar 23, 2022
5b58243
Make tests pass
Forgind Mar 23, 2022
fdee113
Only find environment properties
Forgind Mar 28, 2022
be584ed
PR comments
Forgind Mar 29, 2022
16332a7
Log on first property read
Forgind Mar 30, 2022
2a749b8
Account for prior logging and EvaluationFinished
Forgind Apr 1, 2022
150a442
Tweak tests
Forgind Apr 4, 2022
dfe55d7
Random cleanup
Forgind Apr 7, 2022
bb51b1f
Make it work across nodes
Forgind Apr 7, 2022
133f760
Merge branch 'main' of https://github.com/dotnet/msbuild into log-env…
Forgind Apr 8, 2022
775a20d
EnvironmentVariableReadEventArgs serialization
Forgind Apr 8, 2022
2fc3b00
Self comments
Forgind Apr 11, 2022
4c0f001
PR comments
Forgind Apr 13, 2022
30cb0e1
Remove IProperty.IsEnvironmentProperty
Forgind Apr 13, 2022
d13ef44
Reduce allocations in mainline case
Forgind Apr 14, 2022
01d3362
Break up long line
Forgind Apr 15, 2022
75dc9dd
Make text log align with binlog
Forgind Apr 18, 2022
7914d87
PR feedback
Forgind Apr 26, 2022
47d80f6
Filter from ProjectStarted
Forgind Apr 27, 2022
fff4f97
Add test
Forgind Apr 27, 2022
9fb427c
merge
Forgind Apr 27, 2022
0b830e5
Reorder usings
Forgind Apr 28, 2022
c2b93b9
Make list instead of yield returning
Forgind Apr 29, 2022
d1cad7b
Remove expectation of file
Forgind Apr 29, 2022
d4c2f06
Use log file instead
Forgind Apr 29, 2022
add1258
Update src/Build/BackEnd/Components/Logging/ProjectLoggingContext.cs
Forgind Apr 29, 2022
679c003
Notice env properties accessed in tasks
Forgind May 10, 2022
aa46661
PR comments
Forgind May 10, 2022
ce8dad4
Account for more cases
Forgind May 14, 2022
01ee110
One more case
Forgind May 14, 2022
ad92323
Fix another case
Forgind May 16, 2022
0316ba7
Fix condition on task execution
Forgind May 17, 2022
44aa9b6
Fixed other cases mentioned in PR
Forgind May 17, 2022
f7ccf3d
PR comments
Forgind May 27, 2022
22525b6
Using statement
Forgind May 31, 2022
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
Prev Previous commit
Next Next commit
Only find environment properties
  • Loading branch information
Forgind committed Mar 28, 2022
commit fdee1138759322169182e1dd1e29764ccdcd25ff
2 changes: 2 additions & 0 deletions src/Build/Definition/ProjectProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ string IValued.EscapedValue
get => EvaluatedValueEscapedInternal;
}

bool IProperty.IsEnvironmentProperty { get => IsEnvironmentProperty; set => throw new NotImplementedException(); }

#region IEquatable<ProjectProperty> Members

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Build/Evaluation/Expander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ private static object LookupProperty(IPropertyProvider<T> properties, string pro
private static object LookupProperty(IPropertyProvider<T> properties, string propertyName, int startIndex, int endIndex, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties)
{
T property = properties.GetProperty(propertyName, startIndex, endIndex);
if (!string.IsNullOrEmpty(property?.EvaluatedValue))
if (!string.IsNullOrEmpty(property?.EvaluatedValue) && property.IsEnvironmentProperty)
{
EnvironmentUtilities.EnvironmentVariablesUsedAsProperties[property.Name] = property.EvaluatedValue;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Build/Evaluation/IProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,11 @@ string EvaluatedValueEscaped
{
get;
}

bool IsEnvironmentProperty
{
get;
set;
}
}
}
4 changes: 2 additions & 2 deletions src/Build/Instance/ProjectInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ IItemDefinition<ProjectMetadataInstance> IEvaluatorData<ProjectPropertyInstance,
ProjectPropertyInstance IEvaluatorData<ProjectPropertyInstance, ProjectItemInstance, ProjectMetadataInstance, ProjectItemDefinitionInstance>.SetProperty(string name, string evaluatedValueEscaped, bool isGlobalProperty, bool mayBeReserved, bool isEnvironmentVariable)
{
// Mutability not verified as this is being populated during evaluation
ProjectPropertyInstance property = ProjectPropertyInstance.Create(name, evaluatedValueEscaped, mayBeReserved, _isImmutable);
ProjectPropertyInstance property = ProjectPropertyInstance.Create(name, evaluatedValueEscaped, mayBeReserved, _isImmutable, isEnvironmentVariable);
_properties.Set(property);
return property;
}
Expand Down Expand Up @@ -2966,7 +2966,7 @@ private void CreatePropertiesSnapshot(ICollection<ProjectProperty> properties, b
{
// Allow reserved property names, since this is how they are added to the project instance.
// The caller has prevented users setting them themselves.
ProjectPropertyInstance instance = ProjectPropertyInstance.Create(property.Name, ((IProperty)property).EvaluatedValueEscaped, true /* MAY be reserved name */, isImmutable);
ProjectPropertyInstance instance = ProjectPropertyInstance.Create(property.Name, ((IProperty)property).EvaluatedValueEscaped, true /* MAY be reserved name */, isImmutable, property.IsEnvironmentProperty);
_properties.Set(instance);
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/Build/Instance/ProjectPropertyInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public string EvaluatedValue
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
string IValued.EscapedValue => _escapedValue;

bool IProperty.IsEnvironmentProperty { get; set; }

#region IEquatable<ProjectPropertyInstance> Members

/// <summary>
Expand Down Expand Up @@ -182,9 +184,9 @@ internal static ProjectPropertyInstance Create(string name, string escapedValue,
/// This flags should ONLY be set by the evaluator or by cloning; after the ProjectInstance is created, they must be illegal.
/// If name is invalid or reserved, throws ArgumentException.
/// </summary>
internal static ProjectPropertyInstance Create(string name, string escapedValue, bool mayBeReserved, bool isImmutable)
internal static ProjectPropertyInstance Create(string name, string escapedValue, bool mayBeReserved, bool isImmutable, bool isEnvironmentProperty = false)
{
return Create(name, escapedValue, mayBeReserved, null, isImmutable);
return Create(name, escapedValue, mayBeReserved, null, isImmutable, isEnvironmentProperty);
}

/// <summary>
Expand Down Expand Up @@ -212,7 +214,7 @@ internal static ProjectPropertyInstance Create(string name, string escapedValue,
/// </summary>
internal static ProjectPropertyInstance Create(ProjectPropertyInstance that)
{
return Create(that._name, that._escapedValue, mayBeReserved: true /* already validated */, isImmutable: that.IsImmutable);
return Create(that._name, that._escapedValue, mayBeReserved: true /* already validated */, isImmutable: that.IsImmutable, ((IProperty)that).IsEnvironmentProperty);
}

/// <summary>
Expand All @@ -221,7 +223,7 @@ internal static ProjectPropertyInstance Create(ProjectPropertyInstance that)
/// </summary>
internal static ProjectPropertyInstance Create(ProjectPropertyInstance that, bool isImmutable)
{
return Create(that._name, that._escapedValue, mayBeReserved: true /* already validated */, isImmutable: isImmutable);
return Create(that._name, that._escapedValue, mayBeReserved: true /* already validated */, isImmutable: isImmutable, ((IProperty)that).IsEnvironmentProperty);
}

/// <summary>
Expand Down Expand Up @@ -278,7 +280,7 @@ internal ProjectPropertyElement ToProjectPropertyElement(ProjectElementContainer
/// as it should never be needed for any subsequent messages, and is just extra bulk.
/// Inherits mutability from project if any.
/// </summary>
private static ProjectPropertyInstance Create(string name, string escapedValue, bool mayBeReserved, ElementLocation location, bool isImmutable)
private static ProjectPropertyInstance Create(string name, string escapedValue, bool mayBeReserved, ElementLocation location, bool isImmutable, bool isEnvironmentProperty = false)
{
// Does not check immutability as this is only called during build (which is already protected) or evaluation
ErrorUtilities.VerifyThrowArgumentNull(escapedValue, nameof(escapedValue));
Expand All @@ -295,11 +297,9 @@ private static ProjectPropertyInstance Create(string name, string escapedValue,
XmlUtilities.VerifyThrowProjectValidElementName(name, location);
}

if (isImmutable)
{
return new ProjectPropertyInstanceImmutable(name, escapedValue);
}
return new ProjectPropertyInstance(name, escapedValue);
ProjectPropertyInstance instance = isImmutable ? new ProjectPropertyInstanceImmutable(name, escapedValue) : new ProjectPropertyInstance(name, escapedValue);
((IProperty)instance).IsEnvironmentProperty = isEnvironmentProperty;
return instance;
}

/// <summary>
Expand Down