Skip to content

Fix logging source generator CS0234 error with FormattableString namespace - #118691

Merged
stephentoub merged 2 commits into
dotnet:mainfrom
stephentoub:loggingnetfx
Aug 14, 2025
Merged

stephentoub merged 2 commits into
dotnet:mainfrom
stephentoub:loggingnetfx

Conversation

@stephentoub

@stephentoub stephentoub commented Aug 13, 2025 •

Copy link
Copy Markdown
Member

Fixes #118686.

This change fixes a regression introduced in the linked issue. It also enables the tests on .NET Framework, allowing us to catch similar issues in the future.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables logging generator tests to run on .NET Framework by adding multi-targeting support and handling framework-specific differences. The change allows better test coverage across different target frameworks.

Key changes:

  • Adds .NET Framework support to the test project configuration
  • Updates test code to handle .NET Framework API differences
  • Fixes a namespace reference in the generator code

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Microsoft.Extensions.Logging.Generators.targets Adds multi-targeting to include .NET Framework and includes required compatibility shim
LoggerMessageGeneratorEmitterTests.cs Updates async file operations and string splitting for .NET Framework compatibility, adds platform-specific baseline adjustments
LoggerMessageGenerator.Emitter.cs Corrects FormattableString namespace reference from CodeAnalysis to System

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-logging
See info in area-owners.md if you want to be subscribed.

@tarekgh

tarekgh commented Aug 13, 2025

Copy link
Copy Markdown
Member

@stephentoub I'll try to look at the related failures.

@tarekgh

tarekgh commented Aug 13, 2025

Copy link
Copy Markdown
Member

CC @ericstj regarding last commit fixing the test build error.

@tarekgh tarekgh 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.

Thanks @stephentoub for helping with that!

@stephentoub
stephentoub merged commit 438a8e7 into dotnet:main Aug 14, 2025
@stephentoub
stephentoub deleted the loggingnetfx branch August 14, 2025 18:54

@jvanlangen jvanlangen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why did you removed the async file reading?

@stephentoub

Copy link
Copy Markdown
Member Author

Why did you removed the async file reading?

Because those APIs don't exist on NET Framework where these tests now run.

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 15, 2025
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.

[10.0-preview.7] Cannot compile using logging source generator due to CS0234 errors

5 participants