Why does R# create a property, but it is not an auto property?

I add a non existing property to a class:

SomeClass.IDoNotExist

I hit the context hot key and select the option to Create a Property.  I'd expect an auto property.  But R# generates a weird property where get returns null and set does nothing.  Or after looking at options I see a throw NotImplemented or make uncompilable code.  All of that gets in my way.  Why won't R# just make an auto prop?  Am I missing something?

Nick

3 comments
Avatar
Andrey Serebryansky
Comment actions Permalink

Hello Nick
     Could you please attach a couple of screenshots demonstrating the process and the quick-fix that you're using. When you use 'Create property XYZ' quick-fix, ReSharper should expand a template and after you enter the property type should suggest three possible implementation options: 'Auto property', 'Create and use xyz as backing field' and 'Default implementation'. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Ok finally got screenshots
The option brought up by the quick-fix key
Create Property.png

And the result it created in the class:

CreatedProperty.jpg
I have no doubt I have some setting all crazy, but I don't know which one.

0
Avatar
Andrey Serebryansky
Comment actions Permalink

Hello Nick
     Actually, you just need to take it a step further: on the last screenshot you see that 'int' is inside a red rectangle which means that ReSharper expects you to provide the type of the property. After you enter the type (or leave it as is) and press Enter, ReSharper will suggest available implementation options for the property. Let me know if this helps. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0

Please sign in to leave a comment.