Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cominterop.cs « tests « mono - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 33c8e54be9ba4efaf37b18e42161054eb78f5ae3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
//
// cominterop.cs:
//
//  Tests for COM Interop related features
//

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;


public class Tests
{

	[DllImport("libtest")]
	public static extern int mono_test_marshal_bstr_in([MarshalAs(UnmanagedType.BStr)]string str);

	[DllImport("libtest")]
    public static extern int mono_test_marshal_bstr_out([MarshalAs(UnmanagedType.BStr)] out string str);

    [DllImport("libtest")]
    public static extern int mono_test_marshal_bstr_in_null([MarshalAs(UnmanagedType.BStr)]string str);

    [DllImport("libtest")]
    public static extern int mono_test_marshal_bstr_out_null([MarshalAs(UnmanagedType.BStr)] out string str);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_sbyte([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_byte([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_short([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_ushort([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_int([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_uint([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_long([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_ulong([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_float([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_double([MarshalAs(UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_in_bstr ([MarshalAs (UnmanagedType.Struct)]object obj);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_bool_true ([MarshalAs (UnmanagedType.Struct)]object obj);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_bool_false ([MarshalAs (UnmanagedType.Struct)]object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_sbyte([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_sbyte_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_byte([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_byte_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_short([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_short_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_ushort([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_ushort_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_int([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_int_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_uint([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_uint_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_long([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_long_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_ulong([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_ulong_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_float([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_float_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_double([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_double_byref([MarshalAs(UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_bstr ([MarshalAs (UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_bstr_byref ([MarshalAs (UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_bool_true ([MarshalAs (UnmanagedType.Struct)]out object obj);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_variant_out_bool_true_byref ([MarshalAs (UnmanagedType.Struct)]out object obj);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_bool_false ([MarshalAs (UnmanagedType.Struct)]out object obj);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_bool_false_byref ([MarshalAs (UnmanagedType.Struct)]out object obj);


	public delegate int VarFunc (VarEnum vt, [MarshalAs (UnmanagedType.Struct)] object obj);

	public delegate int VarRefFunc (VarEnum vt, [MarshalAs (UnmanagedType.Struct)] ref object obj);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_sbyte_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_byte_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_short_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_ushort_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_int_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_uint_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_long_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_ulong_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_float_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_double_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_bstr_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_bool_true_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_in_bool_false_unmanaged (VarFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_sbyte_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_byte_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_short_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_ushort_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_int_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_uint_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_long_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_ulong_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_float_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_double_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_bstr_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_bool_true_unmanaged (VarRefFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_variant_out_bool_false_unmanaged (VarRefFunc func);

	public delegate int CheckStructWithVariantFunc ([MarshalAs (UnmanagedType.Struct)] StructWithVariant obj);
	[DllImport ("libtest")]
	public static extern int mono_test_marshal_struct_with_variant_in_unmanaged (CheckStructWithVariantFunc func);

	public delegate int CheckStructWithBstrFunc ([MarshalAs (UnmanagedType.Struct)] StructWithBstr obj);
	[DllImport ("libtest")]
	public static extern int mono_test_marshal_struct_with_bstr_in_unmanaged (CheckStructWithBstrFunc func);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_struct_with_variant_out_unmanaged ([MarshalAs (UnmanagedType.Struct)] StructWithVariant obj);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_struct_with_bstr_out_unmanaged ([MarshalAs (UnmanagedType.Struct)] StructWithBstr obj);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_com_object_create (out IntPtr pUnk);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_com_object_same (out IntPtr pUnk);

    [DllImport ("libtest")]
    public static extern int mono_test_marshal_com_object_destroy (IntPtr pUnk);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_com_object_ref_count (IntPtr pUnk);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_ccw_identity ([MarshalAs (UnmanagedType.Interface)]ITest itest);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_ccw_reflexive ([MarshalAs (UnmanagedType.Interface)]ITest itest);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_ccw_transitive ([MarshalAs (UnmanagedType.Interface)]ITest itest);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_ccw_itest ([MarshalAs (UnmanagedType.Interface)]ITest itest);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_ccw_itest ([MarshalAs (UnmanagedType.Interface)]ITestPresSig itest);

	[DllImport ("libtest", EntryPoint="mono_test_marshal_ccw_itest")]
	public static extern int mono_test_marshal_ccw_itest_nomarshal (ITest itest);

	[DllImport ("libtest", EntryPoint="mono_test_marshal_ccw_itest")]
	public static extern int mono_test_marshal_ccw_itest_nomarshal (ITestPresSig itest);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_array_ccw_itest (int count, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex=0)] ITest[] ppUnk);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_retval_ccw_itest ([MarshalAs (UnmanagedType.Interface)]ITest itest, bool test_null);

	[DllImport ("libtest")]
	public static extern int mono_test_marshal_retval_ccw_itest ([MarshalAs (UnmanagedType.Interface)]ITestPresSig itest, bool test_null);

	[DllImport("libtest")]
	public static extern int mono_test_cominterop_ccw_queryinterface ([MarshalAs (UnmanagedType.Interface)] IOtherTest itest);

	[DllImport("libtest")]
	public static extern int mono_test_cominterop_ccw_queryinterface_foreign_thread ([MarshalAs (UnmanagedType.Interface)] ITest itest);

	[DllImport ("libtest")]
	public static extern int mono_test_cominterop_ccw_itest_foreign_thread ([MarshalAs (UnmanagedType.Interface)] ITest itest);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_out_1dim_vt_bstr_empty ([MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)]out Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_out_1dim_vt_bstr ([MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)]out Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_out_2dim_vt_i4 ([MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)]out Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_out_4dim_vt_i4 ([MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)]out Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_byval_1dim_empty ([In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_byval_1dim_vt_i4 ([In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_byval_1dim_vt_mixed ([In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_byval_2dim_vt_i4 ([In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_byval_3dim_vt_bstr ([In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_byref_3dim_vt_bstr ([In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] ref Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_out_byref_1dim_empty ([In, Out, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] ref Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr ([In, Out, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] ref Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 ([In, Out, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] ref Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 ([In, Out, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr ([In, Out, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array array);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_mixed (
		[In, Out, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array array1,
		[MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] out Array array2,
		[In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] Array array3,
		[In, Out, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] ref Array array4);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_safearray_in_ccw([MarshalAs (UnmanagedType.Interface)] ITest itest);

	[DllImport("libtest")]
	public static extern int mono_test_marshal_lparray_out_ccw([MarshalAs (UnmanagedType.Interface)] ITest itest);

	[DllImport("libtest")]
	public static extern int mono_test_default_interface_ccw([MarshalAs (UnmanagedType.Interface)] ITest itest);

	[DllImport("libtest")]
	public static extern bool mono_cominterop_is_supported ();

	public static int Main ()
	{
		bool isWindows = !(((int)Environment.OSVersion.Platform == 4) ||
			((int)Environment.OSVersion.Platform == 128));

		if (mono_cominterop_is_supported () || isWindows)
		{
			#region BSTR Tests

			string str;
			if (mono_test_marshal_bstr_in ("mono_test_marshal_bstr_in") != 0)
				return 1;
			if (mono_test_marshal_bstr_out (out str) != 0 || str != "mono_test_marshal_bstr_out")
				return 2;
			if (mono_test_marshal_bstr_in_null (null) != 0)
				return 1;
			if (mono_test_marshal_bstr_out_null (out str) != 0 || str != null)
				return 2;

			var sbfunc = new CheckStructWithBstrFunc(mono_test_marshal_struct_with_bstr_callback);
			if (mono_test_marshal_struct_with_bstr_in_unmanaged(sbfunc) != 0)
				return 3;

			StructWithBstr swithB;
			swithB.data = "this is a test string";
			if (mono_test_marshal_struct_with_bstr_out_unmanaged (swithB) != 0)
				return 4;

			#endregion // BSTR Tests

			#region VARIANT Tests

			object obj;
			if (mono_test_marshal_variant_in_sbyte ((sbyte)100) != 0)
				return 13;
			if (mono_test_marshal_variant_in_byte ((byte)100) != 0)
				return 14;
			if (mono_test_marshal_variant_in_short ((short)314) != 0)
				return 15;
			if (mono_test_marshal_variant_in_ushort ((ushort)314) != 0)
				return 16;
			if (mono_test_marshal_variant_in_int ((int)314) != 0)
				return 17;
			if (mono_test_marshal_variant_in_uint ((uint)314) != 0)
				return 18;
			if (mono_test_marshal_variant_in_long ((long)314) != 0)
				return 19;
			if (mono_test_marshal_variant_in_ulong ((ulong)314) != 0)
				return 20;
			if (mono_test_marshal_variant_in_float ((float)3.14) != 0)
				return 21;
			if (mono_test_marshal_variant_in_double ((double)3.14) != 0)
				return 22;
			if (mono_test_marshal_variant_in_bstr ("PI") != 0)
				return 23;
			if (mono_test_marshal_variant_out_sbyte (out obj) != 0 || (sbyte)obj != 100)
				return 24;
			if (mono_test_marshal_variant_out_byte (out obj) != 0 || (byte)obj != 100)
				return 25;
			if (mono_test_marshal_variant_out_short (out obj) != 0 || (short)obj != 314)
				return 26;
			if (mono_test_marshal_variant_out_ushort (out obj) != 0 || (ushort)obj != 314)
				return 27;
			if (mono_test_marshal_variant_out_int (out obj) != 0 || (int)obj != 314)
				return 28;
			if (mono_test_marshal_variant_out_uint (out obj) != 0 || (uint)obj != 314)
				return 29;
			if (mono_test_marshal_variant_out_long (out obj) != 0 || (long)obj != 314)
				return 30;
			if (mono_test_marshal_variant_out_ulong (out obj) != 0 || (ulong)obj != 314)
				return 31;
			if (mono_test_marshal_variant_out_float (out obj) != 0 || ((float)obj - 3.14) / 3.14 > .001)
				return 32;
			if (mono_test_marshal_variant_out_double (out obj) != 0 || ((double)obj - 3.14) / 3.14 > .001)
				return 33;
			if (mono_test_marshal_variant_out_bstr (out obj) != 0 || (string)obj != "PI")
				return 34;

			VarFunc func = new VarFunc (mono_test_marshal_variant_in_callback);
			if (mono_test_marshal_variant_in_sbyte_unmanaged (func) != 0)
				return 35;
			if (mono_test_marshal_variant_in_byte_unmanaged (func) != 0)
				return 36;
			if (mono_test_marshal_variant_in_short_unmanaged (func) != 0)
				return 37;
			if (mono_test_marshal_variant_in_ushort_unmanaged (func) != 0)
				return 38;
			if (mono_test_marshal_variant_in_int_unmanaged (func) != 0)
				return 39;
			if (mono_test_marshal_variant_in_uint_unmanaged (func) != 0)
				return 40;
			if (mono_test_marshal_variant_in_long_unmanaged (func) != 0)
				return 41;
			if (mono_test_marshal_variant_in_ulong_unmanaged (func) != 0)
				return 42;
			if (mono_test_marshal_variant_in_float_unmanaged (func) != 0)
				return 43;
			if (mono_test_marshal_variant_in_double_unmanaged (func) != 0)
				return 44;
			if (mono_test_marshal_variant_in_bstr_unmanaged (func) != 0)
				return 45;
			if (mono_test_marshal_variant_in_bool_true_unmanaged (func) != 0)
				return 46;

			VarRefFunc reffunc = new VarRefFunc (mono_test_marshal_variant_out_callback);
			if (mono_test_marshal_variant_out_sbyte_unmanaged (reffunc) != 0)
				return 50;
			if (mono_test_marshal_variant_out_byte_unmanaged (reffunc) != 0)
				return 51;
			if (mono_test_marshal_variant_out_short_unmanaged (reffunc) != 0)
				return 52;
			if (mono_test_marshal_variant_out_ushort_unmanaged (reffunc) != 0)
				return 53;
			if (mono_test_marshal_variant_out_int_unmanaged (reffunc) != 0)
				return 54;
			if (mono_test_marshal_variant_out_uint_unmanaged (reffunc) != 0)
				return 55;
			if (mono_test_marshal_variant_out_long_unmanaged (reffunc) != 0)
				return 56;
			if (mono_test_marshal_variant_out_ulong_unmanaged (reffunc) != 0)
				return 57;
			if (mono_test_marshal_variant_out_float_unmanaged (reffunc) != 0)
				return 58;
			if (mono_test_marshal_variant_out_double_unmanaged (reffunc) != 0)
				return 59;
			if (mono_test_marshal_variant_out_bstr_unmanaged (reffunc) != 0)
				return 60;
			if (mono_test_marshal_variant_out_bool_true_unmanaged (reffunc) != 0)
				return 61;

			if (mono_test_marshal_variant_out_sbyte_byref (out obj) != 0 || (sbyte)obj != 100)
				return 97;
			if (mono_test_marshal_variant_out_byte_byref (out obj) != 0 || (byte)obj != 100)
				return 98;
			if (mono_test_marshal_variant_out_short_byref (out obj) != 0 || (short)obj != 314)
				return 99;
			if (mono_test_marshal_variant_out_ushort_byref (out obj) != 0 || (ushort)obj != 314)
				return 100;
			if (mono_test_marshal_variant_out_int_byref (out obj) != 0 || (int)obj != 314)
				return 101;
			if (mono_test_marshal_variant_out_uint_byref (out obj) != 0 || (uint)obj != 314)
				return 102;
			if (mono_test_marshal_variant_out_long_byref (out obj) != 0 || (long)obj != 314)
				return 103;
			if (mono_test_marshal_variant_out_ulong_byref (out obj) != 0 || (ulong)obj != 314)
				return 104;
			if (mono_test_marshal_variant_out_float_byref (out obj) != 0 || ((float)obj - 3.14) / 3.14 > .001)
				return 105;
			if (mono_test_marshal_variant_out_double_byref (out obj) != 0 || ((double)obj - 3.14) / 3.14 > .001)
				return 106;
			if (mono_test_marshal_variant_out_bstr_byref (out obj) != 0 || (string)obj != "PI")
				return 107;

			var svfunc = new CheckStructWithVariantFunc(mono_test_marshal_struct_with_variant_callback);
			if (mono_test_marshal_struct_with_variant_in_unmanaged(svfunc) != 0)
				return 108;

			StructWithVariant swithV;
			swithV.data = (object)-123;
			if (mono_test_marshal_struct_with_variant_out_unmanaged (swithV) != 0)
				return 109;

			#endregion // VARIANT Tests

			#region Runtime Callable Wrapper Tests

#if !MOBILE

			IntPtr pUnk;
			if (mono_test_marshal_com_object_create (out pUnk) != 0)
				return 145;

			if (mono_test_marshal_com_object_ref_count (pUnk) != 1)
				return 146;

			if (Marshal.AddRef (pUnk) != 2)
				return 147;

			if (mono_test_marshal_com_object_ref_count (pUnk) != 2)
				return 148;

			if (Marshal.Release (pUnk) != 1)
				return 149;

			if (mono_test_marshal_com_object_ref_count (pUnk) != 1)
				return 150;

			object com_obj = Marshal.GetObjectForIUnknown (pUnk);

			if (com_obj == null)
				return 151;

			ITest itest = com_obj as ITest;

			if (itest == null)
				return 152;

			IntPtr pUnk2;
			if (mono_test_marshal_com_object_same (out pUnk2) != 0)
				return 153;

			object com_obj2 = Marshal.GetObjectForIUnknown (pUnk2);
			
			if (com_obj != com_obj2)
				return 154;

			if (!com_obj.Equals (com_obj2))
				return 155;

			IntPtr pUnk3;
			if (mono_test_marshal_com_object_create (out pUnk3) != 0)
				return 156;

			object com_obj3 = Marshal.GetObjectForIUnknown (pUnk3);
			if (com_obj == com_obj3)
				return 157;

			if (com_obj.Equals (com_obj3))
				return 158;

			// com_obj & com_obj2 share a RCW
			if (Marshal.ReleaseComObject (com_obj2) != 1)
				return 159;

			// com_obj3 should only have one RCW
			if (Marshal.ReleaseComObject (com_obj3) != 0)
				return 160;

			IntPtr iunknown = Marshal.GetIUnknownForObject (com_obj);
			if (iunknown == IntPtr.Zero)
				return 170;

			if (pUnk != iunknown)
				return 171;

			if (TestITest (itest) != 0)
				return 172;

			if (TestITestPresSig (itest as ITestPresSig) != 0)
				return 173;

			if (TestITestDelegate (itest) != 0)
				return 174;

			if (TestIfaceNoIcall (itest as ITestPresSig) != 0)
				return 175;

			itest = new TestClass ();

			if (TestITest (itest) != 0)
				return 176;

			itest = (ITest)System.Activator.CreateInstance (typeof(TestActivatorClass));

			if (TestITest (itest) != 0)
				return 177;

#endif

			#endregion // Runtime Callable Wrapper Tests

			#region COM Callable Wrapper Tests

			ManagedTest test = new ManagedTest ();

			mono_test_marshal_ccw_itest (test);
			mono_test_marshal_ccw_itest_nomarshal (test);

			if (test.Status != 0)
				return 200;

			ManagedTestPresSig test_pres_sig = new ManagedTestPresSig ();

			mono_test_marshal_ccw_itest (test_pres_sig);
			mono_test_marshal_ccw_itest_nomarshal (test_pres_sig);

			// test for Xamarin-47560
			var tests = new[] { test.Test };
			if (mono_test_marshal_array_ccw_itest (1, tests) != 0)
				return 201;

			var otherTest = new OtherTest ();
			if (mono_test_cominterop_ccw_queryinterface (otherTest) != 0)
				return 202;


			if (mono_test_marshal_retval_ccw_itest(test, true) != 0)
				return 203;

			/* Passing NULL to an out parameter will crash. */
			if (mono_test_marshal_retval_ccw_itest(test_pres_sig, false) != 0)
				return 204;

			if (mono_test_default_interface_ccw(test) != 0)
				return 205;

			if (mono_test_cominterop_ccw_queryinterface_foreign_thread (test) != 0)
				return 206;

			{
				ManagedTest mt = new ManagedTest ();
				if (mono_test_cominterop_ccw_itest_foreign_thread (test) != 0)
					return 207;
				if (mt.Status != 0) {
					Console.Error.WriteLine ("after mono_test_cominterop_ccw_itest_foreign_thread Status = {0}", mt.Status);
					return 208;
				}
			}

			#endregion // COM Callable Wrapper Tests

			#region SAFEARRAY tests

			if (isWindows) {

				/* out */
				Array array;
				if ((mono_test_marshal_safearray_out_1dim_vt_bstr_empty (out array) != 0) || (array.Rank != 1) || (array.Length != 0))
					return 62;

				if ((mono_test_marshal_safearray_out_1dim_vt_bstr (out array) != 0) || (array.Rank != 1) || (array.Length != 10))
					return 63;
				for (int i = 0; i < 10; ++i) {
					if (i != Convert.ToInt32 (array.GetValue (i)))
						return 64;
				}

				if ((mono_test_marshal_safearray_out_2dim_vt_i4 (out array) != 0) || (array.Rank != 2))
					return 65;
				if (   (array.GetLowerBound (0) != 0) || (array.GetUpperBound (0) != 3)
					|| (array.GetLowerBound (1) != 0) || (array.GetUpperBound (1) != 2))
					return 66;
				for (int i = array.GetLowerBound (0); i <= array.GetUpperBound (0); ++i)
				{
					for (int j = array.GetLowerBound (1); j <= array.GetUpperBound (1); ++j) {
						if ((i + 1) * 10 + (j + 1) != (int)array.GetValue (new long[] { i, j }))
							return 67;
					}
				}

				if ((mono_test_marshal_safearray_out_4dim_vt_i4 (out array) != 0) || (array.Rank != 4))
					return 68;
				if (   (array.GetLowerBound (0) != 15) || (array.GetUpperBound (0) != 24)
					|| (array.GetLowerBound (1) != 20) || (array.GetUpperBound (1) != 22)
					|| (array.GetLowerBound (2) !=  5) || (array.GetUpperBound (2) != 10)
					|| (array.GetLowerBound (3) != 12) || (array.GetUpperBound (3) != 18) )
					return 69;

				int index = 0;
				for (int i = array.GetLowerBound (3); i <= array.GetUpperBound (3); ++i) {
					for (int j = array.GetLowerBound (2); j <= array.GetUpperBound (2); ++j) {
						for (int k = array.GetLowerBound (1); k <= array.GetUpperBound (1); ++k) {
							for (int l = array.GetLowerBound (0); l <= array.GetUpperBound (0); ++l) {
								if (index != (int)array.GetValue (new long[] { l, k, j, i }))
									return 70;
								++index;
							}
						}
					}
				}

				/* in */

				array = new object[] { };
				if (mono_test_marshal_safearray_in_byval_1dim_empty (array) != 0)
					return 71;

				array = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
				if (mono_test_marshal_safearray_in_byval_1dim_vt_i4 (array) != 0)
					return 72;

				array = new object[] { 0, "1", 2, "3", 4, "5", 6, "7", 8, "9", 10, "11", 12 };
				if (mono_test_marshal_safearray_in_byval_1dim_vt_mixed (array) != 0)
					return 73;
				if ((int)array.GetValue (0) != 0)
					return 74;

				array = new object[,] { { 11, 12, 13, 14 }, { 21, 22, 23, 24 } };
				if (mono_test_marshal_safearray_in_byval_2dim_vt_i4 (array) != 0)
					return 75;
				if ((int)array.GetValue (new int[] { 0, 0 }) != 11)
					return 76;

				array = new object[,,] { { { "111", "112", "113" }, { "121", "122", "123" } }, { { "211", "212", "213" }, { "221", "222", "223" } } };
				if (mono_test_marshal_safearray_in_byval_3dim_vt_bstr (array) != 0)
					return 77;
				if ((string)array.GetValue (new int[] { 0, 0, 0 }) != "111")
					return 78;

				array = new object[,,] { { { "111", "112", "113" }, { "121", "122", "123" } }, { { "211", "212", "213" }, { "221", "222", "223" } } };
				if ((mono_test_marshal_safearray_in_byref_3dim_vt_bstr (ref array) != 0) || (array.Rank != 3) || (array.Length != 12))
					return 79;
				if ((string)array.GetValue (new int[] { 0, 0, 0 }) != "111")
					return 80;

				/* in, out, byref */

				array = new object[] { };
				if ((mono_test_marshal_safearray_in_out_byref_1dim_empty (ref array) != 0) || (array.Rank != 1) || (array.Length != 8))
					return 81;
				for (int i = 0; i < 8; ++i)
				{
					if (i != Convert.ToInt32 (array.GetValue (i)))
						return 82;
				}

				array = new object[,,] { { { "111", "112", "113" }, { "121", "122", "123" } }, { { "211", "212", "213" }, { "221", "222", "223" } } };
				if ((mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (ref array) != 0) || (array.Rank != 1) || (array.Length != 8))
					return 83;
				for (int i = 0; i < 8; ++i)
				{
					if (i != Convert.ToInt32 (array.GetValue (i)))
						return 84;
				}

				array = new object[] { 1 };
				if ((mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (ref array) != 0) || (array.Rank != 1) || (array.Length != 1))
				{
				    return 85;
				}
				if (Convert.ToInt32 (array.GetValue (0)) != -1)
				    return 86;

				/* in, out, byval */

				array = new object[] { 1 };
				if ((mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (array) != 0) || (array.Rank != 1) || (array.Length != 1))
				{
					return 87;
				}
				if (Convert.ToInt32 (array.GetValue (0)) != 12345)
					return 88;

				array = new object[,,] { { { "111", "112", "113" }, { "121", "122", "123" } }, { { "211", "212", "213" }, { "221", "222", "223" } } };
				if ((mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (array) != 0) || (array.Rank != 3) || (array.Length != 12))
				{
				    return 89;
				}
				if (Convert.ToInt32 (array.GetValue (new int[] { 1, 1, 1 })) != 111)
					return 90;
				if (Convert.ToInt32 (array.GetValue (new int[] { 1, 1, 2 })) != 333)
					return 91;
				if (Convert.ToString(array.GetValue (new int[] { 0, 1, 0 })) != "ABCDEFG")
					return 92;

				/* Multiple safearray parameters with various types and options */

				Array array1 = new object[] { 1 };
				Array array2 = new object[,] { { 11, 12, 13, 14 }, { 21, 22, 23, 24 } };
				Array array3 = new object[] { 0, "1", 2, "3", 4, "5", 6, "7", 8, "9", 10, "11", 12 };
				Array array4 = new object[,,] { { { "111", "112", "113" }, { "121", "122", "123" } }, { { "211", "212", "213" }, { "221", "222", "223" } } };
				if (    (mono_test_marshal_safearray_mixed (array1, out array2, array3, ref array4) != 0)
					 || (array1.Rank != 1) || (array1.Length != 1) || (Convert.ToInt32 (array1.GetValue (0)) != 12345)
					 || (array2.Rank != 1) || (array2.Length != 10)
					 || (array4.Rank != 1) || (array4.Length != 8)
					)
				{
					return 93;
				}
				for (int i = 0; i < 10; ++i)
				{
					if (i != Convert.ToInt32 (array2.GetValue (i)))
						return 94;
				}
				if ((int)array3.GetValue (0) != 0)
					return 95;
				for (int i = 0; i < 8; ++i)
				{
					if (i != Convert.ToInt32 (array4.GetValue (i)))
						return 96;
				}
				if (mono_test_marshal_safearray_in_ccw(test) != 0)
					return 97;
				if (mono_test_marshal_lparray_out_ccw(test) != 0)
					return 98;
			}
			#endregion // SafeArray Tests

			#region COM Visible Test
			TestVisible test_vis = new TestVisible();
			IntPtr pDisp = Marshal.GetIDispatchForObject(test_vis);
			if (pDisp == IntPtr.Zero)
				return 300;
			#endregion 
		}

        return 0;
	}

	[ComImport ()]
	[Guid ("10000000-0000-0000-0000-000000000002")]
	[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
	public interface IDefTest1
	{
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		int Method1();
	}

	[ComImport ()]
	[Guid ("10000000-0000-0000-0000-000000000003")]
	[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
	public interface IDefTest2
	{
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		int Method2();
	}

	public class TestDefaultInterfaceClass : IDefTest1, IDefTest2
	{
		public int Method3()
		{
			return 3;
		}

		public int Method1()
		{
			return 1;
		}

		public int Method4()
		{
			return 4;
		}

		public int Method2()
		{
			return 2;
		}
	}

	[ComDefaultInterfaceAttribute (typeof (IDefTest1))]
	public class TestDefaultInterfaceClass1 : TestDefaultInterfaceClass
	{
	}

	[ComDefaultInterfaceAttribute (typeof (IDefTest2))]
	public class TestDefaultInterfaceClass2 : TestDefaultInterfaceClass
	{
	}

	[ComImport ()]
	[Guid ("00000000-0000-0000-0000-000000000001")]
	[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
	public interface ITest
	{
		// properties need to go first since mcs puts them there
		ITest Test
		{
			[return: MarshalAs (UnmanagedType.Interface)]
			[MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId (5242884)]
			get;
		}

		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void SByteIn (sbyte val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void ByteIn (byte val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void ShortIn (short val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void UShortIn (ushort val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void IntIn (int val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void UIntIn (uint val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void LongIn (long val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void ULongIn (ulong val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void FloatIn (float val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void DoubleIn (double val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void ITestIn ([MarshalAs (UnmanagedType.Interface)]ITest val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITest val);
		int Return22NoICall();
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		int IntOut();
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void ArrayIn ([In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] object[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void ArrayIn2 ([In] object[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		void ArrayIn3 (object[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		int ArrayOut ([Out, MarshalAs (UnmanagedType.LPArray, SizeConst=1)] int[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[return: MarshalAs (UnmanagedType.Interface)]
		TestDefaultInterfaceClass1 GetDefInterface1();
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[return: MarshalAs (UnmanagedType.Interface)]
		TestDefaultInterfaceClass2 GetDefInterface2();
	}

	[ComImport ()]
	[Guid ("00000000-0000-0000-0000-000000000001")]
	[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
	public interface ITestPresSig
	{
		// properties need to go first since mcs puts them there
		ITestPresSig Test
		{
			[return: MarshalAs (UnmanagedType.Interface)]
			[MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId (5242884)]
			get;
		}

		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int SByteIn (sbyte val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int ByteIn (byte val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int ShortIn (short val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int UShortIn (ushort val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int IntIn (int val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int UIntIn (uint val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int LongIn (long val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int ULongIn (ulong val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int FloatIn (float val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int DoubleIn (double val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int ITestIn ([MarshalAs (UnmanagedType.Interface)]ITestPresSig val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITestPresSig val);
		[PreserveSig ()]
		int Return22NoICall();
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig ()]
		int IntOut (out int val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		int ArrayIn ([In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] object[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		int ArrayIn2 ([In] object[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		int ArrayIn3 (object[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		[PreserveSig]
		int ArrayOut ([Out, MarshalAs (UnmanagedType.LPArray, SizeConst=1)] int[] array, out int result);
	}

	[System.Runtime.InteropServices.GuidAttribute ("00000000-0000-0000-0000-000000000002")]
	[System.Runtime.InteropServices.ComImportAttribute ()]
	[System.Runtime.InteropServices.ClassInterfaceAttribute (ClassInterfaceType.None)]
	public class _TestClass : ITest
	{
		// properties need to go first since mcs puts them there
		public virtual extern ITest Test
		{
			[return: MarshalAs (UnmanagedType.Interface)]
			[MethodImpl (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId (5242884)]
			get;
		}

		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void SByteIn (sbyte val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void ByteIn (byte val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void ShortIn (short val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void UShortIn (ushort val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void IntIn (int val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void UIntIn (uint val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void LongIn (long val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void ULongIn (ulong val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void FloatIn (float val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void DoubleIn (double val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void ITestIn ([MarshalAs (UnmanagedType.Interface)]ITest val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITest val);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern int Return22NoICall();
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern int IntOut();
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void ArrayIn ([In, MarshalAs (UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] object[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void ArrayIn2 ([In] object[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern void ArrayIn3 (object[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern int ArrayOut ([Out, MarshalAs (UnmanagedType.LPArray, SizeConst=1)] int[] array);
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern TestDefaultInterfaceClass1 GetDefInterface1();
		[MethodImplAttribute (MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
		public virtual extern TestDefaultInterfaceClass2 GetDefInterface2();
	}

	[System.Runtime.InteropServices.GuidAttribute ("00000000-0000-0000-0000-000000000002")]
	public class TestClass : _TestClass
	{
		static TestClass ()
		{
			ExtensibleClassFactory.RegisterObjectCreationCallback (new ObjectCreationDelegate (CreateObject)); ;
		}
		private static System.IntPtr CreateObject (System.IntPtr aggr)
		{
			IntPtr pUnk3;
			mono_test_marshal_com_object_create (out pUnk3);
			return pUnk3;
		}
	}

	[System.Runtime.InteropServices.GuidAttribute ("00000000-0000-0000-0000-000000000003")]
	public class TestActivatorClass : _TestClass
	{
		static TestActivatorClass ()
		{
			ExtensibleClassFactory.RegisterObjectCreationCallback (new ObjectCreationDelegate (CreateObject)); ;
		}
		private static System.IntPtr CreateObject (System.IntPtr aggr)
		{
			IntPtr pUnk3;
			mono_test_marshal_com_object_create (out pUnk3);
			return pUnk3;
		}
	}

	delegate void SByteInDelegate (sbyte val);
	delegate void ByteInDelegate (byte val);
	delegate void ShortInDelegate (short val);
	delegate void UShortInDelegate (ushort val);
	delegate void IntInDelegate (int val);
	delegate void UIntInDelegate (uint val);
	delegate void LongInDelegate (long val);
	delegate void ULongInDelegate (ulong val);
	delegate void FloatInDelegate (float val);
	delegate void DoubleInDelegate (double val);
	delegate void ITestInDelegate (ITest val);
	delegate void ITestOutDelegate (out ITest val);

	public class ManagedTestPresSig : ITestPresSig
	{		// properties need to go first since mcs puts them there
		public ITestPresSig Test
		{
			get
			{
				return new ManagedTestPresSig ();
			}
		}

		public int SByteIn (sbyte val)
		{
			if (val != -100)
				return 1;
			return 0;
		}

		public int ByteIn (byte val)
		{
			if (val != 100)
				return 2;
			return 0;
		}

		public int ShortIn (short val)
		{
			if (val != -100)
				return 3;
			return 0;
		}

		public int UShortIn (ushort val)
		{
			if (val != 100)
				return 4;
			return 0;
		}

		public int IntIn (int val)
		{
			if (val != -100)
				return 5;
			return 0;
		}

		public int UIntIn (uint val)
		{
			if (val != 100)
				return 6;
			return 0;
		}

		public int LongIn (long val)
		{
			if (val != -100)
				return 7;
			return 0;
		}

		public int ULongIn (ulong val)
		{
			if (val != 100)
				return 8;
			return 0;
		}

		public int FloatIn (float val)
		{
			if (Math.Abs (val - 3.14f) > .000001)
				return 9;
			return 0;
		}

		public int DoubleIn (double val)
		{
			if (Math.Abs (val - 3.14f) > .000001)
				return 10;
			return 0;
		}

		public int ITestIn ([MarshalAs (UnmanagedType.Interface)]ITestPresSig val)
		{
			if (val == null)
				return 11;
			if (null == val as ManagedTestPresSig)
				return 12;
			return 0;
		}

		public int ITestOut ([MarshalAs (UnmanagedType.Interface)]out ITestPresSig val)
		{
			val = new ManagedTestPresSig ();
			return 0;
		}

		public int Return22NoICall()
		{
			return 88;
		}

		public int IntOut(out int val)
		{
			val = 33;
			return 0;
		}

		public int ArrayIn(object[] array)
		{
			if (array.Length != 2)
				return 40;
			if (array.Rank != 1)
				return 41;
			if (array.GetLowerBound(0) != 0)
				return 42;
			if (array.GetUpperBound(0) != 1)
				return 43;
			if (array[0] is string)
			{
				if ((array[0] as string) != "Test")
					return 44;
			}
			else
				return 45;
			if (array[1] is int)
			{
				if ((int)array[1] != 2345)
					return 46;
			}
			else
				return 47;

			return 444;
		}

		public int ArrayIn2(object[] array)
		{
			return ArrayIn(array);
		}

		public int ArrayIn3(object[] array)
		{
			return ArrayIn(array);
		}

		public int ArrayOut (int[] array, out int result)
		{
			if (array == null)
				result = 0;
			else
			{
				array[0] = 55;
				result = 1;
			}
			return 0;
		}
	}

	public class ManagedTest : ITest
	{
		private int status = 0;
		public int Status
		{
			get { return status; }
		}
		public void SByteIn (sbyte val)
		{
			if (val != -100)
				status = 1;
		}

		public void ByteIn (byte val)
		{
			if (val != 100)
				status = 2;
		}

		public void ShortIn (short val)
		{
			if (val != -100)
				status = 3;
		}

		public void UShortIn (ushort val)
		{
			if (val != 100)
				status = 4;
		}

		public void IntIn (int val)
		{
			if (val != -100)
				status = 5;
		}

		public void UIntIn (uint val)
		{
			if (val != 100)
				status = 6;
		}

		public void LongIn (long val)
		{
			if (val != -100)
				status = 7;
		}

		public void ULongIn (ulong val)
		{
			if (val != 100)
				status = 8;
		}

		public void FloatIn (float val)
		{
			if (Math.Abs (val - 3.14f) > .000001)
				status = 9;
		}

		public void DoubleIn (double val)
		{
			if (Math.Abs (val - 3.14) > .000001)
				status = 10;
		}

		public void ITestIn (ITest val)
		{
			if (val == null)
				status = 11;
			if (null == val as ManagedTest)
				status = 12;
		}

		public void ITestOut (out ITest val)
		{
			val = new ManagedTest ();
		}

		public ITest Test
		{
			get
			{
				return new ManagedTest ();
			}
		}

		public int Return22NoICall()
		{
			return 99;
		}

		public int IntOut()
		{
			return 33;
		}

		public void ArrayIn(object[] array)
		{
			if (array.Length != 2)
				status = 40;
			else if (array.Rank != 1)
				status = 41;
			else if (array.GetLowerBound(0) != 0)
				status = 42;
			else if (array.GetUpperBound(0) != 1)
				status = 43;
			else if (array[0] is string)
			{
				if ((array[0] as string) != "Test")
					status = 44;
			}
			else if (array[1] is int)
			{
				if ((int)array[1] != 2345)
					status = 45;
			}

			status = 444;
		}

		public void ArrayIn2(object[] array)
		{
			ArrayIn(array);
		}

		public void ArrayIn3(object[] array)
		{
			ArrayIn(array);
		}

		public int ArrayOut (int[] array)
		{
			if (array == null)
				return 0;
			array[0] = 55;
			return 1;
		}

		public TestDefaultInterfaceClass1 GetDefInterface1()
		{
			return new TestDefaultInterfaceClass1();
		}

		public TestDefaultInterfaceClass2 GetDefInterface2()
		{
			return new TestDefaultInterfaceClass2();
		}
	}

	[ComVisible (true)]
	public interface IOtherTest
	{
	}

	public class OtherTest: IOtherTest
	{
	}

	public static int mono_test_marshal_variant_in_callback (VarEnum vt, object obj)
	{
		switch (vt)
		{
		case VarEnum.VT_I1:
			if (obj.GetType () != typeof (sbyte))
				return 1;
			if ((sbyte)obj != -100)
				return 2;
			break;
		case VarEnum.VT_UI1:
			if (obj.GetType () != typeof (byte))
				return 1;
			if ((byte)obj != 100)
				return 2;
			break;
		case VarEnum.VT_I2:
			if (obj.GetType () != typeof (short))
				return 1;
			if ((short)obj != -100)
				return 2;
			break;
		case VarEnum.VT_UI2:
			if (obj.GetType () != typeof (ushort))
				return 1;
			if ((ushort)obj != 100)
				return 2;
			break;
		case VarEnum.VT_I4:
			if (obj.GetType () != typeof (int))
				return 1;
			if ((int)obj != -100)
				return 2;
			break;
		case VarEnum.VT_UI4:
			if (obj.GetType () != typeof (uint))
				return 1;
			if ((uint)obj != 100)
				return 2;
			break;
		case VarEnum.VT_I8:
			if (obj.GetType () != typeof (long))
				return 1;
			if ((long)obj != -100)
				return 2;
			break;
		case VarEnum.VT_UI8:
			if (obj.GetType () != typeof (ulong))
				return 1;
			if ((ulong)obj != 100)
				return 2;
			break;
		case VarEnum.VT_R4:
			if (obj.GetType () != typeof (float))
				return 1;
			if (Math.Abs ((float)obj - 3.14f) > 1e-10)
				return 2;
			break;
		case VarEnum.VT_R8:
			if (obj.GetType () != typeof (double))
				return 1;
			if (Math.Abs ((double)obj - 3.14) > 1e-10)
				return 2;
			break;
		case VarEnum.VT_BSTR:
			if (obj.GetType () != typeof (string))
				return 1;
			if ((string)obj != "PI")
				return 2;
			break;
		case VarEnum.VT_BOOL:
			if (obj.GetType () != typeof (bool))
				return 1;
			if ((bool)obj != true)
				return 2;
			break;
		}
		return 0;
	}

	public static int mono_test_marshal_variant_out_callback (VarEnum vt, ref object obj)
	{
		switch (vt) {
		case VarEnum.VT_I1:
			obj = (sbyte)-100;
			break;
		case VarEnum.VT_UI1:
			obj = (byte)100;
			break;
		case VarEnum.VT_I2:
			obj = (short)-100;
			break;
		case VarEnum.VT_UI2:
			obj = (ushort)100;
			break;
		case VarEnum.VT_I4:
			obj = (int)-100;
			break;
		case VarEnum.VT_UI4:
			obj = (uint)100;
			break;
		case VarEnum.VT_I8:
			obj = (long)-100;
			break;
		case VarEnum.VT_UI8:
			obj = (ulong)100;
			break;
		case VarEnum.VT_R4:
			obj = (float)3.14f;
			break;
		case VarEnum.VT_R8:
			obj = (double)3.14;
			break;
		case VarEnum.VT_BSTR:
			obj = "PI";
			break;
		case VarEnum.VT_BOOL:
			obj = true;
			break;
		}
		return 0;
	}

	public static int TestITest (ITest itest)
	{
		try {
			ITest itest2;
			itest.SByteIn (-100);
			itest.ByteIn (100);
			itest.ShortIn (-100);
			itest.UShortIn (100);
			itest.IntIn (-100);
			itest.UIntIn (100);
			itest.LongIn (-100);
			itest.ULongIn (100);
			itest.FloatIn (3.14f);
			itest.DoubleIn (3.14);
			itest.ITestIn (itest);
			itest.ITestOut (out itest2);
		}
		catch (Exception ex) {
			return 1;
		}
		return 0;
	}

	public static int TestITestPresSig (ITestPresSig itest)
	{
		ITestPresSig itest2;
		if (itest.SByteIn (-100) != 0)
			return 1000;
		if (itest.ByteIn (100) != 0)
			return 1001;
		if (itest.ShortIn (-100) != 0)
			return 1002;
		if (itest.UShortIn (100) != 0)
			return 1003;
		if (itest.IntIn (-100) != 0)
			return 1004;
		if (itest.UIntIn (100) != 0)
			return 1005;
		if (itest.LongIn (-100) != 0)
			return 1006;
		if (itest.ULongIn (100) != 0)
			return 1007;
		if (itest.FloatIn (3.14f) != 0)
			return 1008;
		if (itest.DoubleIn (3.14) != 0)
			return 1009;
		if (itest.ITestIn (itest) != 0)
			return 1010;
		if (itest.ITestOut (out itest2) != 0)
			return 1011;
		return 0;
	}

	public static int TestITestDelegate (ITest itest)
	{
		try {
			ITest itest2;

			SByteInDelegate SByteInFcn= itest.SByteIn;
			ByteInDelegate ByteInFcn = itest.ByteIn;
			UShortInDelegate UShortInFcn = itest.UShortIn;
			IntInDelegate IntInFcn = itest.IntIn;
			UIntInDelegate UIntInFcn = itest.UIntIn;
			LongInDelegate LongInFcn = itest.LongIn;

			ULongInDelegate ULongInFcn = itest.ULongIn;
			FloatInDelegate FloatInFcn = itest.FloatIn;
			DoubleInDelegate DoubleInFcn = itest.DoubleIn;
			ITestInDelegate ITestInFcn = itest.ITestIn;
			ITestOutDelegate ITestOutFcn = itest.ITestOut;

			SByteInFcn (-100);
			ByteInFcn (100);
			UShortInFcn (100);
			IntInFcn (-100);
			UIntInFcn (100);
			LongInFcn (-100);
			ULongInFcn (100);
			FloatInFcn (3.14f);
			DoubleInFcn (3.14);
			ITestInFcn (itest);
			ITestOutFcn (out itest2);
		}
		catch (Exception) {
			return 1;
		}
		return 0;
	}

	public static int TestIfaceNoIcall (ITestPresSig itest) {
		return itest.Return22NoICall () == 22 ? 0 : 1;
	}

        public static int mono_test_marshal_struct_with_variant_callback(StructWithVariant sv)
        {
            if (sv.data.GetType() != typeof(int))
                return 1;
            if ((int)sv.data != -123)
                return 2;
            return 0;
        }

        public static int mono_test_marshal_struct_with_bstr_callback(StructWithBstr sb)
        {
            if (sb.data.GetType() != typeof(string))
                return 1;
            if ((string)sb.data != "this is a test string")
                return 2;
            return 0;
        }
}

public class TestVisible
{
}

public struct StructWithVariant
{
	[MarshalAs (UnmanagedType.Struct)]
	public object data;
}

public struct StructWithBstr
{
	[MarshalAs (UnmanagedType.BStr)]
	public string data;
}