Skip to content

Conversation

@xtqqczze
Copy link
Contributor

Enable CA1812: Avoid uninstantiated internal classes

Add suppression for classes instantiated with System.Activator.CreateInstance.

@ghost ghost assigned iSazonov Jun 25, 2021
@xtqqczze
Copy link
Contributor Author

D:\a\1\s\src\Microsoft.Management.UI.Internal\commandHelpers\OutGridView.cs(21,20): error CA1812: OutGridViewWindow is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it static (Shared in Visual Basic). [D:\a\1\s\src\Microsoft.Management.UI.Internal\Microsoft.PowerShell.GraphicalHost_j30bp2hs_wpftmp.csproj]
D:\a\1\s\src\Microsoft.Management.UI.Internal\ManagementList\Common\WeakEventListener.cs(13,20): error CA1812: WeakEventListener<TEventArgs> is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it static (Shared in Visual Basic). [D:\a\1\s\src\Microsoft.Management.UI.Internal\Microsoft.PowerShell.GraphicalHost_j30bp2hs_wpftmp.csproj]
D:\a\1\s\src\Microsoft.Management.UI.Internal\commandHelpers\ShowCommandHelper.cs(26,20): error CA1812: ShowCommandHelper is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it static (Shared in Visual Basic). [D:\a\1\s\src\Microsoft.Management.UI.Internal\Microsoft.PowerShell.GraphicalHost_j30bp2hs_wpftmp.csproj]

I thought we had suppressed analyzers in Microsoft.Management.UI.Internal, now this is ineffective?

is_global = true
dotnet_analyzer_diagnostic.severity = none

@xtqqczze
Copy link
Contributor Author

xtqqczze commented Jun 25, 2021

The Microsoft.Management.UI.Internal analyzers issue is resolved in #15677 by setting RunAnalyzers to false in Microsoft.PowerShell.GraphicalHost.csproj.

@xtqqczze xtqqczze closed this Jun 25, 2021
@xtqqczze xtqqczze reopened this Jun 26, 2021
@iSazonov iSazonov added the CL-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log label Jun 27, 2021
@iSazonov iSazonov merged commit b77bbf8 into PowerShell:master Jun 27, 2021
@xtqqczze xtqqczze deleted the CA1812 branch June 27, 2021 16:05
@ghost
Copy link

ghost commented Jul 22, 2021

🎉v7.2.0-preview.8 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-CodeCleanup Indicates that a PR should be marked as a Code Cleanup change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants