controlflow / resharper-postfix

ReSharper Postfix Templates plugin
MIT License
127 stars 12 forks source link

IsNullOrEmpty completion in if generates bad code #17

Closed csharpner closed 9 years ago

csharpner commented 10 years ago

I have a variable named exitFileRecord of a POCO type. I write this code:

if (exitFileRecord._agentName.isnullor

I'm prompted with a popup for code completion that properly changes it to:

if (string.IsNullOrEmpty(exitFileRecord._agentName)

But when I continue and add this:

if (string.IsNullOrEmpty(exitFileRecord._agentName) && exitFileRecord._cert.issnullor

when I type that last "r", I have the pop up prompt with the suggested code change (which is correct in the popup), it changes it and ends up with this:

if (string.IsNullOrEmpty(exitFileRecord._agentName) && string.IsNullOrEmpty(String.IsNullOrEmptyd._cert))

That's not my typo on the Emptyd._cert. If leaves out my variable entirely and puts string.IsNullOrEmpty twice like you see here, followed by "d._cert".

controlflow commented 9 years ago

Is this still happens for you? Can't reproduce it at all :(

ulex commented 9 years ago

I'm not quite sure if it's the same bug: out

I'm tried to understand what happening, but stuck in very funny place :)

hazzik commented 9 years ago

Hi, I have the same in Razor Views.

@if (Model.MemberFullName.isnu

ctrl+enter, enter

@if (string.IsNullOrEmpty(String.IsNullOrEmptyullName)

R#9, VS2012 update 4

iccfish commented 9 years ago

I think I have the same issue...... And I've post it on youtrack: https://youtrack.jetbrains.com/issue/RSPL-6375?query=Subsystem%3A+PostfixCompletion

controlflow commented 9 years ago

YAY, finally reproduced this, looks like all you have 'Automatically insert parentheses after completion' setting turned off...

controlflow commented 9 years ago

Fix will be available soon in version >2.0.9, thank you all for your feedback!

iccfish commented 9 years ago

Thanks, just for information, I HAVE to turn 'Automatically insert parentheses after completion' off due to this option will cause more major issue in code completion: https://youtrack.jetbrains.com/issue/RSRP-426530

iccfish commented 9 years ago

Just for a hello... I wonder if could tell me about the roadmap about new version due to this issue bothers me many times a day..

controlflow commented 9 years ago

Fix available in version 2.1 (in both R# 8.x and R# 9.x builds), just uploaded to resharper gallery.