Skip to content
Closed
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 @@ -84,7 +84,7 @@ protected TSession[] Session
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException();
}

_session = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ public class NewPSDriveCommand : CoreCommandWithCredentialsBase
public string Name
{
get => _name;
set => _name = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value));
set => _name = value ?? throw PSTraceSource.NewArgumentNullException();
}

/// <summary>
Expand All @@ -1100,7 +1100,7 @@ public string Name
public string PSProvider
{
get => _provider;
set => _provider = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value));
set => _provider = value ?? throw PSTraceSource.NewArgumentNullException();
}

/// <summary>
Expand All @@ -1112,7 +1112,7 @@ public string PSProvider
public string Root
{
get => _root;
set => _root = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value));
set => _root = value ?? throw PSTraceSource.NewArgumentNullException();
}

/// <summary>
Expand All @@ -1122,7 +1122,7 @@ public string Root
public string Description
{
get => _description;
set => _description = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value));
set => _description = value ?? throw PSTraceSource.NewArgumentNullException();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ public string[] Include
{
// null check is not needed (because of ValidateNotNullOrEmpty),
// but we have to include it to silence OACR
_includeStrings = value ?? throw PSTraceSource.NewArgumentNullException(nameof(value));
_includeStrings = value ?? throw PSTraceSource.NewArgumentNullException();

_include = new WildcardPattern[_includeStrings.Length];
for (int i = 0; i < _includeStrings.Length; i++)
Expand All @@ -1312,7 +1312,7 @@ public string[] Exclude
{
// null check is not needed (because of ValidateNotNullOrEmpty),
// but we have to include it to silence OACR
_excludeStrings = value ?? throw PSTraceSource.NewArgumentNullException("value");
_excludeStrings = value ?? throw PSTraceSource.NewArgumentNullException();

_exclude = new WildcardPattern[_excludeStrings.Length];
for (int i = 0; i < _excludeStrings.Length; i++)
Expand Down Expand Up @@ -1384,7 +1384,7 @@ public Encoding Encoding
{
// null check is not needed (because of ValidateNotNullOrEmpty),
// but we have to include it to silence OACR
_context = value ?? throw PSTraceSource.NewArgumentNullException("value");
_context = value ?? throw PSTraceSource.NewArgumentNullException();

if (_context.Length == 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ public override string WindowTitle
}
else
{
throw PSTraceSource.NewArgumentNullException("value");
throw PSTraceSource.NewArgumentNullException();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/GetCommandCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public string[] ParameterName
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException();
}

_parameterNames = value;
Expand Down Expand Up @@ -319,7 +319,7 @@ public PSTypeName[] ParameterType
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException();
}

// if '...CimInstance#Win32_Process' is specified, then exclude '...CimInstance'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public Type ParameterType
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException("value");
throw PSTraceSource.NewArgumentNullException();
}

_parameterType = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class ChoiceDescription
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException("value");
throw PSTraceSource.NewArgumentNullException();
}

this.helpMessage = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public string Name
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException("value");
throw PSTraceSource.NewArgumentNullException();
}

label = value;
Expand Down Expand Up @@ -230,7 +230,7 @@ public string Name
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException("value");
throw PSTraceSource.NewArgumentNullException();
}

helpMessage = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ internal SessionState SessionState
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException(nameof(value));
throw PSTraceSource.NewArgumentNullException();
}

SessionStateInternal = value.Internal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public List<CommandParameterCollection> StartParameters
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException("value");
throw PSTraceSource.NewArgumentNullException();
}

lock (_syncobject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public string Name
set
{
if (value == null)
throw new PSArgumentNullException("value");
throw new PSArgumentNullException();
_name = value;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public CultureInfo Culture
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException();
}

_culture = value;
Expand All @@ -191,7 +191,7 @@ public CultureInfo UICulture
{
if (value == null)
{
throw new ArgumentNullException("value");
throw new ArgumentNullException();
}

_uiCulture = value;
Expand Down Expand Up @@ -403,7 +403,7 @@ public Uri ConnectionUri
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException("value");
throw PSTraceSource.NewArgumentNullException();
}

UpdateUri(value);
Expand Down Expand Up @@ -610,7 +610,7 @@ public override string CertificateThumbprint
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException("value");
throw PSTraceSource.NewArgumentNullException();
}

_thumbPrint = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ internal CmdletProviderContext Context
{
if (value == null)
{
throw PSTraceSource.NewArgumentNullException("value");
throw PSTraceSource.NewArgumentNullException();
}

// Check that the provider supports the use of credentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ protected override void NewItem(string path, string type, object newItem)
if (newItem == null)
{
ArgumentNullException argException =
PSTraceSource.NewArgumentNullException("value");
PSTraceSource.NewArgumentNullException(nameof(newItem));

WriteError(
new ErrorRecord(
Expand Down
2 changes: 2 additions & 0 deletions src/System.Management.Automation/utils/MshTraceSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ internal static PSTraceSource GetNewTraceSource(

#region TraceFlags.New*Exception methods/helpers

internal static PSArgumentNullException NewArgumentNullException() => new PSArgumentNullException();

/// <summary>
/// Traces the Message and StackTrace properties of the exception
/// and returns the new exception. This is not allowed to call other
Expand Down