Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error with Source Generator when using nested types #133

Open
lxy-iUnknown opened this issue Nov 15, 2024 · 0 comments
Open

[Bug]: Error with Source Generator when using nested types #133

lxy-iUnknown opened this issue Nov 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@lxy-iUnknown
Copy link

lxy-iUnknown commented Nov 15, 2024

Describe the bug 🐞

I'm encountering an issue with the ReactiveUI.SourceGenerators package (version 2.0.17) in my Avalonia project. After upgrading to this version, I receive the following warning during compilation:

ReactiveCommandGenerator\InnerClass.ReactiveCommands.g.cs(17,175): error CS0103: The name 'Test' does not exist in the current context

Step to reproduce

  1. Create a nested type
  2. Annotate method in nested type with [ReactiveCommand]
  3. Compile the project and observe the error.

Reproduction repository

https://github.com/lxy-iUnknown/ReactiveGeneratorSample

Expected behavior

The source generator should handle nested types without causing conflicts or errors.

Screenshots 🖼️

No response

IDE

Visual Studio 2022

Operating system

Windows 11

Version

2.0.17

Device

No response

ReactiveUI Version

No response

Additional information ℹ️

Generated code:

// <auto-generated/>

#pragma warning disable
#nullable enable

namespace ReactiveGeneratorSample
{
    /// <summary>
    /// Partial class for the InnerClass which contains ReactiveUI ReactiveCommand initialization.
    /// </summary>
    public partial class InnerClass
    {
        [global::System.CodeDom.Compiler.GeneratedCode("ReactiveUI.SourceGenerators.ReactiveCommandGenerator", "2.0.0.0")]
        private ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit>? _testCommand;

        [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
        public ReactiveUI.ReactiveCommand<global::System.Reactive.Unit, global::System.Reactive.Unit> TestCommand { get => _testCommand ??= ReactiveUI.ReactiveCommand.Create(Test); }
    }
}
#nullable restore
#pragma warning restore
@lxy-iUnknown lxy-iUnknown added the bug Something isn't working label Nov 15, 2024
@lxy-iUnknown lxy-iUnknown changed the title [Bug]: Error with Source Generator when using nested classes [Bug]: Error with Source Generator when using nested types Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant