diff --git a/src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs b/src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs index 40935f6c8e0..e535535d25e 100644 --- a/src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs +++ b/src/Microsoft.PowerShell.Commands.Diagnostics/PdhHelper.cs @@ -957,7 +957,7 @@ public uint TranslateLocalCounterPath(string englishPath, out string localizedPa // NOTE: 1-based enumeration because the name strings follow index strings in the array Int32 counterIndex = -1; Int32 objIndex = -1; - for (uint enumIndex = 1; enumIndex < regCounters.Length; enumIndex++) + for (int enumIndex = 1; enumIndex < regCounters.Length; enumIndex++) { string regString = regCounters[enumIndex]; if (regString.ToLowerInvariant() == lowerEngCtrName) diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs index a6ff78d8c08..c5d4f0395fa 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/TestConnectionCommand.cs @@ -43,7 +43,7 @@ public class TestConnectionCommand : PSCmdlet, IDisposable // Count of pings sent to each trace route hop. Default mimics Windows' defaults. // If this value changes, we need to update 'ConsoleTraceRouteReply' resource string. - private const int DefaultTraceRoutePingCount = 3; + private const uint DefaultTraceRoutePingCount = 3; // Default size for the send buffer. private const int DefaultSendBufferSize = 32; @@ -608,7 +608,7 @@ private void ProcessPing(string targetNameOrAddress) int timeout = TimeoutSeconds * 1000; int delay = Delay * 1000; - for (uint i = 1; i <= Count; i++) + for (int i = 1; i <= Count; i++) { try { @@ -642,7 +642,7 @@ private void ProcessPing(string targetNameOrAddress) reply, reply.RoundtripTime, buffer.Length, - pingNum: i)); + pingNum: (uint)i)); } // Delay between pings, but not after last ping. diff --git a/src/Microsoft.PowerShell.Security/security/AclCommands.cs b/src/Microsoft.PowerShell.Security/security/AclCommands.cs index 7447318f054..03fa060154b 100644 --- a/src/Microsoft.PowerShell.Security/security/AclCommands.cs +++ b/src/Microsoft.PowerShell.Security/security/AclCommands.cs @@ -396,7 +396,7 @@ public static SecurityIdentifier GetCentralAccessPolicyId(PSObject instance) // Extract the first CAPID from the SACL that does not have INHERIT_ONLY_ACE flag set. IntPtr pAce = pSacl + Marshal.SizeOf(new NativeMethods.ACL()); - for (uint aceIdx = 0; aceIdx < sacl.AceCount; aceIdx++) + for (ushort aceIdx = 0; aceIdx < sacl.AceCount; aceIdx++) { NativeMethods.ACE_HEADER ace = new NativeMethods.ACE_HEADER(); ace = Marshal.PtrToStructure(pAce); diff --git a/src/System.Management.Automation/engine/Attributes.cs b/src/System.Management.Automation/engine/Attributes.cs index 99433b32d0f..593dd89d30d 100644 --- a/src/System.Management.Automation/engine/Attributes.cs +++ b/src/System.Management.Automation/engine/Attributes.cs @@ -1432,7 +1432,7 @@ public sealed class ValidateCountAttribute : ValidateArgumentsAttribute /// protected override void Validate(object arguments, EngineIntrinsics engineIntrinsics) { - UInt32 len = 0; + int len = 0; if (arguments == null || arguments == AutomationNull.Value) { // treat a nul list the same as an empty list @@ -1441,11 +1441,11 @@ protected override void Validate(object arguments, EngineIntrinsics engineIntrin } else if (arguments is IList il) { - len = (UInt32)il.Count; + len = il.Count; } else if (arguments is ICollection ic) { - len = (UInt32)ic.Count; + len = ic.Count; } else if (arguments is IEnumerable ie) { diff --git a/src/System.Management.Automation/engine/SessionState.cs b/src/System.Management.Automation/engine/SessionState.cs index e11b018daf2..f011a87a2aa 100644 --- a/src/System.Management.Automation/engine/SessionState.cs +++ b/src/System.Management.Automation/engine/SessionState.cs @@ -67,7 +67,7 @@ internal SessionStateInternal(SessionStateInternal parent, bool linkToGlobal, Ex _workingLocationStack = new Dictionary>(StringComparer.OrdinalIgnoreCase); // Conservative choice to limit the Set-Location history in order to limit memory impact in case of a regression. - const uint locationHistoryLimit = 20; + const int locationHistoryLimit = 20; _setLocationHistory = new HistoryStack(locationHistoryLimit); GlobalScope = new SessionStateScope(null); diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index 05b8800b4e5..6a83d10dd6c 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -2133,7 +2133,7 @@ internal class HistoryStack private readonly BoundedStack _boundedUndoStack; private readonly BoundedStack _boundedRedoStack; - internal HistoryStack(uint capacity) + internal HistoryStack(int capacity) { _boundedUndoStack = new BoundedStack(capacity); _boundedRedoStack = new BoundedStack(capacity); @@ -2178,13 +2178,13 @@ internal T Redo(T currentItem) /// internal class BoundedStack : LinkedList { - private readonly uint _capacity; + private readonly int _capacity; /// /// Lazy initialisation, i.e. it sets only its limit but does not allocate the memory for the given capacity. /// /// - internal BoundedStack(uint capacity) + internal BoundedStack(int capacity) { _capacity = capacity; } diff --git a/test/xUnit/csharp/test_Utils.cs b/test/xUnit/csharp/test_Utils.cs index 8519babf069..cda3d5741f4 100644 --- a/test/xUnit/csharp/test_Utils.cs +++ b/test/xUnit/csharp/test_Utils.cs @@ -59,7 +59,7 @@ public static void TestHistoryStack() [Fact] public static void TestBoundedStack() { - uint capacity = 20; + int capacity = 20; var boundedStack = new BoundedStack(capacity); Assert.Throws(() => boundedStack.Pop());