File tree Expand file tree Collapse file tree 13 files changed +31
-31
lines changed
sources/ClangSharp.PInvokeGenerator
tests/ClangSharp.PInvokeGenerator.UnitTests Expand file tree Collapse file tree 13 files changed +31
-31
lines changed Original file line number Diff line number Diff line change @@ -5933,7 +5933,7 @@ private bool IsUnsafe(RecordDecl recordDecl)
5933
5933
{
5934
5934
return true ;
5935
5935
}
5936
- else if ( ( decl is RecordDecl nestedRecordDecl ) && nestedRecordDecl . IsAnonymousStructOrUnion && IsUnsafe ( nestedRecordDecl ) )
5936
+ else if ( ( decl is RecordDecl nestedRecordDecl ) && nestedRecordDecl . IsAnonymousStructOrUnion && ( IsUnsafe ( nestedRecordDecl ) || Config . GenerateCompatibleCode ) )
5937
5937
{
5938
5938
return true ;
5939
5939
}
Original file line number Diff line number Diff line change @@ -1446,7 +1446,7 @@ void MyFunction()
1446
1446
namespace ClangSharp.Test
1447
1447
{
1448
1448
[StructLayout(LayoutKind.Explicit)]
1449
- public partial struct MyUnion
1449
+ public unsafe partial struct MyUnion
1450
1450
{
1451
1451
[FieldOffset(0)]
1452
1452
[NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")]
Original file line number Diff line number Diff line change @@ -1249,7 +1249,7 @@ public partial struct _w_e__Struct
1249
1249
public { expectedManagedType } value;
1250
1250
}}
1251
1251
1252
- public partial struct _Anonymous1_e__Struct
1252
+ public unsafe partial struct _Anonymous1_e__Struct
1253
1253
{{
1254
1254
public { expectedManagedType } value1;
1255
1255
@@ -1318,7 +1318,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl()
1318
1318
1319
1319
var expectedOutputContents = @"namespace ClangSharp.Test
1320
1320
{
1321
- public partial struct MyStruct
1321
+ public unsafe partial struct MyStruct
1322
1322
{
1323
1323
public int x;
1324
1324
@@ -1375,7 +1375,7 @@ public int o0_b16_4
1375
1375
}
1376
1376
}
1377
1377
1378
- public partial struct _Anonymous_e__Struct
1378
+ public unsafe partial struct _Anonymous_e__Struct
1379
1379
{
1380
1380
public int z;
1381
1381
@@ -1708,7 +1708,7 @@ protected override Task RemapNestedAnonymousTestImpl()
1708
1708
1709
1709
var expectedOutputContents = @"namespace ClangSharp.Test
1710
1710
{
1711
- public partial struct MyStruct
1711
+ public unsafe partial struct MyStruct
1712
1712
{
1713
1713
public double r;
1714
1714
Original file line number Diff line number Diff line change @@ -891,7 +891,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl()
891
891
namespace ClangSharp.Test
892
892
{
893
893
[StructLayout(LayoutKind.Explicit)]
894
- public partial struct MyUnion
894
+ public unsafe partial struct MyUnion
895
895
{
896
896
[FieldOffset(0)]
897
897
public int x;
@@ -952,7 +952,7 @@ public int o0_b16_4
952
952
}
953
953
954
954
[StructLayout(LayoutKind.Explicit)]
955
- public partial struct _Anonymous_e__Union
955
+ public unsafe partial struct _Anonymous_e__Union
956
956
{
957
957
[FieldOffset(0)]
958
958
public int z;
@@ -1283,7 +1283,7 @@ protected override Task RemapNestedAnonymousTestImpl()
1283
1283
namespace ClangSharp.Test
1284
1284
{
1285
1285
[StructLayout(LayoutKind.Explicit)]
1286
- public partial struct MyUnion
1286
+ public unsafe partial struct MyUnion
1287
1287
{
1288
1288
[FieldOffset(0)]
1289
1289
public double r;
Original file line number Diff line number Diff line change @@ -1446,7 +1446,7 @@ void MyFunction()
1446
1446
namespace ClangSharp.Test
1447
1447
{
1448
1448
[StructLayout(LayoutKind.Explicit)]
1449
- public partial struct MyUnion
1449
+ public unsafe partial struct MyUnion
1450
1450
{
1451
1451
[FieldOffset(0)]
1452
1452
[NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")]
Original file line number Diff line number Diff line change @@ -1257,7 +1257,7 @@ public partial struct _w_e__Struct
1257
1257
public { expectedManagedType } value;
1258
1258
}}
1259
1259
1260
- public partial struct _Anonymous1_e__Struct
1260
+ public unsafe partial struct _Anonymous1_e__Struct
1261
1261
{{
1262
1262
public { expectedManagedType } value1;
1263
1263
@@ -1326,7 +1326,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl()
1326
1326
1327
1327
var expectedOutputContents = @"namespace ClangSharp.Test
1328
1328
{
1329
- public partial struct MyStruct
1329
+ public unsafe partial struct MyStruct
1330
1330
{
1331
1331
public int x;
1332
1332
@@ -1383,7 +1383,7 @@ public int o0_b16_4
1383
1383
}
1384
1384
}
1385
1385
1386
- public partial struct _Anonymous_e__Struct
1386
+ public unsafe partial struct _Anonymous_e__Struct
1387
1387
{
1388
1388
public int z;
1389
1389
@@ -1716,7 +1716,7 @@ protected override Task RemapNestedAnonymousTestImpl()
1716
1716
1717
1717
var expectedOutputContents = @"namespace ClangSharp.Test
1718
1718
{
1719
- public partial struct MyStruct
1719
+ public unsafe partial struct MyStruct
1720
1720
{
1721
1721
public double r;
1722
1722
Original file line number Diff line number Diff line change @@ -898,7 +898,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl()
898
898
namespace ClangSharp.Test
899
899
{
900
900
[StructLayout(LayoutKind.Explicit)]
901
- public partial struct MyUnion
901
+ public unsafe partial struct MyUnion
902
902
{
903
903
[FieldOffset(0)]
904
904
public int x;
@@ -959,7 +959,7 @@ public int o0_b16_4
959
959
}
960
960
961
961
[StructLayout(LayoutKind.Explicit)]
962
- public partial struct _Anonymous_e__Union
962
+ public unsafe partial struct _Anonymous_e__Union
963
963
{
964
964
[FieldOffset(0)]
965
965
public int z;
@@ -1290,7 +1290,7 @@ protected override Task RemapNestedAnonymousTestImpl()
1290
1290
namespace ClangSharp.Test
1291
1291
{
1292
1292
[StructLayout(LayoutKind.Explicit)]
1293
- public partial struct MyUnion
1293
+ public unsafe partial struct MyUnion
1294
1294
{
1295
1295
[FieldOffset(0)]
1296
1296
public double r;
Original file line number Diff line number Diff line change @@ -1629,7 +1629,7 @@ void MyFunction()
1629
1629
var expectedOutputContents = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>
1630
1630
<bindings>
1631
1631
<namespace name=""ClangSharp.Test"">
1632
- <struct name=""MyUnion"" access=""public"" layout=""Explicit"">
1632
+ <struct name=""MyUnion"" access=""public"" unsafe=""true"" layout=""Explicit"">
1633
1633
<field name=""Anonymous"" access=""public"" offset=""0"">
1634
1634
<type native=""__AnonymousRecord_ClangUnsavedFile_L3_C5"">_Anonymous_e__Struct</type>
1635
1635
</field>
Original file line number Diff line number Diff line change @@ -1258,7 +1258,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl()
1258
1258
var expectedOutputContents = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>
1259
1259
<bindings>
1260
1260
<namespace name=""ClangSharp.Test"">
1261
- <struct name=""MyStruct"" access=""public"">
1261
+ <struct name=""MyStruct"" access=""public"" unsafe=""true"" >
1262
1262
<field name=""x"" access=""public"">
1263
1263
<type>int</type>
1264
1264
</field>
@@ -1304,7 +1304,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl()
1304
1304
<code>Anonymous.Anonymous.o0_b16_4 = value;</code>
1305
1305
</set>
1306
1306
</field>
1307
- <struct name=""_Anonymous_e__Struct"" access=""public"">
1307
+ <struct name=""_Anonymous_e__Struct"" access=""public"" unsafe=""true"" >
1308
1308
<field name=""z"" access=""public"">
1309
1309
<type>int</type>
1310
1310
</field>
@@ -1654,7 +1654,7 @@ protected override Task RemapNestedAnonymousTestImpl()
1654
1654
var expectedOutputContents = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>
1655
1655
<bindings>
1656
1656
<namespace name=""ClangSharp.Test"">
1657
- <struct name=""MyStruct"" access=""public"">
1657
+ <struct name=""MyStruct"" access=""public"" unsafe=""true"" >
1658
1658
<field name=""r"" access=""public"">
1659
1659
<type>double</type>
1660
1660
</field>
Original file line number Diff line number Diff line change @@ -846,7 +846,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl()
846
846
var expectedOutputContents = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>
847
847
<bindings>
848
848
<namespace name=""ClangSharp.Test"">
849
- <struct name=""MyUnion"" access=""public"" layout=""Explicit"">
849
+ <struct name=""MyUnion"" access=""public"" unsafe=""true"" layout=""Explicit"">
850
850
<field name=""x"" access=""public"" offset=""0"">
851
851
<type>int</type>
852
852
</field>
@@ -892,7 +892,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl()
892
892
<code>Anonymous.Anonymous.o0_b16_4 = value;</code>
893
893
</set>
894
894
</field>
895
- <struct name=""_Anonymous_e__Union"" access=""public"" layout=""Explicit"">
895
+ <struct name=""_Anonymous_e__Union"" access=""public"" unsafe=""true"" layout=""Explicit"">
896
896
<field name=""z"" access=""public"" offset=""0"">
897
897
<type>int</type>
898
898
</field>
@@ -1188,7 +1188,7 @@ protected override Task RemapNestedAnonymousTestImpl()
1188
1188
var expectedOutputContents = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>
1189
1189
<bindings>
1190
1190
<namespace name=""ClangSharp.Test"">
1191
- <struct name=""MyUnion"" access=""public"" layout=""Explicit"">
1191
+ <struct name=""MyUnion"" access=""public"" unsafe=""true"" layout=""Explicit"">
1192
1192
<field name=""r"" access=""public"" offset=""0"">
1193
1193
<type>double</type>
1194
1194
</field>
You can’t perform that action at this time.
0 commit comments