Refactor convert property to auto property not available

I see 2 other posts but no answer information. I am trying to use this refactor Convert Property to Auto-Property refactoring | ReSharper Documentation

For a class 

public class xxxxxxx
{

   private string xxx;

   private byte totalValueField;

   private string aliasField;

   private bool stackableField;

       
   public string PromoCode
   {
       get
       {
           return this.promoCodeField;
       }
       set
       {
           this.promoCodeField = value;
       }
   }

I notice a few things:

I do not see this in the refactor options:

I do not see it in the refactor options.

 

I do not see the property indicated in the docs for a keyboard shortcut.

 

 

I did a product update to make sure I had latest. 

 

When I do a code cleanup, I get the property in question set to

a different body style. A format specified elsewhere is the body style. But my code clean up says use auto property when possible.

I am doing something very wrong. Does anyone know what? Thanks

0
3 comments

Hello Vthomeschoolmom, thank you for your question. 

  1. Does the problem happen for a newly created solution or it's solution specific problem?
  2. Could you share a screenshot that shows the missing ReSharper_Property2Auto command?
  3. By the way, which version of ReSharper (ReSharper | Help | About JetBrains ReSharper) are you using?
  4. What do you have written at the top of the file on the first 5 lines? It's not visible on the screenshot.
  5. Please check if quick-fixes in ReSharper | Options | Code Inspection | Inspection Severity and context actions in ReSharper | Options | Code Editing | Context Actions related to auto-property conversion are enabled.
  6. Also, check what property style is set in ReSharper | Options | Code Editing | C# | Syntax Style | Code body | Properties, indexers, and events — or simply send me your settings (`ReSharper | Manage Options => "Export to File"` in the context menu for each layer), and I’ll take a look.  You can upload settings files to JB server and share the Upload ID with me.

Thank you!

0

Vthomeschoolmom it looks like you're using a SerializableAttribute for the class. In this case, this is the correct behavior for types marked with SerializableAttribute. Here's an issue in our tracker that describes why converting properties to auto-properties can be dangerous for serializable types: RSRP-453792 Serializable objects SHOULD BE able to convert properties to auto-properties.

1

Please sign in to leave a comment.