Skip to content

fix: require Roslyn 5.0 instead of 5.6 for the generator and analyzers - #831

Merged
vbreuss merged 1 commit into
mainfrom
fix/lower-minimum-roslyn-version
Jul 29, 2026
Merged

fix: require Roslyn 5.0 instead of 5.6 for the generator and analyzers#831
vbreuss merged 1 commit into
mainfrom
fix/lower-minimum-roslyn-version

Conversation

@vbreuss

@vbreuss vbreuss commented Jul 29, 2026

Copy link
Copy Markdown
Member

The generator and analyzers referenced Microsoft.CodeAnalysis 5.6.0, which ships with the .NET 10.0.30x SDK. Roslyn refuses to load a component that references a newer compiler than the host (CS9057), so every older host silently skipped them: no generated members, and 'Cannot resolve symbol CreateMock' throughout the IDE while the command-line build stayed green.

Pin the three shipped components to the oldest Roslyn they actually need. 5.0 is the floor, not lower: the emitted Mock.g.cs declares CreateMock in a C# 14 extension block, so a C# 13 host parses it as garbage and generates no mocks at all. That also rules out any pre-C# 14 host, since a static extension member has no older equivalent.

Mockolate.SourceGenerators.Tests pins the same version, so reaching for a newer Roslyn API fails the build and the generator tests here rather than silently breaking consumers' IDEs.

MinimumRoslynVersion sits in the root Directory.Build.props because the test tree imports that one but not Source/Directory.Build.props.

The generator and analyzers referenced Microsoft.CodeAnalysis 5.6.0, which
ships with the .NET 10.0.30x SDK. Roslyn refuses to load a component that
references a newer compiler than the host (CS9057), so every older host
silently skipped them: no generated members, and 'Cannot resolve symbol
CreateMock' throughout the IDE while the command-line build stayed green.

Pin the three shipped components to the oldest Roslyn they actually need.
5.0 is the floor, not lower: the emitted Mock.g.cs declares CreateMock in a
C# 14 extension block, so a C# 13 host parses it as garbage and generates no
mocks at all. That also rules out any pre-C# 14 host, since a static
extension member has no older equivalent.

Mockolate.SourceGenerators.Tests pins the same version, so reaching for a
newer Roslyn API fails the build and the generator tests here rather than
silently breaking consumers' IDEs.

MinimumRoslynVersion sits in the root Directory.Build.props because the test
tree imports that one but not Source/Directory.Build.props.
@vbreuss vbreuss self-assigned this Jul 29, 2026
@vbreuss vbreuss added the bug Something isn't working label Jul 29, 2026
@vbreuss
vbreuss enabled auto-merge (squash) July 29, 2026 12:11
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Test Results

    24 files  ±0      24 suites  ±0   10m 55s ⏱️ +4s
 4 263 tests ±0   4 261 ✅ ±0  2 💤 ±0  0 ❌ ±0 
27 209 runs  ±0  27 205 ✅ ±0  4 💤 ±0  0 ❌ ±0 

Results for commit 6879f4d. ± Comparison against base commit 01a814a.

@vbreuss
vbreuss merged commit a0e6d15 into main Jul 29, 2026
17 checks passed
@vbreuss
vbreuss deleted the fix/lower-minimum-roslyn-version branch July 29, 2026 12:19
@github-actions

Copy link
Copy Markdown

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.302
[Host] : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v4

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

Event Mean Error StdDev Ratio Allocated Alloc Ratio
baseline* 311.1 ns 9.62 ns 9.00 ns 1.37 1.7 KB 1.00
Mockolate 226.7 ns 0.94 ns 0.83 ns 1.00 1.7 KB 1.00
Imposter 981.0 ns 4.19 ns 3.92 ns 4.33 8.8 KB 5.17
TUnitMocks 135.1 ns 0.79 ns 0.74 ns 0.60 1.34 KB 0.79
Moq 10,659.6 ns 72.27 ns 67.60 ns 47.03 12.51 KB 7.34
NSubstitute 3,847.3 ns 12.71 ns 11.88 ns 16.97 9.05 KB 5.31
FakeItEasy 185,281.5 ns 693.21 ns 648.43 ns 817.47 15.26 KB 8.96
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 9V74 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.302
[Host] : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v3

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

Indexer N Mean Error StdDev Ratio Allocated Alloc Ratio
baseline* 1 1,089.7 ns 33.52 ns 29.71 ns 1.12 3.77 KB 1.00
Mockolate 1 971.0 ns 35.87 ns 33.56 ns 1.00 3.77 KB 1.00
Imposter 1 879.4 ns 20.87 ns 19.53 ns 0.91 5.16 KB 1.37
Moq 1 165,997.0 ns 1,257.28 ns 1,114.54 ns 171.15 20.45 KB 5.43
NSubstitute 1 8,550.6 ns 87.47 ns 81.82 ns 8.82 12.84 KB 3.41
FakeItEasy 1 10,093.8 ns 93.84 ns 87.78 ns 10.41 13.63 KB 3.62
baseline* 10 2,612.9 ns 8.36 ns 7.82 ns 1.09 4.82 KB 1.00
Mockolate 10 2,390.7 ns 13.40 ns 10.46 ns 1.00 4.82 KB 1.00
Imposter 10 1,982.1 ns 17.27 ns 14.42 ns 0.83 7.97 KB 1.65
Moq 10 176,729.3 ns 1,299.28 ns 1,151.78 ns 73.92 29.97 KB 6.22
NSubstitute 10 20,844.5 ns 27.25 ns 21.27 ns 8.72 25.63 KB 5.32
FakeItEasy 10 20,684.6 ns 134.02 ns 111.91 ns 8.65 32.97 KB 6.84
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 9V74 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.302
[Host] : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v3

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

