Skip to content

[Infra] Match runtime packages to runtime major version #6327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

martincostello
Copy link
Member

#5973 (comment)

Changes

Refactoring to match runtime packages to the major version of a target framework.

Unfortunately we can't do this complete for net8.0 without making breaking changes as we have exposed functionality that depends on new APIs added in the System.Diagnostics.DiagnosticSource package for 9.0.0.

tracer = new(new(key.Name, key.Version, key.Tags));

this.Activity!.AddLink(new ActivityLink(context, tags));

As a compromise for net8.0, 8.0.x packages are used for all dependencies except System.Diagnostics.DiagnosticSource which uses 9.0.0 to preserve these use cases.

The downside here is that users running net8.0 will technically be out of support for that package from May 2026, but that's still the case if we do nothing.

We could mitigate this by moving the special case for net8.0 to depend on the 10.0.0 package in November with a new release for .NET 10 (if that works) or users can self-mitigate by adding an explicit reference to the 10.0.0 version of that package to their own application without upgrading to .NET 10 immediately.

Moving forward to preserve the intention of this PR we would need to accept that new functionality would be gated to upgrading to the matching version of .NET. For example, a new feature added in .NET 10 would require your application to net10.0 to use it.

Alternatively we could take an approach where we only expose new APIs to older runtimes when the version is itself an LTS version.

In that case, a new API added in .NET 10 would be supported in all previous versions as we know the package exposing it is LTS, but a new API added in .NET 11 would only be available to net11.0 and later as that is STS.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added infra Infra work - CI/CD, code coverage, linters dependencies Pull requests that update a dependency file pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package labels Jun 12, 2025
Copy link

codecov bot commented Jun 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.75%. Comparing base (a10f955) to head (a8d61f1).

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6327      +/-   ##
==========================================
+ Coverage   86.48%   86.75%   +0.27%     
==========================================
  Files         258      258              
  Lines       11879    11879              
==========================================
+ Hits        10273    10306      +33     
+ Misses       1606     1573      -33     
Flag Coverage Δ
unittests-Project-Experimental 86.43% <ø> (+0.10%) ⬆️
unittests-Project-Stable 86.65% <ø> (+0.26%) ⬆️
unittests-Solution 86.40% <ø> (+0.02%) ⬆️
unittests-UnstableCoreLibraries-Experimental 85.87% <ø> (-0.38%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 7 files with indirect coverage changes

Comment on lines +55 to +58
However, for .NET 8 we need to use the .NET 9 package as the following APIs have been used to expose user-facing functionality:
- System.Diagnostics.Activity.ctor(string, string, IEnumerable<KeyValuePair<string, object>>)
- System.Diagnostics.Activity.AddException()
- System.Diagnostics.Activity.AddLink()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be phrased to indicate that we need to (and can) use the latest version.

We, most likely, can use 10.0.x for all targets, like we can use 9.0.x.

For that matter, I'd use a property specific for this package's version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends on the resolution to this comment:

Moving forward to preserve the intention of this PR we would need to accept that new functionality would be gated to upgrading to the matching version of .NET. For example, a new feature added in .NET 10 would require your application to net10.0 to use it.

Alternatively we could take an approach where we only expose new APIs to older runtimes when the version is itself an LTS version.

The PR as-is is working on the assumption new things need newer TFMs/versions, so the MSBuild as-written is correct as it would only have an exception for net8.0 and code would need to use #if NET10_0_OR_GREATER-like constructs as appropriate for future API additions.

Copy link
Member Author

@martincostello martincostello Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also written it with #6307 in mind, where if this was merged as-is it would just add these changes:

- <RuntimePackageVersions>9.0.0</RuntimePackageVersions>
+ <RuntimePackageVersions>10.0.0</RuntimePackageVersions>
+ <RuntimePackageVersions Condition="'$(TargetFramework)' == 'net10.0'">10.0.0</RuntimePackageVersions>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be prepared, but I'd reason about TFM specific stuff when we get there.

Polyfills are always an option. 😄

@eerhardt
Copy link
Contributor

Build / verify-aot-compat / run-verify-aot-compat (ubuntu-22.04, net8.0) (pull_request)Failing after 1m

Try using 8.0.2 of Microsoft.Extensions.Configuration.Binder. The 8.0.0 package has bugs in the source generator that were fixed in patched versions.

Refactoring to prepare to match runtime packages to the major version of a target framework.

Unfortunately we can't do this for `net8.0` without making breaking changes as we have exposed functionality that depends on new APIs added in the System.Diagnostics.DiagnosticSource package.

Contributes to open-telemetry#5973.
Use .NET 8 packages with `net8.0` except `System.Diagnostics.DiagnosticSource`.

Contributes to open-telemetry#5973.
Update Microsoft.Extensions.Configuration.Binder for `net8.0` to fix issues with native AoT and configurating binding.
Copy link
Contributor

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will help with conflict versions of Microsoft.Extensions.* when using opentelemetry-dotnet-auto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file infra Infra work - CI/CD, code coverage, linters pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants