diff --git a/README.md b/README.md index c209141f..224e3632 100644 --- a/README.md +++ b/README.md @@ -149,41 +149,43 @@ Usage: ClangSharpPInvokeGenerator [options] Options: - -a, --additional An argument to pass to Clang when parsing the input files. [] - -c, --config A configuration option that controls how the bindings are generated. Specify 'help' to see the available options. [] - -D, --define-macro Define to (or 1 if omitted). [] - -e, --exclude A declaration name to exclude from binding generation. [] - -f, --file A file to parse and generate bindings for. [] - -F, --file-directory The base path for files to parse. [] - -h, --headerFile A file which contains the header to prefix every generated file with. [] - -i, --include A declaration name to include in binding generation. [] - -I, --include-directory Add directory to include search path. [] - -x, --language Treat subsequent input files as having type . [default: c++] - -l, --libraryPath The string to use in the DllImport attribute used when generating bindings. [] - -m, --methodClassName The name of the static class that will contain the generated method bindings. [default: Methods] - -n, --namespace The namespace in which to place the generated bindings. [] - -om, --output-mode The mode describing how the information collected from the headers are presented in the resultant bindings. [default: CSharp] - -o, --output The output location to write the generated bindings to. [] - -p, --prefixStrip The prefix to strip from the generated method bindings. [] - -r, --remap A declaration name to be remapped to another name during binding generation. [] - -std Language standard to compile for. [] - -to, --test-output The output location to write the generated tests to. [] - -t, --traverse A file name included either directly or indirectly by -f that should be traversed during binding generation. [] - -v, --version Prints the current version information for the tool and its native dependencies. - -was, --with-access-specifier An access specifier to be used with the given qualified or remapped declaration name during binding generation. Supports wildcards. [] - -wa, --with-attribute An attribute to be added to the given remapped declaration name during binding generation. Supports wildcards. [] - -wcc, --with-callconv A calling convention to be used for the given declaration during binding generation. Supports wildcards. [] - -wc, --with-class A class to be used for the given remapped constant or function declaration name during binding generation. Supports wildcards. [] - -wg, --with-guid A GUID to be used for the given declaration during binding generation. Supports wildcards. [] - -wlb, --with-librarypath A library path to be used for the given declaration during binding generation. Supports wildcards. [] - -wmi, --with-manual-import A remapped function name to be treated as a manual import during binding generation. Supports wildcards. [] - -wn, --with-namespace A namespace to be used for the given remapped declaration name during binding generation. Supports wildcards. [] - -wsle, --with-setlasterror Add the SetLastError=true modifier to a given DllImport or UnmanagedFunctionPointer. Supports wildcards. [] + -a, --additional An argument to pass to Clang when parsing the input files. [] + -c, --config A configuration option that controls how the bindings are generated. Specify 'help' to see the available options. [] + -D, --define-macro Define to (or 1 if omitted). [] + -e, --exclude A declaration name to exclude from binding generation. [] + -f, --file A file to parse and generate bindings for. [] + -F, --file-directory The base path for files to parse. [] + -h, --headerFile A file which contains the header to prefix every generated file with. [] + -i, --include A declaration name to include in binding generation. [] + -I, --include-directory Add directory to include search path. [] + -x, --language Treat subsequent input files as having type . [default: c++] + -l, --libraryPath The string to use in the DllImport attribute used when generating bindings. [] + -m, --methodClassName The name of the static class that will contain the generated method bindings. [default: Methods] + -n, --namespace The namespace in which to place the generated bindings. [] + --nativeTypeNamesToStrip The contents to strip from the generated NativeTypeName attributes. + -om, --output-mode The mode describing how the information collected from the headers are presented in the resultant bindings. [default: CSharp] + -o, --output The output location to write the generated bindings to. [] + -p, --prefixStrip The prefix to strip from the generated method bindings. [] + -r, --remap A declaration name to be remapped to another name during binding generation. [] + -std, --std Language standard to compile for. [] + -to, --test-output The output location to write the generated tests to. [] + -t, --traverse A file name included either directly or indirectly by -f that should be traversed during binding generation. [] + -v, --version Prints the current version information for the tool and its native dependencies. + -was, --with-access-specifier An access specifier to be used with the given qualified or remapped declaration name during binding generation. Supports wildcards. [] + -wa, --with-attribute An attribute to be added to the given remapped declaration name during binding generation. Supports wildcards. [] + -wcc, --with-callconv A calling convention to be used for the given declaration during binding generation. Supports wildcards. [] + -wc, --with-class A class to be used for the given remapped constant or function declaration name during binding generation. Supports wildcards. [] + -wg, --with-guid A GUID to be used for the given declaration during binding generation. Supports wildcards. [] + -wlb, --with-librarypath A library path to be used for the given declaration during binding generation. Supports wildcards. [] + -wmi, --with-manual-import A remapped function name to be treated as a manual import during binding generation. Supports wildcards. [] + -wn, --with-namespace A namespace to be used for the given remapped declaration name during binding generation. Supports wildcards. [] + -wp, --with-packing Overrides the StructLayoutAttribute.Pack property for the given type. Supports wildcards. [] + -wsle, --with-setlasterror Add the SetLastError=true modifier to a given DllImport or UnmanagedFunctionPointer. Supports wildcards. [] -wsgct, --with-suppressgctransition Add the SuppressGCTransition calling convention to a given DllImport or UnmanagedFunctionPointer. Supports wildcards. [] - -wts, --with-transparent-struct A remapped type name to be treated as a transparent wrapper during binding generation. Supports wildcards. [] - -wt, --with-type A type to be used for the given enum declaration during binding generation. Supports wildcards. [] - -wu, --with-using A using directive to be included for the given remapped declaration name during binding generation. Supports wildcards. [] - -?, -h, --help Show help and usage information + -wts, --with-transparent-struct A remapped type name to be treated as a transparent wrapper during binding generation. Supports wildcards. [] + -wt, --with-type A type to be used for the given enum declaration during binding generation. Supports wildcards. [] + -wu, --with-using A using directive to be included for the given remapped declaration name during binding generation. Supports wildcards. [] + -?, -h, --help Show help and usage information Wildcards: You can use * as catch-all rule for remapping procedures. For example if you want make all of your generated code internal you can use --with-access-specifier *=Internal. @@ -195,14 +197,26 @@ The available configuration options (visible with `-c help`) are: Options: ?, h, help Show help and usage information for -c, --config + + # Codegen Options + compatible-codegen Bindings should be generated with .NET Standard 2.0 compatibility. Setting this disables preview code generation. - default-codegen Bindings should be generated for the current LTS version of .NET/C#. This is currently .NET 6/C# 10. - latest-codegen Bindings should be generated for the current STS version of .NET/C#. This is currently .NET 7/C# 11. - preview-codegen Bindings should be generated for the preview version of .NET/C#. This is currently .NET 8/C# 12. + default-codegen Bindings should be generated for the previous LTS version of .NET/C#. This is currently .NET 6/C# 10. + latest-codegen Bindings should be generated for the current LTS/STS version of .NET/C#. This is currently .NET 8/C# 12. + preview-codegen Bindings should be generated for the preview version of .NET/C#. This is currently .NET 9/C# 13. + + # File Options + single-file Bindings should be generated to a single output file. This is the default. multi-file Bindings should be generated so there is approximately one type per file. + + # Type Options + unix-types Bindings should be generated assuming Unix defaults. This is the default on Unix platforms. windows-types Bindings should be generated assuming Windows defaults. This is the default on Windows platforms. + + # Exclusion Options + exclude-anonymous-field-helpers The helper ref properties generated for fields in nested anonymous structs and unions should not be generated. exclude-com-proxies Types recognized as COM proxies should not have bindings generated. Thes are currently function declarations ending with _UserFree, _UserMarshal, _UserSize, _UserUnmarshal, _Proxy, or _Stub. exclude-default-remappings Default remappings for well known types should not be added. This currently includes intptr_t, ptrdiff_t, size_t, and uintptr_t @@ -211,24 +225,39 @@ Options: exclude-fnptr-codegen Generated bindings for latest or preview codegen should not use function pointers. exclude-funcs-with-body Bindings for functions with bodies should not be generated. exclude-using-statics-for-enums Enum usages should be fully qualified and should not include a corresponding 'using static EnumName;' + + # Vtbl Options + explicit-vtbls VTBLs should have an explicit type generated with named fields per entry. implicit-vtbls VTBLs should be implicit to reduce metadata bloat. This is the current default trimmable-vtbls VTBLs should be defined but not used in helper methods to reduce metadata bloat when trimming. + + # Test Options + generate-tests-nunit Basic tests validating size, blittability, and associated metadata should be generated for NUnit. generate-tests-xunit Basic tests validating size, blittability, and associated metadata should be generated for XUnit. + + # Generation Options + generate-aggressive-inlining [MethodImpl(MethodImplOptions.AggressiveInlining)] should be added to generated helper functions. + generate-callconv-member-function Instance function pointers should use [CallConvMemberFunction] where applicable. generate-cpp-attributes [CppAttributeList("")] should be generated to document the encountered C++ attributes. + generate-disable-runtime-marshalling [assembly: DisableRuntimeMarshalling] should be generated. generate-doc-includes <include> xml documentation tags should be generated for declarations. generate-file-scoped-namespaces Namespaces should be scoped to the file to reduce nesting. generate-guid-member Types with an associated GUID should have a corresponding member generated. generate-helper-types Code files should be generated for various helper attributes and declared transparent structs. generate-macro-bindings Bindings for macro-definitions should be generated. This currently only works with value like macros and not function-like ones. generate-marker-interfaces Bindings for marker interfaces representing native inheritance hierarchies should be generated. + generate-native-bitfield-attribute [NativeBitfield(\"\", offset: #, length: #)] attribute should be generated to document the encountered bitfield layout. generate-native-inheritance-attribute [NativeInheritance("")] attribute should be generated to document the encountered C++ base type. generate-setslastsystemerror-attribute [SetsLastSystemError] attribute should be generated rather than using SetLastError = true. generate-template-bindings Bindings for template-definitions should be generated. This is currently experimental. generate-unmanaged-constants Unmanaged constants should be generated using static ref readonly properties. This is currently experimental. generate-vtbl-index-attribute [VtblIndex(#)] attribute should be generated to document the underlying VTBL index for a helper method. + + # Logging Options + 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. log-potential-typedef-remappings A list of potential typedef remappings should be generated. This can help identify missing remappings. log-visited-files A list of the visited files should be generated. This can help identify traversal issues. diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs index 24263826..c798c5a0 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs @@ -89,7 +89,7 @@ public void WriteIid(string name, Guid value) WriteIndented("ReadOnlySpan data = "); - if (_config.GeneratePreviewCode) + if (_config.GenerateLatestCode) { WriteLine('['); } @@ -124,7 +124,7 @@ public void WriteIid(string name, Guid value) WriteNewline(); DecreaseIndentation(); - if (_config.GeneratePreviewCode) + if (_config.GenerateLatestCode) { WriteIndented(']'); } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs index e76f2732..125de914 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs @@ -2903,7 +2903,7 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co AddDiagnostic(DiagnosticLevel.Info, $"{escapedName} (constant array field) has a size of 0", constantOrIncompleteArray); } - if (!_config.GeneratePreviewCode || (totalSize <= 1) || isUnsafeElementType) + if (!_config.GenerateLatestCode || (totalSize <= 1) || isUnsafeElementType) { totalSizeString = null; } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs index 9bd793f1..7c8ee972 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs @@ -1503,7 +1503,7 @@ void HandleUnmanagedConstant(CSharpOutputBuilder outputBuilder, InitListExpr ini outputBuilder.WriteIndented("ReadOnlySpan data = "); - if (_config.GeneratePreviewCode) + if (_config.GenerateLatestCode) { outputBuilder.WriteLine("["); } @@ -1519,7 +1519,7 @@ void HandleUnmanagedConstant(CSharpOutputBuilder outputBuilder, InitListExpr ini outputBuilder.WriteNewline(); outputBuilder.DecreaseIndentation(); - if (_config.GeneratePreviewCode) + if (_config.GenerateLatestCode) { outputBuilder.WriteIndented(']'); } @@ -2553,7 +2553,7 @@ private void VisitStringLiteral(StringLiteral stringLiteral) case CX_CLK_UTF32: { - if (_config.GeneratePreviewCode) + if (_config.GenerateLatestCode) { outputBuilder.Write('['); } @@ -2574,7 +2574,7 @@ private void VisitStringLiteral(StringLiteral stringLiteral) outputBuilder.Write("0x00000000"); - if (_config.GeneratePreviewCode) + if (_config.GenerateLatestCode) { outputBuilder.Write(']'); } diff --git a/sources/ClangSharpPInvokeGenerator/Program.cs b/sources/ClangSharpPInvokeGenerator/Program.cs index 146670ec..6b355de1 100644 --- a/sources/ClangSharpPInvokeGenerator/Program.cs +++ b/sources/ClangSharpPInvokeGenerator/Program.cs @@ -42,8 +42,8 @@ public static class Program private static readonly string[] s_remapOptionAliases = ["--remap", "-r"]; private static readonly string[] s_stdOptionAliases = ["--std", "-std"]; private static readonly string[] s_testOutputOptionAliases = ["--test-output", "-to"]; - private static readonly string[] s_versionOptionAliases = ["--version", "-v"]; private static readonly string[] s_traverseOptionAliases = ["--traverse", "-t"]; + private static readonly string[] s_versionOptionAliases = ["--version", "-v"]; private static readonly string[] s_withAccessSpecifierOptionAliases = ["--with-access-specifier", "-was"]; private static readonly string[] s_withAttributeOptionAliases = ["--with-attribute", "-wa"]; private static readonly string[] s_withCallConvOptionAliases = ["--with-callconv", "-wcc"]; @@ -52,12 +52,12 @@ public static class Program private static readonly string[] s_withLibraryPathOptionAliases = ["--with-librarypath", "-wlb"]; private static readonly string[] s_withManualImportOptionAliases = ["--with-manual-import", "-wmi"]; private static readonly string[] s_withNamespaceOptionAliases = ["--with-namespace", "-wn"]; + private static readonly string[] s_withPackingOptionAliases = ["--with-packing", "-wp"]; private static readonly string[] s_withSetLastErrorOptionAliases = ["--with-setlasterror", "-wsle"]; private static readonly string[] s_withSuppressGCTransitionOptionAliases = ["--with-suppressgctransition", "-wsgct"]; private static readonly string[] s_withTransparentStructOptionAliases = ["--with-transparent-struct", "-wts"]; private static readonly string[] s_withTypeOptionAliases = ["--with-type", "-wt"]; private static readonly string[] s_withUsingOptionAliases = ["--with-using", "-wu"]; - private static readonly string[] s_withPackingOptionAliases = ["--with-packing", "-wp"]; private static readonly Option s_additionalOption = GetAdditionalOption(); private static readonly Option s_configOption = GetConfigOption(); @@ -89,12 +89,12 @@ public static class Program private static readonly Option s_withLibraryPathNameValuePairs = GetWithLibraryPathOption(); private static readonly Option s_withManualImports = GetWithManualImportOption(); private static readonly Option s_withNamespaceNameValuePairs = GetWithNamespaceOption(); + private static readonly Option s_withPackingNameValuePairs = GetWithPackingOption(); private static readonly Option s_withSetLastErrors = GetWithSetLastErrorOption(); private static readonly Option s_withSuppressGCTransitions = GetWithSuppressGCTransitionOption(); private static readonly Option s_withTransparentStructNameValuePairs = GetWithTransparentStructOption(); private static readonly Option s_withTypeNameValuePairs = GetWithTypeOption(); private static readonly Option s_withUsingNameValuePairs = GetWithUsingOption(); - private static readonly Option s_withPackingNameValuePairs = GetWithPackingOption(); private static readonly RootCommand s_rootCommand = GetRootCommand(); @@ -102,24 +102,32 @@ public static class Program [ new TwoColumnHelpRow("?, h, help", "Show help and usage information for -c, --config"), - // Codegen Options + new TwoColumnHelpRow("", ""), + new TwoColumnHelpRow("# Codegen Options", ""), + new TwoColumnHelpRow("", ""), new TwoColumnHelpRow("compatible-codegen", "Bindings should be generated with .NET Standard 2.0 compatibility. Setting this disables preview code generation."), new TwoColumnHelpRow("default-codegen", "Bindings should be generated for the current LTS version of .NET/C#. This is currently .NET 6/C# 10."), new TwoColumnHelpRow("latest-codegen", "Bindings should be generated for the current STS version of .NET/C#. This is currently .NET 7/C# 11."), new TwoColumnHelpRow("preview-codegen", "Bindings should be generated for the preview version of .NET/C#. This is currently .NET 8/C# 12."), - // File Options + new TwoColumnHelpRow("", ""), + new TwoColumnHelpRow("# File Options", ""), + new TwoColumnHelpRow("", ""), new TwoColumnHelpRow("single-file", "Bindings should be generated to a single output file. This is the default."), new TwoColumnHelpRow("multi-file", "Bindings should be generated so there is approximately one type per file."), - // Type Options + new TwoColumnHelpRow("", ""), + new TwoColumnHelpRow("# Type Options", ""), + new TwoColumnHelpRow("", ""), new TwoColumnHelpRow("unix-types", "Bindings should be generated assuming Unix defaults. This is the default on Unix platforms."), new TwoColumnHelpRow("windows-types", "Bindings should be generated assuming Windows defaults. This is the default on Windows platforms."), - // Exclusion Options + new TwoColumnHelpRow("", ""), + new TwoColumnHelpRow("# Exclusion Options", ""), + new TwoColumnHelpRow("", ""), new TwoColumnHelpRow("exclude-anonymous-field-helpers", "The helper ref properties generated for fields in nested anonymous structs and unions should not be generated."), 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 new TwoColumnHelpRow("exclude-funcs-with-body", "Bindings for functions with bodies should not be generated."), new TwoColumnHelpRow("exclude-using-statics-for-enums", "Enum usages should be fully qualified and should not include a corresponding 'using static EnumName;'"), - // VTBL Options + new TwoColumnHelpRow("", ""), + new TwoColumnHelpRow("# Vtbl Options", ""), + new TwoColumnHelpRow("", ""), new TwoColumnHelpRow("explicit-vtbls", "VTBLs should have an explicit type generated with named fields per entry."), new TwoColumnHelpRow("implicit-vtbls", "VTBLs should be implicit to reduce metadata bloat. This is the current default"), new TwoColumnHelpRow("trimmable-vtbls", "VTBLs should be defined but not used in helper methods to reduce metadata bloat when trimming."), - // Test Options + new TwoColumnHelpRow("", ""), + new TwoColumnHelpRow("# Test Options", ""), + new TwoColumnHelpRow("", ""), new TwoColumnHelpRow("generate-tests-nunit", "Basic tests validating size, blittability, and associated metadata should be generated for NUnit."), new TwoColumnHelpRow("generate-tests-xunit", "Basic tests validating size, blittability, and associated metadata should be generated for XUnit."), - // Generation Options + new TwoColumnHelpRow("", ""), + new TwoColumnHelpRow("# Generation Options", ""), + new TwoColumnHelpRow("", ""), new TwoColumnHelpRow("generate-aggressive-inlining", "[MethodImpl(MethodImplOptions.AggressiveInlining)] should be added to generated helper functions."), new TwoColumnHelpRow("generate-callconv-member-function", "Instance function pointers should use [CallConvMemberFunction] where applicable."), @@ -160,7 +174,9 @@ public static class Program new TwoColumnHelpRow("generate-unmanaged-constants", "Unmanaged constants should be generated using static ref readonly properties. This is currently experimental."), new TwoColumnHelpRow("generate-vtbl-index-attribute", "[VtblIndex(#)] attribute should be generated to document the underlying VTBL index for a helper method."), - // Logging Options + new TwoColumnHelpRow("", ""), + new TwoColumnHelpRow("# Logging Options", ""), + new TwoColumnHelpRow("", ""), 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."), 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() s_withLibraryPathNameValuePairs, s_withManualImports, s_withNamespaceNameValuePairs, + s_withPackingNameValuePairs, s_withSetLastErrors, s_withSuppressGCTransitions, s_withTransparentStructNameValuePairs, s_withTypeNameValuePairs, - s_withUsingNameValuePairs, - s_withPackingNameValuePairs + s_withUsingNameValuePairs }; Handler.SetHandler(rootCommand, (Action)Run); return rootCommand; diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs index ab899ce0..179b83fb 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs @@ -591,9 +591,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -607,23 +605,10 @@ public partial struct MyOtherStruct [NativeTypeName(""MyStruct[3]"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - [UnscopedRef] - public ref MyStruct this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -645,9 +630,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -661,55 +644,10 @@ public partial struct MyOtherStruct [NativeTypeName(""MyStruct[2][1][3][4]"")] public _c_e__FixedBuffer c; + [InlineArray(2 * 1 * 3 * 4)] public partial struct _c_e__FixedBuffer {{ public MyStruct e0_0_0_0; - public MyStruct e1_0_0_0; - - public MyStruct e0_0_1_0; - public MyStruct e1_0_1_0; - - public MyStruct e0_0_2_0; - public MyStruct e1_0_2_0; - - public MyStruct e0_0_0_1; - public MyStruct e1_0_0_1; - - public MyStruct e0_0_1_1; - public MyStruct e1_0_1_1; - - public MyStruct e0_0_2_1; - public MyStruct e1_0_2_1; - - public MyStruct e0_0_0_2; - public MyStruct e1_0_0_2; - - public MyStruct e0_0_1_2; - public MyStruct e1_0_1_2; - - public MyStruct e0_0_2_2; - public MyStruct e1_0_2_2; - - public MyStruct e0_0_0_3; - public MyStruct e1_0_0_3; - - public MyStruct e0_0_1_3; - public MyStruct e1_0_1_3; - - public MyStruct e0_0_2_3; - public MyStruct e1_0_2_3; - - [UnscopedRef] - public ref MyStruct this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0_0_0_0, 24); }} }} }} @@ -733,9 +671,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -749,23 +685,10 @@ public partial struct MyOtherStruct [NativeTypeName(""MyBuffer"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - [UnscopedRef] - public ref MyStruct this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -787,9 +710,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -804,23 +725,10 @@ public partial struct MyOtherStruct [NativeTypeName(""MyStruct[3]"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - [UnscopedRef] - public ref MyStruct this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -1136,6 +1044,7 @@ struct MyStruct var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1274,24 +1183,10 @@ public partial struct _Anonymous2_e__Union public {expectedManagedType} value2; }} + [InlineArray(4)] public partial struct _buffer2_e__FixedBuffer {{ public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - public MyUnion e3; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 4); }} }} }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs index 2a5fbf26..8976884a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs @@ -350,8 +350,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -370,23 +369,10 @@ public partial struct MyOtherUnion [NativeTypeName(""MyUnion[3]"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -408,8 +394,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -428,55 +413,10 @@ public partial struct MyOtherUnion [NativeTypeName(""MyUnion[2][1][3][4]"")] public _c_e__FixedBuffer c; + [InlineArray(2 * 1 * 3 * 4)] public partial struct _c_e__FixedBuffer {{ public MyUnion e0_0_0_0; - public MyUnion e1_0_0_0; - - public MyUnion e0_0_1_0; - public MyUnion e1_0_1_0; - - public MyUnion e0_0_2_0; - public MyUnion e1_0_2_0; - - public MyUnion e0_0_0_1; - public MyUnion e1_0_0_1; - - public MyUnion e0_0_1_1; - public MyUnion e1_0_1_1; - - public MyUnion e0_0_2_1; - public MyUnion e1_0_2_1; - - public MyUnion e0_0_0_2; - public MyUnion e1_0_0_2; - - public MyUnion e0_0_1_2; - public MyUnion e1_0_1_2; - - public MyUnion e0_0_2_2; - public MyUnion e1_0_2_2; - - public MyUnion e0_0_0_3; - public MyUnion e1_0_0_3; - - public MyUnion e0_0_1_3; - public MyUnion e1_0_1_3; - - public MyUnion e0_0_2_3; - public MyUnion e1_0_2_3; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0_0_0_0, 24); }} }} }} @@ -500,8 +440,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -520,23 +459,10 @@ public partial struct MyOtherUnion [NativeTypeName(""MyBuffer"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -558,8 +484,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -579,23 +504,10 @@ public partial struct MyOtherUnion [NativeTypeName(""MyUnion[3]"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs index 00fbbb56..c72f00c1 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs @@ -158,23 +158,25 @@ protected override Task WideStringLiteralConstTestImpl() const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"using System; + +namespace ClangSharp.Test {{ public static partial class Methods {{ [NativeTypeName(""const wchar_t[11]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; + public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; + public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; + public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; }} }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); } protected override Task StringLiteralConstTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs index 17a62b5f..381c0f4d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs @@ -599,9 +599,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -615,23 +613,10 @@ public partial struct MyOtherStruct [NativeTypeName(""MyStruct[3]"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - [UnscopedRef] - public ref MyStruct this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -653,9 +638,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -669,55 +652,10 @@ public partial struct MyOtherStruct [NativeTypeName(""MyStruct[2][1][3][4]"")] public _c_e__FixedBuffer c; + [InlineArray(2 * 1 * 3 * 4)] public partial struct _c_e__FixedBuffer {{ public MyStruct e0_0_0_0; - public MyStruct e1_0_0_0; - - public MyStruct e0_0_1_0; - public MyStruct e1_0_1_0; - - public MyStruct e0_0_2_0; - public MyStruct e1_0_2_0; - - public MyStruct e0_0_0_1; - public MyStruct e1_0_0_1; - - public MyStruct e0_0_1_1; - public MyStruct e1_0_1_1; - - public MyStruct e0_0_2_1; - public MyStruct e1_0_2_1; - - public MyStruct e0_0_0_2; - public MyStruct e1_0_0_2; - - public MyStruct e0_0_1_2; - public MyStruct e1_0_1_2; - - public MyStruct e0_0_2_2; - public MyStruct e1_0_2_2; - - public MyStruct e0_0_0_3; - public MyStruct e1_0_0_3; - - public MyStruct e0_0_1_3; - public MyStruct e1_0_1_3; - - public MyStruct e0_0_2_3; - public MyStruct e1_0_2_3; - - [UnscopedRef] - public ref MyStruct this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0_0_0_0, 24); }} }} }} @@ -741,9 +679,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -757,23 +693,10 @@ public partial struct MyOtherStruct [NativeTypeName(""MyBuffer"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - [UnscopedRef] - public ref MyStruct this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -795,9 +718,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -812,23 +733,10 @@ public partial struct MyOtherStruct [NativeTypeName(""MyStruct[3]"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - [UnscopedRef] - public ref MyStruct this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -1144,6 +1052,7 @@ struct MyStruct var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1282,24 +1191,10 @@ public partial struct _Anonymous2_e__Union public {expectedManagedType} value2; }} + [InlineArray(4)] public partial struct _buffer2_e__FixedBuffer {{ public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - public MyUnion e3; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 4); }} }} }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs index 14338655..736cbed5 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs @@ -356,8 +356,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -376,23 +375,10 @@ public partial struct MyOtherUnion [NativeTypeName(""MyUnion[3]"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -414,8 +400,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -434,55 +419,10 @@ public partial struct MyOtherUnion [NativeTypeName(""MyUnion[2][1][3][4]"")] public _c_e__FixedBuffer c; + [InlineArray(2 * 1 * 3 * 4)] public partial struct _c_e__FixedBuffer {{ public MyUnion e0_0_0_0; - public MyUnion e1_0_0_0; - - public MyUnion e0_0_1_0; - public MyUnion e1_0_1_0; - - public MyUnion e0_0_2_0; - public MyUnion e1_0_2_0; - - public MyUnion e0_0_0_1; - public MyUnion e1_0_0_1; - - public MyUnion e0_0_1_1; - public MyUnion e1_0_1_1; - - public MyUnion e0_0_2_1; - public MyUnion e1_0_2_1; - - public MyUnion e0_0_0_2; - public MyUnion e1_0_0_2; - - public MyUnion e0_0_1_2; - public MyUnion e1_0_1_2; - - public MyUnion e0_0_2_2; - public MyUnion e1_0_2_2; - - public MyUnion e0_0_0_3; - public MyUnion e1_0_0_3; - - public MyUnion e0_0_1_3; - public MyUnion e1_0_1_3; - - public MyUnion e0_0_2_3; - public MyUnion e1_0_2_3; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0_0_0_0, 24); }} }} }} @@ -506,8 +446,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -526,23 +465,10 @@ public partial struct MyOtherUnion [NativeTypeName(""MyBuffer"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} @@ -564,8 +490,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -585,23 +510,10 @@ public partial struct MyOtherUnion [NativeTypeName(""MyUnion[3]"")] public _c_e__FixedBuffer c; + [InlineArray(3)] public partial struct _c_e__FixedBuffer {{ public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - [UnscopedRef] - public ref MyUnion this[int index] - {{ - get - {{ - return ref AsSpan()[index]; - }} - }} - - [UnscopedRef] - public Span AsSpan() => MemoryMarshal.CreateSpan(ref e0, 3); }} }} }} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs index 6fbe2884..5e523142 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs @@ -541,28 +541,10 @@ struct MyOtherStruct MyStruct + InlineArray(3) MyStruct - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - return ref AsSpan()[index]; - - - - Span<MyStruct> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -598,91 +580,10 @@ struct MyOtherStruct MyStruct + InlineArray(2 * 1 * 3 * 4) MyStruct - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - return ref AsSpan()[index]; - - - - Span<MyStruct> - MemoryMarshal.CreateSpan(ref e0_0_0_0, 24); - @@ -720,28 +621,10 @@ struct MyOtherStruct MyStruct + InlineArray(3) MyStruct - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - return ref AsSpan()[index]; - - - - Span<MyStruct> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -777,28 +660,10 @@ struct MyOtherStruct MyStruct + InlineArray(3) MyStruct - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - return ref AsSpan()[index]; - - - - Span<MyStruct> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -1189,31 +1054,10 @@ struct MyStruct + InlineArray(4) MyUnion - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0, 4); - diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs index ce508bf7..2a04f051 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs @@ -308,28 +308,10 @@ union MyOtherUnion MyUnion + InlineArray(3) MyUnion - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -365,91 +347,10 @@ union MyOtherUnion MyUnion + InlineArray(2 * 1 * 3 * 4) MyUnion - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0_0_0_0, 24); - @@ -487,28 +388,10 @@ union MyOtherUnion MyUnion + InlineArray(3) MyUnion - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -544,28 +427,10 @@ union MyOtherUnion MyUnion + InlineArray(3) MyUnion - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0, 3); - diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs index 26187922..7092a765 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs @@ -200,19 +200,19 @@ protected override Task WideStringLiteralConstTestImpl() ReadOnlySpan<uint> - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] ReadOnlySpan<uint> - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] @@ -272,19 +272,19 @@ protected override Task WideStringLiteralStaticConstTestImpl() ReadOnlySpan<uint> - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] uint[] - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] ReadOnlySpan<uint> - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs index 7ceab0a9..dfcf8a15 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs @@ -553,28 +553,10 @@ struct MyOtherStruct MyStruct + InlineArray(3) MyStruct - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - return ref AsSpan()[index]; - - - - Span<MyStruct> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -610,91 +592,10 @@ struct MyOtherStruct MyStruct + InlineArray(2 * 1 * 3 * 4) MyStruct - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - return ref AsSpan()[index]; - - - - Span<MyStruct> - MemoryMarshal.CreateSpan(ref e0_0_0_0, 24); - @@ -732,28 +633,10 @@ struct MyOtherStruct MyStruct + InlineArray(3) MyStruct - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - return ref AsSpan()[index]; - - - - Span<MyStruct> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -789,28 +672,10 @@ struct MyOtherStruct MyStruct + InlineArray(3) MyStruct - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - return ref AsSpan()[index]; - - - - Span<MyStruct> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -1201,31 +1066,10 @@ struct MyStruct + InlineArray(4) MyUnion - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0, 4); - diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs index 74376381..e1116cb6 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs @@ -314,28 +314,10 @@ union MyOtherUnion MyUnion + InlineArray(3) MyUnion - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -371,91 +353,10 @@ union MyOtherUnion MyUnion + InlineArray(2 * 1 * 3 * 4) MyUnion - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0_0_0_0, 24); - @@ -493,28 +394,10 @@ union MyOtherUnion MyUnion + InlineArray(3) MyUnion - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0, 3); - @@ -550,28 +433,10 @@ union MyOtherUnion MyUnion + InlineArray(3) MyUnion - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - return ref AsSpan()[index]; - - - - Span<MyUnion> - MemoryMarshal.CreateSpan(ref e0, 3); -