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

SA1000 doesn't handle 'target-typed' new expressions with parameters #3690

Closed
alexyuwen opened this issue Aug 23, 2023 · 1 comment
Closed
Labels

Comments

@alexyuwen
Copy link

alexyuwen commented Aug 23, 2023

This issue was previously reported and closed; however, SA1000 is still being incorrectly reported whenever the expression contains a parameter.

For example, let Dog be a class that defines a constructor that takes one parameter, numPaws.

public class Dog
    {
        public Dog(int numPaws) { }
    }

Then the following invocation of the constructor will incorrectly report SA1000.

Dog dog = new (3);

@bjornhellander
Copy link
Contributor

The issue you refer to was about SA1000 triggering when there were no spaces.

The behaviour you are seeing is by design. If you try Visual Studio's built in formatting (Ctrl K D), you will se that it removes the space between new and the parenthesis. At least if you are using the default formatting settings. This is the expected formatting according to SA1000:
Dog dog = new(3);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants