Przejdź do treści
Biblioteka skilli
Programowanie · Pisanie

writing-xml-doc-comments

/writing-xml-doc-comments

Pisze i przegląda komentarze dokumentacyjne XML w C# dla publicznego API, z opisem parametrów i wartości zwracanych.

Repozytorium
revit-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
08.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 08.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pisze i przegląda komentarze dokumentacyjne XML w C# dla publicznego API, z opisem parametrów i wartości zwracanych.

Oryginalny opis (EN)

Write or review C# XML documentation comments on public API surface. USE FOR: adding or reviewing XML documentation on public types, members, parameters, type parameters, and return values. DO NOT USE FOR: ordinary code comments (use csharp-style), or prose, markdown, README, and wiki text; those follow the writing standard.

Jak działa

  1. When to use
  2. Rules
  3. Tag order
  4. Summary opening by member kind
  5. Parameters, returns, and exceptions
  6. Inherited documentation
  7. Cross-references and inline markup
  8. What belongs in remarks
  9. Examples
  10. Validation
Sekcje z nagłówków SKILL.md, w oryginale · 274 linii, 2 105 słów
Podgląd SKILL.md
---
name: writing-xml-doc-comments
description: >
    Write or review C# XML documentation comments on public API surface.
    USE FOR: adding or reviewing XML documentation on public types, members, parameters, type parameters, and return values.
    DO NOT USE FOR: ordinary code comments (use csharp-style), or prose, markdown, README, and wiki text; those follow the writing standard.
license: MIT
---

# Writing XML Doc Comments

Write reference documentation to an enterprise production standard, not tutorial or learning material.
Document the contract a caller depends on, not the mechanics a reader can see in the signature.
The conventions match Microsoft's own guidance for writing .NET API reference comments: complete, correct, contextual, and polished.
Every tag opens with a third-person singular verb, has no personal pronoun, and states a contract instead of a mechanism.

## When to use

- Adding a public or protected type, member, or contract to a library or a shared assembly.
- Reviewing XML documentation for coverage, tag order, opening phrasing, and contract accuracy.
- Closing documentation gaps reported by CS1591 or CS1573.

## Rules

- Give every public and protected type, member, parameter, type parameter, and return value its tag.
- Put the text on its own line between the opening and closing tag, indented four spaces past the `///` marker; use the one-line form for a single short clause.
- Indent a nested tag one level further, and indent a `<code>` block to the level its rendered output needs.
- Write one sentence per tag and end it with a period; move a second sentence to `<remarks>`.
- Ignore the line length; the text of a tag occupies one line however long it runs, and no line is wrapped by hand.
- State the contract; never restate the name or the parameter list in words.
- Describe observable behavior, not the current implementation.
- Describe the member as it stands, not the change that produced it.
  The caller reading the documentation has no previous version to compare against.
- State facts in the present indicative; never argue why.
- Never use a personal pronoun (`you`, `we`, `I`); state the fact about the member instead.
- Cut every purpose, result, cause, or comparison clause (`so`, `that makes`, `which makes`, `because`, `rather than`); if the clause states a fact the reader needs, make it its own sentence.

## Tag order

Write the tags in this order.

1. `<summary>`
2. `<value>` — a property whose default or unit the caller needs
3. `<typeparam>` — one per type parameter, in declaration order
4. `<param>` — one per parameter, in declaration order
5. `<returns>`
6. `<exception>` — one per contract throw
7. `<remarks>`
8. `<example>`

## Summary opening by member kind

The skeleton is identical for every declaration; the opening phrase is what changes.

