Make most of DynamicProxy's internals internal#505
Merged
jonorossi merged 4 commits intocastleproject:masterfrom Jun 8, 2020
Merged
Make most of DynamicProxy's internals internal#505jonorossi merged 4 commits intocastleproject:masterfrom
internal#505jonorossi merged 4 commits intocastleproject:masterfrom
Conversation
This consists mostly of making `public` types in the `Castle.Dynamic- Proxy` namespace `internal`, however there are a few special cases where types are left public but some or most of their members are made internal, for example: * exception types (client code should be able to catch them, but not instantiate them) * `TypeUtil` (proxies require some of its members at runtime) * `ModuleScope` (`SaveAssembly`, `LoadAssemblyIntoCache`, and related members should stay public for now, unlike others that give access to the internal `ModuleBuilder`)
* Windsor needs `TypeUtil.GetAllInterfaces`, so make it public again. * Windsor is currently relying on `DelegateProxyGenerator`, but there is now another, more public API to build delegate proxies (see PR castleproject#436) so that class can now be removed. The unit tests for it are rewritten in terms of the newer API to demonstrate that it is indeed a suitable replacement.
It is no longer feasible to list every single affected type or type member; there's simply too many. Give a coarse summary instead.
ad57a4c to
02a33b6
Compare
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've been talking about making internals truly
internal(see e.g. #389) so that we can more easily refactor in the future. This PR is my initial attempt at doing so for DynamicProxy.What this PR does not do is change type names or namespaces. The latter might make sense in some cases (e.g. moving
AttributesToAvoidReplicatinginto DynamicProxy's main namespaceCastle.DynamicProxy, or perhaps combining all exception types into a singleDynamicProxyExceptiontype). I would personally favor such changes, but they are left to future PRs.Compatiblity checks for downstream libraries
Windsor
Windsor will be able to update without any major changes. Those are the main required changes that I have identified:
Its single use of
DelegateProxyGeneratorwill have to be replaced withProxyGenerationOptions.AddDelegateTypeMixin. This is straightforward, as demonstrated in the unit tests in one of this PR's commits.(Unrelated to this PR, but since we're discussing Windsor:) It makes use of the
LockAPIs in approx. 15 places. The easiest solution would be to migrate theLockAPI over into Windsor from an older version of Castle.Core (but make it internal). The slightly more laborious solution would be to change allLockusages to useReaderWriterLockSlimdirectly. (This latter approach is definitely possible, but not as straightforward as it may seem because theLockAPI implements some kind of reentrancy on top of non-reentrantReaderWriterLockSliminstances.)(Unrelated to this PR:) Windsor targets some frameworks that we no longer support here (e.g.
net40), those will have to be dropped.FakeItEasy, Moq 4, and NSubstitute
The API removals do not cause any problems for these three libraries. (I've checked by compiling them against this PR's version of Castle.Core. The only problem is unrelated to this PR—some of these libraries will only be able to update after removing their
netstandard1.xtargets, which we stopped supporting in #495.)