Skip to content

[Bug]: Partial properties with Reactive or ObservableAsProperty attribute are flagged by RXUISG0016 analyzer #183

@DarkCloud14

Description

@DarkCloud14

Describe the bug 🐞

When creating partial properties with Reactive or ObservableAsProperty attribute in a class which is subclass of ReactiveObject the RXUISG0016 analyzer flags these properties and suggests to convert them to Reactive field.

Image

Even for the property using the ObservableAsProperty attribute it suggests to convert it to a field with the Reactive attribute instead of ObservableAsProperty attribute.

Step to reproduce

  1. Create a new .NET9 class library project
  2. Install the ReactiveUI and ReactiveUI.SourceGenerators packages
  3. Write a simple partial class which is a subclass of ReactiveObject
  4. Add a partial get-only property with [ObservableAsProperty] attribute and another partial property (get + set) with [Reactive] attribute
public partial class TestClass : ReactiveObject
{
    [ObservableAsProperty]
    public partial int TestObservableValue { get; }

    [Reactive]
    public partial int TestValue { get; set; }
}
  1. See that the TestObservableValue and TestValue properties are flagged with RXUISG0016 suggesting to change them to Reactive fields.

Reproduction repository

https://github.com/DarkCloud14/ReactiveUI_AnalyzerIssues

Expected behavior

The RXUISG0016 analyzer should not flag partial properties if they have the Reactive or ObservableAsProperty attribute (IMHO the last one is even wrong or at least using the suggested code fix produces not the code you'd expect).

In addition to this maybe the ReactiveUI analyzer or ReactiveUI.SourceGenerators could flag (or throw an error) standard properties which have the Reactive or ObservableAsProperty attribute as I think nothing will be created from the SourceGenerators and such properties won't work as expected?!

Screenshots 🖼️

No response

IDE

Rider macOS

Operating system

macOS Sequoia 15.3.1

Version

No response

Device

No response

ReactiveUI Version

ReactiveUI 20.1.63, ReactiveUI.SourceGenerators 2.1.1

Additional information ℹ️

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions