Skip to content

[Bug]: RXUISG0016 flags warnings on properties in non-reactive, non-observable classes #176

@ArcanoxDragon

Description

@ArcanoxDragon

Describe the bug 🐞

When creating auto properties in regular classes (not descending from IReactiveObject or any other RxUI type), the RXUISG0016 analyzer flags a warning on the property suggesting it should be turned into a Reactive property. This makes no sense for normal classes...there is no reason for normal, non-observable, non-INPC classes to have Reactive logic in them.

Image

Attempting to run the code fix action generates a nonsensical error message:

RXUISG0015: The field SKBitmapDrawOperation._bounds cannot be used to generate an reactive property, as its name or type would cause conflicts with other generated members

Image

The error message seems incorrect. The error is due to the object not being IObservableObject (this method), which is obviously the case here.

Not to pile on issues, but the description of #66 and #70 suggest that it shouldn't even be running this analyzer for read-only properties (as they can never change to begin with). The changes in #70 made it ignore private-settable properties, not read-only properties.

Step to reproduce

  1. Install the ReactiveUI.SourceGenerators package
  2. Write a simple class with a get-only property and that does not implement IReactiveObject:
public class TestClass(int x)
{
	public int Value { get; } = x;
}
  1. Observe that the Value property is flagged with the RXUISG0016 warning

Reproduction repository

https://github.com/ArcanoxDragon/ReactiveUI_AnalyzerIssue_Reproduction

Expected behavior

The RXUISG0016 analyzer should not flag a warning on any properties if the containing class does not somehow implement IReactiveObject.

In addition, the error message shown when a [Reactive] attribute is used within a class that does not implement IReactiveObject should be more clear.

Also in addition, the RXUISG0016 analyzer should not flag a warning for any properties that are fully read-only (i.e. no set; accessor at all), even inside of IReactiveObject inheritors.

Screenshots 🖼️

No response

IDE

Visual Studio 2022

Operating system

Windows 11

Version

No response

Device

No response

ReactiveUI Version

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