Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / mscorlib / system / runtime / interopservices / windowsruntime / attributes.cs
1 // ==++==
2 // 
3 //   Copyright (c) Microsoft Corporation.  All rights reserved.
4 // 
5 // ==--==
6 //
7 // <OWNER>Microsoft</OWNER>
8 // <OWNER>Microsoft</OWNER>
9 // <OWNER>Microsoft</OWNER>
10
11 using System;
12
13 namespace System.Runtime.InteropServices.WindowsRuntime
14 {
15     // DefaultInterfaceAttribute marks a WinRT class (or interface group) that has its default interface specified.
16     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)]
17     public sealed class DefaultInterfaceAttribute : Attribute
18     {
19         private Type m_defaultInterface;
20
21         public DefaultInterfaceAttribute(Type defaultInterface)
22         {
23             m_defaultInterface = defaultInterface;
24         }
25
26         public Type DefaultInterface
27         {
28             get { return m_defaultInterface; }
29         }
30     }
31
32     // WindowsRuntimeImport is a pseudo custom attribute which causes us to emit the tdWindowsRuntime bit
33     // onto types which are decorated with the attribute.  This is needed to mark Windows Runtime types
34     // which are redefined in mscorlib.dll and System.Runtime.WindowsRuntime.dll, as the C# compiler does
35     // not have a built in syntax to mark tdWindowsRuntime.   These two assemblies are special as they
36     // implement the CLR's support for WinRT, so this type is internal as marking tdWindowsRuntime should
37     // generally be done via winmdexp for user code.
38     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, Inherited = false)]
39     [System.Runtime.CompilerServices.FriendAccessAllowed]
40     internal sealed class WindowsRuntimeImportAttribute : Attribute
41     {
42         public WindowsRuntimeImportAttribute()
43         { }
44     }
45
46     // This attribute is applied to class interfaces in a generated projection assembly.  It is used by Visual Studio
47     // and other tools to find out what version of a component (eg. Windows) a WinRT class began to implement
48     // a particular interfaces.
49     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = true)]
50     public sealed class InterfaceImplementedInVersionAttribute : Attribute
51     {
52         public InterfaceImplementedInVersionAttribute(Type interfaceType, byte majorVersion, byte minorVersion, byte buildVersion, byte revisionVersion)
53         {
54             m_interfaceType = interfaceType;
55             m_majorVersion = majorVersion;
56             m_minorVersion = minorVersion;
57             m_buildVersion = buildVersion;
58             m_revisionVersion = revisionVersion;
59         }
60
61         public Type InterfaceType
62         {
63             get { return m_interfaceType; }
64         }
65
66         public byte MajorVersion
67         {
68             get { return m_majorVersion; }
69         }
70
71         public byte MinorVersion
72         {
73             get { return m_minorVersion; }
74         }
75
76         public byte BuildVersion
77         {
78             get { return m_buildVersion; }
79         }
80
81         public byte RevisionVersion
82         {
83             get { return m_revisionVersion; }
84         }
85
86         private Type m_interfaceType;
87         private byte m_majorVersion;
88         private byte m_minorVersion;
89         private byte m_buildVersion;
90         private byte m_revisionVersion;
91     }
92
93     // Applies to read-only array parameters
94     [AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
95     public sealed class ReadOnlyArrayAttribute : Attribute
96     {
97         public ReadOnlyArrayAttribute() {}
98     }
99
100     // Applies to write-only array parameters
101     [AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
102     public sealed class WriteOnlyArrayAttribute : Attribute
103     {
104         public WriteOnlyArrayAttribute() {}
105     }
106
107
108
109     // This attribute is applied on the return value to specify the name of the return value. 
110     // In WindowsRuntime all parameters including return value need to have unique names.
111     // This is essential in JS as one of the ways to get at the results of a method in JavaScript is via a Dictionary object keyed by parameter name.
112     [AttributeUsage(AttributeTargets.ReturnValue | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
113     public sealed class ReturnValueNameAttribute : Attribute
114     {
115         private string m_Name;
116         public ReturnValueNameAttribute(string name)
117         {
118             m_Name = name;
119         }
120
121         public string Name
122         {
123             get { return m_Name; }
124         }
125     }
126
127 }