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

[MVUX] Code generation fails to generate unique classes for generic types #2383

Open
kazo0 opened this issue Jun 22, 2024 · 1 comment
Open
Labels
area/mvux kind/bug Something isn't working

Comments

@kazo0
Copy link
Contributor

kazo0 commented Jun 22, 2024

Given Iterator.cs:

public partial record Iterator<T>(IImmutableList<T> Items)
{
    public int CurrentIndex { get; init; } = 0;
    public T CurrentItem => Items[CurrentIndex];
    public int Count => Items.Count;
    public bool CanMoveNext => CurrentIndex < Items.Count - 1;
    public bool CanMovePrevious => CurrentIndex > 0;

    public Iterator<T> MoveNext()
        => CanMoveNext
            ? this with { CurrentIndex = CurrentIndex + 1 }
            : this;

    public Iterator<T> MovePrevious()
        => CanMovePrevious
            ? this with { CurrentIndex = CurrentIndex - 1 }
            : this;
}

And the following Model code:

public partial record MainModel
{
    public MainModel()
    {
    }

    public IState<Iterator<int>> Ints => State<Iterator<int>>.Value(this, () => new Iterator<int>(Enumerable.Range(0, 3).ToImmutableList()));
    public IState<Iterator<string>> Strings => State<Iterator<string>>.Value(this, () => new Iterator<string>(new string[] { "A", "B", "C" }.ToImmutableList()));
}

The following errors occur at compile time:

1>X:\src\TestApps\UnoApp51\UnoApp51\obj\Debug\net8.0-windows10.0.19041\intermediatexaml\Uno.Extensions.Reactive.Generator\Uno.Extensions.Reactive.Generator.FeedsGenerator\UnoApp51.Models.Iterator_string_.g.cs(16,22,16,38): error CS0101: The namespace 'UnoApp51.Models' already contains a definition for 'BindableIterator'
1>X:\src\TestApps\UnoApp51\UnoApp51\obj\Debug\net8.0-windows10.0.19041\intermediatexaml\Uno.Extensions.Reactive.Generator\Uno.Extensions.Reactive.Generator.FeedsGenerator\UnoApp51.Models.Iterator_string_.g.cs(15,3,15,57): error CS0579: Duplicate 'global::System.CodeDom.Compiler.GeneratedCodeAttribute' attribute
1>X:\src\TestApps\UnoApp51\UnoApp51\obj\Debug\net8.0-windows10.0.19041\intermediatexaml\Uno.Extensions.Reactive.Generator\Uno.Extensions.Reactive.Generator.FeedsGenerator\UnoApp51.Models.Iterator_int_.g.cs(16,22,16,38): error CS0263: Partial declarations of 'BindableIterator' must not specify different base classes
1>X:\src\TestApps\UnoApp51\UnoApp51\obj\Debug\net8.0-windows10.0.19041\intermediatexaml\Uno.Extensions.Reactive.Generator\Uno.Extensions.Reactive.Generator.FeedsGenerator\UnoApp51.Models.Iterator_string_.g.cs(54,51,54,64): error CS0111: Type 'BindableIterator' already defines a member called 'CreateDefault' with the same parameter types

The classes that are generated are:

Iterator_int_g.cs:

public sealed class BindableIterator : global::Uno.Extensions.Reactive.Bindings.Bindable<UnoApp51.Models.Iterator<int>>

Iterator_string_g.cs:

public sealed class BindableIterator : global::Uno.Extensions.Reactive.Bindings.Bindable<UnoApp51.Models.Iterator<string>>

UnoApp51.zip

@kazo0 kazo0 added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. area/mvux and removed triage/untriaged Indicates an issue requires triaging or verification. labels Jun 22, 2024
@kazo0
Copy link
Contributor Author

kazo0 commented Jun 22, 2024

Related: #2366

cc: @dr1rrb

@kazo0 kazo0 changed the title [MVUX] Code generation fails to generate unique classes generic types [MVUX] Code generation fails to generate unique classes for generic types Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mvux kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant