Describe the bug 🐞
If a class is marked with the IViewForAttribute<T>, the generator will carry over other attributes to the generated partial class. This means that such attributes as SingleInstanceViewAttribute and ViewContractAttribute cannot be used in conjunction with IViewForAttribute<T>.
Step to reproduce
-
From the CLI, run dotnet new globaljson --sdk-version 8.0.400
-
dotnet new wpf
-
dotnet add package ReactiveUI --version 20.1.63
-
dotnet add package ReactiveUI.SourceGenerators --version 2.0.9
-
Add a minimal view model class and attributes in MainWindow.xaml.cs.
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using ReactiveUI;
+using ReactiveUI.SourceGenerators;
namespace WpfApp1;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
+[IViewFor<MainViewModel>]
+[SingleInstanceView]
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
+public class MainViewModel : ReactiveObject;
-
Run dotnet build to compile. Observe the compilation error.
C:\Users\anon\source\WpfApp1\obj\Debug\net8.0-windows\ReactiveUI.SourceGenerators\ReactiveUI.SourceGenerators.IViewForGenerator\MainWindow.IViewFor.g.cs(14,10): error CS0579: Duplicate 'global::ReactiveUI.SingleInstanceViewAttribute' attribute [C:\Users\anon\source\WpfApp1\WpfApp1_bnyjhzvr_wpftmp.csproj]
Reproduction repository
https://github.com/n-ski/RxUIIViewForGeneratorBugSample
Expected behavior
I should be able to use IViewForAttribute<T> with other attributes.
Screenshots 🖼️
No response
IDE
Rider Windows
Operating system
Windows
Version
21H2
Device
No response
ReactiveUI Version
20.1.63
Additional information ℹ️
No response
Describe the bug 🐞
If a class is marked with the
IViewForAttribute<T>, the generator will carry over other attributes to the generated partial class. This means that such attributes asSingleInstanceViewAttributeandViewContractAttributecannot be used in conjunction withIViewForAttribute<T>.Step to reproduce
From the CLI, run
dotnet new globaljson --sdk-version 8.0.400dotnet new wpfdotnet add package ReactiveUI --version 20.1.63dotnet add package ReactiveUI.SourceGenerators --version 2.0.9Add a minimal view model class and attributes in MainWindow.xaml.cs.
Run
dotnet buildto compile. Observe the compilation error.Reproduction repository
https://github.com/n-ski/RxUIIViewForGeneratorBugSample
Expected behavior
I should be able to use
IViewForAttribute<T>with other attributes.Screenshots 🖼️
No response
IDE
Rider Windows
Operating system
Windows
Version
21H2
Device
No response
ReactiveUI Version
20.1.63
Additional information ℹ️
No response