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

When using CascadingTypeParameter the global:: is not added to __syntheticArg0 parameter #7103

Closed
1 task done
xiety opened this issue Jul 13, 2022 · 3 comments · Fixed by #8247
Closed
1 task done
Assignees
Labels
area-blazor area-compiler Umbrella for all compiler issues bug Something isn't working

Comments

@xiety
Copy link

xiety commented Jul 13, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Problem looks like the closed dotnet/aspnetcore#37482 and dotnet/aspnetcore#18757, but dotnet/razor-compiler#34 doesn't fix it in the latest 7.0.100-preview.6.22352.1

Generated code lacks global:: on __syntheticArg0

namespace __Blazor.BlazorBug.App
...
public static void CreateChildComponent_1<T>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, BlazorBug.GenericClass<T> __syntheticArg0)
...

Produces compilation error:

Error	CS0234	The type or namespace name 'GenericClass<>' does not exist in the namespace '__Blazor.BlazorBug' (are you missing an assembly reference?)

Expected Behavior

Code is generated with global:: on __syntheticArg0

namespace __Blazor.BlazorBug.App
...
public static void CreateChildComponent_1<T>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, global::BlazorBug.GenericClass<T> __syntheticArg0)
...

Steps To Reproduce

Project named BlazorBug

App.razror

<ParentComponent Parameter="new GenericClass<string>()">
    <ChildComponent />
</ParentComponent>

ParentComponent.razor

@typeparam T
@attribute [CascadingTypeParameter(nameof(T))]

@code
{
    [Parameter]
    public GenericClass<T> Parameter { get; set; } = default!;
}

ChildComponent.razor

@typeparam T

GenericClass.cs

namespace BlazorBug;

public class GenericClass<T>
{
}

Exceptions (if any)

No response

.NET Version

7.0.100-preview.6.22352.1

Anything else?

The workaround is to explicitly provide the types or move the GenericClass to a different namespace.

@javiercn
Copy link
Member

@xiety thanks for contacting us.

could you try this in preview7? You can use the nightly build from the dotnet/installer repo to build it from the command line.

@ghost
Copy link

ghost commented Jul 13, 2022

Hi @xiety. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@xiety
Copy link
Author

xiety commented Jul 13, 2022

Same bug with latest daily 7.0.100-rc.1.22363.3

@javiercn javiercn transferred this issue from dotnet/aspnetcore Jul 13, 2022
@chsienki chsienki added the area-compiler Umbrella for all compiler issues label Oct 28, 2022
@chsienki chsienki transferred this issue from dotnet/razor-compiler Oct 28, 2022
@ghost ghost added the untriaged label Oct 28, 2022
@ghost ghost added the untriaged label Feb 22, 2023
@ghost ghost removed the untriaged label May 1, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor area-compiler Umbrella for all compiler issues bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants