Commit 9807ab1
authored
* fix: honor OverloadResolutionPriority on net8 consumers (#6276, #6280)
TUnit's Assert.That(...) overloads are disambiguated with
[OverloadResolutionPriority], which is only honored by C# 13+. Projects
targeting net8.0 (and earlier) default to C# 12, which silently ignores the
attribute, so Assert.That binds to the generic catch-all overload instead of
the typed collection/dictionary overload. The typed surface (All, Count,
ContainsKey, ...) then disappears and calls fail to compile (CS0411/CS0121).
net9.0/net10.0 default to C# 13/14, so they were unaffected.
PR #2437 already set <LangVersion>latest</LangVersion> to address this, but it
lived in the package .targets. The SDK assigns the target-framework default
LangVersion (e.g. 12.0 for net8.0) during the .targets phase, so a .targets
default guarded by Condition="'$(LangVersion)' == ''" never fires. Move the
default to the package .props (imported earlier, before the SDK default) so it
actually wins, while still letting consumers override LangVersion explicitly.
Also remove the #if NET9_0_OR_GREATER gate from
ImplicitConversionEqualityExtensions (a partial band-aid for the same root
cause, issue #5765) and the matching test gates, restoring the
implicit-conversion IsEqualTo / collection-overload-resolution coverage on
net8.0. The JsonElement.DeepEquals gate stays (genuine net9+ BCL API), as do
the Mocks ref-struct (allows ref struct) gates.
Validated end to end with a packed net8 consumer: forced C#12 reproduces
CS0411; the props default builds clean. net8 test build green (Issue5720 15/15,
CollectionOverloadResolution 47/47).
* test: update net8 PublicAPI snapshot for restored typed Assert.That overloads
Dropping the #5765 #if NET9 gate restored IsEqualTo<TValue,TOther> and
IsNotEqualTo<TValue,TOther> on net8, changing the net8 public API surface.
1 parent 1b7218a commit 9807ab1
9 files changed
Lines changed: 49 additions & 18 deletions
File tree
- TUnit.Assertions.Tests
- Bugs
- TUnit.Assertions
- Extensions
- TUnit.Engine
- TUnit.PublicAPI
- TUnit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | 3 | | |
| |||
193 | 191 | | |
194 | 192 | | |
195 | 193 | | |
196 | | - | |
197 | | - | |
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
393 | 392 | | |
394 | 393 | | |
395 | 394 | | |
396 | | - | |
Lines changed: 3 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
6 | 4 | | |
7 | 5 | | |
8 | 6 | | |
| |||
151 | 149 | | |
152 | 150 | | |
153 | 151 | | |
154 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
4 | 16 | | |
5 | 17 | | |
6 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4299 | 4299 | | |
4300 | 4300 | | |
4301 | 4301 | | |
| 4302 | + | |
| 4303 | + | |
| 4304 | + | |
4302 | 4305 | | |
4303 | 4306 | | |
4304 | 4307 | | |
| |||
5225 | 5228 | | |
5226 | 5229 | | |
5227 | 5230 | | |
| 5231 | + | |
| 5232 | + | |
| 5233 | + | |
5228 | 5234 | | |
5229 | 5235 | | |
5230 | 5236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
20 | 32 | | |
21 | 33 | | |
22 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
7 | 6 | | |
8 | 7 | | |
0 commit comments