Remove devdocs from System.Runtime.InteropServices code (dotnet/corefx#36669)
authorHugh Bellamy <hughbellars@gmail.com>
Tue, 16 Apr 2019 14:59:12 +0000 (15:59 +0100)
committerAaron Robinson <arobins@microsoft.com>
Tue, 16 Apr 2019 14:59:12 +0000 (07:59 -0700)
* Cleanup System.Runtime.InteropServices code

- Move public classes/enums to their own file
- Use summary instead of devdoc
- Misc

Commit migrated from https://github.com/dotnet/corefx/commit/8d79b6117e9d584eebb8b6933bba83dd514010ca

40 files changed:
src/libraries/System.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj
src/libraries/System.Runtime.InteropServices/src/System/Runtime/CompilerServices/IDispatchConstantAttribute.cs [moved from src/libraries/System.Runtime.InteropServices/src/System/Runtime/CompilerServices/Attributes.cs with 54% similarity]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/CompilerServices/IUnknownConstantAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/AssemblyRegistrationFlags.cs
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Attributes.cs [deleted file]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/AutomationProxyAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComAliasNameAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComCompatibleVersionAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComConversionLossAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComRegisterFunctionAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/ADVF.cs [moved from src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/advf.cs with 64% similarity]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/DATADIR.cs [moved from src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/datadir.cs with 100% similarity]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/DVASPECT.cs [moved from src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/dvaspect.cs with 100% similarity]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/FORMATETC.cs [moved from src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/formatetc.cs with 100% similarity]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IAdviseSink.cs
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IDataObject.cs
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IEnumFormatETC.cs
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/IEnumSTATDATA.cs
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/STATDATA.cs [moved from src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/statdata.cs with 100% similarity]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/STGMEDIUM.cs [moved from src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/stgmedium.cs with 100% similarity]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/TYMED.cs [moved from src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComTypes/tymed.cs with 100% similarity]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComUnregisterFunctionAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/HandleCollector.cs
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/IDispatchImplAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/IDispatchImplType.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/IMarshal.cs
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ImportedFromTypeLibAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ManagedToNativeComInteropStubAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/PrimaryInteropAssemblyAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/SetWin32ContextInIDispatchAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/StandardOleMarshalObject.cs
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibFuncAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibFuncFlags.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibImportClassAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibTypeAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibTypeFlags.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibVarAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibVarFlags.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibVersionAttribute.cs [new file with mode: 0644]
src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/HandleCollectorTests.cs

index 3e001db..1c3011b 100644 (file)
     <Compile Include="$(CommonPath)\Interop\Windows\Ole32\Interop.CoGetStandardMarshal.cs">
       <Link>Common\Interop\Windows\Ole32\Interop.CoGetStandardMarshal.cs</Link>
     </Compile>
-    <Compile Include="System\Runtime\CompilerServices\Attributes.cs" />
-    <Compile Include="System\Runtime\InteropServices\Attributes.cs" />
-    <Compile Include="System\Runtime\InteropServices\ComAwareEventInfo.cs" />
-    <Compile Include="System\Runtime\InteropServices\HandleCollector.cs" Condition="'$(TargetsAOT)' != 'true'" />
-    <Compile Include="System\Runtime\InteropServices\IMarshal.cs" />
-    <Compile Include="System\Runtime\InteropServices\RuntimeEnvironment.cs" />
-    <Compile Include="System\Runtime\InteropServices\ComTypes\advf.cs" Condition="'$(TargetsAOT)' != 'true'" />
-    <Compile Include="System\Runtime\InteropServices\ComTypes\datadir.cs" Condition="'$(TargetsAOT)' != 'true'" />
-    <Compile Include="System\Runtime\InteropServices\ComTypes\dvaspect.cs" Condition="'$(TargetsAOT)' != 'true'" />
-    <Compile Include="System\Runtime\InteropServices\ComTypes\formatetc.cs" Condition="'$(TargetsAOT)' != 'true'" />
+    <Compile Include="System\Runtime\CompilerServices\IDispatchConstantAttribute.cs" />
+    <Compile Include="System\Runtime\CompilerServices\IUnknownConstantAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\ComTypes\ADVF.cs" Condition="'$(TargetsAOT)' != 'true'" />
+    <Compile Include="System\Runtime\InteropServices\ComTypes\DATADIR.cs" Condition="'$(TargetsAOT)' != 'true'" />
+    <Compile Include="System\Runtime\InteropServices\ComTypes\DVASPECT.cs" Condition="'$(TargetsAOT)' != 'true'" />
+    <Compile Include="System\Runtime\InteropServices\ComTypes\FORMATETC.cs" Condition="'$(TargetsAOT)' != 'true'" />
     <Compile Include="System\Runtime\InteropServices\ComTypes\IAdviseSink.cs" Condition="'$(TargetsAOT)' != 'true'" />
     <Compile Include="System\Runtime\InteropServices\ComTypes\IDataObject.cs" />
     <Compile Include="System\Runtime\InteropServices\ComTypes\IEnumFormatETC.cs" Condition="'$(TargetsAOT)' != 'true'" />
     <Compile Include="System\Runtime\InteropServices\ComTypes\IEnumSTATDATA.cs" />
-    <Compile Include="System\Runtime\InteropServices\ComTypes\statdata.cs" Condition="'$(TargetsAOT)' != 'true'" />
-    <Compile Include="System\Runtime\InteropServices\ComTypes\stgmedium.cs" Condition="'$(TargetsAOT)' != 'true'" />
-    <Compile Include="System\Runtime\InteropServices\ComTypes\tymed.cs" Condition="'$(TargetsAOT)' != 'true'" />
+    <Compile Include="System\Runtime\InteropServices\ComTypes\STATDATA.cs" Condition="'$(TargetsAOT)' != 'true'" />
+    <Compile Include="System\Runtime\InteropServices\ComTypes\STGMEDIUM.cs" Condition="'$(TargetsAOT)' != 'true'" />
+    <Compile Include="System\Runtime\InteropServices\ComTypes\TYMED.cs" Condition="'$(TargetsAOT)' != 'true'" />
     <Compile Include="System\Runtime\InteropServices\AssemblyRegistrationFlags.cs" />
+    <Compile Include="System\Runtime\InteropServices\AutomationProxyAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\ComAliasNameAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\ComAwareEventInfo.cs" />
+    <Compile Include="System\Runtime\InteropServices\ComCompatibleVersionAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\ComConversionLossAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\ComRegisterFunctionAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\ComUnregisterFunctionAttribute.cs" />
     <Compile Include="System\Runtime\InteropServices\ExporterEventKind.cs" />
+    <Compile Include="System\Runtime\InteropServices\HandleCollector.cs" Condition="'$(TargetsAOT)' != 'true'" />
+    <Compile Include="System\Runtime\InteropServices\IDispatchImplAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\IDispatchImplType.cs" />
+    <Compile Include="System\Runtime\InteropServices\IMarshal.cs" />
+    <Compile Include="System\Runtime\InteropServices\ImportedFromTypeLibAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\ManagedToNativeComInteropStubAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\PrimaryInteropAssemblyAttribute.cs" />
     <Compile Include="System\Runtime\InteropServices\RegistrationClassContext.cs" />
     <Compile Include="System\Runtime\InteropServices\RegistrationConnectionType.cs" />
+    <Compile Include="System\Runtime\InteropServices\RuntimeEnvironment.cs" />
     <Compile Include="System\Runtime\InteropServices\StandardOleMarshalObject.cs" />
+    <Compile Include="System\Runtime\InteropServices\SetWin32ContextInIDispatchAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\TypeLibFuncAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\TypeLibFuncFlags.cs" />
+    <Compile Include="System\Runtime\InteropServices\TypeLibImportClassAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\TypeLibTypeAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\TypeLibTypeFlags.cs" />
+    <Compile Include="System\Runtime\InteropServices\TypeLibVarAttribute.cs" />
+    <Compile Include="System\Runtime\InteropServices\TypeLibVarFlags.cs" />
+    <Compile Include="System\Runtime\InteropServices\TypeLibVersionAttribute.cs" />
     <Compile Include="System\Security\SecureStringMarshal.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -6,15 +6,7 @@ using System.Runtime.InteropServices;
 
 namespace System.Runtime.CompilerServices
 {
-    [System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
-    public sealed partial class IUnknownConstantAttribute : CustomConstantAttribute
-    {
-        public IUnknownConstantAttribute() { }
-
-        public override object Value => new UnknownWrapper(null);
-    }
-
-    [System.AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
+    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
     public sealed partial class IDispatchConstantAttribute : CustomConstantAttribute
     {
         public IDispatchConstantAttribute() { }
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/CompilerServices/IUnknownConstantAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/CompilerServices/IUnknownConstantAttribute.cs
new file mode 100644 (file)
index 0000000..7b0f4b4
--- /dev/null
@@ -0,0 +1,16 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+
+namespace System.Runtime.CompilerServices
+{
+    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
+    public sealed partial class IUnknownConstantAttribute : CustomConstantAttribute
+    {
+        public IUnknownConstantAttribute() { }
+
+        public override object Value => new UnknownWrapper(null);
+    }
+}
index 015f1f4..d2b9b45 100644 (file)
@@ -2,8 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using System;
-
 namespace System.Runtime.InteropServices
 {
     [Flags]
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Attributes.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Attributes.cs
deleted file mode 100644 (file)
index f58992a..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Runtime.InteropServices
-{
-    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
-    public sealed class AutomationProxyAttribute : Attribute
-    {
-        public AutomationProxyAttribute(bool val) => Value = val;
-
-        public bool Value { get; }
-    }
-
-    [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
-    public sealed class ComAliasNameAttribute : Attribute
-    {
-        public ComAliasNameAttribute(string alias) => Value = alias;
-
-        public string Value { get; }
-    }
-
-    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
-    public sealed class ComCompatibleVersionAttribute : Attribute
-    {
-        public ComCompatibleVersionAttribute(int major, int minor, int build, int revision)
-        {
-            MajorVersion = major;
-            MinorVersion = minor;
-            BuildNumber = build;
-            RevisionNumber = revision;
-        }
-
-        public int MajorVersion { get; }
-        public int MinorVersion { get; }
-        public int BuildNumber { get; }
-        public int RevisionNumber { get; }
-    }
-
-    [AttributeUsage(AttributeTargets.All, Inherited = false)]
-    public sealed class ComConversionLossAttribute : Attribute
-    {
-    }
-
-    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
-    public sealed class ComRegisterFunctionAttribute : Attribute
-    {
-    }
-
-    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
-    public sealed class ComUnregisterFunctionAttribute : Attribute
-    {
-    }
-
-    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, Inherited = false)]
-    [Obsolete("This attribute is deprecated and will be removed in a future version.", error: false)]
-    public sealed class IDispatchImplAttribute : Attribute
-    {
-        public IDispatchImplAttribute(short implType) : this((IDispatchImplType)implType)
-        {
-        }
-
-        public IDispatchImplAttribute(IDispatchImplType implType) => Value = implType;
-
-        public IDispatchImplType Value { get; }
-    }
-
-    [Obsolete("The IDispatchImplAttribute is deprecated.", error: false)]
-    public enum IDispatchImplType
-    {
-        CompatibleImpl = 2,
-        InternalImpl = 1,
-        SystemDefinedImpl = 0,
-    }
-
-    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
-    public sealed class ImportedFromTypeLibAttribute : Attribute
-    {
-        public ImportedFromTypeLibAttribute(string tlbFile) => Value = tlbFile;
-
-        public string Value { get; }
-    }
-
-    [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
-    public sealed class ManagedToNativeComInteropStubAttribute : Attribute
-    {
-        public ManagedToNativeComInteropStubAttribute(Type classType, string methodName)
-        {
-            ClassType = classType;
-            MethodName = methodName;
-        }
-
-        public Type ClassType { get; }
-        public string MethodName { get; }
-    }
-
-    [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)]
-    public sealed class PrimaryInteropAssemblyAttribute : Attribute
-    {
-        public PrimaryInteropAssemblyAttribute(int major, int minor)
-        {
-            MajorVersion = major;
-            MinorVersion = minor;
-        }
-
-        public int MajorVersion { get; }
-        public int MinorVersion { get; }
-    }
-
-    [Obsolete("This attribute has been deprecated.  Application Domains no longer respect Activation Context boundaries in IDispatch calls.", error: false)]
-    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
-    public sealed class SetWin32ContextInIDispatchAttribute : Attribute
-    {
-        public SetWin32ContextInIDispatchAttribute()
-        {
-        }
-    }
-
-    [AttributeUsage(AttributeTargets.Interface, Inherited = false)]
-    public sealed class TypeLibImportClassAttribute : Attribute
-    {
-        public TypeLibImportClassAttribute(Type importClass) => Value = importClass.ToString();
-
-        public string Value { get; }
-    }
-
-    [Flags]
-    public enum TypeLibTypeFlags
-    {
-        FAppObject      = 0x0001,
-        FCanCreate      = 0x0002,
-        FLicensed       = 0x0004,
-        FPreDeclId      = 0x0008,
-        FHidden         = 0x0010,
-        FControl        = 0x0020,
-        FDual           = 0x0040,
-        FNonExtensible  = 0x0080,
-        FOleAutomation  = 0x0100,
-        FRestricted     = 0x0200,
-        FAggregatable   = 0x0400,
-        FReplaceable    = 0x0800,
-        FDispatchable   = 0x1000,
-        FReverseBind    = 0x2000,
-    }
-
-    [Flags]
-    public enum TypeLibFuncFlags
-    {
-        FRestricted         = 0x0001,
-        FSource             = 0x0002,
-        FBindable           = 0x0004,
-        FRequestEdit        = 0x0008,
-        FDisplayBind        = 0x0010,
-        FDefaultBind        = 0x0020,
-        FHidden             = 0x0040,
-        FUsesGetLastError   = 0x0080,
-        FDefaultCollelem    = 0x0100,
-        FUiDefault          = 0x0200,
-        FNonBrowsable       = 0x0400,
-        FReplaceable        = 0x0800,
-        FImmediateBind      = 0x1000,
-    }
-
-    [Flags]
-    public enum TypeLibVarFlags
-    {
-        FReadOnly           = 0x0001,
-        FSource             = 0x0002,
-        FBindable           = 0x0004,
-        FRequestEdit        = 0x0008,
-        FDisplayBind        = 0x0010,
-        FDefaultBind        = 0x0020,
-        FHidden             = 0x0040,
-        FRestricted         = 0x0080,
-        FDefaultCollelem    = 0x0100,
-        FUiDefault          = 0x0200,
-        FNonBrowsable       = 0x0400,
-        FReplaceable        = 0x0800,
-        FImmediateBind      = 0x1000,
-    }
-
-    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct, Inherited = false)]
-    public sealed class TypeLibTypeAttribute : Attribute
-    {
-        public TypeLibTypeAttribute(TypeLibTypeFlags flags)
-        {
-            Value = flags;
-        }
-
-        public TypeLibTypeAttribute(short flags)
-        {
-            Value = (TypeLibTypeFlags)flags;
-        }
-
-        public TypeLibTypeFlags Value { get; }
-    }
-
-    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
-    public sealed class TypeLibFuncAttribute : Attribute
-    {
-        public TypeLibFuncAttribute(TypeLibFuncFlags flags)
-        {
-            Value = flags;
-        }
-
-        public TypeLibFuncAttribute(short flags)
-        {
-            Value = (TypeLibFuncFlags)flags;
-        }
-
-        public TypeLibFuncFlags Value { get; }
-    }
-
-    [AttributeUsage(AttributeTargets.Field, Inherited = false)]
-    public sealed class TypeLibVarAttribute : Attribute
-    {
-        public TypeLibVarAttribute(TypeLibVarFlags flags)
-        {
-            Value = flags;
-        }
-
-        public TypeLibVarAttribute(short flags)
-        {
-            Value = (TypeLibVarFlags)flags;
-        }
-
-        public TypeLibVarFlags Value { get; }
-    }
-
-    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
-    public sealed class TypeLibVersionAttribute : Attribute
-    {
-        public TypeLibVersionAttribute(int major, int minor)
-        {
-            MajorVersion = major;
-            MinorVersion = minor;
-        }
-
-        public int MajorVersion { get; }
-        public int MinorVersion { get; }
-    }
-}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/AutomationProxyAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/AutomationProxyAttribute.cs
new file mode 100644 (file)
index 0000000..c684723
--- /dev/null
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)]
+    public sealed class AutomationProxyAttribute : Attribute
+    {
+        public AutomationProxyAttribute(bool val) => Value = val;
+
+        public bool Value { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComAliasNameAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComAliasNameAttribute.cs
new file mode 100644 (file)
index 0000000..9664363
--- /dev/null
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
+    public sealed class ComAliasNameAttribute : Attribute
+    {
+        public ComAliasNameAttribute(string alias) => Value = alias;
+
+        public string Value { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComCompatibleVersionAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComCompatibleVersionAttribute.cs
new file mode 100644 (file)
index 0000000..a7e6a56
--- /dev/null
@@ -0,0 +1,23 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class ComCompatibleVersionAttribute : Attribute
+    {
+        public ComCompatibleVersionAttribute(int major, int minor, int build, int revision)
+        {
+            MajorVersion = major;
+            MinorVersion = minor;
+            BuildNumber = build;
+            RevisionNumber = revision;
+        }
+
+        public int MajorVersion { get; }
+        public int MinorVersion { get; }
+        public int BuildNumber { get; }
+        public int RevisionNumber { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComConversionLossAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComConversionLossAttribute.cs
new file mode 100644 (file)
index 0000000..def2c3c
--- /dev/null
@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.All, Inherited = false)]
+    public sealed class ComConversionLossAttribute : Attribute
+    {
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComRegisterFunctionAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComRegisterFunctionAttribute.cs
new file mode 100644 (file)
index 0000000..f481e8c
--- /dev/null
@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+    public sealed class ComRegisterFunctionAttribute : Attribute
+    {
+    }
+}
@@ -4,6 +4,11 @@
 
 namespace System.Runtime.InteropServices.ComTypes
 {
+    /// <remarks>
+    /// Note: ADVF_ONLYONCE and ADVF_PRIMEFIRST values conform with objidl.dll but are backwards from 
+    /// the Platform SDK documentation as of 07/21/2003.
+    /// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/ne-objidl-tagadvf.
+    /// </remarks>
     [Flags]
     public enum ADVF
     {
@@ -15,7 +20,4 @@ namespace System.Runtime.InteropServices.ComTypes
         ADVFCACHE_FORCEBUILTIN = 16,
         ADVFCACHE_ONSAVE = 32
     }
-    // Note: ADVF_ONLYONCE and ADVF_PRIMEFIRST values conform with objidl.dll but are backwards from 
-    // the Platform SDK documentation as of 07/21/2003.
-    // https://docs.microsoft.com/en-us/windows/desktop/api/objidl/ne-objidl-tagadvf.
 }
index 77617f4..4c485d6 100644 (file)
@@ -4,51 +4,51 @@
 
 namespace System.Runtime.InteropServices.ComTypes
 {
-    /// <devdoc>
-    ///     The IAdviseSink interface enables containers and other objects to 
-    ///     receive notifications of data changes, view changes, and compound-document 
-    ///     changes occurring in objects of interest. Container applications, for 
-    ///     example, require such notifications to keep cached presentations of their 
-    ///     linked and embedded objects up-to-date. Calls to IAdviseSink methods are 
-    ///     asynchronous, so the call is sent and then the next instruction is executed 
-    ///     without waiting for the call's return.
-    /// </devdoc>
+    /// <summary>
+    /// The IAdviseSink interface enables containers and other objects to 
+    /// receive notifications of data changes, view changes, and compound-document 
+    /// changes occurring in objects of interest. Container applications, for 
+    /// example, require such notifications to keep cached presentations of their 
+    /// linked and embedded objects up-to-date. Calls to IAdviseSink methods are 
+    /// asynchronous, so the call is sent and then the next instruction is executed 
+    /// without waiting for the call's return.
+    /// </summary>
     [ComImport]
     [Guid("0000010F-0000-0000-C000-000000000046")]
     [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
     public interface IAdviseSink
     {
-        /// <devdoc>
-        ///     Called by the server to notify a data object's currently registered 
-        ///     advise sinks that data in the object has changed.
-        /// </devdoc>
+        /// <summary>
+        /// Called by the server to notify a data object's currently registered 
+        /// advise sinks that data in the object has changed.
+        /// </summary>
         [PreserveSig]
         void OnDataChange([In] ref FORMATETC format, [In] ref STGMEDIUM stgmedium);
 
-        /// <devdoc>
-        ///     Notifies an object's registered advise sinks that its view has changed.
-        /// </devdoc>
+        /// <summary>
+        /// Notifies an object's registered advise sinks that its view has changed.
+        /// </summary>
         [PreserveSig]
         void OnViewChange(int aspect, int index);
 
-        /// <devdoc>
-        ///     Called by the server to notify all registered advisory sinks that 
-        ///     the object has been renamed.
-        /// </devdoc>
+        /// <summary>
+        /// Called by the server to notify all registered advisory sinks that 
+        /// the object has been renamed.
+        /// </summary>
         [PreserveSig]
         void OnRename(IMoniker moniker);
 
-        /// <devdoc>
-        ///     Called by the server to notify all registered advisory sinks that 
-        ///     the object has been saved.
-        /// </devdoc>
+        /// <summary>
+        /// Called by the server to notify all registered advisory sinks that 
+        /// the object has been saved.
+        /// </summary>
         [PreserveSig]
         void OnSave();
 
-        /// <devdoc>
-        ///     Called by the server to notify all registered advisory sinks that the 
-        ///     object has changed from the running to the loaded state.
-        /// </devdoc>
+        /// <summary>
+        /// Called by the server to notify all registered advisory sinks that the 
+        /// object has changed from the running to the loaded state.
+        /// </summary>
         [PreserveSig]
         void OnClose();
     }
index c41c048..57c8bc9 100644 (file)
@@ -4,7 +4,7 @@
 
 namespace System.Runtime.InteropServices.ComTypes
 {
-    /// <devdoc>
+    /// <summary>
     ///     The IDataObject interface specifies methods that enable data transfer
     ///     and notification of changes in data. Data transfer methods specify
     ///     the format of the transferred data along with the medium through
@@ -13,75 +13,75 @@ namespace System.Runtime.InteropServices.ComTypes
     ///     retrieving and storing data, the IDataObject interface specifies
     ///     methods for enumerating available formats and managing connections
     ///     to advisory sinks for handling change notifications.
-    /// </devdoc>
+    /// </summary>
     [CLSCompliant(false)]
     [ComImport()]
     [Guid("0000010E-0000-0000-C000-000000000046")]
     [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
     public interface IDataObject {
 
-        /// <devdoc>
+        /// <summary>
         ///     Called by a data consumer to obtain data from a source data object.
         ///     The GetData method renders the data described in the specified FORMATETC
         ///     structure and transfers it through the specified STGMEDIUM structure.
         ///     The caller then assumes responsibility for releasing the STGMEDIUM structure.
-        /// </devdoc>
+        /// </summary>
         void GetData([In] ref FORMATETC format, out STGMEDIUM medium);
 
-        /// <devdoc>
+        /// <summary>
         ///     Called by a data consumer to obtain data from a source data object.
         ///     This method differs from the GetData method in that the caller must
         ///     allocate and free the specified storage medium.
-        /// </devdoc>
+        /// </summary>
         void GetDataHere([In] ref FORMATETC format, ref STGMEDIUM medium);
 
-        /// <devdoc>
+        /// <summary>
         ///     Determines whether the data object is capable of rendering the data
         ///     described in the FORMATETC structure. Objects attempting a paste or
         ///     drop operation can call this method before calling IDataObject::GetData
         ///     to get an indication of whether the operation may be successful.
-        /// </devdoc>
+        /// </summary>
         [PreserveSig]
         int QueryGetData([In] ref FORMATETC format);
 
-        /// <devdoc>
+        /// <summary>
         ///     Provides a standard FORMATETC structure that is logically equivalent to one that is more
         ///     complex. You use this method to determine whether two different
         ///     FORMATETC structures would return the same data, removing the need
         ///     for duplicate rendering.
-        /// </devdoc>
+        /// </summary>
         [PreserveSig]
         int GetCanonicalFormatEtc([In] ref FORMATETC formatIn, out FORMATETC formatOut);
 
-        /// <devdoc>
+        /// <summary>
         ///     Called by an object containing a data source to transfer data to
         ///     the object that implements this method.
-        /// </devdoc>
+        /// </summary>
         void SetData([In] ref FORMATETC formatIn, [In] ref STGMEDIUM medium, [MarshalAs(UnmanagedType.Bool)] bool release);
 
-        /// <devdoc>
+        /// <summary>
         ///     Creates an object for enumerating the FORMATETC structures for a
         ///     data object. These structures are used in calls to IDataObject::GetData
         ///     or IDataObject::SetData.
-        /// </devdoc>
+        /// </summary>
         IEnumFORMATETC EnumFormatEtc(DATADIR direction);
 
-        /// <devdoc>
+        /// <summary>
         ///     Called by an object supporting an advise sink to create a connection between
         ///     a data object and the advise sink. This enables the advise sink to be
         ///     notified of changes in the data of the object.
-        /// </devdoc>
+        /// </summary>
         [PreserveSig]
         int DAdvise([In] ref FORMATETC pFormatetc, ADVF advf, IAdviseSink adviseSink, out int connection);
 
-        /// <devdoc>
+        /// <summary>
         ///     Destroys a notification connection that had been previously set up.
-        /// </devdoc>
+        /// </summary>
         void DUnadvise(int connection);
 
-        /// <devdoc>
+        /// <summary>
         ///     Creates an object that can be used to enumerate the current advisory connections.
-        /// </devdoc>
+        /// </summary>
         [PreserveSig]
         int EnumDAdvise(out IEnumSTATDATA enumAdvise);
     }
index 3b88b9b..8b07131 100644 (file)
@@ -4,44 +4,44 @@
 
 namespace System.Runtime.InteropServices.ComTypes
 {
-    /// <devdoc>
+    /// <summary>
     ///     The IEnumFORMATETC interface is used to enumerate an array of FORMATETC 
     ///     structures. IEnumFORMATETC has the same methods as all enumerator interfaces: 
     ///     Next, Skip, Reset, and Clone.
-    /// </devdoc>
+    /// </summary>
     [ComImport()]
     [Guid("00000103-0000-0000-C000-000000000046")]
     [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
     public interface IEnumFORMATETC
     {
-        /// <devdoc>
+        /// <summary>
         ///     Retrieves the next celt items in the enumeration sequence. If there are 
         ///     fewer than the requested number of elements left in the sequence, it 
         ///     retrieves the remaining elements. The number of elements actually 
         ///     retrieved is returned through pceltFetched (unless the caller passed 
         ///     in NULL for that parameter).
-        /// </devdoc>
+        /// </summary>
         [PreserveSig]
         int Next(int celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] FORMATETC[] rgelt, [Out, MarshalAs(UnmanagedType.LPArray)] int[] pceltFetched);
 
-        /// <devdoc>
+        /// <summary>
         ///     Skips over the next specified number of elements in the enumeration sequence.
-        /// </devdoc>
+        /// </summary>
         [PreserveSig]
         int Skip(int celt);
 
-        /// <devdoc>
+        /// <summary>
         ///     Resets the enumeration sequence to the beginning.
-        /// </devdoc>
+        /// </summary>
         [PreserveSig]
         int Reset();
 
-        /// <devdoc>
+        /// <summary>
         ///     Creates another enumerator that contains the same enumeration state as 
         ///     the current one. Using this function, a client can record a particular 
         ///     point in the enumeration sequence and then return to that point at a 
         ///     later time. The new enumerator supports the same interface as the original one.
-        /// </devdoc>
+        /// </summary>
         void Clone(out IEnumFORMATETC newEnum);
     }
 }
index 1c05186..50af03a 100644 (file)
@@ -4,46 +4,46 @@
 
 namespace System.Runtime.InteropServices.ComTypes
 {
-    /// <devdoc>
-    ///     The IEnumSTATDATA interface is used to enumerate through an array of
-    ///     STATDATA structures, which contain advisory connection information for
-    ///     a data object. IEnumSTATDATA has the same methods as all enumerator
-    ///     interfaces: Next, Skip, Reset, and Clone.
-    /// </devdoc>
+    /// <summary>
+    /// The IEnumSTATDATA interface is used to enumerate through an array of
+    /// STATDATA structures, which contain advisory connection information for
+    /// a data object. IEnumSTATDATA has the same methods as all enumerator
+    /// interfaces: Next, Skip, Reset, and Clone.
+    /// </summary>
     [ComImport()]
     [Guid("00000103-0000-0000-C000-000000000046")]
     [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
     public interface IEnumSTATDATA
     {
 
-        /// <devdoc>
-        ///     Retrieves the next celt items in the enumeration sequence. If there are
-        ///     fewer than the requested number of elements left in the sequence, it
-        ///     retrieves the remaining elements. The number of elements actually
-        ///     retrieved is returned through pceltFetched (unless the caller passed
-        ///     in NULL for that parameter).
-        /// </devdoc>
+        /// <summary>
+        /// Retrieves the next celt items in the enumeration sequence. If there are
+        /// fewer than the requested number of elements left in the sequence, it
+        /// retrieves the remaining elements. The number of elements actually
+        /// retrieved is returned through pceltFetched (unless the caller passed
+        /// in NULL for that parameter).
+        /// </summary>
         [PreserveSig]
         int Next(int celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] STATDATA[] rgelt, [Out, MarshalAs(UnmanagedType.LPArray, SizeConst=1)] int[] pceltFetched);
 
-        /// <devdoc>
-        ///     Skips over the next specified number of elements in the enumeration sequence.
-        /// </devdoc>
+        /// <summary>
+        /// Skips over the next specified number of elements in the enumeration sequence.
+        /// </summary>
         [PreserveSig]
         int Skip(int celt);
 
-        /// <devdoc>
-        ///     Resets the enumeration sequence to the beginning.
-        /// </devdoc>
+        /// <summary>
+        /// Resets the enumeration sequence to the beginning.
+        /// </summary>
         [PreserveSig]
         int Reset();
 
-        /// <devdoc>
-        ///     Creates another enumerator that contains the same enumeration state as
-        ///     the current one. Using this function, a client can record a particular
-        ///     point in the enumeration sequence and then return to that point at a
-        ///     later time. The new enumerator supports the same interface as the original one.
-        /// </devdoc>
+        /// <summary>
+        /// Creates another enumerator that contains the same enumeration state as
+        /// the current one. Using this function, a client can record a particular
+        /// point in the enumeration sequence and then return to that point at a
+        /// later time. The new enumerator supports the same interface as the original one.
+        /// </summary>
         void Clone(out IEnumSTATDATA newEnum);
     }
 }
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComUnregisterFunctionAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ComUnregisterFunctionAttribute.cs
new file mode 100644 (file)
index 0000000..079d1e3
--- /dev/null
@@ -0,0 +1,11 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+    public sealed class ComUnregisterFunctionAttribute : Attribute
+    {
+    }
+}
index 4830c37..879843c 100644 (file)
@@ -8,13 +8,13 @@ namespace System.Runtime.InteropServices
 {
     public sealed class HandleCollector
     {
-        private const int DeltaPercent = 10; // this is used for increasing the threshold. 
-        private int _initialThreshold;
+        // Used for increasing the threshold. 
+        private const int DeltaPercent = 10;
         private int _threshold;
         private int _handleCount;
 
-        private int[] _gc_counts = new int[3];
-        private int _gc_gen = 0;
+        private int[] _gcCounts = new int[3];
+        private int _gcGeneration = 0;
 
         public HandleCollector(string name, int initialThreshold) :
             this(name, initialThreshold, int.MaxValue)
@@ -25,21 +25,19 @@ namespace System.Runtime.InteropServices
         {
             if (initialThreshold < 0)
             {
-                throw new ArgumentOutOfRangeException(nameof(initialThreshold), SR.Arg_NeedNonNegNumRequired);
+                throw new ArgumentOutOfRangeException(nameof(initialThreshold), initialThreshold, SR.Arg_NeedNonNegNumRequired);
             }
-
             if (maximumThreshold < 0)
             {
-                throw new ArgumentOutOfRangeException(nameof(maximumThreshold), SR.Arg_NeedNonNegNumRequired);
+                throw new ArgumentOutOfRangeException(nameof(maximumThreshold), maximumThreshold, SR.Arg_NeedNonNegNumRequired);
             }
-
             if (initialThreshold > maximumThreshold)
             {
-                throw new ArgumentException(SR.Arg_InvalidThreshold);
+                throw new ArgumentException(SR.Arg_InvalidThreshold, nameof(initialThreshold));
             }
 
             Name = name ?? string.Empty;
-            _initialThreshold = initialThreshold;
+            InitialThreshold = initialThreshold;
             MaximumThreshold = maximumThreshold;
             _threshold = initialThreshold;
             _handleCount = 0;
@@ -47,7 +45,7 @@ namespace System.Runtime.InteropServices
 
         public int Count => _handleCount;
 
-        public int InitialThreshold => _initialThreshold;
+        public int InitialThreshold { get; }
 
         public int MaximumThreshold { get; }
 
@@ -55,7 +53,7 @@ namespace System.Runtime.InteropServices
 
         public void Add()
         {
-            int gen_collect = -1;
+            int collectionGeneration = -1;
             Interlocked.Increment(ref _handleCount);
             if (_handleCount < 0)
             {
@@ -67,26 +65,26 @@ namespace System.Runtime.InteropServices
                 lock (this)
                 {
                     _threshold = _handleCount + (_handleCount / DeltaPercent);
-                    gen_collect = _gc_gen;
-                    if (_gc_gen < 2)
+                    collectionGeneration = _gcGeneration;
+                    if (_gcGeneration < 2)
                     {
-                        _gc_gen++;
+                        _gcGeneration++;
                     }
                 }
             }
 
-            if ((gen_collect >= 0) &&
-                    ((gen_collect == 0) ||
-                    (_gc_counts[gen_collect] == GC.CollectionCount(gen_collect))))
+            if ((collectionGeneration >= 0) &&
+                    ((collectionGeneration == 0) ||
+                    (_gcCounts[collectionGeneration] == GC.CollectionCount(collectionGeneration))))
             {
-                GC.Collect(gen_collect);
-                Thread.Sleep(10 * gen_collect);
+                GC.Collect(collectionGeneration);
+                Thread.Sleep(10 * collectionGeneration);
             }
 
-            //don't bother with gen0. 
+            // Don't bother with gen0. 
             for (int i = 1; i < 3; i++)
             {
-                _gc_counts[i] = GC.CollectionCount(i);
+                _gcCounts[i] = GC.CollectionCount(i);
             }
         }
 
@@ -103,21 +101,21 @@ namespace System.Runtime.InteropServices
             {
                 lock (this)
                 {
-                    if (newThreshold > _initialThreshold)
+                    if (newThreshold > InitialThreshold)
                     {
                         _threshold = newThreshold;
                     }
                     else
                     {
-                        _threshold = _initialThreshold;
+                        _threshold = InitialThreshold;
                     }
-                    _gc_gen = 0;
+                    _gcGeneration = 0;
                 }
             }
 
             for (int i = 1; i < 3; i++)
             {
-                _gc_counts[i] = GC.CollectionCount(i);
+                _gcCounts[i] = GC.CollectionCount(i);
             }
         }
     }
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/IDispatchImplAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/IDispatchImplAttribute.cs
new file mode 100644 (file)
index 0000000..1e74dc6
--- /dev/null
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, Inherited = false)]
+    [Obsolete("This attribute is deprecated and will be removed in a future version.", error: false)]
+    public sealed class IDispatchImplAttribute : Attribute
+    {
+        public IDispatchImplAttribute(short implType) : this((IDispatchImplType)implType)
+        {
+        }
+
+        public IDispatchImplAttribute(IDispatchImplType implType) => Value = implType;
+
+        public IDispatchImplType Value { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/IDispatchImplType.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/IDispatchImplType.cs
new file mode 100644 (file)
index 0000000..6444a61
--- /dev/null
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [Obsolete("The IDispatchImplAttribute is deprecated.", error: false)]
+    public enum IDispatchImplType
+    {
+        CompatibleImpl = 2,
+        InternalImpl = 1,
+        SystemDefinedImpl = 0,
+    }
+}
index 5e26113..cd5ea78 100644 (file)
@@ -4,8 +4,9 @@
 
 namespace System.Runtime.InteropServices
 {
-    [ComImport, Guid("00000003-0000-0000-C000-000000000046"),
-    InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+    [ComImport]
+    [Guid("00000003-0000-0000-C000-000000000046")]
+    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
     internal interface IMarshal
     {
         [PreserveSig]
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ImportedFromTypeLibAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ImportedFromTypeLibAttribute.cs
new file mode 100644 (file)
index 0000000..af128f0
--- /dev/null
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class ImportedFromTypeLibAttribute : Attribute
+    {
+        public ImportedFromTypeLibAttribute(string tlbFile) => Value = tlbFile;
+
+        public string Value { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ManagedToNativeComInteropStubAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/ManagedToNativeComInteropStubAttribute.cs
new file mode 100644 (file)
index 0000000..a8a4736
--- /dev/null
@@ -0,0 +1,20 @@
+
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
+    public sealed class ManagedToNativeComInteropStubAttribute : Attribute
+    {
+        public ManagedToNativeComInteropStubAttribute(Type classType, string methodName)
+        {
+            ClassType = classType;
+            MethodName = methodName;
+        }
+
+        public Type ClassType { get; }
+        public string MethodName { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/PrimaryInteropAssemblyAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/PrimaryInteropAssemblyAttribute.cs
new file mode 100644 (file)
index 0000000..835dc37
--- /dev/null
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)]
+    public sealed class PrimaryInteropAssemblyAttribute : Attribute
+    {
+        public PrimaryInteropAssemblyAttribute(int major, int minor)
+        {
+            MajorVersion = major;
+            MinorVersion = minor;
+        }
+
+        public int MajorVersion { get; }
+        public int MinorVersion { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/SetWin32ContextInIDispatchAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/SetWin32ContextInIDispatchAttribute.cs
new file mode 100644 (file)
index 0000000..609a8d1
--- /dev/null
@@ -0,0 +1,15 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [Obsolete("This attribute has been deprecated.  Application Domains no longer respect Activation Context boundaries in IDispatch calls.", error: false)]
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class SetWin32ContextInIDispatchAttribute : Attribute
+    {
+        public SetWin32ContextInIDispatchAttribute()
+        {
+        }
+    }
+}
index b659347..d7c3009 100644 (file)
@@ -11,23 +11,25 @@ namespace System.Runtime.InteropServices
         private static readonly Guid CLSID_StdMarshal = new Guid("00000017-0000-0000-c000-000000000046");
         
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
-        private delegate int GetMarshalSizeMax_Delegate(IntPtr _this, ref Guid riid, IntPtr pv, int dwDestContext, IntPtr pvDestContext, int mshlflags, out int pSize);
+        private delegate int GetMarshalSizeMaxDelegate(IntPtr _this, ref Guid riid, IntPtr pv, int dwDestContext, IntPtr pvDestContext, int mshlflags, out int pSize);
         
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
-        private delegate int MarshalInterface_Delegate(IntPtr _this, IntPtr pStm, ref Guid riid, IntPtr pv, int dwDestContext, IntPtr pvDestContext, int mshlflags);
+        private delegate int MarshalInterfaceDelegate(IntPtr _this, IntPtr pStm, ref Guid riid, IntPtr pv, int dwDestContext, IntPtr pvDestContext, int mshlflags);
 
-        protected StandardOleMarshalObject() { }
+        protected StandardOleMarshalObject()
+        {
+        }
 
         private IntPtr GetStdMarshaler(ref Guid riid, int dwDestContext, int mshlflags)
         {
-            IntPtr pStandardMarshal = IntPtr.Zero;
-
             IntPtr pUnknown = Marshal.GetIUnknownForObject(this);
             if (pUnknown != IntPtr.Zero)
             {
                 try
                 {
-                    if (HResults.S_OK == Interop.Ole32.CoGetStandardMarshal(ref riid, pUnknown, dwDestContext, IntPtr.Zero, mshlflags, out pStandardMarshal))
+                    IntPtr pStandardMarshal = IntPtr.Zero;
+                    int hr = Interop.Ole32.CoGetStandardMarshal(ref riid, pUnknown, dwDestContext, IntPtr.Zero, mshlflags, out pStandardMarshal);
+                    if (hr == HResults.S_OK)
                     {
                         Debug.Assert(pStandardMarshal != IntPtr.Zero, "Failed to get marshaler for interface '" + riid.ToString() + "', CoGetStandardMarshal returned S_OK");
                         return pStandardMarshal;
@@ -38,7 +40,8 @@ namespace System.Runtime.InteropServices
                     Marshal.Release(pUnknown);
                 }
             }
-            throw new InvalidOperationException(SR.Format(SR.StandardOleMarshalObjectGetMarshalerFailed, riid.ToString()));
+
+            throw new InvalidOperationException(SR.Format(SR.StandardOleMarshalObjectGetMarshalerFailed, riid));
         }
 
         int IMarshal.GetUnmarshalClass(ref Guid riid, IntPtr pv, int dwDestContext, IntPtr pvDestContext, int mshlflags, out Guid pCid)
@@ -53,12 +56,16 @@ namespace System.Runtime.InteropServices
 
             try
             {
-                // we must not wrap pStandardMarshal with an RCW because that would trigger QIs for random IIDs and the marshaler
-                // (aka stub manager object) does not really handle these well and we would risk triggering an AppVerifier break
+                // We must not wrap pStandardMarshal with an RCW because that
+                // would trigger QIs for random IIDs and the marshaler (aka stub
+                // manager object) does not really handle these well and we would
+                // risk triggering an AppVerifier break
                 IntPtr vtable = *(IntPtr*)pStandardMarshal.ToPointer();
-                IntPtr method = *((IntPtr*)vtable.ToPointer() + 4); // GetMarshalSizeMax is 4th slot
+                
+                // GetMarshalSizeMax is 4th slot
+                IntPtr method = *((IntPtr*)vtable.ToPointer() + 4);
 
-                GetMarshalSizeMax_Delegate del = (GetMarshalSizeMax_Delegate)Marshal.GetDelegateForFunctionPointer(method, typeof(GetMarshalSizeMax_Delegate));
+                GetMarshalSizeMaxDelegate del = (GetMarshalSizeMaxDelegate)Marshal.GetDelegateForFunctionPointer(method, typeof(GetMarshalSizeMaxDelegate));
                 return del(pStandardMarshal, ref riid, pv, dwDestContext, pvDestContext, mshlflags, out pSize);
             }
             finally
@@ -73,12 +80,14 @@ namespace System.Runtime.InteropServices
 
             try
             {
-                // we must not wrap pStandardMarshal with an RCW because that would trigger QIs for random IIDs and the marshaler
-                // (aka stub manager object) does not really handle these well and we would risk triggering an AppVerifier break
+                // We must not wrap pStandardMarshal with an RCW because that
+                // would trigger QIs for random IIDs and the marshaler (aka stub
+                // manager object) does not really handle these well and we would
+                // risk triggering an AppVerifier break
                 IntPtr vtable = *(IntPtr*)pStandardMarshal.ToPointer();
                 IntPtr method = *((IntPtr*)vtable.ToPointer() + 5); // MarshalInterface is 5th slot
 
-                MarshalInterface_Delegate del = (MarshalInterface_Delegate)Marshal.GetDelegateForFunctionPointer(method, typeof(MarshalInterface_Delegate));
+                MarshalInterfaceDelegate del = (MarshalInterfaceDelegate)Marshal.GetDelegateForFunctionPointer(method, typeof(MarshalInterfaceDelegate));
                 return del(pStandardMarshal, pStm, ref riid, pv, dwDestContext, pvDestContext, mshlflags);
             }
             finally
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibFuncAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibFuncAttribute.cs
new file mode 100644 (file)
index 0000000..aae81a4
--- /dev/null
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Method, Inherited = false)]
+    public sealed class TypeLibFuncAttribute : Attribute
+    {
+        public TypeLibFuncAttribute(TypeLibFuncFlags flags)
+        {
+            Value = flags;
+        }
+
+        public TypeLibFuncAttribute(short flags)
+        {
+            Value = (TypeLibFuncFlags)flags;
+        }
+
+        public TypeLibFuncFlags Value { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibFuncFlags.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibFuncFlags.cs
new file mode 100644 (file)
index 0000000..8a04d89
--- /dev/null
@@ -0,0 +1,24 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [Flags]
+    public enum TypeLibFuncFlags
+    {
+        FRestricted         = 0x0001,
+        FSource             = 0x0002,
+        FBindable           = 0x0004,
+        FRequestEdit        = 0x0008,
+        FDisplayBind        = 0x0010,
+        FDefaultBind        = 0x0020,
+        FHidden             = 0x0040,
+        FUsesGetLastError   = 0x0080,
+        FDefaultCollelem    = 0x0100,
+        FUiDefault          = 0x0200,
+        FNonBrowsable       = 0x0400,
+        FReplaceable        = 0x0800,
+        FImmediateBind      = 0x1000,
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibImportClassAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibImportClassAttribute.cs
new file mode 100644 (file)
index 0000000..6ff1d6e
--- /dev/null
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Interface, Inherited = false)]
+    public sealed class TypeLibImportClassAttribute : Attribute
+    {
+        public TypeLibImportClassAttribute(Type importClass) => Value = importClass.ToString();
+
+        public string Value { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibTypeAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibTypeAttribute.cs
new file mode 100644 (file)
index 0000000..90d18e7
--- /dev/null
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct, Inherited = false)]
+    public sealed class TypeLibTypeAttribute : Attribute
+    {
+        public TypeLibTypeAttribute(TypeLibTypeFlags flags)
+        {
+            Value = flags;
+        }
+
+        public TypeLibTypeAttribute(short flags)
+        {
+            Value = (TypeLibTypeFlags)flags;
+        }
+
+        public TypeLibTypeFlags Value { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibTypeFlags.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibTypeFlags.cs
new file mode 100644 (file)
index 0000000..d5d7195
--- /dev/null
@@ -0,0 +1,25 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [Flags]
+    public enum TypeLibTypeFlags
+    {
+        FAppObject      = 0x0001,
+        FCanCreate      = 0x0002,
+        FLicensed       = 0x0004,
+        FPreDeclId      = 0x0008,
+        FHidden         = 0x0010,
+        FControl        = 0x0020,
+        FDual           = 0x0040,
+        FNonExtensible  = 0x0080,
+        FOleAutomation  = 0x0100,
+        FRestricted     = 0x0200,
+        FAggregatable   = 0x0400,
+        FReplaceable    = 0x0800,
+        FDispatchable   = 0x1000,
+        FReverseBind    = 0x2000,
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibVarAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibVarAttribute.cs
new file mode 100644 (file)
index 0000000..5961b12
--- /dev/null
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Field, Inherited = false)]
+    public sealed class TypeLibVarAttribute : Attribute
+    {
+        public TypeLibVarAttribute(TypeLibVarFlags flags)
+        {
+            Value = flags;
+        }
+
+        public TypeLibVarAttribute(short flags)
+        {
+            Value = (TypeLibVarFlags)flags;
+        }
+
+        public TypeLibVarFlags Value { get; }
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibVarFlags.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibVarFlags.cs
new file mode 100644 (file)
index 0000000..b3b3772
--- /dev/null
@@ -0,0 +1,25 @@
+
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [Flags]
+    public enum TypeLibVarFlags
+    {
+        FReadOnly           = 0x0001,
+        FSource             = 0x0002,
+        FBindable           = 0x0004,
+        FRequestEdit        = 0x0008,
+        FDisplayBind        = 0x0010,
+        FDefaultBind        = 0x0020,
+        FHidden             = 0x0040,
+        FRestricted         = 0x0080,
+        FDefaultCollelem    = 0x0100,
+        FUiDefault          = 0x0200,
+        FNonBrowsable       = 0x0400,
+        FReplaceable        = 0x0800,
+        FImmediateBind      = 0x1000,
+    }
+}
diff --git a/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibVersionAttribute.cs b/src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/TypeLibVersionAttribute.cs
new file mode 100644 (file)
index 0000000..73ad3c6
--- /dev/null
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+    [AttributeUsage(AttributeTargets.Assembly, Inherited = false)]
+    public sealed class TypeLibVersionAttribute : Attribute
+    {
+        public TypeLibVersionAttribute(int major, int minor)
+        {
+            MajorVersion = major;
+            MinorVersion = minor;
+        }
+
+        public int MajorVersion { get; }
+        public int MinorVersion { get; }
+    }
+}
index d670055..8ff50cc 100644 (file)
@@ -54,7 +54,7 @@ namespace System.Runtime.InteropServices
         [Fact]
         public static void Ctor_InitialThresholdGreaterThanMaximumThreshold_ThrowsArgumentException()
         {
-            AssertExtensions.Throws<ArgumentException>(null, () => new HandleCollector("InitialGreaterThanMax", 100, 1));
+            AssertExtensions.Throws<ArgumentException>("initialThreshold", null, () => new HandleCollector("InitialGreaterThanMax", 100, 1));
         }
 
         [Fact]