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

Error when using collection-expression for an array-typed attribute argument. #69133

Closed
CyrusNajmabadi opened this issue Jul 20, 2023 · 1 comment · Fixed by #69968
Closed
Assignees
Milestone

Comments

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Jul 20, 2023

    [X([1, 2, 3])]
    class C
    {
    }

    public class XAttribute : System.Attribute
    {
        public XAttribute(int[] values) { }
    }

Error: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

This is expected to work, just like with a normal argument. An attribute argument should support target-typing. After all, you can pass null to the argument, and that is totally fine.

Relates to test plan #66418

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 20, 2023
@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jul 20, 2023
@jcouv jcouv added this to the 17.8 milestone Jul 20, 2023
@jcouv jcouv added the Bug label Jul 20, 2023
@jaredpar jaredpar assigned jcouv and cston and unassigned cston Aug 31, 2023
@jcouv jcouv added the 4 - In Review A fix for the issue is submitted for review. label Sep 17, 2023
@RikkiGibson
Copy link
Contributor

Associated PR was merged so closing this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants