diff --git a/docs/fundamentals/code-analysis/code-quality-rule-options.md b/docs/fundamentals/code-analysis/code-quality-rule-options.md index d83ab5318d614..12c8f7b3d4194 100644 --- a/docs/fundamentals/code-analysis/code-quality-rule-options.md +++ b/docs/fundamentals/code-analysis/code-quality-rule-options.md @@ -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 enumeration

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 enumeration

Separate multiple values with a comma (,) | All output kinds | [CA1515](quality-rules/ca1515.md) [CA2007](quality-rules/ca2007.md) | ### required_modifiers diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1515.md b/docs/fundamentals/code-analysis/quality-rules/ca1515.md index 43e9f4392fd08..f1d6cecba0085 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1515.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1515.md @@ -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 @@ -43,7 +43,7 @@ Mark the type as `internal`. The following code snippet shows a violation of CA1515: ```csharp -// Inside a project with Exe +// Inside a project with Exe. public class Program { public static void Main(string[] args) @@ -53,6 +53,7 @@ public class Program ``` ```vb +' Inside a project with Exe. Public Class Program Public Shared Sub Main(args As string()) End Sub @@ -62,7 +63,7 @@ End Class The following code snippet fixes the violation: ```csharp -// Inside a project with Exe +// Inside a project with Exe. internal class Program { public static void Main(string[] args) @@ -72,12 +73,15 @@ internal class Program ``` ```vb +' Inside a project with Exe. 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. @@ -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).