1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
9 namespace System.Runtime.InteropServices.WindowsRuntime
11 // DefaultInterfaceAttribute marks a WinRT class (or interface group) that has its default interface specified.
12 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)]
13 public sealed class DefaultInterfaceAttribute : Attribute
15 private Type m_defaultInterface;
17 public DefaultInterfaceAttribute(Type defaultInterface)
19 m_defaultInterface = defaultInterface;
22 public Type DefaultInterface
24 get { return m_defaultInterface; }
28 // WindowsRuntimeImport is a pseudo custom attribute which causes us to emit the tdWindowsRuntime bit
29 // onto types which are decorated with the attribute. This is needed to mark Windows Runtime types
30 // which are redefined in mscorlib.dll and System.Runtime.WindowsRuntime.dll, as the C# compiler does
31 // not have a built in syntax to mark tdWindowsRuntime. These two assemblies are special as they
32 // implement the CLR's support for WinRT, so this type is internal as marking tdWindowsRuntime should
33 // generally be done via winmdexp for user code.
34 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, Inherited = false)]
35 // [System.Runtime.CompilerServices.FriendAccessAllowed]
36 internal sealed class WindowsRuntimeImportAttribute : Attribute
38 internal WindowsRuntimeImportAttribute()
42 // This attribute is applied to class interfaces in a generated projection assembly. It is used by Visual Studio
43 // and other tools to find out what version of a component (eg. Windows) a WinRT class began to implement
44 // a particular interfaces.
45 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = true)]
46 public sealed class InterfaceImplementedInVersionAttribute : Attribute
48 public InterfaceImplementedInVersionAttribute(Type interfaceType, byte majorVersion, byte minorVersion, byte buildVersion, byte revisionVersion)
50 m_interfaceType = interfaceType;
51 m_majorVersion = majorVersion;
52 m_minorVersion = minorVersion;
53 m_buildVersion = buildVersion;
54 m_revisionVersion = revisionVersion;
57 public Type InterfaceType
59 get { return m_interfaceType; }
62 public byte MajorVersion
64 get { return m_majorVersion; }
67 public byte MinorVersion
69 get { return m_minorVersion; }
72 public byte BuildVersion
74 get { return m_buildVersion; }
77 public byte RevisionVersion
79 get { return m_revisionVersion; }
82 private Type m_interfaceType;
83 private byte m_majorVersion;
84 private byte m_minorVersion;
85 private byte m_buildVersion;
86 private byte m_revisionVersion;
89 // Applies to read-only array parameters
90 [AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
91 public sealed class ReadOnlyArrayAttribute : Attribute
93 public ReadOnlyArrayAttribute() { }
96 // Applies to write-only array parameters
97 [AttributeUsage(AttributeTargets.Parameter, Inherited = false, AllowMultiple = false)]
98 public sealed class WriteOnlyArrayAttribute : Attribute
100 public WriteOnlyArrayAttribute() { }
105 // This attribute is applied on the return value to specify the name of the return value.
106 // In WindowsRuntime all parameters including return value need to have unique names.
107 // 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.
108 [AttributeUsage(AttributeTargets.ReturnValue | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
109 public sealed class ReturnValueNameAttribute : Attribute
111 private string m_Name;
112 public ReturnValueNameAttribute(string name)
119 get { return m_Name; }