3
3
4
4
namespace Microsoft . AspNetCore . Components . Rendering
5
5
{
6
- // Used internally during diffing to track what we know about
7
- // keyed items and their positions
8
- internal struct KeyedItemInfo
6
+ // Used internally during diffing to track what we know about keyed items and their positions
7
+ internal readonly struct KeyedItemInfo
9
8
{
10
- public int OldIndex ;
11
- public int NewIndex ;
12
- public int OldSiblingIndex ;
13
- public int NewSiblingIndex ;
14
- public bool IsUnique ;
9
+ public readonly int OldIndex ;
10
+ public readonly int NewIndex ;
11
+ public readonly int OldSiblingIndex ;
12
+ public readonly int NewSiblingIndex ;
13
+ public readonly bool IsUnique ;
15
14
16
15
public KeyedItemInfo ( int oldIndex , int newIndex , bool isUnique )
17
16
{
@@ -30,5 +29,18 @@ public KeyedItemInfo(int oldIndex, int newIndex, bool isUnique)
30
29
// Guidance for developers is therefore to use distinct keys.
31
30
IsUnique = isUnique ;
32
31
}
32
+
33
+ private KeyedItemInfo ( in KeyedItemInfo copyFrom , int oldSiblingIndex , int newSiblingIndex )
34
+ {
35
+ this = copyFrom ;
36
+ OldSiblingIndex = oldSiblingIndex ;
37
+ NewSiblingIndex = newSiblingIndex ;
38
+ }
39
+
40
+ public KeyedItemInfo WithOldSiblingIndex ( int oldSiblingIndex )
41
+ => new KeyedItemInfo ( this , oldSiblingIndex , NewSiblingIndex ) ;
42
+
43
+ public KeyedItemInfo WithNewSiblingIndex ( int newSiblingIndex )
44
+ => new KeyedItemInfo ( this , OldSiblingIndex , newSiblingIndex ) ;
33
45
}
34
46
}
0 commit comments