Skip to content

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

@martincostello

Description

@martincostello

Description

After updating OpenTelemetry to .NET 10 preview 7, some of our projects fail to compile for due to the following error:

D:\Coding\open-telemetry\opentelemetry-dotnet\test\Benchmarks\obj\Debug\net462\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(37,24): error CS0234: The type or namespace name 'FormattableString' does not exist in the namespace 'System.Diagnostics.CodeAnalysis' (are you missing an assembly reference?)

This appears to be due to this line of code that was added by #117009:

"global::System.Diagnostics.CodeAnalysis.FormattableString.Invariant(";

I think it should be this?

- "global::System.Diagnostics.CodeAnalysis.FormattableString.Invariant("
+ "global::System.FormattableString.Invariant("

Reproduction Steps

  1. Clone open-telemetry/opentelemetry-dotnet@7487f44
  2. Run dotnet build from the root of the repository

Expected behavior

The solution compiles.

Actual behavior

Projects fail to compile due to CS0234 errors.

Regression?

Yes.

Known Workarounds

  1. Don't use the logging source generator
  2. Use fewer parameters to not enter the broken code block.

Configuration

.NET SDK 10.0.100-preview.7.25380.108

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions