-
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
SyntaxTree.GetLineMappings #53752
Comments
Ping @333fred @dotnet/roslyn-api-owners |
Why make |
Also, API owners should be the ones applying ready-for-review, just as an FYI. @CyrusNajmabadi as the other API owner of syntax. |
@333fred The caller might not necessarily need to enumerate all of the mappings if it only looks for the first one matching some criteria. |
Is calculating the mappings expensive? I guess I don't see the benefits that |
There can be 1000s of |
Do we think that's a common use case? If needing to find just one span is going to be the thing people need to do, it seems to me like the appropriate API shape would instead be |
I don't see why IEnumerable is bad. |
We have plenty of precedence here for using IEnumerable in our apis. Usually teh core question is: will this be iterated many times during expected consumption. In that case, we def want IMmutableArray to effectively make the later consumption 'effectively free'. In other words, no allocations to consume. No virtual indirecitons, etc. However, for stuff that really may be computed lazily, and which is only intended to be read a tiny handful of times per user scenario, an IEnumerable is fine. So it comes down to how @tmat thinks this will be used for EnC. If it's just going ot be read once/twice while doing some mapping operation against other data, then that's fine. If we think this data will need to be read a lot though, then we should realize this as an ImmutableArray. |
The method provides another view of data already stored in an array in the underlying implementation (essentially just a translation). EnC currently uses it in multiple ways: 1) enumerates all items 2) finds first mapping that contains given mapped span (note that this requires O(n) since the underlying array is sorted by unmapped location, not mapped), 3) checks if there are any significant line mappings by calling I believe IEnumerable is good for all of these use cases. |
Thanks, this was the context I was missing. Provided @CyrusNajmabadi has no objections, I think this is fine to move ahead. We'll review in the next API review session, but implementation work doesn't need to be gated on it. |
API Review
|
Background and Motivation
EnC analyzer requires the ability to enumerate all
#line
mappings in a source file.Proposed API
Usage Examples
https://github.com/dotnet/roslyn/pull/53735/files#diff-5ee00551d4ea54b98dfc33510c5ea4be279cd1cc11d40a2329a9ad506e75681bR183
Alternative Designs
Risks
The text was updated successfully, but these errors were encountered: