Request: Option to create autoproproperty

Hi,

With the following code (created automatically when you select Create Property):

        protected object CurrentItem
        {
            get { throw new NotImplementedException(); }
            set { throw new NotImplementedException(); }
        }


It would be great if you could move the cursor into CurrentItem and have the option to create an AutoProperty/Property with backing field etc.

The alternative is creating a field and then Encapsulate Field (which of course you can do at the moment). However, I find  myself deleting the text between the curly brackets, typing {get;set:} and selecting "CurrentItem" and then To Property With Backing Field.

Along the same lines. When implementing an interface with only one method/property it would be nice to have the option to create AutoProperty, Backing Field etc - at the moment you only get this option if implementing an interface with more than one method.

Regards
Jeremy
0
3 comments

I was missing this feature too. So I defined a replacement in the Pattern Catalog like this:

search:

public $TYPE$ $IDENTIFIER$
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}

replace:

public $TYPE$ $IDENTIFIER$ { get; set; }


where $TYPE$ and $IDENTIFIER$ are placeholders of type TYPE and IDENTIFIER
(and severity set to hint)


The pattern above would work on public properties, I don't know how to match public/protected/internal... in one pattern, so you probably have to define a separate pattern for protected properties.

0
Avatar
Andrey Serebryansky

Hello Jeremy,

ReSharper should suggest 'Auto-property', 'Create and use ... as backing
field' and 'Default body' implementation options when one uses 'Create Property'
quick-fix. Do I understand correctly that ReSharper doesn't give implementation
options in your case?
As to implementing properties from an interface, you can use ReSharper |
Edit | Generate Code | Implement missing members, which will show a dialog
with implementation opions even if there's only one property/method to implement.
Thank you!

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hi,

With the following code (created automatically when you select Create
Property):

protected object CurrentItem
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
It would be great if you could move the cursor into CurrentItem and
have the option to create an AutoProperty/Property with backing field
etc.

The alternative is creating a field and then Encapsulate Field (which
of course you can do at the moment). However, I find  myself deleting
the text between the curly brackets, typing {get;set:} and selecting
"CurrentItem" and then To Property With Backing Field.

Along the same lines. When implementing an interface with only one
method/property it would be nice to have the option to create
AutoProperty, Backing Field etc - at the moment you only get this
option if implementing an interface with more than one method.

Regards
Jeremy
---
Original message URL:
http://devnet.jetbrains.net/message/5275155#5275155



0

marcus23 wrote:

Hello Jeremy,

ReSharper should suggest 'Auto-property', 'Create and use ... as backing

In some cases, you get the "throw new NotImplementedException();" code without asking (e.g. when you add an abstract method to a class and then select "implement in derived classes").

0

Please sign in to leave a comment.