Skip to content

ref: replace concrete TargetFramework string comparisons with TargetFrameworkIdentifier/Version properties#5240

Draft
jamescrosswell wants to merge 2 commits into
mainfrom
fix-tfm-conditions
Draft

ref: replace concrete TargetFramework string comparisons with TargetFrameworkIdentifier/Version properties#5240
jamescrosswell wants to merge 2 commits into
mainfrom
fix-tfm-conditions

Conversation

@jamescrosswell
Copy link
Copy Markdown
Collaborator

Summary

Replace hardcoded $(TargetFramework) string comparisons in .csproj files with the more scalable $(TargetFrameworkIdentifier) + $(TargetFrameworkVersion) property checks, as recommended by MSBuild best practices.

  • '$(TargetFramework)' == 'net8.0''$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(TargetFrameworkVersion)' == 'v8.0'
  • '$(TargetFramework)' == 'net48''$(TargetFrameworkIdentifier)' == '.NETFramework' And '$(TargetFrameworkVersion)' == 'v4.8'
  • '$(TargetFramework)' == 'netstandard2.0''$(TargetFrameworkIdentifier)' == '.NETStandard' And '$(TargetFrameworkVersion)' == 'v2.0'
  • $(TargetFramework.Contains('-ios'))'$(TargetPlatformIdentifier)' == 'ios'

14 files updated across src/, test/, and samples/.

#skip-changelog

Closes #2657

…rameworkIdentifier/TargetFrameworkVersion properties

Replace `$(TargetFramework) == 'net8.0'` style conditions with
`$(TargetFrameworkIdentifier) == '.NETCoreApp' And $(TargetFrameworkVersion) == 'v8.0'`
equivalents across src, test, and samples project files, as recommended by
the MSBuild best practices guidance. Also replaces `TargetFramework.Contains('-ios')`
with `$(TargetPlatformIdentifier) == 'ios'`.

Closes #2657

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: James Crosswell <james.crosswell@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.11%. Comparing base (a9cb3b2) to head (6ee1a4a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5240      +/-   ##
==========================================
- Coverage   74.12%   74.11%   -0.01%     
==========================================
  Files         508      508              
  Lines       18282    18282              
  Branches     3574     3574              
==========================================
- Hits        13551    13550       -1     
- Misses       3861     3866       +5     
+ Partials      870      866       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread samples/Sentry.Samples.Console.Basic/Sentry.Samples.Console.Basic.csproj Outdated
Comment thread src/Sentry.EntityFramework/Sentry.EntityFramework.csproj Outdated
Comment thread src/Sentry.EntityFramework/Sentry.EntityFramework.csproj Outdated
Comment thread src/Sentry.Extensions.AI/Sentry.Extensions.AI.csproj Outdated
Comment thread src/Sentry.Extensions.Logging/Sentry.Extensions.Logging.csproj Outdated
Comment thread test/Sentry.AspNetCore.TestUtils/Sentry.AspNetCore.TestUtils.csproj Outdated
Comment thread test/Sentry.AspNetCore.TestUtils/Sentry.AspNetCore.TestUtils.csproj Outdated
Comment thread test/Sentry.DiagnosticSource.Tests/Sentry.DiagnosticSource.Tests.csproj Outdated
Comment thread test/Sentry.Extensions.Logging.Tests/Sentry.Extensions.Logging.Tests.csproj Outdated
A bunch of these were unnecessarily specific, simply because historically it was easier to do an exact match than fuzzy matching. Checking the identifier and the versions separately, we can drop the version checks whenever we're checking for netfx and often times when checking for netstandard as well (e.g. when we only target on version of netstandard).

Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
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.

Remove references to specific target frameworks from csproj files

1 participant