Style: Use the type aliases 'char' and 'bool' instead of 'Char' and 'Boolean' (#8572)
This commit is contained in:
parent
23f6e8ff40
commit
f95dae55f7
|
@ -146,7 +146,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
StringBuilder newClassName = new StringBuilder();
|
||||
for (int i = 0; i < filterClass.Length; i++)
|
||||
{
|
||||
if (Char.IsLetterOrDigit(filterClass[i]) ||
|
||||
if (char.IsLetterOrDigit(filterClass[i]) ||
|
||||
filterClass[i].Equals('[') || filterClass[i].Equals(']') ||
|
||||
filterClass[i].Equals('*') || filterClass[i].Equals('?') ||
|
||||
filterClass[i].Equals('-'))
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
// Validate class format
|
||||
for (int i = 0; i < this.Class.Length; i++)
|
||||
{
|
||||
if (Char.IsLetterOrDigit(this.Class[i]) || this.Class[i].Equals('_'))
|
||||
if (char.IsLetterOrDigit(this.Class[i]) || this.Class[i].Equals('_'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
[Cmdlet(VerbsDiagnostic.Test, "Connection", DefaultParameterSetName = ParameterSetPingCount, HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135266")]
|
||||
[OutputType(typeof(PingReport), ParameterSetName = new string[] { ParameterSetPingCount })]
|
||||
[OutputType(typeof(PingReply), ParameterSetName = new string[] { ParameterSetPingContinues, ParameterSetDetectionOfMTUSize })]
|
||||
[OutputType(typeof(Boolean), ParameterSetName = new string[] { ParameterSetPingCount, ParameterSetPingContinues, ParameterSetConnectionByTCPPort })]
|
||||
[OutputType(typeof(bool), ParameterSetName = new string[] { ParameterSetPingCount, ParameterSetPingContinues, ParameterSetConnectionByTCPPort })]
|
||||
[OutputType(typeof(Int32), ParameterSetName = new string[] { ParameterSetDetectionOfMTUSize })]
|
||||
[OutputType(typeof(TraceRouteReply), ParameterSetName = new string[] { ParameterSetTraceRoute })]
|
||||
public class TestConnectionCommand : PSCmdlet
|
||||
|
|
|
@ -161,6 +161,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
#endregion Cmdlet Overrides
|
||||
|
||||
private object _prompt = null;
|
||||
private Boolean _safe = false;
|
||||
private bool _safe = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
|
||||
private bool IsPrintable(char c)
|
||||
{
|
||||
return (Char.IsLetterOrDigit(c) || Char.IsPunctuation(c) || Char.IsSeparator(c) || Char.IsSymbol(c) || Char.IsWhiteSpace(c));
|
||||
return (char.IsLetterOrDigit(c) || char.IsPunctuation(c) || char.IsSeparator(c) || char.IsSymbol(c) || char.IsWhiteSpace(c));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -121,6 +121,6 @@ namespace Microsoft.PowerShell.Commands
|
|||
this.WriteInformation(informationMessage, new string[] { "PSHOST" });
|
||||
}
|
||||
|
||||
private Boolean _notAppendNewline = false;
|
||||
private bool _notAppendNewline = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2978,7 +2978,7 @@ namespace Microsoft.PowerShell
|
|||
internal static extern bool FillConsoleOutputCharacter
|
||||
(
|
||||
NakedWin32Handle consoleOutput,
|
||||
Char character,
|
||||
char character,
|
||||
DWORD length,
|
||||
COORD writeCoord,
|
||||
out DWORD numberOfCharsWritten
|
||||
|
|
|
@ -353,7 +353,7 @@ namespace Microsoft.PowerShell
|
|||
}
|
||||
}
|
||||
#if UNIX
|
||||
else if (Char.IsControl(keyInfo.KeyChar))
|
||||
else if (char.IsControl(keyInfo.KeyChar))
|
||||
{
|
||||
// blacklist control characters
|
||||
continue;
|
||||
|
@ -1668,7 +1668,7 @@ namespace Microsoft.PowerShell
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Char.IsControl(keyInfo.KeyChar))
|
||||
if (char.IsControl(keyInfo.KeyChar))
|
||||
{
|
||||
// blacklist control characters
|
||||
continue;
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace Microsoft.PowerShell
|
|||
{
|
||||
Dictionary<string, PSObject> results = new Dictionary<string, PSObject>();
|
||||
|
||||
Boolean cancelInput = false;
|
||||
bool cancelInput = false;
|
||||
|
||||
if (!string.IsNullOrEmpty(caption))
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ namespace Microsoft.PowerShell
|
|||
{
|
||||
fieldPromptList.Append(
|
||||
string.Format(CultureInfo.InvariantCulture, "{0}]: ", inputList.Count));
|
||||
Boolean inputListEnd = false;
|
||||
bool inputListEnd = false;
|
||||
object convertedObj = null;
|
||||
string inputString = PromptForSingleItem(elementType, fieldPromptList.ToString(), fieldPrompt, caption, message,
|
||||
desc, fieldEchoOnPrompt, true, out inputListEnd, out cancelInput, out convertedObj);
|
||||
|
@ -244,7 +244,7 @@ namespace Microsoft.PowerShell
|
|||
fieldPrompt);
|
||||
// field is not a list
|
||||
object convertedObj = null;
|
||||
Boolean dummy = false;
|
||||
bool dummy = false;
|
||||
|
||||
PromptForSingleItem(fieldType, printFieldPrompt, fieldPrompt, caption, message, desc,
|
||||
fieldEchoOnPrompt, false, out dummy, out cancelInput, out convertedObj);
|
||||
|
|
|
@ -58,14 +58,14 @@ namespace Microsoft.PowerShell
|
|||
|
||||
public override
|
||||
void
|
||||
Write(Char c)
|
||||
Write(char c)
|
||||
{
|
||||
this.Write(new String(c, 1));
|
||||
}
|
||||
|
||||
public override
|
||||
void
|
||||
Write(Char[] a)
|
||||
Write(char[] a)
|
||||
{
|
||||
this.Write(new String(a));
|
||||
}
|
||||
|
|
|
@ -406,9 +406,9 @@ namespace System.Diagnostics.Eventing
|
|||
}
|
||||
else if (data is Boolean)
|
||||
{
|
||||
dataDescriptor->Size = (uint)sizeof(Boolean);
|
||||
dataDescriptor->Size = (uint)sizeof(bool);
|
||||
Boolean* booleanptr = (Boolean*)dataBuffer;
|
||||
*booleanptr = (Boolean)data;
|
||||
*booleanptr = (bool)data;
|
||||
dataDescriptor->DataPointer = (ulong)booleanptr;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace System.Management.Automation.SecurityAccountsManager.Extensions
|
|||
bool allowSidConstants = false)
|
||||
{
|
||||
if (!allowSidConstants)
|
||||
if (!(s.Length > 2 && s.StartsWith("S-", StringComparison.Ordinal) && Char.IsDigit(s[2])))
|
||||
if (!(s.Length > 2 && s.StartsWith("S-", StringComparison.Ordinal) && char.IsDigit(s[2])))
|
||||
return null;
|
||||
|
||||
SecurityIdentifier sid = null;
|
||||
|
|
|
@ -401,7 +401,7 @@ namespace Microsoft.WSMan.Management
|
|||
{
|
||||
string name;
|
||||
string value;
|
||||
string[] Split = filter.Trim().Split(new Char[] { '=', ';' });
|
||||
string[] Split = filter.Trim().Split(new char[] { '=', ';' });
|
||||
if ((Split.Length)%2 != 0)
|
||||
{
|
||||
// mismatched property name/value pair
|
||||
|
|
|
@ -574,7 +574,7 @@ namespace System.Management.Automation.ComInterop
|
|||
}
|
||||
|
||||
// VT_BOOL
|
||||
public Boolean AsBool
|
||||
public bool AsBool
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
@ -2123,7 +2123,7 @@ namespace System.Management.Automation
|
|||
sourceValue, ObjectToTypeNameString(sourceValue), destinationType);
|
||||
}
|
||||
|
||||
if (Char.IsDigit(sourceValueString[0]) || sourceValueString[0] == '+' || sourceValueString[0] == '-')
|
||||
if (char.IsDigit(sourceValueString[0]) || sourceValueString[0] == '+' || sourceValueString[0] == '-')
|
||||
{
|
||||
Type underlyingType = Enum.GetUnderlyingType(destinationType);
|
||||
try
|
||||
|
|
|
@ -916,7 +916,7 @@ namespace System.Management.Automation
|
|||
{
|
||||
char driveChar = Convert.ToChar(drive.Name, CultureInfo.InvariantCulture);
|
||||
|
||||
if (Char.ToUpperInvariant(driveChar) >= 'A' && Char.ToUpperInvariant(driveChar) <= 'Z')
|
||||
if (char.ToUpperInvariant(driveChar) >= 'A' && char.ToUpperInvariant(driveChar) <= 'Z')
|
||||
{
|
||||
DriveInfo systemDriveInfo = new DriveInfo(drive.Name);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace System.Management.Automation.Interpreter
|
|||
{
|
||||
public override int Run(InterpretedFrame frame)
|
||||
{
|
||||
frame.Push(((Boolean)frame.Pop()) == ((Boolean)frame.Pop()));
|
||||
frame.Push(((bool)frame.Pop()) == ((bool)frame.Pop()));
|
||||
return +1;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace System.Management.Automation.Interpreter
|
|||
{
|
||||
public override int Run(InterpretedFrame frame)
|
||||
{
|
||||
frame.Push(((Char)frame.Pop()) == ((Char)frame.Pop()));
|
||||
frame.Push(((char)frame.Pop()) == ((char)frame.Pop()));
|
||||
return +1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ namespace System.Management.Automation.Interpreter
|
|||
{
|
||||
public override int Run(InterpretedFrame frame)
|
||||
{
|
||||
Char right = (Char)frame.Pop();
|
||||
frame.Push(((Char)frame.Pop()) > right);
|
||||
char right = (char)frame.Pop();
|
||||
frame.Push(((char)frame.Pop()) > right);
|
||||
return +1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ namespace System.Management.Automation.Interpreter
|
|||
{
|
||||
public override int Run(InterpretedFrame frame)
|
||||
{
|
||||
Char right = (Char)frame.Pop();
|
||||
frame.Push(((Char)frame.Pop()) < right);
|
||||
char right = (char)frame.Pop();
|
||||
frame.Push(((char)frame.Pop()) < right);
|
||||
return +1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace System.Management.Automation.Interpreter
|
|||
{
|
||||
public override int Run(InterpretedFrame frame)
|
||||
{
|
||||
frame.Push(((Boolean)frame.Pop()) != ((Boolean)frame.Pop()));
|
||||
frame.Push(((bool)frame.Pop()) != ((bool)frame.Pop()));
|
||||
return +1;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace System.Management.Automation.Interpreter
|
|||
{
|
||||
public override int Run(InterpretedFrame frame)
|
||||
{
|
||||
frame.Push(((Char)frame.Pop()) != ((Char)frame.Pop()));
|
||||
frame.Push(((char)frame.Pop()) != ((char)frame.Pop()));
|
||||
return +1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ namespace System.Management.Automation.Interpreter
|
|||
case TypeCode.Byte: return ConvertInt32((Byte)obj);
|
||||
case TypeCode.SByte: return ConvertInt32((SByte)obj);
|
||||
case TypeCode.Int16: return ConvertInt32((Int16)obj);
|
||||
case TypeCode.Char: return ConvertInt32((Char)obj);
|
||||
case TypeCode.Char: return ConvertInt32((char)obj);
|
||||
case TypeCode.Int32: return ConvertInt32((Int32)obj);
|
||||
case TypeCode.Int64: return ConvertInt64((Int64)obj);
|
||||
case TypeCode.UInt16: return ConvertInt32((UInt16)obj);
|
||||
|
|
|
@ -888,7 +888,7 @@ namespace System.Management.Automation
|
|||
private static object AsChar(object obj)
|
||||
{
|
||||
if (obj is char) return obj;
|
||||
if (obj is string str && str.Length == 1 && !Char.IsDigit(str, 0)) return str[0];
|
||||
if (obj is string str && str.Length == 1 && !char.IsDigit(str, 0)) return str[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1196,7 +1196,7 @@ namespace System.Management.Automation.Language {
|
|||
/// </summary>
|
||||
private static bool ContainsWhiteSpace(string name) {
|
||||
foreach (char c in name) {
|
||||
if (Char.IsWhiteSpace(c)) {
|
||||
if (char.IsWhiteSpace(c)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1421,7 +1421,7 @@ namespace System.Management.Automation.Language
|
|||
string hexStr = GetStringAndRelease(sb);
|
||||
|
||||
uint unicodeValue = uint.Parse(hexStr, NumberStyles.AllowHexSpecifier, NumberFormatInfo.InvariantInfo);
|
||||
if (unicodeValue <= Char.MaxValue)
|
||||
if (unicodeValue <= char.MaxValue)
|
||||
{
|
||||
return ((char)unicodeValue);
|
||||
}
|
||||
|
@ -2976,7 +2976,7 @@ namespace System.Management.Automation.Language
|
|||
break;
|
||||
|
||||
default:
|
||||
if (Char.IsLetterOrDigit(c))
|
||||
if (char.IsLetterOrDigit(c))
|
||||
{
|
||||
sb.Append(c);
|
||||
}
|
||||
|
|
|
@ -2602,7 +2602,7 @@ namespace System.Management.Automation
|
|||
Dbg.Assert(entry != null, "caller should have validated the information");
|
||||
|
||||
// Char is defined as unsigned short in schema
|
||||
WriteRawString(serializer, streamName, property, XmlConvert.ToString((UInt16)(Char)source), entry);
|
||||
WriteRawString(serializer, streamName, property, XmlConvert.ToString((UInt16)(char)source), entry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2619,7 +2619,7 @@ namespace System.Management.Automation
|
|||
Dbg.Assert(source != null, "caller should have validated the information");
|
||||
Dbg.Assert(entry != null, "caller should have validated the information");
|
||||
|
||||
WriteRawString(serializer, streamName, property, XmlConvert.ToString((Boolean)source), entry);
|
||||
WriteRawString(serializer, streamName, property, XmlConvert.ToString((bool)source), entry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -3009,7 +3009,7 @@ namespace System.Management.Automation
|
|||
() =>
|
||||
new HashSet<Type>
|
||||
{
|
||||
typeof(Boolean),
|
||||
typeof(bool),
|
||||
typeof(byte),
|
||||
typeof(char),
|
||||
typeof(DateTime),
|
||||
|
@ -4182,7 +4182,7 @@ namespace System.Management.Automation
|
|||
Exception recognizedException = null;
|
||||
try
|
||||
{
|
||||
return (Char)XmlConvert.ToUInt16(deserializer._reader.ReadElementContentAsString());
|
||||
return (char)XmlConvert.ToUInt16(deserializer._reader.ReadElementContentAsString());
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
|
@ -5150,7 +5150,7 @@ namespace System.Management.Automation
|
|||
/// </summary>
|
||||
private static readonly TypeSerializationInfo[] s_typeSerializationInfo = new TypeSerializationInfo[]
|
||||
{
|
||||
new TypeSerializationInfo(typeof(Boolean),
|
||||
new TypeSerializationInfo(typeof(bool),
|
||||
SerializationStrings.BooleanTag,
|
||||
SerializationStrings.BooleanTag,
|
||||
InternalSerializer.WriteBoolean,
|
||||
|
@ -6116,7 +6116,7 @@ namespace System.Management.Automation
|
|||
/// </summary>
|
||||
/// <param name="key">The key of the element to add.</param>
|
||||
/// <param name="value">The value of the element to add.</param>
|
||||
public void Add(string key, Boolean value)
|
||||
public void Add(string key, bool value)
|
||||
{
|
||||
this.Add((object)key, (object)value);
|
||||
}
|
||||
|
@ -6156,7 +6156,7 @@ namespace System.Management.Automation
|
|||
/// </summary>
|
||||
/// <param name="key">The key of the element to add.</param>
|
||||
/// <param name="value">The value of the element to add.</param>
|
||||
public void Add(string key, Char value)
|
||||
public void Add(string key, char value)
|
||||
{
|
||||
this.Add((object)key, (object)value);
|
||||
}
|
||||
|
@ -6166,7 +6166,7 @@ namespace System.Management.Automation
|
|||
/// </summary>
|
||||
/// <param name="key">The key of the element to add.</param>
|
||||
/// <param name="value">The value of the element to add.</param>
|
||||
public void Add(string key, Char[] value)
|
||||
public void Add(string key, char[] value)
|
||||
{
|
||||
this.Add((object)key, (object)value);
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ namespace Microsoft.PowerShell.Commands
|
|||
[OutputType(typeof(FileInfo), ProviderCmdlet = ProviderCmdlet.GetItem)]
|
||||
[OutputType(typeof(FileInfo), typeof(DirectoryInfo), ProviderCmdlet = ProviderCmdlet.GetChildItem)]
|
||||
[OutputType(typeof(FileSecurity), typeof(DirectorySecurity), ProviderCmdlet = ProviderCmdlet.GetAcl)]
|
||||
[OutputType(typeof(Boolean), typeof(string), typeof(FileInfo), typeof(DirectoryInfo), ProviderCmdlet = ProviderCmdlet.GetItem)]
|
||||
[OutputType(typeof(Boolean), typeof(string), typeof(DateTime), typeof(System.IO.FileInfo), typeof(System.IO.DirectoryInfo), ProviderCmdlet = ProviderCmdlet.GetItemProperty)]
|
||||
[OutputType(typeof(bool), typeof(string), typeof(FileInfo), typeof(DirectoryInfo), ProviderCmdlet = ProviderCmdlet.GetItem)]
|
||||
[OutputType(typeof(bool), typeof(string), typeof(DateTime), typeof(System.IO.FileInfo), typeof(System.IO.DirectoryInfo), ProviderCmdlet = ProviderCmdlet.GetItemProperty)]
|
||||
[OutputType(typeof(string), typeof(System.IO.FileInfo), ProviderCmdlet = ProviderCmdlet.NewItem)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "This coupling is required")]
|
||||
public sealed partial class FileSystemProvider : NavigationCmdletProvider,
|
||||
|
@ -657,7 +657,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
{
|
||||
char driveChar = Convert.ToChar(drive.Name, CultureInfo.InvariantCulture);
|
||||
|
||||
if (Char.ToUpperInvariant(driveChar) >= 'A' && Char.ToUpperInvariant(driveChar) <= 'Z')
|
||||
if (char.ToUpperInvariant(driveChar) >= 'A' && char.ToUpperInvariant(driveChar) <= 'Z')
|
||||
{
|
||||
isSupportedDriveForPersistence = true;
|
||||
}
|
||||
|
@ -7629,7 +7629,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
public ushort Data2;
|
||||
public ushort Data3;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public Char[] Data4;
|
||||
public char[] Data4;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
@ -7640,7 +7640,7 @@ namespace Microsoft.PowerShell.Commands
|
|||
public ushort Reserved;
|
||||
public GUID ReparseGuid;
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_REPARSE_SIZE)]
|
||||
public Char[] DataBuffer;
|
||||
public char[] DataBuffer;
|
||||
}
|
||||
|
||||
[DllImport(PinvokeDllNames.DeviceIoControlDllName, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
|
||||
|
|
Loading…
Reference in a new issue