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 editor compiles generic type constraints but throws errors #8839

Closed
cetinbas opened this issue Jun 17, 2023 · 1 comment
Closed

Razor editor compiles generic type constraints but throws errors #8839

cetinbas opened this issue Jun 17, 2023 · 1 comment
Assignees
Labels
area-compiler Umbrella for all compiler issues
Milestone

Comments

@cetinbas
Copy link

cetinbas commented Jun 17, 2023

In a razor component, I can compile the following successfully, but the razor compiler generates superfluous errors:

@typeparam T where T : SomeBaseClass, new()

using a partial code-behind class doesn't work.

errors are
(1) : RZ1017 Unexpected literal following the 'typeparam' directive. Expected 'line break'.
(As many as T is used) : CS0246 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)

T is set explicitly where the component is used.

.NET7, Visual Studio: 17.6.3, up-to-date as of 17th of June, 2023.

added git repo for reproducing:
https://github.com/cetinbas/GenericTypeConstraintError

As a workaround, I deleted the constraints from razor file but kept them in the code-behind. This way it throws no errors.

@ghost ghost added the untriaged label Jun 17, 2023
@davidwengier davidwengier added the area-compiler Umbrella for all compiler issues label Jun 17, 2023
@chsienki chsienki self-assigned this Jul 3, 2023
@chsienki chsienki added this to the 17.8 Planning milestone Jul 3, 2023
@ghost ghost removed the untriaged label Jul 3, 2023
@chsienki
Copy link
Member

chsienki commented Jul 3, 2023

Duplicate of #8572

@chsienki chsienki marked this as a duplicate of #8572 Jul 3, 2023
@chsienki chsienki closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 2, 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
Projects
None yet
Development

No branches or pull requests

3 participants