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
2 changes: 1 addition & 1 deletion .globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ dotnet_diagnostic.IDE0080.severity = silent
dotnet_diagnostic.IDE0081.severity = silent

# IDE0082: ConvertTypeOfToNameOf
dotnet_diagnostic.IDE0082.severity = silent
dotnet_diagnostic.IDE0082.severity = warning

# IDE0083: UseNotPattern
dotnet_diagnostic.IDE0083.severity = silent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2743,7 +2743,7 @@ private bool IsIncompleteParseException(Exception e)
return false;
}

return remoteException.ErrorRecord.CategoryInfo.Reason == typeof(IncompleteParseException).Name;
return remoteException.ErrorRecord.CategoryInfo.Reason == nameof(IncompleteParseException);
}

private void EvaluateSuggestions(ConsoleHostUserInterface ui)
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ private void ValidateRange(object element, ValidateRangeKind rangeKind)
innerException: null,
Metadata.ValidateRangeElementType,
element.GetType().Name,
typeof(int).Name);
nameof(Int32));
}

object resultValue;
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/CmdletInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ internal override bool ImplementsDynamicParameters
{
if (ImplementingType != null)
{
return (ImplementingType.GetInterface(typeof(IDynamicParameters).Name, true) != null);
return (ImplementingType.GetInterface(nameof(IDynamicParameters), true) != null);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/System.Management.Automation/engine/CommandMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ private void ConstructCmdletMetadataUsingReflection()

// Determine if the cmdlet implements dynamic parameters by looking for the interface

Type dynamicParametersType = CommandType.GetInterface(typeof(IDynamicParameters).Name, true);
Type dynamicParametersType = CommandType.GetInterface(nameof(IDynamicParameters), true);

if (dynamicParametersType != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ internal ParameterCollectionTypeInformation(Type type)
return;
}

bool implementsIList = (type.GetInterface(typeof(IList).Name) != null);
bool implementsIList = (type.GetInterface(nameof(IList)) != null);

// Look for class Collection<T>. Collection<T> implements IList, and also IList
// is more efficient to bind than ICollection<T>. This optimization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ private static PSObject GetComponentPSObject(object component)
{
throw PSTraceSource.NewArgumentException(nameof(component), ExtendedTypeSystem.InvalidComponent,
"component",
typeof(PSObject).Name,
typeof(PSObjectTypeDescriptor).Name);
nameof(PSObject),
nameof(PSObjectTypeDescriptor));
}

mshObj = descriptor.Instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4138,7 +4138,7 @@ internal void TraceVariableSet(string varName, object value)
// because 'ToStringParser' would iterate through the enumerator to get the individual elements, which will
// make irreversible changes to the enumerator.
bool isValueAnIEnumerator = PSObject.Base(value) is IEnumerator;
string valAsString = isValueAnIEnumerator ? typeof(IEnumerator).Name : PSObject.ToStringParser(_context, value);
string valAsString = isValueAnIEnumerator ? nameof(IEnumerator) : PSObject.ToStringParser(_context, value);
int msgLength = 60 - varName.Length;

if (valAsString.Length > msgLength)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,12 +680,12 @@ internal static Type GetFieldType(FieldDescription field)

internal static bool IsSecuritySensitiveType(string typeName)
{
if (typeName.Equals(typeof(PSCredential).Name, StringComparison.OrdinalIgnoreCase))
if (typeName.Equals(nameof(PSCredential), StringComparison.OrdinalIgnoreCase))
{
return true;
}

if (typeName.Equals(typeof(SecureString).Name, StringComparison.OrdinalIgnoreCase))
if (typeName.Equals(nameof(SecureString), StringComparison.OrdinalIgnoreCase))
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ public override DebuggerCommandResults ProcessCommand(PSCommand command, PSDataC
{
// Allow the IncompleteParseException to throw so that the console
// can handle here strings and continued parsing.
if (re.ErrorRecord.CategoryInfo.Reason == typeof(IncompleteParseException).Name)
if (re.ErrorRecord.CategoryInfo.Reason == nameof(IncompleteParseException))
{
throw new IncompleteParseException(
(re.ErrorRecord.Exception != null) ? re.ErrorRecord.Exception.Message : null,
Expand All @@ -1945,8 +1945,8 @@ public override DebuggerCommandResults ProcessCommand(PSCommand command, PSDataC

// Allow the RemoteException and InvalidRunspacePoolStateException to propagate so that the host can
// clean up the debug session.
if ((re.ErrorRecord.CategoryInfo.Reason == typeof(InvalidRunspacePoolStateException).Name) ||
(re.ErrorRecord.CategoryInfo.Reason == typeof(RemoteException).Name))
if ((re.ErrorRecord.CategoryInfo.Reason == nameof(InvalidRunspacePoolStateException)) ||
(re.ErrorRecord.CategoryInfo.Reason == nameof(RemoteException)))
{
throw new PSRemotingTransportException(
(re.ErrorRecord.Exception != null) ? re.ErrorRecord.Exception.Message : string.Empty);
Expand Down
2 changes: 1 addition & 1 deletion test/xUnit/csharp/test_AstDefaultVisit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static class AstDefaultVisitTests
public static void TestCustomAstVisitor()
{
var ast = Parser.ParseInput("a | b", out _, out _);
var expected = typeof(NamedBlockAst).Name;
var expected = nameof(NamedBlockAst);

var myVisitor1 = new MyICustomAstVisitor2();
var result1 = ast.EndBlock.Accept(myVisitor1);
Expand Down