Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I over-ride the default code formatting policy in MonoDevelop?

MonoDevelop allows creation and installation of custom policies to control all aspects of code formatting. I have created a policy for our work site, which can be applied via Project > Apply Policy ...

We are using the Unity game engine, which regularly regenerates the MonoDevelop solution, requiring each developer to re-apply the policy -- irritating and error-prone.

How can I make my policy file be the default for new MonoDevelop solutions?

Also, where is the information about the applied policy saved?

In the .sln file I see "$0.CSharpFormattingPolicy = $2", but this is unchanged after applying my custom policy. I have compared all the project files before and after applying the policy, and the only changes are (1) a .userprefs file is generated, but doesn't mention policies, and (2) various .pidb files are different, but this can't be where policy information goes??

I'm using the version of MonoDevelop that is integrated with Unity 3.5.2, which is MonoDevelop version 2.8.2 (on Windows 7). (Yes, 2.8.2 is a little out of date, and it's possible that Unity Technologies has made changes that are causing my issues.)

like image 887
yoyo Avatar asked Jun 11 '12 19:06

yoyo


2 Answers

This is a year after the other answers, but none of the above works for unity, and this was near the top of the google search.

Here are the steps I had to follow to get formatting to work:

  1. MonoDevelop->Tools->Custom Policies->Add Policy->New Policy

  2. Edit the policy inside of the 'Custom Policies' window, making sure your policy is selected.

  3. Project->Apply Policy->Apply Stock or Custom Policy Set (select your policy)->Apply

like image 61
Matt Taylor Avatar answered Sep 30 '22 10:09

Matt Taylor


Goto Tools->Options->KeyBinding Then goto Edit -> FormatDocument Then assign your shortcut key and click on apply and use it in your document.

like image 26
Sudhir Kotila Avatar answered Sep 30 '22 09:09

Sudhir Kotila