How can I over-ride the default code formatting policy in MonoDevelop? - 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.)

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:
MonoDevelop->Tools->Custom Policies->Add Policy->New Policy
Edit the policy inside of the 'Custom Policies' window, making sure your policy is selected.
Project->Apply Policy->Apply Stock or Custom Policy Set (select your policy)->Apply

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

The default policy is applied to new solutions or solutions without policies. It can be edited in the Preferences/Options dialog, where it's mixed in with the user preferences: Tools->Options on Windows, MonoDevelop->Preferences on Mac. You can identify the policies because they have a "Policy" dropdown at the top of the panel that allows you to load from a named policy.

I spent like 30 minutes fixing this and finally figure it out.
In Windows:
Go to Project -> Assembly C-Sharp Options
Then change the Code Formatting from there!
Going to Project -> Solution Options does absolutely nothing

After a year of dealing with this, we wrote a Unity editor script that would watch the project files for changes, and when they changed, check the policy entries in the project (pretty simple XML to parse.) If they had deviated from our desired policy, we'd modify them and write them back out with the correct policy changes.
Another idea (we wanted to enforce a policy) would be do do the same thing, but just remove the policy entries from the project whenever they got updated, and then you'd never have project policies overriding what you set up at the tool level.

Related

PhpStorm: multiple projects with common core

Due to security reasons, I have to split one project to divisions (client, admin, ...), and deploy them to different web servers. These divisions have one common script base, but each division has its own functions. As an IDE I use PhpStorm.
The question: what is the best way to organize project's structure and settings, so the common core part will be visible for IDE indexing in all project's divisions, but at the same time, being maintained from a single project (perhaps, standalone)?
In Java you can do lib jar files for further linking in various projects.
But how it can be done in PHP?
There are multiple ways of how to reference extra PHP code in a project.
If you plan to actively edit such extra code in the same project (and want to see their TODOs, code inspection warnings, include references in code refactoring etc):
You can just add it as an additional Content Root: Settings/Preferences | Directories. Folder added this way will be treated as a part of the project itself and will be shown as a separate node in the Project View panel (just as the main code, which is a Content Root as well).
Or you can open 2nd project while 1st one is already opened and when asked, just chose "Attach":
It's not going to be full 2 projects in one frame, more like something in between attaching Content Root and having 2 projects opened in separate frames.
https://www.jetbrains.com/help/phpstorm/opening-multiple-projects.html
Simple symlink will also do the job (but you need to place it somewhere in a project, e.g. PROJECT_ROOT/libs/my_symlinked_code). You then will need to provide a path mapping for that folder for debugger (if you will debug it of course) as PHP/Xdebug works with "final/resolved path" while IDE works with the path as is.
If you do not need to actively edit that extra code in the same window (and ignore any TODOs, code inspection warnings and other inspection results etc):
Do it as a composer package then? Composer can use custom sources (e.g. GitHub repo or a folder on a local filesystem).
Just add the path to that folder as a "Include Path" at Settings/Preferences | Languages & Frameworks | PHP --> Include Path tab. Code referenced this way is meant for 3rd party libraries (the code that you just use but not edit, e.g. framework code, your send mail/ORM library etc). Composer packages will also be included here by default.
https://www.jetbrains.com/help/phpstorm/php.html#include-path-tab

How to attach a project without mixing class declarations in PhpStorm?

I like PhpStorm's ability to attach multiple projects to the current window:
I've noticed, however, that all classes declared in both projects are available in both projects, which can lead to duplicate declarations:
I understand how this can be useful at times, however I'd like to attach projects just to navigate easily between them (I prefer this to switching windows), while keeping them separate as if they were in separate windows.
Is this possible?
Currently IDE does not have "scoped indexing" that may be able to resolve this. Right now you would need to exclude such duplicate files or tell IDE to not to treat them as PHP so they do not get indexed as such.
Your current options:
Use Mark Directory As | Excluded via context menu in Project View panel (or manually via Settings (Preferences on macOS) | Directories) for a folder(s) from additional project.
Mark individual files as Plain Text via context menu in Project View panel. The downside: such "marking" is IDE-wide as far as I know, so the same file path will be excluded in another project as well.
Any other exclusion mechanic that is currently available (e.g. Settings (Preferences on macOS) | Editor | File Types | Ignore files and folders -- global as well and based on file name only and file will be completely ignored from all operations... so not really acceptable for your case).
Consider watching after https://youtrack.jetbrains.com/issue/WI-17646 (star/vote/comment) and related tickets to get notified on any progress.
If they are the same classes, have you thought about making a composer package for them? Would be easier to manage it all I think.

PhpStorm and workspace issue

I have the newest version of PhpStorm.
Previously I worked with Eclipse and had the opportunity to see my whole workspace. In PhpStorm I need to open one instance per project.
In my daily workflow I need to search for strings in my workspace. In
PhpStorm I would need to switch from instance to instance and need to execute the string search again and again per instance.
Is there another solution or do I really need to execute my search multiple times?
In addition eclipse had the "Open Resource" function for the whole workspace. Does PhpStorm offers the Open Resource for whole workspace too?
In PhpStorm I need to open one instance per project.
That's correct -- currently having more than one project in one frame is not supported.
https://youtrack.jetbrains.com/issue/WI-15187 -- watch this ticket (star/vote/comment) to get notified on progress.
Is there another solution or do I really need to execute my search multiple times?
You can always attach any folder (from any project) to current project as Additional Content Root (will be listed as separate branch in Project View panel).
Settings (Preferences on Mac) | Project | Directories --> "Add Content Root" button.
Note that it will still be treated as one project (no separate settings) -- additional content root is treated as just a bunch of files/folders.
In addition eclipse had the "Open Resource" function for the whole workspace. Does PhpStorm offers the Open Resource for whole workspace too?
Look for commands under Navigate menu.
Navigate | File... Ctrl + Shift + N (using Default keymap) is
most likely what you need.
Useful info:
https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+for+Users+of+Eclipse+PDT+and+Eclipse-based+IDEs
PhpStorm has separate keymap that similar to what Eclipse uses.

PhpStorm multiple project navigation, quick switch between projects

How can I open few projects in left work area in PhpStorm? I need to quick switch between projects.
If you want to open more than one project in this way (and by this I mean so they have their own different settings), then currently it is not possible.
http://youtrack.jetbrains.com/issue/WI-15187 -- vote/star/comment to get notified on progress.
If you need to include files from those projects for reference purposes (to see how you have done it there, to copy some code from there etc) -- you can include them under "External Libraries" -- Settings | PHP | Include paths. Files included this way are protected from modifications.
If you need to modify those files ... you can add them into actual project as Additional Content Root (Settings | Directories| Add Content Root) -- such folders will be treated as part of the actual project with no separate settings.
Other than that -- Alt + Tab (or whatever the shortcut is on your OS) to switch between different PhpStorm windows (each project is opened in separate window/frame).
This is a right on time answer.
It is possible to quick switch between project by adding a keyboard shortcut to the "manage project" menu.
To do just that, go to Settings > Keymap and search for "Manage Projects". Then add it the keyboard shortcut you desire and you're all set.
Hope this will help someone looking for an answer like I did.
As LazyOne said, you can add paths to your project from Setting | PHP | Include paths or from the useful keystroke F4.
But I'd like to also share how I organise my projects, I think when you create a project, you should not open a new window but instead open it in the same window.
This way you don't get confused between the different opened windows.
In settings you can assign a keystroke to Reopen recent projects. I then use ctrl + shift + R but it is up for you to chose the keystroke you like.
Hope this will help you as I struggled as well to find a way to manage all my current projects.

Is there a way to force Vault GUI client doing an auto-check out of modified files?

I feel very comfortable with the way that svn/cvs automatically detects the files which were modified, so that i can see the complete change-set recursively from the root.
Is there a workaround to have the same thing in Vault client?
For any files you changed, would like to show them up as edited and be listed in the pending change set, ready to be checked in.
I can't comment at your post so I am going to post this as an 'answer'.
I am not sure how to do that for any files but that feature is available in for files edited in Visual Studio (code files etc which is under source control of course).
For Visual Studio 2010 the option is found under Tools > Options,
then select the Source Control tree view on the left tab view, and lastly Integration Options. From the dropdown box under the option When check out is required, on edit: > Choose Automatically Check Out.
Hopes this helps. If not the Sourcegear forum will be a good place to ask for support.