What does it mean to decorate a class or parameter?

Decorator was one of the original 23 patterns described in the Gang of Four "Design Patterns" book. They describe it well here.

Summary:

Decorator : Add additional functionality to a class at runtime where subclassing would result in an exponential rise of new classes

Patterns are language agnostic. They are descriptions of solutions to common problems in object-oriented programming. It's possible, even preferred, to discuss them without reference to a particular language. The examples in the original book were written in C++ and Smalltalk. Neither Java nor C# existed when the book was first published in 1995.


When You add decorator in C# it is like adding a property to the class/method. There will be an attribute attached to it.

If You write Unit test You will meet a simple decorator TestMethod like that:

[TestMethod]
public void TestMethod1()
{
}

The framework will use the decorators to check what test methods are in the test set.

You can check on the attribute here

There is another nice to read article about Writing Custom Attributes

Decorators are not limited to the '[ ]' form of decorators. There is also a design pattern for that, that was already mentioned before by others.