Skip to content

Commit b93a6b9

Browse files
authored
Fix docs and exception messages for Change (#1085)
1 parent 7b861d0 commit b93a6b9

4 files changed

Lines changed: 21 additions & 19 deletions

File tree

src/DynamicData/Cache/Change.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public Change(ChangeReason reason, TKey key, TObject current, int index = -1)
2828

2929
/// <summary>
3030
/// Initializes a new instance of the <see cref="Change{TObject, TKey}"/> struct.
31-
/// Constructor for ChangeReason.Move.
31+
/// Constructor for <see cref="ChangeReason.Moved"/>.
3232
/// </summary>
3333
/// <param name="key">The key.</param>
3434
/// <param name="current">The current.</param>
@@ -70,9 +70,9 @@ public Change(TKey key, TObject current, int currentIndex, int previousIndex)
7070
/// <param name="currentIndex">Value of the current.</param>
7171
/// <param name="previousIndex">Value of the previous.</param>
7272
/// <exception cref="ArgumentException">
73-
/// For ChangeReason.Add, a previous value cannot be specified
73+
/// For <see cref="ChangeReason.Add"/>, a previous value cannot be specified
7474
/// or
75-
/// For ChangeReason.Change, must supply previous value.
75+
/// For <see cref="ChangeReason.Update"/>, must supply previous value.
7676
/// </exception>
7777
public Change(ChangeReason reason, TKey key, TObject current, in Optional<TObject> previous, int currentIndex = -1, int previousIndex = -1)
7878
: this()
@@ -91,7 +91,7 @@ public Change(ChangeReason reason, TKey key, TObject current, in Optional<TObjec
9191

9292
if (reason == ChangeReason.Update && !previous.HasValue)
9393
{
94-
throw new ArgumentException("For ChangeReason.Change, must supply previous value");
94+
throw new ArgumentException("For ChangeReason.Update, must supply previous value");
9595
}
9696
}
9797

@@ -101,7 +101,7 @@ public Change(ChangeReason reason, TKey key, TObject current, in Optional<TObjec
101101
public TKey Key { get; }
102102

103103
/// <summary>
104-
/// Gets the reason for the change.
104+
/// Gets the reason for the change.
105105
/// </summary>
106106
public ChangeReason Reason { get; }
107107

@@ -116,14 +116,14 @@ public Change(ChangeReason reason, TKey key, TObject current, in Optional<TObjec
116116
public int CurrentIndex { get; }
117117

118118
/// <summary>
119-
/// <para>Gets the previous change.</para>
120-
/// <para>This is only when Reason==ChangeReason.Replace.</para>
119+
/// <para>Gets the item from before the change.</para>
120+
/// <para>This is only when <see cref="Reason"/> is <see cref="ChangeReason.Update"/>.</para>
121121
/// </summary>
122122
public Optional<TObject> Previous { get; }
123123

124124
/// <summary>
125-
/// <para>Gets the previous change.</para>
126-
/// <para>This is only when Reason==ChangeReason.Update or ChangeReason.Move.</para>
125+
/// <para>Gets the previous index.</para>
126+
/// <para>This is only when <see cref="Reason"/> is <see cref="ChangeReason.Update"/> or <see cref="ChangeReason.Moved"/>.</para>
127127
/// </summary>
128128
public int PreviousIndex { get; }
129129

src/DynamicData/List/Change.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public Change(ListChangeReason reason, IEnumerable<T> items, int index = -1)
4747

4848
/// <summary>
4949
/// Initializes a new instance of the <see cref="Change{T}"/> class.
50-
/// Constructor for ChangeReason.Move.
50+
/// Constructor for <see cref="ListChangeReason.Moved"/>.
5151
/// </summary>
5252
/// <param name="current">The current.</param>
5353
/// <param name="currentIndex">The CurrentIndex.</param>
@@ -84,25 +84,27 @@ public Change(T current, int currentIndex, int previousIndex)
8484
/// <param name="currentIndex">Value of the current.</param>
8585
/// <param name="previousIndex">Value of the previous.</param>
8686
/// <exception cref="ArgumentException">
87-
/// For ChangeReason.Add, a previous value cannot be specified
87+
/// For <see cref="ListChangeReason.Add"/>, a previous value cannot be specified
8888
/// or
89-
/// For ChangeReason.Change, must supply previous value.
89+
/// For <see cref="ListChangeReason.Replace"/>, must supply previous value.
90+
/// or
91+
/// For <see cref="ListChangeReason.Refresh"/>, must supply an index.
9092
/// </exception>
9193
public Change(ListChangeReason reason, T current, in Optional<T> previous, int currentIndex = -1, int previousIndex = -1)
9294
{
9395
if (reason == ListChangeReason.Add && previous.HasValue)
9496
{
95-
throw new ArgumentException("For ChangeReason.Add, a previous value cannot be specified");
97+
throw new ArgumentException("For ListChangeReason.Add, a previous value cannot be specified");
9698
}
9799

98100
if (reason == ListChangeReason.Replace && !previous.HasValue)
99101
{
100-
throw new ArgumentException("For ChangeReason.Replace, must supply previous value");
102+
throw new ArgumentException("For ListChangeReason.Replace, must supply previous value");
101103
}
102104

103105
if (reason == ListChangeReason.Refresh && currentIndex < 0)
104106
{
105-
throw new ArgumentException("For ChangeReason.Refresh, must supply an index");
107+
throw new ArgumentException("For ListChangeReason.Refresh, must supply an index");
106108
}
107109

108110
Reason = reason;

src/DynamicData/List/ItemChange.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ public ItemChange(ListChangeReason reason, T current, int currentIndex)
6767
public int CurrentIndex { get; }
6868

6969
/// <summary>
70-
/// <para>Gets the previous change.</para>
71-
/// <para>This is only when Reason==ChangeReason.Replace.</para>
70+
/// <para>Gets the item from before the change.</para>
71+
/// <para>This is only when <see cref="Reason"/> is <see cref="ListChangeReason.Replace"/>.</para>
7272
/// </summary>
7373
public Optional<T> Previous { get; }
7474

7575
/// <summary>
7676
/// <para>Gets the previous index.</para>
77-
/// <para>This is only when Reason==ChangeReason.Replace or ChangeReason.Move.</para>
77+
/// <para>This is only when <see cref="Reason"/> is <see cref="ListChangeReason.Replace"/> or <see cref="ListChangeReason.Moved"/>.</para>
7878
/// </summary>
7979
public int PreviousIndex { get; }
8080

src/DynamicData/List/RangeChange.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private RangeChange()
6363
public IEnumerator<T> GetEnumerator() => _items.GetEnumerator();
6464

6565
/// <summary>
66-
/// Inserts the item in the range at the specified index.
66+
/// Inserts the item in the range at the specified index.
6767
/// </summary>
6868
/// <param name="index">The index.</param>
6969
/// <param name="item">The item.</param>

0 commit comments

Comments
 (0)