Updates codebase to support Medium/Partial trust #149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We had read somewhere that PetaPoco was supposed to support partial trust but unfortunately this is not the case. The problem is in only one part of the code in the CreateMultiPocoFactory method. This method creates a DynamicMethod that is not medium trust compatible. There are only 2 overloads that work for creating a DynamicMethod in medium trust and those are the overloads that don't set an 'owner' for the method. By not setting an owner, the method is essentially a static anonymously hosted method. It turns out that this DynamicMethod in particular is actually not required and therefore the IL Emit code is not required either. I did have it working with IL Emit codes in medium trust before I realized this so I still have that code saved but it is much nicer (and probably better performance wise) to not have to use IL Emit.
An overview of the changes made: