You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/code-quality/code-analysis-warnings-for-managed-code-by-checkid.md
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -288,6 +288,7 @@ f1_keywords:
288
288
- CA5122
289
289
- CA5374
290
290
- IL3000
291
+
- IL3001
291
292
ms.assetid: 5cb221f6-dc59-4abf-9bfa-adbd6f907f96
292
293
author: mikejo5000
293
294
ms.author: mikejo
@@ -369,7 +370,7 @@ The following table lists Code Analysis warnings for managed code by the CheckId
369
370
| 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. |
370
371
| 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. |
371
372
| 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 welldefined. |
373
374
| 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. |
374
375
| 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. |
375
376
| 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
458
459
| 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<char> 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. |
459
460
| 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. |
460
461
| 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<Byte>' as the first argument, and a 'WriteAsync' overload that takes a 'ReadOnlyMemory<Byte>' as the first argument. Prefer calling the memorybased 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<Byte>' as the first argument, and a 'WriteAsync' overload that takes a 'ReadOnlyMemory<Byte>' as the first argument. Prefer calling the memory-based overloads, which are more efficient. |
462
463
| 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. |
463
464
| 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. |
464
465
| 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
600
601
| 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. |
601
602
| 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. |
602
603
| 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 |
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.
0 commit comments