Skip to content

GetDocumentInsider: use System.Diagnostics.DiagnosticSource from runtime (not OOB) #50020

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

Closed
wants to merge 2 commits into from

Conversation

mgravell
Copy link
Member

@mgravell mgravell commented Aug 11, 2023

(via build-ops)

(probably ignore the actual code here for now; this is becoming more of a place-holder for investigation and discussion)

GetDocumentInsider: use System.Diagnostics.DiagnosticSource from runtime

GetDocumentInsider has historically been using a very old version of the archived System.Diagnostics.DiagnosticSource from NuGet (OOB); however, System.Diagnostics.DiagnosticSource has recently been transitively updated in runtime via a resurected Microsoft.Extensions.Diagnostics.Abstractions by @Tratcher ; this is causing CI failures due to competition between two routes to the assembly, as illustrated by the CI here:

  • GetDocument.Insider -> Microsoft.Extensions.Hosting.Abstractions 8.0.0-rc.1.23410.15 -> Microsoft.Extensions.Diagnostics.Abstractions 8.0.0-rc.1.23410.15 -> System.Diagnostics.DiagnosticSource (>= 8.0.0-rc.1.23410.15)
  • GetDocument.Insider -> System.Diagnostics.DiagnosticSource (>= 4.6.0)

To resolve this, I propose changing GetDocumentInsider to use the runtime version of System.Diagnostics.DiagnosticSource (since I can't reasonably remove Microsoft.Extensions.Hosting.Abstractions).

Notes:

  • I do not know how to test this!
  • the transitive use of Unsafe was unsupported on netcoreapp2.1; I propose dropping this TFM, but I do not know if this has any significance (edit: yes, it very much does have significance; we can't do this 😢 )

C:\Users\marcg.nuget\packages\system.runtime.compilerservices.unsafe\6.0.0\buildTransitive\netcoreapp2.0\System.Runtime.CompilerServices.Unsafe.targets(4,5): error : System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.1. Consi
der updating your TargetFramework to netcoreapp3.1 or later. [C:\Code\aspnet\marc-diagnostics\src\Tools\GetDocumentInsider\src\GetDocument.Insider.csproj::TargetFramework=netcoreapp2.1]

I could have changed to netcoreapp3.1, but that too is end-of-life, so... 🤷

I've done a quick scan of the repo and GetDocumentInsider appears to be the only likely conflict, which is also supported by the CI failure above only reporting this one package.

@mgravell mgravell requested a review from Tratcher August 11, 2023 11:13
@ghost ghost added the area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI label Aug 11, 2023
@mgravell mgravell requested a review from wtgodbe August 11, 2023 11:18
@mgravell
Copy link
Member Author

mgravell commented Aug 11, 2023

Proposed solution isn't going to be enough by itself; has impact via:

Trying other options... next plan is to change System.Diagnostics.DiagnosticSource in runtime to not ref System.Memory in down-level build; however, this has a non-trivial number of span uses internally; even if we fixed that, we'd still have a problem in that System.Diagnostics.DiagnosticSource "current" targets netstandard 2.0, so it isn't going to build in a netcoreapp2.1 environment; the last version to target 2.1 was 5.0, so we could have a lot of fixes and we'd still have the System.Memory problem

Open to suggestions here... my thinking:

  1. stop targeting netcoreapp2.1 for the command-line-tools, but that's a huge thing to change last minute (maybe this should be focused for net9?)
  2. revert the diagnostic source update via Microsoft.Extensions.Hosting.Abstractions
  3. create a new project that is a clone of Microsoft.Extensions.Hosting.Abstractions just used from the command-line-tools, that has what we need without the new refs? or maybe add a netcoreapp2.1 TFM to Microsoft.Extensions.Hosting.Abstractions for this purpose?

@mgravell mgravell added the * NO MERGE * Do not merge this PR as long as this label is present. label Aug 11, 2023
@wtgodbe
Copy link
Member

wtgodbe commented Aug 14, 2023

Stop targeting netcoreapp2.1 for the command-line-tools, but that's a huge thing to change last minute (maybe this should be focused for net9?)

I agree we should do this, but it's probably too late 😢. Can you open an issue in 9 planning to track it?

Revert the diagnostic source update via Microsoft.Extensions.Hosting.Abstractions

I think we should do this unless @Tratcher knows of a quick fix in time for the RC1 build (branch snaps today at 5 PST)

create a new project that is a clone of Microsoft.Extensions.Hosting.Abstractions just used from the command-line-tools, that has what we need without the new refs? or maybe add a netcoreapp2.1 TFM to Microsoft.Extensions.Hosting.Abstractions for this purpose?

I think the latter option makes sense, maybe that's the quick fix we need

@wtgodbe
Copy link
Member

wtgodbe commented Aug 14, 2023

Actually I just had another idea, see code comment

@@ -20,9 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0">
Copy link
Member

Choose a reason for hiding this comment

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

Try bringing back the 4.6.0 reference & conditioning it on '$(TargetFramework)' == 'netcoreapp2.1', then having this non-versioned reference conditioned on '$(TargetFramework)' != 'netcoreapp2.1'

Copy link
Member

Choose a reason for hiding this comment

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

Just pushed that to this branch

@ghost ghost added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Aug 14, 2023
@wtgodbe
Copy link
Member

wtgodbe commented Aug 14, 2023

I folded this change into #50019, closing in favor of that

@wtgodbe wtgodbe closed this Aug 14, 2023
@wtgodbe wtgodbe deleted the marc-diagnostics branch November 15, 2023 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework * NO MERGE * Do not merge this PR as long as this label is present.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants