Bug 40409 - c# formatting styles don't work in Xamarin 6 beta
Summary: c# formatting styles don't work in Xamarin 6 beta
Status: RESOLVED ANSWERED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 6.0.0 (C7)
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: (C8)
Assignee: Mike Krüger
URL:
Depends on:
Blocks:
 
Reported: 2016-04-14 20:35 UTC by ken.yee
Modified: 2016-07-20 11:02 UTC (History)
9 users (show)

Tags: BZSRC7
Is this bug a regression?: Yes
Last known good build:

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:
Status:
RESOLVED ANSWERED

Description ken.yee 2016-04-14 20:35:50 UTC
Description of Problem:
Can't switch code formatting.  I tried setting it to Visual Studio and SharpDevelop style but it keeps doing this:

if (blah) {
  somefunction (param);
}
instead of
if (blah)
{
  somefunction(param);
}

It's driving me nuts enough to go back to stable


Steps to reproduce the problem:
1. try to switch c# formatting
2. add an if statement and type in the curly brace and watch it screw up all your formatting


Actual Results:


Expected Results:


How often does this happen? 


Additional Information:
Xamarin Studio Build 4968
Comment 1 ken.yee 2016-04-15 13:23:41 UTC
FYI, from the forums:

> @IvanMokowitch said:
> I had the same problem with an alpha release some time ago. I then found a entry on my project file, which has set the setting of the code formatting to a fixed value. After I deleted this line, the code formatting work again.
Comment 2 Jimmy [MSFT] 2016-06-22 21:05:53 UTC
I am still able to reproduce this issue in the C7SR0 release therefore I am marking the report as confirmed.

I’ve tried setting the code formatting style to Visual Studio at the XS, solution, and project level. Looking at the .csproj file, NewLinesForBracesInControlBlocks is set to true but the editor still behaves incorrectly.

### Environment Info

=== Xamarin Studio Business ===

Version 6.0.1 (build 8)
Installation UUID: 94ce5106-6a72-4691-b34e-cd5857b1db66
Runtime:
	Mono 4.4.1 (mono-4.4.0-branch-c7sr0/4747417) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404010000

=== Xamarin.Profiler ===

Version: 0.33.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.3.1 (10188.1)
Build 7D1014

=== Xamarin.iOS ===

Version: 9.8.1.4 (Xamarin Business)
Hash: 3cf8aae
Branch: c7sr0
Build date: 2016-06-20 16:09:58-0400

=== Xamarin.Android ===

Version: 6.1.1.1 (Xamarin Business)
Android SDK: /Users/jimmygarrido/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.8.1.4 (Xamarin Business)

=== Build Information ===

Release ID: 600010008
Git revision: 0ecc3639cde21616d675e4fdef1b858d166dd065
Build date: 2016-06-20 13:16:51-04
Xamarin addins: a9252e6df4851fbbed1f9c6228e7b6dd1b475ac5
Build lane: monodevelop-lion-cycle7-sr0

=== Operating System ===

Mac OS X 10.11.5
Darwin Jimmys-MacBook-Pro.local 15.5.0 Darwin Kernel Version 15.5.0
    Tue Apr 19 18:36:36 PDT 2016
    root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Redth's Addins 1.0.2
Comment 3 Mike Krüger 2016-07-07 07:28:39 UTC
You need to set it on project level. The global options only apply to new projects.
Comment 4 ken.yee 2016-07-07 13:39:10 UTC
Tried setting it on both in the beta w/o luck.
Comment 5 Nate Cook 2016-07-19 15:10:15 UTC
@Mike Krüger - Is there documentation anywhere on what has changed with where formatting settings are stored in XS 6? I am seeing blocks such as the following appearing in some csproj files. Previously all formatting customizations we made in the solution options and were stored in the sln files. I don't recall seeing information about this changing in the release notes.

<ProjectExtensions>
  <MonoDevelop>
    <Properties>
      <Policies>
        <TextStylePolicy inheritsSet="VisualStudio" inheritsScope="text/plain" scope="text/x-csharp" />
        <CSharpFormattingPolicy IndentSwitchSection="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceAfterMethodCallName="False" SpaceBeforeOpenSquareBracket="False" inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
      </Policies>
    </Properties>
  </MonoDevelop>
</ProjectExtensions>
Comment 6 Mike Krüger 2016-07-20 11:02:25 UTC
The 'where' didn't change - but the what. We've now a completly different option set so the old options are ignored.

The only thing that should work is the policy the inheritsSet="VisualStudio" or inheritsSet="Mono". But the options itself changed between 5 and 6.

ATM I don't know why this appears as change for you - nothing that was introduced from my side :/