Custom AssemblyInfo Attributes

To complement my previous post bemoaning the lack of respect for AssemblyInfo, I wanted to illustrate just how easy it is to add a few custom attributes to our AssemblyInfo file:


This is a companion discussion topic for the original blog entry at: http://www.codinghorror.com/blog/2004/11/custom-assemblyinfo-attributes.html

Yeah, you could also just strip the “System.Reflection.Assembly” from the beginning and “Attribute” from the end of the assembly type name. This way you wouldn’t need to add a case clause for every new costum attribute you add. It would result in cleaner code, but in a little less efficient method.

Yay, thanks for that. I wanted to have a ReleaseType Attribute :slight_smile:

If anyone needs that in C#, here you go:

[AttributeUsage(AttributeTargets.Assembly)]
public class AssemblyReleaseTypeAttribute : System.Attribute
{
private string _strReleaseType;

public AssemblyReleaseTypeAttribute(string ReleaseType)
{
	_strReleaseType = ReleaseType;
}

public virtual string ReleaseType {
	get {
		return _strReleaseType;
	}
}

}

Thanks. This was just what I was looking for.

How do you call the GetAssemblyAttribs function? I can’t find a valid value for the parameter.

System.Reflection.Assembly.GetCallingAssembly
System.Reflection.Assembly.GetEntryAssembly

Great article…

How can I make the custom attribute appear in the Version tab, when I look at the dll’s properties in Windows Explorer?

Csabi,

in C# i have created 2 classess and i am able to compile them sucessfully, but the problem is I can not see them in properties tab.

Can anyone help?

TIA