Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal static class CommonUtilities
//
public static string StringArrayToString(IEnumerable input)
{
string ret = "";
string ret = string.Empty;
foreach (string element in input)
{
ret += element + ", ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public string Path
get { return _path; }
set { _path = value; }
}
private string _path = "";
private string _path = string.Empty;

public string InstanceName
{
get { return _instanceName; }
set { _instanceName = value; }
}
private string _instanceName = "";
private string _instanceName = string.Empty;

public double CookedValue
{
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.PowerShell.Commands.Diagnostics/CounterSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public string CounterSetName
return _counterSetName;
}
}
private string _counterSetName = "";
private string _counterSetName = string.Empty;

public string MachineName
{
Expand All @@ -70,7 +70,7 @@ public string Description
return _description;
}
}
private string _description = "";
private string _description = string.Empty;

internal Dictionary<string, string[]> CounterInstanceMapping
{
Expand Down
38 changes: 19 additions & 19 deletions src/Microsoft.PowerShell.Commands.Diagnostics/GetEventCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ private EventLogSession CreateSession()
//
// Force the destruction of cached password
//
netCred.Password = "";
netCred.Password = string.Empty;

return eventLogSession;
}
Expand Down Expand Up @@ -973,12 +973,12 @@ private string BuildStructuredQuery(EventLogSession eventLogSession)
//
private string BuildXPathFromHashTable(Hashtable hash)
{
StringBuilder xpathString = new StringBuilder("");
StringBuilder xpathString = new StringBuilder(string.Empty);
bool bDateTimeHandled = false;

foreach (string key in hash.Keys)
{
string added = "";
string added = string.Empty;

switch (key.ToLowerInvariant())
{
Expand Down Expand Up @@ -1062,16 +1062,16 @@ private string BuildXPathFromHashTable(Hashtable hash)
//
private string BuildStructuredQueryFromHashTable(EventLogSession eventLogSession)
{
StringBuilder result = new StringBuilder("");
StringBuilder result = new StringBuilder(string.Empty);

result.Append(queryListOpen);

uint queryId = 0;

foreach (Hashtable hash in _selector)
{
string xpathString = "";
string xpathStringSuppress = "";
string xpathString = string.Empty;
string xpathStringSuppress = string.Empty;

CheckHashTableForQueryPathPresence(hash);

Expand Down Expand Up @@ -1378,7 +1378,7 @@ private string HandleKeywordHashValue(Object value)
{
if (!KeywordStringToInt64(value.ToString(), ref keywordLong))
{
return "";
return string.Empty;
}
keywordsMask |= keywordLong;
}
Expand Down Expand Up @@ -1416,7 +1416,7 @@ private string HandleContextHashValue(Object value)
string msg = string.Format(CultureInfo.InvariantCulture, _resourceMgr.GetString("InvalidContext"), value.ToString());
Exception outerExc = new Exception(msg, exc);
WriteError(new ErrorRecord(outerExc, "InvalidContext", ErrorCategory.InvalidArgument, null));
return "";
return string.Empty;
}
}

Expand All @@ -1434,7 +1434,7 @@ private string HandleStartTimeHashValue(Object value, Hashtable hash)
DateTime startTime = new DateTime();
if (!StringToDateTime(value.ToString(), ref startTime))
{
return "";
return string.Empty;
}

startTime = startTime.ToUniversalTime();
Expand All @@ -1445,7 +1445,7 @@ private string HandleStartTimeHashValue(Object value, Hashtable hash)
DateTime endTime = new DateTime();
if (!StringToDateTime(hash[hashkey_endtime_lc].ToString(), ref endTime))
{
return "";
return string.Empty;
}

endTime = endTime.ToUniversalTime();
Expand Down Expand Up @@ -1477,7 +1477,7 @@ private string HandleEndTimeHashValue(Object value, Hashtable hash)
DateTime endTime = new DateTime();
if (!StringToDateTime(value.ToString(), ref endTime))
{
return "";
return string.Empty;
}

endTime = endTime.ToUniversalTime();
Expand All @@ -1489,7 +1489,7 @@ private string HandleEndTimeHashValue(Object value, Hashtable hash)
DateTime startTime = new DateTime();
if (!StringToDateTime(hash[hashkey_starttime_lc].ToString(), ref startTime))
{
return "";
return string.Empty;
}

startTime = startTime.ToUniversalTime();
Expand Down Expand Up @@ -1709,27 +1709,27 @@ private StringCollection ValidateAndResolveFilePath(string path)
}
catch (PSNotSupportedException notSupported)
{
WriteError(new ErrorRecord(notSupported, "", ErrorCategory.ObjectNotFound, path));
WriteError(new ErrorRecord(notSupported, string.Empty, ErrorCategory.ObjectNotFound, path));
return retColl;
}
catch (System.Management.Automation.DriveNotFoundException driveNotFound)
{
WriteError(new ErrorRecord(driveNotFound, "", ErrorCategory.ObjectNotFound, path));
WriteError(new ErrorRecord(driveNotFound, string.Empty, ErrorCategory.ObjectNotFound, path));
return retColl;
}
catch (ProviderNotFoundException providerNotFound)
{
WriteError(new ErrorRecord(providerNotFound, "", ErrorCategory.ObjectNotFound, path));
WriteError(new ErrorRecord(providerNotFound, string.Empty, ErrorCategory.ObjectNotFound, path));
return retColl;
}
catch (ItemNotFoundException pathNotFound)
{
WriteError(new ErrorRecord(pathNotFound, "", ErrorCategory.ObjectNotFound, path));
WriteError(new ErrorRecord(pathNotFound, string.Empty, ErrorCategory.ObjectNotFound, path));
return retColl;
}
catch (Exception exc)
{
WriteError(new ErrorRecord(exc, "", ErrorCategory.ObjectNotFound, path));
WriteError(new ErrorRecord(exc, string.Empty, ErrorCategory.ObjectNotFound, path));
return retColl;
}

Expand Down Expand Up @@ -1859,7 +1859,7 @@ private string BuildProvidersPredicate(StringCollection providers)
{
if (providers.Count == 0)
{
return "";
return string.Empty;
}

StringBuilder predicate = new StringBuilder("System/Provider[");
Expand Down Expand Up @@ -1887,7 +1887,7 @@ private string BuildAllProvidersPredicate()
{
if (_providersByLogMap.Count == 0)
{
return "";
return string.Empty;
}

StringBuilder predicate = new StringBuilder("System/Provider[");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,27 +568,27 @@ private bool ResolveFilePaths()
}
catch (PSNotSupportedException notSupported)
{
WriteError(new ErrorRecord(notSupported, "", ErrorCategory.ObjectNotFound, origPath));
WriteError(new ErrorRecord(notSupported, string.Empty, ErrorCategory.ObjectNotFound, origPath));
continue;
}
catch (System.Management.Automation.DriveNotFoundException driveNotFound)
{
WriteError(new ErrorRecord(driveNotFound, "", ErrorCategory.ObjectNotFound, origPath));
WriteError(new ErrorRecord(driveNotFound, string.Empty, ErrorCategory.ObjectNotFound, origPath));
continue;
}
catch (ProviderNotFoundException providerNotFound)
{
WriteError(new ErrorRecord(providerNotFound, "", ErrorCategory.ObjectNotFound, origPath));
WriteError(new ErrorRecord(providerNotFound, string.Empty, ErrorCategory.ObjectNotFound, origPath));
continue;
}
catch (ItemNotFoundException pathNotFound)
{
WriteError(new ErrorRecord(pathNotFound, "", ErrorCategory.ObjectNotFound, origPath));
WriteError(new ErrorRecord(pathNotFound, string.Empty, ErrorCategory.ObjectNotFound, origPath));
continue;
}
catch (Exception exc)
{
WriteError(new ErrorRecord(exc, "", ErrorCategory.ObjectNotFound, origPath));
WriteError(new ErrorRecord(exc, string.Empty, ErrorCategory.ObjectNotFound, origPath));
continue;
}

Expand Down
12 changes: 6 additions & 6 deletions src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ private void ReadPdhMultiString(ref IntPtr strNative, Int32 strSize, ref StringC
{
Debug.Assert(strSize >= 2);
int offset = 0;
string allSubstringsWithNulls = "";
string allSubstringsWithNulls = string.Empty;
while (offset <= ((strSize * sizeof(char)) - 4))
{
Int32 next4 = Marshal.ReadInt32(strNative, offset);
Expand Down Expand Up @@ -580,7 +580,7 @@ public uint ConnectToDataSource(StringCollection blgFileNames)
return ConnectToDataSource(blgFileNames[0]);
}

string doubleNullTerminated = "";
string doubleNullTerminated = string.Empty;
foreach (string fileName in blgFileNames)
{
doubleNullTerminated += fileName + '\0';
Expand Down Expand Up @@ -826,7 +826,7 @@ public uint GetValidPathsFromFiles(ref StringCollection validPaths)
private bool IsPathValid(ref PDH_COUNTER_PATH_ELEMENTS pathElts, out string outPath)
{
bool ret = false;
outPath = "";
outPath = string.Empty;
IntPtr pPathBufferSize = new IntPtr(0);

uint res = PdhMakeCounterPath(ref pathElts, IntPtr.Zero, ref pPathBufferSize, 0);
Expand Down Expand Up @@ -880,7 +880,7 @@ public bool IsPathValid(string path)

private uint MakePath(PDH_COUNTER_PATH_ELEMENTS pathElts, out string outPath, bool bWildcardInstances)
{
outPath = "";
outPath = string.Empty;
IntPtr pPathBufferSize = new IntPtr(0);

if (bWildcardInstances)
Expand Down Expand Up @@ -984,7 +984,7 @@ private uint ParsePath(string fullPath, ref PDH_COUNTER_PATH_ELEMENTS pCounterPa
public uint TranslateLocalCounterPath(string englishPath, out string localizedPath)
{
uint res = 0;
localizedPath = "";
localizedPath = string.Empty;
PDH_COUNTER_PATH_ELEMENTS pathElts = new PDH_COUNTER_PATH_ELEMENTS();
res = ParsePath(englishPath, ref pathElts);
if (res != 0)
Expand Down Expand Up @@ -1077,7 +1077,7 @@ public uint LookupPerfNameByIndex(string machineName, uint index, out string loc

int strSize = 256;
IntPtr localizedPathPtr = Marshal.AllocHGlobal(strSize * sizeof(char));
locName = "";
locName = string.Empty;
uint res = 0;
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public Int16 Delay
private readonly string _shortLocalMachineName = Dns.GetHostName();

// And for this, use PsUtils.GetHostname()
private readonly string _fullLocalMachineName = Dns.GetHostEntryAsync("").Result.HostName;
private readonly string _fullLocalMachineName = Dns.GetHostEntryAsync(string.Empty).Result.HostName;

private int _percent;
private string _status;
Expand Down Expand Up @@ -1269,7 +1269,7 @@ public class RenameComputerCommand : PSCmdlet
private string _newNameForLocalHost = null;

private readonly string _shortLocalMachineName = Dns.GetHostName();
private readonly string _fullLocalMachineName = Dns.GetHostEntryAsync("").Result.HostName;
private readonly string _fullLocalMachineName = Dns.GetHostEntryAsync(string.Empty).Result.HostName;

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private bool IsServerCoreOrHeadLessServer()
{
Dbg.Assert(installation != null, "the CurrentVersion subkey should exist");

string installationType = (string)installation.GetValue("InstallationType", "");
string installationType = (string)installation.GetValue("InstallationType", string.Empty);

if (installationType.Equals("Server Core"))
{
Expand Down Expand Up @@ -429,7 +429,7 @@ internal List<ShellFolderItem> GetControlPanelItemByCanonicalName(List<ShellFold
string errMsg = withCategoryFilter
? ControlPanelResources.NoControlPanelItemFoundWithNullCanonicalNameWithCategory
: ControlPanelResources.NoControlPanelItemFoundWithNullCanonicalName;
ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), "",
ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), string.Empty,
ErrorCategory.InvalidArgument, CanonicalNames);
WriteError(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ private void Process(EventLog log)
}
if (!matchesfound && _isThrowError)
{
Exception Ex = new ArgumentException(StringUtil.Format(EventlogResources.NoEntriesFound, log.Log, ""));
Exception Ex = new ArgumentException(StringUtil.Format(EventlogResources.NoEntriesFound, log.Log, string.Empty));
WriteError(new ErrorRecord(Ex, "GetEventLogNoEntriesFound", ErrorCategory.ObjectNotFound, null));
}
}
Expand Down Expand Up @@ -1372,7 +1372,7 @@ protected override void BeginProcessing()
}
else
{
ErrorRecord er = new ErrorRecord(new InvalidOperationException(StringUtil.Format(EventlogResources.SourceDoesNotExist, "", computer, src)), null, ErrorCategory.InvalidOperation, null);
ErrorRecord er = new ErrorRecord(new InvalidOperationException(StringUtil.Format(EventlogResources.SourceDoesNotExist, string.Empty, computer, src)), null, ErrorCategory.InvalidOperation, null);
WriteError(er);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ internal void WriteNonTerminatingError(
string message = StringUtil.Format(resourceId,
processName,
processId,
(null == innerException) ? "" : innerException.Message);
(null == innerException) ? string.Empty : innerException.Message);
ProcessCommandException exception =
new ProcessCommandException(message, innerException);
exception.ProcessName = processName;
Expand All @@ -366,11 +366,11 @@ internal static string SafeGetProcessName(Process process)
}
catch (Win32Exception)
{
return "";
return string.Empty;
}
catch (InvalidOperationException)
{
return "";
return string.Empty;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ private bool NeedToEnablePrivilege(string computer, string methodName, ref bool
string localName = System.Net.Dns.GetHostName();

// And for this, use PsUtils.GetHostname()
string localFullName = System.Net.Dns.GetHostEntry("").HostName;
string localFullName = System.Net.Dns.GetHostEntry(string.Empty).HostName;
if (computer.Equals(".") || computer.Equals("localhost", StringComparison.OrdinalIgnoreCase) ||
computer.Equals(localName, StringComparison.OrdinalIgnoreCase) ||
computer.Equals(localFullName, StringComparison.OrdinalIgnoreCase))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,13 +725,13 @@ protected override
}
//Write property information
string properties = _helper.ConvertPropertyNamesCSV(_propertyNames);
if (!properties.Equals(""))
if (!properties.Equals(string.Empty))
WriteCsvLine(properties);
}

string csv = _helper.ConvertPSObjectToCSV(InputObject, _propertyNames);
//write to the console
if (csv != "")
if (csv != string.Empty)
WriteCsvLine(csv);
}

Expand Down Expand Up @@ -1539,7 +1539,7 @@ private Collection<string>
bool
IsNewLine(char ch, out string newLine)
{
newLine = "";
newLine = string.Empty;
if (ch == '\r')
{
if (PeekNextChar('\n'))
Expand All @@ -1557,7 +1557,7 @@ private Collection<string>
newLine = "\n";
}

return newLine != "";
return newLine != string.Empty;
}

/// <summary>
Expand Down
Loading