diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.DerivedComObject.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.DerivedComObject.cs
index 64e10f2..c6f2b71 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.DerivedComObject.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.DerivedComObject.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace ComInterfaceGenerator.Tests
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
partial class DerivedComObject
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.IDerivedTests.DerivedImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.IDerivedTests.DerivedImpl.cs
index deaf259..f057232 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.IDerivedTests.DerivedImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.IDerivedTests.DerivedImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -26,8 +26,8 @@
return s_vtables;
}
-}
-
+}
+
namespace ComInterfaceGenerator.Tests
{
public unsafe partial class IDerivedTests
@@ -37,4 +37,4 @@ partial class DerivedImpl
{
}
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.ManagedObjectExposedToCom.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.ManagedObjectExposedToCom.cs
index 0fc2e9e..3db9392 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.ManagedObjectExposedToCom.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.ManagedObjectExposedToCom.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace ComInterfaceGenerator.Tests
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
partial class ManagedObjectExposedToCom
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.CustomUtf16MarshalledClass.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.CustomUtf16MarshalledClass.cs
index 82bfd89..4ec58a7 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.CustomUtf16MarshalledClass.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.CustomUtf16MarshalledClass.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,8 +20,8 @@
return s_vtables;
}
-}
-
+}
+
namespace ComInterfaceGenerator.Tests
{
public unsafe partial class StringMarshallingTests
@@ -31,4 +31,4 @@ internal partial class CustomUtf16MarshalledClass
{
}
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.Utf16MarshalledClass.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.Utf16MarshalledClass.cs
index fdfe9df..16af57e 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.Utf16MarshalledClass.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.Utf16MarshalledClass.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,8 +20,8 @@
return s_vtables;
}
-}
-
+}
+
namespace ComInterfaceGenerator.Tests
{
public unsafe partial class StringMarshallingTests
@@ -31,4 +31,4 @@ internal partial class Utf16MarshalledClass
{
}
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.Utf8MarshalledClass.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.Utf8MarshalledClass.cs
index 3525541..d0fd8ae 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.Utf8MarshalledClass.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/ComInterfaceGenerator.Tests.StringMarshallingTests.Utf8MarshalledClass.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,8 +20,8 @@
return s_vtables;
}
-}
-
+}
+
namespace ComInterfaceGenerator.Tests
{
public unsafe partial class StringMarshallingTests
@@ -31,4 +31,4 @@ internal partial class Utf8MarshalledClass
{
}
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.ArrayOfStatelessElements.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.ArrayOfStatelessElements.cs
index 0ade01c..8a079fa 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.ArrayOfStatelessElements.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.ArrayOfStatelessElements.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class ArrayOfStatelessElements
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.ArrayOfStatelessElementsThrows.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.ArrayOfStatelessElementsThrows.cs
new file mode 100644
index 0000000..e2563f8
--- /dev/null
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.ArrayOfStatelessElementsThrows.cs
@@ -0,0 +1,31 @@
+//
+file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
+{
+ private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
+ public static System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* GetComInterfaceEntries(out int count)
+ {
+ count = 1;
+ if (s_vtables == null)
+ {
+ System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* vtables = (System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry*)System.Runtime.CompilerServices.RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(ComClassInformation), sizeof(System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry) * 1);
+ System.Runtime.InteropServices.Marshalling.IIUnknownDerivedDetails details;
+ details = System.Runtime.InteropServices.Marshalling.StrategyBasedComWrappers.DefaultIUnknownInterfaceDetailsStrategy.GetIUnknownDerivedDetails(typeof(SharedTypes.ComInterfaces.IArrayOfStatelessElements).TypeHandle);
+ vtables[0] = new()
+ {
+ IID = details.Iid,
+ Vtable = (nint)details.ManagedVirtualMethodTable
+ };
+ s_vtables = vtables;
+ }
+
+ return s_vtables;
+ }
+}
+
+namespace SharedTypes.ComInterfaces
+{
+ [System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
+ internal partial class ArrayOfStatelessElementsThrows
+ {
+ }
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.Derived.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.Derived.cs
index c4d7431..8714f5c 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.Derived.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.Derived.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -26,12 +26,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class Derived
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.GetAndSetInt.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.GetAndSetInt.cs
index cda8421..b07aefa 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.GetAndSetInt.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.GetAndSetInt.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class GetAndSetInt
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IBoolImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IBoolImpl.cs
index 867e228..bec4508 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IBoolImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IBoolImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class IBoolImpl
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IFloatImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IFloatImpl.cs
index 0f874db..75d34e1 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IFloatImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IFloatImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class IFloatImpl
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IIntArrayImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IIntArrayImpl.cs
index 3fd965d..54224c8 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IIntArrayImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IIntArrayImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class IIntArrayImpl
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IIntImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IIntImpl.cs
index 563469a..b8e69d1 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IIntImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IIntImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class IIntImpl
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IInterfaceImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IInterfaceImpl.cs
index 8e2d048..299cd79 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IInterfaceImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IInterfaceImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class IInterfaceImpl
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IJaggedIntArrayImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IJaggedIntArrayImpl.cs
index e05f617..6cc208d 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IJaggedIntArrayImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.IJaggedIntArrayImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class IJaggedIntArrayImpl
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.ICollectionMarshallingFailsImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.ICollectionMarshallingFailsImpl.cs
index 8165c4d..f143c8a 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.ICollectionMarshallingFailsImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.ICollectionMarshallingFailsImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces.MarshallingFails
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class ICollectionMarshallingFailsImpl
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.IJaggedIntArrayMarshallingFailsImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.IJaggedIntArrayMarshallingFailsImpl.cs
index 2cf5a32..3e510f1 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.IJaggedIntArrayMarshallingFailsImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.IJaggedIntArrayMarshallingFailsImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces.MarshallingFails
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class IJaggedIntArrayMarshallingFailsImpl
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.IStringArrayMarshallingFailsImpl.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.IStringArrayMarshallingFailsImpl.cs
index 3db32a6..bb1bd14 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.IStringArrayMarshallingFailsImpl.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.MarshallingFails.IStringArrayMarshallingFailsImpl.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces.MarshallingFails
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class IStringArrayMarshallingFailsImpl
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatefulFinallyMarshalling.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatefulFinallyMarshalling.cs
index 4b28658..0cc61a8 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatefulFinallyMarshalling.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatefulFinallyMarshalling.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class StatefulFinallyMarshalling
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessCallerAllocatedBufferMarshalling.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessCallerAllocatedBufferMarshalling.cs
index ffb1974..7d63c39 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessCallerAllocatedBufferMarshalling.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessCallerAllocatedBufferMarshalling.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class StatelessCallerAllocatedBufferMarshalling
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessFinallyMarshalling.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessFinallyMarshalling.cs
index 05cfde7..bcea489 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessFinallyMarshalling.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessFinallyMarshalling.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class StatelessFinallyMarshalling
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessMarshalling.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessMarshalling.cs
index e0c887f..054af61 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessMarshalling.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessMarshalling.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class StatelessMarshalling
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessPinnedMarshalling.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessPinnedMarshalling.cs
index a2dfcab..2089aa4 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessPinnedMarshalling.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComClassGenerator/SharedTypes.ComInterfaces.StatelessPinnedMarshalling.cs
@@ -1,4 +1,4 @@
-//
+//
file sealed unsafe class ComClassInformation : System.Runtime.InteropServices.Marshalling.IComExposedClass
{
private static volatile System.Runtime.InteropServices.ComWrappers.ComInterfaceEntry* s_vtables;
@@ -20,12 +20,12 @@
return s_vtables;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.ComExposedClassAttribute]
internal partial class StatelessPinnedMarshalling
{
}
-}
+}
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IArrayOfStatelessElements.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IArrayOfStatelessElements.cs
index 422578f..ca2d14b 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IArrayOfStatelessElements.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IArrayOfStatelessElements.cs
@@ -1,13 +1,13 @@
-//
-#pragma warning disable CS0612, CS0618
+//
+#pragma warning disable CS0612, CS0618
file unsafe class InterfaceInformation : System.Runtime.InteropServices.Marshalling.IIUnknownInterfaceType
{
public static System.Guid Iid { get; } = new(new System.ReadOnlySpan(new byte[] { 191, 60, 150, 244, 175, 16, 11, 70, 132, 149, 16, 119, 130, 24, 119, 5 }));
private static void** _vtable;
public static void** ManagedVirtualMethodTable => _vtable != null ? _vtable : (_vtable = InterfaceImplementation.CreateManagedVirtualFunctionTable());
-}
-
+}
+
[System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute]
file unsafe partial interface InterfaceImplementation : global::SharedTypes.ComInterfaces.IArrayOfStatelessElements
{
@@ -16,6 +16,7 @@
void global::SharedTypes.ComInterfaces.IArrayOfStatelessElements.Method(global::SharedTypes.ComInterfaces.StatelessType[] param, int size)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IArrayOfStatelessElements));
+ bool __invokeSucceeded = default;
nint* __param_native = default;
int __invokeRetVal = default;
// Setup - Perform required setup.
@@ -46,11 +47,18 @@
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
+ __invokeSucceeded = true;
System.GC.KeepAlive(this);
}
finally
{
- // Cleanup - Perform required cleanup.
+ if (__invokeSucceeded)
+ {
+ // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
+ _ = __param_native__lastIndexMarshalled;
+ }
+
+ // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
@@ -68,6 +76,7 @@
void global::SharedTypes.ComInterfaces.IArrayOfStatelessElements.MethodIn(in global::SharedTypes.ComInterfaces.StatelessType[] param, int size)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IArrayOfStatelessElements));
+ bool __invokeSucceeded = default;
nint* __param_native = default;
int __invokeRetVal = default;
// Setup - Perform required setup.
@@ -98,11 +107,18 @@
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
+ __invokeSucceeded = true;
System.GC.KeepAlive(this);
}
finally
{
- // Cleanup - Perform required cleanup.
+ if (__invokeSucceeded)
+ {
+ // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
+ _ = __param_native__lastIndexMarshalled;
+ }
+
+ // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
@@ -120,6 +136,7 @@
void global::SharedTypes.ComInterfaces.IArrayOfStatelessElements.MethodOut(out global::SharedTypes.ComInterfaces.StatelessType[] param, int size)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IArrayOfStatelessElements));
+ bool __invokeSucceeded = default;
System.Runtime.CompilerServices.Unsafe.SkipInit(out param);
nint* __param_native = default;
int __invokeRetVal = default;
@@ -134,6 +151,7 @@
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
+ __invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
__param_native__numElements = size;
@@ -149,17 +167,19 @@
}
finally
{
- // Cleanup - Perform required cleanup.
+ if (__invokeSucceeded)
{
- System.ReadOnlySpan __param_native__nativeSpan = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.GetUnmanagedValuesSource(__param_native, __param_native__numElements);
- for (int __i0 = 0; __i0 < __param_native__nativeSpan.Length; ++__i0)
+ // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
{
- global::SharedTypes.ComInterfaces.StatelessTypeMarshaller.UnmanagedToManaged.Free(__param_native__nativeSpan[__i0]);
+ System.ReadOnlySpan __param_native__nativeSpan = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.GetUnmanagedValuesSource(__param_native, __param_native__numElements);
+ for (int __i0 = 0; __i0 < __param_native__nativeSpan.Length; ++__i0)
+ {
+ global::SharedTypes.ComInterfaces.StatelessTypeMarshaller.UnmanagedToManaged.Free(__param_native__nativeSpan[__i0]);
+ }
}
- }
- __param_native__numElements = size;
- global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.Free(__param_native);
+ global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.Free(__param_native);
+ }
}
}
@@ -208,7 +228,7 @@
}
finally
{
- // Cleanup - Perform required cleanup.
+ // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan __param_native__nativeSpan = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.GetUnmanagedValuesSource(__param_native, __param_native__numElements);
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
@@ -227,6 +247,7 @@
void global::SharedTypes.ComInterfaces.IArrayOfStatelessElements.MethodContentsIn(global::SharedTypes.ComInterfaces.StatelessType[] param, int size)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IArrayOfStatelessElements));
+ bool __invokeSucceeded = default;
nint* __param_native = default;
int __invokeRetVal = default;
// Setup - Perform required setup.
@@ -257,11 +278,18 @@
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
+ __invokeSucceeded = true;
System.GC.KeepAlive(this);
}
finally
{
- // Cleanup - Perform required cleanup.
+ if (__invokeSucceeded)
+ {
+ // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
+ _ = __param_native__lastIndexMarshalled;
+ }
+
+ // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
@@ -279,6 +307,7 @@
void global::SharedTypes.ComInterfaces.IArrayOfStatelessElements.MethodContentsOut(global::SharedTypes.ComInterfaces.StatelessType[] param, int size)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IArrayOfStatelessElements));
+ bool __invokeSucceeded = default;
nint* __param_native = default;
int __invokeRetVal = default;
// Setup - Perform required setup.
@@ -300,6 +329,7 @@
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
+ __invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
{
@@ -314,15 +344,19 @@
}
finally
{
- // Cleanup - Perform required cleanup.
+ if (__invokeSucceeded)
{
- System.ReadOnlySpan __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
- for (int __i0 = 0; __i0 < __param_native__nativeSpan.Length; ++__i0)
+ // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
{
- global::SharedTypes.ComInterfaces.StatelessTypeMarshaller.UnmanagedToManaged.Free(__param_native__nativeSpan[__i0]);
+ System.ReadOnlySpan __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
+ for (int __i0 = 0; __i0 < __param_native__nativeSpan.Length; ++__i0)
+ {
+ global::SharedTypes.ComInterfaces.StatelessTypeMarshaller.UnmanagedToManaged.Free(__param_native__nativeSpan[__i0]);
+ }
}
}
+ // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
__param_native__marshaller.Free();
}
}
@@ -332,6 +366,7 @@
void global::SharedTypes.ComInterfaces.IArrayOfStatelessElements.MethodContentsInOut(global::SharedTypes.ComInterfaces.StatelessType[] param, int size)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IArrayOfStatelessElements));
+ bool __invokeSucceeded = default;
nint* __param_native = default;
int __invokeRetVal = default;
// Setup - Perform required setup.
@@ -362,6 +397,7 @@
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
+ __invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
{
@@ -376,7 +412,13 @@
}
finally
{
- // Cleanup - Perform required cleanup.
+ if (__invokeSucceeded)
+ {
+ // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
+ _ = __param_native__lastIndexMarshalled;
+ }
+
+ // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
{
System.ReadOnlySpan __param_native__nativeSpan = __param_native__marshaller.GetUnmanagedValuesDestination();
for (int __i0 = 0; __i0 < __param_native__lastIndexMarshalled; ++__i0)
@@ -388,8 +430,8 @@
__param_native__marshaller.Free();
}
}
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
[System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvMemberFunction) })]
@@ -404,7 +446,6 @@ internal static int ABI_Method(System.Runtime.InteropServices.ComWrappers.ComInt
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
__param_native__numElements = size;
param = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.AllocateContainerForManagedElements(__param_native, __param_native__numElements);
{
@@ -418,6 +459,8 @@ internal static int ABI_Method(System.Runtime.InteropServices.ComWrappers.ComInt
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.Method(param, size);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
}
catch (System.Exception __exception)
{
@@ -440,7 +483,6 @@ internal static int ABI_MethodIn(System.Runtime.InteropServices.ComWrappers.ComI
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
__param_native__numElements = size;
param = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.AllocateContainerForManagedElements(__param_native, __param_native__numElements);
{
@@ -454,6 +496,8 @@ internal static int ABI_MethodIn(System.Runtime.InteropServices.ComWrappers.ComI
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.MethodIn(in param, size);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
}
catch (System.Exception __exception)
{
@@ -476,9 +520,10 @@ internal static int ABI_MethodOut(System.Runtime.InteropServices.ComWrappers.Com
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.MethodOut(out param, size);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
// Marshal - Convert managed data to native data.
__param_native = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.AllocateContainerForUnmanagedElements(param, out __param_native__numElements);
{
@@ -515,7 +560,6 @@ internal static int ABI_MethodRef(System.Runtime.InteropServices.ComWrappers.Com
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
__param_native__numElements = size;
param = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.AllocateContainerForManagedElements(__param_native, __param_native__numElements);
{
@@ -529,6 +573,8 @@ internal static int ABI_MethodRef(System.Runtime.InteropServices.ComWrappers.Com
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.MethodRef(ref param, size);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
// Marshal - Convert managed data to native data.
__param_native = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.AllocateContainerForUnmanagedElements(param, out __param_native__numElements);
__param_native__ownOriginal = true;
@@ -547,7 +593,7 @@ internal static int ABI_MethodRef(System.Runtime.InteropServices.ComWrappers.Com
}
finally
{
- // Cleanup - Perform required cleanup.
+ // CleanupCallerAllocated - Perform cleanup of caller allocated resources.
if (__param_native__ownOriginal)
{
{
@@ -578,7 +624,6 @@ internal static int ABI_MethodContentsIn(System.Runtime.InteropServices.ComWrapp
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
__param_native__numElements = size;
param = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.AllocateContainerForManagedElements(__param_native, __param_native__numElements);
{
@@ -592,6 +637,8 @@ internal static int ABI_MethodContentsIn(System.Runtime.InteropServices.ComWrapp
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.MethodContentsIn(param, size);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
}
catch (System.Exception __exception)
{
@@ -613,10 +660,11 @@ internal static int ABI_MethodContentsOut(System.Runtime.InteropServices.ComWrap
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.GetManagedValuesDestination(param).Clear();
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.MethodContentsOut(param, size);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
// Marshal - Convert managed data to native data.
{
__param_native__numElements = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.GetManagedValuesDestination(param).Length;
@@ -650,7 +698,6 @@ internal static int ABI_MethodContentsInOut(System.Runtime.InteropServices.ComWr
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
__param_native__numElements = size;
param = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.AllocateContainerForManagedElements(__param_native, __param_native__numElements);
{
@@ -664,6 +711,8 @@ internal static int ABI_MethodContentsInOut(System.Runtime.InteropServices.ComWr
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.MethodContentsInOut(param, size);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
// Marshal - Convert managed data to native data.
{
__param_native__numElements = global::System.Runtime.InteropServices.Marshalling.ArrayMarshaller.GetManagedValuesDestination(param).Length;
@@ -684,8 +733,8 @@ internal static int ABI_MethodContentsInOut(System.Runtime.InteropServices.ComWr
return __retVal;
}
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
internal static void** CreateManagedVirtualFunctionTable()
@@ -711,16 +760,16 @@ file unsafe partial interface InterfaceImplementation
return vtable;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.IUnknownDerivedAttribute]
internal partial interface IArrayOfStatelessElements
{
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
internal partial interface IArrayOfStatelessElements
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IBool.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IBool.cs
index 35672ee..e4e4b59 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IBool.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IBool.cs
@@ -1,13 +1,13 @@
-//
-#pragma warning disable CS0612, CS0618
+//
+#pragma warning disable CS0612, CS0618
file unsafe class InterfaceInformation : System.Runtime.InteropServices.Marshalling.IIUnknownInterfaceType
{
public static System.Guid Iid { get; } = new(new System.ReadOnlySpan(new byte[] { 214, 62, 157, 90, 23, 204, 185, 79, 143, 130, 0, 112, 72, 155, 114, 19 }));
private static void** _vtable;
public static void** ManagedVirtualMethodTable => _vtable != null ? _vtable : (_vtable = InterfaceImplementation.CreateManagedVirtualFunctionTable());
-}
-
+}
+
[System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute]
file unsafe partial interface InterfaceImplementation : global::SharedTypes.ComInterfaces.IBool
{
@@ -48,8 +48,8 @@
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
System.GC.KeepAlive(this);
}
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
[System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvMemberFunction) })]
@@ -62,9 +62,10 @@ internal static int ABI_Get(System.Runtime.InteropServices.ComWrappers.ComInterf
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
__invokeRetVal = @this.Get();
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
// Marshal - Convert managed data to native data.
__invokeRetValUnmanaged = (sbyte)(__invokeRetVal ? 1 : 0);
}
@@ -85,10 +86,11 @@ internal static int ABI_Set(System.Runtime.InteropServices.ComWrappers.ComInterf
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
value = __value_native != 0;
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.Set(value);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
}
catch (System.Exception __exception)
{
@@ -97,8 +99,8 @@ internal static int ABI_Set(System.Runtime.InteropServices.ComWrappers.ComInterf
return __retVal;
}
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
internal static void** CreateManagedVirtualFunctionTable()
@@ -119,16 +121,16 @@ file unsafe partial interface InterfaceImplementation
return vtable;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.IUnknownDerivedAttribute]
internal partial interface IBool
{
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
internal partial interface IBool
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.ICustomStringMarshallingUtf16.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.ICustomStringMarshallingUtf16.cs
index ed15d0f..74732ff 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.ICustomStringMarshallingUtf16.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.ICustomStringMarshallingUtf16.cs
@@ -1,13 +1,13 @@
-//
-#pragma warning disable CS0612, CS0618
+//
+#pragma warning disable CS0612, CS0618
file unsafe class InterfaceInformation : System.Runtime.InteropServices.Marshalling.IIUnknownInterfaceType
{
public static System.Guid Iid { get; } = new(new System.ReadOnlySpan(new byte[] { 62, 95, 29, 225, 87, 221, 166, 65, 165, 158, 125, 17, 5, 81, 167, 96 }));
private static void** _vtable;
public static void** ManagedVirtualMethodTable => _vtable != null ? _vtable : (_vtable = InterfaceImplementation.CreateManagedVirtualFunctionTable());
-}
-
+}
+
[System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute]
file unsafe partial interface InterfaceImplementation : global::SharedTypes.ComInterfaces.ICustomStringMarshallingUtf16
{
@@ -16,6 +16,7 @@
string global::SharedTypes.ComInterfaces.ICustomStringMarshallingUtf16.GetString()
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.ICustomStringMarshallingUtf16));
+ bool __invokeSucceeded = default;
string __retVal = default;
ushort* __retVal_native = default;
int __invokeRetVal = default;
@@ -27,14 +28,18 @@
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
+ __invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
__retVal = global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.ConvertToManaged(__retVal_native);
}
finally
{
- // Cleanup - Perform required cleanup.
- global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.Free(__retVal_native);
+ if (__invokeSucceeded)
+ {
+ // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
+ global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.Free(__retVal_native);
+ }
}
return __retVal;
@@ -56,8 +61,8 @@
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
System.GC.KeepAlive(this);
}
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
[System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvMemberFunction) })]
@@ -70,9 +75,10 @@ internal static int ABI_GetString(System.Runtime.InteropServices.ComWrappers.Com
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
__invokeRetVal = @this.GetString();
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
// Marshal - Convert managed data to native data.
__invokeRetValUnmanaged = (ushort*)global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.ConvertToUnmanaged(__invokeRetVal);
}
@@ -93,10 +99,11 @@ internal static int ABI_SetString(System.Runtime.InteropServices.ComWrappers.Com
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
value = global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.ConvertToManaged(__value_native);
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.SetString(value);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
}
catch (System.Exception __exception)
{
@@ -105,8 +112,8 @@ internal static int ABI_SetString(System.Runtime.InteropServices.ComWrappers.Com
return __retVal;
}
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
internal static void** CreateManagedVirtualFunctionTable()
@@ -127,16 +134,16 @@ file unsafe partial interface InterfaceImplementation
return vtable;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.IUnknownDerivedAttribute]
internal partial interface ICustomStringMarshallingUtf16
{
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
internal partial interface ICustomStringMarshallingUtf16
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IDerived.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IDerived.cs
index 9d57c73..d2bd382 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IDerived.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IDerived.cs
@@ -1,13 +1,13 @@
-//
-#pragma warning disable CS0612, CS0618
+//
+#pragma warning disable CS0612, CS0618
file unsafe class InterfaceInformation : System.Runtime.InteropServices.Marshalling.IIUnknownInterfaceType
{
public static System.Guid Iid { get; } = new(new System.ReadOnlySpan(new byte[] { 100, 179, 13, 127, 4, 60, 135, 68, 145, 147, 75, 176, 93, 199, 182, 84 }));
private static void** _vtable;
public static void** ManagedVirtualMethodTable => _vtable != null ? _vtable : (_vtable = InterfaceImplementation.CreateManagedVirtualFunctionTable());
-}
-
+}
+
[System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute]
file unsafe partial interface InterfaceImplementation : global::SharedTypes.ComInterfaces.IDerived
{
@@ -33,6 +33,7 @@
string global::SharedTypes.ComInterfaces.IDerived.GetName()
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IDerived));
+ bool __invokeSucceeded = default;
string __retVal = default;
ushort* __retVal_native = default;
int __invokeRetVal = default;
@@ -44,14 +45,18 @@
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
+ __invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
__retVal = global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.ConvertToManaged(__retVal_native);
}
finally
{
- // Cleanup - Perform required cleanup.
- global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.Free(__retVal_native);
+ if (__invokeSucceeded)
+ {
+ // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
+ global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.Free(__retVal_native);
+ }
}
return __retVal;
@@ -91,8 +96,8 @@
int global::SharedTypes.ComInterfaces.IGetAndSetInt.GetInt() => throw new System.Diagnostics.UnreachableException();
void global::SharedTypes.ComInterfaces.IGetAndSetInt.SetInt(int x) => throw new System.Diagnostics.UnreachableException();
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
[System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvMemberFunction) })]
@@ -104,10 +109,11 @@ internal static int ABI_SetName(System.Runtime.InteropServices.ComWrappers.ComIn
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
name = global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.ConvertToManaged(__name_native);
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
@this.SetName(name);
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
}
catch (System.Exception __exception)
{
@@ -127,9 +133,10 @@ internal static int ABI_GetName(System.Runtime.InteropServices.ComWrappers.ComIn
try
{
// Unmarshal - Convert native data to managed data.
- __retVal = 0; // S_OK
@this = System.Runtime.InteropServices.ComWrappers.ComInterfaceDispatch.GetInstance(__this_native);
__invokeRetVal = @this.GetName();
+ // NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
+ __retVal = 0; // S_OK
// Marshal - Convert managed data to native data.
__invokeRetValUnmanaged = (ushort*)global::System.Runtime.InteropServices.Marshalling.Utf16StringMarshaller.ConvertToUnmanaged(__invokeRetVal);
}
@@ -140,8 +147,8 @@ internal static int ABI_GetName(System.Runtime.InteropServices.ComWrappers.ComIn
return __retVal;
}
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
internal static void** CreateManagedVirtualFunctionTable()
@@ -158,16 +165,16 @@ file unsafe partial interface InterfaceImplementation
return vtable;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.IUnknownDerivedAttribute]
internal partial interface IDerived
{
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
internal partial interface IDerived
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IEmpty.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IEmpty.cs
index 0b4a031..7feb8f3 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IEmpty.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IEmpty.cs
@@ -1,22 +1,22 @@
-//
-#pragma warning disable CS0612, CS0618
+//
+#pragma warning disable CS0612, CS0618
file unsafe class InterfaceInformation : System.Runtime.InteropServices.Marshalling.IIUnknownInterfaceType
{
public static System.Guid Iid { get; } = new(new System.ReadOnlySpan(new byte[] { 80, 159, 209, 149, 216, 242, 97, 78, 136, 75, 10, 145, 98, 234, 70, 70 }));
private static void** _vtable;
public static void** ManagedVirtualMethodTable => _vtable != null ? _vtable : (_vtable = InterfaceImplementation.CreateManagedVirtualFunctionTable());
-}
-
+}
+
[System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute]
file unsafe partial interface InterfaceImplementation : global::SharedTypes.ComInterfaces.IEmpty
{
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
-}
-
+}
+
file unsafe partial interface InterfaceImplementation
{
internal static void** CreateManagedVirtualFunctionTable()
@@ -35,16 +35,16 @@ file unsafe partial interface InterfaceImplementation
return vtable;
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
[System.Runtime.InteropServices.Marshalling.IUnknownDerivedAttribute]
internal partial interface IEmpty
{
}
-}
-
+}
+
namespace SharedTypes.ComInterfaces
{
internal partial interface IEmpty
diff --git a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IEnumUnknown.cs b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IEnumUnknown.cs
index 9bcb5bf..a7296e3 100644
--- a/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IEnumUnknown.cs
+++ b/ComInterfaceGenerator.Tests/Microsoft.Interop.ComInterfaceGenerator/Microsoft.Interop.ComInterfaceGenerator/SharedTypes.ComInterfaces.IEnumUnknown.cs
@@ -1,13 +1,13 @@
-//
-#pragma warning disable CS0612, CS0618
+//
+#pragma warning disable CS0612, CS0618
file unsafe class InterfaceInformation : System.Runtime.InteropServices.Marshalling.IIUnknownInterfaceType
{
public static System.Guid Iid { get; } = new(new System.ReadOnlySpan(new byte[] { 0, 1, 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 70 }));
private static void** _vtable;
public static void** ManagedVirtualMethodTable => _vtable != null ? _vtable : (_vtable = InterfaceImplementation.CreateManagedVirtualFunctionTable());
-}
-
+}
+
[System.Runtime.InteropServices.DynamicInterfaceCastableImplementationAttribute]
file unsafe partial interface InterfaceImplementation : global::SharedTypes.ComInterfaces.IEnumUnknown
{
@@ -16,6 +16,7 @@
void global::SharedTypes.ComInterfaces.IEnumUnknown.Next(uint celt, object[] rgelt, out uint pceltFetched)
{
var(__this, __vtable_native) = ((System.Runtime.InteropServices.Marshalling.IUnmanagedVirtualMethodTableProvider)this).GetVirtualMethodTableInfoForKey(typeof(global::SharedTypes.ComInterfaces.IEnumUnknown));
+ bool __invokeSucceeded = default;
System.Runtime.CompilerServices.Unsafe.SkipInit(out pceltFetched);
System.IntPtr* __rgelt_native = default;
int __invokeRetVal = default;
@@ -39,6 +40,7 @@
// NotifyForSuccessfulInvoke - Keep alive any managed objects that need to stay alive across the call.
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(__invokeRetVal);
+ __invokeSucceeded = true;
System.GC.KeepAlive(this);
// Unmarshal - Convert native data to managed data.
{
@@ -53,15 +55,19 @@
}
finally
{
- // Cleanup - Perform required cleanup.
+ if (__invokeSucceeded)
{
- System.ReadOnlySpan __rgelt_native__nativeSpan = __rgelt_native__marshaller.GetUnmanagedValuesDestination();
- for (int __i0 = 0; __i0 < __rgelt_native__nativeSpan.Length; ++__i0)
+ // CleanupCalleeAllocated - Perform cleanup of callee allocated resources.
{
- global::System.Runtime.InteropServices.Marshalling.ComInterfaceMarshaller