-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Refactoring "Move type to ..." breaks preprocessor directives #19613
Comments
📝 We had to deal with this for StyleCop Analyzers, and believe we found a rather clever solution in the end. Rather than construct a new file from a particular syntax node, we duplicate the entire tree and then selectively remove different sets of nodes from each file. |
This was fixed already for 15.3 (I think by #16300 - @CyrusNajmabadi does that look right), though it leaves the |
@sharwell That's actually how this is implemented as well :) |
Yeah. This was fixed. But clearly the fix could use some work. If anyone wants to fix up the formatting, that would be totally great. |
@yvef I would not over complicate things. We can just detect some very common cases that go awry today and improve on them. :-) |
This still applies (17.9.2) and also carries over We have this file: public class Foo
{
#region Region1
public class NotBar
{
}
#endregion
#region Region2
public class Bar // Move type to 'Bar.cs'
{
}
#endregion
} After moving Foo.Bar to Bar.cs, we have (indentation is preserved as-is): // Foo.cs
public partial class Foo
{
#region Region1
public class NotBar
{
}
#endregion
#region Region2
#endregion
}
// Bar.cs
public partial class Foo
{
#endregion
#region Region2
public class Bar // Move type to 'Bar.cs'
{
}
#endregion
} |
Version Used: Visual Studio 2017 15.2.0+26430.6
Code to Reproduce:
Actual Behavior:
The text was updated successfully, but these errors were encountered: