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

Cannot pass constant string array into VerbAttribute #864

Closed
rombethor opened this issue Dec 12, 2022 · 2 comments
Closed

Cannot pass constant string array into VerbAttribute #864

rombethor opened this issue Dec 12, 2022 · 2 comments

Comments

@rombethor
Copy link

The VerbAttribute constructor has the option to pass in string[] aliases, however attribute constructors should accept constants when used as attributes and, last I checked, arrays can't be constants.

I suggest using a params keyword.

@elgonzo
Copy link

elgonzo commented Dec 13, 2022

Wrong, you can use single-dimension string arrays as attribute parameter types/values.

See the specification for allowed attribute parameter types here https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/attributes#2124-attribute-parameter-types

The types of positional and named parameters for an attribute class are limited to the attribute parameter types, which are:

  • One of the following types: bool, byte, char, double, float, int, long, sbyte, short, string, uint, ulong, ushort.
  • The type object.
  • The type System.Type.
  • Enum types.
  • Single-dimensional arrays of the above types.
  • A constructor argument or public field that does not have one of these types, shall not be used as a positional or named parameter in an attribute specification.

Please also close this issue. (Aside from the repro/project maintainers, you as the issue creator have the ability to close it.)

@rombethor
Copy link
Author

I stand corrected. However, I will advocate a params keyword just because it's neater.

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

No branches or pull requests

2 participants