Apply Policies to code

We're trying to use the code policies within Xamarin Studio. When I click 'Apply Policies' in the 'Project | Apply Policy...' dialog, nothing seems to happen. Is there something that I'm supposed to setup for this to work?

Also, is this in any way related to stylecop? Wondering if we can share the rules that we have over in Visual Studio.

Thanks!

Posts

  • mhutchmhutch USXamarin Team Xamurai
    edited March 2013

    Broadly speaking there are three kinds of setting in Xamarin Studio:

    User Preferences

    Settings that affect the way you work but are really a matter of personal preference. For example, keyboard shortcuts, syntax highlighting colours, text editor behaviour. These are stored in your local machine's preferences directory, or if solution-specific are stored in a {SolutionName}.userprefs file beside the solution.

    Project/Solution Options

    Settings that affect how the code is built and run, for example compiler options, output directory. These are saved into the solution/project files, in a VS compatible way when possible.

    Policies

    Settings that affect the style of the code you write and commit. For example, code formatting style, the copyright header for new files, naming conventions, directory structure. These are saved into the solution/project files to make sure that all users working on a solution have have the same policies. You can edit the default policies for new solutions in the User Preferences dialog, but for existing solutions you must use the Solution Options dialog. The Custom Policies dialog can be used to create, edit, export, and import named policy sets that you can easily apply to solutions.

    So policies are basically settings that are used by things like the code formatter, the source analysis, the template system etc. There's nothing yet equivalent to StyleCop but it wouldn't be hard to write a source analysis rule that would underline and offer fixes for style policy violations. I imagine it would also be possible to write a VS addin to synchronize VS and R# settings with the policies that XS stores in the solution.

  • MarcoViveroMarcoVivero MXUniversity

    Hi, I know it's been over a year since @JuanPerez.3422 asked this, but I have found a Stylecop addin for Xamarin Studio. It actually works pretty nice. Check out this link addins.monodevelop.com/Project/Index/54

    You can configure which rules you want to use on your project/solution. The only downer to this is that it apparently doesn't run automatically, you must go to the menu Tools > Run Stylecop so that the rules are checked on your code (you can also right click on a solution, project or file and select Run Stylecop).

    Also, I haven't yet found a way to include custom rules that we have defined for Visual Studio... still working on it. If anyone knows how to use custom rules on Xamarin Studio, please let me know.

    Hope this helps!

Sign In or Register to comment.