-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OverloadResolutionPriority conceptual documentation. (#42394)
* Publish feature speclet Publish the C# 13 speclet for overload priority attribute. * Update attributes language reference * Final conceptual updates * Warnings and wording. * fix build warnings in our repo * Add quick note on the priority values.
- Loading branch information
1 parent
7da7b4f
commit f8c356e
Showing
7 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
docs/csharp/language-reference/attributes/snippets/OrpaSnippets.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace attributes; | ||
public class OverloadExample | ||
{ | ||
|
||
public static void OrpaExample() | ||
{ | ||
// <SnippetOrpaExample> | ||
var d = new OverloadExample(); | ||
int[] arr = [1, 2, 3]; | ||
d.M(1, 2, 3, 4); // Prints "Span" | ||
d.M(arr); // Prints "Span" when PriorityAttribute is applied | ||
d.M([1, 2, 3, 4]); // Prints "Span" | ||
d.M(1, 2, 3, 4); // Prints "Span" | ||
// </SnippetOrpaExample> | ||
} | ||
|
||
// <SnippetOverloadExample> | ||
[OverloadResolutionPriority(1)] | ||
public void M(params ReadOnlySpan<int> s) => Console.WriteLine("Span"); | ||
// Default overload resolution priority of 0 | ||
public void M(params int[] a) => Console.WriteLine("Array"); | ||
// </SnippetOverloadExample> | ||
} |
3 changes: 3 additions & 0 deletions
3
docs/csharp/language-reference/attributes/snippets/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters