Open tarekgh opened 1 year ago
Tagging subscribers to this area: @dotnet/area-system-componentmodel-dataannotations See info in area-owners.md if you want to be subscribed.
Author: | tarekgh |
---|---|
Assignees: | - |
Labels: | `area-System.ComponentModel.DataAnnotations` |
Milestone: | - |
Tagging subscribers to this area: @dotnet/area-extensions-options See info in area-owners.md if you want to be subscribed.
Author: | tarekgh |
---|---|
Assignees: | tarekgh |
Labels: | `untriaged`, `area-Extensions-Options`, `source-generator` |
Milestone: | 9.0.0 |
In solving this we should look at all possible parameters that might appear in attribute usage to ensure we can synthesize source for them. I think it might make sense to look at Roslyn's CSharpSyntaxGenerator for some inspiration here - I think the place to look for reference implementation might be https://github.com/dotnet/roslyn/blob/1b7a6f807cb8ce709048debae6b771f4705a697a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs#L3393
@tarekgh co we need to address this in 9.0? I don't think we've heard feedback on it.
Options source generator is parsing the code validation attributes in the source and then emits generated code which instantiate the attribute with the same parameters and properties used in the source code. Currently the source generator support all basic parameter types including the array and params parameters. There are more complex scenarios which can include array of arrays like:
This issue is tracking to look at such complex scenarios and support it.
https://github.com/dotnet/runtime/pull/91934#discussion_r1323326105 https://sourceroslyn.io/#Microsoft.CodeAnalysis.CSharp.Workspaces/CodeGeneration/CSharpSyntaxGenerator.cs,838c28d0fc10cd04
CC @ericstj