resharper-heapview icon indicating copy to clipboard operation
resharper-heapview copied to clipboard

Methods where all paths allocate should be shown as allocations (optional)

Open viktor-svub opened this issue 10 years ago • 5 comments

If this is possible with R# engine... Currently a simple generic static factory hides the allocation.

viktor-svub avatar Dec 16 '14 16:12 viktor-svub

Can you please clarify? Do you want allocations analyzer to be intra-procedural or something?

controlflow avatar Dec 29 '14 15:12 controlflow

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.

viktor-svub avatar Dec 29 '14 19:12 viktor-svub

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]).

ltrzesniewski avatar Jul 17 '17 17:07 ltrzesniewski

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.

viktor-svub avatar Jul 17 '17 17:07 viktor-svub

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.

ltrzesniewski avatar Jul 17 '17 20:07 ltrzesniewski