Skip to content

Complex validation attribute constructor support in the Options validator source generator #91966

Open
@tarekgh

Description

@tarekgh

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:

using System;
public class MyValidationAttribute : Attribute {
    public MyValidationAttribute(params object[] values) { }
}

[MyValidationAttribute(new object[] { new object [] { new object[] { new int[] {1, 2, 3}}}})]
public class MyType
{
}

This issue is tracking to look at such complex scenarios and support it.

#91934 (comment)
https://sourceroslyn.io/#Microsoft.CodeAnalysis.CSharp.Workspaces/CodeGeneration/CSharpSyntaxGenerator.cs,838c28d0fc10cd04

CC @ericstj

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions