- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Bug]: Legacy MSBuild projects sometimes fail to build #144
Comments
I just saw in the README that for net481, you're supposed to use Polyfill or PolySharp -- not sure how I missed that before. I added a polysharp branch to the repro where I use PolySharp instead of my own hack. The behavior is unchanged. |
I'm a bit behind on a lot of maintenance stuff in regards to this project and @ChrisPulman is out til christmas. There can be issues with source generator relying on source generators. I know they moved some of the xaml into a generated based context, not sure if they are using source generators to do. |
Usually the way I've solved source generator relying on source generator issues is to move into separate projects the source code so only one generator happens at any one time. |
Yeah, @ChrisPulman. That's exactly what I've been doing. Thanks for looking into this. I gather that there's nothing to do here except close this issue and possibly open an issue with msbuild (I'm assuming that's not worth it)? |
The Source Generator is definitely working. Generated types exist at runtime. It's just that they can only be referenced via reflection. Static references cause build failures. Very strange behavior. |
Describe the bug 🐞
By adding a Window with a namespace definition in an SDK-style .NET Framework WPF application, we can essentially prevent SourceGenerators from generating code. The IDE makes it look like everything is fine: you can navigate to the generated source file for properties generated by the
[ReactiveUI.SourceGenerators.ReactiveAttribute]
, but the project fails to compile:Step to reproduce
This project is a minimal reproduction. Initial commit b27e435 builds just fine in both a legacy and sdk-style project. a845b4a adds an
xmlns:local
definition to XAML. Once that namespace is added, the legacy application no longer compiles (though the SDK-style project continues to compile).Reproduction repository
https://github.com/timothylcooke/SourceGeneratorIssue
Expected behavior
The project should compile
Screenshots 🖼️
No response
IDE
No response
Operating system
Windows 11 23H2
Version
Visual Studio 17.12.3
Device
No response
ReactiveUI Version
2.0.17
Additional information ℹ️
It's unclear if this is even your bug, or if it's an issue in msbuild.
I have a legacy WPF application deployed with ClickOnce, so I can't switch to an SDK-style project without a whole lot of headache. While
ReactiveUI.Fody
works fine, I'd like to start usingReactiveUI.SourceGenerators
.Adding local namespaces in XAML is a very common thing in WPF that I can't just avoid doing. The best workaround I have is to move any VM classes to a library.
If you remove all references to
ReactiveAttribute
to get the project to compile, you can access the type via reflection:var reactiveAttributeTypeViaReflection = GetType().Assembly.GetType("ReactiveUI.SourceGenerators.ReactiveAttribute");
So, it seems like it's an issue with the order of build events: it seems that the generated files are being added after the static files are built, so any references from static files to generated types fail to compile because the types haven't been generated yet.The text was updated successfully, but these errors were encountered: