TestDataAnalyzer: detect Func<T> by symbol instead of display-string prefix
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
The three display-string checks are at src/TUnit.Analyzers/TestDataAnalyzer.cs lines 548, 569 and 870; line 870 may live on the branch from #7347 rather than main. Look at how TestDataRow1 is already compared by symbol in the same file and mirror that pattern. Done means all three sites compare OriginalDefinition against a System.Func1 symbol resolved once per compilation, and tests/TUnit.Analyzers.Tests still pass.
Written by the indexing model from the issue text.
Description
TestDataAnalyzer detects Func<T> by calling ToDisplayString().StartsWith("System.Func<", StringComparison.Ordinal). This allocates a display string during analysis and relies on formatting instead of symbol identity.
Current code
Following merged PR #7347 (#7227), the three checks are:
- Two property-injection checks in
src/TUnit.Analyzers/TestDataAnalyzer.cs, usingfuncTypeandfuncTypeForError. TryUnwrapFuncin the same file, called while peeling the supported data-row wrappers.
Both automated reviewers raised this as non-blocking on #7347 (review comment). That prerequisite has merged; this issue is available for implementation.
Acceptance criteria
- Resolve
System.Func`1once per compilation withCompilation.GetTypeByMetadataName("System.Func`1"). - Compare
OriginalDefinitionwithSymbolEqualityComparer.Defaultin all three checks, as the analyzer already does forTestDataRow<T>. - Preserve the existing wrapper-peeling order and property-injection behavior.
- Add analyzer cases for
Func<TestDataRow<(int, int)>>andTestDataRow<Func<(int, int)>>against an(int a, int b)test signature. These are regression coverage for the existing tuple expansion after wrapper peeling; there is no known defect in that ordering. - Run the relevant
TUnit.Analyzers.Testscoverage.
- Dominant language
- C#
- Stars
- 4k
- Forks
- 139
- Avg merge
- 9h 6m
- Merged PRs (30d)
- 282
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from thomhurst/TUnit
-
bug P3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug P3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
documentation P3
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
thomhurst/TUnit#7444 · 1 comment ·
Maintainers usually reply within 1 day
-
bug P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug P2
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
RadicalCSG/com.chisel#192 ·
Maintainers usually reply within 1 day
-
area-testing p2-post-1.0 technical-debt
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
RazorConsole/RazorConsole#447 ·
Maintainers usually reply within 1 day
-
CloudEventsMiddleware decodes JSON string data for `+json` content typesPossibly taken @RaphaelFakhri claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
dapr/dotnet-sdk#1964 ·
Maintainers usually reply within 1 day
-
Add a Godot splashOpengodot good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days