Bug 6285 - Custom code formatting does not work
Summary: Custom code formatting does not work
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: C# Binding ()
Version: 3.0.x
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: Mike Krüger
Depends on:
Reported: 2012-07-25 17:10 UTC by Matt
Modified: 2013-09-09 07:53 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

First image in code formatting sequence (64.25 KB, image/jpeg)
2012-10-11 10:15 UTC, Matt
Second image in code formatting sequence (117.11 KB, image/jpeg)
2012-10-11 10:17 UTC, Matt
Third image in code formatting sequence (122.36 KB, image/jpeg)
2012-10-11 10:18 UTC, Matt
Final image in code formatting sequence. (142.48 KB, image/jpeg)
2012-10-11 10:19 UTC, Matt

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Matt 2012-07-25 17:10:33 UTC
Description of Problem:

Custom code formatting settings are ignored by Format command (either Format Selection or Format Document).

Steps to reproduce the problem:
1. Set solution code format option (for example no space between method and paren)
2. Set project code format option to inherited.
3. Format a document that is presently in conflict with the format setting.

Actual Results:

No change to the document.

Expected Results:

Code would be formatted according to the setting.

How often does this happen? 


Additional Information:
Comment 1 Mike Krüger 2012-07-26 03:14:00 UTC
Should be fixed in master.
Comment 2 Matt 2012-07-26 07:23:47 UTC
I rebuilt from: 

Build information:
	Git revision: ddd37ced4f49d0c4aa635916c46fb94adff40fca
	Build date: 2012-07-26 11:10:38+0000

And continue to see the issue. Perhaps there is a problem with new code versus existing code? Or very long lines? I created a new file, intentionally out of format, did a reformat and it fixed the formatting. However, I formatted an existing file which also has format violations (example, with space in outer method call):

resetmap.Add ("qtd", fullspec.EnumerateIndices(new TimeSpec(fullspec.Begin, fullspec.End, PeriodicityType.Quarter)).Select(i => i.I1).ToList());

and that was not corrected. 

Comment 3 Mike Krüger 2012-07-30 14:30:30 UTC
Then the formatting does work - but not all cases, is that right ?

(That's a different issue than custom code formatting does not work)
Comment 4 Mike Krüger 2012-07-30 14:34:46 UTC
btw. I still can't reproduce it - that's what I did:


Can you make a screencast ?
Comment 5 Mike Krüger 2012-10-10 02:30:20 UTC
no response
Comment 6 Matt 2012-10-10 07:22:54 UTC

I was unable to make a screencast. I tried two different packages and neither worked. I am surprised you cannot replicate this bug. I have two new ubuntu installations of monodevelop + our code base and both exhibit this. The code formatting ignores the settings, I've yet to see it do otherwise.

Comment 7 Mike Krüger 2012-10-11 00:39:33 UTC
Can you give me a small project with the settings ?
Comment 8 Matt 2012-10-11 10:07:16 UTC

I set out to make a small project and in that project it (code formatting) did work. However it still does not work in my large project. While I cannot make a screen cast, I can do screen shots. I am attaching a sequence of these.

Perhaps it is relevant that the large project is shared between multiple users some of whom use Visual Studio. However, as you can see in the screen shots, the settings are set to not put spaces in. Spaces is one example, all of the formatting options as near as I can tell are ignored. 

Thank you for your help,

Comment 9 Matt 2012-10-11 10:15:58 UTC
Created attachment 2731 [details]
First image in code formatting sequence

Here I have selected the text I want to format. Notice the space between DefaultCalcPeriod and (calc).
Comment 10 Matt 2012-10-11 10:17:19 UTC
Created attachment 2732 [details]
Second image in code formatting sequence

Here are the settings for white space for the project the file is in. Notice spaces are off.
Comment 11 Matt 2012-10-11 10:18:32 UTC
Created attachment 2733 [details]
Third image in code formatting sequence

These are the remaining code format options for whitespace for the project the file is in.
Comment 12 Matt 2012-10-11 10:19:46 UTC
Created attachment 2734 [details]
Final image in code formatting sequence.

Here I select Format Selection. After this the code is unchanged. I expect it to remove the space between DefaultCalcPeriod and (stat).
Comment 13 Mike Krüger 2013-09-04 07:01:20 UTC
Should be fixed (at least it works for me - we had a broken format selection at that time btw.)