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

SA1133 batch code fix does half the work #1879

Closed
vbfox opened this issue Dec 1, 2015 · 5 comments
Closed

SA1133 batch code fix does half the work #1879

vbfox opened this issue Dec 1, 2015 · 5 comments
Assignees
Milestone

Comments

@vbfox
Copy link

vbfox commented Dec 1, 2015

Given the following code (Using the JetBrains.Annotations NuGet package):

using JetBrains.Annotations;

namespace Stylecop_rc1_bug_repro
{
    class Foo
    {
        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo1{ get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo2{ get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo3 { get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo4{ get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo5{ get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo6{ get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo7{ get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo8{ get; set; }

    }
}

Applying SA1133 code fix on document scope give :

using JetBrains.Annotations;

namespace Stylecop_rc1_bug_repro
{
    class Foo
    {
        [CanBeNull]
        [UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo1 { get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo2 { get; set; }

        [CanBeNull]
        [UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo3 { get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo4 { get; set; }

        [CanBeNull]
        [UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo5 { get; set; }

        [CanBeNull, UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo6 { get; set; }

        [CanBeNull]
        [UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo7 { get; set; }

        [CanBeNull]
        [UsedImplicitly(ImplicitUseKindFlags.Assign)]
        public string Foo8 { get; set; }

    }
}

(VS2015 update 1, StyleCop 1.0 RC1)

@vbfox
Copy link
Author

vbfox commented Dec 1, 2015

BTW Running the code fix a second time finishes the work cleanly.

@sharwell
Copy link
Member

sharwell commented Dec 1, 2015

Assigning to 1.0 for investigation, but I expect this will end up as a post-1.0 improvement.

/cc @vweijsters

@NikolayIT
Copy link
Member

I am just guessing here but I have a good feeling that fixing #1878 will also fix this issue.

@pdelvo
Copy link
Member

pdelvo commented Dec 2, 2015

@vweijsters Are you workin on this? If not I would like to grab this.

@vweijsters @sharwell Do we want to include this is rc2? My fix would be to write a custom fix all provider. That would also improve performance.

@sharwell
Copy link
Member

sharwell commented Dec 3, 2015

Normally I would say no, but we've already had a bug report (on gitter I think) regarding the performance of this code fix. If the current fix is easily converted to support a custom fix all then I think we could include it.

@sharwell sharwell assigned pdelvo and unassigned vweijsters Dec 3, 2015
@sharwell sharwell modified the milestones: 1.0.0 RC 2, 1.0.0 Dec 4, 2015
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Dec 23, 2015
* Check iterations as a fixed number instead of a bound
* Assume "Fix All" operations take one iteration unless specified

This change helps ensure situations like DotNetAnalyzers#1879 do not go unnoticed.
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

5 participants