That's a limitation in the assembly format. There's a few things that you can't know without resolving the type. This is one of them.
Cecil, or any metadata reader, needs to know the size to read and write the constant. One could try to guess, but as any guesses, they could be wrong. Jb On Wed, Dec 4, 2013 at 1:26 PM, Sam S <[email protected]> wrote: > Hi Jb, > > Thanks for your quick response. > > I appreciate that to know the size of the enum it would be necessary to > resolve the underlying type. However, it is counter-intuitive that Cecil > needs to know the size of the enum in order to reconstruct the original > assembly that is unaware of this same size. It seems that it should be > possible to reconstruct the original from all the info that comes from this > assembly without any additional (size) information. > > Is this a limitation in the design of Cecil or am I missing something? > > Cheers, > Sam > > > On Wednesday, 4 December 2013 11:01:24 UTC, Jb Evain wrote: >> >> Hey Sam, >> >> Sadly that's one of the scenarios where Cecil needs to resolve the >> underlying type of the enum to know which size it is. >> >> Jb >> >> On Wed, Dec 4, 2013 at 11:32 AM, Sam S <[email protected]> wrote: >> > I am using the latest version of Cecil from Github and have run into the >> > following issue. >> > >> > I have an assembly for which AssemblyDefinition.ReadAssembly immediately >> > followed by a Write fails as it cannot resolve another assembly. >> > Specifically, it cannot resolve the assembly which defines the enum X, >> > which >> > the assembly I am processing uses in a field (private const X x = X.Y;). >> > >> > I would have thought that it is unnecessary to resolve the other >> > assembly as >> > all information required to write the original assembly to file is per >> > definition in the original assembly. >> > >> > Would it be possible for Cecil to support this scenario? >> > >> > Cheers, >> > Sam >> > >> > -- >> > -- >> > -- >> > mono-cecil >> > --- >> > You received this message because you are subscribed to the Google >> > Groups >> > "mono-cecil" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an >> > email to [email protected]. >> > For more options, visit https://groups.google.com/groups/opt_out. > > -- > -- > -- > mono-cecil > --- > You received this message because you are subscribed to the Google Groups > "mono-cecil" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. -- -- -- mono-cecil --- You received this message because you are subscribed to the Google Groups "mono-cecil" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
