controlflow / resharper-heapview

ReSharper Heap Allocations Viewer plugin
MIT License
304 stars 28 forks source link

Incorrect boxing highlight for string concatenation and modern compilers #73

Closed citizenmatt closed 1 year ago

citizenmatt commented 4 years ago

The code var x = "Hello " + longValue will show a highlight for boxing of the longValue variable. It appears previous compilers would box the value and call String.Concat(object, object). Modern compilers will call longValue.ToString() and then call String.Concat(string, string)

neonb commented 3 years ago

myPrimitive.ToString() will still allocate a string object, if it hasn't been interned, right? In any case, if modern compilers skip the boxing then the plugin's message at least is incorrect.

controlflow commented 2 years ago

Partially fixed, boxing is not reported now. Will report implicit .ToString() invocation

controlflow commented 1 year ago

Both allocations are now reported: image image

Boxing is eliminated, but implicit .ToString() call still allocates a new string (at least for BCL's numeric types)