当我要求 ReSharper 将我的 get 弄平时,设置为一行,它通常不会全部完成有谁知道为什么?

问题描述

从这段代码开始,我使用 ReSharper 来整理我的代码

    public static readonly BindableProperty TestProperty =
        BindableProperty.Create(nameof(Test),typeof(string),typeof(BaseGrid),default(string));
    public string Test
    {
        get => (string)GetValue(TestProperty);
        set => SetValue(TestProperty,value);
    }
    public static readonly BindableProperty TapCommandProperty =
        BindableProperty.Create(nameof(TapCommand),typeof(Command),default(Command));
    public Command TapCommand {
        get => (Command)GetValue(TapCommandProperty);
        set => SetValue(TapCommandProperty,value);
    }

    public static readonly BindableProperty TapCommandParamProperty =
        BindableProperty.Create(nameof(TapCommandParam),typeof(object),default(object));
    public object TapCommandParam {
        get => (object)GetValue(TapCommandParamProperty);
        set => SetValue(TapCommandParamProperty,value);
    }

    public static readonly BindableProperty TextProperty =
        BindableProperty.Create(nameof(Text),default(string));
    public string Text
    {
        get => (string)GetValue(TextProperty);
        set => SetValue(TextProperty,value);
    }

ReSharper 将 Bindable 属性移动到文件的顶部并排序我想要的所有内容。但它会将 get,set 更改为如下所示:

    public Command TapCommand{
        get => (Command) GetValue(TapCommandProperty);
        set => SetValue(TapCommandProperty,value);
    }
    public object TapCommandParam{
        get => GetValue(TapCommandParamProperty);
        set => SetValue(TapCommandParamProperty,value);
    }
    public string Test{ get => (string) GetValue(TestProperty); set => SetValue(TestProperty,value); }
    public string Text{ get => (string) GetValue(TextProperty); set => SetValue(TextProperty,value); }

我的问题是,为什么有时 ReSharper 只将部分 get,set 展平为一行(这是我想要的),而不会将其他部分展平?

注意:

a) 我使用的是最新版本的 ReSharper、Visual Studio、.net 等。 b) 属性声明设置为:“行尾无空格)”

有没有其他人遇到过同样的问题?

解决方法

我怀疑这是“换行长行”设置,可能您的财产线超过了最大行长(我认为默认为 120 个字符)

The fine manual 表示相关选项在 Alt-R,O 中,然后在 代码编辑 | C# | 格式样式 | 行上使用“右边距(列)”首选项中断和包装"

注意,我不使用 R#r,因此请随时编辑此答案中的任何不准确之处