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

RSRP-182597: Extract variable -> const -> RS does not use const prefix in suggested variable name.

$
0
0
Reporter Stefan (GreenMoose) Stefan (GreenMoose)
Created Jun 16, 2010 11:36:51 AM
Updated Apr 7, 2018 11:08:42 AM
Subsystem Refactorings
Assignee Alisa Afonina (alisa.afonina)
Priority Major
State Open
Type Feature
Fix version Backlog
Affected versions 2018.1
Fixed In Version ReSharper Undefined
VsVersion All Versions
[5.1.1708]

When extracting a local variable, and choosing the const option, RS does not name it according to const prefix.
(don't know if this should be treated as a bug or "feature request" but I filed it under bug)

Repro:
Naming convention for local constants: lowerCamelCase with prefix "c_"

 public class Foo
{
//This is private field constant, i.e. lowerCamelCase with prefix "_c_"
private const int _c_dummyConstValue = 123;
public void Bar()
{
const int c_exampleVariable = 12; //Example of local constant naming

var dummy1 = _c_dummyConstValue;
var dummy2 = _c_dummyConstValue;
}
}


Extract variable on _c_dummyConstValue; (2 occurrences) to const int. Suggested variable name is not using the constant prefix:

 const int dummyConstValue = _c_dummyConstValue;
var dummy1 = dummyConstValue;
var dummy2 = dummyConstValue;
and RS immediately warns about incorrect naming (missing c_ prefix).



I suppose RS could be a little smarter here and check the const-prefix if I choose "const int" instead of int?

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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