Skip to content

fix: give indexers the same default values as properties - #1133

Merged
vbreuss merged 1 commit into
mainfrom
fix/indexer-default-values
Nov 25, 2026
Merged

vbreuss merged 1 commit into
mainfrom
fix/indexer-default-values

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 25, 2026

Copy link
Copy Markdown
Member

Indexers computed their default inside generic library code, where only the general Generate overload binds, so an unconfigured indexer returned null for Task, collections, arrays, tuples and Func<T, T>/Action while a property of the same type got a proper default. The generated getter now passes a static default-value factory, as property getters already do.

Indexers computed their default inside generic library code, where only the general Generate<T> overload binds, so an unconfigured indexer returned null for Task<T>, collections, arrays, tuples and Func<T, T>/Action<T> while a property of the same type got a proper default. The generated getter now passes a static default-value factory, as property getters already do.
@vbreuss vbreuss self-assigned this Nov 25, 2026
@vbreuss vbreuss added the bug Something isn't working label Nov 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
46.2% Coverage on New Code (required ≥ 50%)

See analysis details on SonarQube Cloud

@vbreuss
vbreuss merged commit 4f46104 into main Nov 25, 2026
22 of 24 checks passed
@vbreuss
vbreuss deleted the fix/indexer-default-values branch November 25, 2026 19:32
github-actions Bot added a commit that referenced this pull request Nov 25, 2026
github-actions Bot added a commit that referenced this pull request Nov 25, 2026
@github-actions

Copy link
Copy Markdown

🚀 Benchmark Results

Compared to main, which ran on the same runner. Times that change by more than 10% are marked.

Memory

Benchmark main PR Δ
Unconfigured (N=1000) 273,296 B 273,297 B 🔴 +1 B (±0%)
Indexer (N=1000) 105,720 B 105,721 B 🔴 +1 B (±0%)
CompleteWorkflowBenchmarks
Complete Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1.773 μs 0.0260 μs 0.0203 μs 1.00 5.14 KB 1.00
Imposter 2.142 μs 0.0382 μs 0.0339 μs 1.21 7.21 KB 1.40
TUnitMocks 3.495 μs 0.1040 μs 0.0973 μs 1.97 10.66 KB 2.07
Moq 1,040.573 μs 6.1046 μs 5.4116 μs 586.86 90.29 KB 17.56
NSubstitute 271.555 μs 1.1705 μs 0.9774 μs 153.15 53.11 KB 10.33
FakeItEasy 308.531 μs 3.8118 μs 2.9760 μs 174.00 63.94 KB 12.44
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

