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

Feed generation fails for Select operator on data object with required members #2583

Open
ProphetLamb opened this issue Oct 8, 2024 · 4 comments
Labels
kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification.

Comments

@ProphetLamb
Copy link

Current behavior

  1. Create a POCO with required members.
  2. Create a state from an instance of that POCO.
  3. Select from the state
  4. Compilation fails.

Expected behavior

The project compiles.

How to reproduce it (as minimally and precisely as possible)

ProjectModel

public Guid Key { get; } // passed via constructor. Defined by DataViewMap

public IState<Project> Project => State.Async(this, async ct => await _projectRepository.Project(Key, ct) ?? throw new InvalidOperationException($"Project {Key} does not exist"));
public IListFeed<string> PositionTextList => Project.Select(project => project.Plan.Positions.Select(pos =>
            $"""
            {project.Plan.QualifiedProjectName} / {project.Plan.Operation} / {pos.Position} / {pos.Enhancement} / {pos.ProductName} {pos.ProductVersion} / {project.Plan.LoggedonUser} / {DateTime.Now.Date:yyyy-MM-dd}
            - {pos.Description.Trim()} {pos.DescriptionExtended.Trim()}
            """
        )
        .ToImmutableList()
    ).AsListFeed();

Project

public sealed record Project
{
    public required ProjectPlan Plan { get; init; }
    public required DevelopmentServer Server { get; init; }
    public required ImmutableArray<ProjectFile> Files { get; init; }
}

Workaround

Sadly, I am unable to view the generated files, since Uno cleans them up immediately.
I assume the source generator new() instantiates the Project at some point.

...\obj\Debug\net8.0-desktop\Uno.Extensions.Reactive.Generator\Uno.Extensions.Reactive.Generator.FeedsGenerator\AutoDev.Models.Project.g.cs(40,7): error CS9035: Required member 'Project.Plan' must be set in the object initializer or attribute constructor. [...\AutoDev.csproj::TargetFramework=net8.0-desktop]
...\obj\Debug\net8.0-desktop\Uno.Extensions.Reactive.Generator\Uno.Extensions.Reactive.Generator.FeedsGenerator\AutoDev.Models.Project.g.cs(40,7): error CS9035: Required member 'Project.Server' must be set in the object initializer or attribute constructor. [...\AutoDev.csproj::TargetFramework=net8.0-desktop]
...\obj\Debug\net8.0-desktop\Uno.Extensions.Reactive.Generator\Uno.Extensions.Reactive.Generator.FeedsGenerator\AutoDev.Models.Project.g.cs(40,7): error CS9035: Required member 'Project.Files' must be set in the object initializer or attribute constructor. [...\AutoDev.csproj::TargetFramework=net8.0-desktop]

Works on UWP/WinUI

None

Environment

Uno.SourceGenerationTasks

NuGet package version(s)

<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="FluentAssertions" Version="6.12.1" />
<PackageVersion Include="FluentValidation" Version="11.10.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  <PrivateAssets>all</PrivateAssets>
</PackageVersion>
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="NUnit" Version="4.2.2" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Uno.Extensions.Validation.Fluent" Version="5.0.2" />
<PackageVersion Include="Uno.UITest.Helpers" Version="1.0.0" />
<PackageVersion Include="Xamarin.UITest" Version="4.4.0" />

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@ProphetLamb ProphetLamb added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels Oct 8, 2024
@Youssef1313
Copy link
Member

Moving to uno.extensions as this is where the generator in question is implemented

@Youssef1313 Youssef1313 transferred this issue from unoplatform/uno Oct 9, 2024
@Youssef1313
Copy link
Member

cc @dr1rrb

@ProphetLamb
Copy link
Author

Upon further testing, I found this error is entirely unrelated to the Select. Instead the generation already fails for IState<Project>.
Maybe a SetsRequireMembers annotation is missing somewhere?

@ProphetLamb
Copy link
Author

Is there any way in which I can view the generated source files, to figure out what's going wrong here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification.
Projects
None yet
Development

No branches or pull requests

2 participants