Skip to content

Commit 7c150d8

Browse files
committed
Renamed [Follow()] to [Include()]
The `[Follow()]` attribute name isn't bad, but it's potentially misleading in that it isn't a recusive instruction. For this reason, it's being renamed to `[Include()]`. Not only does this better communicate that this exclusively impacts the models in the associated property, but not their associations, but it is also more consistent with the Entity Framework's nomenclature for navigation properties—which are effectively synonymous with OnTopic's associations. While we're not generally striving to maintain feature or identifier parity with Entity Framework, it's useful to leverage familiar terminology when the concepts cleanly map, as is the case here.
1 parent 78600fd commit 7c150d8

12 files changed

Lines changed: 29 additions & 31 deletions

OnTopic.Tests/ViewModels/AscendentTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace OnTopic.Tests.ViewModels {
2424
/// </remarks>
2525
public class AscendentTopicViewModel: KeyOnlyTopicViewModel {
2626

27-
[Follow(AssociationTypes.Parents)]
27+
[Include(AssociationTypes.Parents)]
2828
public AscendentTopicViewModel? Parent { get; set; }
2929

3030
} //Class

OnTopic.Tests/ViewModels/CircularTopicViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace OnTopic.Tests.ViewModels {
1919
/// </remarks>
2020
public class CircularTopicViewModel {
2121

22-
[Follow(AssociationTypes.Parents)]
22+
[Include(AssociationTypes.Parents)]
2323
public CircularTopicViewModel? Parent { get; set; }
2424

25-
[Follow(AssociationTypes.Children | AssociationTypes.Parents)]
25+
[Include(AssociationTypes.Children | AssociationTypes.Parents)]
2626
public Collection<CircularTopicViewModel> Children { get; } = new();
2727

2828
} //Class

OnTopic.Tests/ViewModels/DescendentTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace OnTopic.Tests.ViewModels {
2626
/// </remarks>
2727
public record DescendentTopicViewModel: TopicViewModel {
2828

29-
[Follow(AssociationTypes.Children)]
29+
[Include(AssociationTypes.Children)]
3030
public TopicViewModelCollection<DescendentTopicViewModel> Children { get; } = new();
3131

3232
} //Class

OnTopic.Tests/ViewModels/Metadata/ContentTypeDescriptorTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ContentTypeDescriptorTopicViewModel {
2323
public Collection<AttributeDescriptorTopicViewModel> AttributeDescriptors { get; } = new();
2424

2525
[Collection(CollectionType.MappedCollection)]
26-
[Follow(AssociationTypes.None)]
26+
[Include(AssociationTypes.None)]
2727
public Collection<ContentTypeDescriptorTopicViewModel> PermittedContentTypes { get; } = new();
2828

2929
} //Class

OnTopic.Tests/ViewModels/RelationTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace OnTopic.Tests.ViewModels {
2525
/// </remarks>
2626
public class RelationTopicViewModel: KeyOnlyTopicViewModel {
2727

28-
[Follow(AssociationTypes.Children)]
28+
[Include(AssociationTypes.Children)]
2929
public Collection<RelationTopicViewModel> Cousins { get; } = new();
3030

3131
} //Class

OnTopic.Tests/ViewModels/RelationWithChildrenTopicViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace OnTopic.Tests.ViewModels {
2525
/// </remarks>
2626
public class RelationWithChildrenTopicViewModel: RelationTopicViewModel {
2727

28-
[Follow(AssociationTypes.Relationships)]
28+
[Include(AssociationTypes.Relationships)]
2929
public Collection<RelationWithChildrenTopicViewModel> Children { get; } = new();
3030

3131
} //Class

OnTopic.ViewModels/TopicViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ public record TopicViewModel: ITopicViewModel {
8686
/// </summary>
8787
/// <remarks>
8888
/// If the current <see cref="TopicViewModel"/> is being mapped as part of another <see cref="TopicViewModel"/>, then the
89-
/// <see cref="Parent"/> property will only be mapped if that association includes a <see cref="FollowAttribute"/> with a
89+
/// <see cref="Parent"/> property will only be mapped if that association includes a <see cref="IncludeAttribute"/> with a
9090
/// value including <see cref="AssociationTypes.Parents"/>. If it does, all <see cref="Parent"/> topics will be mapped up
9191
/// to the root of the site. No other associations on the <see cref="Parent"/> view models will be mapped, even if they
92-
/// are annotated with a <see cref="FollowAttribute"/>.
92+
/// are annotated with a <see cref="IncludeAttribute"/>.
9393
/// </remarks>
94-
[Follow(AssociationTypes.Parents)]
94+
[Include(AssociationTypes.Parents)]
9595
public TopicViewModel? Parent { get; init; }
9696

9797
} //Class

OnTopic/Mapping/Annotations/AssociationTypes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace OnTopic.Mapping.Annotations {
1616
/// </summary>
1717
/// <remarks>
1818
/// <para>
19-
/// The <see cref="TopicMappingService"/> and <see cref="FollowAttribute"/> use the <see cref="AssociationTypes"/> enum to
19+
/// The <see cref="TopicMappingService"/> and <see cref="IncludeAttribute"/> use the <see cref="AssociationTypes"/> enum to
2020
/// determine what associations should be mapped—or followed—as part of the mapping process. This helps constrain the
2121
/// scope of the object graph to only include the data needed for a given view, or vice verse. That said, the <see cref="
2222
/// AssociationTypes"/> enum can be used any place where the code needs to model multiple types of associations relevant

OnTopic/Mapping/Annotations/FlattenAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace OnTopic.Mapping.Annotations {
1616
/// <remarks>
1717
/// <para>
1818
/// By default, <see cref="ITopicMappingService"/> will populate all items in a collection—and, if the <see
19-
/// cref="FollowAttribute"/> is defined, then also include their specified relationships. The <see
19+
/// cref="IncludeAttribute"/> is defined, then also include their specified relationships. The <see
2020
/// cref="FlattenAttribute"/> allows all subsequent children to not only be included, but to be elevated to a single
2121
/// list. This can be especially useful when combined with e.g. <see cref="FilterByAttributeAttribute"/> as well as
2222
/// strongly-typed collections (e.g., of a specific view model type), as it allows a list to provide, effectively, search

OnTopic/Mapping/Annotations/FollowAttribute.cs renamed to OnTopic/Mapping/Annotations/IncludeAttribute.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,42 @@
77
namespace OnTopic.Mapping.Annotations {
88

99
/*============================================================================================================================
10-
| ATTRIBUTE: FOLLOW
10+
| ATTRIBUTE: INCLUDE
1111
\---------------------------------------------------------------------------------------------------------------------------*/
1212
/// <summary>
13-
/// Instructs the <see cref="ITopicMappingService"/> to continue following relationships on that property. Optionally
14-
/// specifies which relationships should be followed.
13+
/// Instructs the <see cref="ITopicMappingService"/> to include the specified <see cref="Associations"/> on that property.
1514
/// </summary>
1615
/// <remarks>
1716
/// <para>
18-
/// By default, <see cref="ITopicMappingService"/> will populate all relationships on the initial data transfer object,
19-
/// but won't continue to do so on related objects. So, for instance, a <c>Children</c> collection will cause all children
20-
/// to be loaded, but the mapper won't populate their <c>Children</c> (assuming that property is set).
17+
/// By default, <see cref="ITopicMappingService"/> will populate all associations on the initial data transfer object,
18+
/// but won't continue to do so on associated objects. So, for instance, a <c>Children</c> collection will cause all
19+
/// children to be loaded, but the mapper won't populate <i>their</i> <c>Children</c> (assuming that property is
20+
/// available).
2121
/// </para>
2222
/// <para>
23-
/// The <see cref="FollowAttribute"/> overrides this behavior. If set, the <see cref="ITopicMappingService"/> will
24-
/// populate the <see cref="Associations"/> specified on the related topics. By default, it will crawl <i>all</i>
25-
/// relationships, but the <see cref="Associations"/> flag can optionally be used to specify one or multiple
26-
/// relationship types, thus providing fine-tune control.
23+
/// The <see cref="IncludeAttribute"/> overrides this behavior. If set, the <see cref="ITopicMappingService"/> will
24+
/// populate the <see cref="Associations"/> specified on the associated topics.
2725
/// </para>
2826
/// </remarks>
2927
[System.AttributeUsage(System.AttributeTargets.Property)]
30-
public sealed class FollowAttribute : System.Attribute {
28+
public sealed class IncludeAttribute : System.Attribute {
3129

3230
/*==========================================================================================================================
3331
| CONSTRUCTOR
3432
\-------------------------------------------------------------------------------------------------------------------------*/
3533
/// <summary>
36-
/// Annotates a property with the <see cref="FollowAttribute"/> by providing an <paramref name="associations"/>.
34+
/// Annotates a property with the <see cref="IncludeAttribute"/> by providing an <paramref name="associations"/>.
3735
/// </summary>
3836
/// <param name="associations">The specific associations that should be crawled.</param>
39-
public FollowAttribute(AssociationTypes associations) {
37+
public IncludeAttribute(AssociationTypes associations) {
4038
Associations = associations;
4139
}
4240

4341
/*==========================================================================================================================
44-
| PROPERTY: RELATIONSHIPS
42+
| PROPERTY: ASSOCIATIONS
4543
\-------------------------------------------------------------------------------------------------------------------------*/
4644
/// <summary>
47-
/// Gets the type(s) of relationships that should be recursed over.
45+
/// Gets the type(s) of associations that should be recursed over.
4846
/// </summary>
4947
public AssociationTypes Associations { get; }
5048

0 commit comments

Comments
 (0)