A pending Task<T> can hang the failure message in a trimmed app

Open
#52 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
testing

Research direction

Start in src/Vouch/Formatting/Formatter.cs, reading SafeMembers, the Write chain, and MemberCache.IsSafeOnly to understand how trimming affects the safe-member lookup and equivalency. Reproduce the hang with a trimmed app that fails an assertion on a pending Task<int>, then check the existing FormatterTests cases for Task<Int32> and Lazy<Int32>. Done means the trimmed app prints the task status and exits, those tests pass, and the Release build completes with zero warnings.

Written by the indexing model from the issue text.

Description

Goal

In a trimmed app, a failure message that prints a pending Task<T>, ValueTask<T> or Lazy<T> still prints only its safe member and never blocks or runs the factory.

Where

  • src/Vouch/Formatting/Formatter.cs: SafeMembers (looks up Status, IsCompleted, IsValueCreated with GetProperty) and the Write chain that calls it.

Found while checking the CodeRabbit thread on #51. Read in the code, not yet reproduced in a trimmed publish.

If trimming removed Task.Status, SafeMembers returns null and Write falls through to the unrestricted WriteObject, which reads every public property. On a task that has not finished, Task<T>.Result blocks, so writing the failure message hangs. ValueTask<T> falls back to Result the same way, and Lazy<T> to Value, which runs the factory. This path is older than #51, which only added the trim annotations.

Likely fix: [DynamicDependency] on SafeMembers for those members, so trimming keeps them. Another option is to print the type name alone when the safe member is missing.

Done when

  • A trimmed publish of a small app that fails an assertion on a pending Task<int> prints Status = WaitingForActivation and exits.
  • FormatterTests still pass, including the Task<Int32> { Status = WaitingForActivation } and Lazy<Int32> { IsValueCreated = false } cases.
  • dotnet build src/Vouch -c Release -warnaserror gives 0 warnings.

Risks

  • MemberCache calls IsSafeOnly, which also uses SafeMembers. Equivalency must not change.

Out of scope

Other members WriteObject reads.

Dominant language
C#
Stars
0
Forks
1
Avg merge
1h 56m
Merged PRs (30d)
26

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from BaryoDev/Vouch

All issues in BaryoDev/Vouch

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.