Skip to content

Commit 84735fb

Browse files
committed
Remove attributePrefix from ItemConfiguration
With the `ItemConfiguration` moved to a `Configuration` property off of `ItemMetadata` (74cb817, 2f482b1), it's no longer receiving runtime data on the contextual configuration needed to populate the `attributePrefix`. In subsequent commits, we'll be updating the `TopicMappingService` and `ReverseTopicMappingService` to pass these internally. In the meanwhile, it can safely be removed from the `ItemConfiguration` since it's not being actively used, and the parent `ItemMetadata` class doesn't have access to it regardless. I also removed the `name` parameter since that can be pulled directly from `itemMetadata` parameter.
1 parent 2f482b1 commit 84735fb

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

OnTopic/Internal/Reflection/ItemMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool isList()
120120
internal ItemConfiguration Configuration {
121121
get {
122122
if (_itemConfiguration is null) {
123-
_itemConfiguration = new(this, Name, "");
123+
_itemConfiguration = new(this);
124124
}
125125
return _itemConfiguration;
126126
}

OnTopic/Mapping/Internal/ItemConfiguration.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ internal class ItemConfiguration {
4848
/// <param name="itemMetadata">
4949
/// The <see cref="ItemMetadata"/> instance associated with this <see cref="ItemConfiguration"/>.
5050
/// </param>
51-
/// <param name="name">The name of the <see cref="ParameterInfo"/> or <see cref="PropertyInfo"/>.</param>
52-
/// <param name="attributePrefix">The prefix to apply to the attributes.</param>
53-
internal ItemConfiguration(ItemMetadata itemMetadata, string name, string? attributePrefix = "") {
51+
internal ItemConfiguration(ItemMetadata itemMetadata) {
5452

5553
/*------------------------------------------------------------------------------------------------------------------------
5654
| Set backing properties
@@ -61,8 +59,8 @@ internal ItemConfiguration(ItemMetadata itemMetadata, string name, string? attri
6159
/*------------------------------------------------------------------------------------------------------------------------
6260
| Set default values
6361
\-----------------------------------------------------------------------------------------------------------------------*/
64-
AttributeKey = attributePrefix + name;
65-
AttributePrefix = attributePrefix;
62+
AttributeKey = itemMetadata.Name;
63+
AttributePrefix = "";
6664
DefaultValue = null;
6765
InheritValue = false;
6866
CollectionKey = AttributeKey;
@@ -79,9 +77,9 @@ internal ItemConfiguration(ItemMetadata itemMetadata, string name, string? attri
7977
GetAttributeValue<MapAsAttribute>( a => MapAs = a.Type);
8078
GetAttributeValue<DefaultValueAttribute>( a => DefaultValue = a.Value);
8179
GetAttributeValue<InheritAttribute>( a => InheritValue = true);
82-
GetAttributeValue<AttributeKeyAttribute>( a => AttributeKey = attributePrefix + a.Key);
80+
GetAttributeValue<AttributeKeyAttribute>( a => AttributeKey = a.Key);
8381
GetAttributeValue<MapToParentAttribute>( a => MapToParent = true);
84-
GetAttributeValue<MapToParentAttribute>( a => AttributePrefix += (a.AttributePrefix?? name));
82+
GetAttributeValue<MapToParentAttribute>( a => AttributePrefix += (a.AttributePrefix?? AttributeKey));
8583
GetAttributeValue<IncludeAttribute>( a => IncludeAssociations = a.Associations);
8684
GetAttributeValue<FlattenAttribute>( a => FlattenChildren = true);
8785
GetAttributeValue<MetadataAttribute>( a => MetadataKey = a.Key);

0 commit comments

Comments
 (0)