Skip to content

Commit b427ef7

Browse files
committed
Update latest-codegen to be net8.0
1 parent 03da09d commit b427ef7

File tree

13 files changed

+67
-1033
lines changed

13 files changed

+67
-1033
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ Options:
201201
# Codegen Options
202202
203203
compatible-codegen Bindings should be generated with .NET Standard 2.0 compatibility. Setting this disables preview code generation.
204-
default-codegen Bindings should be generated for the current LTS version of .NET/C#. This is currently .NET 6/C# 10.
205-
latest-codegen Bindings should be generated for the current STS version of .NET/C#. This is currently .NET 7/C# 11.
206-
preview-codegen Bindings should be generated for the preview version of .NET/C#. This is currently .NET 8/C# 12.
204+
default-codegen Bindings should be generated for the previous LTS version of .NET/C#. This is currently .NET 6/C# 10.
205+
latest-codegen Bindings should be generated for the current LTS/STS version of .NET/C#. This is currently .NET 8/C# 12.
206+
preview-codegen Bindings should be generated for the preview version of .NET/C#. This is currently .NET 9/C# 13.
207207
208208
# File Options
209209

sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void WriteIid(string name, Guid value)
8989

9090
WriteIndented("ReadOnlySpan<byte> data = ");
9191

92-
if (_config.GeneratePreviewCode)
92+
if (_config.GenerateLatestCode)
9393
{
9494
WriteLine('[');
9595
}
@@ -124,7 +124,7 @@ public void WriteIid(string name, Guid value)
124124
WriteNewline();
125125
DecreaseIndentation();
126126

127-
if (_config.GeneratePreviewCode)
127+
if (_config.GenerateLatestCode)
128128
{
129129
WriteIndented(']');
130130
}

sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2903,7 +2903,7 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co
29032903
AddDiagnostic(DiagnosticLevel.Info, $"{escapedName} (constant array field) has a size of 0", constantOrIncompleteArray);
29042904
}
29052905

2906-
if (!_config.GeneratePreviewCode || (totalSize <= 1) || isUnsafeElementType)
2906+
if (!_config.GenerateLatestCode || (totalSize <= 1) || isUnsafeElementType)
29072907
{
29082908
totalSizeString = null;
29092909
}

sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ void HandleUnmanagedConstant(CSharpOutputBuilder outputBuilder, InitListExpr ini
15031503

15041504
outputBuilder.WriteIndented("ReadOnlySpan<byte> data = ");
15051505

1506-
if (_config.GeneratePreviewCode)
1506+
if (_config.GenerateLatestCode)
15071507
{
15081508
outputBuilder.WriteLine("[");
15091509
}
@@ -1519,7 +1519,7 @@ void HandleUnmanagedConstant(CSharpOutputBuilder outputBuilder, InitListExpr ini
15191519
outputBuilder.WriteNewline();
15201520
outputBuilder.DecreaseIndentation();
15211521

1522-
if (_config.GeneratePreviewCode)
1522+
if (_config.GenerateLatestCode)
15231523
{
15241524
outputBuilder.WriteIndented(']');
15251525
}
@@ -2553,7 +2553,7 @@ private void VisitStringLiteral(StringLiteral stringLiteral)
25532553

25542554
case CX_CLK_UTF32:
25552555
{
2556-
if (_config.GeneratePreviewCode)
2556+
if (_config.GenerateLatestCode)
25572557
{
25582558
outputBuilder.Write('[');
25592559
}
@@ -2574,7 +2574,7 @@ private void VisitStringLiteral(StringLiteral stringLiteral)
25742574

25752575
outputBuilder.Write("0x00000000");
25762576

2577-
if (_config.GeneratePreviewCode)
2577+
if (_config.GenerateLatestCode)
25782578
{
25792579
outputBuilder.Write(']');
25802580
}

sources/ClangSharpPInvokeGenerator/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ public static class Program
174174
new TwoColumnHelpRow("generate-unmanaged-constants", "Unmanaged constants should be generated using static ref readonly properties. This is currently experimental."),
175175
new TwoColumnHelpRow("generate-vtbl-index-attribute", "[VtblIndex(#)] attribute should be generated to document the underlying VTBL index for a helper method."),
176176

177-
// Logging Options
177+
new TwoColumnHelpRow("", ""),
178+
new TwoColumnHelpRow("# Logging Options", ""),
179+
new TwoColumnHelpRow("", ""),
178180

179181
new TwoColumnHelpRow("log-exclusions", "A list of excluded declaration types should be generated. This will also log if the exclusion was due to an exact or partial match."),
180182
new TwoColumnHelpRow("log-potential-typedef-remappings", "A list of potential typedef remappings should be generated. This can help identify missing remappings."),

tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs

Lines changed: 10 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,7 @@ struct MyOtherStruct
591591
}};
592592
";
593593

594-
var expectedOutputContents = $@"using System;
595-
using System.Diagnostics.CodeAnalysis;
596-
using System.Runtime.InteropServices;
594+
var expectedOutputContents = $@"using System.Runtime.CompilerServices;
597595
598596
namespace ClangSharp.Test
599597
{{
@@ -607,23 +605,10 @@ public partial struct MyOtherStruct
607605
[NativeTypeName(""MyStruct[3]"")]
608606
public _c_e__FixedBuffer c;
609607
608+
[InlineArray(3)]
610609
public partial struct _c_e__FixedBuffer
611610
{{
612611
public MyStruct e0;
613-
public MyStruct e1;
614-
public MyStruct e2;
615-
616-
[UnscopedRef]
617-
public ref MyStruct this[int index]
618-
{{
619-
get
620-
{{
621-
return ref AsSpan()[index];
622-
}}
623-
}}
624-
625-
[UnscopedRef]
626-
public Span<MyStruct> AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3);
627612
}}
628613
}}
629614
}}
@@ -645,9 +630,7 @@ struct MyOtherStruct
645630
}};
646631
";
647632

648-
var expectedOutputContents = $@"using System;
649-
using System.Diagnostics.CodeAnalysis;
650-
using System.Runtime.InteropServices;
633+
var expectedOutputContents = $@"using System.Runtime.CompilerServices;
651634
652635
namespace ClangSharp.Test
653636
{{
@@ -661,55 +644,10 @@ public partial struct MyOtherStruct
661644
[NativeTypeName(""MyStruct[2][1][3][4]"")]
662645
public _c_e__FixedBuffer c;
663646
647+
[InlineArray(2 * 1 * 3 * 4)]
664648
public partial struct _c_e__FixedBuffer
665649
{{
666650
public MyStruct e0_0_0_0;
667-
public MyStruct e1_0_0_0;
668-
669-
public MyStruct e0_0_1_0;
670-
public MyStruct e1_0_1_0;
671-
672-
public MyStruct e0_0_2_0;
673-
public MyStruct e1_0_2_0;
674-
675-
public MyStruct e0_0_0_1;
676-
public MyStruct e1_0_0_1;
677-
678-
public MyStruct e0_0_1_1;
679-
public MyStruct e1_0_1_1;
680-
681-
public MyStruct e0_0_2_1;
682-
public MyStruct e1_0_2_1;
683-
684-
public MyStruct e0_0_0_2;
685-
public MyStruct e1_0_0_2;
686-
687-
public MyStruct e0_0_1_2;
688-
public MyStruct e1_0_1_2;
689-
690-
public MyStruct e0_0_2_2;
691-
public MyStruct e1_0_2_2;
692-
693-
public MyStruct e0_0_0_3;
694-
public MyStruct e1_0_0_3;
695-
696-
public MyStruct e0_0_1_3;
697-
public MyStruct e1_0_1_3;
698-
699-
public MyStruct e0_0_2_3;
700-
public MyStruct e1_0_2_3;
701-
702-
[UnscopedRef]
703-
public ref MyStruct this[int index]
704-
{{
705-
get
706-
{{
707-
return ref AsSpan()[index];
708-
}}
709-
}}
710-
711-
[UnscopedRef]
712-
public Span<MyStruct> AsSpan() => MemoryMarshal.CreateSpan(ref e0_0_0_0, 24);
713651
}}
714652
}}
715653
}}
@@ -733,9 +671,7 @@ struct MyOtherStruct
733671
}};
734672
";
735673

