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
4 changes: 4 additions & 0 deletions .globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ dotnet_diagnostic.CA1846.severity = warning
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1847
dotnet_diagnostic.CA1847.severity = warning

# CA1853: Unnecessary call to 'Dictionary.ContainsKey(key)'
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1853
dotnet_diagnostic.CA1853.severity = warning

# CA1858: Use 'StartsWith' instead of 'IndexOf'
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1858
dotnet_diagnostic.CA1858.severity = warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@ protected override void ProcessRecord()
{
TimeSpan uptime = TimeSpan.FromSeconds(Stopwatch.GetTimestamp() / Stopwatch.Frequency);

switch (ParameterSetName)
if (Since)
{
case TimespanParameterSet:
// return TimeSpan of time since the system started up
WriteObject(uptime);
break;
case SinceParameterSet:
// return Datetime when the system started up
WriteObject(DateTime.Now.Subtract(uptime));
break;
// Output the time of the last system boot.
WriteObject(DateTime.Now.Subtract(uptime));
}
else
{
// Output the time elapsed since the last system boot.
WriteObject(uptime);
}
}
else
Expand Down
7 changes: 6 additions & 1 deletion test/powershell/Host/ConsoleHost.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,12 @@ public static WINDOWPLACEMENT GetPlacement(IntPtr hwnd)
{
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(placement);
GetWindowPlacement(hwnd, ref placement);

if (!GetWindowPlacement(hwnd, ref placement))
{
throw new System.ComponentModel.Win32Exception();
}

return placement;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Describe "Get-Uptime" -Tags "CI" {
$upt = Get-Uptime -Since
$upt | Should -BeOfType DateTime
}
It "Get-Uptime -Since:`$false return TimeSpan" {
$upt = Get-Uptime -Since:$false
$upt | Should -BeOfType TimeSpan
}
It "Get-Uptime throw if IsHighResolution == false" {
# Enable the test hook
[system.management.automation.internal.internaltesthooks]::SetTestHook('StopwatchIsNotHighResolution', $true)
Expand Down
Loading