> > I just joined this list because I've been thinking about using Cecil > > in NUnit, to replace most of the Reflection that is done to discover > > tests. With .Net 2.0, load times became much greater, with most of it > > being spent in GetCustomAttributes, and I'm wondering if I should make > > this conversion more of a priority.
[...] > I'm not aware of any performance comparison between Cecil and > Reflection. A gust feeling would be that the time to load an assembly > is longer in Cecil, but then, for operations like discovering methods, > and reading custom attributes, it should be faster. Well, this should probably not be discussed here, but I just want to mention that if your performance problems are in GetCustomAttributes, there might also be an alternative in the System.Reflection namespace: the CustomAttributeData class should be somewhat faster because it doesn't instantiate the attribute instances. Instead, it only provides a view on the metadata, similar to what Cecil does, I suppose. On the other hand, for large assemblies, you might still be better off to do a first-pass analysis of the test assemblies with Cecil and use Reflection in a second pass only to instantiate and execute your test cases. > you would have to load the assembly > containing the tests anyway, and to have an helper, to get for > instance a S.R.MethodInfo from a M.C.MethodDefinition. Is there any experience with building such a helper? I suppose after loading the assembly, a simple Module.ResolveXXX (mdTokenSuppliedByCecil) should work to get a Type or MethodInfo for any given type or method token, right? Regards, Fabian --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~---
