PowerShell / PowerShell/PSScriptAnalyzer

Extra level of indentation within #region/#endregion tags

未关闭
#1,562 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Area - Formatter Issue - Enhancement
主要语言
C#
星标
2.2k
派生
414
平均合并
13 小时 1 分钟
30 天内合并 PR
2

描述

Support indenting an extra level inside regions, both with analyzing and auto-formatting, so it's possible to verify/auto-format code to look like this:

#region
    Get-ChildItem
#endregion

Currently the formatter will do this (because #region/#endregion isn't a token that merits an indent

#region
Get-ChildItem
#endregion

After discussing in the PowerShell slack, I was pointed towards this area where the change would need to be made:
https://github.com/PowerShell/PSScriptAnalyzer/blob/c78f5a60c1f49a5e767286ff6323a2ec0788991a/Rules/UseConsistentIndentation.cs#L146
I believe specifically this would need to be handled in the default part of the switch block.
Per @bergmeister this would most likely get added as a configurable option for the PSUseConsistentIndentation rule.

I'm putting this here because I sort of volunteered to work on it, but it will be a very low priority for me, and also I don't want this information to disappear from the Slack buffer and be gone entirely.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Rules/UseConsistentIndentation.cs 中引用行附近的 switch 块开始,尤其检查其 default case。检查 PSUseConsistentIndentation 规则如何处理配置,然后定义这项更改,使分析和自动格式化都能够对 #region/#endregion 标签内的代码进行缩进。当所示的 region 布局可通过预期的可配置选项得到支持时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, powershell
领域
tooling
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。