| Declaration                        | Summary opens with                                             | Example                                                                                 |
|------------------------------------|----------------------------------------------------------------|-----------------------------------------------------------------------------------------|
| Class, struct, record              | `Represents …`, `Provides …`, `Defines …`                      | `Represents the host portion of a URI.`                                                 |
| Static class with extensions       | `Extension methods for …`, `Provides extension methods for …`  | `Provides extension methods for <see cref="IEndpointRouteBuilder" /> to add endpoints.` |
| Interface                          | `Defines a contract that …`, `Provides an interface for …`     | `Defines a contract that represents the result of an HTTP endpoint.`                    |
| Attribute                          | `Specifies …`                                                  | `Specifies a collection of tags in <see cref="Endpoint.Metadata" />.`                   |
| Exception type                     | `Represents … error`                                           | `Represents an HTTP request error.`                                                     |
| Delegate                           | `A function that …`, `A delegate that …`                       | `A function that can process an HTTP request.`                                          |
| Enum                               | `Determines …`, `Indicates whether …`                          | `Determines how cookie security properties are set.`                                    |
| Enum member                        | the effect of selecting the value                              | `Opts out of compression over HTTPS.`                                                   |
| Constant, static readonly field    | the meaning of the value                                       | `HTTP status code 201.`                                                                 |
| Constructor                        | `Initializes a new instance of the <see cref="T" /> class.`    | —                                                                                       |
| Read-only property                 | `Gets …`                                                       | `Gets the HTTP status code for this exception.`                                         |
| Read-write property                | `Gets or sets …`                                               | `Gets or sets the prefix used to identify the current object.`                          |
| Boolean property                   | `Gets a value indicating whether …`                            | —                                                                                       |
| Event                              | `An event that fires when …`, `An event that is raised when …` | `An event that is raised when a field value changes.`                                   |
| Factory method                     | `Creates a <see cref="T" /> …`                                 | `Creates a <see cref="ChallengeHttpResult" /> for the response.`                        |
| Registration method                | `Adds … to the specified <see cref="IServiceCollection" />.`   | —                                                                                       |
| Override, interface implementation | `<inheritdoc />`                                               | —                                                                                       |
| Explicit interface implementation  | no doc comment                                                 | —                                                                                       |

A delegate has its `<param>` and `<returns>` on the type declaration.
An `extension` block has a `<param>` for its receiver, placed on the block; each member inside the block documents only its own parameters.

## Parameters, returns, and exceptions

- Write `<param>` and `<returns>` as noun phrases opening with `The`, `A`, or `An`, and end them with a period.
- An async method returns `A task that represents the asynchronous <operation> operation.`; name the produced value when the task has one.
- A builder or registration method returns `The <see cref="T" /> for chaining.` or `A <see cref="T" /> that can be used to further customize the …`.
- A `Try` method documents the `out` parameter as `When this method returns, contains …`, and returns `<see langword="true" /> if …; otherwise, <see langword="false" />.`.
- State what a null or empty result means in `<summary>` or `<returns>`.
- Reserve `<exception>` for a throw that is part of the contract; an argument guard at entry gets none.
- Never add an empty tag to silence CS1573; describe the parameter.

## Inherited documentation

- Put `<inheritdoc />` on an override and on an implicit interface implementation.
- Add `<remarks>` under `<inheritdoc />` when the implementation adds a caller-visible constraint the base contract does not state.
- Use `<inheritdoc cref="…" />` when the source is not the immediate base member.
- Add no doc comment to an explicit interface implementation.
  The interface documents the contract.

## Cross-references and inline markup

- Reference every type or member named in text with `<see cref="…" />`.
  A rename refactoring updates the reference.
- Reference the current member's parameters with `<paramref name="…" />` and `<typeparamref name="…" />`.
- Write keywords as `<see langword="true" />`, `<see langword="false" />`, `<see langword="null" />`.
- Use `<c>` for a literal value or fragment that names no symbol.
- Link external documentation with `<see href="https://…">Title</see>`; HTTPS only.
- Use `<list type="bullet">` with `<item><description>…</description></item>` when the behavior branches on argument combinations.
- Add a prose `<example>` on a parsing or accessor member to show what a concrete input yields.
- Add `<example>` with `<code>` on an attribute or entry-point API whose call shape is not obvious from the signature; ordinary members get none.
- Use `<para>` only to split a long `<remarks>`.

## What belongs in remarks

A default value, a threading or reentrancy rule, an ownership or disposal rule, a platform limit, an interaction with another member, or the behavior on an edge input.

## Examples

```csharp
/// <summary>
///     Represents a session opened against a document store.
/// </summary>
public sealed class DocumentSession : IDisposable
{
    /// <summary>
    ///     Initializes a new instance of the <see cref="DocumentSession" /> class.
    /// </summary>
    /// <param name="store">The store the session reads from.</param>
    public DocumentSession(IDocumentStore store)
    {
        Store = store;
    }

    /// <summary>
    ///     Gets the store the session reads from.
    /// </summary>
    public IDocumentStore Store { get; }

    /// <summary>
    ///     Gets or sets the timeout applied to every read.
    /// </summary>
    /// <value>Defaults to 30 seconds.</value>
    public TimeSpan ReadTimeout { get; set; } = TimeSpan.FromSeconds(30);

    /// <summary>
    ///     Gets a value indicating whether the session has an open transaction.
    /// </summary>
    public bool IsTransactional { get; }

    /// <summary>
    ///     An event that is raised when the session loads a document.
    /// </summary>
    public event EventHandler<DocumentLoadedEventArgs>? DocumentLoaded;

    /// <summary>
    ///     Loads the document stored under the specified identifier.
    /// </summary>
    /// <param name="documentId">The identifier of the document to load.</param>
    /// <param name="cancellationToken">A <see cref="CancellationToken" /> used to cancel the operation.</param>
    /// <returns>
    ///     A task that represents the asynchronous load operation.
    ///     The task result contains the loaded document, or <see langword="null" /> when the identifier is unknown.
    /// </returns>
    /// <exception cref="ObjectDisposedException">The session is closed.</exception>
    /// <remarks>The caller owns the returned document and disposes it.</remarks>
    public async Task<Document?> LoadAsync(string documentId, CancellationToken cancellationToken = default)
    {
        ...
    }

    /// <inheritdoc />
    public void Dispose()
    {
        ...
    }
}
```

```csharp
/// <summary>
///     Defines a contract that resolves a document by its identifier.
/// </summary>
public interface IDocumentResolver
{
    /// <summary>
    ///     Resolves the document stored under the specified identifier.
    /// </summary>
    /// <param name="documentId">The identifier of the document to resolve.</param>
    /// <param name="document">When this method returns, contains the resolved document if the identifier is known.</param>
    /// <returns><see langword="true" /> if the document was resolved; otherwise, <see langword="false" />.</returns>
    bool TryResolve(string documentId, [NotNullWhen(true)] out Document? document);
}

/// <summary>
///     Resolves a document from the local file system cache.
/// </summary>
public sealed class CachedDocumentResolver : IDocumentResolver
{
    /// <inheritdoc />
    public bool TryResolve(string documentId, [NotNullWhen(true)] out Document? document)
    {
        ...
    }
}
```

```csharp
/// <summary>
///     Determines how a session resolves a document that is absent from the cache.
/// </summary>
public enum CacheMissBehavior
{
    /// <summary>
    ///     Reads the document from the store and adds it to the cache.
    /// </summary>
    Fetch,

    /// <summary>
    ///     Returns no document and does not modify the cache.
    /// </summary>
    Skip
}

/// <summary>
///     A function that transforms a document before it is returned to the caller.
/// </summary>
/// <param name="document">The document to transform.</param>
/// <returns>The transformed document.</returns>
public delegate Document DocumentTransform(Document document);
```

```csharp
/// <summary>
///     Provides extension methods for <see cref="IServiceCollection" /> to register document storage.
/// </summary>
public static class DocumentStorageServiceCollectionExtensions
{
    /// <param name="services">The <see cref="IServiceCollection" /> to add the services to.</param>
    extension(IServiceCollection services)
    {
        /// <summary>
        ///     Adds the document storage services to the specified <see cref="IServiceCollection" />.
        /// </summary>
        /// <param name="configure">An optional action to configure the <see cref="DocumentStorageOptions" />.</param>
        /// <returns>The <see cref="IServiceCollection" /> for chaining.</returns>
        public IServiceCollection AddDocumentStorage(Action<DocumentStorageOptions>? configure = null)
        {
            ...
        }
    }
}
```

## Validation

- [ ] Every public and protected type, member, parameter, type parameter, and return value has its tag; the build reports no CS1591 or CS1573.
- [ ] Tags appear in the order summary, value, typeparam, param, returns, exception, remarks, example.
- [ ] Multi-line tag text is indented four spaces past the `///` marker, and a nested tag one level further.
- [ ] The summary opening matches the member kind, and a property opens with `Gets`, `Gets or sets`, or `Gets a value indicating whether`.
- [ ] Overrides and implicit interface implementations use `<inheritdoc />`; explicit interface implementations have no doc comment.
- [ ] Every type and member named in text is a `<see cref="…" />`, and `true`, `false`, and `null` are `<see langword="…" />`.
- [ ] `<exception>` lists only contract throws; argument guards at entry have none.
- [ ] Null and empty-result meaning appears in the summary or returns; ownership, defaults, and threading rules appear in remarks or value.
- [ ] Text states facts about the member as it stands; none narrates the change or argues why.
- [ ] No tag contains `you`, `we`, or `I`.

## Common Pitfalls

| Pitfall                                                       | Correct approach                                           |
|---------------------------------------------------------------|------------------------------------------------------------|
| `<summary>Gets the name.</summary>` on `GetName()`            | State what the name is and any constraint.                 |
| A property summary without `Gets` or `Gets or sets`           | Open with the accessor verb the member exposes.            |
| Re-summarizing an override or interface implementation        | Use `<inheritdoc />`.                                      |
| Documenting an explicit interface implementation              | Omit the doc comment; the interface states the contract.   |
| An empty `<param></param>` added to silence CS1573            | Describe the parameter.                                    |
| `<exception cref="ArgumentNullException">` for an entry guard | Document only a throw that is part of the contract.        |
| `<remarks>` placed before `<param>` on a method               | Put `<remarks>` after `<returns>`.                         |
| Multi-line tag text flush against `///`                       | Indent it four spaces past the marker.                     |
| Documenting the implementation ("loops over items")           | Describe the observable contract.                          |
| Hardcoding a type name in prose                               | Use `<see cref="TypeName" />`.                             |
| Writing `true`, `false`, or `null` as plain text              | Use `<see langword="true" />`.                             |
| Ownership, default value, or unit not stated                  | State it in `<remarks>` or `<value>`.                      |
| Narrating the change ("now returns null when…")               | Describe the member as it stands.                          |
| "You must dispose the returned stream."                        | "The caller disposes the returned stream."                 |

Wersje

W bazie nie ma innych skilli o nazwie writing-xml-doc-comments.

Migawka bazy z 13.11.2026 · wersja paczki d5a83d75a228 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 1 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90csharp-style
    Pisze i przegląda kod w C# według zasad stylu, pomijając komentarze XML i zwykły tekst.
  • 100code-comments
    Pisze, przegląda i usuwa komentarze w kodzie oraz komentarze dokumentacyjne, także w diffach.
  • 100technical-writing
    Pisze i przegląda opisy kontraktów, zachowań i decyzji w markdownie, na wiki i w README, sprawdzając, czy czytelnik ma nową informację.
  • 100api-docs
    Dodaje i recenzuje komentarze dokumentacyjne XML w C# dla publicznych API SkiaSharp: dokumentowanie klas i członków, uzupełnianie braków i poprawianie błędnych przykładów.
  • 100api-doc-comments
    Pomaga pisać komentarze dokumentacyjne w Rust, które dają dokładną wygenerowaną dokumentację kontraktu, dla typów Instantiate, Execute, Query i Response oraz publicznych API schematu.
  • 100go-documentation
    Pomaga pisać i recenzować komentarze doc w Go oraz tworzyć eksportowane typy, funkcje i pakiety, także bez prośby o dokumentację.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.