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

Code Fix Provider for SA1402 adds extra space #3876

Open
MattFromRVA opened this issue Jul 16, 2024 · 0 comments
Open

Code Fix Provider for SA1402 adds extra space #3876

MattFromRVA opened this issue Jul 16, 2024 · 0 comments

Comments

@MattFromRVA
Copy link
Contributor

MattFromRVA commented Jul 16, 2024

While working on PR #3873 for #3109 I noticed the following errors when applying the original code fix for SA1402 for two edge cases.

If there are no using statements then a space is added between the namespace and the class in the new file:

namespace TestNamespace
{
    public class TestClass
    {
        public int MyProperty { get; set; }
    }

    public class TestClass2
    {
        public string MyProperty { get; set; }
    }
}

New File:

namespace TestNamespace
{

    public class TestClass2
    {
        public string MyProperty { get; set; }
    }
}

Similarly if there is a preprocessor directive with using statements then a space is added between the last using statement and the ending directive:

namespace TestNamespace
{
#if true
    using System;
#endif

    public class TestClass
    {
        public DateTime MyDate { get; set; }
    }

    public class TestClass2
    {
        public DateTime MyDate2 { get; set; }
    }
}

New File:

namespace TestNamespace
{
#if true
    using System;

#endif

    public class TestClass2
    {
        public DateTime MyDate2 { get; set; }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant