Skip to content

Commit

Permalink
Use nameof() in LocationGlobber and PathInfo (#10200)
Browse files Browse the repository at this point in the history
* Use nameof() in LocationGlobber
* Use nameof() in PathInfo
  • Loading branch information
iSazonov committed Jul 24, 2019
1 parent 6b2690e commit 500595b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
92 changes: 46 additions & 46 deletions src/System.Management.Automation/namespaces/LocationGlobber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal LocationGlobber(SessionState sessionState)
{
if (sessionState == null)
{
throw PSTraceSource.NewArgumentNullException("sessionState");
throw PSTraceSource.NewArgumentNullException(nameof(sessionState));
}

_sessionState = sessionState;
Expand Down Expand Up @@ -174,12 +174,12 @@ internal LocationGlobber(SessionState sessionState)
providerInstance = null;
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (context == null)
{
throw PSTraceSource.NewArgumentNullException("context");
throw PSTraceSource.NewArgumentNullException(nameof(context));
}

Collection<PathInfo> result;
Expand Down Expand Up @@ -663,7 +663,7 @@ out providerInstance
providerInstance = null;
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

CmdletProviderContext context =
Expand Down Expand Up @@ -738,12 +738,12 @@ out providerInstance
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (context == null)
{
throw PSTraceSource.NewArgumentNullException("context");
throw PSTraceSource.NewArgumentNullException(nameof(context));
}

using (s_pathResolutionTracer.TraceScope("Resolving MSH path \"{0}\" to PROVIDER-INTERNAL path", path))
Expand Down Expand Up @@ -849,7 +849,7 @@ out providerInstance

if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

CmdletProviderContext context =
Expand Down Expand Up @@ -935,17 +935,17 @@ out providerInstance

if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (providerId == null)
{
throw PSTraceSource.NewArgumentNullException("providerId");
throw PSTraceSource.NewArgumentNullException(nameof(providerId));
}

if (context == null)
{
throw PSTraceSource.NewArgumentNullException("context");
throw PSTraceSource.NewArgumentNullException(nameof(context));
}

using (s_pathResolutionTracer.TraceScope("Resolving PROVIDER-INTERNAL path \"{0}\" to PROVIDER-INTERNAL path", path))
Expand Down Expand Up @@ -1057,7 +1057,7 @@ internal string GetProviderPath(string path, out ProviderInfo provider)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

CmdletProviderContext context =
Expand Down Expand Up @@ -1129,7 +1129,7 @@ internal string GetProviderPath(string path, CmdletProviderContext context)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

PSDriveInfo drive = null;
Expand Down Expand Up @@ -1217,12 +1217,12 @@ internal string GetProviderPath(string path, CmdletProviderContext context)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (context == null)
{
throw PSTraceSource.NewArgumentNullException("context");
throw PSTraceSource.NewArgumentNullException(nameof(context));
}

string result = null;
Expand Down Expand Up @@ -1374,7 +1374,7 @@ internal static bool IsProviderQualifiedPath(string path, out string providerId)

if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

providerId = null;
Expand Down Expand Up @@ -1472,7 +1472,7 @@ internal static bool IsAbsolutePath(string path)

if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

bool result = false;
Expand Down Expand Up @@ -1561,7 +1561,7 @@ internal bool IsAbsolutePath(string path, out string driveName)

if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

bool result = false;
Expand Down Expand Up @@ -1672,7 +1672,7 @@ private static string RemoveGlobEscaping(string path)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

string result = WildcardPattern.Unescape(path);
Expand Down Expand Up @@ -1714,7 +1714,7 @@ internal bool IsShellVirtualDrive(string driveName, out SessionStateScope scope)
{
if (driveName == null)
{
throw PSTraceSource.NewArgumentNullException("driveName");
throw PSTraceSource.NewArgumentNullException(nameof(driveName));
}

bool result = false;
Expand Down Expand Up @@ -1817,7 +1817,7 @@ internal bool IsShellVirtualDrive(string driveName, out SessionStateScope scope)

if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

workingDriveForPath = null;
Expand Down Expand Up @@ -2048,12 +2048,12 @@ CmdletProviderContext context

if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (drive == null)
{
throw PSTraceSource.NewArgumentNullException("drive");
throw PSTraceSource.NewArgumentNullException(nameof(drive));
}

// This string will be filled in with the
Expand Down Expand Up @@ -2321,12 +2321,12 @@ private bool HasRelativePathTokens(string path)
{
if (drive == null)
{
throw PSTraceSource.NewArgumentNullException("drive");
throw PSTraceSource.NewArgumentNullException(nameof(drive));
}

if (workingPath == null)
{
throw PSTraceSource.NewArgumentNullException("workingPath");
throw PSTraceSource.NewArgumentNullException(nameof(workingPath));
}

// Trace the inputs
Expand Down Expand Up @@ -2380,7 +2380,7 @@ private static string ParseProviderPath(string path, out string providerId)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

int providerIdSeparatorIndex = path.IndexOf(StringLiterals.ProviderPathSeparator, StringComparison.Ordinal);
Expand Down Expand Up @@ -2459,17 +2459,17 @@ private static string ParseProviderPath(string path, out string providerId)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (containerProvider == null)
{
throw PSTraceSource.NewArgumentNullException("containerProvider");
throw PSTraceSource.NewArgumentNullException(nameof(containerProvider));
}

if (context == null)
{
throw PSTraceSource.NewArgumentNullException("context");
throw PSTraceSource.NewArgumentNullException(nameof(context));
}

Collection<string> expandedPaths =
Expand Down Expand Up @@ -2499,7 +2499,7 @@ internal static bool StringContainsGlobCharacters(string path)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

return WildcardPattern.ContainsWildcardCharacters(path);
Expand Down Expand Up @@ -2636,17 +2636,17 @@ internal static bool ShouldPerformGlobbing(string path, CmdletProviderContext co
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (provider == null)
{
throw PSTraceSource.NewArgumentNullException("provider");
throw PSTraceSource.NewArgumentNullException(nameof(provider));
}

if (drive == null)
{
throw PSTraceSource.NewArgumentNullException("drive");
throw PSTraceSource.NewArgumentNullException(nameof(drive));
}

s_tracer.WriteLine("path = {0}", path);
Expand Down Expand Up @@ -3061,12 +3061,12 @@ internal static string GetDriveQualifiedPath(string path, PSDriveInfo drive)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (drive == null)
{
throw PSTraceSource.NewArgumentNullException("drive");
throw PSTraceSource.NewArgumentNullException(nameof(drive));
}

string result = path;
Expand Down Expand Up @@ -3205,12 +3205,12 @@ internal static string GetProviderQualifiedPath(string path, ProviderInfo provid
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (provider == null)
{
throw PSTraceSource.NewArgumentNullException("provider");
throw PSTraceSource.NewArgumentNullException(nameof(provider));
}

string result = path;
Expand Down Expand Up @@ -3345,12 +3345,12 @@ internal static string RemoveProviderQualifier(string path)
{
if (currentDirs == null)
{
throw PSTraceSource.NewArgumentNullException("currentDirs");
throw PSTraceSource.NewArgumentNullException(nameof(currentDirs));
}

if (provider == null)
{
throw PSTraceSource.NewArgumentNullException("provider");
throw PSTraceSource.NewArgumentNullException(nameof(provider));
}

NavigationCmdletProvider navigationProvider = provider as NavigationCmdletProvider;
Expand Down Expand Up @@ -3579,12 +3579,12 @@ internal static string RemoveProviderQualifier(string path)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (provider == null)
{
throw PSTraceSource.NewArgumentNullException("provider");
throw PSTraceSource.NewArgumentNullException(nameof(provider));
}

// See if the provider wants to convert the path and filter
Expand Down Expand Up @@ -3951,12 +3951,12 @@ internal static string RemoveProviderQualifier(string path)
{
if (currentDirs == null)
{
throw PSTraceSource.NewArgumentNullException("currentDirs");
throw PSTraceSource.NewArgumentNullException(nameof(currentDirs));
}

if (provider == null)
{
throw PSTraceSource.NewArgumentNullException("provider");
throw PSTraceSource.NewArgumentNullException(nameof(provider));
}

NavigationCmdletProvider navigationProvider = provider as NavigationCmdletProvider;
Expand Down Expand Up @@ -4432,7 +4432,7 @@ private static string ConvertMshEscapeToRegexEscape(string path)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

const char mshEscapeChar = '`';
Expand Down Expand Up @@ -4522,7 +4522,7 @@ internal static bool IsHomePath(string path)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

bool result = false;
Expand Down Expand Up @@ -4571,7 +4571,7 @@ internal static bool IsProviderDirectPath(string path)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

return path.StartsWith(StringLiterals.DefaultRemotePathPrefix, StringComparison.Ordinal) ||
Expand Down Expand Up @@ -4611,7 +4611,7 @@ internal string GetHomeRelativePath(string path)
{
if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

string result = path;
Expand Down
6 changes: 3 additions & 3 deletions src/System.Management.Automation/namespaces/PathInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ internal PathInfo(PSDriveInfo drive, ProviderInfo provider, string path, Session
{
if (provider == null)
{
throw PSTraceSource.NewArgumentNullException("provider");
throw PSTraceSource.NewArgumentNullException(nameof(provider));
}

if (path == null)
{
throw PSTraceSource.NewArgumentNullException("path");
throw PSTraceSource.NewArgumentNullException(nameof(path));
}

if (sessionState == null)
{
throw PSTraceSource.NewArgumentNullException("sessionState");
throw PSTraceSource.NewArgumentNullException(nameof(sessionState));
}

_drive = drive;
Expand Down

0 comments on commit 500595b

Please sign in to comment.