Skip to content

Commit 863b618

Browse files
committed
Introduced new ConstructorParameters property to TypeAccessor
With the new `ParameterMetadata` class established (37eeb3c), we can now expose a collection of `ParameterMetadata` instances on `TypeClass` to represent the list of parameters on the primary (currently first) constructor. This way, this information is now cached, which will ultimately allow us to only call `GetPrimaryConstructor()` once per class, instead of every time an instance of that class is evaluated. In a subsequent commit, this will be incorporated into the `TopicMappingService`.
1 parent 37eeb3c commit 863b618

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

OnTopic/Internal/Reflection/TypeAccessor.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ internal TypeAccessor(Type type) {
8383
}
8484
}
8585

86+
/*------------------------------------------------------------------------------------------------------------------------
87+
| Get parameters from primary constructor
88+
\-----------------------------------------------------------------------------------------------------------------------*/
89+
foreach (var parameter in GetPrimaryConstructor().GetParameters()) {
90+
ConstructorParameters.Add(new(parameter));
91+
}
92+
8693
}
8794

8895
/*==========================================================================================================================
@@ -93,6 +100,15 @@ internal TypeAccessor(Type type) {
93100
/// </summary>
94101
internal Type Type { get; }
95102

103+
/*==========================================================================================================================
104+
| CONSTRUCTOR PARAMETERS
105+
\-------------------------------------------------------------------------------------------------------------------------*/
106+
/// <summary>
107+
/// Gets a list of <see cref="ParameterMetadata"/> instances derived from the primary constructor of the <see cref="Type"
108+
/// /> associated with this <see cref="TypeAccessor"/>.
109+
/// </summary>
110+
internal List<ParameterMetadata> ConstructorParameters { get; } = new();
111+
96112
/*==========================================================================================================================
97113
| GET MEMBERS
98114
\-------------------------------------------------------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)