Skip to content

Commit ad8fb60

Browse files
Merge pull request #496 from tannergooding/main
Update latest-codegen to be net8.0
2 parents b792a14 + 933c644 commit ad8fb60

File tree

15 files changed

+169
-1090
lines changed

15 files changed

+169
-1090
lines changed

README.md

Lines changed: 66 additions & 37 deletions
Large diffs are not rendered by default.

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: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public static class Program
4242
private static readonly string[] s_remapOptionAliases = ["--remap", "-r"];
4343
private static readonly string[] s_stdOptionAliases = ["--std", "-std"];
4444
private static readonly string[] s_testOutputOptionAliases = ["--test-output", "-to"];
45-
private static readonly string[] s_versionOptionAliases = ["--version", "-v"];
4645
private static readonly string[] s_traverseOptionAliases = ["--traverse", "-t"];
46+
private static readonly string[] s_versionOptionAliases = ["--version", "-v"];
4747
private static readonly string[] s_withAccessSpecifierOptionAliases = ["--with-access-specifier", "-was"];
4848
private static readonly string[] s_withAttributeOptionAliases = ["--with-attribute", "-wa"];
4949
private static readonly string[] s_withCallConvOptionAliases = ["--with-callconv", "-wcc"];
@@ -52,12 +52,12 @@ public static class Program
5252
private static readonly string[] s_withLibraryPathOptionAliases = ["--with-librarypath", "-wlb"];
5353
private static readonly string[] s_withManualImportOptionAliases = ["--with-manual-import", "-wmi"];
5454
private static readonly string[] s_withNamespaceOptionAliases = ["--with-namespace", "-wn"];
55+
private static readonly string[] s_withPackingOptionAliases = ["--with-packing", "-wp"];
5556
private static readonly string[] s_withSetLastErrorOptionAliases = ["--with-setlasterror", "-wsle"];
5657
private static readonly string[] s_withSuppressGCTransitionOptionAliases = ["--with-suppressgctransition", "-wsgct"];
5758
private static readonly string[] s_withTransparentStructOptionAliases = ["--with-transparent-struct", "-wts"];
5859
private static readonly string[] s_withTypeOptionAliases = ["--with-type", "-wt"];
5960
private static readonly string[] s_withUsingOptionAliases = ["--with-using", "-wu"];
60-
private static readonly string[] s_withPackingOptionAliases = ["--with-packing", "-wp"];
6161

6262
private static readonly Option<string[]> s_additionalOption = GetAdditionalOption();
6363
private static readonly Option<string[]> s_configOption = GetConfigOption();
@@ -89,37 +89,45 @@ public static class Program
8989
private static readonly Option<string[]> s_withLibraryPathNameValuePairs = GetWithLibraryPathOption();
9090
private static readonly Option<string[]> s_withManualImports = GetWithManualImportOption();
9191
private static readonly Option<string[]> s_withNamespaceNameValuePairs = GetWithNamespaceOption();
92+
private static readonly Option<string[]> s_withPackingNameValuePairs = GetWithPackingOption();
9293
private static readonly Option<string[]> s_withSetLastErrors = GetWithSetLastErrorOption();
9394
private static readonly Option<string[]> s_withSuppressGCTransitions = GetWithSuppressGCTransitionOption();
9495
private static readonly Option<string[]> s_withTransparentStructNameValuePairs = GetWithTransparentStructOption();
9596
private static readonly Option<string[]> s_withTypeNameValuePairs = GetWithTypeOption();
9697
private static readonly Option<string[]> s_withUsingNameValuePairs = GetWithUsingOption();
97-
private static readonly Option<string[]> s_withPackingNameValuePairs = GetWithPackingOption();
9898

9999
private static readonly RootCommand s_rootCommand = GetRootCommand();
100100

