Skip to content

Commit 328ab0d

Browse files
authored
Merge pull request #7025 from agocke/add-il3001
Add docs for IL3001
2 parents 98af63c + 08f0fd9 commit 328ab0d

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

docs/code-quality/code-analysis-warnings-for-managed-code-by-checkid.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ f1_keywords:
288288
- CA5122
289289
- CA5374
290290
- IL3000
291+
- IL3001
291292
ms.assetid: 5cb221f6-dc59-4abf-9bfa-adbd6f907f96
292293
author: mikejo5000
293294
ms.author: mikejo
@@ -369,7 +370,7 @@ The following table lists Code Analysis warnings for managed code by the CheckId
369370
| CA1070 | [CA1070: Do not declare event fields as virtual](../code-quality/ca1070.md) | A [field-like event](/dotnet/csharp/language-reference/language-specification/classes#field-like-events) was declared as virtual. |
370371
| CA1200 | [CA1200: Avoid using cref tags with a prefix](../code-quality/ca1200.md) | The [cref](/dotnet/csharp/programming-guide/xmldoc/cref-attribute) attribute in an XML documentation tag means "code reference". It specifies that the inner text of the tag is a code element, such as a type, method, or property. Avoid using `cref` tags with prefixes, because it prevents the compiler from verifying references. It also prevents the Visual Studio integrated development environment (IDE) from finding and updating these symbol references during refactorings. |
371372
| CA1300 | [CA1300: Specify MessageBoxOptions](../code-quality/ca1300.md) | To correctly display a message box for cultures that use a right-to-left reading order, the RightAlign and RtlReading members of the MessageBoxOptions enumeration must be passed to the Show method. |
372-
| CA1301 | [CA1301: Avoid duplicate accelerators](../code-quality/ca1301.md) | An access key, also known as an accelerator, enables keyboard access to a control by using the ALT key. When multiple controls have duplicate access keys, the behavior of the access key is not well-defined. |
373+
| CA1301 | [CA1301: Avoid duplicate accelerators](../code-quality/ca1301.md) | An access key, also known as an accelerator, enables keyboard access to a control by using the ALT key. When multiple controls have duplicate access keys, the behavior of the access key is not well defined. |
373374
| CA1302 | [CA1302: Do not hardcode locale specific strings](../code-quality/ca1302.md) | The System.Environment.SpecialFolder enumeration contains members that refer to special system folders. The locations of these folders can have different values on different operating systems; the user can change some of the locations; and the locations are localized. The Environment.GetFolderPath method returns the locations that are associated with the Environment.SpecialFolder enumeration, localized and appropriate for the currently running computer. |
374375
| CA1303 | [CA1303: Do not pass literals as localized parameters](../code-quality/ca1303.md) | An externally visible method passes a string literal as a parameter to a .NET constructor or method, and that string should be localizable. |
375376
| CA1304 | [CA1304: Specify CultureInfo](../code-quality/ca1304.md) | A method or constructor calls a member that has an overload that accepts a System.Globalization.CultureInfo parameter, and the method or constructor does not call the overload that takes the CultureInfo parameter. When a CultureInfo or System.IFormatProvider object is not supplied, the default value that is supplied by the overloaded member might not have the effect that you want in all locales. |
@@ -458,7 +459,7 @@ The following table lists Code Analysis warnings for managed code by the CheckId
458459
| CA1831 |[CA1831: Use AsSpan instead of Range-based indexers for string when appropriate](../code-quality/ca1831.md) | When using a range-indexer on a string and implicitly assigning the value to ReadOnlySpan&lt;char&gt; type, the method <xref:System.String.Substring%2A?#System_String_Substring_System_Int32_System_Int32_> will be used instead of <xref:System.Span%601.Slice%2A?#System_Span_1_Slice_System_Int32_System_Int32_>, which produces a copy of requested portion of the string. |
459460
| CA1832 |[CA1832: Use AsSpan or AsMemory instead of Range-based indexers for getting ReadOnlySpan or ReadOnlyMemory portion of an array](../code-quality/ca1832.md) | When using a range-indexer on an array and implicitly assigning the value to a <xref:System.ReadOnlySpan%601> or <xref:System.ReadOnlyMemory%601> type, the method <xref:System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray%2A> will be used instead of <xref:System.Span%601.Slice%2A?#System_Span_1_Slice_System_Int32_System_Int32_>, which produces a copy of requested portion of the array. |
460461
| CA1833 |[CA1833: Use AsSpan or AsMemory instead of Range-based indexers for getting Span or Memory portion of an array](../code-quality/ca1833.md) | When using a range-indexer on an array and implicitly assigning the value to a <xref:System.Span%601> or <xref:System.Memory%601> type, the method <xref:System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray%2A> will be used instead of <xref:System.Span%601.Slice%2A?#System_Span_1_Slice_System_Int32_System_Int32_>, which produces a copy of requested portion of the array. |
461-
| CA1835 |[CA1835: Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync'](../code-quality/ca1835.md) | 'Stream' has a 'ReadAsync' overload that takes a 'Memory&lt;Byte&gt;' as the first argument, and a 'WriteAsync' overload that takes a 'ReadOnlyMemory&lt;Byte&gt;' as the first argument. Prefer calling the memory based overloads, which are more efficient. |
462+
| CA1835 |[CA1835: Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync'](../code-quality/ca1835.md) | 'Stream' has a 'ReadAsync' overload that takes a 'Memory&lt;Byte&gt;' as the first argument, and a 'WriteAsync' overload that takes a 'ReadOnlyMemory&lt;Byte&gt;' as the first argument. Prefer calling the memory-based overloads, which are more efficient. |
462463
| CA1836 |[CA1836: Prefer `IsEmpty` over `Count` when available](../code-quality/ca1836.md) | Prefer `IsEmpty` property that is more efficient than `Count`, `Length`, <xref:System.Linq.Enumerable.Count%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%29> or <xref:System.Linq.Enumerable.LongCount%60%601%28System.Collections.Generic.IEnumerable%7B%60%600%7D%29> to determine whether the object contains or not any items. |
463464
| CA1838 | [CA1838: Avoid `StringBuilder` parameters for P/Invokes](../code-quality/ca1838.md) | Marshaling of 'StringBuilder' always creates a native buffer copy, resulting in multiple allocations for one marshaling operation. |
464465
| CA1900 | [CA1900: Value type fields should be portable](../code-quality/ca1900.md) | This rule checks that structures that are declared by using explicit layout will align correctly when marshaled to unmanaged code on 64-bit operating systems. |
@@ -600,4 +601,5 @@ The following table lists Code Analysis warnings for managed code by the CheckId
600601
| CA5400 | [CA5400 Ensure HttpClient certificate revocation list check is not disabled](../code-quality/ca5400.md) | A revoked certificate isn't trusted anymore. It could be used by attackers passing some malicious data or stealing sensitive data in HTTPS communication. |
601602
| CA5401 | [CA5401 Do not use CreateEncryptor with non-default IV](../code-quality/ca5401.md) | Symmetric encryption should always use a non-repeatable initialization vector to prevent dictionary attacks. |
602603
| CA5402 | [CA5402 Use CreateEncryptor with the default IV](../code-quality/ca5402.md) | Symmetric encryption should always use a non-repeatable initialization vector to prevent dictionary attacks. |
603-
| IL3000 | [IL3000 Avoid using accessing Assembly file path when publishing as a single-file](../code-quality/il3000.md) | Avoid using accessing Assembly file path when publishing as a single-file |
604+
| IL3000 | [IL3000 Avoid accessing Assembly file path when publishing as a single file](../code-quality/il3000.md) | Avoid using accessing Assembly file path when publishing as a single file |
605+
| IL3001 | [IL3001 Avoid accessing Assembly file path when publishing as a single-file](../code-quality/il3001.md) | Avoid accessing Assembly file path when publishing as a single-file |

docs/code-quality/il3000.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "IL3000: Avoid using accessing Assembly file path when publishing as a single-file"
2+
title: "IL3000: Avoid accessing Assembly file path when publishing as a single file"
33
description: "Assembly.Location always returns an empty string for assemblies embedded in a single-file bundle"
44
ms.date: 08/04/2020
55
ms.topic: reference
@@ -12,7 +12,7 @@ f1_keywords:
1212
- "IL3000"
1313
- "AvoidAssemblyLocationInSingleFile"
1414
---
15-
# IL3000: Avoid using accessing Assembly file path when publishing as a single-file
15+
# IL3000: Avoid accessing Assembly file path when publishing as a single file
1616

1717
## Cause
1818

docs/code-quality/il3001.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: "IL3001: Avoid accessing Assembly file path when publishing as a single file"
3+
description: "Assembly.GetFile(s) will throw for assemblies embedded in a single-file app"
4+
ms.date: 08/18/2020
5+
ms.topic: reference
6+
author: agocke
7+
ms.author: angocke
8+
manager: angocke
9+
ms.workload:
10+
- "multiple"
11+
f1_keywords:
12+
- "IL3001"
13+
- "AvoidAssemblyLocationInSingleFile"
14+
---
15+
# IL3001: Avoid accessing Assembly file path when publishing as a single file
16+
17+
## Cause
18+
19+
When publishing as a single file (for example, by setting the PublishSingleFile property in a project to true), calling the `Assembly.GetFile(s)` methods for
20+
assemblies embedded inside the single-file bundle always throws an exception.
21+
22+
## How to fix violations
23+
24+
To embed files in assemblies in single-file bundles, consider using embedded resources and the `Assembly.GetManifestResourceStream` method.
25+
26+
## When to suppress warnings
27+
28+
It's appropriate to silence this warning if the assembly being accessed is definitely not in the single-file bundle. This may be the case if the assembly is being loaded dynamically from a file path.

docs/code-quality/toc.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,5 +989,7 @@
989989
items:
990990
- name: Overview
991991
displayName: "publish warnings"
992-
- name: "IL3000: Avoid using accessing Assembly file path when publishing as a single-file"
992+
- name: "IL3000: Avoid accessing Assembly file path when publishing as a single file"
993993
href: il3000.md
994+
- name: "IL3001: Avoid accessing Assembly file path when publishing as a single file"
995+
href: il3001.md

0 commit comments

Comments
 (0)