Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Documentation for CSharpSyntaxWalker constructor needs clarification of "depth" parameter

未关闭 适合新手
#33,866 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
停滞
技术栈
csharp
领域
documentation

调研方向

从 dotnet/xml/Microsoft.CodeAnalysis.CSharp/CSharpSyntaxWalker.xml 开始,查看 issue 中指定的 Content Source,并检查 CSharpSyntaxWalker 构造函数、类和 Depth 属性条目。更新文档,以说明 Depth 的默认行为、token 和 trivia 的访问方式,以及 Depth 的含义;完成的标准是每个请求的 API 页面都清楚地描述这些行为。

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

描述

:watch: Not Triaged dotnet-roslyn-api/svc microsoft.codeanalysis/subsvc

Currently, in a derived syntax walker without an explicit constructor, the syntax walker will not visit tokens or trivia nodes. This is extremely non-obvious.

I wasted about half a day discovering this behavior, confirming it, opening an issue, discovering the underlying cause, and then closing the issue (see #66713).

The documentation desperately needs improvements in this regard.

First, the Constructor page should better explain both the usage and the default value of the terribly named depth parameter. Currently, it lists only the name and data type of the parameter and no additional information. I suggest adding something like the following:

The value of this parameter limits the types of nodes that will be visited. With its default value of SyntaxWalkerDepth.Node, neither tokens nor trivia are visited.

Next, the Class page should warn that by default this class will not visit tokens or trivia nodes. I suggest adding something like the following:

By default, this class will not visit tokens or trivia. To change this behavior, supply a different value for the depth parameter of the constructor.

Next, on the same page, the documentation for the Depth property should be improved. Currently, it only provides the property name and no further information. I suggest adding something like the following:

Gets a value that indicates the types of nodes that will be visited.

Finally, on the Property page for Depth, a similar description should be added. Currently, it only provides the name and data type and no further information.

Regarding the poor naming of the parameter and property, the word "depth" generally has a different meaning when referring to a tree data structure. There, it is a measure of the distance between a given node and the root of the tree.

In this class, the name depth refers to a filter that limits the types of nodes that will be visited. While this loosely relates to the previously mentioned concept of "depth", since descent stops at the depth where a node does not match the filter, it is nonetheless poorly named.

Better names include: "depthLimit", "depthFilter", "filter", "limit", and frankly almost anything else 😄


Document Details

⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

主要语言
没有语言数据
星标
4.8k
派生
6.1k
平均合并
1 天 3 小时
30 天内合并 PR
167

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

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

dotnet/docs 的其他 Issue

查看 dotnet/docs 的全部 Issue

相似的 Issue

更多 Documentation Issue

把新 issue 发到你的邮箱

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