Skip to content

Commit e9de72f

Browse files
committed
Reintroduced FromList method as [Obsolete]
This was removed from `ReadOnlyKeyedTopicCollection<T>` since the use case is better covered by the similar constructor overload, but should have been kept with an obsolete notice to provide instructions to callers. In addition, the `ReadOnlyKeyedTopicCollection<T>` used to be named `ReadOnlyTopicCollection<T>`, from which a `ReadOnlyTopicCollection` was derived. The `ReadOnlyTopicCollection` no longer derives from `ReadOnlyKeyedTopicCollection<T>`. But since callers may confuse it with the previous class of the same name—which was based on a `KeyedCollection`—I've introduced it there as well, in order to offer instruction to implementors.
1 parent c0b5d7d commit e9de72f

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

OnTopic/Collections/ReadOnlyKeyedTopicCollection{T}.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ public class ReadOnlyKeyedTopicCollection<T> : ReadOnlyCollection<T> where T : T
3535
_innerCollection = innerCollection as KeyedTopicCollection<T>?? new(innerCollection);
3636
}
3737

38+
/*==========================================================================================================================
39+
| FACTORY METHOD: FROM LIST
40+
\-------------------------------------------------------------------------------------------------------------------------*/
41+
/// <summary>
42+
/// Establishes a new <see cref="ReadOnlyTopicCollection{T}"/> based on an existing <see cref="List{T}"/>.
43+
/// </summary>
44+
/// <remarks>
45+
/// The <paramref name="innerCollection"/> will be converted to a <see cref="TopicCollection{T}"/>.
46+
/// </remarks>
47+
/// <param name="innerCollection">The underlying <see cref="TopicCollection{T}"/>.</param>
48+
[Obsolete("This is effectively satisfied by the related overload, and has been removed.", true)]
49+
public ReadOnlyTopicCollection<T> FromList(IList<T> innerCollection) => throw new NotImplementedException();
50+
3851
/*==========================================================================================================================
3952
| METHOD: GET VALUE
4053
\-------------------------------------------------------------------------------------------------------------------------*/

OnTopic/Collections/ReadOnlyTopicCollection.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ public class ReadOnlyTopicCollection : ReadOnlyCollection<Topic> {
2727
public ReadOnlyTopicCollection(IList<Topic>? innerCollection = null) : base(innerCollection?? new List<Topic>()) {
2828
}
2929

30+
/*==========================================================================================================================
31+
| FACTORY METHOD: FROM LIST
32+
\-------------------------------------------------------------------------------------------------------------------------*/
33+
/// <summary>
34+
/// Establishes a new <see cref="ReadOnlyTopicCollection"/> based on an existing <see cref="List{Topic}"/>.
35+
/// </summary>
36+
/// <remarks>
37+
/// The <paramref name="innerCollection"/> will be converted to a <see cref="ReadOnlyTopicCollection"/>.
38+
/// </remarks>
39+
/// <param name="innerCollection">The underlying <see cref="List{Topic}"/>.</param>
40+
[Obsolete("This is effectively satisfied by the related overload, and has been removed.", true)]
41+
public ReadOnlyTopicCollection FromList(IList<Topic> innerCollection) => throw new NotImplementedException();
42+
3043
/*==========================================================================================================================
3144
| METHOD: GET TOPIC
3245
\-------------------------------------------------------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)