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

Razor Compiler created generic class constrains in wrong order and this result in CS0449 #7935

Closed
1 task done
wolfgangschneider opened this issue Nov 18, 2022 · 0 comments · Fixed by #7965
Closed
1 task done
Labels
area-compiler Umbrella for all compiler issues untriaged
Milestone

Comments

@wolfgangschneider
Copy link

wolfgangschneider commented Nov 18, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Razor Compiler created generic class constrains in wrong order
internal static class TypeInference
{
public static void CreateEBQuickGrid_0(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::System.Object __arg0, int __seq1, global::System.Object __arg1, int __seq2, global::System.Linq.IQueryable __arg2, int __seq3, global::System.Func<TGridItem, global::System.Object> __arg3, int __seq4, global::Microsoft.AspNetCore.Components.EventCallback __arg4, int __seq5, TGridItem __arg5, int __seq6, global::Microsoft.AspNetCore.Components.RenderFragment __arg6, int __seq7, System.Action<global::EBBetreuungWeb.Client.Components.EBQuickGrid> __arg7)
where TGridItem : global::EBBetreuungWeb.Models.Data.IGetKey, class

Expected Behavior

where TGridItem : global::class,EBBetreuungWeb.Models.Data.IGetKey should work

Steps To Reproduce

  1. Base razor component
    '''
[CascadingTypeParameter(nameof(TGridItem))]
public partial class QuickGrid<TGridItem> : IAsyncDisposable
{
.......
}
  1. inheritance a new generic class from it and add 2 constrains (class and Interface)
    2.a) cs
[CascadingTypeParameter(nameof(TGridItem))]
public partial class EBQuickGrid<TGridItem> : QuickGrid<TGridItem> where  TGridItem: class , IGetKey 
{
...
}

2.b razor

@using Microsoft.AspNetCore.Components.QuickGrid
@using Microsoft.AspNetCore.Components.Rendering

@typeparam TGridItem
@inherits QuickGrid<TGridItem>

razor compiler generate

  internal static class TypeInference
    {
        public static void CreateEBQuickGrid_0<TGridItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::System.Object __arg0, int __seq1, global::System.Object __arg1, int __seq2, global::System.Linq.IQueryable<TGridItem> __arg2, int __seq3, global::System.Func<TGridItem, global::System.Object> __arg3, int __seq4, global::Microsoft.AspNetCore.Components.EventCallback __arg4, int __seq5, TGridItem __arg5, int __seq6, global::Microsoft.AspNetCore.Components.RenderFragment __arg6, int __seq7, System.Action<global::EBBetreuungWeb.Client.Components.EBQuickGrid<TGridItem>> __arg7)
            where TGridItem : global::EBBetreuungWeb.Models.Data.IGetKey, class
        {
   

Exceptions (if any)

Severity Code Description Project File Line Suppression State
Error CS0449 The 'class', 'struct', 'unmanaged', 'notnull', and 'default' constraints cannot be combined or duplicated, and must be specified first in the constraints list.

.NET Version

7.0.100

Anything else?

No response

@javiercn javiercn transferred this issue from dotnet/aspnetcore Nov 18, 2022
@ghost ghost added the untriaged label Nov 18, 2022
@DustinCampbell DustinCampbell added the area-compiler Umbrella for all compiler issues label Nov 18, 2022
@wolfgangschneider wolfgangschneider changed the title Razor Compiler created generic class constrains in wrong error and this result in CS0449 Razor Compiler created generic class constrains in wrong order and this result in CS0449 Nov 21, 2022
@chsienki chsienki removed the untriaged label Dec 1, 2022
@chsienki chsienki added this to the 17.5 P2 milestone Dec 1, 2022
@ghost ghost added the untriaged label Dec 20, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-compiler Umbrella for all compiler issues untriaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants