forked from IronLanguages/dlr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParamDictionaryAttribute.cs
More file actions
49 lines (46 loc) · 1.86 KB
/
ParamDictionaryAttribute.cs
File metadata and controls
49 lines (46 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
#nullable enable
using System;
namespace Microsoft.Scripting {
/// <summary>
/// This attribute is used to mark a parameter that can accept any keyword arguments that
/// are not bound to normal parameters. The extra keyword arguments will be
/// passed in a dictionary which is created for the call.
///
/// Most languages which support params dictionaries will support the following types:
/// <code>
/// IReadOnlyDictionary<string, anything><br/>
/// IReadOnlyDictionary<object, anything><br/>
/// IDictionary<string, anything><br/>
/// IDictionary<object, anything><br/>
/// Dictionary<string, anything><br/>
/// Dictionary<object, anything><br/>
/// IDictionary
/// </code>
///
/// For languages which don't have language level support the user will be required to
/// create and populate the dictionary by hand.
///
/// This attribute is the dictionary equivalent of the System.ParamArrayAttribute.
/// </summary>
/// <example>
/// public static void KeywordArgFunction([ParamDictionary]IDictionary<string, object> dict) {
/// foreach (var v in dict) {
/// Console.WriteLine("Key: {0} Value: {1}", v.Key, v.Value);
/// }
/// }
///
/// Called from Python:
///
/// KeywordArgFunction(a = 2, b = "abc")
///
/// will print:
/// Key: a Value = 2
/// Key: b Value = abc
/// </example>
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public sealed class ParamDictionaryAttribute : Attribute {
}
}