Skip to content
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

Logging Source Generator emits CS0757 errors when referencing Microsoft.Extensions.Telemetry #4286

Closed
martincostello opened this issue Aug 14, 2023 · 10 comments · Fixed by #4287
Assignees

Comments

@martincostello
Copy link
Member

Description

I have a number of applications, both public and private, where for test purposes I've set them up to ingest changes from the .NET daily builds feed out of the dotnet/installer repo.

For one specific application, updating to .NET 8 RC1 daily builds is causing the application to fail to compile due to CS0757 errors for duplication partial logger method implementations. We use this pattern in many of the applications ingesting daily builds, but only this application was affected.

Through trial and error of cutting back the application to a minimal repro, I've found that this issue is caused when the application references the Microsoft.Extensions.Telemetry NuGet package (it doesn't even need to be used).

A repository that contains the subset of the application that causes the compilation error can be found at martincostello/CS0757-With-Telemetry-Repro.

Reproduction Steps

  1. Install version 8.0.100-rc.1.23412.1 of the .NET SDK.
  2. Clone https://github.com/martincostello/CS0757-With-Telemetry-Repro
  3. Run dotnet build /p:IncludeTelemetry=true

Expected behavior

The application compiles.

Actual behavior

The application fails to compile due to CS0757 errors:

> dotnet build /p:IncludeTelemetry=true
MSBuild version 17.8.0-preview-23401-01+b3989dc43 for .NET
  Determining projects to restore...
  Restored src\MyApplication\MyApplication.csproj (in 869 ms).
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(15,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(27,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(39,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(51,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(63,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]

Build FAILED.

src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(15,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(27,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(39,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(51,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(63,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
    0 Warning(s)
    5 Error(s)

Time Elapsed 00:00:02.65

Regression?

Worked with version 8.0.100-preview.7.23376.3 of the SDK.

Known Workarounds

Do not reference Microsoft.Extensions.Telemetry.

Configuration

  • .NET SDK 8.0.100-rc.1.23412.1
  • Microsoft.Extensions.Telemetry 8.0.0-rc.1.23409.4

Other information

It might be that this is caused by some sort of compiler/tooling lag between the runtime, extensions sdk and/or installer repos that will resolve itself over time as dependencies flow and is a non-issue in practice, but it's been broken in this application since last week so I thought it was worth flagging.

@ghost ghost added the untriaged label Aug 14, 2023
@ghost
Copy link

ghost commented Aug 14, 2023

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

Issue Details

Description

I have a number of applications, both public and private, where for test purposes I've set them up to ingest changes from the .NET daily builds feed out of the dotnet/installer repo.

For one specific application, updating to .NET 8 RC1 daily builds is causing the application to fail to compile due to CS0757 errors for duplication partial logger method implementations. We use this pattern in many of the applications ingesting daily builds, but only this application was affected.

Through trial and error of cutting back the application to a minimal repro, I've found that this issue is caused when the application references the Microsoft.Extensions.Telemetry NuGet package (it doesn't even need to be used).

A repository that contains the subset of the application that causes the compilation error can be found at martincostello/CS0757-With-Telemetry-Repro.

Reproduction Steps

  1. Install version 8.0.100-rc.1.23412.1 of the .NET SDK.
  2. Clone https://github.com/martincostello/CS0757-With-Telemetry-Repro
  3. Run dotnet build /p:IncludeTelemetry=true

Expected behavior

The application compiles.

Actual behavior

The application fails to compile due to CS0757 errors:

> dotnet build /p:IncludeTelemetry=true
MSBuild version 17.8.0-preview-23401-01+b3989dc43 for .NET
  Determining projects to restore...
  Restored src\MyApplication\MyApplication.csproj (in 869 ms).
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(15,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(27,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(39,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(51,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(63,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]

Build FAILED.

src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(15,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(27,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(39,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(51,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
src\MyApplication\Microsoft.Extensions.Logging.Generators\Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator\LoggerMessage.g.cs(63,40): error CS0757: A partial method may not have multiple implementing declarations [src\MyApplication\MyApplication.csproj]
    0 Warning(s)
    5 Error(s)

Time Elapsed 00:00:02.65

Regression?

Worked with version 8.0.100-preview.7.23376.3 of the SDK.

Known Workarounds

Do not reference Microsoft.Extensions.Telemetry.

Configuration

  • .NET SDK 8.0.100-rc.1.23412.1
  • Microsoft.Extensions.Telemetry 8.0.0-rc.1.23409.4

Other information

It might be that this is caused by some sort of compiler/tooling lag between the runtime, extensions sdk and/or installer repos that will resolve itself over time as dependencies flow and is a non-issue in practice, but it's been broken in this application since last week so I thought it was worth flagging.

Author: martincostello
Assignees: -
Labels:

area-Extensions-Logging

Milestone: -

@tarekgh
Copy link
Member

tarekgh commented Aug 14, 2023

@geeknoid @joperezr doesn't this is the issue you already fixed in the telemetry package?

@tarekgh tarekgh transferred this issue from dotnet/runtime Aug 14, 2023
@joperezr
Copy link
Member

Hey, yeah this one should be fixed but it would be good to validate with the latest version of the package to make sure everything works as expected.

@martincostello
Copy link
Member Author

@joperezr If you let me know what version of the package this should be fixed from, I can check it tomorrow when the update automation for our app runs again.

@joperezr
Copy link
Member

Thanks a bunch for the help @martincostello! This should have been fixed with: #4238, but after some testing I can see that this is indeed still broken for web projects (since the package is correctly removing the Logging.Abstractions analyzer package, but the web project targeting pack also includes this analyzer so it has to be removed from there as well). I'll put up a fix that addresses this and let you know when we have a package version for you to test

@joperezr
Copy link
Member

Thanks for the patience @martincostello. PR is now merged so version 8.0.0-rc.2.23416.4 should have the fix, would you be able to retry your tests with that version to ensure things work now? Thanks again for the help.

@joperezr joperezr added waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue. and removed untriaged labels Aug 17, 2023
@martincostello
Copy link
Member Author

Any chance of this fix being backported to RC1?

I can manually check it against RC2 today, but my automation is targeting RC1 and if the fix doesn't land until RC2 I'll have to comment-out the NuGet usage in the app until after RC1 ships and I switch to target RC2 dailies.

@ghost ghost removed the waiting-author-feedback 📭 The author of this issue needs to respond in order for us to continue investigating this issue. label Aug 17, 2023
@joperezr
Copy link
Member

Yeah, I think it should get backported. I'll send out the PR for that in a bit.

@geeknoid
Copy link
Member

geeknoid commented Sep 5, 2023

@joperezr Can we close this issue?

@joperezr
Copy link
Member

joperezr commented Sep 5, 2023

Yes, let's go ahead and close it. @martincostello if you can still repro with latest package, please feel free to re-open it.

@joperezr joperezr closed this as completed Sep 5, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants