csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Sort Using with additional grouping

Open VleaStwo opened this issue 7 months ago • 2 comments

Input:

using System;
using Microsoft.Extensions.Logging;
using System.IO;
using System.Text;
using MyCompany.Project;
using MyCompany.Utilities;
using Newtonsoft.Json;

Output:

using System;
using System.IO;
using System.Text;
using Microsoft.Extensions.Logging;
using MyCompany.Project;
using MyCompany.Utilities;
using Newtonsoft.Json;

Expected behavior:

using System;
using System.IO;
using System.Text;

using Microsoft.Extensions.Logging;

using MyCompany.Project;
using MyCompany.Utilities;

using Newtonsoft.Json;
  • English (Generated by translation tools) Currently, the plugin removes blank lines in the namespace import list and sorts them alphabetically. I would like to suggest adding a "grouping" feature:
    Group namespaces by their common prefix (split by dot), and insert a blank line between different groups. The grouping behavior can refer to Visual Studio's Edit.SortUsing feature.

  • 中文原文 目前插件会删除命名空间引用列表中的空行,并按命名空间字母升序排列。希望能增加一个“分组”功能:
    根据点号(.)分割,将相同前缀的命名空间作为一组,并在组与组之间增加空行。具体分组方式可参考 Visual Studio 的 Edit.SortUsing 功能。

VleaStwo avatar May 28 '25 07:05 VleaStwo

#1305 is for respecting existing empty lines between using when sorting them. I don't think the majority of users would want extra lines automatically inserted between groups so don't see a compelling reason to automatically do that.

belav avatar May 28 '25 14:05 belav

Thank you for your response

[#1305]

Sorry, I brought up the same topic again. I tried searching but couldn't find it. It should be a problem with my keywords.

I don't think the majority of users would want extra lines automatically inserted between groups so don't see a compelling reason to automatically do that.

I think line breaks (grouping) can provide a clearer structure of references. Of course you are right, there is no sufficient reason to do so automatically. Therefore, I understand this decision. Thanks again

VleaStwo avatar May 28 '25 15:05 VleaStwo