Yeah caching my own model would be much easier, just worry a bit about the amount of duplication I will run into.
Oh well its not that difficult and will lead to better testability / ability to support other platforms anyways. Thanks JB. Greg On Mon, Dec 6, 2010 at 12:46 PM, Jb Evain <[email protected]> wrote: > On Mon, Dec 6, 2010 at 6:40 PM, Greg Young <[email protected]> > wrote: > > But you mentioned that the typereferences will still keep the module > alive > > (thus all typereferences will be kept alive). Or am I misunderstanding > you? > > I guess. You'd need to have something like this: > > static void CleanForCaching (TypeDefinition type) > { > Detach (type.BaseType); > > foreach (var iface in type.Interfaces) > Detach (iface); > > foreach (var field in type.Fields) > Detach (field.FieldType); > > foreach (var method in type.Methods) { > Detach (method.ReturnType); > > foreach (var parameter in method.Parameters) { > Detach (parameter.ParameterType); > } > } > > // ... > } > > static void Detach (TypeReference type) > { > if (type != null) > type.Module = null; > } > > But you have to be intrusive, for instance, you have to detach types > found in the IL body of methods, in custom attributes, and so forth > and so on. > > All in all, it ends up being a bit tedious. > > Caching an object model you control is probably easier. > > Jb > > -- > -- > mono-cecil -- Les erreurs de grammaire et de syntaxe ont été incluses pour m'assurer de votre attention -- -- mono-cecil
