You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
error CS0234: The type or namespace name 'SourceGenerators' does not exist in the namespace 'ReactiveUI' (are you missing an assembly reference?)
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).
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 using ReactiveUI.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:
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.
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: