Skip to content

Commit 91579ba

Browse files
authored
Use Stack<T> instead of Stack (#7253)
1 parent 14efa06 commit 91579ba

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Build/Logging/SerialConsoleLogger.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ internal enum FrameType
822822
internal struct Frame
823823
{
824824
/// <summary>
825-
/// Creates a new instance of frame with all fields specified.
825+
/// Initializes a new instance of the <see cref="Frame"/> struct with all fields specified.
826826
/// </summary>
827827
/// <param name="t">the type of the this frame</param>
828828
/// <param name="d">display state. true indicates this frame has been displayed to the user</param>
@@ -907,14 +907,14 @@ internal class FrameStack
907907
/// The frames member is contained by FrameStack and does
908908
/// all the heavy lifting for FrameStack.
909909
/// </summary>
910-
private System.Collections.Stack _frames;
910+
private readonly Stack<Frame> _frames;
911911

912912
/// <summary>
913-
/// Create a new, empty, FrameStack.
913+
/// Initializes a new instance of the <see cref="FrameStack"/> class.
914914
/// </summary>
915915
internal FrameStack()
916916
{
917-
_frames = new System.Collections.Stack();
917+
_frames = new Stack<Frame>();
918918
}
919919

920920
/// <summary>
@@ -923,15 +923,15 @@ internal FrameStack()
923923
/// <exception cref="InvalidOperationException">Thrown when stack is empty.</exception>
924924
internal Frame Pop()
925925
{
926-
return (Frame)(_frames.Pop());
926+
return _frames.Pop();
927927
}
928928

929929
/// <summary>
930930
/// Returns, but does not remove, the top of the stack.
931931
/// </summary>
932932
internal Frame Peek()
933933
{
934-
return (Frame)(_frames.Peek());
934+
return _frames.Peek();
935935
}
936936

937937
/// <summary>

src/Tasks/ParserState.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Text;
6-
using System.Collections;
6+
using System.Collections.Generic;
77

88
#nullable disable
99

@@ -19,7 +19,7 @@ internal sealed class ParseState
1919
private int _openConditionalDirectives;
2020

2121
// A stack of namespaces so that nested namespaces can be supported.
22-
private readonly Stack _namespaceStack = new Stack();
22+
private readonly Stack<string> _namespaceStack = new Stack<string>();
2323

2424
internal ParseState()
2525
{
@@ -90,7 +90,7 @@ internal string PopNamespacePart()
9090
return null;
9191
}
9292

93-
return (string)_namespaceStack.Pop();
93+
return _namespaceStack.Pop();
9494
}
9595

9696
/// <summary>

0 commit comments

Comments
 (0)