Skip to content

Commit 83d5c3d

Browse files
committed
Restrict topic reference lookups to classes
Currently, any call to `GetValue()` that doesn't match the other conditions—i.e., isn't a compatible or convertible property, isn't a list, and isn't `[MapToParent]`—is evaluated to determine if it's a topic reference. In practice, most properties that aren't topic references will have fallen into one of the other conditions. Nevertheless, as the lookups required for topic references are a bit expensive, we can further optimize this by specifying that the property type must be a class (i.e., not an interface and not a value object). That's consistent with what we expect topic references to be mapped to. In practice, this will typically relate to potential properties that are non-compatible value properties. These are likely rare scenarios as they won't get mapped, and should probably be decorated with `[DisableMapping]`. Still, it's a fast check for refining the condition.
1 parent 0539c8d commit 83d5c3d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

OnTopic/Mapping/TopicMappingService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ await MapAsync(
541541
else if (configuration.Metadata.IsList) {
542542
return null;
543543
}
544-
else if (associations.HasFlag(AssociationTypes.References)) {
544+
else if (configuration.Metadata.Type.IsClass && associations.HasFlag(AssociationTypes.References)) {
545545
var topicReference = getTopicReference();
546546
if (topicReference is not null) {
547547
value = await GetTopicReferenceAsync(topicReference, targetType, configuration, cache).ConfigureAwait(false);

0 commit comments

Comments
 (0)