Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Description of Problem: Some of the defaults for the "Visual Studio" policy in Xamarin Studio do not match up with the actual C# formatting of Visual Studio. Users that select this policy expect their code to format identically to the way Visual Studio would format it. However, there are some incongruous results when using this policy in Xamarin Studio.
One such example is that "Whitespace->before opening bracket" is checked by default for both Indexers and Element Access. This is incorrect, as Visual Studio does not place leading whitespace before the opening bracket in these cases.
Steps to reproduce the problem:
1. In Preferences, set your C#/Text File code formatting to "Visual Studio".
2. Open or create a new C# project/solution.
3. Open or create a new code file that uses indexers or element access.
4. Press CTRL+I (or Edit->Format->Format Document) to see the incorrect formatting take place.
In my example, I use a Regex pattern with capture groups to illustrate the formatting mistake.
var key = match.Groups ["Key"].Value;
var key = match.Groups["Key"].Value;
How often does this happen?
Every time you use the default "Visual Studio" policy and Indexers/Element Access in your code.
Additional Information: It is possible to fix this manually of course. You can uncheck "Whitespace->before opening bracket" for both Indexers and Element Access, and it will format properly. However, the default policy for "Visual Studio" should mimic the expectations that users coming from VS would have.
I discovered this bug too in master branch(from yesterday) and XS 4.0.3.
Whitespace before indexer is still the default in "Microsoft Visual Studio"
While at it.
Same policy should not state that catch is placed on the same line.
In Visual Studio it usually is written
So at lease allow both should be the default
The following should change in the "Microsoft Visual Studio" policy.
Tested with Visual Studio 2010.
My suggestion below is based on the result of "Format Document", less strict coding can be done if not used.
Place on new line: (current policy)->(should be)
else: always same->always new
catch: always same->always new
finally: always same->always new
while: always same->allow both
Place array initializers on new line: "wrap if too long"->"do not change"
I fixed the allman formatting defaults.
btw. for new issues open new bugs - if I wouldn't have memorized that there were issues with that I would've overlooked it.