Skip to content

Commit 006fe4d

Browse files
authored
1 parent fcd9e37 commit 006fe4d

11 files changed

Lines changed: 15 additions & 15 deletions

File tree

.globalconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ dotnet_diagnostic.IDE0080.severity = silent
971971
dotnet_diagnostic.IDE0081.severity = silent
972972

973973
# IDE0082: ConvertTypeOfToNameOf
974-
dotnet_diagnostic.IDE0082.severity = silent
974+
dotnet_diagnostic.IDE0082.severity = warning
975975

976976
# IDE0083: UseNotPattern
977977
dotnet_diagnostic.IDE0083.severity = silent

src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ private bool IsIncompleteParseException(Exception e)
27412741
return false;
27422742
}
27432743

2744-
return remoteException.ErrorRecord.CategoryInfo.Reason == typeof(IncompleteParseException).Name;
2744+
return remoteException.ErrorRecord.CategoryInfo.Reason == nameof(IncompleteParseException);
27452745
}
27462746

27472747
private void EvaluateSuggestions(ConsoleHostUserInterface ui)

src/System.Management.Automation/engine/Attributes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ private void ValidateRange(object element, ValidateRangeKind rangeKind)
10921092
innerException: null,
10931093
Metadata.ValidateRangeElementType,
10941094
element.GetType().Name,
1095-
typeof(int).Name);
1095+
nameof(Int32));
10961096
}
10971097

10981098
object resultValue;

src/System.Management.Automation/engine/CmdletInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ internal override bool ImplementsDynamicParameters
548548
{
549549
if (ImplementingType != null)
550550
{
551-
return (ImplementingType.GetInterface(typeof(IDynamicParameters).Name, true) != null);
551+
return (ImplementingType.GetInterface(nameof(IDynamicParameters), true) != null);
552552
}
553553
else
554554
{

src/System.Management.Automation/engine/CommandMetadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ private void ConstructCmdletMetadataUsingReflection()
680680

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

683-
Type dynamicParametersType = CommandType.GetInterface(typeof(IDynamicParameters).Name, true);
683+
Type dynamicParametersType = CommandType.GetInterface(nameof(IDynamicParameters), true);
684684

685685
if (dynamicParametersType != null)
686686
{

src/System.Management.Automation/engine/CompiledCommandParameter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ internal ParameterCollectionTypeInformation(Type type)
625625
return;
626626
}
627627

628-
bool implementsIList = (type.GetInterface(typeof(IList).Name) != null);
628+
bool implementsIList = (type.GetInterface(nameof(IList)) != null);
629629

630630
// Look for class Collection<T>. Collection<T> implements IList, and also IList
631631
// is more efficient to bind than ICollection<T>. This optimization

src/System.Management.Automation/engine/MshObjectTypeDescriptor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ private static PSObject GetComponentPSObject(object component)
222222
{
223223
throw PSTraceSource.NewArgumentException(nameof(component), ExtendedTypeSystem.InvalidComponent,
224224
"component",
225-
typeof(PSObject).Name,
226-
typeof(PSObjectTypeDescriptor).Name);
225+
nameof(PSObject),
226+
nameof(PSObjectTypeDescriptor));
227227
}
228228

229229
mshObj = descriptor.Instance;

src/System.Management.Automation/engine/debugger/debugger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4138,7 +4138,7 @@ internal void TraceVariableSet(string varName, object value)
41384138
// because 'ToStringParser' would iterate through the enumerator to get the individual elements, which will
41394139
// make irreversible changes to the enumerator.
41404140
bool isValueAnIEnumerator = PSObject.Base(value) is IEnumerator;
4141-
string valAsString = isValueAnIEnumerator ? typeof(IEnumerator).Name : PSObject.ToStringParser(_context, value);
4141+
string valAsString = isValueAnIEnumerator ? nameof(IEnumerator) : PSObject.ToStringParser(_context, value);
41424142
int msgLength = 60 - varName.Length;
41434143

41444144
if (valAsString.Length > msgLength)

src/System.Management.Automation/engine/hostifaces/InternalHostUserInterface.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,12 @@ internal static Type GetFieldType(FieldDescription field)
680680

681681
internal static bool IsSecuritySensitiveType(string typeName)
682682
{
683-
if (typeName.Equals(typeof(PSCredential).Name, StringComparison.OrdinalIgnoreCase))
683+
if (typeName.Equals(nameof(PSCredential), StringComparison.OrdinalIgnoreCase))
684684
{
685685
return true;
686686
}
687687

688-
if (typeName.Equals(typeof(SecureString).Name, StringComparison.OrdinalIgnoreCase))
688+
if (typeName.Equals(nameof(SecureString), StringComparison.OrdinalIgnoreCase))
689689
{
690690
return true;
691691
}

src/System.Management.Automation/engine/remoting/client/remoterunspace.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ public override DebuggerCommandResults ProcessCommand(PSCommand command, PSDataC
19361936
{
19371937
// Allow the IncompleteParseException to throw so that the console
19381938
// can handle here strings and continued parsing.
1939-
if (re.ErrorRecord.CategoryInfo.Reason == typeof(IncompleteParseException).Name)
1939+
if (re.ErrorRecord.CategoryInfo.Reason == nameof(IncompleteParseException))
19401940
{
19411941
throw new IncompleteParseException(
19421942
(re.ErrorRecord.Exception != null) ? re.ErrorRecord.Exception.Message : null,
@@ -1945,8 +1945,8 @@ public override DebuggerCommandResults ProcessCommand(PSCommand command, PSDataC
19451945

19461946
// Allow the RemoteException and InvalidRunspacePoolStateException to propagate so that the host can
19471947
// clean up the debug session.
1948-
if ((re.ErrorRecord.CategoryInfo.Reason == typeof(InvalidRunspacePoolStateException).Name) ||
1949-
(re.ErrorRecord.CategoryInfo.Reason == typeof(RemoteException).Name))
1948+
if ((re.ErrorRecord.CategoryInfo.Reason == nameof(InvalidRunspacePoolStateException)) ||
1949+
(re.ErrorRecord.CategoryInfo.Reason == nameof(RemoteException)))
19501950
{
19511951
throw new PSRemotingTransportException(
19521952
(re.ErrorRecord.Exception != null) ? re.ErrorRecord.Exception.Message : string.Empty);

0 commit comments

Comments
 (0)