Skip to content

[Bug]: ReactiveCommand generator doesn't generate global:: for ReactiveUI.ReactiveCommand<,> #351

@chhaugen

Description

@chhaugen

Describe the bug 🐞

When generating the code for a [ReactiveCommand], the generator puts global:: for everyting, except ReactiveUI.ReactiveCommand<,>. I discovered this when i tried to use it on a project where ReactiveUI was a part of the namespace, the compiler got confused, and stated it couldn't find ReactiveCommand<,> at MyCompany.ReactiveUI, when the namespace was MyCompany.ReactiveUI.App.Core.

public partial class MainViewModel
{
    private ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::ReactiveUI.IRoutableViewModel>? _goToSmileCommand;

    [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveCommandGenerator", "2.5.0.0")]
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
    public ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::ReactiveUI.IRoutableViewModel> GoToSmileCommand { get => _goToSmileCommand ??= ReactiveUI.ReactiveCommand.CreateFromObservable<global::System.Reactive.Unit, global::ReactiveUI.IRoutableViewModel>(GoToSmile); }
}

Step to reproduce

  1. Create an ReactiveObject class, with partial and everything
  2. Make a ReactiveCommand like this one:
[ReactiveCommand]
private IObservable<IRoutableViewModel> GoToSmile(Unit _) =>
    Router.Navigate.Execute(new SmileViewModel());
  1. Write GoToSmileCommand in the constructor and use F12 to observe the generated output
  2. See error

Reproduction repository

No response

Expected behavior

This should happen...

public partial class MainViewModel
{
    private global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::ReactiveUI.IRoutableViewModel>? _goToSmileCommand;

    [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveCommandGenerator", "2.5.0.0")]
    [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
    public global::ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::ReactiveUI.IRoutableViewModel> GoToSmileCommand { get => _goToSmileCommand ??= ReactiveUI.ReactiveCommand.CreateFromObservable<global::System.Reactive.Unit, global::ReactiveUI.IRoutableViewModel>(GoToSmile); }
}

Screenshots 🖼️

No response

IDE

Visual Studio 2022

Operating system

Windows

Version

Windows 11 Pro

Device

No response

ReactiveUI Version

22.3.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