Skip to content

Commit 41598c5

Browse files
committed
Marked Description property as [Obsolete]
The `Topic` class contains a number of convenience methods for accessing (and setting) popular attributes. These were useful back when we worked directly with the `Topic` entities in our views (ugh!). Since we now use view models (e.g., `ITopicViewModel`) alongside the `TopicMappingService`, these don't provide as much benefit, as we can expose strongly typed accessor properties on our view models as needed, and have them automatically mapped to attributes. Given this, we're removing accessor properties that don't include business logic and aren't widely used within our libraries. I also updated the `ReverseTopicMappingServiceTest` to account for this change, as it used the accessor method in one of its unit tests. There are other convenience methods we will be keeping for now because they provide internal benefits. For instance, `IsHidden` and `IsDisabled` are frequently used by the library itself. Also, `Title` has the benefit of providing a fallback to `Key` if the `Title` isn't provided, which is useful—and especially since this accessor is utilized by the `TopicMappingService`.
1 parent a3f0cba commit 41598c5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

OnTopic.Tests/ReverseTopicMappingServiceTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ public async Task Map_Existing_ReturnsUpdatedTopic() {
140140
target.DefaultValue = "Hello";
141141
target.IsRequired = true;
142142
target.IsExtendedAttribute= false;
143-
target.Description = "Original Description";
143+
144+
target.Attributes.SetValue("Description", "Original Description");
144145

145146
target = (TextAttribute?)await mappingService.MapAsync(bindingModel, target).ConfigureAwait(false);
146147

@@ -150,7 +151,7 @@ public async Task Map_Existing_ReturnsUpdatedTopic() {
150151
Assert.AreEqual<string>("World", target.DefaultValue);
151152
Assert.AreEqual<bool>(false, target.IsRequired);
152153
Assert.AreEqual<bool>(false, target.IsExtendedAttribute);
153-
Assert.AreEqual<string>("Original Description", target.Description);
154+
Assert.AreEqual<string>("Original Description", target.Attributes.GetValue("Description"));
154155

155156
}
156157

OnTopic/Topic.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ public string Title {
368368
/// <requires description="The value from the getter must be provided." exception="T:System.ArgumentNullException">
369369
/// !string.IsNullOrWhiteSpace(value)
370370
/// </requires>
371+
[Obsolete("The Description convenience property will be removed in OnTopic Library 5.0. Use Attributes.SetValue() instead.")]
371372
public string? Description {
372373
get => Attributes.GetValue("Description");
373374
set => SetAttributeValue("Description", value);

0 commit comments

Comments
 (0)