Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ private PSObject WrapOutputInPSObject(
return result;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/

#if !UNIX

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -5179,3 +5181,5 @@ private static class PInvokeDllNames
}
#endregion Native
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -417,4 +417,4 @@ private static int GetByteCount(StringBuilder sb, int start = 0, int end = -1)
return count;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace Microsoft.PowerShell.Commands
/// Displays the hexidecimal equivalent of the input data.
/// </summary>
[Cmdlet(VerbsCommon.Format, "Hex", SupportsShouldProcess = true, HelpUri ="https://go.microsoft.com/fwlink/?LinkId=526919")]
[Alias ("fhx")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This alias declaration shouldn't be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry. Fixed.

[OutputType(typeof(Microsoft.PowerShell.Commands.ByteCollection))]
[Alias ("fhx")]
public sealed class FormatHex : PSCmdlet
{
private const int BUFFERSIZE = 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ModuleVersion="3.1.0.0"
PowerShellVersion="3.0"
NestedModules="Microsoft.PowerShell.Commands.Management.dll"
HelpInfoURI = 'https://go.microsoft.com/fwlink/?linkid=390785'
AliasesToExport = @("gtz")
FunctionsToExport = @()
CmdletsToExport=@("Add-Content",
"Clear-Content",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ModuleVersion="3.1.0.0"
PowerShellVersion="3.0"
NestedModules="Microsoft.PowerShell.Commands.Management.dll"
HelpInfoURI = 'https://go.microsoft.com/fwlink/?linkid=390785'
AliasesToExport = @("gin", "gtz", "stz")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same - we now control all the aliases in the tests and can safely export all aliases by default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason as explained above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

AliasesToExport = @("gin", "gtz", "stz")
FunctionsToExport = @()
CmdletsToExport=@("Add-Content",
"Clear-Content",
Expand Down
16 changes: 10 additions & 6 deletions src/System.Management.Automation/engine/InitialSessionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5054,8 +5054,6 @@ internal static SessionStateAliasEntry[] BuiltInAliases
"Get-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("group",
"Group-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("gsv",
"Get-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("gu",
"Get-Unique", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("gv",
Expand Down Expand Up @@ -5110,8 +5108,6 @@ internal static SessionStateAliasEntry[] BuiltInAliases
"Resolve-Path", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("sal",
"Set-Alias", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("sasv",
"Start-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("sbp",
"Set-PSBreakpoint", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("sc",
Expand All @@ -5131,8 +5127,6 @@ internal static SessionStateAliasEntry[] BuiltInAliases
"Start-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("spps",
"Stop-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("spsv",
"Stop-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("sv",
"Set-Variable", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
// Web cmdlets aliases
Expand All @@ -5151,12 +5145,18 @@ internal static SessionStateAliasEntry[] BuiltInAliases
"Copy-ItemProperty", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("diff",
"Compare-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("gsv",
"Get-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("sleep",
"Start-Sleep", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("sort",
"Sort-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("start",
"Start-Process", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("sasv",
"Start-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("spsv",
"Stop-Service", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("tee",
"Tee-Object", "", ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
new SessionStateAliasEntry("write",
Expand Down Expand Up @@ -5883,6 +5883,10 @@ private static void AnalyzeModuleAssemblyWithReflection(Assembly assembly, strin
var aliasList = new List<SessionStateAliasEntry>();
foreach (var alias in aliasAttribute.AliasNames)
{
// Alias declared by AliasAttribute is set with the option 'ScopedItemOptions.None',
// because we believe a user of the cmdlet, instead of the author of it,
// should be the one to decide the option
// ('ScopedItemOptions.ReadOnly' and/or 'ScopedItemOptions.AllScopes') of the alias usage."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment probably should be removed now. When making the change to add internal support to AliasAttribute to allow specifying options, we can have a more accurate comment here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today the comment is correct. After improving the AliasAttribute the code here will be changed too and we could adjust the comment in that time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's reasonable #closed

var aliasEntry = new SessionStateAliasEntry(alias, cmdletName, "", ScopedItemOptions.None);
if (psSnapInInfo != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1332,11 +1332,6 @@ try {
}
}

It "Verify that alias 'gin' exists" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than removing this test, can you skip it for non-windows platforms?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea (from @lzybkr) is that we should put all alias tests in one place (Default-Aliases.Tests.ps1) rather than spread on many files.

$result = (Get-Alias -Name "gin").Name
$result | Should Be "gin"
}

It "Test for DeviceGuard properties" {
if (-not (HasDeviceGuardLicense))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ Describe "Get-Timezone test cases" -Tags "CI" {
Assert-ListsSame $expectedIdList $result
}

It "Verify that alias 'gtz' exists" {
(Get-Alias -Name "gtz").Name | Should Be "gtz"
}

It "Call Get-TimeZone Name parameter from pipeline by value " {
$result = ("Pacific*" | Get-TimeZone).Id
$expectedIdList = ($TimeZonesAvailable | Where-Object { $_.StandardName -match "^Pacific" }).Id
Expand Down Expand Up @@ -211,10 +207,6 @@ try {
}
}

It "Verify that alias 'stz' exists" {
(Get-Alias -Name "stz").Name | Should Be "stz"
}

It "Call Set-TimeZone from pipeline input object of type TimeZoneInfo" {
$origTimeZoneID = (Get-TimeZone).Id
$timezoneList = Get-TimeZone -ListAvailable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ Describe "Clear-Variable" -Tags "CI" {
{ Get-Variable var1 } | Should Not Throw
}

It "Should work using the clv alias" {
clv -Name var1
$var1 | Should BeNullOrEmpty
{ Get-Variable var1 } | Should Not Throw
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not checking if the alias exists, but actually testing the functionality of clear-variable, so it shouldn't be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous test do that so the test is alias related only.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#Closed.


It "Should be able to include a set of variables to clear" {
$var1 = 2
$var2 = 3
Expand Down
Loading