Additional custom attributes 'constraints'

Topics: C# Language Design, General
Apr 5, 2014 at 11:58 AM
How flexible are you when it comes to extending language/framework features around custom attributes? Is it something that is open-source and open to potential contributions as well?

I would be interested to see more custom attribute constraints available. For example it would be nice to be able to define a custom attribute that will only be allowed to be set on public getter string properties of a public instance class type that implements a specific interface (this is a very extreme example). When a constraint is violated a compiler error is given. A the moment it is only possible to get some basic constraints via AttributeUsageAttribute.

I have a run-time validation implementation which could obviously be converted into a Roslyn-package in future. However I believe that it could become a part of .NET Framework and benefit third-party framework builders.

What are the options?

Thank you.