101101
private static readonly TwoColumnHelpRow[] s_configOptions =
102102
[
103103
new TwoColumnHelpRow("?, h, help", "Show help and usage information for -c, --config"),
104104

105-
// Codegen Options
105+
new TwoColumnHelpRow("", ""),
106+
new TwoColumnHelpRow("# Codegen Options", ""),
107+
new TwoColumnHelpRow("", ""),
106108

107109
new TwoColumnHelpRow("compatible-codegen", "Bindings should be generated with .NET Standard 2.0 compatibility. Setting this disables preview code generation."),
108110
new TwoColumnHelpRow("default-codegen", "Bindings should be generated for the current LTS version of .NET/C#. This is currently .NET 6/C# 10."),
109111
new TwoColumnHelpRow("latest-codegen", "Bindings should be generated for the current STS version of .NET/C#. This is currently .NET 7/C# 11."),
110112
new TwoColumnHelpRow("preview-codegen", "Bindings should be generated for the preview version of .NET/C#. This is currently .NET 8/C# 12."),
111113

112-
// File Options
114+
new TwoColumnHelpRow("", ""),
115+
new TwoColumnHelpRow("# File Options", ""),
116+
new TwoColumnHelpRow("", ""),
113117

114118
new TwoColumnHelpRow("single-file", "Bindings should be generated to a single output file. This is the default."),
115119
new TwoColumnHelpRow("multi-file", "Bindings should be generated so there is approximately one type per file."),
116120

117-
// Type Options
121+
new TwoColumnHelpRow("", ""),
122+
new TwoColumnHelpRow("# Type Options", ""),
123+
new TwoColumnHelpRow("", ""),
118124

119125
new TwoColumnHelpRow("unix-types", "Bindings should be generated assuming Unix defaults. This is the default on Unix platforms."),
120126
new TwoColumnHelpRow("windows-types", "Bindings should be generated assuming Windows defaults. This is the default on Windows platforms."),
121127

122-
// Exclusion Options
128+
new TwoColumnHelpRow("", ""),
129+
new TwoColumnHelpRow("# Exclusion Options", ""),
130+
new TwoColumnHelpRow("", ""),
123131

124132
new TwoColumnHelpRow("exclude-anonymous-field-helpers", "The helper ref properties generated for fields in nested anonymous structs and unions should not be generated."),
125133
new TwoColumnHelpRow("exclude-com-proxies", "Types recognized as COM proxies should not have bindings generated. These are currently function declarations ending with _UserFree, _UserMarshal, _UserSize, _UserUnmarshal, _Proxy, or _Stub."),
@@ -130,18 +138,24 @@ public static class Program
130138
new TwoColumnHelpRow("exclude-funcs-with-body", "Bindings for functions with bodies should not be generated."),
131139
new TwoColumnHelpRow("exclude-using-statics-for-enums", "Enum usages should be fully qualified and should not include a corresponding 'using static EnumName;'"),
132140

133-
// VTBL Options
141+
new TwoColumnHelpRow("", ""),
142+
new TwoColumnHelpRow("# Vtbl Options", ""),
143+
new TwoColumnHelpRow("", ""),
134144

135145
new TwoColumnHelpRow("explicit-vtbls", "VTBLs should have an explicit type generated with named fields per entry."),
136146
new TwoColumnHelpRow("implicit-vtbls", "VTBLs should be implicit to reduce metadata bloat. This is the current default"),
137147
new TwoColumnHelpRow("trimmable-vtbls", "VTBLs should be defined but not used in helper methods to reduce metadata bloat when trimming."),
138148

139-
// Test Options
149+
new TwoColumnHelpRow("", ""),
150+
new TwoColumnHelpRow("# Test Options", ""),
151+
new TwoColumnHelpRow("", ""),
140152

141153
new TwoColumnHelpRow("generate-tests-nunit", "Basic tests validating size, blittability, and associated metadata should be generated for NUnit."),
142154
new TwoColumnHelpRow("generate-tests-xunit", "Basic tests validating size, blittability, and associated metadata should be generated for XUnit."),
143155

144-
// Generation Options
156+
new TwoColumnHelpRow("", ""),
157+
new TwoColumnHelpRow("# Generation Options", ""),
158+
new TwoColumnHelpRow("", ""),
145159

146160
new TwoColumnHelpRow("generate-aggressive-inlining", "[MethodImpl(MethodImplOptions.AggressiveInlining)] should be added to generated helper functions."),
147161
new TwoColumnHelpRow("generate-callconv-member-function", "Instance function pointers should use [CallConvMemberFunction] where applicable."),
@@ -160,7 +174,9 @@ public static class Program
160174
new TwoColumnHelpRow("generate-unmanaged-constants", "Unmanaged constants should be generated using static ref readonly properties. This is currently experimental."),
161175
new TwoColumnHelpRow("generate-vtbl-index-attribute", "[VtblIndex(#)] attribute should be generated to document the underlying VTBL index for a helper method."),
162176

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

165181
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."),
166182
new TwoColumnHelpRow("log-potential-typedef-remappings", "A list of potential typedef remappings should be generated. This can help identify missing remappings."),
@@ -1151,12 +1167,12 @@ private static RootCommand GetRootCommand()
11511167
s_withLibraryPathNameValuePairs,
11521168
s_withManualImports,
11531169
s_withNamespaceNameValuePairs,
1170+
s_withPackingNameValuePairs,
11541171
s_withSetLastErrors,
11551172
s_withSuppressGCTransitions,
11561173
s_withTransparentStructNameValuePairs,
11571174
s_withTypeNameValuePairs,
1158-
s_withUsingNameValuePairs,
1159-
s_withPackingNameValuePairs
1175+
s_withUsingNameValuePairs
11601176
};
11611177
Handler.SetHandler(rootCommand, (Action<InvocationContext>)Run);
11621178
return rootCommand;

0 commit comments

Comments
 (0)