Skip to content

Commit 13d23f7

Browse files
authored
Merge pull request #3878 from MicrosoftDocs/master637034059079927327
For protected CLA branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 8990cf9 + 78cd6be commit 13d23f7

11 files changed

+75
-25
lines changed

docs/code-quality/ca1002-do-not-expose-generic-lists.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,33 @@ ms.workload:
2525
|Breaking Change|Breaking|
2626

2727
## Cause
28-
A type contains an externally visible member that is a <xref:System.Collections.Generic.List%601?displayProperty=fullName> type, returns a <xref:System.Collections.Generic.List%601?displayProperty=fullName> type, or whose signature includes a <xref:System.Collections.Generic.List%601?displayProperty=fullName> parameter.
28+
29+
A type contains an externally visible member that is a <xref:System.Collections.Generic.List%601?displayProperty=fullName> type, returns a <xref:System.Collections.Generic.List%601> type, or whose signature includes a <xref:System.Collections.Generic.List%601> parameter.
2930

3031
## Rule description
31-
<xref:System.Collections.Generic.List%601?displayProperty=fullName> is a generic collection that is designed for performance and not inheritance. <xref:System.Collections.Generic.List%601?displayProperty=fullName> does not contain virtual members that make it easier to change the behavior of an inherited class. The following generic collections are designed for inheritance and should be exposed instead of <xref:System.Collections.Generic.List%601?displayProperty=fullName>.
32+
33+
<xref:System.Collections.Generic.List%601?displayProperty=fullName> is a generic collection that's designed for performance and not inheritance. <xref:System.Collections.Generic.List%601> does not contain virtual members that make it easier to change the behavior of an inherited class. The following generic collections are designed for inheritance and should be exposed instead of <xref:System.Collections.Generic.List%601>.
3234

3335
- <xref:System.Collections.ObjectModel.Collection%601?displayProperty=fullName>
3436

3537
- <xref:System.Collections.ObjectModel.ReadOnlyCollection%601?displayProperty=fullName>
3638

3739
- <xref:System.Collections.ObjectModel.KeyedCollection%602?displayProperty=fullName>
3840

41+
- <xref:System.Collections.Generic.IList%601?displayProperty=fullName>
42+
43+
- <xref:System.Collections.Generic.ICollection%601?displayProperty=fullName>
44+
3945
## How to fix violations
40-
To fix a violation of this rule, change the <xref:System.Collections.Generic.List%601?displayProperty=fullName> type to one of the generic collections that is designed for inheritance.
46+
47+
To fix a violation of this rule, change the <xref:System.Collections.Generic.List%601?displayProperty=fullName> type to one of the generic collections that's designed for inheritance.
4148

4249
## When to suppress warnings
43-
Do not suppress a warning from this rule unless the assembly that raises this warning is not meant to be a reusable library. For example, it would be safe to suppress this warning in a performance tuned application where a performance benefit was gained from the use of generic lists.
50+
51+
Do not suppress a warning from this rule unless the assembly that raises this warning is not meant to be a reusable library. For example, it would be safe to suppress this warning in a performance-tuned application where a performance benefit was gained from the use of generic lists.
4452

4553
## Related rules
54+
4655
[CA1005: Avoid excessive parameters on generic types](../code-quality/ca1005-avoid-excessive-parameters-on-generic-types.md)
4756

4857
[CA1010: Collections should implement generic interface](../code-quality/ca1010-collections-should-implement-generic-interface.md)
@@ -58,4 +67,5 @@ Do not suppress a warning from this rule unless the assembly that raises this wa
5867
[CA1007: Use generics where appropriate](../code-quality/ca1007-use-generics-where-appropriate.md)
5968

6069
## See also
61-
[Generics](/dotnet/csharp/programming-guide/generics/index)
70+
71+
[Generics](/dotnet/csharp/programming-guide/generics/index)

docs/code-quality/ca1051-do-not-declare-visible-instance-fields.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,24 @@ By default, this rule only looks at externally visible types, but this is [confi
3232

3333
## Rule description
3434

35-
The primary use of a field should be as an implementation detail. Fields should be `private` or `internal` and should be exposed by using properties. It is as easy to access a property as it is to access a field, and the code in the accessors of a property can change as the features of the type expand without introducing breaking changes. Properties that just return the value of a private or internal field are optimized to perform on par with accessing a field; very little performance gain is associated with the use of externally visible fields over properties.
35+
The primary use of a field should be as an implementation detail. Fields should be `private` or `internal` and should be exposed by using properties. It's as easy to access a property as it is to access a field, and the code in the accessors of a property can change as the features of the type expand without introducing breaking changes.
3636

37-
Externally visible refers to `public`, `protected`, and `protected internal` (`Public`, `Protected`, and `Protected Friend` in Visual Basic) accessibility levels.
37+
Properties that just return the value of a private or internal field are optimized to perform on par with accessing a field; the performance gain from using externally visible fields instead of properties is minimal. *Externally visible* refers to `public`, `protected`, and `protected internal` (`Public`, `Protected`, and `Protected Friend` in Visual Basic) accessibility levels.
38+
39+
Additionally, public fields cannot be protected by [Link demands](/dotnet/framework/misc/link-demands). For more information, see [CA2112: Secured types should not expose fields](../code-quality/ca2112-secured-types-should-not-expose-fields.md). (Link demands are not applicable to .NET Core apps.)
3840

3941
## How to fix violations
4042

4143
To fix a violation of this rule, make the field `private` or `internal` and expose it by using an externally visible property.
4244

4345
## When to suppress warnings
4446

45-
Do not suppress a warning from this rule. Externally visible fields do not provide any benefits that are unavailable to properties. Additionally, public fields cannot be protected by [Link Demands](/dotnet/framework/misc/link-demands). See [CA2112: Secured types should not expose fields](../code-quality/ca2112-secured-types-should-not-expose-fields.md).
47+
Only suppress this warning if you're certain that consumers need direct access to the field. For most applications, exposed fields do not provide performance or maintainability benefits over properties.
48+
49+
Consumers may need field access in the following situations:
50+
51+
- in ASP.NET Web Forms content controls
52+
- when the target platform makes use of `ref` to modify fields, such as model-view-viewmodel (MVVM) frameworks for WPF and UWP
4653

4754
## Configurability
4855

@@ -66,4 +73,4 @@ The following example shows a type (`BadPublicInstanceFields`) that violates thi
6673

6774
## See also
6875

69-
- [Link Demands](/dotnet/framework/misc/link-demands)
76+
- [Link Demands](/dotnet/framework/misc/link-demands)

docs/code-quality/ca1801-review-unused-parameters.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,23 @@ This rule does not examine the following kinds of methods:
4343

4444
- Methods declared with the `extern` (`Declare` statement in Visual Basic) modifier.
4545

46+
If you're using [FxCop analyzers](install-fxcop-analyzers.md), this rule does not flag parameters that are named with the [discard](/dotnet/csharp/discards) symbol, for example, `_`, `_1`, and `_2`. This reduces warning noise on parameters that are needed for signature requirements, for example, a method used as a delegate, a parameter with special attributes, or a parameter whose value is implicitly accessed at run time by a framework but is not referenced in code.
47+
4648
## Rule description
4749

48-
Review parameters in non-virtual methods that are not used in the method body to make sure no correctness exists around failure to access them. Unused parameters incur maintenance and performance costs.
50+
Review parameters in non-virtual methods that are not used in the method body to make sure no incorrectness exists around failure to access them. Unused parameters incur maintenance and performance costs.
4951

50-
Sometimes a violation of this rule can point to an implementation bug in the method. For example, the parameter should have been used in the method body. Suppress warnings of this rule if the parameter has to exist because of backward compatibility.
52+
Sometimes, a violation of this rule can point to an implementation bug in the method. For example, the parameter should have been used in the method body. Suppress warnings of this rule if the parameter must exist because of backward compatibility.
5153

5254
## How to fix violations
5355

54-
To fix a violation of this rule, remove the unused parameter (a breaking change) or use the parameter in the method body (a non-breaking change).
56+
To fix a violation of this rule, remove the unused parameter (a breaking change), or use the parameter in the method body (a non-breaking change).
5557

5658
## When to suppress warnings
5759

5860
It is safe to suppress a warning from this rule:
5961

60-
- For previously shipped code for which the fix would be a breaking change.
62+
- In previously shipped code for which the fix would be a breaking change.
6163

6264
- For the `this` parameter in a custom extension method for <xref:Microsoft.VisualStudio.TestTools.UnitTesting.Assert?displayProperty=nameWithType>. The functions in the <xref:Microsoft.VisualStudio.TestTools.UnitTesting.Assert> class are static, so there's no need to access the `this` parameter in the method body.
6365

@@ -73,4 +75,4 @@ The following example shows two methods. One method violates the rule and the ot
7375

7476
[CA1812: Avoid uninstantiated internal classes](../code-quality/ca1812-avoid-uninstantiated-internal-classes.md)
7577

76-
[CA1804: Remove unused locals](../code-quality/ca1804-remove-unused-locals.md)
78+
[CA1804: Remove unused locals](../code-quality/ca1804-remove-unused-locals.md)

docs/code-quality/ca1821-remove-empty-finalizers.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,23 @@ ms.workload:
2424
|Breaking Change|Non-breaking|
2525

2626
## Cause
27+
2728
A type implements a finalizer that is empty, calls only the base type finalizer, or calls only conditionally emitted methods.
2829

2930
## Rule description
30-
Whenever you can, avoid finalizers because of the additional performance overhead that is involved in tracking object lifetime. The garbage collector will run the finalizer before it collects the object. This means that two collections will be required to collect the object. An empty finalizer incurs this added overhead without any benefit.
31+
32+
Whenever you can, avoid finalizers because of the additional performance overhead that's involved in tracking object lifetime. The garbage collector runs the finalizer before it collects the object. This means that at least two collections are required to collect the object. An empty finalizer incurs this added overhead without any benefit.
3133

3234
## How to fix violations
35+
3336
Remove the empty finalizer. If a finalizer is required for debugging, enclose the whole finalizer in `#if DEBUG / #endif` directives.
3437

3538
## When to suppress warnings
36-
Do not suppress a message from this rule. Failure to suppress finalization decreases performance and provides no benefits.
39+
40+
Do not suppress a message from this rule.
3741

3842
## Example
43+
3944
The following example shows an empty finalizer that should be removed, a finalizer that should be enclosed in `#if DEBUG / #endif` directives, and a finalizer that uses the `#if DEBUG / #endif` directives correctly.
4045

41-
[!code-csharp[FxCop.Performance.RemoveEmptyFinalizers#1](../code-quality/codesnippet/CSharp/ca1821-remove-empty-finalizers_1.cs)]
46+
[!code-csharp[FxCop.Performance.RemoveEmptyFinalizers#1](../code-quality/codesnippet/CSharp/ca1821-remove-empty-finalizers_1.cs)]

docs/code-quality/ca2213-disposable-fields-should-be-disposed.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,28 @@ The following snippet shows a type `TypeB` that violates rule CA2213 by declarin
6767

6868
[!code-csharp[FxCop.Usage.IDisposableFields#1](../code-quality/codesnippet/CSharp/ca2213-disposable-fields-should-be-disposed_2.cs)]
6969

70+
To fix the violation, call `Dispose()` on the disposable field:
71+
72+
```csharp
73+
protected virtual void Dispose(bool disposing)
74+
{
75+
if (!disposed)
76+
{
77+
// Dispose of resources held by this instance.
78+
aFieldOfADisposableType.Dispose();
79+
80+
disposed = true;
81+
82+
// Suppress finalization of this disposed instance.
83+
if (disposing)
84+
{
85+
GC.SuppressFinalize(this);
86+
}
87+
}
88+
}
89+
```
90+
7091
## See also
7192

7293
- <xref:System.IDisposable?displayProperty=fullName>
73-
- [Dispose Pattern](/dotnet/standard/design-guidelines/dispose-pattern)
94+
- [Dispose pattern](/dotnet/standard/design-guidelines/dispose-pattern)

docs/ide/code-snippets.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Code snippets are small blocks of reusable code that can be inserted in a code f
2525
> [!NOTE]
2626
> This topic applies to Visual Studio on Windows. For Visual Studio for Mac, see [Code snippets (Visual Studio for Mac)](/visualstudio/mac/snippets).
2727
28-
Code snippets are available for a multitude of languages, including C#, C++, Visual Basic, XML, and T-SQL, to name a few. To view all the available installed snippets for a language, open the **Code Snippets Manager** from the **Tools** menu in Visual Studio, and choose the language from the drop-down menu at the top.
28+
Code snippets are available for a multitude of languages, including C#, C++, Visual Basic, XML, and T-SQL, to name a few. To view all the available installed snippets for a language, open the **Code Snippets Manager** from the **Tools** menu (or, press **Ctrl**+**K**, **Ctrl**+**B**), and choose the language from the drop-down menu at the top.
2929

3030
![Code Snippets Manager dialog box](media/code-snippets-manager.png)
3131

@@ -35,7 +35,7 @@ Code snippets can be accessed in the following general ways:
3535

3636
- From the right-click or context menu in the code editor, choose **Snippet** > **Insert Snippet**
3737

38-
- From the keyboard, press **Ctrl**+**K**+**X**
38+
- From the keyboard, press **Ctrl**+**K**,**Ctrl**+**X**
3939

4040
## Expansion snippets and surround-with snippets
4141

@@ -98,4 +98,4 @@ If you change `newPropertyValue` to `m_property`, then every instance of `newPro
9898
- [C# code snippets](../ide/visual-csharp-code-snippets.md)
9999
- [Visual C++ code snippets](../ide/visual-cpp-code-snippets.md)
100100
- [Code snippets schema reference](../ide/code-snippets-schema-reference.md)
101-
- [Code snippets (Visual Studio for Mac)](/visualstudio/mac/snippets)
101+
- [Code snippets (Visual Studio for Mac)](/visualstudio/mac/snippets)

docs/ide/default-keyboard-shortcuts-in-visual-studio.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,13 @@ These keyboard shortcuts are *global*, which means that you can use them when an
335335
|--------------| - |
336336
|TestExplorer.DebugAllTests|**Ctrl+R, Ctrl+A**|
337337
|TestExplorer.DebugAllTestsInContext|**Ctrl+R, Ctrl+T**|
338+
|TestExplorer.DebugLastRun|**Ctrl+R, D**|
338339
|TestExplorer.RepeatLastRun|**Ctrl+R, L**|
339340
|TestExplorer.RunAllTests|**Ctrl+R, A**|
340341
|TestExplorer.RunAllTestsInContext|**Ctrl+R, T**|
342+
|TestExplorer.ShowTestExplorer|**Ctrl+E, T**|
343+
|LiveUnitTesting.OpenTab|**Ctrl+E, L**|
344+
|Test.CodeCoverageResults|**Ctrl+E, C**|
341345

342346
### <a name="bkmk_tools"></a> Tools
343347

@@ -395,6 +399,7 @@ These keyboard shortcuts are *global*, which means that you can use them when an
395399
|View.WebBrowser|**Ctrl+Alt+R**|
396400
|View.ZoomIn|**Ctrl+Shift+.**|
397401
|View.ZoomOut|**Ctrl+Shift+,**|
402+
|TestExplorer.ShowTestExplorer|**Ctrl+E, T**|
398403

399404
### <a name="bkmk_window"></a> Window
400405

docs/ide/template-parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The following table lists the reserved template parameters that can be used by a
5555
|safeitemrootname|Same as `safeitemname`.|
5656
|safeprojectname|The name provided by the user when the project was created but with all unsafe characters and spaces removed.|
5757
|time|The current time in the format DD/MM/YYYY 00:00:00.|
58-
|SpecificSolutionName|The name of the solution. When "create solution directory" is checked, `SpecificSolutionName` has the solution name. When "create solution directory" is not checked, `SpecificSolutionName` is blank.|
58+
|specifiedSolutionName|The name of the solution. When "create solution directory" is checked, `specifiedSolutionName` has the solution name. When "create solution directory" is not checked, `specifiedSolutionName` is blank.|
5959
|userdomain|The current user domain.|
6060
|username|The current user name.|
6161
|webnamespace|The name of the current website. This parameter is used in the web form template to guarantee unique class names. If the website is at the root directory of the web server, this template parameter resolves to the root directory of the web server.|

docs/modeling/create-layer-diagrams-from-your-code.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Before you create a dependency diagram, make sure your solution has a modeling p
3535
### Add a new dependency diagram to a modeling project
3636

3737
> [!NOTE]
38-
> Dependency diagrams are not supported for .NET Core projects in Visual Studio.
38+
> Dependency diagrams for .NET Core projects are supported starting in Visual Studio 2019 version 16.2.
3939
4040
1. On the **Architecture** menu, choose **New Dependency Diagram**.
4141

docs/modeling/layer-diagrams-guidelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Describe your app's architecture at a high level by creating *dependency diagram
2020
To see which editions of Visual Studio support this feature, see [Edition support for architecture and modeling tools](../modeling/what-s-new-for-design-in-visual-studio.md#VersionSupport).
2121

2222
> [!NOTE]
23-
> Dependency diagrams are not supported for .NET Core projects in Visual Studio.
23+
> Dependency diagrams for .NET Core projects are supported starting in Visual Studio 2019 version 16.2.
2424
2525
## What is a dependency diagram?
2626

docs/modeling/layer-diagrams-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ In Visual Studio, you can use a *dependency diagram* to visualize the high-level
2828
To see which editions of Visual Studio support this feature, see [Edition support for architecture and modeling tools](../modeling/what-s-new-for-design-in-visual-studio.md#VersionSupport).
2929

3030
> [!NOTE]
31-
> Dependency diagrams are not supported for .NET Core projects in Visual Studio.
31+
> Dependency diagrams for .NET Core projects are supported starting in Visual Studio 2019 version 16.2.
3232
3333
You can specify the intended or existing dependencies between layers. These dependencies, which are represented as arrows, indicate which layers can use or currently use the functionality represented by other layers. By organizing your system into layers that describe distinct roles and functions, a dependency diagram can help make it easier for you to understand, reuse, and maintain your code.
3434

0 commit comments

Comments
 (0)