[Mono-list] Possible simple Mono Cecil question

Gluber bernhardglueck at bluelogic.at
Sun Mar 11 19:10:27 EDT 2007


Hi !

I am developing a tool that reads the AssemblyVersionAttribute of an
assembly, changes its instantiation parameters and saves out the resulting
assembly again.
This is for a tool in our build process that tags all built assemblies with
the correct revision number based on a script file and for example the svn
revision. ( really simple stuff ) 
What i did now is the following:

AssemblyDefinition myLibrary = AssemblyFactory.GetAssembly(filename);

            if ( myLibrary != null )
            {
                foreach (ModuleDefinition m in myLibrary.Modules)
                {
                    Console.Out.WriteLine( "Module found: {0}", m.Name );

                    foreach ( CustomAttribute a in m.CustomAttributes )
                    {
                        TypeReference attributeType =
a.Constructor.DeclaringType;
                        Console.Out.WriteLine( "Found custom assembly
attribute: {0}", attributeType.FullName );

                        if ( attributeType.FullName.Equals( typeof (
AssemblyVersionAttribute ).FullName ) ||
                             attributeType.FullName.Equals( typeof (
AssemblyFileVersionAttribute ).FullName ) )
                        {
                            a.ConstructorParameters.Clear();

                       
                            a.ConstructorParameters.Add( 1 );
                            a.ConstructorParameters.Add( 0 );
                            a.ConstructorParameters.Add( 100 );
                            a.ConstructorParameters.Add( 1 );
                        }
                    }
                }

                AssemblyFactory.SaveAssembly( myLibrary, filename );
            }

The problem is that i get all the applied assembly attributes this way,
except the assemblyversion attribute ! ( I tested this on a number of
assemblies all having one applied , which was verified with reflector and
ildasm ) 

Am i doing something fundamentally wrong ? 
Also is this above the correct way to change the instantiation parameters
when the attribute was found ?
-- 
View this message in context: http://www.nabble.com/Possible-simple-Mono-Cecil-question-tf3386312.html#a9426051
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list