Property N Mean Error StdDev Ratio Allocated Alloc Ratio
baseline* 1 538.6 ns 7.87 ns 6.98 ns 1.02 2.41 KB 1.00
Mockolate 1 529.3 ns 9.67 ns 8.57 ns 1.00 2.41 KB 1.00
Imposter 1 448.8 ns 5.12 ns 4.28 ns 0.85 3.13 KB 1.29
TUnitMocks 1 477.8 ns 4.01 ns 3.75 ns 0.90 1.64 KB 0.68
Moq 1 10,825.6 ns 171.33 ns 160.27 ns 20.46 10.39 KB 4.30
NSubstitute 1 6,907.3 ns 92.66 ns 86.68 ns 13.05 11.45 KB 4.74
FakeItEasy 1 7,860.9 ns 93.38 ns 87.34 ns 14.86 11.24 KB 4.66
baseline* 10 1,045.8 ns 21.98 ns 20.56 ns 1.00 2.91 KB 1.00
Mockolate 10 1,046.1 ns 20.09 ns 17.81 ns 1.00 2.91 KB 1.00
Imposter 10 1,127.8 ns 10.22 ns 8.54 ns 1.08 4.67 KB 1.61
TUnitMocks 10 1,664.2 ns 11.50 ns 10.19 ns 1.59 3.94 KB 1.35
Moq 10 17,137.6 ns 106.77 ns 94.65 ns 16.39 18.28 KB 6.29
NSubstitute 10 16,400.4 ns 47.91 ns 42.47 ns 15.68 21.08 KB 7.25
FakeItEasy 10 18,121.1 ns 232.12 ns 193.83 ns 17.33 30.81 KB 10.60
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 7763 2.77GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.302
[Host] : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v3

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

CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
baseline* 19.25 ns 0.262 ns 0.245 ns 1.06 160 B 1.00
Mockolate 18.20 ns 0.440 ns 0.412 ns 1.00 160 B 1.00
Imposter 277.27 ns 6.628 ns 6.200 ns 15.24 2248 B 14.05
TUnitMocks 35.97 ns 0.429 ns 0.401 ns 1.98 200 B 1.25
Moq 1,449.44 ns 13.496 ns 11.963 ns 79.68 2096 B 13.10
NSubstitute 2,047.20 ns 37.918 ns 35.469 ns 112.54 5048 B 31.55
FakeItEasy 1,849.75 ns 19.081 ns 15.934 ns 101.68 2763 B 17.27
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 7763 2.66GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.302
[Host] : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v3

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

Callback Mean Error StdDev Ratio Allocated Alloc Ratio
baseline* 315.9 ns 7.47 ns 6.99 ns 0.96 1.57 KB 1.00
Mockolate 330.0 ns 8.56 ns 7.59 ns 1.00 1.57 KB 1.00
Imposter 416.8 ns 11.87 ns 10.52 ns 1.26 2.38 KB 1.52
TUnitMocks 491.3 ns 6.74 ns 6.31 ns 1.49 1.99 KB 1.27
Moq 98,221.9 ns 210.73 ns 186.80 ns 297.77 8.88 KB 5.66
NSubstitute 4,597.2 ns 36.30 ns 33.96 ns 13.94 7.71 KB 4.91
FakeItEasy 4,939.8 ns 37.37 ns 29.18 ns 14.98 6.81 KB 4.33
Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 9V74 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.302
[Host] : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v4

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

Method N Mean Error StdDev Ratio Allocated Alloc Ratio
baseline* 1 431.7 ns 8.18 ns 7.65 ns 1.60 1.93 KB 1.00
Mockolate 1 269.4 ns 2.28 ns 2.02 ns 1.00 1.93 KB 1.00
Imposter 1 404.9 ns 2.21 ns 1.96 ns 1.50 4.04 KB 2.09
TUnitMocks 1 372.1 ns 1.48 ns 1.31 ns 1.38 2.02 KB 1.04
Moq 1 103,033.6 ns 452.07 ns 422.86 ns 382.50 14.59 KB 7.56
NSubstitute 1 4,095.8 ns 13.80 ns 12.24 ns 15.21 9.12 KB 4.72
FakeItEasy 1 4,434.2 ns 13.00 ns 12.16 ns 16.46 8.27 KB 4.29
baseline* 10 735.9 ns 10.41 ns 9.74 ns 1.56 2.14 KB 1.00
Mockolate 10 470.7 ns 1.13 ns 1.05 ns 1.00 2.14 KB 1.00
Imposter 10 813.5 ns 3.25 ns 2.88 ns 1.73 5.52 KB 2.58
TUnitMocks 10 1,081.3 ns 4.50 ns 4.21 ns 2.30 3.73 KB 1.74
Moq 10 106,650.7 ns 484.32 ns 453.04 ns 226.59 18.49 KB 8.64
NSubstitute 10 6,350.1 ns 24.66 ns 19.26 ns 13.49 12.07 KB 5.64
FakeItEasy 10 7,035.5 ns 59.48 ns 55.64 ns 14.95 15.65 KB 7.31

baseline* rows show the corresponding Mockolate benchmark from the most recent successful main branch build with results, for regression comparison.

github-actions Bot added a commit that referenced this pull request Jul 29, 2026
…for the generator and analyzers (#831) by Valentin Breuß
github-actions Bot added a commit that referenced this pull request Jul 29, 2026
…for the generator and analyzers (#831) by Valentin Breuß
@github-actions

Copy link
Copy Markdown

This is addressed in release v3.4.0.

@github-actions github-actions Bot added the state: released The issue is released label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant