How can I override the default code formatting policy in MonoDevelop?

MonoDevelop allows you to create and install custom policies to manage all aspects of code formatting. I created a policy for our working site that can be applied through Project> Apply Policy ...

We use the Unity engine, which regularly regenerates the MonoDevelop solution, requiring each developer to re-apply the policy - annoying and error-prone.

How to make my policy file standard for new MonoDevelop solutions?

Also, where is application policy information stored?

In the .sln file, I see "$ 0.CSharpFormattingPolicy = $ 2", but this has not changed after applying my user policy. I compared all the project files before and after applying the policy, and the only changes are: (1) the .userprefs file is generated, but no policies are mentioned, and (2) the different .pidb files are different, but it can. Where will the policy information be?

I am using MonoDevelop version integrated with Unity 3.5.2, which is MonoDevelop version 2.8.2 (on Windows 7). (Yes, 2.8.2 is a bit outdated, and it is possible that Unity Technologies has made changes that cause my problems.)

+8
unity3d monodevelop
source share
5 answers

This is a year after the other answers, but none of the above actions work for unity, and that was close to the start of a Google search.

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

  • MonoDevelop-> Tools-> Custom Policies-> Add Policy-> New Policy

  • Edit the policy inside the User Policies window, making sure your policy is selected.

  • Project-> Apply Policy-> Apply Stock or Custom Policy Set (select your policy) โ†’ Apply

+11
source share

Go to Tools-> Options-> KeyBinding Then go to Edit โ†’ FormatDocument Then assign your shortcut and click "Apply" and use it in your document.

+4
source share

The default policy applies to new solutions or solutions without policies. It can be edited in the "Settings / Options" dialog box, in which it is mixed with user settings: "Tools" - "Options" on Windows, MonoDevelop-> "Settings" on Mac. You can define policies because they have a Politics drop-down menu at the top of the panel that allows you to load from a named policy.

+2
source share

I spent about 30 minutes fixing it and finally understanding it.

On Windows: Go to Project -> Assembly C-Sharp Options

Then change the formatting of the code!

Going to Project -> Solution Options does absolutely nothing

+1
source share

After a year with this, we wrote a Unity script editor that will look at project files for changes, and when they are changed, check the policy entries in the project (fairly simple XML to parse). If they deviate from our desired policies, we must change them and write them down with the correct policy changes.

Another idea (we would like to ensure compliance with the policy) is to do the same, but just delete the policy entries from the project when they are updated, and then you will never have a project policy redefining what you created in the tool level .

0
source share

All Articles