Skip to content

[Bug]: namespace error #54

@ethpch

Description

@ethpch

Describe the bug 🐞

Build Avalonia project always report CS0246 error. It seems like namespace is not resolved for custom classes. In generated files there are always no using statements for Avalonia namespace and Project.ViewModels namespace.

Step to reproduce

  1. Create a new Avalonia C# Project, enable ReactiveUI and add this package to the project by nuget
  2. Open MainView.axaml.cs
  3. Add [IViewFor(nameof(MainViewModel))] for MainView
  4. Build, and see error

Reproduction repository

No response

Expected behavior

No build errors

Screenshots 🖼️

image

IDE

Visual Studio 2022

Operating system

Windows 11 Pro

Version

23H2

Device

Desktop

ReactiveUI Version

18.3.1, by avalonia

Additional information ℹ️

Changing attribute to full declaration like [IViewFor($"ViewModels.{nameof(MainViewModel)}")] can avoid such issue, but StyledProperty and AvaloniaPropertyChangedEventArgs belongs to Avalonia namespace. Please fix this namespace error for Avalonia, and add more information at readme.

image

Maybe Generic Attribute could help, or scan the full assembly to find the correct class and its namespace. I'm not familar with SourceGenerators.

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