Skip to content

[Bug]: Build error with classes that implement IReactiveObject but do not inherit from ReactiveObject #224

@megazyz

Description

@megazyz

Describe the bug 🐞

Adding a [Reactive] property to a class that implements IReactiveObject but does not inherit from ReactiveObject leads to a build error:

The field {MyField} cannot be used to generate an ReactiveUI property, as it is not part of a class that inherits from ReactiveObject

This happens because IsTargetTypeValid(propertySymbol) compares IReactiveObject to propertySymbol.ContainingType.BaseType instead of checking the implemented interfaces on propertySymbol.ContainingType.

Step to reproduce

  1. Create a MyReactiveBase class that implements IReactiveObject but does not inherit from ReactiveObject
  2. Create a partial class that inherits from MyReactiveBase and add a partial property with the [Reactive] attribute
  3. Build

Try the reproduction repository.

Reproduction repository

https://github.com/megazyz/ReactiveUI.SourceGenerators.Repro1

Expected behavior

[Reactive] properties should work when the containing class implements IReactiveObject but does not inherit from ReactiveObject.

Screenshots 🖼️

No response

IDE

Visual Studio 2022

Operating system

No response

Version

No response

Device

No response

ReactiveUI Version

20.2.45

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