Mangled quotes
Here's a contrived example:
throw new ArgumentNullException("", "");
Modify the code to append a string to the first parameter by typing a plus sign and a quotation mark:
throw new ArgumentNullException("" + ", "");
Close the string by typing a second quotation mark:
throw new ArgumentNullException("" + """, "");
The problem is that ReSharper inserts a single quotation mark in the first case and two quotation marks in the second case.
I reported this in JIRA and the the ticket was closed with the comment that this is expected and normal behavior. Did I actually read the comment correctly and that this is correct behavior?
Attachment not added (content type not allowed): "att1.html"
Please sign in to leave a comment.
Yes, this is an expected behavour.
Given the following case:
throw new ArgumentNullException("" + ", "");
Te caret is located INSIDE string literal, so pressing quote will introduce doublequote to not to break existing string literal
This is one of the rare cases where our typing assitance confuses user
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Jetbrains" <lothan@newsguy.com> wrote in message news:f92ldi$mmd$1@is.intellij.net...
Here's a contrived example:
throw new ArgumentNullException("", "");
Modify the code to append a string to the first parameter by typing a plus sign and a quotation mark:
throw new ArgumentNullException("" + ", "");
Close the string by typing a second quotation mark:
throw new ArgumentNullException("" + """, "");
The problem is that ReSharper inserts a single quotation mark in the first case and two quotation marks in the second case.
I reported this in JIRA and the the ticket was closed with the comment that this is expected and normal behavior. Did I actually read the comment correctly and that this is correct behavior?
Attachment not added (content type not allowed): "att1.html"
I wouldn't call it "expected".
Becuase in the original case, before the first quote it typed, it's obvious that the cursor is OUTSIDE of any string literal. Therefore, it should insert two quotes. Then when you type the closing quote, it would just step over the existing quote. No problem.
"Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in message news:f96lp7$tnq$1@is.intellij.net...
Yes, this is an expected behavour.
Given the following case:
throw new ArgumentNullException("" + ", "");
Te caret is located INSIDE string literal, so pressing quote will introduce doublequote to not to break existing string literal
This is one of the rare cases where our typing assitance confuses user
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Jetbrains" <lothan@newsguy.com> wrote in message news:f92ldi$mmd$1@is.intellij.net...
Here's a contrived example:
throw new ArgumentNullException("", "");
Modify the code to append a string to the first parameter by typing a plus sign and a quotation mark:
throw new ArgumentNullException("" + ", "");
Close the string by typing a second quotation mark:
throw new ArgumentNullException("" + """, "");
The problem is that ReSharper inserts a single quotation mark in the first case and two quotation marks in the second case.
I reported this in JIRA and the the ticket was closed with the comment that this is expected and normal behavior. Did I actually read the comment correctly and that this is correct behavior?
Attachment not added (content type not allowed): "att1.html"
I think I must be missing the point because in the example the caret is OUTSIDE the string literal. That is, the original code might be something like:
throw new ArgumentNullException("arg1", "blah blah"); What I want to do in this contrived example is to append a new string literal to the existing string literal, so I type a plus sign and one double quote. I expected ReSharper to insert the closing double quote for me, but it doesn't so I end up with: throw new ArgumentNullException("arg1" + ", "blah blah");
Note that ReSharper does not complete the string literal for me above, but I think it should. This is admittedly a contrived example, but it's the simplest example I can come up with to demonstrate the problem.
If I then complete the string literal and type the closing double quote, ReSharper inserts two double quotes:
throw new ArgumentNullException("arg1" + "arg2"", "blah blah"); Here, it seems that ReSharper mistakenly thinks it is outside the string literal when it is in fact inside a string literal. "Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in message news:f96lp7$tnq$1@is.intellij.net... Yes, this is an expected behavour. Given the following case: throw new ArgumentNullException("" + ", "");
Te caret is located INSIDE string literal, so pressing quote will introduce doublequote to not to break existing string literal
This is one of the rare cases where our typing assitance confuses user
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Jetbrains" <lothan@newsguy.com> wrote in message news:f92ldi$mmd$1@is.intellij.net...
Here's a contrived example:
throw new ArgumentNullException("", "");
Modify the code to append a string to the first parameter by typing a plus sign and a quotation mark:
throw new ArgumentNullException("" + ", "");
Close the string by typing a second quotation mark:
throw new ArgumentNullException("" + """, "");
The problem is that ReSharper inserts a single quotation mark in the first case and two quotation marks in the second case.
I reported this in JIRA and the the ticket was closed with the comment that this is expected and normal behavior. Did I actually read the comment correctly and that this is correct behavior?
Attachment not added (content type not allowed): "att1.html"
Hello,
>> Given the following case:
>> throw new ArgumentNullException("" + ", ""); >> Te caret is located INSIDE string literal, so pressing quote will introduce doublequote to not to break existing string literal > I think I must be missing the point because in the example the caret > is OUTSIDE the string literal. The first string literal is "". The second one is ", ". The third
one is ");", and it is not closed.
—
Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”
I think you're missing the point... either that or I am.
The second case only occurs because Resharper messes up and doesn't insert a
double quote when it should.
In the first example, the cursor is clearly outside any double quotes.
Typing a quote at that point should insert TWO quotes, with the cursor
inside them. Instead it breaks things by inserting only one, making a
"false string" that includes the comma, and then leaving the final false
string unclosed.
"Serge Baltic" <baltic@intellij.net> wrote in message
news:dc0986bf6ad028c9a81644e066f7@news.intellij.net...
>
>>> Given the following case:
>>> throw new ArgumentNullException("" + ", ""); > >>> Te caret is located INSIDE string literal, so pressing quote will >>> introduce > doublequote to not to break existing string literal > >> I think I must be missing the point because in the example the caret >> is OUTSIDE the string literal. > > The first string literal is "". The second one is ", ". The third
>
Paul Bradshaw wrote:
I found that:
When i have:
SomeMethod("abc" + ); and press ", then r# add two "" and place cursor into quotes, like this: SomeMethod("abc" + "");
this is OK and excepted, but when method have another parameter(string
type) after our first param string, like this:
SomeMethod("abc" + , "xxx"); and press ", then r# add only one " and place cursor after this quote, like this: SomeMethod("abc" + ", "xxx");
And this is bad, it does not add pair quote.
I Think is is bug, because if second param is not string "xxx", but for
example int 111, then it addes double quotes and place cursor right
place:
SomeMethod("abc" + "", 111);
--
Peter Sulek
terrorix@centrum.sk
XanaNews ver. 1.18.1.6
That is definitely a bug. If you haven't already, you should put that
information into a Tracker report.
"Peter Sulek" <terrorix@centrum.sk> wrote in message
news:f9p4a4$4hk$1@is.intellij.net...
>
>> I think you're missing the point... either that or I am.
>>
>> The second case only occurs because Resharper messes up and doesn't
>> insert a double quote when it should.
>>
>> In the first example, the cursor is clearly outside any double
>> quotes. Typing a quote at that point should insert TWO quotes, with
>> the cursor inside them. Instead it breaks things by inserting only
>> one, making a "false string" that includes the comma, and then
>> leaving the final false string unclosed.
>>
>>
>>
>> "Serge Baltic" <baltic@intellij.net> wrote in message
>> news:dc0986bf6ad028c9a81644e066f7@news.intellij.net...
>> > Hello,
>> >
>> > > > Given the following case:
>> > > > throw new ArgumentNullException("" + ", ""); >> > >> > > > Te caret is located INSIDE string literal, so pressing quote >> > > > will introduce >> > doublequote to not to break existing string literal >> > >> > > I think I must be missing the point because in the example the >> > > caret is OUTSIDE the string literal. >> > >> > The first string literal is "". The second one is ", ". The
>> > third one is ");", and it is not closed. —
>> > Serge Baltic
>> > JetBrains, Inc — http://www.jetbrains.com
>> > “Develop with pleasure!”
>> >
>> >
>
>
>
>
>
>
>
>
>
Paul Bradshaw wrote:
Created jira bug report -http://www.jetbrains.net/jira/browse/RSRP-47391
--
Peter Sulek
terrorix@centrum.sk
XanaNews ver. 1.18.1.6
Hello,
>>>> throw new ArgumentNullException("" + ", ""); > In the first example, the cursor is clearly outside any double quotes. The only thing that can be told “clearly” is the C# parsing result, which tells us that the caret is just in the beginning of the second string literal ", ". To make it clearer, let's replace a comma with a space (makes
no difference since inside a string literal):
("" + " "")
Is the caret inside a string literal now?
But, on the other hand, the caret is intuitively outside the string literal
from the user's point of view. A user sees the comma and gives it a higher
priority over the quotation marks (it's what he wants to write, after all).
Even though it does not agree with C# language itself.
Speaking of R#'s ability to work on broken code — we'd expect R# to behave
intuitively and help with commas in string literals. So yes, your request
is just reasonable. But, as the current behaior is formally correct, it will
not be understood when put as a bug — it's rather a “usability problem” or
a “new feature”.
—
Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”
Again, you're missing the point, Serge.
The problem is this (where | identifies the cursor):
("" + |, "")
If you type a quote, you get a SINGLE quote, even though you're CLEARLY
outside of a string. This results in:
("" + "|, "")
Which is just flat-out wrong. It should be:
("" + "|", "")
You seem to be getting confused about the before and after. I hope it's
clear to you now.
"Serge Baltic" <baltic@intellij.net> wrote in message
news:dc0986bf6bac68c9ad90a0c90272@news.intellij.net...
>
>>>>> throw new ArgumentNullException("" + ", ""); > >> In the first example, the cursor is clearly outside any double quotes. > > The only thing that can be told “clearly” is the C# parsing result, which > tells us that the caret is just in the beginning of the second string > literal ", ". To make it clearer, let's replace a comma with a
>
>
>
>
>
>
Paul Bradshaw wrote:
Its right, becase when expression is:
("" + |, 5) ->> number 5 instead of empty string in example above then
r# makes correct:
("" + "|", 5), and this must be definitely a bug
(http://www.jetbrains.net/jira/browse/RSRP-47391)
--
Peter Sulek
terrorix@centrum.sk
XanaNews ver. 1.18.1.6
The intent is to append a new string, but ReSharper can't figure out proper
string boundaries when two strings are adjacent in the same
statement--whether separated by a space or a comma. I've actually run across
this problem in other areas when attempting to insert variables into
existing strings; e.g. modifying
throw new IndexOutOfRangeException("The parameter is outside the range of
the array.")
to
throw new IndexOutOfRangeException("The parameter index (" + index + ") is
outside the range of the array (0 to " + array.Length + ")");
The underlying issue here is that ReSharper is often confused when
attempting to determine string boundaries and inserts either a single quote
when it should insert a two quotes or inserts two quotes when it should
insert one quote. I understand this may internally be a design or feature
issue. In my mind, this is a bug because it doesn't work as expected.
"Serge Baltic" <baltic@intellij.net> wrote in message
news:dc0986bf6bac68c9ad90a0c90272@news.intellij.net...
>
>
>
>
>
>