Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-469414: Boxing allocation vs. ToString()

$
0
0
Reporter Brett Stime (steamer25) Brett Stime (steamer25)
Created Apr 25, 2018 11:07:45 PM
Updated Apr 26, 2018 1:24:25 PM
Subsystem Code Analysis - C#
Assignee Ivan Serduk (IvanSerduk)
Priority Normal
State Submitted
Type Bug
Fix version No Fix versions
Affected versions No Affected versions
Fixed In Version ReSharper Undefined
VsVersion All Versions

When trying to convert a simple numeric primitive to a string, Rider helpfully warns that a boxing allocation will be incurred. E.g.,

Console.Write("foo" + 3);  // Red underline under 3

...according to this 2014 blog entry the warning can be resolved by adding .ToString() to the numeric:

Console.Write("foo" + 3.ToString());  // .ToString() grayed out

...if you do that, Rider flags the code with a new inspection notification indicating that the call to .ToString() is redundant. It'd be nice if Rider would warn about the boxing allocation but not consider the call to .ToString() as redundant in cases where it prevents the boxing allocation.

Version: RD-181.4379.1191
Timezone: America/Chicago
Evaluation: false
Environment: RD-181.4379.1191, JRE 1.8.0_152-release-1136-b23x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.13.4 unknown, screens 1440x900, 1920x1200


Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>