Skip to content

Tighten the Last-Frame Exception Wording in the .NET Code Style #4528

Backlog

Description

@ptr727

Problem

The .NET console app interrupt rule in CODESTYLE.md "Interrupts in .NET" and the dotnet-codestyle Skill carry two defects a local review raised on the final head of the pull request that introduced them. That pull request's edit budget was spent, so both are deferred here.

  1. The leftover-removal example bound does not fit inside the container stop grace. "Interrupts in .NET" puts the kill bound below the container stop grace, 10 seconds by default, at a value such as 5 seconds. The bullet on what a child leaves behind gives the removal its own bound, "such as 10 seconds". For an app running as PID 1 whose child starts a sibling container, a docker stop can spend up to the kill bound on the child and then up to the removal bound on the removal. At the example values the removal and the log flush run past the 10-second grace, so the container runtime kills the app and the sibling container stays behind. The example value, or the rule's relation between the removal bound and the stop grace, needs a decision.
  2. Item 5's pointer misses the unhandled-exception handler. dotnet-codestyle item 5 ("do not swallow exceptions") names the last-frame catches, the unhandled-exception handler's guards among them, and points at "Interrupts in .NET". That handler is described in "Unhandled Exceptions in .NET", and neither section mentions its guards. The pointer should name both sections.

Recommendation

For the first, state the removal bound as fitting inside the container stop grace together with the kill bound, with an example such as 3 seconds. For the second, point item 5 at "Interrupts in .NET" and "Unhandled Exceptions in .NET".

Activity

  1. added
    enhancement
    on Nov 27, 2026
  2. ptr727 commented on Nov 27, 2026

    @ptr727
    OwnerAuthor

    Deferred From the Final Review of the Introducing Pull Request

    Both items in the body above are fixed in the pull request that introduced the rule. Its final local review raised two more on dotnet-codestyle item 5's last-frame exception, deferred here because that pull request's last round allowed no further edits.

    1. The cited sections state only some of the frames item 5 names. Item 5 names the entry point's final catch, a signal handler, the unhandled-exception handler's guards, and a fault-reporting callback, citing "Interrupts in .NET" and "Unhandled Exceptions in .NET". Those sections state the signal handler's catch-all and the fault-reporting callback. They give Main a try whose finally flushes the log, with no final catch, and describe the unhandled-exception handler with no guard. The entry point's final catch and the handler's guards appear only in the reference skeleton.
    2. The stated reason holds for only some of the frames. "Does not rethrow, since nothing above it can" is true for a signal handler and for the unhandled-exception handler's own guards. A rethrow from Main or from a fault-reporting callback reaches the UnhandledException handler, which "Unhandled Exceptions in .NET" has log and flush. The reasons there are different: Main turns a failure into the error exit status, and an exception escaping a callback aborts the process before cleanup.

    Recommendation

    State the reason per frame kind, or reword the principle as "a catch where a rethrow would only reach the unhandled-exception path", and name the entry point's final catch in "Interrupts in .NET" so the citation covers every frame item 5 lists.

  3. ptr727 commented on Nov 28, 2026

    @ptr727
    OwnerAuthor

    State After the Merge

    The pull request that this issue follows merged into develop, and it carries both points in the body above. The removal bound is stated against the stop grace, and item 5 points at both sections.

    What stays open is the pair of wording gaps in the comment above, on item 5's last-frame sentence. The title now names that.

  4. changed the title [-]Fit the .NET Leftover-Removal Bound Inside the Stop Grace and Point Item 5 at Both Sections[/-] [+]Tighten the Last-Frame Exception Wording in the .NET Code Style[/+] on Nov 28, 2026
  5. ptr727 commented on Nov 29, 2026

    @ptr727
    OwnerAuthor

    Related PR: #4544 widens item 5's translate arm so a bounded cancellation may become a domain result, matching the ToolRunner skeleton. Four precision follow-ups from its local review are listed in that PR body.

  6. ptr727 commented on Nov 29, 2026

    @ptr727
    OwnerAuthor

    Two wording follow-ups from the last local review of #4544, deferred here: (1) item 5 does not require a caller of an outcome-returning boundary to stop on a cancelled outcome or check the stop token itself. (2) 'Translate a fault' collides with the CODESTYLE 'Interrupts in .NET' meaning of fault, so 'failure' reads better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions