[221] [VS2005] Extract variable within switch

Hi,

I tried extracting variables from string literals in a switch statement,
but R# puts the extracted string within the switch statement instead of
above:

switch(type){
case "Numeric":
break;

case "MultipleChoice":
break;
}

now extract a variable from "Numeric", R# turns it into this:

switch(type){
private const string Numeric="Numeric";

case Numeric:
break;

case "MultipleChoice":
break;
}

Regards,

Wiebe

3 comments
Comment actions Permalink

Additionally (ok this is a little trivial), since it's in within a case
label, only constants are allowed so it would be nice if the 'const'
checkbox is automatically checked. :)

For me it would be nice anyway to have 'const' checked by default if a
string literal is extracted to a variable...

Thanks!

Wiebe Tijsma wrote:

Hi,

I tried extracting variables from string literals in a switch statement,
but R# puts the extracted string within the switch statement instead of
above:

switch(type){
case "Numeric":
break;

case "MultipleChoice":
break;
}

now extract a variable from "Numeric", R# turns it into this:

switch(type){
private const string Numeric="Numeric";

case Numeric:
break;

case "MultipleChoice":
break;
}

Regards,

Wiebe

0
Comment actions Permalink

Hello Wiebe,

Thanks for reporting the bug. Could you also please submit it to the bugtracker
(www.intellij.net/tracker/resharper/browse) to be notified when it's fixed?

Oleg Stepanov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Additionally (ok this is a little trivial), since it's in within a
case label, only constants are allowed so it would be nice if the
'const' checkbox is automatically checked. :)

For me it would be nice anyway to have 'const' checked by default if a
string literal is extracted to a variable...

Thanks!

Wiebe Tijsma wrote:

>> Hi,
>>
>> I tried extracting variables from string literals in a switch
>> statement, but R# puts the extracted string within the switch
>> statement instead of above:
>>
>> switch(type){
>> case "Numeric":
>> break;
>> case "MultipleChoice":
>> break;
>> }
>> now extract a variable from "Numeric", R# turns it into this:
>>
>> switch(type){
>> private const string Numeric="Numeric";
>> case Numeric:
>> break;
>> case "MultipleChoice":
>> break;
>> }
>> Regards,
>>
>> Wiebe
>>


0
Comment actions Permalink

Hi Oleg,

Thanks, done added #19888
(http://www.intellij.net/forums/thread.jsp?forum=35&thread=204235)

Wiebe

Oleg Stepanov (JetBrains) wrote:

Hello Wiebe,

Thanks for reporting the bug. Could you also please submit it to the
bugtracker (www.intellij.net/tracker/resharper/browse) to be notified
when it's fixed?

Oleg Stepanov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>> Additionally (ok this is a little trivial), since it's in within a
>> case label, only constants are allowed so it would be nice if the
>> 'const' checkbox is automatically checked. :)
>>
>> For me it would be nice anyway to have 'const' checked by default if a
>> string literal is extracted to a variable...
>>
>> Thanks!
>>
>> Wiebe Tijsma wrote:
>>
>>> Hi,
>>>
>>> I tried extracting variables from string literals in a switch
>>> statement, but R# puts the extracted string within the switch
>>> statement instead of above:
>>>
>>> switch(type){
>>> case "Numeric":
>>> break;
>>> case "MultipleChoice":
>>> break;
>>> }
>>> now extract a variable from "Numeric", R# turns it into this:
>>>
>>> switch(type){
>>> private const string Numeric="Numeric";
>>> case Numeric:
>>> break;
>>> case "MultipleChoice":
>>> break;
>>> }
>>> Regards,
>>>
>>> Wiebe
>>>


0

Please sign in to leave a comment.