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

SA1500 false positive in stackalloc expression #3047

Closed
Tan90909090 opened this issue Oct 23, 2019 · 0 comments · Fixed by #3054
Closed

SA1500 false positive in stackalloc expression #3047

Tan90909090 opened this issue Oct 23, 2019 · 0 comments · Fixed by #3054

Comments

@Tan90909090
Copy link

Tan90909090 commented Oct 23, 2019

Version used: StyleCop.Analyzers 1.2.0-beta.66

using System;

class C
{
    static void Main()
    {
        Foo(stackalloc[] { 'a' }); // SA1500 is reported here
        Foo(new[] { 'a' }); // SA1500 is NOT reported here
    }

    static void Foo(ReadOnlySpan<char> a) { }
}

The Foo(stackalloc[] { 'a' }); code is in one line, so I think SA1500 should not be reported that.

pantosha added a commit to pantosha/StyleCopAnalyzers that referenced this issue Nov 4, 2019
pantosha added a commit to pantosha/StyleCopAnalyzers that referenced this issue Nov 4, 2019
sharwell added a commit that referenced this issue Nov 6, 2019
Make SA1500 work with stackalloc arrays (#3047)
@sharwell sharwell added this to the 1.2-beta.next milestone Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants