-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ComInterfaceGenerator] Add Pinned collection parameter test type (#9…
- Loading branch information
1 parent
7a11cff
commit ab383f0
Showing
2 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
...rvices/tests/TestAssets/SharedTypes/ComInterfaces/IStatefulCollectionPinnableReference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.InteropServices.Marshalling; | ||
|
||
namespace SharedTypes.ComInterfaces | ||
{ | ||
[GeneratedComInterface(), Guid("0A52BA7C-E08B-42A4-A1F4-1A2BF2C07E60")] | ||
internal partial interface IStatefulCollectionPinnableReference | ||
{ | ||
void Method( | ||
[MarshalUsing(CountElementName = nameof(size))] StatefulCollectionPinnableReference<int> p, | ||
int size); | ||
|
||
void MethodIn( | ||
[MarshalUsing(CountElementName = nameof(size))] in StatefulCollectionPinnableReference<int> pIn, | ||
in int size); | ||
|
||
void MethodRef( | ||
[MarshalUsing(CountElementName = nameof(size))] ref StatefulCollectionPinnableReference<int> pRef, | ||
int size); | ||
|
||
void MethodOut( | ||
[MarshalUsing(CountElementName = nameof(size))] out StatefulCollectionPinnableReference<int> pOut, | ||
out int size); | ||
|
||
[return: MarshalUsing(CountElementName = nameof(size))] | ||
StatefulCollectionPinnableReference<int> Return(int size); | ||
} | ||
|
||
[NativeMarshalling(typeof(StatefulCollectionPinnableReferenceMarshaller<,>))] | ||
internal class StatefulCollectionPinnableReference<T> | ||
{ | ||
} | ||
|
||
internal struct StatefulCollectionPinnableReferenceNative | ||
{ | ||
public static unsafe explicit operator void*(StatefulCollectionPinnableReferenceNative _) => throw new NotImplementedException(); | ||
public static unsafe explicit operator StatefulCollectionPinnableReferenceNative(void* _) => throw new NotImplementedException(); | ||
} | ||
|
||
[ContiguousCollectionMarshaller] | ||
[CustomMarshaller(typeof(StatefulCollectionPinnableReference<>), MarshalMode.ManagedToUnmanagedRef, typeof(StatefulCollectionPinnableReferenceMarshaller<,>.Bidirectional))] | ||
[CustomMarshaller(typeof(StatefulCollectionPinnableReference<>), MarshalMode.UnmanagedToManagedRef, typeof(StatefulCollectionPinnableReferenceMarshaller<,>.Bidirectional))] | ||
[CustomMarshaller(typeof(StatefulCollectionPinnableReference<>), MarshalMode.ManagedToUnmanagedOut, typeof(StatefulCollectionPinnableReferenceMarshaller<,>.UnmanagedToManaged))] | ||
[CustomMarshaller(typeof(StatefulCollectionPinnableReference<>), MarshalMode.UnmanagedToManagedIn, typeof(StatefulCollectionPinnableReferenceMarshaller<,>.UnmanagedToManaged))] | ||
[CustomMarshaller(typeof(StatefulCollectionPinnableReference<>), MarshalMode.ManagedToUnmanagedIn, typeof(StatefulCollectionPinnableReferenceMarshaller<,>.ManagedToUnmanaged))] | ||
[CustomMarshaller(typeof(StatefulCollectionPinnableReference<>), MarshalMode.UnmanagedToManagedOut, typeof(StatefulCollectionPinnableReferenceMarshaller<,>.ManagedToUnmanaged))] | ||
internal static class StatefulCollectionPinnableReferenceMarshaller<T, TUnmanaged> where TUnmanaged : unmanaged | ||
{ | ||
public struct Bidirectional | ||
{ | ||
public void FromManaged(StatefulCollectionPinnableReference<T> managed) => throw new NotImplementedException(); | ||
public StatefulCollectionPinnableReferenceNative ToUnmanaged() => throw new NotImplementedException(); | ||
public ReadOnlySpan<T> GetManagedValuesSource() => throw new NotImplementedException(); | ||
public Span<TUnmanaged> GetUnmanagedValuesDestination() => throw new NotImplementedException(); | ||
|
||
public void FromUnmanaged(StatefulCollectionPinnableReferenceNative unmanaged) => throw new NotImplementedException(); | ||
public StatefulCollectionPinnableReference<T> ToManaged() => throw new NotImplementedException(); | ||
public ReadOnlySpan<TUnmanaged> GetUnmanagedValuesSource(int numElements) => throw new NotImplementedException(); | ||
public Span<T> GetManagedValuesDestination(int numElements) => throw new NotImplementedException(); | ||
|
||
public void Free() => throw new NotImplementedException(); | ||
} | ||
|
||
public struct UnmanagedToManaged | ||
{ | ||
public void Free() => throw new NotImplementedException(); | ||
public void FromUnmanaged(StatefulCollectionPinnableReferenceNative unmanaged) => throw new NotImplementedException(); | ||
public StatefulCollectionPinnableReference<T> ToManaged() => throw new NotImplementedException(); | ||
public ReadOnlySpan<TUnmanaged> GetUnmanagedValuesSource(int numElements) => throw new NotImplementedException(); | ||
public Span<T> GetManagedValuesDestination(int numElements) => throw new NotImplementedException(); | ||
} | ||
|
||
public struct ManagedToUnmanaged | ||
{ | ||
public void FromManaged(StatefulCollectionPinnableReference<T> managed) => throw new NotImplementedException(); | ||
public StatefulCollectionPinnableReferenceNative ToUnmanaged() => throw new NotImplementedException(); | ||
public ReadOnlySpan<T> GetManagedValuesSource() => throw new NotImplementedException(); | ||
public Span<TUnmanaged> GetUnmanagedValuesDestination() => throw new NotImplementedException(); | ||
public void Free() => throw new NotImplementedException(); | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...vices/tests/TestAssets/SharedTypes/ComInterfaces/IStatelessCollectionPinnableReference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.InteropServices.Marshalling; | ||
|
||
namespace SharedTypes.ComInterfaces | ||
{ | ||
[GeneratedComInterface(), Guid("0A52BA7C-E08B-42A4-A1F4-1A2BF2C07E60")] | ||
internal partial interface IStatelessCollectionPinnableReference | ||
{ | ||
void Method( | ||
[MarshalUsing(CountElementName = nameof(size))] StatelessCollectionPinnableReference<int> p, | ||
int size); | ||
|
||
void MethodIn( | ||
[MarshalUsing(CountElementName = nameof(size))] in StatelessCollectionPinnableReference<int> pIn, | ||
in int size); | ||
|
||
void MethodRef( | ||
[MarshalUsing(CountElementName = nameof(size))] ref StatelessCollectionPinnableReference<int> pRef, | ||
int size); | ||
|
||
void MethodOut( | ||
[MarshalUsing(CountElementName = nameof(size))] out StatelessCollectionPinnableReference<int> pOut, | ||
out int size); | ||
|
||
[return: MarshalUsing(CountElementName = nameof(size))] | ||
StatelessCollectionPinnableReference<int> Return(int size); | ||
} | ||
|
||
[NativeMarshalling(typeof(StatelessCollectionPinnableReferenceMarshaller<,>))] | ||
internal class StatelessCollectionPinnableReference<T> | ||
{ | ||
} | ||
|
||
internal struct StatelessCollectionPinnableReferenceNative | ||
{ | ||
public static unsafe explicit operator void*(StatelessCollectionPinnableReferenceNative _) => throw new NotImplementedException(); | ||
public static unsafe explicit operator StatelessCollectionPinnableReferenceNative(void* _) => throw new NotImplementedException(); | ||
} | ||
|
||
[ContiguousCollectionMarshaller] | ||
[CustomMarshaller(typeof(StatelessCollectionPinnableReference<>), MarshalMode.ManagedToUnmanagedRef, typeof(StatelessCollectionPinnableReferenceMarshaller<,>.Bidirectional))] | ||
[CustomMarshaller(typeof(StatelessCollectionPinnableReference<>), MarshalMode.UnmanagedToManagedRef, typeof(StatelessCollectionPinnableReferenceMarshaller<,>.Bidirectional))] | ||
[CustomMarshaller(typeof(StatelessCollectionPinnableReference<>), MarshalMode.ElementIn, typeof(StatelessCollectionPinnableReferenceMarshaller<,>.Bidirectional))] | ||
[CustomMarshaller(typeof(StatelessCollectionPinnableReference<>), MarshalMode.ElementOut, typeof(StatelessCollectionPinnableReferenceMarshaller<,>.Bidirectional))] | ||
[CustomMarshaller(typeof(StatelessCollectionPinnableReference<>), MarshalMode.ElementRef, typeof(StatelessCollectionPinnableReferenceMarshaller<,>.Bidirectional))] | ||
[CustomMarshaller(typeof(StatelessCollectionPinnableReference<>), MarshalMode.ManagedToUnmanagedOut, typeof(StatelessCollectionPinnableReferenceMarshaller<,>.UnmanagedToManaged))] | ||
[CustomMarshaller(typeof(StatelessCollectionPinnableReference<>), MarshalMode.UnmanagedToManagedIn, typeof(StatelessCollectionPinnableReferenceMarshaller<,>.UnmanagedToManaged))] | ||
[CustomMarshaller(typeof(StatelessCollectionPinnableReference<>), MarshalMode.ManagedToUnmanagedIn, typeof(StatelessCollectionPinnableReferenceMarshaller<,>.ManagedToUnmanaged))] | ||
[CustomMarshaller(typeof(StatelessCollectionPinnableReference<>), MarshalMode.UnmanagedToManagedOut, typeof(StatelessCollectionPinnableReferenceMarshaller<,>.ManagedToUnmanaged))] | ||
internal static class StatelessCollectionPinnableReferenceMarshaller<T, TUnmanaged> where TUnmanaged : unmanaged | ||
{ | ||
public static class Bidirectional | ||
{ | ||
public static ref StatelessCollectionPinnableReferenceNative GetPinnableReference(StatelessCollectionPinnableReference<T> managed) => throw new NotImplementedException(); | ||
public static StatelessCollectionPinnableReferenceNative AllocateContainerForUnmanagedElements(StatelessCollectionPinnableReference<T> managed, out int numElements) => throw new NotImplementedException(); | ||
public static StatelessCollectionPinnableReference<T> AllocateContainerForManagedElements(StatelessCollectionPinnableReferenceNative unmanaged, int numElements) => throw new NotImplementedException(); | ||
public static ReadOnlySpan<T> GetManagedValuesSource(StatelessCollectionPinnableReference<T> managed) => throw new NotImplementedException(); | ||
public static Span<TUnmanaged> GetUnmanagedValuesDestination(StatelessCollectionPinnableReferenceNative unmanaged, int numElements) => throw new NotImplementedException(); | ||
public static ReadOnlySpan<TUnmanaged> GetUnmanagedValuesSource(StatelessCollectionPinnableReferenceNative unmanaged, int numElements) => throw new NotImplementedException(); | ||
public static Span<T> GetManagedValuesDestination(StatelessCollectionPinnableReference<T> managed) => throw new NotImplementedException(); | ||
public static void Free(StatelessCollectionPinnableReferenceNative native) { } | ||
} | ||
|
||
public static class UnmanagedToManaged | ||
{ | ||
public static StatelessCollectionPinnableReference<T> AllocateContainerForManagedElements(StatelessCollectionPinnableReferenceNative unmanaged, int numElements) => throw new NotImplementedException(); | ||
public static ReadOnlySpan<TUnmanaged> GetUnmanagedValuesSource(StatelessCollectionPinnableReferenceNative unmanaged, int numElements) => throw new NotImplementedException(); | ||
public static Span<T> GetManagedValuesDestination(StatelessCollectionPinnableReference<T> managed) => throw new NotImplementedException(); | ||
public static void Free(StatelessCollectionPinnableReferenceNative native) { } | ||
} | ||
|
||
public static class ManagedToUnmanaged | ||
{ | ||
public static ref StatelessCollectionPinnableReferenceNative GetPinnableReference(StatelessCollectionPinnableReference<T> managed) => throw new NotImplementedException(); | ||
public static StatelessCollectionPinnableReferenceNative AllocateContainerForUnmanagedElements(StatelessCollectionPinnableReference<T> managed, out int numElements) => throw new NotImplementedException(); | ||
public static ReadOnlySpan<T> GetManagedValuesSource(StatelessCollectionPinnableReference<T> managed) => throw new NotImplementedException(); | ||
public static Span<TUnmanaged> GetUnmanagedValuesDestination(StatelessCollectionPinnableReferenceNative unmanaged, int numElements) => throw new NotImplementedException(); | ||
public static void Free(StatelessCollectionPinnableReferenceNative native) { } | ||
} | ||
} | ||
} |