[Bug] Metadata extraction fails with .NET SDK 10.0.2xx — Razor compiler requires Roslyn 5.3.0
DocFx Version
2.78.5
.NET SDK Versions Tested
| SDK Version | Result |
|---|---|
| 10.0.103 (100-band) | Works |
| 10.0.201 (200-band) | Fails |
Describe the Bug
docfx metadata fails for projects containing Blazor components when running with .NET SDK 10.0.2xx (200-band). The issue does not occur with SDK 10.0.1xx (100-band).
Root Cause
The Razor compiler analyzer shipped with the 200-band SDK requires Roslyn 5.3.0, but DocFx bundles an older version that cannot load it:
warning: FailedToLoadAnalyzer: Failed to load .NET Analyzer.
AnalyzerName: Microsoft.CodeAnalysis.Razor.Compiler
ErrorCode: ReferencesNewerCompiler
ReferencedCompilerVersion: 5.3.0.0
Because the Razor source generator fails to load, it does not produce the generated partial classes for .razor files. Code-behind files (.razor.cs) that override virtual methods from their base class then fail with CS0115 ("no suitable method found to override"), because the generated partial class — which establishes the inheritance chain via @inherits — is missing.
Affected Components
The failure affects Blazor components that:
- Declare their base class via
@inheritsin the.razorfile (standard Blazor pattern) - Override virtual or abstract methods from that base class in the
.razor.cscode-behind
Common overridden methods that trigger CS0115 include OnInitialized(), OnInitializedAsync(), SetParametersAsync(ParameterView), and custom virtual methods from the component's base class hierarchy.
To Reproduce
- Install .NET SDK 10.0.2xx (e.g., 10.0.201)
- Have a Blazor component library targeting
net10.0 - Include components with code-behind files where the
.razorfile uses@inherits SomeBaseand the.razor.csfile overrides virtual methods from that base - Run
docfx metadataon a DocFx config that includes this project
Example Component Structure
MyComponent.razor:
@namespace MyApp.Components
@inherits MyComponentBase
<div>@ChildContent</div>
MyComponent.razor.cs:
namespace MyApp.Components;
public partial class MyComponent
{
protected override void OnInitialized()
{
// CS0115 because Razor generator didn't run,
// so this partial class has no base class
base.OnInitialized();
}
}
Error Output
warning: FailedToLoadAnalyzer: Failed to load .NET Analyzer.
AnalyzerName: Microsoft.CodeAnalysis.Razor.Compiler
ErrorCode: ReferencesNewerCompiler
ReferencedCompilerVersion: 5.3.0.0
error CS0115: 'MyComponent.OnInitialized()': no suitable method found to override
Workaround
Pin the .NET SDK to the 100-band (e.g., 10.0.103) via global.json or CI configuration. The 100-band SDK ships with a Roslyn version that DocFx can still load.
Expected Behavior
docfx metadata should work with all current .NET SDK 10 versions, including the 200-band. DocFx should be updated to support the Roslyn version shipped with the 200-band SDK.
Related Issues
- #10901 — CS8652 triggered for .NET 10 (DocFx's Roslyn doesn't support C# 14
fieldkeyword) - #10192 — Metadata extraction fails when projects use a newer compiler than DocFx ships with
- dotnet/runtime#120815 — Runtime analyzers target Roslyn 4.14.0 but DocFx bundles 4.12.0
Minimal reproduction repo: https://github.com/uo-uhbc/docfx_11046
This looks like the same thing that has been causing API documentation generation to fail when the SDK is updated. https://github.com/dotnet/docfx/issues/10542
This is becoming a real issue given the fact that there is not much activity in this repo and the releases are very sparse. Seems like we are broken more often than not.
First of all, thank you for the detailed analysis and for maintaining DocFX.
I’m currently running into the same issue when generating metadata with the .NET SDK 10.0.2xx, especially in projects that include Blazor components. Downgrading to the 100‑series SDK works as a temporary workaround on local machines, but it’s unfortunately not a long‑term option for some of our build pipelines.
I wanted to kindly ask whether there are any known workarounds beyond switching SDK versions, or if there is already some progress or a plan regarding a fix for the Roslyn compatibility issue.
Any guidance or an estimate on whether a fix might be expected in an upcoming release would be greatly appreciated.
Thanks again for your work on DocFX and for any insights you can share!
Fixed by #11124, released in v2.80.1 (2026-09-18).
#11124 raised the bundled dependencies for the non-net8.0/net9.0 TFMs:
Microsoft.CodeAnalysis.*5.6.0 → 5.9.0Microsoft.Build18.8.2 → 18.9.6
Verified on .NET SDK 10.0.401, against a Blazor component library of the shape in the reproduction linked above:
| docfx | docfx metadata |
full build with --warningsAsErrors |
|---|---|---|
| 2.78.5 | fails — CS0115 per code-behind override, No .NET API detected |
fails |
| 2.80.1 | succeeds | succeeds, 0 warnings / 0 errors |
Note that 2.78.6 does not contain the fix — it was published the day before #11124 merged. 2.80.1 is the first release carrying it.
@Eisi1482 — to answer your question directly: no SDK downgrade is needed any more. Upgrading docfx to 2.80.1 is sufficient, and the 100-series workaround can be removed from local setups and build pipelines alike.
@groogiam — your point about this recurring is unfortunately borne out. The same failure returns on the .NET 11 SDK, which ships Roslyn 5.11.0 while 2.80.1 bundles 5.9.0; I have opened #11171 for that with a four-file repro. Because Roslyn is bundled rather than taken from the installed SDK, every SDK band that moves Roslyn forward needs a bump like #11124. The general form of that is tracked in #10192, and #10969 addresses the MSBuild half of the coupling.
Closing this one as completed, since the 10.0.2xx case it was filed for is resolved; further discussion of the recurring pattern is better placed on #11171 or #10192.