-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add brace new line code style for switch expressions #36913
Comments
The formatter should be using one of the existing options here: roslyn/src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.cs Lines 354 to 355 in 90bdf25
roslyn/src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.cs Lines 360 to 361 in 90bdf25
|
I was the person to initially post this issue. Based on what you have shown, this option should be the one listed as var msg = 2 switch
{
1 => "One",
2 => "Two",
_ => "Not one or two"
};
for (var a = 1; a < 1; a++)
{
} With the option disabled, I get this: var msg = 2 switch
{
1 => "One",
2 => "Two",
_ => "Not one or two"
};
for (var a = 1; a < 1; a++) {
} Currently, I am using .NET Core 3.0, CSharp 8.0, and Visual Studio 16.3.0 (I haven't had time to update to 16.3.1 yet). |
Yes. The issue has not been fixed. |
@sharwell @CyrusNajmabadi I'm going to take a stab at this one, let me know, if I shouldn't for some reason. I'm going to report back here, if I get stuck, or have questions. |
@tiesmaster It should be fine to implement this. There is a chance the specific option changes following a design review, but it should be easy to update the implementation and tests to match regardless. |
Good luck! Happy to help out if you need it :) |
@CyrusNajmabadi Awesome!! Thnx, I'm probably going to need it ;) I've managed to reproduce the bug, but so far, I haven't been able to get it fixed. I have this so far, but that doesn't "push the brace back". So I need to do some more digging, but it's getting late, so I'm stopping for today. Just let me know if I'm on the right track (both tests, as the fixes). |
Design review conclusion:
|
This formatting option should also cover It currently inconsistently affects roslyn/src/Workspaces/CSharp/Portable/Formatting/Rules/NewLineUserSettingFormattingRule.cs Line 107 in fed2d6e
vs roslyn/src/Workspaces/CSharp/Portable/Formatting/Rules/NewLineUserSettingFormattingRule.cs Line 282 in fed2d6e
|
Bump |
We took this to a design meeting and decided in the design and behavior we want here. The issue is currently 'up for grabs' for anyone to fix, although @tiesmaster Expressed interest in doing that work. We would take a well written pr that implements the design specified. Thanks! |
Hey @tiesmaster, are you still up for it? Otherwise, how about the product owners take care of it? |
@ChainReactive We haven't heard from @tiesmaster in some time. Would you be interested in taking a look and contributing a PR here? |
@CyrusNajmabadi Sorry, I'm too busy working on my own products. I can't afford spending the time it'd take to learn Roslyn and contribute to it. Seems it'd be best if the product owners took responsibility. |
We have responsibility for many issues. This is not more important than all the issues currently assigned to everyone currently. As this is a low impact issue, it likely won't get fixed until current critical work is done, or unless someone wants to take their spare time to fix it. :)
I'm happy to take my spare time to try to help you learn this :) We have many external contributers already, and you might like being able to be in a position to immediately address small paper cuts like this when they affect you instead of hoping that it might make the cut for someone else in teh future :) |
Thanks for the explanation.
There was a time in my life.... but not now. Good luck! |
@tiesmaster @ChainReactive @CyrusNajmabadi I was the one supposed to finalize #39396 for merge. I'll update it now so this should already be fixed. |
@here Indeed, as @sharwell indicated, I already put in a PR to fix this. I left that in an intermediate state, as there were still loose ends (or maybe just a single loose end, I'm not sure), so that was also a bit on me, I suppose. @sharwell From all the other issues that point back to this issue, it's apparent that there is desire to get this in. Let me know if you need anything from me on the PR. Though, I'd need to dive into that again, if there is anything that needs to be change, so that would take a bit of time. @CyrusNajmabadi Indeed, you haven't heard from me for some time. I started out with a new job, and together with some demanding things in my personal life (happy stuff, but still time consuming), I didn't have any time to continue with my contributing. I suppose I should have mentioned that, sorry about that. I do like to start contributing again, but didn't really knew where to start. Getting help on certain issues would definitely help. I know the Gitter channel, but that didn't really work for me, somehow. I see there is Discord now, that might be a better fit for me. Perhaps having a dedicated person to ask questions to, would also help, something like a mentor. |
@sharwell Thanks for finishing the PR! I assume it is too late to get this in 16.8, right? Will it be in 16.9? |
I think this will be 16.8 Preview 4. |
Sorry for barging in late, but is this fix now up on some stable release? And what is the setting now available for the |
@joelhoisko The .editorconfig property is |
Currently in Visual Studio 2019 release, there is no option to specify new line options for braces when using the new switch expression. Visual Studio will always place the opening brace on a new line, regardless of what has been specified for a switch statement, and there is no switch statement specific setting to change the option to having the opening brace on the same line. I typically change all of my code style options for all braces to begin on the same line as the statement/expression creating the brace, but this is one expression where I am unable to configure currently.
This issue has been moved from https://developercommunity.visualstudio.com/content/idea/524975/add-brace-new-line-code-style-for-switch-expressio.html
VSTS ticketId: 843465
These are the original issue comments:
Jane Wu [MSFT] on 4/10/2019, 00:52 AM (82 days ago):
Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. We'll provide an update once the issue has been triaged by the product team.
The text was updated successfully, but these errors were encountered: