Skip to content

Refactor Assert.That into focused partial-class files#8367

Open
Copilot wants to merge 1 commit into
mainfrom
copilot/refactor-split-assert-that-file
Open

Refactor Assert.That into focused partial-class files#8367
Copilot wants to merge 1 commit into
mainfrom
copilot/refactor-split-assert-that-file

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Assert.That.cs had grown into a 1.5K-line mixed-responsibility file, making the assertion pipeline hard to navigate. This change keeps API/behavior intact and splits internal logic into focused partial-class files under Assertions/.

  • Public API surface kept in Assert.That.cs

    • Retained namespace/class declaration, constants, failure sentinel, and the public Assert.That(...) entry point.
    • Removed internal helper implementations from this file so it is now API-focused.
  • Expression evaluation extracted

    • Added Assert.That.ExpressionEvaluator.cs.
    • Moved recursive expression-walk/evaluation methods (including short-circuit, coalesce, and conditional handling).
  • Expression replacement extracted

    • Added Assert.That.ExpressionReplacer.cs.
    • Moved sub-expression replacement helpers used to simplify expression rendering.
  • Failure-detail extraction extracted

    • Added Assert.That.DetailExtractor.cs.
    • Moved variable/member/method/index detail collection and sentinel translation helpers.
  • Expression formatting extracted

    • Added Assert.That.ExpressionFormatter.cs.
    • Moved expression-text cleanup and value-formatting helpers, including compiler-generated wrapper cleanup utilities.
    • IsFuncOrActionType and CompilerGeneratedDisplayClassRegex remain private helpers.
// Assert.That.cs (entry point only)
public static partial class AssertExtensions
{
    public static void That(Expression<Func<bool>> assertion, string? message = null) { ... }
}

// Assert.That.ExpressionEvaluator.cs
public static partial class AssertExtensions
{
    private static object? EvaluateExpression(Expression expression, Dictionary<Expression, object?> cache) { ... }
}

Copilot AI requested review from Copilot and removed request for Copilot May 19, 2026 19:51
Copilot AI linked an issue May 19, 2026 that may be closed by this pull request
5 tasks
Copilot AI changed the title [WIP] Refactor split Assert.That.cs into focused partial-class files Refactor Assert.That into focused partial-class files May 19, 2026
Copilot AI requested a review from Evangelink May 19, 2026 19:57
@Evangelink Evangelink marked this pull request as ready for review May 20, 2026 06:32
Copilot AI review requested due to automatic review settings May 20, 2026 06:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Split Assert.That.cs (1522 lines) into focused partial-class files

3 participants