GetUnmanagedValues[Source|Destination] by marshal direction, not stub direction ...
authorJackson Schuster <36744439+jtschuster@users.noreply.github.com>
Mon, 7 Aug 2023 21:58:17 +0000 (16:58 -0500)
committerGitHub <noreply@github.com>
Mon, 7 Aug 2023 21:58:17 +0000 (14:58 -0700)
src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Marshalling/ElementsMarshalling.cs
src/libraries/System.Runtime.InteropServices/tests/TestAssets/SharedTypes/ComInterfaces/IStatelessCollectionStatelessElement.cs

index 5581892..7b71e9e 100644 (file)
@@ -463,7 +463,7 @@ namespace Microsoft.Interop
                     VariableDeclarator(
                         Identifier(nativeSpanIdentifier))
                     .WithInitializer(EqualsValueClause(
-                            context.Direction == MarshalDirection.ManagedToUnmanaged
+                            MarshallerHelpers.GetMarshalDirection(info, context) == MarshalDirection.ManagedToUnmanaged
                                 ? CollectionSource.GetUnmanagedValuesDestination(info, context)
                                 : CollectionSource.GetUnmanagedValuesSource(info, context)))))),
                 contentsCleanupStatements);
index 0465f39..7ab2245 100644 (file)
@@ -123,11 +123,6 @@ namespace SharedTypes.ComInterfaces
             {
                 throw new NotImplementedException();
             }
-            // Should be removed: https://github.com/dotnet/runtime/issues/89885
-            public static Span<TUnmanagedElement> GetUnmanagedValuesDestination(NativeCollection<T> unmanaged, int numElements)
-            {
-                throw new NotImplementedException();
-            }
 
             public static Span<T> GetManagedValuesDestination(StatelessCollection<T> managed)
             {
@@ -135,7 +130,6 @@ namespace SharedTypes.ComInterfaces
             }
 
             public static void Free(NativeCollection<T> unmanaged) => throw new NotImplementedException();
-
         }
     }
 }