From 45def419cf60e6139d387dd0d3c8c5f3de67c195 Mon Sep 17 00:00:00 2001
From: MarkFern <49532200+MarkFern@users.noreply.github.com>
Date: Thu, 11 Apr 2019 22:41:06 +0100
Subject: [PATCH] 2 Mistakes? In GetEndComSlot & GetStartComSlot?
Possible corrections are as follows:
- In remarks section of documentation for Marshal.GetEndComSlot, the following possible correction is made: "... If the class interface is auto-dispatch, this method always returns -1 to indicate that the dispatch-only interface does not expose a v-table to managed clients. ..."
- In parameter descriptions of documentation for Marshal.GetStartComSlot, the following possible correction is made: "A type that represents an interface or class."
Justifications for suggestions:
- Potential corrections align remarks section & parameter descriptions of the two methods: Marshal.GetEndComSlot & Marshal.GetStartComSlot.
- I've written code where the parameter in question has been a class type for the Marshal.GetStartComSlot method, and it worked without problems.
- The remarks section for Marshal.GetStartComSlot says that it returns a v-table number for an interface or a class. It logically follows that the one parameter that the static method accepts can be either an interface or a class.
- Changing 'auto-dual' to 'auto-dispatch' seems to be correct when reading documentation at: https://docs.microsoft.com/en-us/dotnet/framework/interop/com-callable-wrapper#avoid-caching-dispatch-identifiers-dispids.
- I've written code that runs Marshal.GetEndComSlot on an System.Collections.ArrayList type as well as on a System.Object type. The documentation for System.Object indicates that it is an auto-dual class ("[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)]" is written in class definition). Running GetEndComSlot on this type does not return -1 which is what the previous documentation for the method indicated would be the case. Contrastedly, running the method on an ArrayList type returns -1. The documentation at 'https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/4fcadw4a(v=vs.100)#avoid-caching-dispatch-identifiers-dispids' indicates that if the ClassInterface attribute is not defined, its value should be the default auto-dispatch. The ArrayList class definition in the documentation doesn't define the attribute and so should be auto-dispatch (from my thinking). Therefore, according to the previous documentation for the GetEndComSlot, running the method on an ArrayList type probably should return a genuine positive-integer com slot, but as just said, it returns -1 (the number that is supposed to be returned by auto-dual classes according to previous documentation.) It seems the documentation for GetEndComSlot has got auto-dual mixed up with auto-dispatch.
- The previous documentation for GetEndComSlot has the text: 'If the class interface is auto-dual, this method always returns -1 to indicate that the dispatch-only interface does not expose a v-table to managed clients.' I've suggested this text should be changed. The first part of the sentence refers to auto-dual classes, but the second part, which it seems is supposed to either also refer to auto-dual classes or an aspect of them, suddenly comments on dispatch-only interfaces which is not a proper reference to auto-dual classes or a direct aspect of them. Instead dispatch-only interfaces are connected to auto-dispatch classes which are not auto-dual classes - it looks like the first part of the sentence likely was supposed to refer to auto-dispatch classes instead of auto-dual classes.
---
xml/System.Runtime.InteropServices/Marshal.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/xml/System.Runtime.InteropServices/Marshal.xml b/xml/System.Runtime.InteropServices/Marshal.xml
index 7e6a3f258c6..fad8e5bc439 100644
--- a/xml/System.Runtime.InteropServices/Marshal.xml
+++ b/xml/System.Runtime.InteropServices/Marshal.xml
@@ -3234,7 +3234,7 @@
and in conjunction with to pass slots within a specified range. For additional information, see [Introducing the Class Interface](https://msdn.microsoft.com/library/733c0dd2-12e5-46e6-8de1-39d5b25df024).
+ This method returns the zero-based, v-table number for an interface or a class. When used on a class, the slot number returned refers to the class interface for the class. If the class interface is auto-dispatch, this method always returns -1 to indicate that the dispatch-only interface does not expose a v-table to managed clients. You can use and in conjunction with to pass slots within a specified range. For additional information, see [Introducing the Class Interface](https://msdn.microsoft.com/library/733c0dd2-12e5-46e6-8de1-39d5b25df024).
]]>
@@ -4819,7 +4819,7 @@
- A type that represents an interface.
+ A type that represents an interface or a class.
Gets the first slot in the virtual function table (v-table or VTBL) that contains user-defined methods.
The first VTBL slot that contains user-defined methods. The first slot is 3 if the interface is based on IUnknown, and 7 if the interface is based on [IDispatch](https://msdn.microsoft.com/library/ebbff4bc-36b2-4861-9efa-ffa45e013eb5).
@@ -12093,4 +12093,4 @@ public static void ThrowExceptionForHR(interrorCode,IntPtrerrorInfo)
-
\ No newline at end of file
+