Skip to content

fix(mcp): report correct TargetFramework for net10.0 projects - #20

Merged
iammukeshm merged 2 commits into
mainfrom
fix/issue-19-tfm-detection
Jul 22, 2026
Merged

fix(mcp): report correct TargetFramework for net10.0 projects#20
iammukeshm merged 2 commits into
mainfrom
fix/issue-19-tfm-detection

Conversation

@iammukeshm

Copy link
Copy Markdown
Member

Fixes #19

Root cause

get_project_graph falls back to preprocessor symbols when the TFM is inherited from Directory.Build.props (so the .csproj parse finds nothing). The fallback picked the longest NET*-prefixed symbol — for a net10.0 compilation that's the compat symbol NETCOREAPP1_0_OR_GREATER (24 chars beats NET10_0_OR_GREATER's 18). Stripping _OR_GREATER and lowercasing produced netcoreapp1.0. net8.0/net9.0 misreport identically.

Fix

The fallback now matches only exact TFM symbols with anchored regexes (NET10_0, NETSTANDARD2_0, NETCOREAPP3_1), picks the highest version, and handles underscore-less .NET Framework symbols (NET48net48). *_OR_GREATER compat symbols can never match.

Changes

  • GetProjectGraphTool.cs — symbol-selection logic extracted to an internal, testable method with the corrected matching
  • 6 regression tests using the real SDK symbol sets for net10.0, net8.0, netstandard2.0, netcoreapp3.1, net48, and no-TFM cases (written first; 5 reproduced the exact netcoreapp1.0 from the issue)
  • InternalsVisibleTo for the test assembly
  • Version bump to 0.7.3

Verification

  • New tests: red before fix (reproducing netcoreapp1.0), green after
  • Full suite: 119/119 passing
  • dotnet format --verify-no-changes clean on changed files

🤖 Generated with Claude Code

iammukeshm and others added 2 commits July 22, 2026 17:15
get_project_graph fell back to preprocessor symbols when the TFM was
inherited from Directory.Build.props, and picked the longest NET-prefixed
symbol. For net10.0 that is NETCOREAPP1_0_OR_GREATER (24 chars beats
NET10_0_OR_GREATER's 18), which after stripping _OR_GREATER misreported
as "netcoreapp1.0".

Match only exact TFM symbols (NET10_0, NETSTANDARD2_0, NETCOREAPP3_1)
with anchored regexes so *_OR_GREATER compat symbols can never win, and
fall back to underscore-less .NET Framework symbols (NET48, NET472).

Fixes #19

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Ships the TargetFramework detection fix for #19.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@iammukeshm
iammukeshm merged commit eb85f8f into main Jul 22, 2026
9 checks passed
@iammukeshm
iammukeshm deleted the fix/issue-19-tfm-detection branch July 22, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] get_project_graph reports TargetFramework "netcoreapp1.0" for net10.0 projects

1 participant