This seems like a silly question, but are there rules for where you can put Assembly specific attributes (which would be terrible if true)? For example if I try to put:
[assembly: RadAttribute]
in a class, it just laughs at me and pretends like it doesn't know what RadAttribute
is. I do notice that AssemblyInfo.cs
seems to contain some assembly specific attributes, so why is it that they can go in there, but nowhere else?
Assembly attributes are values that provide information about an assembly. The attributes are divided into the following sets of information: Assembly identity attributes. Informational attributes.
Apply attributes at the assembly levelWhen this attribute is applied, the string "My Assembly" is placed in the assembly manifest in the metadata portion of the file. You can view the attribute either by using the MSIL Disassembler (Ildasm.exe) or by creating a custom program to retrieve the attribute.
An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes.
Custom attribute cannot be applied to an assembly.
Assembly attributes like that must be before any namespace
or class
(or other type) declarations in the code file in question.
I'd usually put it outside of any class declarations, and indeed namespace declarations.
It could go anywhere (except within a class), and AssemblyInfo.cs has no special properties - but is simply a place used by convention to store assembly attributes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With