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

Generator fails with partial classes #9

Closed
powerdude opened this issue Dec 2, 2024 · 4 comments
Closed

Generator fails with partial classes #9

powerdude opened this issue Dec 2, 2024 · 4 comments

Comments

@powerdude
Copy link

Hi,

If your code has something like the following:

partial class MyPage
{
}

public partial class MyPage : ContentPage 
{
}

The following warning is generated:

2>CSC : warning CS8785: Generator 'RouteGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'An item with the same key has already been added.'.

This should probably be an error though since no file is actually generated.

@ewerspej
Copy link
Owner

ewerspej commented Dec 3, 2024

Hi @powerdude ,

thanks for reporting this.

CS8785 is not issued by the Route Generator, it's a warning from the Roslyn compiler platform. The Route Generator seems to throw an unhandled exception due to a duplicate key.

I'll look into this.

Cheers

@ewerspej
Copy link
Owner

ewerspej commented Dec 3, 2024

@ewerspej ewerspej closed this as completed Dec 3, 2024
@powerdude
Copy link
Author

Sorry, one more thing was discovered once this issue was fixed. Errors are generated for the following.

internal abstract class BaseContentPage<T> : ContentPage where T : BaseViewModel
{
    protected BaseContentPage(T viewModel, string pageTitle)
    {
        base.BindingContext = viewModel;

        Title = pageTitle;
    }

    protected new T BindingContext => (T)base.BindingContext;
}

I can work work around it temporarily by renaming the class.

@ewerspej
Copy link
Owner

ewerspej commented Dec 5, 2024

I opened a separate issue for this: #10.

Repository owner locked and limited conversation to collaborators Dec 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants