You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Use snippets in article
Responding to #50244
These files should remain in the repo, and should generally be included in the article
* Apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
---------
Co-authored-by: Copilot <[email protected]>
Copy file name to clipboardExpand all lines: docs/csharp/fundamentals/tutorials/xml-documentation.md
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Generate XML documentation from your source code
3
3
description: "Learn to add `///` comments that generate XML documentation directly from your source code. Learn which tags are available and how to add documentation blocks to types and members."
4
-
ms.topic: tutorial#Don't change.
4
+
ms.topic: tutorial
5
5
ms.date: 10/14/2025
6
6
ai-usage: ai-assisted
7
7
#customer intent: As a developer, I want to generate XML documentation comments so that other developers can use my code successfully.
@@ -50,7 +50,9 @@ Build the project now. You see warnings for any public members that are missing
50
50
</doc>
51
51
```
52
52
53
-
With the file in place, start adding targeted XML comments and immediately verify how each one appears in the generated output.
53
+
With the file in place, start adding targeted XML comments and immediately verify how each one appears in the generated output. Start with the `Transaction` record type:
When you're done, open the regenerated XML file and confirm that each member appears with your new elements. A trimmed portion might look like this:
69
75
70
76
```xml
@@ -83,19 +89,17 @@ When you're done, open the regenerated XML file and confirm that each member app
83
89
84
90
## Use `<inheritdoc/>` in derived classes
85
91
86
-
If you derive from `BankAccount` (for example, a `SavingsAccount` that applies interest), you can inherit base documentation instead of copying it. Add a self-closing `<inheritdoc/>` element inside the derived member's documentation block. You can still append more elements (such as extra `<remarks>` details) after `<inheritdoc/>` to document the specialized behavior.
92
+
If you derive from `BankAccount` (for example, a `SavingsAccount` that applies interest), you can inherit base documentation instead of copying it. Add a self-closing `<inheritdoc/>` element inside the derived member's documentation block. You can still append more elements (such as extra `<remarks>` details) after `<inheritdoc/>` to document the specialized behavior:
87
93
88
-
```csharp
89
-
/// <inheritdoc/>
90
-
/// <remarks>Adds monthly interest during month-end processing.</remarks>
> `<inheritdoc/>` reduces duplication and helps maintain consistency when you update base type documentation later.
96
98
97
99
After you finish documenting the public surface, build one final time to confirm there are no remaining CS1591 warnings. Your project now produces useful IntelliSense and a structured XML file ready for publishing workflows.
98
100
101
+
You can see the full annotated sample in [the source folder](https://github.com/dotnet/docs/tree/main/docs/csharp/fundamentals/tutorials/snippets/xml-documentation) of the [dotnet/docs](https://github.com/dotnet/docs) repository on GitHub.
102
+
99
103
## Build output from comments
100
104
101
105
You can explore more by trying any of these tools to create output from XML comments:
0 commit comments