-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-validationIssues related to model validation in minimal and controller-based APIsIssues related to model validation in minimal and controller-based APIs
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When the input of an API is a generic type, such as Dictionary<string,string>, the build fails with errors in the generated code.
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(80,24): error CS0106: The modifier 'new' is not valid for this item
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(80,24): error CS1520: Method must have a return type
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(83,25): error CS0106: The modifier 'new' is not valid for this item
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(83,25): error CS1520: Method must have a return type
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(99,210): error CS0246: The type or namespace name 'ValidationOptions' could not be found (are you missing a using directive or an assembly reference?)
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(98,10): error CS9206: An interceptor cannot be declared in the global namespace.
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(81,17): error CS0246: The type or namespace name 'type' could not be found (are you missing a using directive or an assembly reference?)
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(82,17): error CS0246: The type or namespace name 'members' could not be found (are you missing a using directive or an assembly reference?)
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(84,25): error CS0246: The type or namespace name 'containingType' could not be found (are you missing a using directive or an assembly reference?)
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(85,25): error CS0246: The type or namespace name 'propertyType' could not be found (are you missing a using directive or an assembly reference?)
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(86,25): error CS0246: The type or namespace name 'name' could not be found (are you missing a using directive or an assembly reference?)
/workspaces/dotnet10-issue-repros/validation-generic-types/obj/Debug/net10.0/Microsoft.AspNetCore.Http.ValidationsGenerator/Microsoft.AspNetCore.Http.ValidationsGenerator.ValidationsGenerator/ValidatableInfoResolver.g.cs(87,25): error CS0246: The type or namespace name 'displayName' could not be found (are you missing a using directive or an assembly reference?)
The problem may come from the name mangling done for generic types, e.g. this line in the generated file ValidatableInfoResolver.g.cs:
private ValidatableTypeInfo CreateDictionary`2()Expected Behavior
Turning on validation should not cause build failures.
Steps To Reproduce
The "validation-generic-types" project in this repo is a minimal repro of the problem:
https://github.com/mikekistler/dotnet10-issue-repros
The .http file contains a request that will trigger the error.
If you comment out the AddValidations() call Program.cs, the project builds and works correctly.
Exceptions (if any)
No response
.NET Version
10.0.100-preview.3.25201.16
Anything else?
No response
timdeschryver and sbomer
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-validationIssues related to model validation in minimal and controller-based APIsIssues related to model validation in minimal and controller-based APIs