Skip to content

Commit b36b257

Browse files
Automatically port System.Runtime.InteropServices documentation (#4705)
* Automatically port System.Runtime.InteropServices documentation * Apply suggestions from code review Co-authored-by: Genevieve Warren <[email protected]> * typo Co-authored-by: carlossanlop <[email protected]> Co-authored-by: Genevieve Warren <[email protected]>
1 parent 2528cc3 commit b36b257

File tree

5 files changed

+130
-34
lines changed

5 files changed

+130
-34
lines changed

xml/System.Runtime.InteropServices/ComWrappers.xml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="ComWrappers" FullName="System.Runtime.InteropServices.ComWrappers">
1+
<Type Name="ComWrappers" FullName="System.Runtime.InteropServices.ComWrappers">
22
<TypeSignature Language="C#" Value="public abstract class ComWrappers" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract beforefieldinit ComWrappers extends System.Object" />
44
<TypeSignature Language="DocId" Value="T:System.Runtime.InteropServices.ComWrappers" />
@@ -167,7 +167,15 @@ If the object cannot be created and `null` is returned, the call to <xref:System
167167
<param name="flags">Flags used to configure the generated interface.</param>
168168
<summary>Creates a COM representation of the supplied object that can be passed to a non-managed environment.</summary>
169169
<returns>The generated COM interface that can be passed outside the .NET runtime.</returns>
170-
<remarks>To be added.</remarks>
170+
<remarks>
171+
<format type="text/markdown"><![CDATA[
172+
173+
## Remarks
174+
175+
If a COM representation was previously created for the specified `instance` using this <xref:System.Runtime.InteropServices.ComWrappers> instance, the previously created COM interface will be returned. If not, a new one will be created.
176+
177+
]]></format>
178+
</remarks>
171179
</Docs>
172180
</Member>
173181
<Member MemberName="GetOrCreateObjectForComInstance">
@@ -194,7 +202,15 @@ If the object cannot be created and `null` is returned, the call to <xref:System
194202
<param name="flags">Flags used to describe the external object.</param>
195203
<summary>Gets the currently registered managed object or creates a new managed object and registers it.</summary>
196204
<returns>A managed object associated with the supplied external COM object.</returns>
197-
<remarks>To be added.</remarks>
205+
<remarks>
206+
<format type="text/markdown"><![CDATA[
207+
208+
## Remarks
209+
210+
If a managed object was previously created for the specified `externalComObject` using this <xref:System.Runtime.InteropServices.ComWrappers> instance, the previously created object will be returned. If not, a new one will be created.
211+
212+
]]></format>
213+
</remarks>
198214
</Docs>
199215
</Member>
200216
<Member MemberName="GetOrRegisterObjectForComInstance">
@@ -246,9 +262,22 @@ If the object cannot be created and `null` is returned, the call to <xref:System
246262
<Parameter Name="instance" Type="System.Runtime.InteropServices.ComWrappers" />
247263
</Parameters>
248264
<Docs>
249-
<param name="instance">To be added.</param>
250-
<summary>To be added.</summary>
251-
<remarks>To be added.</remarks>
265+
<param name="instance">The instance to register.</param>
266+
<summary>Registers a <see cref="T:System.Runtime.InteropServices.ComWrappers" /> instance to be used as the global instance for marshalling in the runtime.</summary>
267+
<remarks>
268+
<format type="text/markdown"><![CDATA[
269+
270+
## Remarks
271+
272+
This function can only be called a single time. Subsequent calls to this function will result in a <xref:System.InvalidOperationException> being thrown.
273+
Scenarios where this global instance may be used are:
274+
* Usage of COM-related Marshal APIs
275+
* P/Invokes with COM-related types
276+
* COM activation
277+
278+
]]></format>
279+
</remarks>
280+
<exception cref="T:System.InvalidOperationException">The method was called more than once.</exception>
252281
</Docs>
253282
</Member>
254283
<Member MemberName="RegisterForTrackerSupport">
@@ -270,9 +299,20 @@ If the object cannot be created and `null` is returned, the call to <xref:System
270299
<Parameter Name="instance" Type="System.Runtime.InteropServices.ComWrappers" />
271300
</Parameters>
272301
<Docs>
273-
<param name="instance">To be added.</param>
274-
<summary>To be added.</summary>
275-
<remarks>To be added.</remarks>
302+
<param name="instance">The instance to register.</param>
303+
<summary>Registers a <see cref="T:System.Runtime.InteropServices.ComWrappers" /> instance to be used as the global instance for reference tracker support.</summary>
304+
<remarks>
305+
<format type="text/markdown"><![CDATA[
306+
307+
## Remarks
308+
309+
This function can only be called a single time. Subsequent calls to this function will result in a <xref:System.InvalidOperationException> being thrown.
310+
Scenarios where this global instance may be used are:
311+
* Object tracking via the <xref:System.Runtime.InteropServices.CreateComInterfaceFlags.TrackerSupport> and <xref:System.Runtime.InteropServices.CreateObjectFlags.TrackerObject> flags.
312+
313+
]]></format>
314+
</remarks>
315+
<exception cref="T:System.InvalidOperationException">The method was called more than once.</exception>
276316
</Docs>
277317
</Member>
278318
<Member MemberName="ReleaseObjects">

xml/System.Runtime.InteropServices/DynamicInterfaceCastableImplementationAttribute.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="DynamicInterfaceCastableImplementationAttribute" FullName="System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute">
1+
<Type Name="DynamicInterfaceCastableImplementationAttribute" FullName="System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute">
22
<TypeSignature Language="C#" Value="public sealed class DynamicInterfaceCastableImplementationAttribute : Attribute" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit DynamicInterfaceCastableImplementationAttribute extends System.Attribute" />
44
<TypeSignature Language="DocId" Value="T:System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute" />
@@ -20,8 +20,16 @@
2020
</Attribute>
2121
</Attributes>
2222
<Docs>
23-
<summary>To be added.</summary>
24-
<remarks>To be added.</remarks>
23+
<summary>Attribute required by any type that is returned by <see cref="M:System.Runtime.InteropServices.IDynamicInterfaceCastable.GetInterfaceImplementation(System.RuntimeTypeHandle)" />.</summary>
24+
<remarks>
25+
<format type="text/markdown"><![CDATA[
26+
27+
## Remarks
28+
29+
This attribute is used to enforce policy in the runtime and make <xref:System.Runtime.InteropServices.IDynamicInterfaceCastable> scenarios linker friendly.
30+
31+
]]></format>
32+
</remarks>
2533
</Docs>
2634
<Members>
2735
<Member MemberName=".ctor">

xml/System.Runtime.InteropServices/IDynamicInterfaceCastable.xml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="IDynamicInterfaceCastable" FullName="System.Runtime.InteropServices.IDynamicInterfaceCastable">
1+
<Type Name="IDynamicInterfaceCastable" FullName="System.Runtime.InteropServices.IDynamicInterfaceCastable">
22
<TypeSignature Language="C#" Value="public interface IDynamicInterfaceCastable" />
33
<TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IDynamicInterfaceCastable" />
44
<TypeSignature Language="DocId" Value="T:System.Runtime.InteropServices.IDynamicInterfaceCastable" />
@@ -11,8 +11,16 @@
1111
</AssemblyInfo>
1212
<Interfaces />
1313
<Docs>
14-
<summary>To be added.</summary>
15-
<remarks>To be added.</remarks>
14+
<summary>Interface used to participate in a type cast failure.</summary>
15+
<remarks>
16+
<format type="text/markdown"><![CDATA[
17+
18+
## Remarks
19+
20+
Implementation of this interface on a value type will be ignored. Only non-value types are allowed to participate in a type cast failure through this interface.
21+
22+
]]></format>
23+
</remarks>
1624
</Docs>
1725
<Members>
1826
<Member MemberName="GetInterfaceImplementation">
@@ -34,10 +42,20 @@
3442
<Parameter Name="interfaceType" Type="System.RuntimeTypeHandle" />
3543
</Parameters>
3644
<Docs>
37-
<param name="interfaceType">To be added.</param>
38-
<summary>To be added.</summary>
39-
<returns>To be added.</returns>
40-
<remarks>To be added.</remarks>
45+
<param name="interfaceType">The interface type.</param>
46+
<summary>Called during interface dispatch when the given interface type cannot be found in the class's metadata.</summary>
47+
<returns>The type that should be used to dispatch for <paramref name="interfaceType" /> on the current object.</returns>
48+
<remarks>
49+
<format type="text/markdown"><![CDATA[
50+
51+
## Remarks
52+
53+
When this function is called, the cast of this object to the given interface should already have been verified through the `castclass/isinst` instructions.
54+
The returned type must be an interface type and be marked with the <xref:System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute>. Otherwise, <xref:System.InvalidOperationException> will be thrown.
55+
56+
]]></format>
57+
</remarks>
58+
<exception cref="T:System.InvalidOperationException">The returned type is not an interface type, or it was not marked with the <see cref="T:System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute" />.</exception>
4159
</Docs>
4260
</Member>
4361
<Member MemberName="IsInterfaceImplemented">
@@ -60,11 +78,20 @@
6078
<Parameter Name="throwIfNotImplemented" Type="System.Boolean" />
6179
</Parameters>
6280
<Docs>
63-
<param name="interfaceType">To be added.</param>
64-
<param name="throwIfNotImplemented">To be added.</param>
65-
<summary>To be added.</summary>
66-
<returns>To be added.</returns>
67-
<remarks>To be added.</remarks>
81+
<param name="interfaceType">The interface type.</param>
82+
<param name="throwIfNotImplemented">Indicates if the function should throw an exception instead of returning <see langword="false" />.</param>
83+
<summary>Called when an implementing class instance is cast to an interface type that is not contained in the class's metadata.</summary>
84+
<returns><see langword="true" /> if this object can be cast to the given interface; otherwise, <see langword="false" />.</returns>
85+
<remarks>
86+
<format type="text/markdown"><![CDATA[
87+
88+
## Remarks
89+
90+
This is called if casting this object to the given interface type would otherwise fail. Casting here means the IL `isinst` and `castclass` instructions in the case where they are given an interface type as the target type.
91+
If `throwIfNotImplemented` is `false`, this function should avoid throwing exceptions. If `throwIfNotImplemented` is `true` and this function returns `false`, then <xref:System.InvalidCastException> will be thrown unless an exception is thrown by the implementation.
92+
93+
]]></format>
94+
</remarks>
6895
</Docs>
6996
</Member>
7097
</Members>

xml/System.Runtime.InteropServices/MemoryMarshal.xml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="MemoryMarshal" FullName="System.Runtime.InteropServices.MemoryMarshal">
1+
<Type Name="MemoryMarshal" FullName="System.Runtime.InteropServices.MemoryMarshal">
22
<TypeSignature Language="C#" Value="public static class MemoryMarshal" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit MemoryMarshal extends System.Object" />
44
<TypeSignature Language="DocId" Value="T:System.Runtime.InteropServices.MemoryMarshal" />
@@ -600,11 +600,21 @@ This method can be useful if part of a managed object represents a fixed array.
600600
<Parameter Name="array" Type="T[]" Index="0" FrameworkAlternate="net-5.0" />
601601
</Parameters>
602602
<Docs>
603-
<typeparam name="T">To be added.</typeparam>
604-
<param name="array">To be added.</param>
605-
<summary>To be added.</summary>
603+
<typeparam name="T">The type of the array elements.</typeparam>
604+
<param name="array">The array to analyze.</param>
605+
<summary>Returns a reference to the 0th element of <paramref name="array" />. If the array is empty, returns a reference to where the 0th element would have been stored. Such a reference may be used for pinning but must never be dereferenced.</summary>
606606
<returns>To be added.</returns>
607-
<remarks>To be added.</remarks>
607+
<remarks>
608+
<format type="text/markdown"><![CDATA[
609+
610+
## Remarks
611+
612+
This method does not perform array variance checks. The caller must manually perform any array variance checks if the caller wishes to write to the returned reference.
613+
614+
]]></format>
615+
</remarks>
616+
<exception cref="T:System.NullReferenceException">
617+
<paramref name="array" /> is <see langword="null" />.</exception>
608618
</Docs>
609619
</Member>
610620
<Member MemberName="GetReference&lt;T&gt;">

xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Type Name="UnmanagedCallersOnlyAttribute" FullName="System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute">
1+
<Type Name="UnmanagedCallersOnlyAttribute" FullName="System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute">
22
<TypeSignature Language="C#" Value="public sealed class UnmanagedCallersOnlyAttribute : Attribute" />
33
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit UnmanagedCallersOnlyAttribute extends System.Attribute" />
44
<TypeSignature Language="DocId" Value="T:System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute" />
@@ -20,8 +20,19 @@
2020
</Attribute>
2121
</Attributes>
2222
<Docs>
23-
<summary>To be added.</summary>
24-
<remarks>To be added.</remarks>
23+
<summary>Any method marked with <see cref="T:System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute" /> can be directly called from native code. The function token can be loaded to a local variable using the <see href="https://docs.microsoft.com/dotnet/csharp/language-reference/operators/pointer-related-operators#address-of-operator-">address-of</see> operator in C# and passed as a callback to a native method.</summary>
24+
<remarks>
25+
<format type="text/markdown"><![CDATA[
26+
27+
## Remarks
28+
29+
Methods marked with this attribute have the following restrictions:
30+
* Method must be marked "static".
31+
* Must not be called from managed code.
32+
* Must only have <see href="https://docs.microsoft.com/dotnet/framework/interop/blittable-and-non-blittable-types">blittable</see> arguments.
33+
34+
]]></format>
35+
</remarks>
2536
</Docs>
2637
<Members>
2738
<Member MemberName=".ctor">
@@ -37,7 +48,7 @@
3748
</AssemblyInfo>
3849
<Parameters />
3950
<Docs>
40-
<summary>To be added.</summary>
51+
<summary>Initializes a new <see cref="T:System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute" /> instance.</summary>
4152
<remarks>To be added.</remarks>
4253
</Docs>
4354
</Member>
@@ -77,7 +88,7 @@
7788
<ReturnType>System.String</ReturnType>
7889
</ReturnValue>
7990
<Docs>
80-
<summary>To be added.</summary>
91+
<summary>Optional. If omitted, no named export is emitted during compilation.</summary>
8192
<remarks>To be added.</remarks>
8293
</Docs>
8394
</Member>

0 commit comments

Comments
 (0)