Skip to content

Commit 17b3375

Browse files
authored
1 parent d5b0264 commit 17b3375

File tree

11 files changed

+39
-39
lines changed

11 files changed

+39
-39
lines changed

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/HeaderInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.PowerShell.Commands
99
{
1010
internal class HeaderInfo
1111
{
12-
private readonly List<ColumnInfo> _columns = new List<ColumnInfo>();
12+
private readonly List<ColumnInfo> _columns = new();
1313

1414
internal void AddColumn(ColumnInfo col)
1515
{
@@ -18,7 +18,7 @@ internal void AddColumn(ColumnInfo col)
1818

1919
internal PSObject AddColumnsToWindow(OutWindowProxy windowProxy, PSObject liveObject)
2020
{
21-
PSObject staleObject = new PSObject();
21+
PSObject staleObject = new();
2222

2323
// Initiate arrays to be of the same size.
2424
int count = _columns.Count;
@@ -47,7 +47,7 @@ internal PSObject AddColumnsToWindow(OutWindowProxy windowProxy, PSObject liveOb
4747

4848
internal PSObject CreateStalePSObject(PSObject liveObject)
4949
{
50-
PSObject staleObject = new PSObject();
50+
PSObject staleObject = new();
5151
foreach (ColumnInfo column in _columns)
5252
{
5353
// Add a property to the stale PSObject.

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/OutGridViewCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ protected override void StopProcessing()
212212
/// <param name="liveObject">PSObject to be converted to a string.</param>
213213
internal string ConvertToString(PSObject liveObject)
214214
{
215-
StringFormatError formatErrorObject = new StringFormatError();
215+
StringFormatError formatErrorObject = new();
216216
string smartToString = PSObjectHelper.SmartToString(liveObject,
217217
_expressionFactory,
218218
InnerFormatShapeCommand.FormatEnumerationLimit(),
@@ -265,7 +265,7 @@ baseObject is PSReference ||
265265
baseObject is FormatInfoData ||
266266
baseObject is PSObject)
267267
{
268-
ErrorRecord error = new ErrorRecord(
268+
ErrorRecord error = new(
269269
new FormatException(StringUtil.Format(FormatAndOut_out_gridview.DataNotQualifiedForGridView)),
270270
DataNotQualifiedForGridView,
271271
ErrorCategory.InvalidType,
@@ -289,7 +289,7 @@ baseObject is FormatInfoData ||
289289
Exception exception = _windowProxy.GetLastException();
290290
if (exception != null)
291291
{
292-
ErrorRecord error = new ErrorRecord(
292+
ErrorRecord error = new(
293293
exception,
294294
"ManagementListInvocationException",
295295
ErrorCategory.OperationStopped,
@@ -357,7 +357,7 @@ internal class NonscalarTypeHeader : GridHeader
357357
internal NonscalarTypeHeader(OutGridViewCommand parentCmd, PSObject input) : base(parentCmd)
358358
{
359359
// Prepare a table view.
360-
TableView tableView = new TableView();
360+
TableView tableView = new();
361361
tableView.Initialize(parentCmd._expressionFactory, parentCmd._typeInfoDataBase);
362362

363363
// Request a view definition from the type database.

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/OutGridView/TableView.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal void Initialize(PSPropertyExpressionFactory expressionFactory,
2525
_typeInfoDatabase = db;
2626

2727
// Initialize Format Error Manager.
28-
FormatErrorPolicy formatErrorPolicy = new FormatErrorPolicy();
28+
FormatErrorPolicy formatErrorPolicy = new();
2929

3030
formatErrorPolicy.ShowErrorsAsMessages = _typeInfoDatabase.defaultSettingsSection.formatErrorPolicy.ShowErrorsAsMessages;
3131
formatErrorPolicy.ShowErrorsInFormattedOutput = _typeInfoDatabase.defaultSettingsSection.formatErrorPolicy.ShowErrorsInFormattedOutput;
@@ -35,7 +35,7 @@ internal void Initialize(PSPropertyExpressionFactory expressionFactory,
3535

3636
internal HeaderInfo GenerateHeaderInfo(PSObject input, TableControlBody tableBody, OutGridViewCommand parentCmdlet)
3737
{
38-
HeaderInfo headerInfo = new HeaderInfo();
38+
HeaderInfo headerInfo = new();
3939

4040
// This verification is needed because the database returns "LastWriteTime" value for file system objects
4141
// as strings and it is used to detect this situation and use the actual field value.
@@ -124,7 +124,7 @@ internal HeaderInfo GenerateHeaderInfo(PSObject input, TableControlBody tableBod
124124

125125
internal HeaderInfo GenerateHeaderInfo(PSObject input, OutGridViewCommand parentCmdlet)
126126
{
127-
HeaderInfo headerInfo = new HeaderInfo();
127+
HeaderInfo headerInfo = new();
128128
List<MshResolvedExpressionParameterAssociation> activeAssociationList;
129129

130130
// Get properties from the default property set of the object
@@ -201,7 +201,7 @@ private static void FilterActiveAssociationList(List<MshResolvedExpressionParame
201201

202202
if (activeAssociationList.Count > nMax)
203203
{
204-
List<MshResolvedExpressionParameterAssociation> tmp = new List<MshResolvedExpressionParameterAssociation>(activeAssociationList);
204+
List<MshResolvedExpressionParameterAssociation> tmp = new(activeAssociationList);
205205
activeAssociationList.Clear();
206206
for (int k = 0; k < nMax; k++)
207207
activeAssociationList.Add(tmp[k]);
@@ -222,7 +222,7 @@ private List<TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBod
222222
TableRowDefinition matchingRowDefinition = null;
223223

224224
var typeNames = so.InternalTypeNames;
225-
TypeMatch match = new TypeMatch(_expressionFactory, _typeInfoDatabase, typeNames);
225+
TypeMatch match = new(_expressionFactory, _typeInfoDatabase, typeNames);
226226

227227
foreach (TableRowDefinition x in tableBody.optionalDefinitionList)
228228
{
@@ -268,7 +268,7 @@ private List<TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBod
268268
}
269269

270270
// we have an override, we need to compute the merge of the active cells
271-
List<TableRowItemDefinition> activeRowItemDefinitionList = new List<TableRowItemDefinition>();
271+
List<TableRowItemDefinition> activeRowItemDefinitionList = new();
272272
int col = 0;
273273
foreach (TableRowItemDefinition rowItem in matchingRowDefinition.rowItemDefinitionList)
274274
{

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/common/WriteFormatDataCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public string LiteralPath
7474

7575
private bool _isLiteralPath = false;
7676

77-
private readonly List<ExtendedTypeDefinition> _typeDefinitions = new List<ExtendedTypeDefinition>();
77+
private readonly List<ExtendedTypeDefinition> _typeDefinitions = new();
7878

7979
private bool _force;
8080

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-hex/Format-Hex.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public sealed class FormatHex : PSCmdlet
2727
/// For cases where a homogenous collection of bytes or other items are directly piped in, we collect all the
2828
/// bytes in a List&lt;byte&gt; and then output the formatted result all at once in EndProcessing().
2929
/// </summary>
30-
private readonly List<byte> _inputBuffer = new List<byte>();
30+
private readonly List<byte> _inputBuffer = new();
3131

3232
/// <summary>
3333
/// Expect to group <see cref="InputObject"/>s by default. When receiving input that should not be grouped,
@@ -153,12 +153,12 @@ protected override void EndProcessing()
153153
/// <returns></returns>
154154
private List<string> ResolvePaths(string[] path, bool literalPath)
155155
{
156-
List<string> pathsToProcess = new List<string>();
156+
List<string> pathsToProcess = new();
157157
ProviderInfo provider = null;
158158

159159
foreach (string currentPath in path)
160160
{
161-
List<string> newPaths = new List<string>();
161+
List<string> newPaths = new();
162162

163163
if (literalPath)
164164
{
@@ -174,7 +174,7 @@ private List<string> ResolvePaths(string[] path, bool literalPath)
174174
{
175175
if (!WildcardPattern.ContainsWildcardCharacters(currentPath))
176176
{
177-
ErrorRecord errorRecord = new ErrorRecord(e, "FileNotFound", ErrorCategory.ObjectNotFound, path);
177+
ErrorRecord errorRecord = new(e, "FileNotFound", ErrorCategory.ObjectNotFound, path);
178178
WriteError(errorRecord);
179179
continue;
180180
}
@@ -185,7 +185,7 @@ private List<string> ResolvePaths(string[] path, bool literalPath)
185185
{
186186
// Write a non-terminating error message indicating that path specified is not supported.
187187
string errorMessage = StringUtil.Format(UtilityCommonStrings.FormatHexOnlySupportsFileSystemPaths, currentPath);
188-
ErrorRecord errorRecord = new ErrorRecord(
188+
ErrorRecord errorRecord = new(
189189
new ArgumentException(errorMessage),
190190
"FormatHexOnlySupportsFileSystemPaths",
191191
ErrorCategory.InvalidArgument,
@@ -293,7 +293,7 @@ private void ProcessString(string originalString)
293293
}
294294
}
295295

296-
private static readonly Random _idGenerator = new Random();
296+
private static readonly Random _idGenerator = new();
297297

298298
private static string GetGroupLabel(Type inputType)
299299
=> string.Format("{0} ({1}) <{2:X8}>", inputType.Name, inputType.FullName, _idGenerator.Next());
@@ -370,7 +370,7 @@ private void ProcessInputObjects(PSObject inputObject)
370370
else
371371
{
372372
string errorMessage = StringUtil.Format(UtilityCommonStrings.FormatHexTypeNotSupported, obj.GetType());
373-
ErrorRecord errorRecord = new ErrorRecord(
373+
ErrorRecord errorRecord = new(
374374
new ArgumentException(errorMessage),
375375
"FormatHexTypeNotSupported",
376376
ErrorCategory.InvalidArgument,

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-object/Format-Object.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public int Depth
5858

5959
internal override FormattingCommandLineParameters GetCommandLineParameters()
6060
{
61-
FormattingCommandLineParameters parameters = new FormattingCommandLineParameters();
61+
FormattingCommandLineParameters parameters = new();
6262

6363
if (_props != null)
6464
{
65-
ParameterProcessor processor = new ParameterProcessor(new FormatObjectParameterDefinition());
66-
TerminatingErrorContext invocationContext = new TerminatingErrorContext(this);
65+
ParameterProcessor processor = new(new FormatObjectParameterDefinition());
66+
TerminatingErrorContext invocationContext = new(this);
6767
parameters.mshParameterList = processor.ProcessParameters(_props, invocationContext);
6868
}
6969

@@ -87,7 +87,7 @@ internal override FormattingCommandLineParameters GetCommandLineParameters()
8787

8888
parameters.expansion = ProcessExpandParameter();
8989

90-
ComplexSpecificParameters csp = new ComplexSpecificParameters();
90+
ComplexSpecificParameters csp = new();
9191
csp.maxDepth = _depth;
9292
parameters.shapeParameters = csp;
9393

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/format-wide/Format-Wide.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ public int Column
8383

8484
internal override FormattingCommandLineParameters GetCommandLineParameters()
8585
{
86-
FormattingCommandLineParameters parameters = new FormattingCommandLineParameters();
86+
FormattingCommandLineParameters parameters = new();
8787

8888
if (_prop != null)
8989
{
90-
ParameterProcessor processor = new ParameterProcessor(new FormatWideParameterDefinition());
91-
TerminatingErrorContext invocationContext = new TerminatingErrorContext(this);
90+
ParameterProcessor processor = new(new FormatWideParameterDefinition());
91+
TerminatingErrorContext invocationContext = new(this);
9292
parameters.mshParameterList = processor.ProcessParameters(new object[] { _prop }, invocationContext);
9393
}
9494

@@ -111,7 +111,7 @@ internal override FormattingCommandLineParameters GetCommandLineParameters()
111111
// the user specified -autosize:true AND a column number
112112
string msg = StringUtil.Format(FormatAndOut_format_xxx.CannotSpecifyAutosizeAndColumnsError);
113113

114-
ErrorRecord errorRecord = new ErrorRecord(
114+
ErrorRecord errorRecord = new(
115115
new InvalidDataException(),
116116
"FormatCannotSpecifyAutosizeAndColumns",
117117
ErrorCategory.InvalidArgument,
@@ -134,7 +134,7 @@ internal override FormattingCommandLineParameters GetCommandLineParameters()
134134
if (_autosize.HasValue)
135135
parameters.autosize = _autosize.Value;
136136

137-
WideSpecificParameters wideSpecific = new WideSpecificParameters();
137+
WideSpecificParameters wideSpecific = new();
138138
parameters.shapeParameters = wideSpecific;
139139
if (_column.HasValue)
140140
{

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-file/Out-File.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ private LineOutput InstantiateLineOutputInterface()
228228
}
229229

230230
// use the stream writer to create and initialize the Line Output writer
231-
TextWriterLineOutput twlo = new TextWriterLineOutput(_sw, computedWidth, _suppressNewline);
231+
TextWriterLineOutput twlo = new(_sw, computedWidth, _suppressNewline);
232232

233233
// finally have the ILineOutput interface extracted
234234
return (LineOutput)twlo;

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/Out-Printer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected override void BeginProcessing()
5656
/// </summary>
5757
private LineOutput InstantiateLineOutputInterface()
5858
{
59-
PrinterLineOutput printOutput = new PrinterLineOutput(_printerName);
59+
PrinterLineOutput printOutput = new(_printerName);
6060
return (LineOutput)printOutput;
6161
}
6262
}

src/Microsoft.PowerShell.Commands.Utility/commands/utility/FormatAndOutput/out-printer/PrinterLineOutput.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ internal PrinterLineOutput(string printerName)
9090
_printerName = printerName;
9191

9292
// instantiate the helper to do the line processing when LineOutput.WriteXXX() is called
93-
WriteLineHelper.WriteCallback wl = new WriteLineHelper.WriteCallback(this.OnWriteLine);
94-
WriteLineHelper.WriteCallback w = new WriteLineHelper.WriteCallback(this.OnWrite);
93+
WriteLineHelper.WriteCallback wl = new(this.OnWriteLine);
94+
WriteLineHelper.WriteCallback w = new(this.OnWrite);
9595

9696
_writeLineHelper = new WriteLineHelper(true, wl, w, this.DisplayCells);
9797
}
@@ -124,7 +124,7 @@ private void DoPrint()
124124
try
125125
{
126126
// create a new print document object and set the printer name, if available
127-
PrintDocument pd = new PrintDocument();
127+
PrintDocument pd = new();
128128

129129
if (!string.IsNullOrEmpty(_printerName))
130130
{
@@ -316,7 +316,7 @@ private void pd_PrintPage(object sender, PrintPageEventArgs ev)
316316
/// <summary>
317317
/// Text lines ready to print (after output cache playback).
318318
/// </summary>
319-
private readonly Queue<string> _lines = new Queue<string>();
319+
private readonly Queue<string> _lines = new();
320320

321321
/// <summary>
322322
/// Cached font object.

0 commit comments

Comments
 (0)