Skip to content

Commit d680df8

Browse files
committed
replace _nodeStack with generic stack for code quality, make it readonly
1 parent 09ea714 commit d680df8

File tree

1 file changed

+7
-7
lines changed
  • src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup

1 file changed

+7
-7
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlReader.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public BamlReader(Stream bamlStream)
182182
_properties = new ArrayList();
183183
_haveUnprocessedRecord = false;
184184
_deferableContentBlockDepth = -1;
185-
_nodeStack = new Stack();
185+
_nodeStack = new Stack<BamlNodeInfo>();
186186
_reverseXmlnsTable = new Dictionary<String, List<String>>();
187187
}
188188

@@ -1493,7 +1493,7 @@ private BamlKeyInfo ProcessKeyTree()
14931493

14941494
case BamlRecordType.PropertyComplexStart:
14951495
ReadPropertyComplexStartRecord();
1496-
nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
1496+
nodeInfo = _nodeStack.Pop();
14971497
if (readProperty.Pop())
14981498
{
14991499
markupString += ", ";
@@ -1842,7 +1842,7 @@ private void ReadDocumentEndRecord()
18421842
{
18431843
// Pop information off the node stack to ensure we have matched all the
18441844
// start and end nodes and have nothing left but the start document node.
1845-
BamlNodeInfo nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
1845+
BamlNodeInfo nodeInfo = _nodeStack.Pop();
18461846
if (nodeInfo.RecordType != BamlRecordType.DocumentStart)
18471847
{
18481848
throw new InvalidOperationException(SR.Format(SR.BamlScopeError,
@@ -2025,7 +2025,7 @@ private void ReadElementEndRecord()
20252025
// Pop information off the node stack that tells us what element this
20262026
// is the end of. Check to make sure the record on the stack is for a
20272027
// start element.
2028-
BamlNodeInfo nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
2028+
BamlNodeInfo nodeInfo = _nodeStack.Pop();
20292029
if (nodeInfo.RecordType != BamlRecordType.ElementStart)
20302030
{
20312031
throw new InvalidOperationException(SR.Format(SR.BamlScopeError,
@@ -2112,7 +2112,7 @@ private void ReadPropertyComplexEndRecord()
21122112
// Pop information off the node info stack that tells us what the starting
21132113
// record was for this ending record. Check to make sure it is the
21142114
// correct type. If not, throw an exception.
2115-
BamlNodeInfo nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
2115+
BamlNodeInfo nodeInfo = _nodeStack.Pop();
21162116
BamlRecordType expectedType;
21172117
switch (nodeInfo.RecordType)
21182118
{
@@ -2240,7 +2240,7 @@ private void ReadConstructorEnd()
22402240
// Pop information off the node stack that tells us what element this
22412241
// is the end of. Check to make sure the record on the stack is for a
22422242
// start element.
2243-
BamlNodeInfo nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
2243+
BamlNodeInfo nodeInfo = _nodeStack.Pop();
22442244
if (nodeInfo.RecordType != BamlRecordType.ConstructorParametersStart)
22452245
{
22462246
throw new InvalidOperationException(SR.Format(SR.BamlScopeError,
@@ -2842,7 +2842,7 @@ private BamlMapTable MapTable
28422842
private BamlAttributeUsage _attributeUsage;
28432843

28442844
// Stack of node information about the element tree being built.
2845-
private Stack _nodeStack;
2845+
private readonly Stack<BamlNodeInfo> _nodeStack;
28462846

28472847
// Context information used when reading baml file. This contains the XamlTypeMapper used
28482848
// for resolving binary property information into strings.

0 commit comments

Comments
 (0)