@@ -25,7 +25,11 @@ public StructWithShortAndBool(short s, bool b)
25
25
26
26
public struct StructWithShortAndBoolWithMarshalAs
27
27
{
28
+ #if DISABLE_RUNTIME_MARSHALLING
28
29
[ MarshalAs ( UnmanagedType . VariantBool ) ]
30
+ #else
31
+ [ MarshalAs ( UnmanagedType . U1 ) ]
32
+ #endif
29
33
bool b ;
30
34
short s ;
31
35
int padding ;
@@ -41,6 +45,10 @@ public StructWithShortAndBoolWithMarshalAs(short s, bool b)
41
45
public struct StructWithWCharAndShort
42
46
{
43
47
short s ;
48
+ #if DISABLE_RUNTIME_MARSHALLING
49
+ #else
50
+ [ MarshalAs ( UnmanagedType . U2 ) ]
51
+ #endif
44
52
char c ;
45
53
46
54
public StructWithWCharAndShort ( short s , char c )
@@ -54,7 +62,11 @@ public StructWithWCharAndShort(short s, char c)
54
62
public struct StructWithWCharAndShortWithMarshalAs
55
63
{
56
64
short s ;
65
+ #if DISABLE_RUNTIME_MARSHALLING
57
66
[ MarshalAs ( UnmanagedType . U1 ) ]
67
+ #else
68
+ [ MarshalAs ( UnmanagedType . U2 ) ]
69
+ #endif
58
70
char c ;
59
71
60
72
public StructWithWCharAndShortWithMarshalAs ( short s , char c )
@@ -76,6 +88,7 @@ public StructWithShortAndGeneric(short s, T t)
76
88
}
77
89
}
78
90
91
+ #if DISABLE_RUNTIME_MARSHALLING
79
92
public struct StructWithString
80
93
{
81
94
string s ;
@@ -89,6 +102,7 @@ public StructWithString(string s)
89
102
[ StructLayout ( LayoutKind . Sequential ) ]
90
103
public class LayoutClass
91
104
{ }
105
+ #endif
92
106
93
107
[ StructLayout ( LayoutKind . Auto ) ]
94
108
public struct AutoLayoutStruct
@@ -106,52 +120,142 @@ public struct SequentialWithAutoLayoutNestedField
106
120
SequentialWithAutoLayoutField field ;
107
121
}
108
122
123
+ #if DISABLE_RUNTIME_MARSHALLING
109
124
public enum ByteEnum : byte
110
125
{
111
126
Value = 42
112
127
}
113
128
129
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "PassThrough" ) ]
130
+ public static extern byte GetEnumUnderlyingValue ( ByteEnum b ) ;
131
+ #endif
132
+
114
133
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
134
+ #if ! DISABLE_RUNTIME_MARSHALLING
135
+ [ return : MarshalAs ( UnmanagedType . U1 ) ]
136
+ #endif
115
137
public static extern bool CheckStructWithShortAndBool ( StructWithShortAndBool str , short s , bool b ) ;
138
+
116
139
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
117
- public static extern bool CheckStructWithShortAndBool ( StructWithShortAndBoolWithMarshalAs str , short s , [ MarshalAs ( UnmanagedType . I4 ) ] bool b ) ;
140
+ #if DISABLE_RUNTIME_MARSHALLING
141
+ public static extern bool CheckStructWithShortAndBool ( StructWithShortAndBoolWithMarshalAs str , short s , bool b ) ;
142
+ #else
143
+ [ return : MarshalAs ( UnmanagedType . U1 ) ]
144
+ public static extern bool CheckStructWithShortAndBool ( StructWithShortAndBoolWithMarshalAs str , short s , [ MarshalAs ( UnmanagedType . Bool ) ] bool b ) ;
145
+ #endif
146
+
118
147
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
148
+ #if ! DISABLE_RUNTIME_MARSHALLING
149
+ [ return : MarshalAs ( UnmanagedType . U1 ) ]
150
+ #endif
119
151
public static extern bool CheckStructWithWCharAndShort ( StructWithWCharAndShort str , short s , char c ) ;
152
+
120
153
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
154
+ #if ! DISABLE_RUNTIME_MARSHALLING
155
+ [ return : MarshalAs ( UnmanagedType . U1 ) ]
156
+ #endif
121
157
public static extern bool CheckStructWithWCharAndShort ( StructWithWCharAndShortWithMarshalAs str , short s , char c ) ;
158
+
122
159
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
160
+ #if ! DISABLE_RUNTIME_MARSHALLING
161
+ [ return : MarshalAs ( UnmanagedType . U1 ) ]
162
+ #endif
123
163
public static extern bool CheckStructWithWCharAndShort ( StructWithShortAndGeneric < char > str , short s , char c ) ;
124
164
125
165
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
166
+ #if ! DISABLE_RUNTIME_MARSHALLING
167
+ [ return : MarshalAs ( UnmanagedType . U1 ) ]
168
+ #endif
126
169
public static extern bool CheckStructWithWCharAndShort ( StructWithShortAndGeneric < short > str , short s , short c ) ;
127
170
171
+ #if DISABLE_RUNTIME_MARSHALLING
172
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
173
+ public static extern bool CallCheckStructWithShortAndBoolCallback ( delegate * unmanaged< StructWithShortAndBool , short , bool , bool > cb , StructWithShortAndBool str , short s , bool b ) ;
174
+ #endif
175
+
176
+ public static IntPtr GetStructWithShortAndBoolCallback ( )
177
+ {
178
+ #if DISABLE_RUNTIME_MARSHALLING
179
+ return GetStructWithShortAndBoolCallback ( false ) ;
180
+ #else
181
+ return GetStructWithShortAndBoolCallback ( true ) ;
182
+ #endif
183
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
184
+ static extern IntPtr GetStructWithShortAndBoolCallback ( [ MarshalAs ( UnmanagedType . U1 ) ] bool marshalSupported ) ;
185
+ }
186
+
187
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
188
+ public static extern IntPtr GetStructWithShortAndBoolWithVariantBoolCallback ( ) ;
189
+
190
+ #if DISABLE_RUNTIME_MARSHALLING
191
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "PassThrough" ) ]
192
+ public static extern bool GetByteAsBool ( byte b ) ;
193
+ #endif
194
+
195
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
196
+ public static extern void CallWithAutoLayoutStruct ( AutoLayoutStruct s ) ;
197
+
198
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
199
+ public static extern void CallWithAutoLayoutStruct ( SequentialWithAutoLayoutField s ) ;
200
+
201
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
202
+ public static extern void CallWithAutoLayoutStruct ( SequentialWithAutoLayoutNestedField s ) ;
203
+
204
+ #if DISABLE_RUNTIME_MARSHALLING
205
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
206
+ [ return : MarshalAs ( UnmanagedType . U1 ) ]
207
+ public static extern bool CheckStructWithShortAndBoolWithVariantBool ( StructWithShortAndBool str , short s , [ MarshalAs ( UnmanagedType . VariantBool ) ] bool b ) ;
208
+ #else
209
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
210
+ [ return : MarshalAs ( UnmanagedType . U1 ) ]
211
+ public static extern bool CheckStructWithShortAndBoolWithVariantBool ( StructWithShortAndBoolWithMarshalAs str , short s , [ MarshalAs ( UnmanagedType . VariantBool ) ] bool b ) ;
212
+ #endif
213
+
214
+ // Apply the UnmanagedFunctionPointer attributes with the default calling conventions so that Mono's AOT compiler
215
+ // recognizes that these delegate types are used in interop and should have managed->native thunks generated for them.
216
+ [ UnmanagedFunctionPointer ( CallingConvention . Winapi ) ]
217
+ public delegate bool CheckStructWithShortAndBoolCallback ( StructWithShortAndBool str , short s , bool b ) ;
218
+
219
+ #if DISABLE_RUNTIME_MARSHALLING
220
+ [ UnmanagedFunctionPointer ( CallingConvention . Winapi ) ]
221
+ public delegate bool CheckStructWithShortAndBoolWithVariantBoolCallback ( StructWithShortAndBool str , short s , [ MarshalAs ( UnmanagedType . VariantBool ) ] bool b ) ;
222
+ #else
223
+ [ UnmanagedFunctionPointer ( CallingConvention . Winapi ) ]
224
+ public delegate bool CheckStructWithShortAndBoolWithMarshalAsAndVariantBoolCallback ( StructWithShortAndBoolWithMarshalAs str , short s , [ MarshalAs ( UnmanagedType . VariantBool ) ] bool b ) ;
225
+ #endif
226
+
227
+ [ UnmanagedCallersOnly ]
228
+ public static bool CheckStructWithShortAndBoolManaged ( StructWithShortAndBool str , short s , bool b )
229
+ {
230
+ return str . s == s && str . b == b ;
231
+ }
232
+
233
+ #if DISABLE_RUNTIME_MARSHALLING
128
234
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" , CharSet = CharSet . Ansi ) ]
129
235
public static extern void CheckStringWithAnsiCharSet ( string s ) ;
236
+
130
237
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" , CharSet = CharSet . Unicode ) ]
131
238
public static extern void CheckStringWithUnicodeCharSet ( string s ) ;
239
+
132
240
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" , CharSet = CharSet . Unicode ) ]
133
241
public static extern string GetStringWithUnicodeCharSet ( ) ;
242
+
134
243
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
135
244
public static extern void CheckStructWithStructWithString ( StructWithString s ) ;
245
+
136
246
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
137
247
public static extern void CheckLayoutClass ( LayoutClass c ) ;
248
+
138
249
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" , SetLastError = true ) ]
139
250
public static extern void CallWithSetLastError ( ) ;
251
+
140
252
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
141
253
[ LCIDConversion ( 0 ) ]
142
254
public static extern void CallWithLCID ( ) ;
255
+
143
256
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" , PreserveSig = false ) ]
144
257
public static extern int CallWithHResultSwap ( ) ;
145
258
146
- [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
147
- public static extern void CallWithAutoLayoutStruct ( AutoLayoutStruct s ) ;
148
-
149
- [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
150
- public static extern void CallWithAutoLayoutStruct ( SequentialWithAutoLayoutField s ) ;
151
-
152
- [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
153
- public static extern void CallWithAutoLayoutStruct ( SequentialWithAutoLayoutNestedField s ) ;
154
-
155
259
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
156
260
public static extern void CallWithByRef ( ref int i ) ;
157
261
@@ -161,50 +265,28 @@ public enum ByteEnum : byte
161
265
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
162
266
public static extern void CallWithInt128 ( Int128 i ) ;
163
267
164
- [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
165
- public static extern delegate * unmanaged< StructWithShortAndBool , short , bool , bool > GetStructWithShortAndBoolCallback ( ) ;
166
-
167
- [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
168
- public static extern delegate * unmanaged< StructWithShortAndBool , short , bool , bool > GetStructWithShortAndBoolWithVariantBoolCallback ( ) ;
169
-
170
- [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) ) ]
171
- public static extern bool CallCheckStructWithShortAndBoolCallback ( delegate * unmanaged< StructWithShortAndBool , short , bool , bool > cb , StructWithShortAndBool str , short s , bool b ) ;
172
-
173
- [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "PassThrough" ) ]
174
- public static extern bool GetByteAsBool ( byte b ) ;
175
-
176
- [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "PassThrough" ) ]
177
- public static extern byte GetEnumUnderlyingValue ( ByteEnum b ) ;
178
-
179
- [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "CheckStructWithShortAndBoolWithVariantBool" ) ]
180
- [ return : MarshalAs ( UnmanagedType . U1 ) ]
181
- public static extern bool CheckStructWithShortAndBoolWithVariantBool_FailureExpected ( StructWithShortAndBool str , short s , [ MarshalAs ( UnmanagedType . VariantBool ) ] bool b ) ;
268
+ [ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
269
+ public static extern void CallWithUInt128 ( UInt128 i ) ;
182
270
183
271
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
184
272
public static extern void CallWith ( Nullable < int > s ) ;
273
+
185
274
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
186
275
public static extern void CallWith ( Span < int > s ) ;
276
+
187
277
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
188
278
public static extern void CallWith ( ReadOnlySpan < int > ros ) ;
279
+
189
280
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
190
281
public static extern void CallWith ( Vector64 < int > v ) ;
282
+
191
283
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
192
284
public static extern void CallWith ( Vector128 < int > v ) ;
285
+
193
286
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
194
287
public static extern void CallWith ( Vector256 < int > v ) ;
288
+
195
289
[ DllImport ( nameof ( DisabledRuntimeMarshallingNative ) , EntryPoint = "Invalid" ) ]
196
290
public static extern void CallWith ( Vector < int > v ) ;
197
-
198
- // Apply the UnmanagedFunctionPointer attributes with the default calling conventions so that Mono's AOT compiler
199
- // recognizes that these delegate types are used in interop and should have managed->native thunks generated for them.
200
- [ UnmanagedFunctionPointer ( CallingConvention . Winapi ) ]
201
- public delegate bool CheckStructWithShortAndBoolCallback ( StructWithShortAndBool str , short s , bool b ) ;
202
- [ UnmanagedFunctionPointer ( CallingConvention . Winapi ) ]
203
- public delegate bool CheckStructWithShortAndBoolWithVariantBoolCallback ( StructWithShortAndBool str , short s , [ MarshalAs ( UnmanagedType . VariantBool ) ] bool b ) ;
204
-
205
- [ UnmanagedCallersOnly ]
206
- public static bool CheckStructWithShortAndBoolManaged ( StructWithShortAndBool str , short s , bool b )
207
- {
208
- return str . s == s && str . b == b ;
209
- }
291
+ #endif
210
292
}
0 commit comments