From: Stephen Toub Date: Fri, 27 Sep 2019 18:19:52 +0000 (-0400) Subject: Add some DebuggerDisplay attributes in System.Linq (dotnet/corefx#41386) X-Git-Tag: submit/tizen/20210909.063632~11031^2~394 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c362923cae8543b5092b2115f169411ee7dd4763;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add some DebuggerDisplay attributes in System.Linq (dotnet/corefx#41386) Commit migrated from https://github.com/dotnet/corefx/commit/e667c29636a622eb4f9493f75232b44e0ae90b29 --- diff --git a/src/libraries/System.Linq/src/System/Linq/Partition.SpeedOpt.cs b/src/libraries/System.Linq/src/System/Linq/Partition.SpeedOpt.cs index 1b8d9ff..4c59749 100644 --- a/src/libraries/System.Linq/src/System/Linq/Partition.SpeedOpt.cs +++ b/src/libraries/System.Linq/src/System/Linq/Partition.SpeedOpt.cs @@ -17,6 +17,7 @@ namespace System.Linq /// Returning an instance of this type is useful to quickly handle scenarios where it is known /// that an operation will result in zero elements. /// + [DebuggerDisplay("Count = 0")] internal sealed class EmptyPartition : IPartition, IEnumerator { /// @@ -150,6 +151,7 @@ namespace System.Linq /// An iterator that yields the items of part of an . /// /// The type of the source list. + [DebuggerDisplay("Count = {Count}")] private sealed class ListPartition : Iterator, IPartition { private readonly IList _source; diff --git a/src/libraries/System.Linq/src/System/Linq/Range.cs b/src/libraries/System.Linq/src/System/Linq/Range.cs index a26ed82..10d3d61 100644 --- a/src/libraries/System.Linq/src/System/Linq/Range.cs +++ b/src/libraries/System.Linq/src/System/Linq/Range.cs @@ -28,6 +28,7 @@ namespace System.Linq /// /// An iterator that yields a range of consecutive integers. /// + [DebuggerDisplay("Count = {CountForDebugger}")] private sealed partial class RangeIterator : Iterator { private readonly int _start; @@ -40,6 +41,8 @@ namespace System.Linq _end = unchecked(start + count); } + private int CountForDebugger => _end - _start; + public override Iterator Clone() => new RangeIterator(_start, _end - _start); public override bool MoveNext() diff --git a/src/libraries/System.Linq/src/System/Linq/Repeat.cs b/src/libraries/System.Linq/src/System/Linq/Repeat.cs index df4812b..a37dc08 100644 --- a/src/libraries/System.Linq/src/System/Linq/Repeat.cs +++ b/src/libraries/System.Linq/src/System/Linq/Repeat.cs @@ -28,6 +28,7 @@ namespace System.Linq /// An iterator that yields the same item multiple times. /// /// The type of the item. + [DebuggerDisplay("Count = {_count}")] private sealed partial class RepeatIterator : Iterator { private readonly int _count; diff --git a/src/libraries/System.Linq/src/System/Linq/Select.SpeedOpt.cs b/src/libraries/System.Linq/src/System/Linq/Select.SpeedOpt.cs index 7ac46f1..bfbff0f 100644 --- a/src/libraries/System.Linq/src/System/Linq/Select.SpeedOpt.cs +++ b/src/libraries/System.Linq/src/System/Linq/Select.SpeedOpt.cs @@ -683,6 +683,7 @@ namespace System.Linq /// /// The type of the source list. /// The type of the mapped items. + [DebuggerDisplay("Count = {Count}")] private sealed class SelectListPartitionIterator : Iterator, IPartition { private readonly IList _source; diff --git a/src/libraries/System.Linq/src/System/Linq/Select.cs b/src/libraries/System.Linq/src/System/Linq/Select.cs index 4278e6d..000777a 100644 --- a/src/libraries/System.Linq/src/System/Linq/Select.cs +++ b/src/libraries/System.Linq/src/System/Linq/Select.cs @@ -156,6 +156,7 @@ namespace System.Linq /// /// The type of the source array. /// The type of the mapped items. + [DebuggerDisplay("Count = {CountForDebugger}")] private sealed partial class SelectArrayIterator : Iterator { private readonly TSource[] _source; @@ -170,6 +171,8 @@ namespace System.Linq _selector = selector; } + private int CountForDebugger => _source.Length; + public override Iterator Clone() => new SelectArrayIterator(_source, _selector); public override bool MoveNext() @@ -194,6 +197,7 @@ namespace System.Linq /// /// The type of the source list. /// The type of the mapped items. + [DebuggerDisplay("Count = {CountForDebugger}")] private sealed partial class SelectListIterator : Iterator { private readonly List _source; @@ -208,6 +212,8 @@ namespace System.Linq _selector = selector; } + private int CountForDebugger => _source.Count; + public override Iterator Clone() => new SelectListIterator(_source, _selector); public override bool MoveNext() @@ -241,6 +247,7 @@ namespace System.Linq /// /// The type of the source list. /// The type of the mapped items. + [DebuggerDisplay("Count = {CountForDebugger}")] private sealed partial class SelectIListIterator : Iterator { private readonly IList _source; @@ -255,6 +262,8 @@ namespace System.Linq _selector = selector; } + private int CountForDebugger => _source.Count; + public override Iterator Clone() => new SelectIListIterator(_source, _selector); public override bool MoveNext()