-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Ported from TFS WorkItem: 1107386
Repro Steps:
1. Create a new C# class library.
2. Add the following method:
void M()
{
int x = 5;
// Foo bar baz
}
3. Put the cursor on the "int x = 5;" line.
4. Press Ctrl+. to bring up the light bulb.
5. Hit enter to add the #pragmas.
Expected
The indentation of "// Foo bar baz" remains the same.
Actual
The comment is pushed over to the right. That is, you end up with something like this:
void M()
{
#pragma suppress CS2091
int x = 5;
#pragma restore CS2091
// Foo bar baz
}
Revisions:
- Created By Tom Meschter (1/13/2015 12:21:30 PM)
- Edited By Shyam Namboodiripad (1/14/2015 1:42:19 PM)
This is actually a known bug in the formatter. Unless Kevin is willing to reconsider :) this can be resolved as a dupe of 1079746.
- Edited By Tom Meschter (1/14/2015 2:53:51 PM)
Reactivating.
I took a look at 1079746 and I think this is a different issue.
In 1079746 you start with incorrectly formatted code, and inserting the suppression fixes the formatting. We may end up formatting things not directly connected to the trivia we're inserting, but the end result is fine.
In this bug, you start with correctly formatted code, and inserting the #pragma makes it incorrect. So you then have to run "Format Document" or similar to clean up the results of the suppress action.
I've updated the repro steps to show the output from the suppress action.