How to run ReSharper CLI with only rules specified in .DotSettings file?

29 Views Asked by At

I have the following minimal .DotSettings-file:

<wpf:ResourceDictionary 
  xml:space="preserve" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:s="clr-namespace:System;assembly=mscorlib" 
  xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" 
  xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_ANONYMOUS_FUNCTION/@EntryValue">Positional</s:String>
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_LITERAL/@EntryValue">Positional</s:String>
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_NAMED/@EntryValue">Positional</s:String>
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_OTHER/@EntryValue">Positional</s:String>
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_STRING_LITERAL/@EntryValue">Positional</s:String>
</wpf:ResourceDictionary>

How can I "apply" this using the ReSharper CLI, without any other rules being run?

I've tried to use the following:

dotnet tool install -g JetBrains.ReSharper.GlobalTools
jb cleanupcode --no-buildin-settings --settings="./../MyCustom.DotSettings" .\MySolution.sln

And the rules in my file are applied, but so are a bunch of other ReSharper default styles and formatting rules, which I do not want applied. Figured --no-buildin-settings would opt out of those, but apparently not.

Is there no way to run a limited set of rules using the ReSharper CLI?

1

There are 1 best solutions below

0
Svish On

The "solution" was to install the ReSharper trial, create a Styles only-profile with only the csharp argument code style selected, and add that to the file:

<wpf:ResourceDictionary 
  xml:space="preserve" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:s="clr-namespace:System;assembly=mscorlib" 
  xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" 
  xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_ANONYMOUS_FUNCTION/@EntryValue">Positional</s:String>
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_LITERAL/@EntryValue">Positional</s:String>
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_NAMED/@EntryValue">Positional</s:String>
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_OTHER/@EntryValue">Positional</s:String>
    <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ARGUMENTS_STRING_LITERAL/@EntryValue">Positional</s:String>

    <s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Styles_0020only/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Styles only"&gt;&lt;CSCodeStyleAttributes ArrangeArgumentsStyle="True" /&gt;&lt;XAMLCollapseEmptyTags&gt;False&lt;/XAMLCollapseEmptyTags&gt;&lt;/Profile&gt;</s:String>
</wpf:ResourceDictionary>

Then run:

jb cleanupcode --no-buildin-settings --profile="Styles only" --settings="./../MyCustom.DotSettings" .\MySolution.sln

If anyone know of a way to do this without having to install ReSharper to create stupid profiles, please do let me know...