如果长时间不工作,ReSharper 会被砍掉

发布于 2025-01-08 04:57:35 字数 2977 浏览 1 评论 0原文

我有以下代码,当我在 ReSharper 中运行自动格式时,该代码不会改变。

在此处输入图像描述

我认为如果超出右边距,Chop if long 会导致发生切碎。

如果我打开 Chop,我总是会得到这个。

在此处输入图像描述

这可行,但我不想像第一个那样删除简短的语句,这就是我假设的 Chop if长的意思。

有想法吗?

这是我的 ReSharper 设置。

在此处输入图像描述

打开长行换行会使事情变得更糟。

在此处输入图像描述

更新1:

这是我发送给 JetBrains 支持人员的电子邮件。

我相信我面临的核心问题是我理解“始终切碎”设置,但我不理解“长切切”或“简单换行”。我还没有找到任何关于这些设置含义的文档,所以我将放弃我认为应该发生的事情。

我正在设置“包装对象集合和初始值设定项”。

Chop Always:

        cdata.GetByIdData = new Category {
            Id = "123",
            Name = "category"
        };
        vdata.GetByIdData = new Vendor {
            Id = "456",
            Name = "vendor"
        };
        adata.GetByIdData.Add(new Account {
            Id = "789",
            Name = "account",
            Balance = 5000
        });

        svc.ExecuteRequest(new AccountTransactionService.Add {
            Kind = AccountTransaction.KIND_DEBIT,
            Source = "789",
            Destination = "dst",
            Date = new DateTime(2011, 1, 1),
            Categories = new List<AccountTransactionService.CreateCategory> {
                new AccountTransactionService.CreateCategory {
                    Id = "123",
                    Amount = 200.50m
                }
            }
        });

Chop If Long:

        cdata.GetByIdData = new Category { Id = "123", Name = "category" };
        vdata.GetByIdData = new Vendor { Id = "456", Name = "vendor" };
        adata.GetByIdData.Add(new Account { Id = "789", Name = "account", Balance = 5000 });

        svc.ExecuteRequest(new AccountTransactionService.Add { Kind = AccountTransaction.KIND_DEBIT, Source = "789", Destination = "dst", Date = new DateTime(2011, 1, 1), Categories = new List<AccountTransactionService.CreateCategory> { new AccountTransactionService.CreateCategory { Id = "123", Amount = 200.50m } } });

给定 80 的边距,我希望 Chop If Long 看起来像这样:

        cdata.GetByIdData = new Category { Id = "123", Name = "category" };
        vdata.GetByIdData = new Vendor { Id = "456", Name = "vendor" };
        adata.GetByIdData.Add(new Account { Id = "789", Name = "account", Balance = 5000 });

        svc.ExecuteRequest(new AccountTransactionService.Add {
            Kind = AccountTransaction.KIND_DEBIT,
            Source = "789",
            Destination = "dst",
            Date = new DateTime(2011, 1, 1),
            Categories = new List<AccountTransactionService.CreateCategory> {
                new AccountTransactionService.CreateCategory {
                    Id = "123",
                    Amount = 200.50m
                }
            }
        });

I have the following code that when I run autoformat in ReSharper doesn't not get changed.

enter image description here

I thought Chop if long would cause a chop to occur if the right margin is exceeded.

If I turn on Chop always I get this.

enter image description here

This works, but I would rather not chop short statements like the first, which is what I assume Chop if long means.

Ideas?

Here are my ReSharper settings.

enter image description here

Turning on wrap long lines makes things even worse.

enter image description here

UPDATE1:

Here is the email I sent to JetBrains support.

The believe the central issues I'm facing is I understand the "chop always" setting, but I do not understand "chop if long" or "simple wrap". I have not found any documentation on what these settings mean, so I'm going off what I believe should be happening.

I am setting the "Wrap object collection and initializer".

Chop Always:

        cdata.GetByIdData = new Category {
            Id = "123",
            Name = "category"
        };
        vdata.GetByIdData = new Vendor {
            Id = "456",
            Name = "vendor"
        };
        adata.GetByIdData.Add(new Account {
            Id = "789",
            Name = "account",
            Balance = 5000
        });

        svc.ExecuteRequest(new AccountTransactionService.Add {
            Kind = AccountTransaction.KIND_DEBIT,
            Source = "789",
            Destination = "dst",
            Date = new DateTime(2011, 1, 1),
            Categories = new List<AccountTransactionService.CreateCategory> {
                new AccountTransactionService.CreateCategory {
                    Id = "123",
                    Amount = 200.50m
                }
            }
        });

Chop If Long:

        cdata.GetByIdData = new Category { Id = "123", Name = "category" };
        vdata.GetByIdData = new Vendor { Id = "456", Name = "vendor" };
        adata.GetByIdData.Add(new Account { Id = "789", Name = "account", Balance = 5000 });

        svc.ExecuteRequest(new AccountTransactionService.Add { Kind = AccountTransaction.KIND_DEBIT, Source = "789", Destination = "dst", Date = new DateTime(2011, 1, 1), Categories = new List<AccountTransactionService.CreateCategory> { new AccountTransactionService.CreateCategory { Id = "123", Amount = 200.50m } } });

I would expect Chop If Long to look like this given a margin of 80:

        cdata.GetByIdData = new Category { Id = "123", Name = "category" };
        vdata.GetByIdData = new Vendor { Id = "456", Name = "vendor" };
        adata.GetByIdData.Add(new Account { Id = "789", Name = "account", Balance = 5000 });

        svc.ExecuteRequest(new AccountTransactionService.Add {
            Kind = AccountTransaction.KIND_DEBIT,
            Source = "789",
            Destination = "dst",
            Date = new DateTime(2011, 1, 1),
            Categories = new List<AccountTransactionService.CreateCategory> {
                new AccountTransactionService.CreateCategory {
                    Id = "123",
                    Amount = 200.50m
                }
            }
        });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅忆 2025-01-15 04:57:35

仅当您打开“Wrap longlines”选项时,“Chop if long”才起作用,因此您应该打开它。我猜 http://youtrack.jetbrains.com/issue/RSRP-291146 阻止了打开“长行换行”后,您将无法获得所需的格式。好吧,它应该在 ReSharper 7.1 EAP 中得到修复 - 如果您仍然遇到问题,请尝试写信给我们。

"Chop if long" works only when you turn on "Wrap long lines" option, so you should turn it on. I guess that http://youtrack.jetbrains.com/issue/RSRP-291146 prevented you from getting the formatting you wanted with "Wrap long lines" turned on. Well, it should be fixed in ReSharper 7.1 EAP - try and write us if you still have problems.

夏天碎花小短裙 2025-01-15 04:57:35

将“包装对象集合和初始化程序”更改为“简单包装”,这应该按照您想要的方式设置代码样式。

不幸的是,我无法查找 Chop if long 应该做什么,因为 Resharper 社区站点由于某种奇怪的原因而无法工作。

Change "Wrap object collection and initialisers" to "Simple Wrap", that should style your code in the way you want it to.

Unfortunately, I can't look up what Chop if long is supposed to do as the Resharper community site is blocked from work for some strange reason.

青朷 2025-01-15 04:57:35

JetBrains 记录了一个问题,该问题描述的行为与您所描述的行为相同...

http://youtrack .jetbrains.com/issue/RSRP-291146

There is an issue logged with JetBrains that is depicting the same behavior you describe...

http://youtrack.jetbrains.com/issue/RSRP-291146

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文