Skip to content

Commit 092717f

Browse files
committed
Add VB new features
- Fixes dotnet#44190: Add note that Visual Basic can consume types (defined in C#) that specify the `unmanaged` constraint. - Fixes dotnet#44174: VB Overload resolution respects the OverloadResolutionPriorityAttribute. In these changes, I made the necessary updates for accuracy with the current compiler. Then, I did an edit for style and updated per style. You may want to review the two commits separately to see the semantic changes distinct from the grammar and style changes.
1 parent a1f1c09 commit 092717f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

docs/visual-basic/programming-guide/language-features/data-types/generic-types.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Generic Types in Visual Basic (Visual Basic)"
33
title: "Generic Types"
4-
ms.date: 07/20/2015
4+
ms.date: 01/31/2025
55
helpviewer_keywords:
66
- "generic interfaces"
77
- "data type arguments [Visual Basic], defining"
@@ -36,7 +36,6 @@ helpviewer_keywords:
3636
- "data type parameters [Visual Basic], defining"
3737
- "type arguments [Visual Basic], defining"
3838
- "arguments [Visual Basic], type"
39-
ms.assetid: 89f771d9-ecbb-4737-88b8-116b63c6cf4d
4039
---
4140
# Generic Types in Visual Basic (Visual Basic)
4241

@@ -125,6 +124,8 @@ A *generic type* is a single programming element that adapts to perform the same
125124
- The type argument must expose a parameterless constructor accessible to the code that creates objects from it
126125

127126
- The type argument must be a *reference type*, or it must be a *value type*
127+
128+
- The type argument must be an [*unmanaged type*](../../../../csharp/programming-guide/generics/constraints-on-type-parameters.md#unmanaged-constraint). The Visual Basic compiler enforces this constraint on type arguments. Visual Basic can't declare this constraint on a generic type or method.
128129

129130
If you need to impose more than one requirement, you use a comma-separated *constraint list* inside braces (`{ }`). To require an accessible constructor, you include the [New Operator](../../../language-reference/operators/new-operator.md) keyword in the list. To require a reference type, you include the `Class` keyword; to require a value type, you include the `Structure` keyword.
130131

docs/visual-basic/programming-guide/language-features/procedures/overload-resolution.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Overload Resolution (Visual Basic)"
33
title: "Overload Resolution"
4-
ms.date: 07/20/2015
4+
ms.date:01/31/2025
55
helpviewer_keywords:
66
- "Visual Basic code, procedures"
77
- "overload resolution"
@@ -10,7 +10,6 @@ helpviewer_keywords:
1010
- "procedure overloading [Visual Basic], overload resolution"
1111
- "signatures [Visual Basic], procedure"
1212
- "overloads [Visual Basic], resolution"
13-
ms.assetid: 766115d1-4352-45fb-859f-6063e0de0ec0
1413
---
1514
# Overload Resolution (Visual Basic)
1615

@@ -27,8 +26,10 @@ When the Visual Basic compiler encounters a call to a procedure that is defined
2726
4. **Narrowing Conversions.** It eliminates any overload that requires a narrowing conversion from the calling argument types to the defined parameter types. This is true whether the type checking switch ([Option Strict Statement](../../../language-reference/statements/option-strict-statement.md)) is `On` or `Off`.
2827

2928
5. **Least Widening.** The compiler considers the remaining overloads in pairs. For each pair, it compares the data types of the defined parameters. If the types in one of the overloads all widen to the corresponding types in the other, the compiler eliminates the latter. That is, it retains the overload that requires the least amount of widening.
29+
30+
6. **Overload Resolution Priority.** The compiler removes any overload that has a lower <xref:System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute> than the highest value. Any overload without this attribute is assigned the default value of zero.
3031

31-
6. **Single Candidate.** It continues considering overloads in pairs until only one overload remains, and it resolves the call to that overload. If the compiler cannot reduce the overloads to a single candidate, it generates an error.
32+
7. **Single Candidate.** It continues considering overloads in pairs until only one overload remains, and it resolves the call to that overload. If the compiler cannot reduce the overloads to a single candidate, it generates an error.
3233

3334
The following illustration shows the process that determines which of a set of overloaded versions to call.
3435

0 commit comments

Comments
 (0)