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

SA1119 reports incorrect unnecessary parenthesis in string interpolation #1284

Closed
nbarbettini opened this issue Aug 25, 2015 · 7 comments
Closed
Assignees
Milestone

Comments

@nbarbettini
Copy link
Contributor

This snippet triggers SA1119:

bool flag = false;
string data = $"{(flag ? "yep" : "nope")}";

But this is actually correct syntax for using the ternary operator inside a C# 6.0 interpolated string; there's no way to write it without the parenthesis. The code fix (removing the parenthesis) causes the code to be uncompilable.

@pdelvo
Copy link
Member

pdelvo commented Aug 25, 2015

Nice catch! Im going to have a look at it

@nbarbettini
Copy link
Contributor Author

Would take a look myself, but still at work! 😄

@pdelvo
Copy link
Member

pdelvo commented Aug 25, 2015

If you want to fix it go ahead!

@nbarbettini
Copy link
Contributor Author

I wouldn't be able to get to it until later, so unless I've specifically mentioned here that I'm looking at it, assume I haven't had time yet. 👍

@sharwell sharwell added the bug label Aug 25, 2015
@sharwell
Copy link
Member

So who took it? 😄

@pdelvo
Copy link
Member

pdelvo commented Aug 27, 2015

Im going to fix this now

@nbarbettini
Copy link
Contributor Author

Yeah, sorry... didn't have time to look at it yet. 😞 Go for it!

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

3 participants