@@ -593,7 +593,7 @@ struct S
593
593
public bool b;
594
594
}
595
595
596
- [CustomTypeMarshaller]
596
+ [CustomTypeMarshaller(typeof(S)) ]
597
597
struct Native
598
598
{
599
599
private int i;
@@ -612,6 +612,7 @@ struct S
612
612
public bool b;
613
613
}
614
614
615
+ [CustomTypeMarshaller(typeof(S))]
615
616
struct Native
616
617
{
617
618
private int i;
@@ -631,7 +632,7 @@ struct S
631
632
public bool b;
632
633
}
633
634
634
- [CustomTypeMarshaller]
635
+ [CustomTypeMarshaller(typeof(S), BufferSize = 1) ]
635
636
struct Native
636
637
{
637
638
private int i;
@@ -641,8 +642,6 @@ public Native(S s, System.Span<byte> b)
641
642
}
642
643
643
644
public S ToManaged() => new S { b = i != 0 };
644
-
645
- public const int BufferSize = 1;
646
645
}
647
646
" ;
648
647
public static string CustomStructMarshallingStackallocOnlyRefParameter = BasicParameterWithByRefModifier ( "ref" , "S" , DisableRuntimeMarshalling ) + @"
@@ -652,7 +651,7 @@ struct S
652
651
public bool b;
653
652
}
654
653
655
- [CustomTypeMarshaller]
654
+ [CustomTypeMarshaller(typeof(S), BufferSize = 1, RequiresStackBuffer = false) ]
656
655
struct Native
657
656
{
658
657
private int i;
@@ -662,9 +661,6 @@ public Native(S s, System.Span<byte> b)
662
661
}
663
662
664
663
public S ToManaged() => new S { b = i != 0 };
665
-
666
- public const int BufferSize = 1;
667
- public const bool RequiresStackBuffer = false;
668
664
}
669
665
" ;
670
666
public static string CustomStructMarshallingOptionalStackallocParametersAndModifiers = BasicParametersAndModifiers ( "S" , DisableRuntimeMarshalling ) + @"
@@ -674,7 +670,7 @@ struct S
674
670
public bool b;
675
671
}
676
672
677
- [CustomTypeMarshaller]
673
+ [CustomTypeMarshaller(typeof(S), BufferSize = 1, RequiresStackBuffer = true) ]
678
674
struct Native
679
675
{
680
676
private int i;
@@ -688,9 +684,6 @@ public Native(S s)
688
684
}
689
685
690
686
public S ToManaged() => new S { b = i != 0 };
691
-
692
- public const int BufferSize = 1;
693
- public const bool RequiresStackBuffer = true;
694
687
}
695
688
" ;
696
689
@@ -701,7 +694,7 @@ struct S
701
694
public bool b;
702
695
}
703
696
704
- [CustomTypeMarshaller]
697
+ [CustomTypeMarshaller(typeof(S), BufferSize = 1) ]
705
698
struct Native
706
699
{
707
700
public Native(S s, System.Span<byte> b)
@@ -712,8 +705,6 @@ public Native(S s, System.Span<byte> b)
712
705
public S ToManaged() => new S { b = Value != 0 };
713
706
714
707
public int Value { get; set; }
715
-
716
- public const int BufferSize = 1;
717
708
}
718
709
" ;
719
710
public static string CustomStructMarshallingValuePropertyParametersAndModifiers = BasicParametersAndModifiers ( "S" , DisableRuntimeMarshalling ) + @"
@@ -723,7 +714,7 @@ struct S
723
714
public bool b;
724
715
}
725
716
726
- [CustomTypeMarshaller]
717
+ [CustomTypeMarshaller(typeof(S)) ]
727
718
struct Native
728
719
{
729
720
public Native(S s)
@@ -745,7 +736,7 @@ class S
745
736
public ref int GetPinnableReference() => ref i;
746
737
}
747
738
748
- [CustomTypeMarshaller]
739
+ [CustomTypeMarshaller(typeof(S)) ]
749
740
unsafe struct Native
750
741
{
751
742
private int* ptr;
@@ -777,7 +768,7 @@ class S
777
768
public byte c;
778
769
}
779
770
780
- [CustomTypeMarshaller]
771
+ [CustomTypeMarshaller(typeof(S), BufferSize = 1) ]
781
772
unsafe ref struct Native
782
773
{
783
774
private byte* ptr;
@@ -815,8 +806,6 @@ public void FreeNative()
815
806
Marshal.FreeCoTaskMem((IntPtr)ptr);
816
807
}
817
808
}
818
-
819
- public const int BufferSize = 1;
820
809
}
821
810
822
811
partial class Test
@@ -835,7 +824,7 @@ class S
835
824
public byte c = 0;
836
825
}
837
826
838
- [CustomTypeMarshaller]
827
+ [CustomTypeMarshaller(typeof(S)) ]
839
828
unsafe struct Native
840
829
{
841
830
private S value;
@@ -886,7 +875,7 @@ struct S
886
875
public bool b;
887
876
}
888
877
889
- [CustomTypeMarshaller]
878
+ [CustomTypeMarshaller(typeof(S)) ]
890
879
struct Native
891
880
{
892
881
private int i;
@@ -905,7 +894,7 @@ struct S
905
894
public bool b;
906
895
}
907
896
908
- [CustomTypeMarshaller]
897
+ [CustomTypeMarshaller(typeof(S)) ]
909
898
struct Native
910
899
{
911
900
private int i;
@@ -938,7 +927,7 @@ public struct IntStructWrapper
938
927
public int Value;
939
928
}
940
929
941
- [CustomTypeMarshaller]
930
+ [CustomTypeMarshaller(typeof(IntStructWrapper)) ]
942
931
public struct IntStructWrapperNative
943
932
{
944
933
public IntStructWrapperNative(IntStructWrapper managed)
@@ -959,7 +948,7 @@ public struct IntStructWrapper
959
948
public int Value;
960
949
}
961
950
962
- [CustomTypeMarshaller]
951
+ [CustomTypeMarshaller(typeof(IntStructWrapper)) ]
963
952
public struct IntStructWrapperNative
964
953
{
965
954
private int value;
@@ -1085,7 +1074,7 @@ public static string CollectionByValue(string elementType) => BasicParameterByVa
1085
1074
[NativeMarshalling(typeof(Marshaller<>))]
1086
1075
class TestCollection<T> {}
1087
1076
1088
- [CustomTypeMarshaller(CustomTypeMarshallerKind.SpanCollection)]
1077
+ [CustomTypeMarshaller(typeof(TestCollection<>), CustomTypeMarshallerKind.SpanCollection)]
1089
1078
ref struct Marshaller<T>
1090
1079
{
1091
1080
public Marshaller(TestCollection<T> managed, int nativeElementSize) : this() {}
@@ -1119,7 +1108,7 @@ public static string CustomCollectionWithMarshaller(bool enableDefaultMarshallin
1119
1108
string nativeMarshallingAttribute = enableDefaultMarshalling ? "[NativeMarshalling(typeof(Marshaller<>))]" : string . Empty ;
1120
1109
return nativeMarshallingAttribute + @"class TestCollection<T> {}
1121
1110
1122
- [CustomTypeMarshaller(CustomTypeMarshallerKind.SpanCollection)]
1111
+ [CustomTypeMarshaller(typeof(TestCollection<>), CustomTypeMarshallerKind.SpanCollection)]
1123
1112
ref struct Marshaller<T>
1124
1113
{
1125
1114
public Marshaller(int nativeElementSize) : this() {}
@@ -1216,7 +1205,7 @@ public static partial void Method(
1216
1205
[NativeMarshalling(typeof(Marshaller<,>))]
1217
1206
class TestCollection<T> {}
1218
1207
1219
- [CustomTypeMarshaller(CustomTypeMarshallerKind.SpanCollection)]
1208
+ [CustomTypeMarshaller(typeof(TestCollection<>), CustomTypeMarshallerKind.SpanCollection)]
1220
1209
ref struct Marshaller<T, U>
1221
1210
{
1222
1211
public Marshaller(TestCollection<T> managed, int nativeElementSize) : this() {}
0 commit comments