-
Notifications
You must be signed in to change notification settings - Fork 4k
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
IncrementalValuesProvider.GroupBy #72667
Comments
Am I correct in understanding that calling .Collect() makes an IncrementalGenerator non-cache friendly? I think I may be running into this issue when I collect to do some deduping. |
You can call
|
So |
Incremental generators include many steps in the graph. Each step is cached depending on its own inputs and outputs. Most changes to a project result in at least one step somewhere running. As best I can tell, the proposed |
|
@chsienki I think we really need to invest in:
There's really no reason at all to have no comparer here, and it means a collect call will break incrementality unless a user knows to go fix this up. |
@CyrusNajmabadi I'm not sure that aspect is a problem today. I've seen many source generators opt for Providing a default comparer for |
@sharwell public static IncrementalValueProvider<ImmutableArray<TSource>> Collect<TSource>(this IncrementalValuesProvider<TSource> source) => new IncrementalValueProvider<ImmutableArray<TSource>>(new BatchNode<TSource>(source.Node), source.CatchAnalyzerExceptions); So you get an |
So if I'm understanding the semantics of |
That should be fine. If none of the inputs to the
There is no public API to alter the comparer for |
There is. You call . WithComparer afterwards |
Right. That's the exact problem. You get a different input, but you end up creating conceptually the same output (which is very very possible). As far as the driver is concerned, because it's a new IA, it is different, and it will not stop the incremental pipeline. |
Background and Motivation
I've been responding to this user report about an issue with the STJ source generator where adding
JsonSerializable
allocations in two separate declarations of the same partial context class will result in the generator emitting code twice for the same type, resulting in conflicts.While this doesn't appear to be a common enough scenario, it made me think that there's no real way in which we could group elements of an
IncrementalValuesProvider<T>
by a given key without use ofCollect()
which typically forces re-evaluation of every element in the incremental collection. It seems that aGroupBy
-like combinator which only triggers downstream evaluation for keys that have been updated might be necessary, although I couldn't find a good way to obtain this with the existing APIs.Proposed API
Usage Examples
The text was updated successfully, but these errors were encountered: