docfx icon indicating copy to clipboard operation
docfx copied to clipboard

[Feature Request] Support C# 14

Open AArnott opened this issue 3 months ago • 6 comments

When I'm using C# 14 extension members syntax, the docfx build fails with errors suggesting that my global.json selected SDK version and Directory.Build.props selected LangVersion is not being used.

Why is this? How/when can docfx support using C# 14 and/or the SDK and langversion specified by the user?

AArnott avatar Sep 11 '25 14:09 AArnott

docfx using Roslyn API by referencing Microsoft.CodeAnalysis.* packages. Latest version of docfx using 4.14.0 version.

C# 14 Extensions feature support seems to be added on v5.x. (Currently preview status) And it'll updated by PR #10859

After above PR merged. It need to add code to handle C# 14 extensions features.

  • Handle TypeKind.Extension and extract defined extensions.
  • Handle AssociatedSymbol and extract information about extended method/property/user defined operator
  • Add page rendering logics for extensions

filzrev avatar Nov 12 '25 00:11 filzrev

I don't know if docfx shows user-defined operators, but if it does, should also take into account the new += operator which was added in C# 14.

bkoelman avatar Nov 12 '25 01:11 bkoelman

Getting a docfx release that at least doesn't totally break on C# 14 syntax would be helpful. Actually including C# 14 extension members in the docs could be a separate release, if that allows the unblocking release to come sooner.

AArnott avatar Nov 14 '25 19:11 AArnott

Any ETA on this? This is affecting us to migrate to .NET 10.

gumbarros avatar Dec 01 '25 14:12 gumbarros

I saw that Roslyn 5.0 packages were released 2 weeks ago (e.g. https://www.nuget.org/packages/Microsoft.CodeAnalysis.CSharp).

Would that allow some progress on this issue?

Seems like @dependabot already created #10906

Marv51 avatar Dec 03 '25 11:12 Marv51

also https://github.com/dotnet/docfx/pull/10859

WeihanLi avatar Dec 03 '25 12:12 WeihanLi