-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/MemberAccessor' into develop
Major refactoring of the internal `OnTopic.Internal.Reflection` classes. Previously, these classes relied on the .NET Reflection libraries to dynamically create delegate signatures for properties and methods before getting or setting values. Now, the delegate signature is created by the new `MemberAccessor` class and cached as part of a `TypeAccessorCache`. This promises to improve performance. As part of this, I significantly refactored the organization and approach to the code. `TypeMemberInfoCollection` has been replaced by `TypeAccessorCache`, `MemberInfoCollection<T>` has been replaced by `TypeAccessor`, and `MemberDispatcher` has been replaced by `MemberAccessor`. This takes a more intuitive top-down approach, where as previously `MemberDispatcher` maintained its own `TypeMemberInfoCollection` cache which complicated the relationship between objects. I also improved the validation of accessors, thus helping prevent unnecessary conversions, or attempts to set members that can't be set (e.g., by setting `null` to a non-nullable property). In theory, this is supposed to have a major performance benefit—and, indeed, according to my initial testing directly against the new and old methods, it did. In real-world testing, however, we're not seeing that much benefit. That said, this also isn't any slower, and while it adds some complexity when calculating the delegate signatures, it's also much better organized. This resolves Issue #90.
- Loading branch information
Showing
19 changed files
with
2,132 additions
and
1,352 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*============================================================================================================================== | ||
| Author Ignia, LLC | ||
| Client Ignia, LLC | ||
| Project Topics Library | ||
\=============================================================================================================================*/ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using OnTopic.Data.Caching; | ||
using OnTopic.Internal.Reflection; | ||
using OnTopic.Lookup; | ||
using OnTopic.Mapping; | ||
using OnTopic.Repositories; | ||
using OnTopic.TestDoubles; | ||
using OnTopic.Tests.TestDoubles; | ||
using OnTopic.ViewModels; | ||
|
||
namespace OnTopic.Tests.Fixtures { | ||
|
||
/*============================================================================================================================ | ||
| CLASS: TYPE ACCESSOR FIXTURE | ||
\---------------------------------------------------------------------------------------------------------------------------*/ | ||
/// <summary> | ||
/// Introduces a shared context to use for unit tests depending on an <see cref="TypeAccessor"/>. | ||
/// </summary> | ||
public class TypeAccessorFixture<T> { | ||
|
||
/*========================================================================================================================== | ||
| CONSTRUCTOR | ||
\-------------------------------------------------------------------------------------------------------------------------*/ | ||
public TypeAccessorFixture() { | ||
|
||
/*------------------------------------------------------------------------------------------------------------------------ | ||
| Create type accessor | ||
\-----------------------------------------------------------------------------------------------------------------------*/ | ||
TypeAccessor = new TypeAccessor(typeof(T)); | ||
|
||
} | ||
|
||
/*========================================================================================================================== | ||
| TYPE ACCESSOR | ||
\-------------------------------------------------------------------------------------------------------------------------*/ | ||
/// <summary> | ||
/// A <see cref="TypeAccessor"/> for accessing <see cref="MemberAccessor"/> instances. | ||
/// </summary> | ||
internal TypeAccessor TypeAccessor { get; private set; } | ||
|
||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Oops, something went wrong.