diff options
author | Rob Mensching <rob@firegiant.com> | 2022-03-02 13:53:34 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-03-02 14:38:30 -0800 |
commit | 558dd1a421d53ebb9ca3171bcccc39eb58dfec70 (patch) | |
tree | b11df2979a61a058e47e4d264671460141e1a482 | |
parent | 726013926b7cef670d228fabb0a65c6a13fc5835 (diff) | |
download | wix-558dd1a421d53ebb9ca3171bcccc39eb58dfec70.tar.gz wix-558dd1a421d53ebb9ca3171bcccc39eb58dfec70.tar.bz2 wix-558dd1a421d53ebb9ca3171bcccc39eb58dfec70.zip |
Minor code cleanup
-rw-r--r-- | src/wix/WixToolset.Core/Preprocessor.cs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/wix/WixToolset.Core/Preprocessor.cs b/src/wix/WixToolset.Core/Preprocessor.cs index 603c0e5b..486a4c8c 100644 --- a/src/wix/WixToolset.Core/Preprocessor.cs +++ b/src/wix/WixToolset.Core/Preprocessor.cs | |||
@@ -402,8 +402,7 @@ namespace WixToolset.Core | |||
402 | switch (reader.NodeType) | 402 | switch (reader.NodeType) |
403 | { | 403 | { |
404 | case XmlNodeType.XmlDeclaration: | 404 | case XmlNodeType.XmlDeclaration: |
405 | var document = currentContainer as XDocument; | 405 | if (currentContainer is XDocument document) |
406 | if (null != document) | ||
407 | { | 406 | { |
408 | document.Declaration = new XDeclaration(null, null, null); | 407 | document.Declaration = new XDeclaration(null, null, null); |
409 | while (reader.MoveToNextAttribute()) | 408 | while (reader.MoveToNextAttribute()) |
@@ -705,15 +704,13 @@ namespace WixToolset.Core | |||
705 | } | 704 | } |
706 | 705 | ||
707 | // get the offset of this xml fragment (for some reason its always off by 1) | 706 | // get the offset of this xml fragment (for some reason its always off by 1) |
708 | var lineInfoReader = reader as IXmlLineInfo; | 707 | if (reader is IXmlLineInfo lineInfoReader) |
709 | if (null != lineInfoReader) | ||
710 | { | 708 | { |
711 | offset += lineInfoReader.LineNumber - 1; | 709 | offset += lineInfoReader.LineNumber - 1; |
712 | } | 710 | } |
713 | 711 | ||
714 | var textReader = reader as XmlTextReader; | ||
715 | // dump the xml to a string (maintaining whitespace if possible) | 712 | // dump the xml to a string (maintaining whitespace if possible) |
716 | if (null != textReader) | 713 | if (reader is XmlTextReader textReader) |
717 | { | 714 | { |
718 | textReader.WhitespaceHandling = WhitespaceHandling.All; | 715 | textReader.WhitespaceHandling = WhitespaceHandling.All; |
719 | } | 716 | } |
@@ -1344,8 +1341,7 @@ namespace WixToolset.Core | |||
1344 | /// <param name="offset">This is the artificial offset of the line numbers from the reader. Used for the foreach processing.</param> | 1341 | /// <param name="offset">This is the artificial offset of the line numbers from the reader. Used for the foreach processing.</param> |
1345 | private void UpdateCurrentLineNumber(ProcessingState state, XmlReader reader, int offset) | 1342 | private void UpdateCurrentLineNumber(ProcessingState state, XmlReader reader, int offset) |
1346 | { | 1343 | { |
1347 | var lineInfoReader = reader as IXmlLineInfo; | 1344 | if (reader is IXmlLineInfo lineInfoReader) |
1348 | if (null != lineInfoReader) | ||
1349 | { | 1345 | { |
1350 | var newLine = lineInfoReader.LineNumber + offset; | 1346 | var newLine = lineInfoReader.LineNumber + offset; |
1351 | 1347 | ||