This project is read-only.

Non-mutable SourceMethodBody

Jan 12, 2011 at 7:13 AM

Is it much work to make a ISourceMethodBody that doesn't depend on MutableCodeModel?

It's not a big problem but I was trying to eliminate a MutableCodeModel dependency and SourceMethodBody is the only mutable implementation that I'm forced to use.

I attempted to factor out as much code as I could but it looks like the normalizer is built entirely on the mutable code model. Does it actually need a mutable implementation?


Jan 12, 2011 at 7:23 AM

Constructing an immutable code model is surprsingly tricky because of the various kinds of back pointers, but you can do it. You'll need to write a lot of classes and probably need to budget a week or so.

However, I don't think you need to be quite so concerned about using the mtuable code model. As long as you only use the mutable classes during construction, the objects are perfectly safe. If you want to give the constructed code model to code that you do not trust (your own code included :-), then make sure that the untrusted code is in a separate assembly and that that assembly does not have a reference to the assembly defining the mutable code model.