Skip to content

Add more info about output type #46573

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

Merged
merged 2 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ This section lists the available configuration options for code analyzers. For m

| Description | Allowable values | Default value | Configurable rules |
|-------------|------------------|---------------|--------------------|
| 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) |
| 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) |

### required_modifiers

Expand Down
20 changes: 17 additions & 3 deletions docs/fundamentals/code-analysis/quality-rules/ca1515.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "CA1515: Consider making public types internal"
description: "Learn about code analyzer rule CA1515 - Consider making public types internal"
ms.date: 12/07/2023
ms.date: 06/04/2025
ms.topic: reference
f1_keywords:
- CA1515
Expand Down Expand Up @@ -43,7 +43,7 @@ Mark the type as `internal`.
The following code snippet shows a violation of CA1515:

```csharp
// Inside a project with <OutputKind>Exe</OutputKind>
// Inside a project with <OutputKind>Exe</OutputKind>.
public class Program
{
public static void Main(string[] args)
Expand All @@ -53,6 +53,7 @@ public class Program
```

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

```csharp
// Inside a project with <OutputKind>Exe</OutputKind>
// Inside a project with <OutputKind>Exe</OutputKind>.
internal class Program
{
public static void Main(string[] args)
Expand All @@ -72,12 +73,15 @@ internal class Program
```

```vb
' Inside a project with <OutputKind>Exe</OutputKind>.
Friend Class Program
Public Shared Sub Main(args As string())
End Sub
End Class
```

(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).)

## When to suppress warnings

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

For more information, see [How to suppress code analysis warnings](../suppress-warnings.md).

## Configure code to analyze

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:

```ini
dotnet_code_quality.CA1515.output_kind = ConsoleApplication, DynamicallyLinkedLibrary
```

For more information, see [output_kind](../code-quality-rule-options.md#output_kind).