Proposal: Allow tuples as attribute parameters #1979
Replies: 6 comments
-
This limitation is set by the CLR which would need support for reading the attribute parameters at runtime in order to instantiate the attribute. |
Beta Was this translation helpful? Give feedback.
-
I'd like this to be relaxed for any type constructor, [SomeAttribute(Foo(5))] We can already serialize types (for typeof), so I think this shouldn't be impossible to do without clr changes? |
Beta Was this translation helpful? Give feedback.
-
That's done by serializing the type's FQDN in its place and looking it up/injecting it at runtime. |
Beta Was this translation helpful? Give feedback.
-
This could be essentially the same issue as const ValueTuple and Unmanaged Constants. |
Beta Was this translation helpful? Give feedback.
-
That's why I think it's not a clr concern. Only the reflection API needs to be updated to recognize the new format? |
Beta Was this translation helpful? Give feedback.
-
That's possible. To me the line between CLR and BCL has always been a little fuzzy when it comes to mscorlib. Either way it requires a modification outside of the C# language to be supported. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently attributes may only use a small set of types as their parameters.
As tuples are deterministic in their layout, as long as they consist of types that can be used as attribute parameters (primitives, strings, arrays of the former), they themselves should also be usable as such (including arrays of tuples).
Beta Was this translation helpful? Give feedback.
All reactions