PowerShell / PowerShell/PSScriptAnalyzer
Rule Idea: .NET Constructor Auto Document/Align
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 13 小时 1 分钟
- 30 天内合并 PR
- 2
描述
Summary of the new feature
When instantiating dotnet objects with [Class]::new(), the syntax is generally obtuse for anyone coming along to read it. Reflection could be used to expand out the definition to the proper constructor from the OverloadDefinitions using the AST and comment the properties, since hashtable constructor syntax only works if the object has no constructors.
Proposed technical implementation details (optional)
Before:
[datetime]::new(2000, 6, 20)
After formatting:
[DateTime]::new(
2000, #int year
6, #int month
20, #int day
)
Major issue here would be variables, since Powershell is not statically typed it won't know what type the variable should be until runtime. This is only the problem in the case of overloaded constructors with the same number of arguments, maybe could still work if someone strongly typed the variable ahead of time that the AST could parse, e,g, [int]$Month?
What is the latest version of PSScriptAnalyzer at the point of writing
1.19.1.0
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先审查提议的 PowerShell AST 和 reflection 方法,包括来自 OverloadDefinitions 的构造函数元数据,以及与变量和重载构造函数相关的限制。定义支持的情况和示例前后输出的预期格式,然后为这些情况添加有针对性的覆盖测试。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- powershell
- 领域
- tooling
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100