-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Fix a couple of bugs in SG #55032
Fix a couple of bugs in SG #55032
Conversation
- Ensure that .Collect() reports as cached if all the inputs are cached - Don't use user comparer for matching inputs
@dotnet/roslyn-compiler for review please :) |
@@ -38,7 +38,7 @@ public NodeStateTable<T> UpdateStateTable(DriverStateTable.Builder graphState, N | |||
var inputItems = _getInput(graphState); | |||
|
|||
// create a mutable hashset of the new items we can check against | |||
HashSet<T> itemsSet = new HashSet<T>(_comparer); | |||
HashSet<T> itemsSet = new HashSet<T>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why aren't we using the custom comparer here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the bug. Because these are 'input' items (compilations / syntax trees / additional files etc) we control their lifetime. If the user comparer is used they can say that two additional files are different when they are not; that breaks our internal assumptions around comparers that they can only be used to change a modified value back to a cached value.
Basically the only time the comparer should be used is if we think the item has changed, the user has to the ability to override it.
|
||
AssertTableEntries(table, new[] { (1, EntryState.Cached), (2, EntryState.Cached), (3, EntryState.Cached) }); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int index = 0; | ||
foreach (var entry in table) | ||
{ | ||
Assert.Equal(expected[index].item, (IEnumerable<T>)entry.item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using the AssertEx
helpers that do nice output diffing to make failures more diagnosable.
@chsienki do you still plan on merging this for p3? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks (iteration 2)
.Collect()
reports as cached if all the inputs are cachedFixes #54855