Skip to content

Commit 68a4e83

Browse files
committed
Removed IsHidden from the ITopicViewModel definition
In addition to cluttering an already overpopulated interface, the `IsHidden` property doesn't make much in the current version of OnTopic, as hidden view models are explicitly excluded from the the `TopicMappingService`. The one exception to this is the top-level topic—i.e., the one sent directly to the `ITopicMappingService`, as opposed to referenced from its properties. But in those cases, we expect callers, such as `TopicController`, to explicitly determine if `IsHidden is appropriate or not. Given that, there isn't much benefit to exposing `IsHidden` to the view model—either the interface or the implementation. As part of this, I marked the interface as obsolete, and marked the implementation as both obsolete and disabled mapping of the property. In addition, I removed references to it from the unit tests. These weren't strictly necessary, and can be safely removed while still satisfying the basic criteria of the unit tests.
1 parent c41d989 commit 68a4e83

4 files changed

Lines changed: 4 additions & 6 deletions

File tree

OnTopic.AspNetCore.Mvc.Host/Views/Shared/_TopicAttributes.cshtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<li>ContentType: @Model.ContentType</li>
88
<li>UniqueKey: @Model.UniqueKey</li>
99
<li>WebPath: @Model.WebPath</li>
10-
<li>IsHidden? @Model.IsHidden</li>
1110
<li>LastModified: @Model.LastModified</li>
1211
<li>View: @Model.View</li>
1312
</ul>

OnTopic.Tests/TopicMappingServiceTest.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,11 @@ public async Task Map_Generic_ReturnsNewModel() {
8585

8686
topic.Attributes.SetValue("MetaTitle", "ValueA");
8787
topic.Attributes.SetValue("Title", "Value1");
88-
topic.Attributes.SetValue("IsHidden", "1");
8988

9089
var target = await _mappingService.MapAsync<PageTopicViewModel>(topic).ConfigureAwait(false);
9190

9291
Assert.AreEqual<string>("ValueA", target.MetaTitle);
9392
Assert.AreEqual<string>("Value1", target.Title);
94-
Assert.AreEqual<bool>(true, target.IsHidden);
9593

9694
}
9795

@@ -127,13 +125,11 @@ public async Task Map_Dynamic_ReturnsNewModel() {
127125

128126
topic.Attributes.SetValue("MetaTitle", "ValueA");
129127
topic.Attributes.SetValue("Title", "Value1");
130-
topic.Attributes.SetValue("IsHidden", "1");
131128

132129
var target = (PageTopicViewModel?)await _mappingService.MapAsync(topic).ConfigureAwait(false);
133130

134131
Assert.AreEqual<string>("ValueA", target.MetaTitle);
135132
Assert.AreEqual<string>("Value1", target.Title);
136-
Assert.AreEqual<bool>(true, target.IsHidden);
137133

138134
}
139135

OnTopic.ViewModels/TopicViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ public record TopicViewModel: ITopicViewModel, IKeyedTopicViewModel, IAssociated
6767
/*==========================================================================================================================
6868
| IS HIDDEN?
6969
\-------------------------------------------------------------------------------------------------------------------------*/
70-
/// <inheritdoc />
70+
/// <inheritdoc/>
71+
[Obsolete("The IsHidden property is no longer supported by TopicViewModel.", true)]
72+
[DisableMapping]
7173
public bool IsHidden { get; init; }
7274

7375
/*==========================================================================================================================

OnTopic/Models/ITopicViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public interface ITopicViewModel: IKeyedTopicViewModel, IAssociatedTopicBindingM
6868
/// <summary>
6969
/// Gets or sets whether the current topic is hidden.
7070
/// </summary>
71+
[Obsolete("The IsHidden property is no longer supported by ITopicViewModel.", true)]
7172
bool IsHidden { get; init; }
7273

7374
/*==========================================================================================================================

0 commit comments

Comments
 (0)