Is it possible to add an attribute to a class using reflection?

Test.cs:

public class Test : ITest { public void TestMessage() { System.Console.WriteLine("Test message!"); } } 

ITest.cs:

 public interface ITest { void TestMessage(); } 

Expected Result:

 [SomeAttribute] public class Test : ITest { public void TestMessage() { System.Console.WriteLine("Test message!"); } } 
  • 3
    Here is an example from an English question - Grundy
  • 3
    But why this may be needed? - Grundy
  • Indeed, it is easier to create your own dictionary of attributes and add attributes to it. Well, or you incorrectly described the task, maybe you need PostSharp? - Andrei NOP
  • Yes, thank you all for your help. - Tibomso

0