Skip to content

Replace platform's Logging source generator - #4238

Merged
joperezr merged 1 commit into
mainfrom
ReplaceLoggingGenerator
Aug 4, 2023
Merged

Replace platform's Logging source generator#4238
joperezr merged 1 commit into
mainfrom
ReplaceLoggingGenerator

Conversation

@joperezr

@joperezr joperezr commented Aug 2, 2023

Copy link
Copy Markdown
Member

cc: @geeknoid @RussKie @ViktorHofer @tarekgh

This PR will make sure that when Microsoft.Extensions.Telemetry.Abstractions package gets referenced, the import of the Microsoft.Extensions.Logging.Abstractions package is disabled as the new referenced package's source generator should take precedence.

For additional context, the package Microsoft.Extensions.Logging.Abstractions has a built-in targets file which will check if the property DisableMicrosoftExtensionsLoggingSourceGenerator is set to true, and if so, it will disable the automatic reference of the logging generator included in that package. The changes in this PR are just setting that value when the extensions Telemetry package gets referenced, in order to replace the logging generator with the extensions version.

Microsoft Reviewers: Open in CodeFlow

@ghost ghost assigned joperezr Aug 2, 2023
@joperezr

joperezr commented Aug 2, 2023

Copy link
Copy Markdown
Member Author

@ViktorHofer this currently doesn't work when targeting netcoreapp3.1, because currently the logging.abstractions package has a different buildTransitive .targets file for that TFM which just shows the not supported warning instead of having the mechanism that the rest of the TFMs have for disabling the source generator:

image

You would need a workaround similar than the one I'm introducing here which allows for extra content on that generated file in order for this to work.

@joperezr
joperezr requested review from RussKie and geeknoid August 2, 2023 20:36

@geeknoid geeknoid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Terrific!

@ViktorHofer

Copy link
Copy Markdown
Member

@ViktorHofer this currently doesn't work when targeting netcoreapp3.1, because currently the logging.abstractions package has a different buildTransitive .targets file for that TFM which just shows the not supported warning instead of having the mechanism that the rest of the TFMs have for disabling the source generator

This is by design as packages produced by dotnet/runtime don't support netcoreapp3.1. The runtime has been out-of-support since December 2022. We communicate this via the Warning task that we emit. cc @ericstj

@joperezr
joperezr merged commit 60800f8 into main Aug 4, 2023
@joperezr
joperezr deleted the ReplaceLoggingGenerator branch August 4, 2023 16:13
@ghost ghost added this to the 8.0 RC1 milestone Aug 4, 2023
@xakep139

xakep139 commented Aug 8, 2023

Copy link
Copy Markdown
Contributor

@joperezr does this PR resolves #4207?
If so, could you please link these two and close the issue? Thanks!

@joperezr

joperezr commented Aug 8, 2023

Copy link
Copy Markdown
Member Author

Yes, it does. 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide ability to replace the default logging code-gen

4 participants