MockCreationBenchmarks
CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 19.54 ns 1.179 ns 1.103 ns 1.00 136 B 1.00
Imposter 103.55 ns 5.660 ns 5.294 ns 5.31 504 B 3.71
TUnitMocks 32.59 ns 2.119 ns 1.982 ns 1.67 216 B 1.59
Moq 1,381.14 ns 26.720 ns 24.994 ns 70.89 2088 B 15.35
NSubstitute 2,099.66 ns 119.143 ns 111.446 ns 107.77 5032 B 37.00
FakeItEasy 1,686.52 ns 73.641 ns 68.884 ns 86.56 2755 B 20.26
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.22GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CompleteUnconfiguredBenchmarks
Unconfigured N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 322.4 ns 6.34 ns 5.62 ns 1.00 1.51 KB 1.00
Imposter 1 218.4 ns 1.49 ns 1.39 ns 0.68 1.06 KB 0.70
TUnitMocks 1 377.9 ns 2.09 ns 1.85 ns 1.17 1.74 KB 1.16
Moq 1 72,023.0 ns 391.34 ns 346.91 ns 223.49 9.9 KB 6.57
NSubstitute 1 5,477.3 ns 37.74 ns 35.31 ns 17.00 10.01 KB 6.64
FakeItEasy 1 5,205.0 ns 45.24 ns 40.10 ns 16.15 11.58 KB 7.68
Mockolate 10 1,236.2 ns 11.70 ns 10.37 ns 1.00 3.92 KB 1.00
Imposter 10 837.8 ns 17.82 ns 16.67 ns 0.68 2.89 KB 0.74
TUnitMocks 10 2,512.6 ns 52.58 ns 46.61 ns 2.03 8.4 KB 2.14
Moq 10 83,715.9 ns 466.32 ns 413.38 ns 67.73 24.63 KB 6.28
NSubstitute 10 16,637.8 ns 226.80 ns 212.15 ns 13.46 22.93 KB 5.85
FakeItEasy 10 20,320.2 ns 155.19 ns 145.17 ns 16.44 53.92 KB 13.75
Mockolate 1000 97,888.7 ns 799.39 ns 747.75 ns 1.00 266.89 KB 1.00
Imposter 1000 67,564.9 ns 518.34 ns 459.49 ns 0.69 203.99 KB 0.76
TUnitMocks 1000 238,510.6 ns 2,827.21 ns 2,644.57 ns 2.44 691.13 KB 2.59
Moq 1000 1,220,487.1 ns 8,353.32 ns 6,975.40 ns 12.47 1653.12 KB 6.19
NSubstitute 1000 1,265,677.4 ns 20,410.61 ns 18,093.47 ns 12.93 1434.49 KB 5.37
FakeItEasy 1000 2,371,219.6 ns 114,621.16 ns 107,216.70 ns 24.22 4690.8 KB 17.58
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CompleteMethodBenchmarks
Method N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 137.1 ns 6.91 ns 6.47 ns 1.00 592 B 1.00
Imposter 1 189.1 ns 3.57 ns 3.34 ns 1.38 808 B 1.36
TUnitMocks 1 361.8 ns 3.35 ns 2.97 ns 2.65 1424 B 2.41
Moq 1 4,689.1 ns 46.07 ns 38.47 ns 34.28 6552 B 11.07
NSubstitute 1 6,080.3 ns 56.22 ns 49.83 ns 44.45 9816 B 16.58
FakeItEasy 1 4,654.6 ns 54.99 ns 51.44 ns 34.03 7517 B 12.70
Mockolate 10 369.1 ns 7.10 ns 6.64 ns 1.00 1096 B 1.00
Imposter 10 385.5 ns 3.71 ns 3.29 ns 1.04 1168 B 1.07
TUnitMocks 10 1,192.4 ns 7.51 ns 7.02 ns 3.23 3288 B 3.00
Moq 10 6,517.6 ns 30.49 ns 27.03 ns 17.67 10536 B 9.61
NSubstitute 10 9,685.4 ns 30.29 ns 25.30 ns 26.25 12841 B 11.72
FakeItEasy 10 8,315.2 ns 49.75 ns 44.10 ns 22.54 15754 B 14.37
Mockolate 1000 28,066.3 ns 141.53 ns 125.46 ns 1.00 56536 B 1.00
Imposter 1000 22,393.7 ns 99.05 ns 92.65 ns 0.80 40768 B 0.72
TUnitMocks 1000 79,643.3 ns 731.27 ns 684.03 ns 2.84 178353 B 3.15
Moq 1000 187,005.4 ns 1,502.44 ns 1,405.38 ns 6.66 423564 B 7.49
NSubstitute 1000 274,028.0 ns 1,378.88 ns 1,289.81 ns 9.76 378537 B 6.70
FakeItEasy 1000 402,877.8 ns 5,367.41 ns 5,020.68 ns 14.35 943763 B 16.69
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.65GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CompletePropertyBenchmarks
Property N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 324.5 ns 2.10 ns 1.86 ns 1.00 920 B 1.00
Imposter 1 218.5 ns 0.77 ns 0.72 ns 0.67 672 B 0.73
TUnitMocks 1 458.3 ns 2.04 ns 1.81 ns 1.41 1464 B 1.59
Moq 1 9,091.3 ns 58.72 ns 49.04 ns 28.02 10569 B 11.49
NSubstitute 1 6,732.8 ns 19.81 ns 18.53 ns 20.75 11664 B 12.68
FakeItEasy 1 6,150.1 ns 27.94 ns 26.14 ns 18.95 11191 B 12.16
Mockolate 10 768.1 ns 3.53 ns 3.13 ns 1.00 1784 B 1.00
Imposter 10 454.1 ns 1.25 ns 1.17 ns 0.59 960 B 0.54
TUnitMocks 10 1,641.7 ns 3.89 ns 3.45 ns 2.14 3600 B 2.02
Moq 10 15,094.7 ns 41.78 ns 34.89 ns 19.65 18504 B 10.37
NSubstitute 10 15,634.5 ns 47.43 ns 42.05 ns 20.35 21528 B 12.07
FakeItEasy 10 16,272.6 ns 58.34 ns 54.57 ns 21.18 30785 B 17.26
Mockolate 1000 51,019.6 ns 176.81 ns 165.38 ns 1.00 96824 B 1.00
Imposter 1000 26,629.0 ns 174.63 ns 145.83 ns 0.52 32640 B 0.34
TUnitMocks 1000 126,650.8 ns 821.49 ns 685.98 ns 2.48 218305 B 2.25
Moq 1000 588,344.3 ns 2,777.95 ns 2,462.58 ns 11.53 836452 B 8.64
NSubstitute 1000 927,791.9 ns 3,152.35 ns 2,948.71 ns 18.19 1139621 B 11.77
FakeItEasy 1000 1,105,340.9 ns 7,481.81 ns 6,247.65 ns 21.67 2194291 B 22.66
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
INTEL XEON PLATINUM 8573C 3.01GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CompleteIndexerBenchmarks
Indexer N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 353.7 ns 6.75 ns 5.98 ns 1.00 1.78 KB 1.00
Imposter 1 261.4 ns 3.26 ns 3.05 ns 0.74 1.19 KB 0.67
TUnitMocks 1 511.8 ns 20.53 ns 19.20 ns 1.45 2.16 KB 1.21
Moq 1 410,720.5 ns 2,267.25 ns 2,009.86 ns 1,161.62 37.59 KB 21.10
NSubstitute 1 118,659.1 ns 701.54 ns 585.81 ns 335.60 27.5 KB 15.44
FakeItEasy 1 147,896.6 ns 2,510.34 ns 2,348.17 ns 418.29 29.56 KB 16.60
Mockolate 10 1,048.4 ns 15.80 ns 14.01 ns 1.00 2.7 KB 1.00
Imposter 10 659.5 ns 7.12 ns 6.66 ns 0.63 2.24 KB 0.83
TUnitMocks 10 1,847.5 ns 23.58 ns 22.06 ns 1.76 5.13 KB 1.90
Moq 10 422,456.4 ns 1,878.50 ns 1,665.24 ns 403.02 46.95 KB 17.42
NSubstitute 10 135,421.7 ns 1,012.61 ns 947.19 ns 129.19 40.3 KB 14.95
FakeItEasy 10 163,659.9 ns 860.68 ns 718.71 ns 156.13 48.76 KB 18.09
Mockolate 1000 69,642.8 ns 488.43 ns 432.98 ns 1.00 103.24 KB 1.00
Imposter 1000 43,748.8 ns 267.68 ns 250.38 ns 0.63 118.26 KB 1.15
TUnitMocks 1000 136,697.2 ns 1,387.39 ns 1,297.77 ns 1.96 292.52 KB 2.83
Moq 1000 1,079,077.2 ns 15,379.17 ns 13,633.23 ns 15.50 1023.76 KB 9.92
NSubstitute 1000 1,451,440.7 ns 24,558.31 ns 21,770.30 ns 20.84 1480.39 KB 14.34
FakeItEasy 1000 1,255,220.3 ns 14,985.27 ns 12,513.38 ns 18.02 2169.36 KB 21.01
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.68GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CompleteEventBenchmarks
Event Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 129.3 ns 4.09 ns 3.63 ns 1.00 712 B 1.00
Imposter 156.9 ns 1.42 ns 1.26 ns 1.21 512 B 0.72
TUnitMocks 142.8 ns 3.50 ns 3.27 ns 1.11 1392 B 1.96
Moq 11,223.1 ns 38.20 ns 35.73 ns 86.87 12761 B 17.92
NSubstitute 4,494.0 ns 28.23 ns 23.57 ns 34.78 9192 B 12.91
FakeItEasy 198,176.1 ns 927.25 ns 821.98 ns 1,533.90 15619 B 21.94
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.68GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CallbackBenchmarks
Callback Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 201.6 ns 2.09 ns 1.85 ns 1.00 800 B 1.00
Imposter 200.3 ns 1.51 ns 1.42 ns 0.99 616 B 0.77
TUnitMocks 336.4 ns 6.46 ns 6.05 ns 1.67 1352 B 1.69
Moq 103,538.2 ns 418.60 ns 391.56 ns 513.71 9056 B 11.32
NSubstitute 4,628.3 ns 24.35 ns 20.33 ns 22.96 7864 B 9.83
FakeItEasy 4,567.2 ns 73.83 ns 69.06 ns 22.66 6930 B 8.66
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.70GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

AsyncBenchmarks
Async N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 364.9 ns 16.47 ns 15.41 ns 1.00 1 KB 1.00
Imposter 1 454.9 ns 31.45 ns 29.42 ns 1.25 1.58 KB 1.58
TUnitMocks 1 887.3 ns 26.18 ns 24.49 ns 2.44 2.57 KB 2.57
Moq 1 334,886.7 ns 4,249.24 ns 3,974.74 ns 919.41 22.74 KB 22.74
NSubstitute 1 16,361.6 ns 176.84 ns 156.77 ns 44.92 19.1 KB 19.10
FakeItEasy 1 11,663.1 ns 328.72 ns 307.48 ns 32.02 14 KB 14.00
Mockolate 10 1,665.3 ns 6.12 ns 5.11 ns 1.00 2.97 KB 1.00
Imposter 10 1,522.4 ns 18.58 ns 17.38 ns 0.91 3.41 KB 1.15
TUnitMocks 10 4,799.3 ns 50.06 ns 46.83 ns 2.88 9.22 KB 3.11
Moq 10 375,821.5 ns 1,906.50 ns 1,592.02 ns 225.67 40.19 KB 13.54
NSubstitute 10 30,552.1 ns 504.10 ns 471.54 ns 18.35 29.41 KB 9.91
FakeItEasy 10 45,280.5 ns 618.70 ns 548.46 ns 27.19 59.08 KB 19.90
Mockolate 1000 160,896.0 ns 1,085.07 ns 1,014.98 ns 1.00 219.53 KB 1.00
Imposter 1000 114,078.1 ns 3,023.34 ns 2,828.04 ns 0.71 204.5 KB 0.93
TUnitMocks 1000 398,237.8 ns 4,169.56 ns 3,900.21 ns 2.48 638.22 KB 2.91
Moq 1000 4,487,615.4 ns 105,658.21 ns 98,832.75 ns 27.89 1891.04 KB 8.61
NSubstitute 1000 1,239,479.0 ns 10,317.79 ns 9,146.45 ns 7.70 1092.92 KB 4.98
FakeItEasy 1000 4,197,778.4 ns 71,033.10 ns 66,444.41 ns 26.09 4933.54 KB 22.47
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

SequenceBenchmarks
Sequence Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 2.713 μs 0.0177 μs 0.0157 μs 1.00 2.23 KB 1.00
Imposter 2.465 μs 0.0216 μs 0.0192 μs 0.91 2.23 KB 1.00
TUnitMocks 2.871 μs 0.0048 μs 0.0040 μs 1.06 2.84 KB 1.27
Moq 10.218 μs 0.0131 μs 0.0116 μs 3.77 10.79 KB 4.83
NSubstitute 9.312 μs 0.0510 μs 0.0452 μs 3.43 14.29 KB 6.40
FakeItEasy 9.667 μs 0.0312 μs 0.0244 μs 3.56 14.28 KB 6.39
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant