-
-
Notifications
You must be signed in to change notification settings - Fork 110
perf: use static Task in MethodAssertionGenerator generated code
#4543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
SummaryOptimizes generated code by caching the successful assertion result task in a static field. Critical IssuesMissing snapshot test updates - The PR modifies source generator output but does not include updated verified.txt files. TUnit CRITICAL RULE 2 requires snapshot tests to be updated when source generator output changes. The generated code will now include a static field and changed return logic affecting MethodAssertionGeneratorTests snapshot files. Required: Run snapshot tests, review changes, update verified.txt files and commit them. SuggestionsThe optimization follows TUnit Performance First principle. Caching the success case is good. The failure case correctly allocates new Task for unique error messages. VerdictREQUEST CHANGES - Missing required snapshot test updates |
Improve generated code by
MethodAssertionGeneratorto sometimes emitprivate static readonly Task<AssertionResult> _passedTask = Task.FromResult(AssertionResult.Passed);and return it.protected static readonly Task<AssertionResult> _passedTaskinherited fromAssertion<T>, but I didn't want to change the existing api.Again I'll ask you to update the snapshot tests, I've rebased and I still get the Sourcy error 😅
Before
After