-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix build when using source generators (#6534) #6680
Conversation
Hi @singhashish-wpf. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge. To learn more about how to prepare a servicing PR click here. |
/cc: @ThomasGoulet73 |
@jaredpar , tactics wondered whether a compiler feature like this ought to have a minimal test for each appmodel upstream. I see the Roslyn repo has some test projects that use WPF in connection with code analysis. If one of those used a source generator, would it have caught this bug? |
Merge when ready, we are past 6.0.7 code complete. |
@singhashish-wpf After updating to the latest .NET 6 SDK released today, analyzers are now passed twice to the CoreCompile target in the WPF generated project. Some analyzers don't like this and fail with "The namespace already contains a type ". Analyzers are now explicitly listed in the generated project and also imported by the ResolveLockFileAnalyzers target, resulting in duplicates. |
@jlaanstra Could you provide a repro ? Analyzers need to be run twice because of source generators and the way Baml compilation requires CoreCompile to be run twice (Once for the generated project and once for the main project). |
@singhashish-wpf Since update my WPF application using Microsoft MVVM Toolkit reports errors CS0579 (duplicate attribute) and CS0111 (duplicate member declaration) at compile time, possibly connected to source generators in the toolkit: |
same problem |
This seems to be a bug with Analyzers from nuget packages. I'll try to prepare a fix soon. This PR fixed Source Generators from the SDK but broke Source Generators coming from nuget packages. |
global.json workaround works for me -- #6792 |
Edit: See #6792 (comment) for a better workaround.
|
@ThomasGoulet73 I have a binlog that I can't publicly share. Msft employes can reach out internally if they need it. I'm using the following workaround which allows both scenarios to work:
|
What will be the correct fix and where can i follow it ? on the .net sdk itself ? |
In 6.0.9 release. Current fix is hanging in 6.0.9 milestone. |
Thanks for the workaround. |
Fixes #6522
Fixes dotnet/roslyn#60257
Description
Fixes the build when using source generators.
Customer Impact
Without this PR, customers cannot build a WPF application with source generators.
Regression
No. To my knowledge, it never worked.
Testing
Tested by building a blank WPF application that uses the Regex source generator. This PR fixed the build.
Risk
Low.
/cc @RussKie (It looks like your hunch about the
Analyzers
property was right)Microsoft Reviewers: Open in CodeFlow
Microsoft Reviewers: Open in CodeFlow