{"id":14966895,"url":"https://github.com/reactiveui/reactiveui.sourcegenerators","last_synced_at":"2025-10-19T09:31:24.706Z","repository":{"id":152419820,"uuid":"624543868","full_name":"reactiveui/ReactiveUI.SourceGenerators","owner":"reactiveui","description":"Use source generators to generate objects. ","archived":false,"fork":false,"pushed_at":"2024-10-03T15:36:22.000Z","size":555,"stargazers_count":25,"open_issues_count":8,"forks_count":1,"subscribers_count":9,"default_branch":"main","last_synced_at":"2024-10-07T00:15:57.745Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reactiveui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["reactivemarbles"]}},"created_at":"2023-04-06T17:52:28.000Z","updated_at":"2024-09-30T22:29:35.000Z","dependencies_parsed_at":"2024-08-22T01:25:33.955Z","dependency_job_id":"80b37868-19d5-40c5-93f3-ed66c1085ed5","html_url":"https://github.com/reactiveui/ReactiveUI.SourceGenerators","commit_stats":{"total_commits":28,"total_committers":3,"mean_commits":9.333333333333334,"dds":0.3571428571428571,"last_synced_commit":"d9d6309192aa9b56885cefa7d3d6439d80086c19"},"previous_names":["reactiveui/reactiveui.sourcegenerators"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactiveui%2FReactiveUI.SourceGenerators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactiveui%2FReactiveUI.SourceGenerators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactiveui%2FReactiveUI.SourceGenerators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactiveui%2FReactiveUI.SourceGenerators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reactiveui","download_url":"https://codeload.github.com/reactiveui/ReactiveUI.SourceGenerators/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219869246,"owners_count":16555571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:37:06.822Z","updated_at":"2025-10-19T09:31:24.699Z","avatar_url":"https://github.com/reactiveui.png","language":"C#","funding_links":["https://github.com/sponsors/reactivemarbles"],"categories":[],"sub_categories":[],"readme":"# ReactiveUI Source Generators Documentation\n\nThis documentation covers using ReactiveUI Source Generators to simplify and enhance the use of ReactiveUI objects.\n\n- **Minimum Requirements**:\n  - **C# Version**: 12.0\n  - **Visual Studio Version**: 17.8.0\n  - **ReactiveUI Version**: 19.5.31+\n\n## Table of Contents\n- [Overview](#overview)\n- [Supported Attributes \u0026 Features](#supported-attributes)\n- [Detailed Usage](#welcome-to-a-new-way---source-generators)\n  - [Reactive](#reactive)\n  - [ObservableAsProperty](#observableasproperty)\n  - [ReactiveCommand](#reactivecommand)\n  - [IViewFor](#iviewfor)\n  - [BindableDerivedList](#usage-readonlyobservablecollection)\n  - [Platform-Specific Attributes](#platform-specific-attributes)\n- [Compatibility Notes](#compatibility-notes)\n- [Credits](#credits)\n\n## Overview\n\nReactiveUI Source Generators automatically generate ReactiveUI objects to streamline your code. These Source Generators are designed to work with ReactiveUI V19.5.31+ and support the following features:\n\n- `[Reactive]` With field and access modifiers, partial property support (C# 13 Visual Studio Version 17.12.0), partial properties with initializer support (C# preview only)\n- `[Reactive(SetModifier = AccessModifier.Protected)]` With field and access modifiers, (Not Required for partial properties, configure set accessor with the property decalaration).\n- `[Reactive(Inheritance = InheritanceModifier.Virtual)]` With field and access modifiers. This will generate a virtual property.\n- `[Reactive(UseRequired = true)]` With field and access modifiers. This will generate a required property, (Not Required for partial properties, use required keyword for property decalaration).\n- `[ObservableAsProperty]` With field, method, Observable property and partial property support (C# 13 Visual Studio Version 17.12.0)\n- `[ObservableAsProperty(ReadOnly = false)]` Removes readonly keyword from the generated helper field\n- `[ObservableAsProperty(PropertyName = \"ReadOnlyPropertyName\")]`\n- `[ObservableAsProperty(InitialValue = \"Default Value\")]` Only valid for partial properties using (C# 13 Visual Studio Version 17.12.0)\n- `[ReactiveCommand]`\n- `[ReactiveCommand(CanExecute = nameof(IObservableBoolName))]` with CanExecute\n- `[ReactiveCommand(OutputScheduler = \"RxApp.MainThreadScheduler\")]` using a ReactiveUI Scheduler\n- `[ReactiveCommand(OutputScheduler = nameof(_isheduler))]` using a Scheduler defined in the class\n- `[ReactiveCommand][property: AttributeToAddToCommand]` with Attribute passthrough\n- `[IViewFor(nameof(ViewModelName))]`\n- `[IViewFor\u003cYourViewModelType\u003e]`\n- `[IViewFor(\"YourNameSpace.YourGenericViewModel\u003cint\u003e\")]` Generic\n- `[IViewFor\u003cYourViewModelType\u003e(RegistrationType = SplatRegistrationType.PerRequest)]` with Splat Registration Type for IViewFor registration.\n- `[IViewFor\u003cYourViewModelType\u003e(RegistrationType = SplatRegistrationType.LazySingleton)]` Generic with Splat Registration Type for IViewFor registration.\n- `[IViewFor\u003cYourViewModelType\u003e(RegistrationType = SplatRegistrationType.Constant)]` Generic with Splat Registration Type for IViewFor registration.\n- `[RoutedControlHost(\"YourNameSpace.CustomControl\")]`\n- `[ViewModelControlHost(\"YourNameSpace.CustomControl\")]`\n- `[BindableDerivedList]` Generates a derived list from a ReadOnlyObservableCollection backing field\n- `[ReactiveCollection]` Generates property changed notifications on add, remove, new actions on a ObservableCollection backing field\n\n#### IViewFor Registration generator\n\nTo register all views for view models registered via the IViewFor Source Generator with a specified `RegistrationType`, call the following method during application startup:\n```csharp\nSplat.Locator.CurrentMutable.RegisterViewsForViewModelsSourceGenerated();\n```\n\n### Compatibility Notes\n- For ReactiveUI versions **older than V19.5.31**, all `[ReactiveCommand]` options are supported except for async methods with a `CancellationToken`.\n- For **.NET Framework 4.8 and older**, add [Polyfill by Simon Cropp](https://github.com/SimonCropp/Polyfill) or [PolySharp by Sergio Pedri](https://github.com/Sergio0694/PolySharp) to your project and set the `LangVersion` to 12.0 or later in your project file.\n\nFor more information on analyzer codes, see the [analyzer codes documentation](https://github.com/reactiveui/ReactiveUI.SourceGenerators/blob/main/src/ReactiveUI.SourceGenerators/AnalyzerReleases.Shipped.md).\n\n---\n\n## Supported Attributes\n\n### `[Reactive]`\nMarks properties as reactive, generating getter and setter code.\n\n### `[ObservableAsProperty]`\nGenerates read-only properties backed by an `ObservableAsPropertyHelper` based on an `IObservable`.\n\n### `[ReactiveCommand]`\nGenerates commands, with options to add attributes or enable `CanExecute` functionality.\n\n### `[IViewFor]`\nLinks a view to a view model for data binding. Supports generic types and Splat registration.\n\n### `[RoutedControlHost]` and `[ViewModelControlHost]`\nPlatform-specific attributes for control hosting in WinForms applications.\n\n### `[BindableDerivedList]`\nGenerates a derived list from a `ReadOnlyObservableCollection` backing field.\n\n### `[ReactiveCollection]`\nGenerates property changed notifications on add, remove, and new actions on an `ObservableCollection` backing field.\n\n## Historical Approach\n\n### Read-Write Properties\nPreviously, properties were declared like this:\n\n```csharp\nprivate string _name;\npublic string Name \n{\n    get =\u003e _name;\n    set =\u003e this.RaiseAndSetIfChanged(ref _name, value);\n}\n```\n\nBefore these Source Generators were available we used ReactiveUI.Fody.\nWith ReactiveUI.Fody the `[Reactive]` Attribute was placed on a Public Property with Auto get / set properties, the generated code from the Source Generator and the Injected code using Fody are very similar with the exception of the Attributes.\n\n```csharp\n[Reactive]\npublic string Name { get; set; }\n```\n\n## ObservableAsPropertyHelper properties\nSimilarly, to declare output properties, the code looks like this:\n```csharp\npublic partial class MyReactiveClass : ReactiveObject\n{\n    ObservableAsPropertyHelper\u003cstring\u003e _firstName;\n\n    public MyReactiveClass()\n    {\n        _firstName = firstNameObservable\n            .ToProperty(this, x =\u003e x.FirstName);\n    }\n\n    public string FirstName =\u003e _firstName.Value;\n\n    private IObservable\u003cstring\u003e firstNameObservable() =\u003e Observable.Return(\"Test\");\n}\n```\n\nWith ReactiveUI.Fody, you can simply declare a read-only property using the [ObservableAsProperty] attribute, using either option of the two options shown below.\n```csharp\n[ObservableAsProperty]\npublic string FirstName { get; }\n```\n\n# Welcome to a new way - Source Generators\n\n## Usage Reactive property `[Reactive]`\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{\n    [Reactive]\n    private string _myProperty;\n}\n```\n\n### Usage Reactive property with set Access Modifier\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{\n    [Reactive(SetModifier = AccessModifier.Protected)]\n    private string _myProperty;\n}\n```\n\n### Usage Reactive property with property Attribute pass through\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{\n    [Reactive]\n    [property: JsonIgnore]\n    private string _myProperty;\n}\n```\n\n### Usage Reactive property from partial property\n\nPartial properties are supported in C# 13 and Visual Studio 17.12.0 and later.\nBoth the getter and setter must be empty, and the `[Reactive]` attribute must be placed on the property.\nOverride and Virtual properties are supported.\nSet Access Modifier is also supported on partial properties.\n\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{\n    [Reactive]\n    public partial string MyProperty { get; set; }\n}\n```\n\n### Usage Reactive property from partial property with default value\nPartial properties with initial value are supported in C# preview and Visual Studio 17.12.0 and later.\nBoth the getter and setter must be empty, and the `[Reactive]` attribute must be placed on the property.\nOverride and Virtual properties are supported.\nSet Access Modifier is also supported on partial properties.\n```csharp\nusing ReactiveUI.SourceGenerators;\npublic partial class MyReactiveClass : ReactiveObject\n{\n    [Reactive]\n    public partial string MyProperty { get; set; } = \"Default Value\"\n}\n```\n\n## Usage ObservableAsPropertyHelper `[ObservableAsProperty]`\n\nObservableAsPropertyHelper is used to create a read-only property from an IObservable. The generated code will create a backing field and a property that returns the value of the backing field. The backing field is initialized with the value of the IObservable when the class is instantiated.\n\nA private field is created with the name of the property prefixed with an underscore. The field is initialized with the value of the IObservable when the class is instantiated. The property is created with the same name as the field without the underscore. The property returns the value of the field until initialized, then it returns the value of the IObservable.\n\nYou can define the name of the property by using the PropertyName parameter. If you do not define the PropertyName, the property name will be the same as the field name without the underscore.\n\n### Usage ObservableAsPropertyHelper with Field\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{\n    [ObservableAsProperty]\n    private string _myProperty = \"Default Value\";\n\n    public MyReactiveClass()\n    {\n        _myPrpertyHelper = MyPropertyObservable()\n            .ToProperty(this, x =\u003e x.MyProperty);\n    }\n\n    IObservable\u003cstring\u003e MyPropertyObservable() =\u003e Observable.Return(\"Test Value\");\n}\n```\n\n### Usage ObservableAsPropertyHelper with Field and non readonly nullable OAPH field\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject, IActivatableViewModel\n{\n    [ObservableAsProperty(ReadOnly = false)]\n    private string _myProperty = \"Default Value\";\n\n    public MyReactiveClass()\n    {\n        this.WhenActivated(disposables =\u003e\n        {\n            _myPrpertyHelper = MyPropertyObservable()\n                .ToProperty(this, x =\u003e x.MyProperty)\n                .DisposeWith(disposables);\n        });\n    }\n\n    IObservable\u003cstring\u003e MyPropertyObservable() =\u003e Observable.Return(\"Test Value\");\n}\n```\n\n### Usage ObservableAsPropertyHelper with Observable Property and specific PropertyName\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{    \n    [ObservableAsProperty(ReadOnly = false)]\n    private string _myProperty = \"Default Value\";\n\n    public MyReactiveClass()\n    {\n        this.WhenActivated(disposables =\u003e\n        {\n            _myPrpertyHelper = MyPropertyObservable()\n                .ToProperty(this, x =\u003e x.MyProperty)\n                .DisposeWith(disposables);\n        });\n    }\n\n    IObservable\u003cstring\u003e MyPropertyObservable() =\u003e Observable.Return(\"Test Value\");\n}\n```\n\n### Usage ObservableAsPropertyHelper with Observable Property and protected OAPH field\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{\n    [ObservableAsProperty(UseProtected = true)]\n    private string _myProperty = \"Default Value\";\n\n    public MyReactiveClass()\n    {\n        _myPrpertyHelper = MyPropertyObservable()\n            .ToProperty(this, x =\u003e x.MyProperty);\n    }\n\n    IObservable\u003cstring\u003e MyPropertyObservable() =\u003e Observable.Return(\"Test Value\");\n}\n```\n\n### Usage ObservableAsPropertyHelper with Observable Method\n\nNOTE: This does not currently support methods with parameters\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{    \n    public MyReactiveClass()\n    { \n        // Initialize generated _myObservablePropertyHelper\n        // for the generated MyObservableProperty\n        InitializeOAPH();\n    }\n\n    [ObservableAsProperty]\n    IObservable\u003cstring\u003e MyObservable() =\u003e Observable.Return(\"Test Value\");\n}\n```\n\n### Usage ObservableAsPropertyHelper with Observable Method and specific PropertyName\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{    \n    public MyReactiveClass()\n    { \n        // Initialize generated _testValuePropertyHelper\n        // for the generated TestValueProperty\n        InitializeOAPH();\n    }\n\n    [ObservableAsProperty(PropertyName = TestValueProperty)]\n    IObservable\u003cstring\u003e MyObservable() =\u003e Observable.Return(\"Test Value\");\n}\n```\n\n### Usage ObservableAsPropertyHelper with Observable Method and protected OAPH field\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{    \n    public MyReactiveClass()\n    { \n        // Initialize generated _myObservablePropertyHelper\n        // for the generated MyObservableProperty\n        InitializeOAPH();\n    }\n\n    [ObservableAsProperty(UseProtected = true)]\n    IObservable\u003cstring\u003e MyObservable() =\u003e Observable.Return(\"Test Value\");\n}\n```\n\n### Usage ObservableAsPropertyHelper with partial Property and a default value\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{\n    public MyReactiveClass()\n    {\n        // The value of MyProperty will be \"Default Value\" until the Observable is initialized\n        _myPrpertyHelper = MyPropertyObservable()\n            .ToProperty(this, nameof(MyProperty));\n    }\n    \n    [ObservableAsProperty(InitialValue = \"Default Value\")]\n    public partial string MyProperty { get; }\n\n    public IObservable\u003cstring\u003e MyPropertyObservable() =\u003e Observable.Return(\"Test Value\");\n}\n```\n\n## Usage ReactiveCommand `[ReactiveCommand]`\n\n### Usage ReactiveCommand without parameter\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    [ReactiveCommand]\n    private void Execute() { }\n}\n```\n\n### Usage ReactiveCommand with parameter\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    [ReactiveCommand]\n    private void Execute(string parameter) { }\n}\n```\n\n### Usage ReactiveCommand with parameter and return value\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    [ReactiveCommand]\n    private string Execute(string parameter) =\u003e parameter;\n}\n```\n\n### Usage ReactiveCommand with parameter and async return value.\n\nNote: the Async suffix is removed from the generated command\n\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    [ReactiveCommand]\n    private async Task\u003cstring\u003e ExecuteAsync(string parameter) =\u003e await Task.FromResult(parameter);\n\n    // Generates the following code ExecuteCommand, Note the Async suffix is removed\n}\n```\n\n### Usage ReactiveCommand with IObservable return value\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    [ReactiveCommand]\n    private IObservable\u003cstring\u003e Execute(string parameter) =\u003e Observable.Return(parameter);\n}\n```\n\n### Usage ReactiveCommand with CancellationToken\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    [ReactiveCommand]\n    private async Task Execute(CancellationToken token) =\u003e await Task.Delay(1000, token);\n}\n```\n\n### Usage ReactiveCommand with CancellationToken and parameter\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    [ReactiveCommand]\n    private async Task\u003cstring\u003e Execute(string parameter, CancellationToken token)\n    {\n        await Task.Delay(1000, token);\n        return parameter;\n    }\n}\n```\n\n### Usage ReactiveCommand with CanExecute\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    private IObservable\u003cbool\u003e _canExecute;\n\n    [Reactive]\n    private string _myProperty1;\n\n    [Reactive]\n    private string _myProperty2;\n\n    public MyReactiveClass()\n    {\n        _canExecute = this.WhenAnyValue(x =\u003e x.MyProperty1, x =\u003e x.MyProperty2, (x, y) =\u003e !string.IsNullOrEmpty(x) \u0026\u0026 !string.IsNullOrEmpty(y));\n    }\n\n    [ReactiveCommand(CanExecute = nameof(_canExecute))]\n    private void Search() { }\n}\n```\n\n### Usage ReactiveCommand with property Attribute pass through\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    private IObservable\u003cbool\u003e _canExecute;\n\n    [Reactive]\n    private string _myProperty1;\n\n    [Reactive]\n    private string _myProperty2;\n\n    public MyReactiveClass()\n    {\n        _canExecute = this.WhenAnyValue(x =\u003e x.MyProperty1, x =\u003e x.MyProperty2, (x, y) =\u003e !string.IsNullOrEmpty(x) \u0026\u0026 !string.IsNullOrEmpty(y));\n    }\n\n    [ReactiveCommand(CanExecute = nameof(_canExecute))]\n    [property: JsonIgnore]\n    private void Search() { }\n}\n```\n\n### Usage ReactiveCommand with ReactiveUI OutputScheduler\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    [ReactiveCommand(OutputScheduler = \"RxApp.MainThreadScheduler\")]\n    private void Execute() { }\n}\n```\n\n### Usage ReactiveCommand with custom OutputScheduler\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    private IScheduler _customScheduler = new TestScheduler();\n\n    [ReactiveCommand(OutputScheduler = nameof(_customScheduler))]\n    private void Execute() { }\n}\n```\n\n## Usage IViewFor `[IViewFor(nameof(ViewModelName))]`\n\n### IViewFor usage\n\nIViewFor is used to link a View to a ViewModel, this is used to link the ViewModel to the View in a way that ReactiveUI can use it to bind the ViewModel to the View.\nThe ViewModel is passed as a type to the IViewFor Attribute using generics.\nThe class must inherit from a UI Control from any of the following platforms and namespaces:\n- Maui (Microsoft.Maui)\n- WinUI (Microsoft.UI.Xaml)\n- WPF (System.Windows or System.Windows.Controls)\n- WinForms (System.Windows.Forms)\n- Avalonia (Avalonia)\n- Uno (Windows.UI.Xaml).\n\n### IViewFor with Splat Registration Type\n\nChoose from the following Splat Registration Types:\n- `SplatRegistrationType.PerRequest`\n- `SplatRegistrationType.LazySingleton`\n- `SplatRegistrationType.Constant`\n- `SplatRegistrationType.None` (Default if not specified - no registration is performed)\n\n```csharp\nusing ReactiveUI.SourceGenerators;\nusing Splat;\n[IViewFor\u003cMyReactiveClass\u003e(RegistrationType = SplatRegistrationType.PerRequest)]\npublic partial class MyReactiveControl : UserControl\n{\n    public MyReactiveControl()\n    {\n        InitializeComponent();\n        ViewModel = Locator.Current.GetService\u003cMyReactiveClass\u003e();\n    }\n}\n```\n\nthis will generate the following code to enable you register the marked Views as `IViewFor\u003cViewModel\u003e` with Splat:\n```csharp\nusing ReactiveUI.SourceGenerators;\n\nSplat.Locator.CurrentMutable.RegisterViewsForViewModelsSourceGenerated();\n```\n\n### Usage IViewFor with ViewModel Name - Generic Types should be used with the fully qualified name, otherwise use nameof(ViewModelTypeName)\n```csharp\nusing ReactiveUI.SourceGenerators;\n\n[IViewFor(\"MyReactiveGenericClass\u003cint\u003e\")]\npublic partial class MyReactiveControl : UserControl\n{\n    public MyReactiveControl()\n    {\n        InitializeComponent();\n        ViewModel = new MyReactiveClass();\n    }\n}\n```\n\n### Usage IViewFor with ViewModel Type\n\n```csharp\nusing ReactiveUI.SourceGenerators;\n\n[IViewFor\u003cMyReactiveClass\u003e]\npublic partial class MyReactiveControl : UserControl\n{\n    public MyReactiveControl()\n    {\n        InitializeComponent();\n        ViewModel = new MyReactiveClass();\n    }\n}\n```\n\n### Usage ReadOnlyObservableCollection\n\n```csharp\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass\n{\n    [BindableDerivedList]\n    private readonly ReadOnlyObservableCollection\u003cstring\u003e _myList;\n}\n```\n\n## Platform specific Attributes\n\n### WinForms\n\n#### RoutedControlHost\n```csharp\nusing ReactiveUI.SourceGenerators.WinForms;\n\n[RoutedControlHost(\"YourNameSpace.CustomControl\")]\npublic partial class MyCustomRoutedControlHost;\n```\n\n#### ViewModelControlHost\n```csharp\nusing ReactiveUI.SourceGenerators.WinForms;\n\n[ViewModelControlHost(\"YourNameSpace.CustomControl\")]\npublic partial class MyCustomViewModelControlHost;\n```\n\n### ReactiveCollection\n```csharp\nusing System.Collections.ObjectModel;\nusing ReactiveUI;\nusing ReactiveUI.SourceGenerators;\n\npublic partial class MyReactiveClass : ReactiveObject\n{\n    [ReactiveCollection]\n    private ObservableCollection\u003cstring\u003e _myCollection;\n\n    public MyReactiveClass()\n    {\n        MyCollection = new ObservableCollection\u003cstring\u003e();\n        _myCollection.Add(\"Item 1\");\n    }\n}\n```\n\n### TODO:\n- Add ObservableAsProperty to generate from a IObservable method with parameters.\n\n# Credits\n\nPortions of this code base are based on and derived from\n* [PolySharp](https://github.com/Sergio0694/PolySharp) library. Thanks go to @Sergio0694\n* [Microsoft MVVM Community Toolkit](https://github.com/CommunityToolkit/dotnet)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactiveui%2Freactiveui.sourcegenerators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freactiveui%2Freactiveui.sourcegenerators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactiveui%2Freactiveui.sourcegenerators/lists"}