Skip to content

Proposal: Automatic documentation for potential exceptions #15573

Open
@alrz

Description

@alrz

Currently you can carelessly throw exceptions without any documentation for the client unless you manually write <exception> doc tags above the method. I suggest to automate this so that all potential exceptions would be added to method's doc automatically and Quick Info can show them.

/// <exception cref="ExceptionA"></exception>
void F() => throw new ExceptionA();
/// <exception cref="ExceptionB"></exception>
void G() => throw new ExceptionB();
/// <exception cref="ExceptionA"></exception>
/// <exception cref="ExceptionB"></exception>
void H() { F(); G(); }

->

void F() => throw new ExceptionA();
void G() => throw new ExceptionB();
void H() { F(); G(); }

If the method is outside of the assembly boundary, we can infer exception tags from documentation of the used methods.

It would be also helpful if a code fix add those tags to include the descriptions of the reasons why these exceptions could be thrown. I think this can be an alternative to checked exception (a la Java) to encourage people to document exceptions without forcing them to write try catch.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions