Skip to content

Bug: sort-email-oversized-with-untestable-io-and-dialog-paths #956

Description

@drmoisan
  • Work Mode: full-bug

Summary

UtilitiesCS/EmailIntelligence/EmailParsingSorting/SortEmail.cs is 1,454 lines, nearly three times the 500-line limit. It also mixes sorting logic with direct file-system and WinForms dialog calls that tests cannot reach. #945 added one injected seam for directory creation, and its review reported three residual follow-ups, recorded here together because they share one cause and one file.

Environment

Steps to Reproduce

  1. Count the lines in SortEmail.cs: 1,454.
  2. Read TrySaveAttachmentAsync. It carries [ExcludeFromCodeCoverage] because of the YesNoToAll.ShowDialog prompt, and its UnauthorizedAccessException branches are untested.
  3. Search the other SortEmail helpers for direct System.IO.Directory and System.IO.File calls.

Expected Behavior

  • Each file is under 500 lines, with cohesive partial classes or extracted types.
  • UI prompts and file-system access sit behind injectable seams, so the coverage exclusion can be removed and the error branches tested.

Actual Behavior

  • The file is over the limit.
  • The dialog branch forces a coverage exclusion.
  • Other helpers may still touch the real file system.

Logs / Screenshots

Impact / Severity

  • Blocker
  • High
  • Medium
  • Low

Source

From: docs/features/potential/2026-10-01-sort-email-oversized-with-untestable-io-and-dialog-paths.md

Activity

  1. drmoisan commented on Oct 1, 2026

    @drmoisan
    OwnerAuthor

    Restoring sections dropped by the promotion tooling.

    Suspected Cause / Notes

    The legacy static-class design (SortEmail is static) keeps I/O and UI inline. Per-call delegate seams, as used in #945, are safe under parallel tests. Settable static seams are not. Sequence this after #945 merges, because it touches the same file.

    Proposed Fix / Validation Ideas

    • Split SortEmail.cs (1,454 lines) by responsibility into partial files or types under 500 lines each, with no behavior change and the existing tests green.
    • Put YesNoToAll.ShowDialog behind an injected prompt delegate or interface, remove [ExcludeFromCodeCoverage] from TrySaveAttachmentAsync, and add tests for the UnauthorizedAccessException branches.
    • Inventory the remaining direct Directory and File calls in SortEmail helpers, and give each one a seam or a recorded justification.
  2. added a commit that references this issue on Oct 6, 2026
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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions