Documentation for CSharpSyntaxWalker constructor needs clarification of "depth" parameter
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- documentation
Research direction
Start with dotnet/xml/Microsoft.CodeAnalysis.CSharp/CSharpSyntaxWalker.xml, the Content Source named in the issue, and review the CSharpSyntaxWalker constructor, class, and Depth property entries. Update the documentation to explain the default depth behavior, token and trivia visitation, and the meaning of Depth; done means each requested API page clearly describes these behaviors.
Written by the indexing model from the issue text.
Description
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
depthparameter 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.
- ID: 7f4df4eb-e177-be67-06f2-6cd65d8cbac9
- Version Independent ID: 0b46d8cb-407a-94ed-a5a0-13528960b2a9
- Content: CSharpSyntaxWalker Class (Microsoft.CodeAnalysis.CSharp)
- Content Source: dotnet/xml/Microsoft.CodeAnalysis.CSharp/CSharpSyntaxWalker.xml
- Product: dotnet-roslyn-api
- Technology: microsoft.codeanalysis
- GitHub Login: @dotnet-bot
- Microsoft Alias: dotnetcontent
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 14h 40m
- Merged PRs (30d)
- 302
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/docs
-
:watch: Not Triaged dotnet-target-version
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
:watch: Not Triaged dotnet-fundamentals/svc
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
SYSLIB1219 (and placeholder SYSLIB1218) missing from the options-validation source-generator diagnostics referencePossibly taken A pull request linked to this issue is open or already merged. Open:watch: Not Triaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dotnet/docs#56285 · 1 comment ·
Maintainers usually reply within 1 day
-
Add more to the documentationPossibly taken @adarsh6980 claimed this 10 days ago. Opendotnet-fsharp/svc help wanted
Difficulty 1/5 Under an hour Newbie friendliness 90/100
dotnet/docs#56209 · 2 comments ·
Maintainers usually reply within 1 day
-
:watch: Not Triaged
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
Similar issues
-
skills.mdx: ReadResourceDirectoryRequest does not type-check against the 2026-07-28 base schemaOpen
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
modelcontextprotocol/ext-skills#156 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
open-telemetry/opentelemetry-go-compile-instrumentation#1445 ·
Maintainers usually reply within 2 days
-
docs
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
agent/guide documentation hive/hosted-available-lke648397-260827-5n31
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
CopilotKit/OpenDots#55 ·
Maintainers usually reply within 1 day