GeezerVison is showing github.com — Fix MatchInfoContext clone implementation (#5121) · PowerShell/PowerShell@81c46c6
File tree
Expand file treeCollapse file tree
Open diff view settings
src/Microsoft.PowerShell.Commands.Utility/commands/utility
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs +7-6Lines changed: 7 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -61,12 +61,13 @@ internal MatchInfoContext() |
61 | 61 | /// </summary> |
62 | 62 | public object Clone() |
63 | 63 | { |
64 | | - MatchInfoContext clone = new MatchInfoContext(); |
65 | | - clone.PreContext = (clone.PreContext != null) ? (string[])PreContext.Clone() : null; |
66 | | - clone.PostContext = (clone.PostContext != null) ? (string[])PostContext.Clone() : null; |
67 | | - clone.DisplayPreContext = (clone.DisplayPreContext != null) ? (string[])DisplayPreContext.Clone() : null; |
68 | | - clone.DisplayPostContext = (clone.DisplayPostContext != null) ? (string[])DisplayPostContext.Clone() : null; |
69 | | - return clone; |
| 64 | + return new MatchInfoContext() |
| 65 | + { |
| 66 | + PreContext = (string[])PreContext?.Clone(), |
| 67 | + PostContext = (string[])PostContext?.Clone(), |
| 68 | + DisplayPreContext = (string[])DisplayPreContext?.Clone(), |
| 69 | + DisplayPostContext = (string[])DisplayPostContext?.Clone() |
| 70 | + }; |
70 | 71 | } |
71 | 72 | } |
72 | 73 |
|
|