You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Specifies that code in a project that generates this type of assembly should be analyzed | One or more fields of the <xref:Microsoft.CodeAnalysis.OutputKind> enumeration<br/><br/>Separate multiple values with a comma (,) | All output kinds | [CA2007](quality-rules/ca2007.md) |
138
+
| Specifies that code in a project that generates this type of assembly should be analyzed | One or more fields of the <xref:Microsoft.CodeAnalysis.OutputKind> enumeration<br/><br/>Separate multiple values with a comma (,) | All output kinds | [CA1515](quality-rules/ca1515.md) [CA2007](quality-rules/ca2007.md) |
Copy file name to clipboardExpand all lines: docs/fundamentals/code-analysis/quality-rules/ca1515.md
+17-3Lines changed: 17 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "CA1515: Consider making public types internal"
3
3
description: "Learn about code analyzer rule CA1515 - Consider making public types internal"
4
-
ms.date: 12/07/2023
4
+
ms.date: 06/04/2025
5
5
ms.topic: reference
6
6
f1_keywords:
7
7
- CA1515
@@ -43,7 +43,7 @@ Mark the type as `internal`.
43
43
The following code snippet shows a violation of CA1515:
44
44
45
45
```csharp
46
-
// Inside a project with <OutputKind>Exe</OutputKind>
46
+
// Inside a project with <OutputKind>Exe</OutputKind>.
47
47
publicclassProgram
48
48
{
49
49
publicstaticvoidMain(string[] args)
@@ -53,6 +53,7 @@ public class Program
53
53
```
54
54
55
55
```vb
56
+
' Inside a project with <OutputKind>Exe</OutputKind>.
56
57
PublicClassProgram
57
58
PublicSharedSubMain(argsAsstring())
58
59
EndSub
@@ -62,7 +63,7 @@ End Class
62
63
The following code snippet fixes the violation:
63
64
64
65
```csharp
65
-
// Inside a project with <OutputKind>Exe</OutputKind>
66
+
// Inside a project with <OutputKind>Exe</OutputKind>.
66
67
internalclassProgram
67
68
{
68
69
publicstaticvoidMain(string[] args)
@@ -72,12 +73,15 @@ internal class Program
72
73
```
73
74
74
75
```vb
76
+
' Inside a project with <OutputKind>Exe</OutputKind>.
75
77
FriendClassProgram
76
78
PublicSharedSubMain(argsAsstring())
77
79
EndSub
78
80
EndClass
79
81
```
80
82
83
+
(For more information about the output type of a project, see [the "Output type" section of .NET Project Designer](/visualstudio/ide/reference/project-designer-dotnet-csharp#application-general-settings).)
84
+
81
85
## When to suppress warnings
82
86
83
87
It's safe to suppress a violation of this rule if you're not concerned about the maintainability of your code.
For more information, see [How to suppress code analysis warnings](../suppress-warnings.md).
107
+
108
+
## Configure code to analyze
109
+
110
+
You can configure which _output assembly kinds_ to apply this rule to. For example, to only apply this rule to code that produces a console application or a dynamically linked library (that is, not a UI app), add the following key-value pair to an *.editorconfig* file in your project:
0 commit comments