Skip to content

Enable CA1812: Avoid uninstantiated internal classes - #15674

Merged
Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
xtqqczze:CA1812
Jun 27, 2021
Merged

Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
xtqqczze:CA1812

Conversation

@xtqqczze

Copy link
Copy Markdown
Contributor

Enable CA1812: Avoid uninstantiated internal classes

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

@ghost ghost assigned Ilya (iSazonov) Jun 25, 2021
@xtqqczze

Copy link
Copy Markdown
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

xtqqczze commented Jun 25, 2021 •

Copy link
Copy Markdown
Contributor Author

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 Ilya (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
Ilya (iSazonov) merged commit b77bbf8 into PowerShell:master Jun 27, 2021
@xtqqczze
xtqqczze deleted the CA1812 branch June 27, 2021 16:05
@ghost

Copy link
Copy Markdown

🎉v7.2.0-preview.8 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
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