Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDE options to control the sorting of fields and properties #4778

Closed
conniey opened this issue Aug 25, 2015 · 6 comments
Closed

IDE options to control the sorting of fields and properties #4778

conniey opened this issue Aug 25, 2015 · 6 comments

Comments

@conniey
Copy link
Member

conniey commented Aug 25, 2015

Steps to Reproduce

  1. Create a WPF Application
  2. Open MainWindow.xaml.cs
  3. Type the following: string field;
    public partial class MainWindow : Window
    {
        string field;

        public MainWindow()
        {
            InitializeComponent();
        }
    }
  1. Press Ctrl+.
  2. Select "Encapsulate field: 'field' (usages reference field)" and press Enter

Expected
Behaviour in VS2013

Actual

  1. Field is generated at the bottom of the class declaration (sometimes it is generated in the correct location though.. right below the field declaration)
  2. Unnecessary new lines are added to the getter/setter
    image
@Pilchie Pilchie added the Bug label Aug 26, 2015
@Pilchie Pilchie added this to the 1.1 milestone Aug 26, 2015
@Pilchie
Copy link
Member

Pilchie commented Aug 26, 2015

The newlines are also tracked by http://connect.microsoft.com/VisualStudio/feedback/details/1617595/incorrectly-formats-source-code-when-using-the-encapsulate-field-command.

The property placement may be by design, but we should understand the difference.

@rchande
Copy link
Contributor

rchande commented Sep 1, 2015

The newline aspect of this is tracked by #84.

@rchande rchande changed the title "Encapsulate field" does not place generated property in correct position and adds unnecessary new lines IDE options to control the sorting of fields and properties Sep 1, 2015
@rchande
Copy link
Contributor

rchande commented Sep 1, 2015

Generally, Roslyn inserts properties after constructors, as controlled by the CSharpDeclarationComparer. We'll use this bug to track adding options to modify that sort order.

@rchande rchande removed this from the 1.1 milestone Sep 1, 2015
@rchande rchande removed their assignment Sep 1, 2015
@Pilchie Pilchie added this to the Unknown milestone Sep 2, 2015
@galastur
Copy link

Really annoying all those extra lines when generating the get/set for a property...please let us have it as it was with VS 2013 !!!

@Pilchie
Copy link
Member

Pilchie commented Jan 5, 2017

Note - when implementing, it would probably be a good idea to re-use the idea of Symbol Specification from naming styles to define this ordering.

@CyrusNajmabadi
Copy link
Member

I don't repro this. The fields go in teh right place, and the property formatting is correct.

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants