mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix IDE0090: Simplify new expression part 4.3 (#14257)
https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0090
This commit is contained in:
+1
-1
@@ -87,7 +87,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
}
|
||||
|
||||
private readonly StringBuilder _cachedWrite = new StringBuilder();
|
||||
private readonly StringBuilder _cachedWrite = new();
|
||||
|
||||
/// <summary>
|
||||
/// Sends the given output string to the host for processing.
|
||||
|
||||
+3
-3
@@ -56,7 +56,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
notMatched = new Collection<string>();
|
||||
|
||||
Collection<PSTraceSource> results = new Collection<PSTraceSource>();
|
||||
Collection<PSTraceSource> results = new();
|
||||
foreach (string patternToMatch in patternsToMatch)
|
||||
{
|
||||
bool matchFound = false;
|
||||
@@ -102,12 +102,12 @@ namespace Microsoft.PowerShell.Commands
|
||||
!WildcardPattern.ContainsWildcardCharacters(patternToMatch))
|
||||
{
|
||||
ItemNotFoundException itemNotFound =
|
||||
new ItemNotFoundException(
|
||||
new(
|
||||
patternToMatch,
|
||||
"TraceSourceNotFound",
|
||||
SessionStateStrings.TraceSourceNotFound);
|
||||
|
||||
ErrorRecord errorRecord = new ErrorRecord(itemNotFound.ErrorRecord, itemNotFound);
|
||||
ErrorRecord errorRecord = new(itemNotFound.ErrorRecord, itemNotFound);
|
||||
WriteError(errorRecord);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -541,6 +541,6 @@ namespace Microsoft.PowerShell.Commands
|
||||
private readonly TraceListenerCommandBase _cmdlet;
|
||||
private readonly bool _writeError;
|
||||
private bool _isOpen = true;
|
||||
private readonly Collection<PSTraceSource> _matchingSources = new Collection<PSTraceSource>();
|
||||
private readonly Collection<PSTraceSource> _matchingSources = new();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -229,7 +229,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
try
|
||||
{
|
||||
Collection<string> resolvedPaths = new Collection<string>();
|
||||
Collection<string> resolvedPaths = new();
|
||||
try
|
||||
{
|
||||
// Resolve the file path
|
||||
@@ -287,7 +287,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
if (ForceWrite && System.IO.File.Exists(resolvedPath))
|
||||
{
|
||||
// remove readonly attributes on the file
|
||||
System.IO.FileInfo fInfo = new System.IO.FileInfo(resolvedPath);
|
||||
System.IO.FileInfo fInfo = new(resolvedPath);
|
||||
if (fInfo != null)
|
||||
{
|
||||
// Save some disk write time by checking whether file is readonly..
|
||||
@@ -300,13 +300,13 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
// Trace commands always append..So there is no need to set overwrite with force..
|
||||
FileStream fileStream = new FileStream(resolvedPath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
|
||||
FileStream fileStream = new(resolvedPath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
|
||||
FileStreams.Add(fileStream);
|
||||
|
||||
// Open the file stream
|
||||
|
||||
TextWriterTraceListener fileListener =
|
||||
new TextWriterTraceListener(fileStream, resolvedPath);
|
||||
new(fileStream, resolvedPath);
|
||||
|
||||
fileListener.Name = FileListener;
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
if (fileOpenError != null)
|
||||
{
|
||||
ErrorRecord errorRecord =
|
||||
new ErrorRecord(
|
||||
new(
|
||||
fileOpenError,
|
||||
"FileListenerPathResolutionFailed",
|
||||
ErrorCategory.OpenError,
|
||||
@@ -353,7 +353,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
if (error != null)
|
||||
{
|
||||
ErrorRecord errorRecord =
|
||||
new ErrorRecord(
|
||||
new(
|
||||
error,
|
||||
"FileListenerPathResolutionFailed",
|
||||
ErrorCategory.InvalidArgument,
|
||||
@@ -491,7 +491,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
// Copy the listeners into a different collection
|
||||
|
||||
Collection<TraceListener> listenerCollection = new Collection<TraceListener>();
|
||||
Collection<TraceListener> listenerCollection = new();
|
||||
foreach (TraceListener listener in source.Listeners)
|
||||
{
|
||||
listenerCollection.Add(listener);
|
||||
@@ -596,7 +596,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
|
||||
private readonly Dictionary<PSTraceSource, KeyValuePair<PSTraceSourceOptions, Collection<TraceListener>>> _storedTraceSourceState =
|
||||
new Dictionary<PSTraceSource, KeyValuePair<PSTraceSourceOptions, Collection<TraceListener>>>();
|
||||
new();
|
||||
|
||||
#endregion stored state
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user