Skip to content

Make it easier to track property value origin - log properties that were used for assignment #12612

@ayeltsov

Description

@ayeltsov

Summary

Request: log list of properties that went into calculating property. This will allow tooling to be enhanced to follow up the chain of assignments.

Background and Motivation

Details:

There are awesome events like PropertyReassignmentEventArgs, PropertyInitialValueSetEventArgs, UninitializedPropertyReadEventArgs that are helpful with troubleshooting properties.

However, even with these it can be hard to follow the sequence assignments and condition checks that lead to assignment. For example, our overly customized build has something like this:

<MyProjectObjectPath Condition="'$(MyFlatObjectPath)'!=''">$(MyObjectRoot)\$(MyFlatObjectPath)\$(_ProjectHash)\</MyProjectObjectPath>

When some of these are also calculated, it gets hard to follow the chain manually.

Hence the request: log list of properties that went into calculating property. This will allow tooling to be enhanced to follow up the chain.

We should probably also log property generation id (that is increased on every assignment). This way if property is reassigned multiple times, we'd know exactly which generation was used.

Proposed Feature

Put feature under additional flag in MsBuildLogPropertyTracking since it's even more expensive.

When enabled, this would add list of properties used in evaluation. Something like List<Tuple<string PropertyName, int PropertyGeneration>>.
We should probably log not just events that did modify property but also ones that did not. When assignment condition is not met, developer could be troubleshooting "why is this not getting set" issue.

So feature shape could look like:

  • Additional flag to enable feature
  • Log generations of property (every change updates generation)
  • Add PropertyNotAssignedEventArgs (for the cases when assignment was skipped due to false condition)
  • Add list of properties that went into calculation (probably to base class of events?)

Should probably get feedback from current maintainers of log viewers if they see potential of adding visualization of property ancestry to the tool.

Alternative Designs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions