Updates codebase to support Medium/Partial trust#149
Open
Shazwazza wants to merge 1 commit into
Open
Conversation
- changes some 'object' references to 'Delegate' (easier to understand) - changes MultiPocoFactory class to perform the operation of calling the callback and calling each mapper delegate - changes CreateMultiPocoFactory, this is the problem with medium trust... you cannot declare a DynamicMethod with an 'owner' in medium trust. Also, there there is no need for any of the IL.Emit logic in this method and therefore no need for the DynamicMethod at all in this method. It has been changed so that the MultiPocoFactory class does the heavy lifting. Without a DynamicMethod or IL Emit, this should work a teeny bit faster and is much easier to debug. Before I realized that the IL Emit was not necessary, i did make it work in medium trust with IL Emit so have saved that code locally in case its required.
Member
|
Hi There. Thanks for the contribution. You're targeting v4. We're about to make v5 the standard, and as such, we not going to process this PR. |
Author
|
The thing about this change though is that in theory it is a performance optimization. This change essentially means there is less code generation required because the actual change means that a statically declared method is used instead of the same method being generated each time. We've been using this change in Umbraco core for years now. I've not actually run the benchmarks on this change as compared to the original code, so I'm not sure how much perf optimization there is but there's definitely less codegen going on. |
Member
|
I've reopened the PR. Thanks for the explanation. |
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: