Skip to content

Commit eabea90

Browse files
authored
Add more docs for new COM source generator types (#88627)
1 parent d2fae90 commit eabea90

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/ComInterfaceMarshaller.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace System.Runtime.InteropServices.Marshalling
77
{
88
/// <summary>
9-
/// COM interface marshaller using a StrategyBasedComWrappers instance
9+
/// COM interface marshaller using a <see cref="StrategyBasedComWrappers" /> instance
1010
/// </summary>
1111
/// <remarks>
1212
/// This marshaller will always pass the <see cref="CreateObjectFlags.Unwrap"/> flag
@@ -22,6 +22,11 @@ public static unsafe class ComInterfaceMarshaller<T>
2222
{
2323
private static readonly Guid? TargetInterfaceIID = StrategyBasedComWrappers.DefaultIUnknownInterfaceDetailsStrategy.GetIUnknownDerivedDetails(typeof(T).TypeHandle)?.Iid;
2424

25+
/// <summary>
26+
/// Convert a managed object to a COM interface pointer for the COM interface represented by <typeparamref name="T"/>.
27+
/// </summary>
28+
/// <param name="managed">The managed object</param>
29+
/// <returns>The COM interface pointer</returns>
2530
public static void* ConvertToUnmanaged(T? managed)
2631
{
2732
if (managed == null)
@@ -35,6 +40,13 @@ public static unsafe class ComInterfaceMarshaller<T>
3540
return CastIUnknownToInterfaceType(unknown);
3641
}
3742

43+
/// <summary>
44+
/// Convert a COM interface pointer to a managed object.
45+
/// </summary>
46+
/// <param name="unmanaged">The COM interface pointer</param>
47+
/// <remarks>
48+
/// If the passed in COM interface pointer wraps a managed object, this method returns the underlying object.
49+
/// </remarks>
3850
public static T? ConvertToManaged(void* unmanaged)
3951
{
4052
if (unmanaged == null)
@@ -44,6 +56,10 @@ public static unsafe class ComInterfaceMarshaller<T>
4456
return (T)StrategyBasedComWrappers.DefaultMarshallingInstance.GetOrCreateObjectForComInstance((nint)unmanaged, CreateObjectFlags.Unwrap);
4557
}
4658

59+
/// <summary>
60+
/// Release a reference to the COM interface pointer.
61+
/// </summary>
62+
/// <param name="unmanaged">A COM interface pointer.</param>
4763
public static void Free(void* unmanaged)
4864
{
4965
if (unmanaged != null)

src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/ComObject.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ internal ComObject(IIUnknownInterfaceDetailsStrategy interfaceDetailsStrategy, I
3030
_instancePointer = IUnknownStrategy.CreateInstancePointer(thisPointer);
3131
}
3232

33+
/// <summary>
34+
/// Release all references to the underlying COM object.
35+
/// </summary>
3336
~ComObject()
3437
{
3538
CacheStrategy.Clear(IUnknownStrategy);
@@ -54,11 +57,11 @@ internal ComObject(IIUnknownInterfaceDetailsStrategy interfaceDetailsStrategy, I
5457
internal bool UniqueInstance { get; init; }
5558

5659
/// <summary>
57-
/// Releases all references owned by this ComObject if it is a unique instance.
60+
/// Releases all references owned by this <see cref="ComObject" /> if it is a unique instance.
5861
/// </summary>
5962
/// <remarks>
60-
/// This method does nothing if the ComObject was not created with
61-
/// CreateObjectFlags.UniqueInstance.
63+
/// This method does nothing if the <see cref="ComObject" /> was not created with
64+
/// <see cref="CreateObjectFlags.UniqueInstance" />.
6265
/// </remarks>
6366
public void FinalRelease()
6467
{

src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/GeneratedComClassAttribute.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
namespace System.Runtime.InteropServices.Marshalling
55
{
6+
/// <summary>
7+
/// Specifies that code should be generated to enable exposing the attributed class to COM.
8+
/// </summary>
9+
/// <remarks>
10+
/// This attribute is only valid on types that implement at least one <see cref="GeneratedComInterfaceAttribute"/>-attributed interface.
11+
/// </remarks>
612
[AttributeUsage(AttributeTargets.Class)]
713
public sealed class GeneratedComClassAttribute : Attribute
814
{

src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/GeneratedComInterfaceAttribute.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace System.Runtime.InteropServices.Marshalling
55
{
6+
/// <summary>
7+
/// Specifies that the attributed type is a COM interface and that the source generator should generate code for it.
8+
/// </summary>
69
[AttributeUsage(AttributeTargets.Interface)]
710
public class GeneratedComInterfaceAttribute : Attribute
811
{

src/libraries/System.Runtime.InteropServices/src/System/Runtime/InteropServices/Marshalling/UniqueComInterfaceMarshaller.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ namespace System.Runtime.InteropServices.Marshalling
2121
[CustomMarshaller(typeof(CustomMarshallerAttribute.GenericPlaceholder), MarshalMode.Default, typeof(UniqueComInterfaceMarshaller<>))]
2222
public static unsafe class UniqueComInterfaceMarshaller<T>
2323
{
24+
/// <summary>
25+
/// Convert a managed object to a COM interface pointer for the COM interface represented by <typeparamref name="T"/>.
26+
/// </summary>
27+
/// <param name="managed">The managed object</param>
28+
/// <returns>The COM interface pointer</returns>
2429
public static void* ConvertToUnmanaged(T? managed)
2530
{
2631
if (managed == null)
@@ -34,6 +39,15 @@ public static unsafe class UniqueComInterfaceMarshaller<T>
3439
return ComInterfaceMarshaller<T>.CastIUnknownToInterfaceType(unknown);
3540
}
3641

42+
43+
/// <summary>
44+
/// Convert a COM interface pointer to a managed object.
45+
/// </summary>
46+
/// <param name="unmanaged">The COM interface pointer</param>
47+
/// <returns>A managed object that represents the passed in COM interface pointer.</returns>
48+
/// <remarks>
49+
/// If the passed in COM interface pointer wraps a managed object, this method returns the underlying object.
50+
/// </remarks>
3751
public static T? ConvertToManaged(void* unmanaged)
3852
{
3953
if (unmanaged == null)
@@ -43,6 +57,11 @@ public static unsafe class UniqueComInterfaceMarshaller<T>
4357
return (T)StrategyBasedComWrappers.DefaultMarshallingInstance.GetOrCreateObjectForComInstance((nint)unmanaged, CreateObjectFlags.Unwrap | CreateObjectFlags.UniqueInstance);
4458
}
4559

60+
61+
/// <summary>
62+
/// Release a reference to the COM interface pointer.
63+
/// </summary>
64+
/// <param name="unmanaged">A COM interface pointer.</param>
4665
public static void Free(void* unmanaged)
4766
{
4867
if (unmanaged != null)

0 commit comments

Comments
 (0)