Skip to content

Commit 24071bf

Browse files
committed
Reintroduced GetTopic(), indexer as [Obsolete]
The `TopicCollection` and `ReadOnlyTopicCollection` were renamed to `KeyedTopicCollection` and `ReadOnlyKeyedTopicCollection`. In their place, a non-keyed version was introduced. Callers of these classes may still expected `GetTopic()` to be in place. We obviously can't mark `TopicCollection` and `ReadOnlyTopicCollection` as `[Obsolete]` since they've been reintroduced in a new capacity, but we can introduce these common members as `[Obsolete]` as a means of instructing callers how to migrate to the new classes.
1 parent 0f5602e commit 24071bf

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

OnTopic/Collections/ReadOnlyTopicCollection.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
| Client Ignia, LLC
44
| Project Topics Library
55
\=============================================================================================================================*/
6+
using System;
67
using System.Collections.Generic;
78
using System.Collections.ObjectModel;
89

@@ -26,5 +27,25 @@ public class ReadOnlyTopicCollection : ReadOnlyCollection<Topic> {
2627
public ReadOnlyTopicCollection(IList<Topic>? innerCollection = null) : base(innerCollection?? new List<Topic>()) {
2728
}
2829

30+
/*==========================================================================================================================
31+
| METHOD: GET TOPIC
32+
\-------------------------------------------------------------------------------------------------------------------------*/
33+
/// <inheritdoc cref="ReadOnlyKeyedTopicCollection{T}.GetTopic(String)"/>
34+
[Obsolete(
35+
"The GetTopic() method is not implemented on ReadOnlyTopicCollection. Use ReadOnlyKeyedTopicCollection instead.",
36+
true
37+
)]
38+
public Topic? GetValue(string key) => throw new NotImplementedException();
39+
40+
/*==========================================================================================================================
41+
| INDEXER
42+
\-------------------------------------------------------------------------------------------------------------------------*/
43+
/// <inheritdoc cref="ReadOnlyKeyedTopicCollection{T}"/>
44+
[Obsolete(
45+
"Indexing by key is not implemented on ReadOnlyTopicCollection. Use ReadOnlyKeyedTopicCollection instead.",
46+
true
47+
)]
48+
public Topic this[string key] => throw new ArgumentOutOfRangeException(nameof(key));
49+
2950
} //Class
3051
} //Namespace

OnTopic/Collections/TopicCollection.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
| Client Ignia, LLC
44
| Project Topics Library
55
\=============================================================================================================================*/
6+
using System;
67
using System.Collections.Generic;
78
using System.Collections.ObjectModel;
89
using System.Linq;
@@ -35,5 +36,19 @@ public class TopicCollection : Collection<Topic> {
3536
/// </summary>
3637
public ReadOnlyTopicCollection AsReadOnly() => new(this);
3738

39+
/*==========================================================================================================================
40+
| METHOD: GET TOPIC
41+
\-------------------------------------------------------------------------------------------------------------------------*/
42+
/// <inheritdoc cref="KeyedTopicCollection{T}.GetTopic(String)"/>
43+
[Obsolete("The GetTopic() method is not implemented on TopicCollection. Use KeyedTopicCollection instead.", true)]
44+
public Topic? GetValue(string key) => throw new NotImplementedException();
45+
46+
/*==========================================================================================================================
47+
| INDEXER
48+
\-------------------------------------------------------------------------------------------------------------------------*/
49+
/// <inheritdoc cref="KeyedTopicCollection{T}"/>
50+
[Obsolete("Indexing by key is not implemented on the TopicCollection. Use the KeyedTopicCollection instead.",true)]
51+
public Topic this[string key] => throw new ArgumentOutOfRangeException(nameof(key));
52+
3853
} //Class
3954
} //Namespace

0 commit comments

Comments
 (0)