What is the proper way to document a C# Attribute on a class in a UML class diagram?
-
@Artur: if you have a problem, take it to http://meta.stackoverflow.com/, and then add a comment here with the link to your question there. – John Saunders Jan 22 '11 at 04:41
-
@John Saunders: Phank you, I think it will be helpful for you too – Alan Turing Jan 22 '11 at 04:58
-
@John Sanders: Thanks, Stupid typos. – Jordan Jan 24 '11 at 18:34
2 Answers
I haven't decided if this is my answer, but I figured I'd throw it out there for sake of discussion. Does this look acceptable?
Its an instance of the attribute type with the metadata values put into tagged values below. I just figured out how to add custom stereo types. The arrow is just a dependency arrow that is labeled as "applies".

- 9,642
- 10
- 71
- 141
-
-
You know, I've got a personal hater here, so i think it will not do the trick ;) I think you saw this obvious things first, and this looks like a dependency, so even dependency injection mechanisms sometimes can use attributes, that means something, actually ;) – Alan Turing Jan 22 '11 at 04:15
-
I like your post. By the way, UML is desighend to be capable, at least, describe weak dependencies, for example, between C# classes and class attributes. – Alan Turing Jan 22 '11 at 04:54
-
@Artur: This is dependency injection actually. I'm using MEF. ExportViewMetadataAttribute extends ExportAttribute. – Jordan Jan 22 '11 at 04:55
I don't know if this is "standard", except that it uses a standard feature from UML:
Sparx Enterprise Architect, when reverse-engineering, for instance, a unit test class, uses tagged values for the attributes. A tagged value "Attribute
" on the class, has the name of the attribute as a value, for instance, "[TestClass]
". Similarly, "Attribute = [TestMethod]
" is placed on the methods. An example would be:
[TestClass]
public class MyTests
{
[TestMethod]
public void DoSomeTest()
{
}
}
In this example, [TestClass]
and [TestMethod]
are .NET attributes (not UML attributes). They are short for [TestClassAttribute]
and [TestMethodAttribute]
. Both are classes deriving from the System.Attribute
class.
An attribute simply adds metadata to the assembly. By itself, it has no runtime behavior.

- 160,644
- 26
- 247
- 397