Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Change CimCmdlets to use AliasAttribute#12617

Merged
anmenaga merged 2 commits intoPowerShell:masterfrom
thlac:master
May 22, 2020
Merged

Change CimCmdlets to use AliasAttribute#12617
anmenaga merged 2 commits intoPowerShell:masterfrom
thlac:master

Conversation

@thlac
Copy link
Contributor

@thlac thlac commented May 10, 2020

PR Summary

Changes CimCmdlets-modude to use AliasAttribute and removed CimCmdletModuleInitialize.cs as its only function was to set the aliases

PR Context

Should fix #11988

PR Checklist

@ghost ghost assigned anmenaga May 10, 2020
@msftclas
Copy link

msftclas commented May 10, 2020

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

Please test in DefaultCommands.Tests.ps1

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label May 11, 2020
@iSazonov iSazonov added this to the 7.1.0-preview.3 milestone May 11, 2020
@thlac
Copy link
Contributor Author

thlac commented May 11, 2020

I saw that and thought that test was only for aliases defined in InitialSessionState.cs, but looking at it again it also says it only checks default loaded modules, the CimCmdlets module is not automatically loaded by default.

Not sure if I am misunderstanding anything, but the aliases looked to be default, because it was set during the module load, so it's technically the equivalent of the user doing Set-Alias -Name "gcim" -Value "Get-CimInstance" when the module loads.

@iSazonov
Copy link
Collaborator

We have a list of modules in the test and explicitly load the modules.

@thlac
Copy link
Contributor Author

thlac commented May 11, 2020

Okay, thanks, just wanted to make sure. I've added tests for them now :)

@thlac
Copy link
Contributor Author

thlac commented May 11, 2020

That test doesn't fail locally here

@anmenaga
Copy link

@daxian-dbw @SteveL-MSFT Please check this PR. Do you have any theories why alias initialization for CimCmdlets module was previously done through manually calling Set-Alias? I guess there should be a reason for it looking strange like that...

@SeeminglyScience
Copy link
Contributor

SeeminglyScience commented May 21, 2020

@daxian-dbw @SteveL-MSFT Please check this PR. Do you have any theories why alias initialization for CimCmdlets module was previously done through manually calling Set-Alias? I guess there should be a reason for it looking strange like that...

So in PSv2, the AliasAttribute was decorated with AttributeUsage(AttributeTargets.Property | AttributeTargets.Field) so it wasn't yet able to be applied to classes. In PSv3 (I think), AttributeTargets.Class was added. Although the CIM cmdlets were added in the same version, my guess is that the additional attribute target was added later in development (or the folks working on CIM just weren't aware of it). If y'all found someone who remembers then feel free to ignore my theory 🙂

@anmenaga anmenaga merged commit 62bb436 into PowerShell:master May 22, 2020
@iSazonov
Copy link
Collaborator

@thlac Thanks for your contribution!

@ghost
Copy link

ghost commented Jun 25, 2020

🎉v7.1.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GCIM Alias does not work in PowerShell 7 RC3

6 participants