736-
var expectedOutputContents = $@"using System;
737-
using System.Diagnostics.CodeAnalysis;
738-
using System.Runtime.InteropServices;
674+
var expectedOutputContents = $@"using System.Runtime.CompilerServices;
739675
740676
namespace ClangSharp.Test
741677
{{
@@ -749,23 +685,10 @@ public partial struct MyOtherStruct
749685
[NativeTypeName(""MyBuffer"")]
750686
public _c_e__FixedBuffer c;
751687
688+
[InlineArray(3)]
752689
public partial struct _c_e__FixedBuffer
753690
{{
754691
public MyStruct e0;
755-
public MyStruct e1;
756-
public MyStruct e2;
757-
758-
[UnscopedRef]
759-
public ref MyStruct this[int index]
760-
{{
761-
get
762-
{{
763-
return ref AsSpan()[index];
764-
}}
765-
}}
766-
767-
[UnscopedRef]
768-
public Span<MyStruct> AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3);
769692
}}
770693
}}
771694
}}
@@ -787,9 +710,7 @@ struct MyOtherStruct
787710
}};
788711
";
789712

790-
var expectedOutputContents = $@"using System;
791-
using System.Diagnostics.CodeAnalysis;
792-
using System.Runtime.InteropServices;
713+
var expectedOutputContents = $@"using System.Runtime.CompilerServices;
793714
794715
namespace ClangSharp.Test
795716
{{
@@ -804,23 +725,10 @@ public partial struct MyOtherStruct
804725
[NativeTypeName(""MyStruct[3]"")]
805726
public _c_e__FixedBuffer c;
806727
728+
[InlineArray(3)]
807729
public partial struct _c_e__FixedBuffer
808730
{{
809731
public MyStruct e0;
810-
public MyStruct e1;
811-
public MyStruct e2;
812-
813-
[UnscopedRef]
814-
public ref MyStruct this[int index]
815-
{{
816-
get
817-
{{
818-
return ref AsSpan()[index];
819-
}}
820-
}}
821-
822-
[UnscopedRef]
823-
public Span<MyStruct> AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3);
824732
}}
825733
}}
826734
}}
@@ -1136,6 +1044,7 @@ struct MyStruct
11361044

11371045
var expectedOutputContents = $@"using System;
11381046
using System.Diagnostics.CodeAnalysis;
1047+
using System.Runtime.CompilerServices;
11391048
using System.Runtime.InteropServices;
11401049
11411050
namespace ClangSharp.Test
@@ -1274,24 +1183,10 @@ public partial struct _Anonymous2_e__Union
12741183
public {expectedManagedType} value2;
12751184
}}
12761185
1186+
[InlineArray(4)]
12771187
public partial struct _buffer2_e__FixedBuffer
12781188
{{
12791189
public MyUnion e0;
1280-
public MyUnion e1;
1281-
public MyUnion e2;
1282-
public MyUnion e3;
1283-
1284-
[UnscopedRef]
1285-
public ref MyUnion this[int index]
1286-
{{
1287-
get
1288-
{{
1289-
return ref AsSpan()[index];
1290-
}}
1291-
}}
1292-
1293-
[UnscopedRef]
1294-
public Span<MyUnion> AsSpan() => MemoryMarshal.CreateSpan(ref e0, 4);
12951190
}}
12961191
}}
12971192
}}

0 commit comments

Comments
 (0)