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

Fix SA1513 incorrectly reported on object initializers without assignment #1314

Merged
merged 3 commits into from
Aug 29, 2015

Conversation

@sharwell
Copy link
Member

I think this change does not work with the following code. SA1513 should be reported on the } before the second return statement. Prior to this change it is reported, but afterwards it is not.

public void Example()
{
    new List<Action>
    {
        () =>
        {
            if (true)
            {
                return;
            }
            return;
        }
    };
}

@sharwell sharwell added this to the 1.0.0 Beta 9 milestone Aug 28, 2015
@sharwell
Copy link
Member

I made a mistake in my comment before. The strange behavior appears if you have an empty statement following the }. Notice that the ; is actually not part of the if statement here:

public void Example()
{
    new List<Action>
    {
        () =>
        {
            if (true)
            {
                return;
            };
        }
    };
}

Given its obscurity, this is something we may just want to file a bug for.

@sharwell sharwell self-assigned this Aug 29, 2015
sharwell added a commit that referenced this pull request Aug 29, 2015
Fix SA1513 incorrectly reported on object initializers without assignment
@sharwell sharwell merged commit ea93d52 into DotNetAnalyzers:master Aug 29, 2015
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

Successfully merging this pull request may close these issues.

2 participants