Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set code formatting to allow end-of-line comments?

The C# code formatting in Xamarin Studio (i.e. when hitting Ctrl-I to format the document) puts end of line comments onto a new line. I can't find any way to change this in the C# code formatting policy settings. How to change this to preserve end of line comments on the same line?

For example, take this code:

public class Foo
{
    int bar; // comment
}

If I hit Ctrl-I (or alternately click Edit > Format > Format Document from the menu, or select the code and click Edit > Format > Format Selection from the menu), the code is reformatted as:

public class Foo
{
    int bar; 
    // comment
}

I'm using v4.2.2 build 2 v4.3 build 52 on OS X.

Note: it seems this is a bug. So my question really is -- has anyone who has also encountered this come up with a fix or workaround and if so what is it?

like image 941
Ghopper21 Avatar asked Nov 02 '13 14:11

Ghopper21


1 Answers

I don't think there is a real answer to this question, as you have said its a bug in the version you are using. UPDATE: We have discovered that this is not a bug in the software. As it affects all versions the OP updates to, most likely there is some setting or extension affecting the outcome.

A work around although you may not be to happy with it would be to place you comments above the line in question. This is a perfectly acceptable way of code-commenting.

public class Foo
{
   // comment
   int bar;   
}

Using version 4.3
Pre Ctrl + I Unformatted

Post Ctrl + I Formatted

As a final note you may want to view your code formatting preferences found here: Settings

UPDATE 1
You could try resetting all your preferences by deleting everything in the following folders, see here.
I will add that I haven't tried this so could break your installation.
Just tested and this doesn't break Xamarin Studio and does reset all preferences.

  • ~/Library/Preferences/XamarinStudio-4.0/
  • ~/Library/XamarinStudio-4.0/

UPDATE 2
The only last thing you can try as we have found out this isn't a bug in the software but something on your computer. Is to do a full removal of Xamarin Studio. I recommend using AppCleaner as it will search for any related files and remove them.
Onces it has fully uninstalled, then reinstall Xamarin Studio.

UPDATE 3
Last solution, try creating a new user account. Run Xamarin Studio under that account to see if the problem persist. If it does the only thing left to do is a fresh install of OS X and reinstall Xamarin Studio first. The problem should be gone now... reinstall all other applications checking that nothing has broken Xamarin Studio after each install.

like image 99
Ashley Medway Avatar answered Sep 29 '22 07:09

Ashley Medway