Skip to content

Commit c4a798b

Browse files
authored
Merge pull request #1711 from gewarren/gewarren-neutral-lang
Fixes issue 755
2 parents edbd91e + 55e592c commit c4a798b

File tree

1 file changed

+52
-42
lines changed

1 file changed

+52
-42
lines changed
Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,65 @@
11
---
22
title: "CA1824: Mark assemblies with NeutralResourcesLanguageAttribute | Microsoft Docs"
3-
ms.custom: ""
4-
ms.date: "11/04/2016"
5-
ms.reviewer: ""
6-
ms.suite: ""
7-
ms.technology:
8-
- "vs-ide-code-analysis"
9-
ms.tgt_pltfrm: ""
10-
ms.topic: "article"
11-
f1_keywords:
3+
ms.date: 03/29/2018
4+
ms.technology: vs-ide-code-analysis
5+
ms.topic: reference
6+
f1_keywords:
127
- "CA1824"
138
- "MarkAssembliesWithNeutralResourcesLanguage"
14-
helpviewer_keywords:
9+
helpviewer_keywords:
1510
- "MarkAssembliesWithNeutralResourcesLanguage"
1611
- "CA1824"
1712
ms.assetid: 10e97f8a-aa6e-47aa-b253-1e5d3a295d82
18-
caps.latest.revision: 12
1913
author: "gewarren"
2014
ms.author: "gewarren"
2115
manager: ghogen
22-
ms.workload:
16+
ms.workload:
2317
- "multiple"
2418
---
2519
# CA1824: Mark assemblies with NeutralResourcesLanguageAttribute
26-
|||
27-
|-|-|
28-
|TypeName|MarkAssembliesWithNeutralResourcesLanguage|
29-
|CheckId|CA1824|
30-
|Category|Microsoft.Performance|
31-
|Breaking Change|Non-breaking|
32-
33-
## Cause
34-
An assembly contains a **ResX**-based resource but does not have the <xref:System.Resources.NeutralResourcesLanguageAttribute?displayProperty=fullName> applied to it.
35-
36-
## Rule Description
37-
The **NeutralResourcesLanguage** attribute informs the **ResourceManager** of the language that was used to display the resources of the neutral culture for an assembly. When it looks up resources in the same culture as the neutral resources language, the **ResourceManager** automatically uses the resources that are located in the main assembly. It does this instead of searching for a satellite assembly that has the current user interface culture for the current thread. This improves lookup performance for the first resource that you load and can reduce your working set.
38-
39-
## Fixing Violations
40-
To fix a violation of this rule, add the attribute to the assembly, and specify the language of the resources of the neutral culture.
41-
42-
## Specifying the Language
43-
44-
#### To specify the language of the resource of the neutral culture
45-
46-
1. In **Solution Explorer**, right-click your project, and then Click **Properties**.
47-
48-
2. From the left navigation bar select **Application**, and then click **Assembly Information**.
49-
50-
3. In the **Assembly Information** dialog box, select the language from the **Neutral Language** drop-down list.
51-
52-
4. Click **OK**.
53-
54-
## When to Suppress Warnings
55-
It is permissible to suppress a warning from this rule. However, startup performance might decrease.
20+
21+
|||
22+
|-|-|
23+
|TypeName|MarkAssembliesWithNeutralResourcesLanguage|
24+
|CheckId|CA1824|
25+
|Category|Microsoft.Performance|
26+
|Breaking Change|Non-breaking|
27+
28+
## Cause
29+
30+
An assembly contains a **ResX**-based resource but does not have the <xref:System.Resources.NeutralResourcesLanguageAttribute?displayProperty=fullName> applied to it.
31+
32+
## Rule description
33+
34+
The <xref:System.Resources.NeutralResourcesLanguageAttribute> attribute informs the resource manager of an app's default culture. If the default culture's resources are embedded in the app's main assembly, and <xref:System.Resources.ResourceManager> has to retrieve resources that belong to the same culture as the default culture, the <xref:System.Resources.ResourceManager> automatically uses the resources located in the main assembly instead of searching for a satellite assembly. This bypasses the usual assembly probe, improves lookup performance for the first resource you load, and can reduce your working set.
35+
36+
> [!TIP]
37+
> See [Packaging and deploying resources](/dotnet/framework/resources/packaging-and-deploying-resources-in-desktop-apps) for the process that <xref:System.Resources.ResourceManager> uses to probe for resource files.
38+
39+
## Fix violations
40+
41+
To fix a violation of this rule, add the attribute to the assembly, and specify the language of the resources of the neutral culture.
42+
43+
### To specify the neutral language for resources
44+
45+
1. In **Solution Explorer**, right-click your project, and then select **Properties**.
46+
47+
2. Select the **Application** tab, and then select **Assembly Information**.
48+
49+
> [!NOTE]
50+
> If your project is a .NET Standard or .NET Core project, select the **Package** tab.
51+
52+
3. Select the language from the **Neutral language** or **Assembly neutral language** drop-down list.
53+
54+
4. Select **OK**.
55+
56+
## When to suppress warnings
57+
58+
It is permissible to suppress a warning from this rule. However, startup performance might degrade.
59+
60+
## See also
61+
62+
- <xref:System.Resources.NeutralResourcesLanguageAttribute>
63+
- [Resources in desktop apps (.NET)](/dotnet/framework/resources/)
64+
- [CA1703 - Resource strings should be spelled correctly](../code-quality/ca1703-resource-strings-should-be-spelled-correctly.md)
65+
- [CA1701 - Resource string compound words should be cased correctly](../code-quality/ca1701-resource-string-compound-words-should-be-cased-correctly.md)

0 commit comments

Comments
 (0)