Method name as matching custom attribute application - helps to work with attribute based frameworks (e.g. MSTest)

Topics: C# Language Design
Nov 14, 2014 at 12:39 PM
Edited Nov 14, 2014 at 12:40 PM
Right now I write next in MSTest:
        public void TestInitialize(){ ... }
Can we have next to have same effect
        public void [TestInitialize](){ ... }
The same for [ClassCleanup], [ClassInitialize],[TestCleanup].

Contradicts pattern that method name should be verb, but tests naming conventions are quite different of usual C# already.

NUnit has [TearDown] and [SetUp] which are verbs.

What else except tests?
Unity container supports next:
public void InjectionMethod(IMyService theService) 
Can write next instead:
public void [InjectionMethod](IMyService theService) 
May work for modularity (class name as matching attribute name):
namespace MyCompany.MyProduct.MyFeature {
public class [Module]:IConfigurable, IContentProvider{}
Do not have IModule interface, but have [ModuleAttribute] and some known interfaces implemented are checked after class load. Module is one for namespace.

What about attribute arguments?
public void [SetUp("foo")]()
Cannot make up more examples, seems like too narrow concern for language?
Nov 14, 2014 at 2:50 PM
A language feature of this complexity just to avoid typing a single token? Seems unlikely.