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

Expander refactoring [property tracking analyzers prerequisity] #10102

Merged
merged 8 commits into from May 20, 2024

Conversation

JanKrivanek
Copy link
Member

@JanKrivanek JanKrivanek commented May 3, 2024

Contributes to #9883 (spinoff from #10009 - focusing on parts not related to BuildCheck)

Note

There is no new functionality in this PR - just refactoring and code moving. It is required for the followup PR(s) for property tracking analyzers

Context

Expander is using LoggingContext in some of the execution paths, but in it usually has a default value of null - so we end up with literaly hundrets of calling paths where we cannot be sure whether LoggingContext is available or not. The LoggingContext is appealing for a data pub-sub, so let's make sure it's available throughout the Expander calls, while at the same let's simplify the code a bit

Changes Made

  • Added constructors to Expander to pass LoggingContext wherever possible (the only exception is the Expander usages from the ToolsetReader - where we do not know the build context yet).
  • Removed explicit LoggingContext arg from the Expander methods
    Reason: Went through all the methods in Expander and all the possible caller chains (there were many hunderts of them) - and found out there is just a single case where LoggingContext passed to expander calls differ from the LoggingContext used to construct the Expander
  • Added ItemBucket.UpdateLoggingContext
    Reason: The single differing case was in TargetEntry.ExecuteTarget where ProjectLoggingContext was used to construct the Expander, but then TargetLogginContext was used to transitively call the methods. So the updating of the context was used to bridge this case
  • Moved the conditioning of PropertyTrackingEvaluatorDataWrapper into the type - so that in the folowup PR we can use the type to feed data to analyzers even if proprty tracking logging is not requested
  • Renamed UsedUninitializedProperties -> PropertiesUsageTracker
  • Added more info to calls of PropertiesUsageTracker
    • Info about context in which the property was expanded
    • Moved the code to make this class responsible for deciding about uninitialized reads

Testing

Refactored and resued existing tests (as there is no new functionality)

@ladipro ladipro self-requested a review May 7, 2024 09:17
Copy link
Member

@ladipro ladipro left a comment

Choose a reason for hiding this comment

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

Thank you, this is good stuff. Leaving a few comments inline.

src/Build/Evaluation/Expander.cs Outdated Show resolved Hide resolved
src/Build/Evaluation/Expander.cs Show resolved Hide resolved
@JanKrivanek JanKrivanek merged commit c3d24bb into main May 20, 2024
10 checks passed
@JanKrivanek JanKrivanek deleted the exp/expander-refactor branch May 20, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants