Skip to content
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

Recognize direct properties access in ProjectInstance #10659

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ internal readonly record struct PropertyReadInfo(
int EndIndex,
IMSBuildElementLocation ElementLocation,
bool IsUninitialized,
PropertyReadContext PropertyReadContext);
PropertyReadContext PropertyReadContext)
{
internal PropertyReadInfo(
string PropertyName,
IMSBuildElementLocation ElementLocation,
bool IsUninitialized,
PropertyReadContext PropertyReadContext)
: this(PropertyName, 0, PropertyName.Length - 1, ElementLocation, IsUninitialized, PropertyReadContext)
{ }
}
8 changes: 8 additions & 0 deletions src/Build/Instance/ProjectInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Microsoft.Build.Definition;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Evaluation.Context;
using Microsoft.Build.Experimental.BuildCheck.Infrastructure;
using Microsoft.Build.FileSystem;
using Microsoft.Build.Framework;
using Microsoft.Build.Instance;
Expand Down Expand Up @@ -1894,6 +1895,11 @@ public string GetPropertyValue(string name)
{
unescapedValue = String.Empty;
}
else
{
_loggingContext?.ProcessPropertyRead(
new PropertyReadInfo(name, ElementLocation.EmptyLocation, false, PropertyReadContext.Other));
JanKrivanek marked this conversation as resolved.
Show resolved Hide resolved
}

return unescapedValue;
}
Expand All @@ -1913,6 +1919,8 @@ public ProjectPropertyInstance SetProperty(string name, string evaluatedValue)
ProjectPropertyInstance property = ProjectPropertyInstance.Create(name, evaluatedValue, false /* may not be reserved */, _isImmutable);
_properties.Set(property);

_loggingContext?.ProcessPropertyWrite(new PropertyWriteInfo(name, false, ElementLocation.EmptyLocation));

return property;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<PropertyGroup Condition="'$(MyProp12)' == ''">
<MyProp13>$(MyProp11)</MyProp13>
<MSBuildTreatWarningsAsErrors>false</MSBuildTreatWarningsAsErrors>
</PropertyGroup>

<!--
Expand Down
Loading