resharper-heapview
resharper-heapview copied to clipboard
Methods where all paths allocate should be shown as allocations (optional)
If this is possible with R# engine... Currently a simple generic static factory hides the allocation.
Can you please clarify? Do you want allocations analyzer to be intra-procedural or something?
I'm not sure if the R# SDK allows to "annotate" an analyzed method with custom information - but if it was possible, it would allow to pass the information up the call tree, i.e. mark a method as "always allocating" and show it as such, w/o additional analysis.
Maybe it would be easier to support a manual annotation, like an [Allocates] attribute on a method which allocates (using the same annotation mechanism than other R# attributes like [NotNull]).
I would expect the manual annotation way to be very brittle, depending on the author to correctly inspect all paths in the fist place, and 3rd-party annotations being invalidated by allocations optimized away, e.g. when rewriting a yield enumerator to a struct-based one.
Yes, I wouldn't put these annotations everywhere. They'd just be for a few methods I know to be expensive. And for those I'd prefer a false positive than a false negative anyway.