Skip to content

Commit 4fcc57a

Browse files
authored
Add more info about output type (#46573)
1 parent 967d28b commit 4fcc57a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

docs/fundamentals/code-analysis/code-quality-rule-options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ This section lists the available configuration options for code analyzers. For m
135135
136136
| Description | Allowable values | Default value | Configurable rules |
137137
|-------------|------------------|---------------|--------------------|
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 | [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) |
139139
140140
### required_modifiers
141141

docs/fundamentals/code-analysis/quality-rules/ca1515.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "CA1515: Consider making public types internal"
33
description: "Learn about code analyzer rule CA1515 - Consider making public types internal"
4-
ms.date: 12/07/2023
4+
ms.date: 06/04/2025
55
ms.topic: reference
66
f1_keywords:
77
- CA1515
@@ -43,7 +43,7 @@ Mark the type as `internal`.
4343
The following code snippet shows a violation of CA1515:
4444

4545
```csharp
46-
// Inside a project with <OutputKind>Exe</OutputKind>
46+
// Inside a project with <OutputKind>Exe</OutputKind>.
4747
public class Program
4848
{
4949
public static void Main(string[] args)
@@ -53,6 +53,7 @@ public class Program
5353
```
5454

5555
```vb
56+
' Inside a project with <OutputKind>Exe</OutputKind>.
5657
Public Class Program
5758
Public Shared Sub Main(args As string())
5859
End Sub
@@ -62,7 +63,7 @@ End Class
6263
The following code snippet fixes the violation:
6364

6465
```csharp
65-
// Inside a project with <OutputKind>Exe</OutputKind>
66+
// Inside a project with <OutputKind>Exe</OutputKind>.
6667
internal class Program
6768
{
6869
public static void Main(string[] args)
@@ -72,12 +73,15 @@ internal class Program
7273
```
7374

7475
```vb
76+
' Inside a project with <OutputKind>Exe</OutputKind>.
7577
Friend Class Program
7678
Public Shared Sub Main(args As string())
7779
End Sub
7880
End Class
7981
```
8082

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+
8185
## When to suppress warnings
8286

8387
It's safe to suppress a violation of this rule if you're not concerned about the maintainability of your code.
@@ -100,3 +104,13 @@ dotnet_diagnostic.CA1515.severity = none
100104
```
101105

102106
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:
111+
112+
```ini
113+
dotnet_code_quality.CA1515.output_kind = ConsoleApplication, DynamicallyLinkedLibrary
114+
```
115+
116+
For more information, see [output_kind](../code-quality-rule-options.md#output_kind).

0 commit comments

Comments
 (0)