Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Minor MonoDevelop Annoyance: Code format around parenthesis

Discussion in 'Scripting' started by 39thstreet, Jun 22, 2012.

  1. 39thstreet

    39thstreet

    Joined:
    Jan 30, 2012
    Posts:
    104
    I admit this is a super minor thing, but I can not find an answer. I went through every code formatting setting I could find in MonoDevelop, and yet I'm still getting this. I'm coding in C# if it matters.

    I want my method calls to look like this:
    Code (csharp):
    1.  
    2. methodCall();
    3.  
    NOT like this:
    Code (csharp):
    1.  
    2. methodCall ();
    3.  
    How do I stamp out that space before the parenthesis Monodevelop keeps popping in?

    As an aside, I have never seen anyone do this in any language I've coded in (C, C++, Java, Perl, PHP, Javascript, Actionscript, none of 'em). Why did they decide this is a good default? It simply hurts readability.
     
  2. HarvesteR

    HarvesteR

    Joined:
    May 22, 2009
    Posts:
    531
    Heh, that IS weird. Never noticed that.

    My advice on this matter: Visual Studio > MonoDevelop ;)

    Cheers
     
  3. AnthonyFaraci

    AnthonyFaraci

    Joined:
    Jun 26, 2011
    Posts:
    414
    In his case yes, but if your using uscript then id would suggest monoDevelop.
     
  4. phase5

    phase5

    Joined:
    Sep 28, 2010
    Posts:
    13
    You can do this through the Code Formatting policies in MonoDevelop. Make sure you set the Code Formatting policy for your project and then reformat your code. There are various ways to do this, but the easiest (but per-project basis) is to right click your solution and go to Options.

    Then, make your screen look something like below:


    http://cl.ly/2O1E0m1K2D2P262t0A11

    There are various options there. For example, you may want to scroll up to the top and remove white space on declarations as well.
     
  5. the_lemur

    the_lemur

    Joined:
    Apr 3, 2013
    Posts:
    104
    The problem is this setting seems to reset with every new project - and even after I turn off white-space between function and parenthesese, it still puts it in automatically for certain types of code completion, like Debug.Log ()

    I have no idea why they went with this extra white space. Not only is it completely non-standard, but even if you thought it looked cleaner ( which I don't think it does at all ) it flies in the face of the origin of the syntax to begin with.

    Function call syntax with hugging parentheses comes from mathematical notation, where the parens are always placed against the function object. For people with some mathematical background ( me and most other programmers I imagine ) this just looks atrocious. And I don't think the math community at large is going to change any time soon.
     
  6. almo

    almo

    Joined:
    Jul 14, 2010
    Posts:
    83
    I tried setting this in both the project C# settings, and the IDE's preferences. It accepts everything I've set, like Allman bracing, but it insists on putting a space before parenthesis for function calls. Driving me nuts.