-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Reenable compound assignment preference #17784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reenable compound assignment preference #17784
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"));
}
}
#endif Or 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
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).