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

Extract New Class Refactoring Request #73178

Open
TonyValenti opened this issue Apr 22, 2024 · 0 comments
Open

Extract New Class Refactoring Request #73178

TonyValenti opened this issue Apr 22, 2024 · 0 comments
Labels
Area-IDE Feature Request Need Design Review The end user experience design needs to be reviewed and approved.
Milestone

Comments

@TonyValenti
Copy link

TonyValenti commented Apr 22, 2024

Brief description:
Sometimes code has properties like this:

    public class Foo {
        public string M1_Value1 { get; set; }
        public string M1_Value2 { get; set; }
        public string M1_Value3 { get; set; }
        public DateTime M2_Value1 { get; set; }
        public DateTime M2_Value2 { get; set; }
        public DateTime M2_Value3 { get; set; }
    }

Which should, ideally, be code like this:

    public class Foo {
        public M1 M1s { get; set; } = new();
        public M2 M2s { get; set; } = new();
    }

    public class M1 {
        public string Value1 { get; set; }
        public string Value2 { get; set; }
        public string Value3 { get; set; }
    }

    public class M2 {
        public DateTime Value1 { get; set; }
        public DateTime Value2 { get; set; }
        public DateTime Value3 { get; set; }
    }

A refactoring should exist that enables this kind of conversion.

Languages applicable:
Both, but I only care about C#

Code example that the analyzer should report:
See above

Additional information:
This is identical to the "Extract Base Class" refactoring except the members should be wrapped into a child class instead of a base class.

It is OK if it simply moved the members and a subsequent refactoring would be used to rename them.
For example, after the first refactoring, you might have:


    public class Foo {
        public M1 M1s { get; set; } = new();
        public DateTime M2_Value1 { get; set; }
        public DateTime M2_Value2 { get; set; }
        public DateTime M2_Value3 { get; set; }
    }

    public class M1 {
        public string M1_Value1 { get; set; }
        public string M1_Value2 { get; set; }
        public string M1_Value3 { get; set; }
    }

Documentation requirements:
When this analyzer is implemented, it must be documented by following the steps at Documentation for IDE CodeStyle analyzers.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Apr 22, 2024
@genlu genlu added Need Design Review The end user experience design needs to be reviewed and approved. and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 24, 2024
@genlu genlu added this to the Backlog milestone Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request Need Design Review The end user experience design needs to be reviewed and approved.
Projects
Status: In Queue
Development

No branches or pull requests

2 participants