|
|
|
Community Member
|
|
Hello,
is it possible to remove entry from AssemblyInfo.cs using PostSharp.Core?
Problem: I have entry like this: [assembly: MyApplication(MyAttributeType = typeof(MyAttribute))]
I need to remove it at runtime.
If it is possible, then how?
|
|
|
|
|
Gael Fraiteur
SharpCrafters
|
|
This is possible by developing a custom task. The collection of these custom attributes is in this.Project.Module.AssemblyManifest.CustomAttributes. Find your and remove it.
You may want to look at sample PostSharp.Samples.Trace to see how to work with PostSharp Core. What you want to do is very easy.
|
|
|
|
|
Community Member
|
|
Thank you. Sorry, that was silly to ask. Here is code if anybody will need that
LinkedList<CustomAttributeDeclaration> customAttributesToRemove = new LinkedList<CustomAttributeDeclaration>(); foreach (CustomAttributeDeclaration customAttribute in this.Project.Module.AssemblyManifest.CustomAttributes) { if ((customAttribute.Constructor.DeclaringType is TypeRefDeclaration) && (customAttribute.Constructor.DeclaringType as PostSharp.CodeModel.TypeRefDeclaration).Name.Equals("MyApplicationAttribute")) customAttributesToRemove.AddLast(customAttribute); } foreach (CustomAttributeDeclaration customAttribute in customAttributesToRemove) this.Project.Module.AssemblyManifest.CustomAttributes.Remove(customAttribute);
|
|
|
|