Reenable compound assignment preference#17784
Reenable compound assignment preference#17784iSazonov merged 4 commits intoPowerShell:masterfrom Molkree:reenable-compound-assignment
Conversation
|
Okay, I already see some missed cases. I wonder what is different between the CI and my local environment? |
|
Hm, one of them looks like a false positive. In if (s_defaultMshSnapins == null)
{
s_defaultMshSnapins = new List<DefaultPSSnapInInformation>()
{
#if !UNIX
new DefaultPSSnapInInformation("Microsoft.PowerShell.Diagnostics", "Microsoft.PowerShell.Commands.Diagnostics", null,
"GetEventResources,Description", "GetEventResources,Vendor"),
#endif
new DefaultPSSnapInInformation("Microsoft.PowerShell.Host", "Microsoft.PowerShell.ConsoleHost", null,
"HostMshSnapInResources,Description", "HostMshSnapInResources,Vendor"),
s_coreSnapin,
new DefaultPSSnapInInformation("Microsoft.PowerShell.Utility", "Microsoft.PowerShell.Commands.Utility", null,
"UtilityMshSnapInResources,Description", "UtilityMshSnapInResources,Vendor"),
new DefaultPSSnapInInformation("Microsoft.PowerShell.Management", "Microsoft.PowerShell.Commands.Management", null,
"ManagementMshSnapInResources,Description", "ManagementMshSnapInResources,Vendor"),
new DefaultPSSnapInInformation("Microsoft.PowerShell.Security", "Microsoft.PowerShell.Security", null,
"SecurityMshSnapInResources,Description", "SecurityMshSnapInResources,Vendor")
};
#if !UNIX
if (!Utils.IsWinPEHost())
{
s_defaultMshSnapins.Add(new DefaultPSSnapInInformation("Microsoft.WSMan.Management", "Microsoft.WSMan.Management", null,
"WsManResources,Description", "WsManResources,Vendor"));
}
#endif
}It's not just an assignment inside the outer if, so analyzer shouldn't trigger here, what do you think? |
The system is different, CI errored on Linux and macOS and I use Windows. 3 cases were inside 4th one has |
We can rewrite the code block into this and it should please Analyzer on both platforms: #if UNIX
s_defaultMshSnapins ??= new List<DefaultPSSnapInInformation>()
{
new DefaultPSSnapInInformation("Microsoft.PowerShell.Host", "Microsoft.PowerShell.ConsoleHost", null,
"HostMshSnapInResources,Description", "HostMshSnapInResources,Vendor"),
s_coreSnapin,
new DefaultPSSnapInInformation("Microsoft.PowerShell.Utility", "Microsoft.PowerShell.Commands.Utility", null,
"UtilityMshSnapInResources,Description", "UtilityMshSnapInResources,Vendor"),
new DefaultPSSnapInInformation("Microsoft.PowerShell.Management", "Microsoft.PowerShell.Commands.Management", null,
"ManagementMshSnapInResources,Description", "ManagementMshSnapInResources,Vendor"),
new DefaultPSSnapInInformation("Microsoft.PowerShell.Security", "Microsoft.PowerShell.Security", null,
"SecurityMshSnapInResources,Description", "SecurityMshSnapInResources,Vendor")
};
#else
if (s_defaultMshSnapins == null)
{
s_defaultMshSnapins = new List<DefaultPSSnapInInformation>()
{
new DefaultPSSnapInInformation("Microsoft.PowerShell.Diagnostics", "Microsoft.PowerShell.Commands.Diagnostics", null,
"GetEventResources,Description", "GetEventResources,Vendor"),
new DefaultPSSnapInInformation("Microsoft.PowerShell.Host", "Microsoft.PowerShell.ConsoleHost", null,
"HostMshSnapInResources,Description", "HostMshSnapInResources,Vendor"),
s_coreSnapin,
new DefaultPSSnapInInformation("Microsoft.PowerShell.Utility", "Microsoft.PowerShell.Commands.Utility", null,
"UtilityMshSnapInResources,Description", "UtilityMshSnapInResources,Vendor"),
new DefaultPSSnapInInformation("Microsoft.PowerShell.Management", "Microsoft.PowerShell.Commands.Management", null,
"ManagementMshSnapInResources,Description", "ManagementMshSnapInResources,Vendor"),
new DefaultPSSnapInInformation("Microsoft.PowerShell.Security", "Microsoft.PowerShell.Security", null,
"SecurityMshSnapInResources,Description", "SecurityMshSnapInResources,Vendor")
};
if (!Utils.IsWinPEHost())
{
s_defaultMshSnapins.Add(new DefaultPSSnapInInformation("Microsoft.WSMan.Management", "Microsoft.WSMan.Management", null,
"WsManResources,Description", "WsManResources,Vendor"));
}
}
#endifOr we can ignore this rule locally. I'll let the maintainers decide. |
Please suppress locally. |
@iSazonov, done |
|
@Molkree I guess CIs fail because we need to fix compound assignment in test code (weblistener). |
|
@iSazonov, I am stumped, from failing tests I can only see that the |
|
@Molkree Try compile |
@iSazonov, thank you! |
|
🎉 Handy links: |
PR Summary
Reenable compound assignment preference in .editorconfig.
PR Context
All violations of the rule should be fixed by now.
Fixes #17631
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).