Skip to content

Repo sync for protected CLA branch #5751

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 5 commits into from
Aug 19, 2020
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 @@ -288,6 +288,7 @@ f1_keywords:
- CA5122
- CA5374
- IL3000
- IL3001
ms.assetid: 5cb221f6-dc59-4abf-9bfa-adbd6f907f96
author: mikejo5000
ms.author: mikejo
Expand Down Expand Up @@ -369,7 +370,7 @@ The following table lists Code Analysis warnings for managed code by the CheckId
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
Expand Down Expand Up @@ -458,7 +459,7 @@ The following table lists Code Analysis warnings for managed code by the CheckId
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
Expand Down Expand Up @@ -600,4 +601,5 @@ The following table lists Code Analysis warnings for managed code by the CheckId
| 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. |
| 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. |
| 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. |
| 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 |
| 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 |
| 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 |
4 changes: 2 additions & 2 deletions docs/code-quality/il3000.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "IL3000: Avoid using accessing Assembly file path when publishing as a single-file"
title: "IL3000: Avoid accessing Assembly file path when publishing as a single file"
description: "Assembly.Location always returns an empty string for assemblies embedded in a single-file bundle"
ms.date: 08/04/2020
ms.topic: reference
Expand All @@ -12,7 +12,7 @@ f1_keywords:
- "IL3000"
- "AvoidAssemblyLocationInSingleFile"
---
# IL3000: Avoid using accessing Assembly file path when publishing as a single-file
# IL3000: Avoid accessing Assembly file path when publishing as a single file

## Cause

Expand Down
28 changes: 28 additions & 0 deletions docs/code-quality/il3001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: "IL3001: Avoid accessing Assembly file path when publishing as a single file"
description: "Assembly.GetFile(s) will throw for assemblies embedded in a single-file app"
ms.date: 08/18/2020
ms.topic: reference
author: agocke
ms.author: angocke
manager: angocke
ms.workload:
- "multiple"
f1_keywords:
- "IL3001"
- "AvoidAssemblyLocationInSingleFile"
---
# IL3001: Avoid accessing Assembly file path when publishing as a single file

## Cause

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
assemblies embedded inside the single-file bundle always throws an exception.

## How to fix violations

To embed files in assemblies in single-file bundles, consider using embedded resources and the `Assembly.GetManifestResourceStream` method.

## When to suppress warnings

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.
4 changes: 3 additions & 1 deletion docs/code-quality/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -989,5 +989,7 @@
items:
- name: Overview
displayName: "publish warnings"
- name: "IL3000: Avoid using accessing Assembly file path when publishing as a single-file"
- name: "IL3000: Avoid accessing Assembly file path when publishing as a single file"
href: il3000.md
- name: "IL3001: Avoid accessing Assembly file path when publishing as a single file"
href: il3001.md