diff --git a/.editorconfig b/.editorconfig index d57b44be..e0151b57 100644 --- a/.editorconfig +++ b/.editorconfig @@ -21,6 +21,7 @@ end_of_line = lf insert_final_newline = true indent_style = space indent_size = 4 +tab_width = 4 trim_trailing_whitespace = true ############################################################################### @@ -176,6 +177,7 @@ dotnet_sort_system_directives_first = true # require null-coalescing expressions, # require collection-initializers, # require explicit tuple names, +# suggest namespace match folder names, # require null-propogation # require object-initializers, # @@ -210,6 +212,7 @@ dotnet_sort_system_directives_first = true dotnet_style_coalesce_expression = true:error dotnet_style_collection_initializer = true:error dotnet_style_explicit_tuple_names = true:error +dotnet_style_namespace_match_folder = true:suggestion dotnet_style_null_propagation = true:error dotnet_style_object_initializer = true:error @@ -372,16 +375,18 @@ csharp_space_between_square_brackets = false # require expression-bodied operators when on a single line, # require expression-bodied properties when on a single line, # -# error on simplified new expression, +# error on new expressions when created type is apparent # # require inlined variable declarations, # +# require file scoped namespace declarations, +# # require local over anonymous functions, # require pattern-matching over "as" with "null" check, # require pattern-matching over "is" with "cast" check, # -# require index operators where possible, -# require range operators where possible, +# error on index operators where possible, +# error on range operators where possible, # require the "not" pattern where possible, # require pattern-matching where possible, # require switch expressions where possible, @@ -412,14 +417,17 @@ csharp_style_implicit_object_creation_when_type_is_apparent = false:error csharp_style_inlined_variable_declaration = true:error +csharp_style_namespace_declarations = file_scoped:error + csharp_style_pattern_local_over_anonymous_function = true:error csharp_style_pattern_matching_over_as_with_null_check = true:error csharp_style_pattern_matching_over_is_with_cast_check = true:error -csharp_style_prefer_index_operator = true:error -csharp_style_prefer_range_operator = true:error +csharp_style_prefer_index_operator = false:error +csharp_style_prefer_method_group_conversion = true:suggestion csharp_style_prefer_not_pattern = true:error csharp_style_prefer_pattern_matching = true:error +csharp_style_prefer_range_operator = false:error csharp_style_prefer_switch_expression = true:error csharp_style_throw_expression = true:error @@ -439,8 +447,7 @@ csharp_style_var_when_type_is_apparent = true:error csharp_using_directive_placement = outside_namespace:error ############################################################################### -# Supress diagnostics that don't apply to ClangSharp +# Set dotnet analyzer rules to: +# disable CA1401: P/Invoke method '*' should not be visible ############################################################################### -dotnet_diagnostic.CA1069.severity = none -dotnet_diagnostic.CA1826.severity = none -dotnet_diagnostic.IDE0060.severity = none +dotnet_diagnostic.CA1401.severity = silent diff --git a/sources/ClangSharp.Interop/.editorconfig b/sources/ClangSharp.Interop/.editorconfig index ec18c8f6..94ffcc6b 100644 --- a/sources/ClangSharp.Interop/.editorconfig +++ b/sources/ClangSharp.Interop/.editorconfig @@ -1,3 +1,5 @@ +# Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + ############################################################################### # EditorConfig is awesome: http://EditorConfig.org ############################################################################### @@ -23,6 +25,17 @@ dotnet_naming_rule.public_and_protected_declarations_should_be_pascal_case.sever dotnet_naming_rule.type_parameters_should_be_pascal_case_prefixed_with_t.severity = none ############################################################################### -# Supress diagnostics that don't apply to ClangSharp P/Invokes -############################################################################### -dotnet_diagnostic.CA1401.severity = none +# Set dotnet style options to: +# disable certain parent style options since they are not applicable to interop +############################################################################### +csharp_style_expression_bodied_methods = when_on_single_line:none +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:none +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:none +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:none +dotnet_style_prefer_conditional_expression_over_assignment = true:none +dotnet_style_prefer_conditional_expression_over_return = true:none +csharp_style_prefer_pattern_matching = true:none +csharp_style_var_elsewhere = true:none +csharp_style_var_for_built_in_types = true:none +csharp_style_var_when_type_is_apparent = true:none diff --git a/sources/ClangSharp.Interop/CXAvailabilityKind.cs b/sources/ClangSharp.Interop/CXAvailabilityKind.cs index 48d3ba04..463b6d4a 100644 --- a/sources/ClangSharp.Interop/CXAvailabilityKind.cs +++ b/sources/ClangSharp.Interop/CXAvailabilityKind.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXAvailabilityKind { - public enum CXAvailabilityKind - { - CXAvailability_Available, - CXAvailability_Deprecated, - CXAvailability_NotAvailable, - CXAvailability_NotAccessible, - } + CXAvailability_Available, + CXAvailability_Deprecated, + CXAvailability_NotAvailable, + CXAvailability_NotAccessible, } diff --git a/sources/ClangSharp.Interop/CXCallingConv.cs b/sources/ClangSharp.Interop/CXCallingConv.cs index 45891705..b6614aa4 100644 --- a/sources/ClangSharp.Interop/CXCallingConv.cs +++ b/sources/ClangSharp.Interop/CXCallingConv.cs @@ -3,30 +3,29 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCallingConv { - public enum CXCallingConv - { - CXCallingConv_Default = 0, - CXCallingConv_C = 1, - CXCallingConv_X86StdCall = 2, - CXCallingConv_X86FastCall = 3, - CXCallingConv_X86ThisCall = 4, - CXCallingConv_X86Pascal = 5, - CXCallingConv_AAPCS = 6, - CXCallingConv_AAPCS_VFP = 7, - CXCallingConv_X86RegCall = 8, - CXCallingConv_IntelOclBicc = 9, - CXCallingConv_Win64 = 10, - CXCallingConv_X86_64Win64 = CXCallingConv_Win64, - CXCallingConv_X86_64SysV = 11, - CXCallingConv_X86VectorCall = 12, - CXCallingConv_Swift = 13, - CXCallingConv_PreserveMost = 14, - CXCallingConv_PreserveAll = 15, - CXCallingConv_AArch64VectorCall = 16, - CXCallingConv_SwiftAsync = 17, - CXCallingConv_Invalid = 100, - CXCallingConv_Unexposed = 200, - } + CXCallingConv_Default = 0, + CXCallingConv_C = 1, + CXCallingConv_X86StdCall = 2, + CXCallingConv_X86FastCall = 3, + CXCallingConv_X86ThisCall = 4, + CXCallingConv_X86Pascal = 5, + CXCallingConv_AAPCS = 6, + CXCallingConv_AAPCS_VFP = 7, + CXCallingConv_X86RegCall = 8, + CXCallingConv_IntelOclBicc = 9, + CXCallingConv_Win64 = 10, + CXCallingConv_X86_64Win64 = CXCallingConv_Win64, + CXCallingConv_X86_64SysV = 11, + CXCallingConv_X86VectorCall = 12, + CXCallingConv_Swift = 13, + CXCallingConv_PreserveMost = 14, + CXCallingConv_PreserveAll = 15, + CXCallingConv_AArch64VectorCall = 16, + CXCallingConv_SwiftAsync = 17, + CXCallingConv_Invalid = 100, + CXCallingConv_Unexposed = 200, } diff --git a/sources/ClangSharp.Interop/CXChildVisitResult.cs b/sources/ClangSharp.Interop/CXChildVisitResult.cs index 5c308dcd..20405710 100644 --- a/sources/ClangSharp.Interop/CXChildVisitResult.cs +++ b/sources/ClangSharp.Interop/CXChildVisitResult.cs @@ -3,12 +3,11 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXChildVisitResult { - public enum CXChildVisitResult - { - CXChildVisit_Break, - CXChildVisit_Continue, - CXChildVisit_Recurse, - } + CXChildVisit_Break, + CXChildVisit_Continue, + CXChildVisit_Recurse, } diff --git a/sources/ClangSharp.Interop/CXCodeCompleteResults.cs b/sources/ClangSharp.Interop/CXCodeCompleteResults.cs index c22b42b0..ed1b5ad0 100644 --- a/sources/ClangSharp.Interop/CXCodeCompleteResults.cs +++ b/sources/ClangSharp.Interop/CXCodeCompleteResults.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXCodeCompleteResults { - public unsafe partial struct CXCodeCompleteResults - { - public CXCompletionResult* Results; + public CXCompletionResult* Results; - [NativeTypeName("unsigned int")] - public uint NumResults; - } + [NativeTypeName("unsigned int")] + public uint NumResults; } diff --git a/sources/ClangSharp.Interop/CXCodeComplete_Flags.cs b/sources/ClangSharp.Interop/CXCodeComplete_Flags.cs index 262fcf13..b2186a94 100644 --- a/sources/ClangSharp.Interop/CXCodeComplete_Flags.cs +++ b/sources/ClangSharp.Interop/CXCodeComplete_Flags.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCodeComplete_Flags { - public enum CXCodeComplete_Flags - { - CXCodeComplete_IncludeMacros = 0x01, - CXCodeComplete_IncludeCodePatterns = 0x02, - CXCodeComplete_IncludeBriefComments = 0x04, - CXCodeComplete_SkipPreamble = 0x08, - CXCodeComplete_IncludeCompletionsWithFixIts = 0x10, - } + CXCodeComplete_IncludeMacros = 0x01, + CXCodeComplete_IncludeCodePatterns = 0x02, + CXCodeComplete_IncludeBriefComments = 0x04, + CXCodeComplete_SkipPreamble = 0x08, + CXCodeComplete_IncludeCompletionsWithFixIts = 0x10, } diff --git a/sources/ClangSharp.Interop/CXComment.cs b/sources/ClangSharp.Interop/CXComment.cs index 53f57c77..a623e7ba 100644 --- a/sources/ClangSharp.Interop/CXComment.cs +++ b/sources/ClangSharp.Interop/CXComment.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXComment { - public unsafe partial struct CXComment - { - [NativeTypeName("const void *")] - public void* ASTNode; + [NativeTypeName("const void *")] + public void* ASTNode; - [NativeTypeName("CXTranslationUnit")] - public CXTranslationUnitImpl* TranslationUnit; - } + [NativeTypeName("CXTranslationUnit")] + public CXTranslationUnitImpl* TranslationUnit; } diff --git a/sources/ClangSharp.Interop/CXCommentInlineCommandRenderKind.cs b/sources/ClangSharp.Interop/CXCommentInlineCommandRenderKind.cs index 142de8ff..de769b0c 100644 --- a/sources/ClangSharp.Interop/CXCommentInlineCommandRenderKind.cs +++ b/sources/ClangSharp.Interop/CXCommentInlineCommandRenderKind.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCommentInlineCommandRenderKind { - public enum CXCommentInlineCommandRenderKind - { - CXCommentInlineCommandRenderKind_Normal, - CXCommentInlineCommandRenderKind_Bold, - CXCommentInlineCommandRenderKind_Monospaced, - CXCommentInlineCommandRenderKind_Emphasized, - CXCommentInlineCommandRenderKind_Anchor, - } + CXCommentInlineCommandRenderKind_Normal, + CXCommentInlineCommandRenderKind_Bold, + CXCommentInlineCommandRenderKind_Monospaced, + CXCommentInlineCommandRenderKind_Emphasized, + CXCommentInlineCommandRenderKind_Anchor, } diff --git a/sources/ClangSharp.Interop/CXCommentKind.cs b/sources/ClangSharp.Interop/CXCommentKind.cs index 494cbef4..60909df0 100644 --- a/sources/ClangSharp.Interop/CXCommentKind.cs +++ b/sources/ClangSharp.Interop/CXCommentKind.cs @@ -3,22 +3,21 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCommentKind { - public enum CXCommentKind - { - CXComment_Null = 0, - CXComment_Text = 1, - CXComment_InlineCommand = 2, - CXComment_HTMLStartTag = 3, - CXComment_HTMLEndTag = 4, - CXComment_Paragraph = 5, - CXComment_BlockCommand = 6, - CXComment_ParamCommand = 7, - CXComment_TParamCommand = 8, - CXComment_VerbatimBlockCommand = 9, - CXComment_VerbatimBlockLine = 10, - CXComment_VerbatimLine = 11, - CXComment_FullComment = 12, - } + CXComment_Null = 0, + CXComment_Text = 1, + CXComment_InlineCommand = 2, + CXComment_HTMLStartTag = 3, + CXComment_HTMLEndTag = 4, + CXComment_Paragraph = 5, + CXComment_BlockCommand = 6, + CXComment_ParamCommand = 7, + CXComment_TParamCommand = 8, + CXComment_VerbatimBlockCommand = 9, + CXComment_VerbatimBlockLine = 10, + CXComment_VerbatimLine = 11, + CXComment_FullComment = 12, } diff --git a/sources/ClangSharp.Interop/CXCommentParamPassDirection.cs b/sources/ClangSharp.Interop/CXCommentParamPassDirection.cs index 558917e5..6a1e667c 100644 --- a/sources/ClangSharp.Interop/CXCommentParamPassDirection.cs +++ b/sources/ClangSharp.Interop/CXCommentParamPassDirection.cs @@ -3,12 +3,11 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCommentParamPassDirection { - public enum CXCommentParamPassDirection - { - CXCommentParamPassDirection_In, - CXCommentParamPassDirection_Out, - CXCommentParamPassDirection_InOut, - } + CXCommentParamPassDirection_In, + CXCommentParamPassDirection_Out, + CXCommentParamPassDirection_InOut, } diff --git a/sources/ClangSharp.Interop/CXCompilationDatabase_Error.cs b/sources/ClangSharp.Interop/CXCompilationDatabase_Error.cs index dd4d96ca..fe30ede2 100644 --- a/sources/ClangSharp.Interop/CXCompilationDatabase_Error.cs +++ b/sources/ClangSharp.Interop/CXCompilationDatabase_Error.cs @@ -3,11 +3,10 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCompilationDatabase_Error { - public enum CXCompilationDatabase_Error - { - CXCompilationDatabase_NoError = 0, - CXCompilationDatabase_CanNotLoadDatabase = 1, - } + CXCompilationDatabase_NoError = 0, + CXCompilationDatabase_CanNotLoadDatabase = 1, } diff --git a/sources/ClangSharp.Interop/CXCompletionChunkKind.cs b/sources/ClangSharp.Interop/CXCompletionChunkKind.cs index 7075721a..98bdaa9f 100644 --- a/sources/ClangSharp.Interop/CXCompletionChunkKind.cs +++ b/sources/ClangSharp.Interop/CXCompletionChunkKind.cs @@ -3,30 +3,29 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCompletionChunkKind { - public enum CXCompletionChunkKind - { - CXCompletionChunk_Optional, - CXCompletionChunk_TypedText, - CXCompletionChunk_Text, - CXCompletionChunk_Placeholder, - CXCompletionChunk_Informative, - CXCompletionChunk_CurrentParameter, - CXCompletionChunk_LeftParen, - CXCompletionChunk_RightParen, - CXCompletionChunk_LeftBracket, - CXCompletionChunk_RightBracket, - CXCompletionChunk_LeftBrace, - CXCompletionChunk_RightBrace, - CXCompletionChunk_LeftAngle, - CXCompletionChunk_RightAngle, - CXCompletionChunk_Comma, - CXCompletionChunk_ResultType, - CXCompletionChunk_Colon, - CXCompletionChunk_SemiColon, - CXCompletionChunk_Equal, - CXCompletionChunk_HorizontalSpace, - CXCompletionChunk_VerticalSpace, - } + CXCompletionChunk_Optional, + CXCompletionChunk_TypedText, + CXCompletionChunk_Text, + CXCompletionChunk_Placeholder, + CXCompletionChunk_Informative, + CXCompletionChunk_CurrentParameter, + CXCompletionChunk_LeftParen, + CXCompletionChunk_RightParen, + CXCompletionChunk_LeftBracket, + CXCompletionChunk_RightBracket, + CXCompletionChunk_LeftBrace, + CXCompletionChunk_RightBrace, + CXCompletionChunk_LeftAngle, + CXCompletionChunk_RightAngle, + CXCompletionChunk_Comma, + CXCompletionChunk_ResultType, + CXCompletionChunk_Colon, + CXCompletionChunk_SemiColon, + CXCompletionChunk_Equal, + CXCompletionChunk_HorizontalSpace, + CXCompletionChunk_VerticalSpace, } diff --git a/sources/ClangSharp.Interop/CXCompletionContext.cs b/sources/ClangSharp.Interop/CXCompletionContext.cs index 3b4d64ce..7fc5e4fa 100644 --- a/sources/ClangSharp.Interop/CXCompletionContext.cs +++ b/sources/ClangSharp.Interop/CXCompletionContext.cs @@ -3,34 +3,33 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCompletionContext { - public enum CXCompletionContext - { - CXCompletionContext_Unexposed = 0, - CXCompletionContext_AnyType = 1 << 0, - CXCompletionContext_AnyValue = 1 << 1, - CXCompletionContext_ObjCObjectValue = 1 << 2, - CXCompletionContext_ObjCSelectorValue = 1 << 3, - CXCompletionContext_CXXClassTypeValue = 1 << 4, - CXCompletionContext_DotMemberAccess = 1 << 5, - CXCompletionContext_ArrowMemberAccess = 1 << 6, - CXCompletionContext_ObjCPropertyAccess = 1 << 7, - CXCompletionContext_EnumTag = 1 << 8, - CXCompletionContext_UnionTag = 1 << 9, - CXCompletionContext_StructTag = 1 << 10, - CXCompletionContext_ClassTag = 1 << 11, - CXCompletionContext_Namespace = 1 << 12, - CXCompletionContext_NestedNameSpecifier = 1 << 13, - CXCompletionContext_ObjCInterface = 1 << 14, - CXCompletionContext_ObjCProtocol = 1 << 15, - CXCompletionContext_ObjCCategory = 1 << 16, - CXCompletionContext_ObjCInstanceMessage = 1 << 17, - CXCompletionContext_ObjCClassMessage = 1 << 18, - CXCompletionContext_ObjCSelectorName = 1 << 19, - CXCompletionContext_MacroName = 1 << 20, - CXCompletionContext_NaturalLanguage = 1 << 21, - CXCompletionContext_IncludedFile = 1 << 22, - CXCompletionContext_Unknown = ((1 << 23) - 1), - } + CXCompletionContext_Unexposed = 0, + CXCompletionContext_AnyType = 1 << 0, + CXCompletionContext_AnyValue = 1 << 1, + CXCompletionContext_ObjCObjectValue = 1 << 2, + CXCompletionContext_ObjCSelectorValue = 1 << 3, + CXCompletionContext_CXXClassTypeValue = 1 << 4, + CXCompletionContext_DotMemberAccess = 1 << 5, + CXCompletionContext_ArrowMemberAccess = 1 << 6, + CXCompletionContext_ObjCPropertyAccess = 1 << 7, + CXCompletionContext_EnumTag = 1 << 8, + CXCompletionContext_UnionTag = 1 << 9, + CXCompletionContext_StructTag = 1 << 10, + CXCompletionContext_ClassTag = 1 << 11, + CXCompletionContext_Namespace = 1 << 12, + CXCompletionContext_NestedNameSpecifier = 1 << 13, + CXCompletionContext_ObjCInterface = 1 << 14, + CXCompletionContext_ObjCProtocol = 1 << 15, + CXCompletionContext_ObjCCategory = 1 << 16, + CXCompletionContext_ObjCInstanceMessage = 1 << 17, + CXCompletionContext_ObjCClassMessage = 1 << 18, + CXCompletionContext_ObjCSelectorName = 1 << 19, + CXCompletionContext_MacroName = 1 << 20, + CXCompletionContext_NaturalLanguage = 1 << 21, + CXCompletionContext_IncludedFile = 1 << 22, + CXCompletionContext_Unknown = ((1 << 23) - 1), } diff --git a/sources/ClangSharp.Interop/CXCompletionResult.cs b/sources/ClangSharp.Interop/CXCompletionResult.cs index 10a00e19..811dc9fe 100644 --- a/sources/ClangSharp.Interop/CXCompletionResult.cs +++ b/sources/ClangSharp.Interop/CXCompletionResult.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXCompletionResult { - public unsafe partial struct CXCompletionResult - { - [NativeTypeName("enum CXCursorKind")] - public CXCursorKind CursorKind; + [NativeTypeName("enum CXCursorKind")] + public CXCursorKind CursorKind; - [NativeTypeName("CXCompletionString")] - public void* CompletionString; - } + [NativeTypeName("CXCompletionString")] + public void* CompletionString; } diff --git a/sources/ClangSharp.Interop/CXCursor.cs b/sources/ClangSharp.Interop/CXCursor.cs index 6797955d..51314399 100644 --- a/sources/ClangSharp.Interop/CXCursor.cs +++ b/sources/ClangSharp.Interop/CXCursor.cs @@ -3,32 +3,31 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXCursor { - public partial struct CXCursor - { - [NativeTypeName("enum CXCursorKind")] - public CXCursorKind kind; + [NativeTypeName("enum CXCursorKind")] + public CXCursorKind kind; - public int xdata; + public int xdata; - [NativeTypeName("const void *[3]")] - public _data_e__FixedBuffer data; + [NativeTypeName("const void *[3]")] + public _data_e__FixedBuffer data; - public unsafe partial struct _data_e__FixedBuffer - { - public void* e0; - public void* e1; - public void* e2; + public unsafe partial struct _data_e__FixedBuffer + { + public void* e0; + public void* e1; + public void* e2; - public ref void* this[int index] + public ref void* this[int index] + { + get { - get + fixed (void** pThis = &e0) { - fixed (void** pThis = &e0) - { - return ref pThis[index]; - } + return ref pThis[index]; } } } diff --git a/sources/ClangSharp.Interop/CXCursorAndRangeVisitor.cs b/sources/ClangSharp.Interop/CXCursorAndRangeVisitor.cs index 970e002e..9dec40af 100644 --- a/sources/ClangSharp.Interop/CXCursorAndRangeVisitor.cs +++ b/sources/ClangSharp.Interop/CXCursorAndRangeVisitor.cs @@ -5,13 +5,12 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXCursorAndRangeVisitor { - public unsafe partial struct CXCursorAndRangeVisitor - { - public void* context; + public void* context; - [NativeTypeName("enum CXVisitorResult (*)(void *, CXCursor, CXSourceRange)")] - public IntPtr visit; - } + [NativeTypeName("enum CXVisitorResult (*)(void *, CXCursor, CXSourceRange)")] + public IntPtr visit; } diff --git a/sources/ClangSharp.Interop/CXCursorKind.cs b/sources/ClangSharp.Interop/CXCursorKind.cs index 036950ef..2f9c2004 100644 --- a/sources/ClangSharp.Interop/CXCursorKind.cs +++ b/sources/ClangSharp.Interop/CXCursorKind.cs @@ -3,282 +3,281 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCursorKind { - public enum CXCursorKind - { - CXCursor_UnexposedDecl = 1, - CXCursor_StructDecl = 2, - CXCursor_UnionDecl = 3, - CXCursor_ClassDecl = 4, - CXCursor_EnumDecl = 5, - CXCursor_FieldDecl = 6, - CXCursor_EnumConstantDecl = 7, - CXCursor_FunctionDecl = 8, - CXCursor_VarDecl = 9, - CXCursor_ParmDecl = 10, - CXCursor_ObjCInterfaceDecl = 11, - CXCursor_ObjCCategoryDecl = 12, - CXCursor_ObjCProtocolDecl = 13, - CXCursor_ObjCPropertyDecl = 14, - CXCursor_ObjCIvarDecl = 15, - CXCursor_ObjCInstanceMethodDecl = 16, - CXCursor_ObjCClassMethodDecl = 17, - CXCursor_ObjCImplementationDecl = 18, - CXCursor_ObjCCategoryImplDecl = 19, - CXCursor_TypedefDecl = 20, - CXCursor_CXXMethod = 21, - CXCursor_Namespace = 22, - CXCursor_LinkageSpec = 23, - CXCursor_Constructor = 24, - CXCursor_Destructor = 25, - CXCursor_ConversionFunction = 26, - CXCursor_TemplateTypeParameter = 27, - CXCursor_NonTypeTemplateParameter = 28, - CXCursor_TemplateTemplateParameter = 29, - CXCursor_FunctionTemplate = 30, - CXCursor_ClassTemplate = 31, - CXCursor_ClassTemplatePartialSpecialization = 32, - CXCursor_NamespaceAlias = 33, - CXCursor_UsingDirective = 34, - CXCursor_UsingDeclaration = 35, - CXCursor_TypeAliasDecl = 36, - CXCursor_ObjCSynthesizeDecl = 37, - CXCursor_ObjCDynamicDecl = 38, - CXCursor_CXXAccessSpecifier = 39, - CXCursor_FirstDecl = CXCursor_UnexposedDecl, - CXCursor_LastDecl = CXCursor_CXXAccessSpecifier, - CXCursor_FirstRef = 40, - CXCursor_ObjCSuperClassRef = 40, - CXCursor_ObjCProtocolRef = 41, - CXCursor_ObjCClassRef = 42, - CXCursor_TypeRef = 43, - CXCursor_CXXBaseSpecifier = 44, - CXCursor_TemplateRef = 45, - CXCursor_NamespaceRef = 46, - CXCursor_MemberRef = 47, - CXCursor_LabelRef = 48, - CXCursor_OverloadedDeclRef = 49, - CXCursor_VariableRef = 50, - CXCursor_LastRef = CXCursor_VariableRef, - CXCursor_FirstInvalid = 70, - CXCursor_InvalidFile = 70, - CXCursor_NoDeclFound = 71, - CXCursor_NotImplemented = 72, - CXCursor_InvalidCode = 73, - CXCursor_LastInvalid = CXCursor_InvalidCode, - CXCursor_FirstExpr = 100, - CXCursor_UnexposedExpr = 100, - CXCursor_DeclRefExpr = 101, - CXCursor_MemberRefExpr = 102, - CXCursor_CallExpr = 103, - CXCursor_ObjCMessageExpr = 104, - CXCursor_BlockExpr = 105, - CXCursor_IntegerLiteral = 106, - CXCursor_FloatingLiteral = 107, - CXCursor_ImaginaryLiteral = 108, - CXCursor_StringLiteral = 109, - CXCursor_CharacterLiteral = 110, - CXCursor_ParenExpr = 111, - CXCursor_UnaryOperator = 112, - CXCursor_ArraySubscriptExpr = 113, - CXCursor_BinaryOperator = 114, - CXCursor_CompoundAssignOperator = 115, - CXCursor_ConditionalOperator = 116, - CXCursor_CStyleCastExpr = 117, - CXCursor_CompoundLiteralExpr = 118, - CXCursor_InitListExpr = 119, - CXCursor_AddrLabelExpr = 120, - CXCursor_StmtExpr = 121, - CXCursor_GenericSelectionExpr = 122, - CXCursor_GNUNullExpr = 123, - CXCursor_CXXStaticCastExpr = 124, - CXCursor_CXXDynamicCastExpr = 125, - CXCursor_CXXReinterpretCastExpr = 126, - CXCursor_CXXConstCastExpr = 127, - CXCursor_CXXFunctionalCastExpr = 128, - CXCursor_CXXTypeidExpr = 129, - CXCursor_CXXBoolLiteralExpr = 130, - CXCursor_CXXNullPtrLiteralExpr = 131, - CXCursor_CXXThisExpr = 132, - CXCursor_CXXThrowExpr = 133, - CXCursor_CXXNewExpr = 134, - CXCursor_CXXDeleteExpr = 135, - CXCursor_UnaryExpr = 136, - CXCursor_ObjCStringLiteral = 137, - CXCursor_ObjCEncodeExpr = 138, - CXCursor_ObjCSelectorExpr = 139, - CXCursor_ObjCProtocolExpr = 140, - CXCursor_ObjCBridgedCastExpr = 141, - CXCursor_PackExpansionExpr = 142, - CXCursor_SizeOfPackExpr = 143, - CXCursor_LambdaExpr = 144, - CXCursor_ObjCBoolLiteralExpr = 145, - CXCursor_ObjCSelfExpr = 146, - CXCursor_OMPArraySectionExpr = 147, - CXCursor_ObjCAvailabilityCheckExpr = 148, - CXCursor_FixedPointLiteral = 149, - CXCursor_OMPArrayShapingExpr = 150, - CXCursor_OMPIteratorExpr = 151, - CXCursor_CXXAddrspaceCastExpr = 152, - CXCursor_LastExpr = CXCursor_CXXAddrspaceCastExpr, - CXCursor_FirstStmt = 200, - CXCursor_UnexposedStmt = 200, - CXCursor_LabelStmt = 201, - CXCursor_CompoundStmt = 202, - CXCursor_CaseStmt = 203, - CXCursor_DefaultStmt = 204, - CXCursor_IfStmt = 205, - CXCursor_SwitchStmt = 206, - CXCursor_WhileStmt = 207, - CXCursor_DoStmt = 208, - CXCursor_ForStmt = 209, - CXCursor_GotoStmt = 210, - CXCursor_IndirectGotoStmt = 211, - CXCursor_ContinueStmt = 212, - CXCursor_BreakStmt = 213, - CXCursor_ReturnStmt = 214, - CXCursor_GCCAsmStmt = 215, - CXCursor_AsmStmt = CXCursor_GCCAsmStmt, - CXCursor_ObjCAtTryStmt = 216, - CXCursor_ObjCAtCatchStmt = 217, - CXCursor_ObjCAtFinallyStmt = 218, - CXCursor_ObjCAtThrowStmt = 219, - CXCursor_ObjCAtSynchronizedStmt = 220, - CXCursor_ObjCAutoreleasePoolStmt = 221, - CXCursor_ObjCForCollectionStmt = 222, - CXCursor_CXXCatchStmt = 223, - CXCursor_CXXTryStmt = 224, - CXCursor_CXXForRangeStmt = 225, - CXCursor_SEHTryStmt = 226, - CXCursor_SEHExceptStmt = 227, - CXCursor_SEHFinallyStmt = 228, - CXCursor_MSAsmStmt = 229, - CXCursor_NullStmt = 230, - CXCursor_DeclStmt = 231, - CXCursor_OMPParallelDirective = 232, - CXCursor_OMPSimdDirective = 233, - CXCursor_OMPForDirective = 234, - CXCursor_OMPSectionsDirective = 235, - CXCursor_OMPSectionDirective = 236, - CXCursor_OMPSingleDirective = 237, - CXCursor_OMPParallelForDirective = 238, - CXCursor_OMPParallelSectionsDirective = 239, - CXCursor_OMPTaskDirective = 240, - CXCursor_OMPMasterDirective = 241, - CXCursor_OMPCriticalDirective = 242, - CXCursor_OMPTaskyieldDirective = 243, - CXCursor_OMPBarrierDirective = 244, - CXCursor_OMPTaskwaitDirective = 245, - CXCursor_OMPFlushDirective = 246, - CXCursor_SEHLeaveStmt = 247, - CXCursor_OMPOrderedDirective = 248, - CXCursor_OMPAtomicDirective = 249, - CXCursor_OMPForSimdDirective = 250, - CXCursor_OMPParallelForSimdDirective = 251, - CXCursor_OMPTargetDirective = 252, - CXCursor_OMPTeamsDirective = 253, - CXCursor_OMPTaskgroupDirective = 254, - CXCursor_OMPCancellationPointDirective = 255, - CXCursor_OMPCancelDirective = 256, - CXCursor_OMPTargetDataDirective = 257, - CXCursor_OMPTaskLoopDirective = 258, - CXCursor_OMPTaskLoopSimdDirective = 259, - CXCursor_OMPDistributeDirective = 260, - CXCursor_OMPTargetEnterDataDirective = 261, - CXCursor_OMPTargetExitDataDirective = 262, - CXCursor_OMPTargetParallelDirective = 263, - CXCursor_OMPTargetParallelForDirective = 264, - CXCursor_OMPTargetUpdateDirective = 265, - CXCursor_OMPDistributeParallelForDirective = 266, - CXCursor_OMPDistributeParallelForSimdDirective = 267, - CXCursor_OMPDistributeSimdDirective = 268, - CXCursor_OMPTargetParallelForSimdDirective = 269, - CXCursor_OMPTargetSimdDirective = 270, - CXCursor_OMPTeamsDistributeDirective = 271, - CXCursor_OMPTeamsDistributeSimdDirective = 272, - CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273, - CXCursor_OMPTeamsDistributeParallelForDirective = 274, - CXCursor_OMPTargetTeamsDirective = 275, - CXCursor_OMPTargetTeamsDistributeDirective = 276, - CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277, - CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278, - CXCursor_OMPTargetTeamsDistributeSimdDirective = 279, - CXCursor_BuiltinBitCastExpr = 280, - CXCursor_OMPMasterTaskLoopDirective = 281, - CXCursor_OMPParallelMasterTaskLoopDirective = 282, - CXCursor_OMPMasterTaskLoopSimdDirective = 283, - CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284, - CXCursor_OMPParallelMasterDirective = 285, - CXCursor_OMPDepobjDirective = 286, - CXCursor_OMPScanDirective = 287, - CXCursor_OMPTileDirective = 288, - CXCursor_OMPCanonicalLoop = 289, - CXCursor_OMPInteropDirective = 290, - CXCursor_OMPDispatchDirective = 291, - CXCursor_OMPMaskedDirective = 292, - CXCursor_OMPUnrollDirective = 293, - CXCursor_OMPMetaDirective = 294, - CXCursor_OMPGenericLoopDirective = 295, - CXCursor_LastStmt = CXCursor_OMPGenericLoopDirective, - CXCursor_TranslationUnit = 300, - CXCursor_FirstAttr = 400, - CXCursor_UnexposedAttr = 400, - CXCursor_IBActionAttr = 401, - CXCursor_IBOutletAttr = 402, - CXCursor_IBOutletCollectionAttr = 403, - CXCursor_CXXFinalAttr = 404, - CXCursor_CXXOverrideAttr = 405, - CXCursor_AnnotateAttr = 406, - CXCursor_AsmLabelAttr = 407, - CXCursor_PackedAttr = 408, - CXCursor_PureAttr = 409, - CXCursor_ConstAttr = 410, - CXCursor_NoDuplicateAttr = 411, - CXCursor_CUDAConstantAttr = 412, - CXCursor_CUDADeviceAttr = 413, - CXCursor_CUDAGlobalAttr = 414, - CXCursor_CUDAHostAttr = 415, - CXCursor_CUDASharedAttr = 416, - CXCursor_VisibilityAttr = 417, - CXCursor_DLLExport = 418, - CXCursor_DLLImport = 419, - CXCursor_NSReturnsRetained = 420, - CXCursor_NSReturnsNotRetained = 421, - CXCursor_NSReturnsAutoreleased = 422, - CXCursor_NSConsumesSelf = 423, - CXCursor_NSConsumed = 424, - CXCursor_ObjCException = 425, - CXCursor_ObjCNSObject = 426, - CXCursor_ObjCIndependentClass = 427, - CXCursor_ObjCPreciseLifetime = 428, - CXCursor_ObjCReturnsInnerPointer = 429, - CXCursor_ObjCRequiresSuper = 430, - CXCursor_ObjCRootClass = 431, - CXCursor_ObjCSubclassingRestricted = 432, - CXCursor_ObjCExplicitProtocolImpl = 433, - CXCursor_ObjCDesignatedInitializer = 434, - CXCursor_ObjCRuntimeVisible = 435, - CXCursor_ObjCBoxable = 436, - CXCursor_FlagEnum = 437, - CXCursor_ConvergentAttr = 438, - CXCursor_WarnUnusedAttr = 439, - CXCursor_WarnUnusedResultAttr = 440, - CXCursor_AlignedAttr = 441, - CXCursor_LastAttr = CXCursor_AlignedAttr, - CXCursor_PreprocessingDirective = 500, - CXCursor_MacroDefinition = 501, - CXCursor_MacroExpansion = 502, - CXCursor_MacroInstantiation = CXCursor_MacroExpansion, - CXCursor_InclusionDirective = 503, - CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective, - CXCursor_LastPreprocessing = CXCursor_InclusionDirective, - CXCursor_ModuleImportDecl = 600, - CXCursor_TypeAliasTemplateDecl = 601, - CXCursor_StaticAssert = 602, - CXCursor_FriendDecl = 603, - CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl, - CXCursor_LastExtraDecl = CXCursor_FriendDecl, - CXCursor_OverloadCandidate = 700, - } + CXCursor_UnexposedDecl = 1, + CXCursor_StructDecl = 2, + CXCursor_UnionDecl = 3, + CXCursor_ClassDecl = 4, + CXCursor_EnumDecl = 5, + CXCursor_FieldDecl = 6, + CXCursor_EnumConstantDecl = 7, + CXCursor_FunctionDecl = 8, + CXCursor_VarDecl = 9, + CXCursor_ParmDecl = 10, + CXCursor_ObjCInterfaceDecl = 11, + CXCursor_ObjCCategoryDecl = 12, + CXCursor_ObjCProtocolDecl = 13, + CXCursor_ObjCPropertyDecl = 14, + CXCursor_ObjCIvarDecl = 15, + CXCursor_ObjCInstanceMethodDecl = 16, + CXCursor_ObjCClassMethodDecl = 17, + CXCursor_ObjCImplementationDecl = 18, + CXCursor_ObjCCategoryImplDecl = 19, + CXCursor_TypedefDecl = 20, + CXCursor_CXXMethod = 21, + CXCursor_Namespace = 22, + CXCursor_LinkageSpec = 23, + CXCursor_Constructor = 24, + CXCursor_Destructor = 25, + CXCursor_ConversionFunction = 26, + CXCursor_TemplateTypeParameter = 27, + CXCursor_NonTypeTemplateParameter = 28, + CXCursor_TemplateTemplateParameter = 29, + CXCursor_FunctionTemplate = 30, + CXCursor_ClassTemplate = 31, + CXCursor_ClassTemplatePartialSpecialization = 32, + CXCursor_NamespaceAlias = 33, + CXCursor_UsingDirective = 34, + CXCursor_UsingDeclaration = 35, + CXCursor_TypeAliasDecl = 36, + CXCursor_ObjCSynthesizeDecl = 37, + CXCursor_ObjCDynamicDecl = 38, + CXCursor_CXXAccessSpecifier = 39, + CXCursor_FirstDecl = CXCursor_UnexposedDecl, + CXCursor_LastDecl = CXCursor_CXXAccessSpecifier, + CXCursor_FirstRef = 40, + CXCursor_ObjCSuperClassRef = 40, + CXCursor_ObjCProtocolRef = 41, + CXCursor_ObjCClassRef = 42, + CXCursor_TypeRef = 43, + CXCursor_CXXBaseSpecifier = 44, + CXCursor_TemplateRef = 45, + CXCursor_NamespaceRef = 46, + CXCursor_MemberRef = 47, + CXCursor_LabelRef = 48, + CXCursor_OverloadedDeclRef = 49, + CXCursor_VariableRef = 50, + CXCursor_LastRef = CXCursor_VariableRef, + CXCursor_FirstInvalid = 70, + CXCursor_InvalidFile = 70, + CXCursor_NoDeclFound = 71, + CXCursor_NotImplemented = 72, + CXCursor_InvalidCode = 73, + CXCursor_LastInvalid = CXCursor_InvalidCode, + CXCursor_FirstExpr = 100, + CXCursor_UnexposedExpr = 100, + CXCursor_DeclRefExpr = 101, + CXCursor_MemberRefExpr = 102, + CXCursor_CallExpr = 103, + CXCursor_ObjCMessageExpr = 104, + CXCursor_BlockExpr = 105, + CXCursor_IntegerLiteral = 106, + CXCursor_FloatingLiteral = 107, + CXCursor_ImaginaryLiteral = 108, + CXCursor_StringLiteral = 109, + CXCursor_CharacterLiteral = 110, + CXCursor_ParenExpr = 111, + CXCursor_UnaryOperator = 112, + CXCursor_ArraySubscriptExpr = 113, + CXCursor_BinaryOperator = 114, + CXCursor_CompoundAssignOperator = 115, + CXCursor_ConditionalOperator = 116, + CXCursor_CStyleCastExpr = 117, + CXCursor_CompoundLiteralExpr = 118, + CXCursor_InitListExpr = 119, + CXCursor_AddrLabelExpr = 120, + CXCursor_StmtExpr = 121, + CXCursor_GenericSelectionExpr = 122, + CXCursor_GNUNullExpr = 123, + CXCursor_CXXStaticCastExpr = 124, + CXCursor_CXXDynamicCastExpr = 125, + CXCursor_CXXReinterpretCastExpr = 126, + CXCursor_CXXConstCastExpr = 127, + CXCursor_CXXFunctionalCastExpr = 128, + CXCursor_CXXTypeidExpr = 129, + CXCursor_CXXBoolLiteralExpr = 130, + CXCursor_CXXNullPtrLiteralExpr = 131, + CXCursor_CXXThisExpr = 132, + CXCursor_CXXThrowExpr = 133, + CXCursor_CXXNewExpr = 134, + CXCursor_CXXDeleteExpr = 135, + CXCursor_UnaryExpr = 136, + CXCursor_ObjCStringLiteral = 137, + CXCursor_ObjCEncodeExpr = 138, + CXCursor_ObjCSelectorExpr = 139, + CXCursor_ObjCProtocolExpr = 140, + CXCursor_ObjCBridgedCastExpr = 141, + CXCursor_PackExpansionExpr = 142, + CXCursor_SizeOfPackExpr = 143, + CXCursor_LambdaExpr = 144, + CXCursor_ObjCBoolLiteralExpr = 145, + CXCursor_ObjCSelfExpr = 146, + CXCursor_OMPArraySectionExpr = 147, + CXCursor_ObjCAvailabilityCheckExpr = 148, + CXCursor_FixedPointLiteral = 149, + CXCursor_OMPArrayShapingExpr = 150, + CXCursor_OMPIteratorExpr = 151, + CXCursor_CXXAddrspaceCastExpr = 152, + CXCursor_LastExpr = CXCursor_CXXAddrspaceCastExpr, + CXCursor_FirstStmt = 200, + CXCursor_UnexposedStmt = 200, + CXCursor_LabelStmt = 201, + CXCursor_CompoundStmt = 202, + CXCursor_CaseStmt = 203, + CXCursor_DefaultStmt = 204, + CXCursor_IfStmt = 205, + CXCursor_SwitchStmt = 206, + CXCursor_WhileStmt = 207, + CXCursor_DoStmt = 208, + CXCursor_ForStmt = 209, + CXCursor_GotoStmt = 210, + CXCursor_IndirectGotoStmt = 211, + CXCursor_ContinueStmt = 212, + CXCursor_BreakStmt = 213, + CXCursor_ReturnStmt = 214, + CXCursor_GCCAsmStmt = 215, + CXCursor_AsmStmt = CXCursor_GCCAsmStmt, + CXCursor_ObjCAtTryStmt = 216, + CXCursor_ObjCAtCatchStmt = 217, + CXCursor_ObjCAtFinallyStmt = 218, + CXCursor_ObjCAtThrowStmt = 219, + CXCursor_ObjCAtSynchronizedStmt = 220, + CXCursor_ObjCAutoreleasePoolStmt = 221, + CXCursor_ObjCForCollectionStmt = 222, + CXCursor_CXXCatchStmt = 223, + CXCursor_CXXTryStmt = 224, + CXCursor_CXXForRangeStmt = 225, + CXCursor_SEHTryStmt = 226, + CXCursor_SEHExceptStmt = 227, + CXCursor_SEHFinallyStmt = 228, + CXCursor_MSAsmStmt = 229, + CXCursor_NullStmt = 230, + CXCursor_DeclStmt = 231, + CXCursor_OMPParallelDirective = 232, + CXCursor_OMPSimdDirective = 233, + CXCursor_OMPForDirective = 234, + CXCursor_OMPSectionsDirective = 235, + CXCursor_OMPSectionDirective = 236, + CXCursor_OMPSingleDirective = 237, + CXCursor_OMPParallelForDirective = 238, + CXCursor_OMPParallelSectionsDirective = 239, + CXCursor_OMPTaskDirective = 240, + CXCursor_OMPMasterDirective = 241, + CXCursor_OMPCriticalDirective = 242, + CXCursor_OMPTaskyieldDirective = 243, + CXCursor_OMPBarrierDirective = 244, + CXCursor_OMPTaskwaitDirective = 245, + CXCursor_OMPFlushDirective = 246, + CXCursor_SEHLeaveStmt = 247, + CXCursor_OMPOrderedDirective = 248, + CXCursor_OMPAtomicDirective = 249, + CXCursor_OMPForSimdDirective = 250, + CXCursor_OMPParallelForSimdDirective = 251, + CXCursor_OMPTargetDirective = 252, + CXCursor_OMPTeamsDirective = 253, + CXCursor_OMPTaskgroupDirective = 254, + CXCursor_OMPCancellationPointDirective = 255, + CXCursor_OMPCancelDirective = 256, + CXCursor_OMPTargetDataDirective = 257, + CXCursor_OMPTaskLoopDirective = 258, + CXCursor_OMPTaskLoopSimdDirective = 259, + CXCursor_OMPDistributeDirective = 260, + CXCursor_OMPTargetEnterDataDirective = 261, + CXCursor_OMPTargetExitDataDirective = 262, + CXCursor_OMPTargetParallelDirective = 263, + CXCursor_OMPTargetParallelForDirective = 264, + CXCursor_OMPTargetUpdateDirective = 265, + CXCursor_OMPDistributeParallelForDirective = 266, + CXCursor_OMPDistributeParallelForSimdDirective = 267, + CXCursor_OMPDistributeSimdDirective = 268, + CXCursor_OMPTargetParallelForSimdDirective = 269, + CXCursor_OMPTargetSimdDirective = 270, + CXCursor_OMPTeamsDistributeDirective = 271, + CXCursor_OMPTeamsDistributeSimdDirective = 272, + CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273, + CXCursor_OMPTeamsDistributeParallelForDirective = 274, + CXCursor_OMPTargetTeamsDirective = 275, + CXCursor_OMPTargetTeamsDistributeDirective = 276, + CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277, + CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278, + CXCursor_OMPTargetTeamsDistributeSimdDirective = 279, + CXCursor_BuiltinBitCastExpr = 280, + CXCursor_OMPMasterTaskLoopDirective = 281, + CXCursor_OMPParallelMasterTaskLoopDirective = 282, + CXCursor_OMPMasterTaskLoopSimdDirective = 283, + CXCursor_OMPParallelMasterTaskLoopSimdDirective = 284, + CXCursor_OMPParallelMasterDirective = 285, + CXCursor_OMPDepobjDirective = 286, + CXCursor_OMPScanDirective = 287, + CXCursor_OMPTileDirective = 288, + CXCursor_OMPCanonicalLoop = 289, + CXCursor_OMPInteropDirective = 290, + CXCursor_OMPDispatchDirective = 291, + CXCursor_OMPMaskedDirective = 292, + CXCursor_OMPUnrollDirective = 293, + CXCursor_OMPMetaDirective = 294, + CXCursor_OMPGenericLoopDirective = 295, + CXCursor_LastStmt = CXCursor_OMPGenericLoopDirective, + CXCursor_TranslationUnit = 300, + CXCursor_FirstAttr = 400, + CXCursor_UnexposedAttr = 400, + CXCursor_IBActionAttr = 401, + CXCursor_IBOutletAttr = 402, + CXCursor_IBOutletCollectionAttr = 403, + CXCursor_CXXFinalAttr = 404, + CXCursor_CXXOverrideAttr = 405, + CXCursor_AnnotateAttr = 406, + CXCursor_AsmLabelAttr = 407, + CXCursor_PackedAttr = 408, + CXCursor_PureAttr = 409, + CXCursor_ConstAttr = 410, + CXCursor_NoDuplicateAttr = 411, + CXCursor_CUDAConstantAttr = 412, + CXCursor_CUDADeviceAttr = 413, + CXCursor_CUDAGlobalAttr = 414, + CXCursor_CUDAHostAttr = 415, + CXCursor_CUDASharedAttr = 416, + CXCursor_VisibilityAttr = 417, + CXCursor_DLLExport = 418, + CXCursor_DLLImport = 419, + CXCursor_NSReturnsRetained = 420, + CXCursor_NSReturnsNotRetained = 421, + CXCursor_NSReturnsAutoreleased = 422, + CXCursor_NSConsumesSelf = 423, + CXCursor_NSConsumed = 424, + CXCursor_ObjCException = 425, + CXCursor_ObjCNSObject = 426, + CXCursor_ObjCIndependentClass = 427, + CXCursor_ObjCPreciseLifetime = 428, + CXCursor_ObjCReturnsInnerPointer = 429, + CXCursor_ObjCRequiresSuper = 430, + CXCursor_ObjCRootClass = 431, + CXCursor_ObjCSubclassingRestricted = 432, + CXCursor_ObjCExplicitProtocolImpl = 433, + CXCursor_ObjCDesignatedInitializer = 434, + CXCursor_ObjCRuntimeVisible = 435, + CXCursor_ObjCBoxable = 436, + CXCursor_FlagEnum = 437, + CXCursor_ConvergentAttr = 438, + CXCursor_WarnUnusedAttr = 439, + CXCursor_WarnUnusedResultAttr = 440, + CXCursor_AlignedAttr = 441, + CXCursor_LastAttr = CXCursor_AlignedAttr, + CXCursor_PreprocessingDirective = 500, + CXCursor_MacroDefinition = 501, + CXCursor_MacroExpansion = 502, + CXCursor_MacroInstantiation = CXCursor_MacroExpansion, + CXCursor_InclusionDirective = 503, + CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective, + CXCursor_LastPreprocessing = CXCursor_InclusionDirective, + CXCursor_ModuleImportDecl = 600, + CXCursor_TypeAliasTemplateDecl = 601, + CXCursor_StaticAssert = 602, + CXCursor_FriendDecl = 603, + CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl, + CXCursor_LastExtraDecl = CXCursor_FriendDecl, + CXCursor_OverloadCandidate = 700, } diff --git a/sources/ClangSharp.Interop/CXCursorSetImpl.cs b/sources/ClangSharp.Interop/CXCursorSetImpl.cs index 14b68fb9..ecdcea20 100644 --- a/sources/ClangSharp.Interop/CXCursorSetImpl.cs +++ b/sources/ClangSharp.Interop/CXCursorSetImpl.cs @@ -3,9 +3,8 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXCursorSetImpl { - public partial struct CXCursorSetImpl - { - } } diff --git a/sources/ClangSharp.Interop/CXCursorVisitor.cs b/sources/ClangSharp.Interop/CXCursorVisitor.cs index 260e891a..d5be796a 100644 --- a/sources/ClangSharp.Interop/CXCursorVisitor.cs +++ b/sources/ClangSharp.Interop/CXCursorVisitor.cs @@ -5,9 +5,8 @@ using System.Runtime.InteropServices; -namespace ClangSharp.Interop -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [return: NativeTypeName("enum CXChildVisitResult")] - public unsafe delegate CXChildVisitResult CXCursorVisitor(CXCursor cursor, CXCursor parent, [NativeTypeName("CXClientData")] void* client_data); -} +namespace ClangSharp.Interop; + +[UnmanagedFunctionPointer(CallingConvention.Cdecl)] +[return: NativeTypeName("enum CXChildVisitResult")] +public unsafe delegate CXChildVisitResult CXCursorVisitor(CXCursor cursor, CXCursor parent, [NativeTypeName("CXClientData")] void* client_data); diff --git a/sources/ClangSharp.Interop/CXCursor_ExceptionSpecificationKind.cs b/sources/ClangSharp.Interop/CXCursor_ExceptionSpecificationKind.cs index 4df7a33f..a7684407 100644 --- a/sources/ClangSharp.Interop/CXCursor_ExceptionSpecificationKind.cs +++ b/sources/ClangSharp.Interop/CXCursor_ExceptionSpecificationKind.cs @@ -3,19 +3,18 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXCursor_ExceptionSpecificationKind { - public enum CXCursor_ExceptionSpecificationKind - { - CXCursor_ExceptionSpecificationKind_None, - CXCursor_ExceptionSpecificationKind_DynamicNone, - CXCursor_ExceptionSpecificationKind_Dynamic, - CXCursor_ExceptionSpecificationKind_MSAny, - CXCursor_ExceptionSpecificationKind_BasicNoexcept, - CXCursor_ExceptionSpecificationKind_ComputedNoexcept, - CXCursor_ExceptionSpecificationKind_Unevaluated, - CXCursor_ExceptionSpecificationKind_Uninstantiated, - CXCursor_ExceptionSpecificationKind_Unparsed, - CXCursor_ExceptionSpecificationKind_NoThrow, - } + CXCursor_ExceptionSpecificationKind_None, + CXCursor_ExceptionSpecificationKind_DynamicNone, + CXCursor_ExceptionSpecificationKind_Dynamic, + CXCursor_ExceptionSpecificationKind_MSAny, + CXCursor_ExceptionSpecificationKind_BasicNoexcept, + CXCursor_ExceptionSpecificationKind_ComputedNoexcept, + CXCursor_ExceptionSpecificationKind_Unevaluated, + CXCursor_ExceptionSpecificationKind_Uninstantiated, + CXCursor_ExceptionSpecificationKind_Unparsed, + CXCursor_ExceptionSpecificationKind_NoThrow, } diff --git a/sources/ClangSharp.Interop/CXDiagnosticDisplayOptions.cs b/sources/ClangSharp.Interop/CXDiagnosticDisplayOptions.cs index acfab9d4..d280514b 100644 --- a/sources/ClangSharp.Interop/CXDiagnosticDisplayOptions.cs +++ b/sources/ClangSharp.Interop/CXDiagnosticDisplayOptions.cs @@ -3,15 +3,14 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXDiagnosticDisplayOptions { - public enum CXDiagnosticDisplayOptions - { - CXDiagnostic_DisplaySourceLocation = 0x01, - CXDiagnostic_DisplayColumn = 0x02, - CXDiagnostic_DisplaySourceRanges = 0x04, - CXDiagnostic_DisplayOption = 0x08, - CXDiagnostic_DisplayCategoryId = 0x10, - CXDiagnostic_DisplayCategoryName = 0x20, - } + CXDiagnostic_DisplaySourceLocation = 0x01, + CXDiagnostic_DisplayColumn = 0x02, + CXDiagnostic_DisplaySourceRanges = 0x04, + CXDiagnostic_DisplayOption = 0x08, + CXDiagnostic_DisplayCategoryId = 0x10, + CXDiagnostic_DisplayCategoryName = 0x20, } diff --git a/sources/ClangSharp.Interop/CXDiagnosticSeverity.cs b/sources/ClangSharp.Interop/CXDiagnosticSeverity.cs index 0aaf3d2d..0635bd08 100644 --- a/sources/ClangSharp.Interop/CXDiagnosticSeverity.cs +++ b/sources/ClangSharp.Interop/CXDiagnosticSeverity.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXDiagnosticSeverity { - public enum CXDiagnosticSeverity - { - CXDiagnostic_Ignored = 0, - CXDiagnostic_Note = 1, - CXDiagnostic_Warning = 2, - CXDiagnostic_Error = 3, - CXDiagnostic_Fatal = 4, - } + CXDiagnostic_Ignored = 0, + CXDiagnostic_Note = 1, + CXDiagnostic_Warning = 2, + CXDiagnostic_Error = 3, + CXDiagnostic_Fatal = 4, } diff --git a/sources/ClangSharp.Interop/CXErrorCode.cs b/sources/ClangSharp.Interop/CXErrorCode.cs index 3d37f8c1..c1545866 100644 --- a/sources/ClangSharp.Interop/CXErrorCode.cs +++ b/sources/ClangSharp.Interop/CXErrorCode.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXErrorCode { - public enum CXErrorCode - { - CXError_Success = 0, - CXError_Failure = 1, - CXError_Crashed = 2, - CXError_InvalidArguments = 3, - CXError_ASTReadError = 4, - } + CXError_Success = 0, + CXError_Failure = 1, + CXError_Crashed = 2, + CXError_InvalidArguments = 3, + CXError_ASTReadError = 4, } diff --git a/sources/ClangSharp.Interop/CXEvalResultKind.cs b/sources/ClangSharp.Interop/CXEvalResultKind.cs index 4aa7c5db..a873fcd1 100644 --- a/sources/ClangSharp.Interop/CXEvalResultKind.cs +++ b/sources/ClangSharp.Interop/CXEvalResultKind.cs @@ -3,16 +3,15 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXEvalResultKind { - public enum CXEvalResultKind - { - CXEval_Int = 1, - CXEval_Float = 2, - CXEval_ObjCStrLiteral = 3, - CXEval_StrLiteral = 4, - CXEval_CFStr = 5, - CXEval_Other = 6, - CXEval_UnExposed = 0, - } + CXEval_Int = 1, + CXEval_Float = 2, + CXEval_ObjCStrLiteral = 3, + CXEval_StrLiteral = 4, + CXEval_CFStr = 5, + CXEval_Other = 6, + CXEval_UnExposed = 0, } diff --git a/sources/ClangSharp.Interop/CXFieldVisitor.cs b/sources/ClangSharp.Interop/CXFieldVisitor.cs index 0fb466cf..dc8a993c 100644 --- a/sources/ClangSharp.Interop/CXFieldVisitor.cs +++ b/sources/ClangSharp.Interop/CXFieldVisitor.cs @@ -5,9 +5,8 @@ using System.Runtime.InteropServices; -namespace ClangSharp.Interop -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [return: NativeTypeName("enum CXVisitorResult")] - public unsafe delegate CXVisitorResult CXFieldVisitor(CXCursor C, [NativeTypeName("CXClientData")] void* client_data); -} +namespace ClangSharp.Interop; + +[UnmanagedFunctionPointer(CallingConvention.Cdecl)] +[return: NativeTypeName("enum CXVisitorResult")] +public unsafe delegate CXVisitorResult CXFieldVisitor(CXCursor C, [NativeTypeName("CXClientData")] void* client_data); diff --git a/sources/ClangSharp.Interop/CXFileUniqueID.cs b/sources/ClangSharp.Interop/CXFileUniqueID.cs index 2afdfa7a..f75e074b 100644 --- a/sources/ClangSharp.Interop/CXFileUniqueID.cs +++ b/sources/ClangSharp.Interop/CXFileUniqueID.cs @@ -3,11 +3,10 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXFileUniqueID { - public unsafe partial struct CXFileUniqueID - { - [NativeTypeName("unsigned long long [3]")] - public fixed ulong data[3]; - } + [NativeTypeName("unsigned long long [3]")] + public fixed ulong data[3]; } diff --git a/sources/ClangSharp.Interop/CXGlobalOptFlags.cs b/sources/ClangSharp.Interop/CXGlobalOptFlags.cs index f479d26c..4d663842 100644 --- a/sources/ClangSharp.Interop/CXGlobalOptFlags.cs +++ b/sources/ClangSharp.Interop/CXGlobalOptFlags.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXGlobalOptFlags { - public enum CXGlobalOptFlags - { - CXGlobalOpt_None = 0x0, - CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, - CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, - CXGlobalOpt_ThreadBackgroundPriorityForAll = CXGlobalOpt_ThreadBackgroundPriorityForIndexing | CXGlobalOpt_ThreadBackgroundPriorityForEditing, - } + CXGlobalOpt_None = 0x0, + CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 0x1, + CXGlobalOpt_ThreadBackgroundPriorityForEditing = 0x2, + CXGlobalOpt_ThreadBackgroundPriorityForAll = CXGlobalOpt_ThreadBackgroundPriorityForIndexing | CXGlobalOpt_ThreadBackgroundPriorityForEditing, } diff --git a/sources/ClangSharp.Interop/CXIdxAttrInfo.cs b/sources/ClangSharp.Interop/CXIdxAttrInfo.cs index 4e77fa7e..03522a0a 100644 --- a/sources/ClangSharp.Interop/CXIdxAttrInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxAttrInfo.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXIdxAttrInfo { - public partial struct CXIdxAttrInfo - { - public CXIdxAttrKind kind; + public CXIdxAttrKind kind; - public CXCursor cursor; + public CXCursor cursor; - public CXIdxLoc loc; - } + public CXIdxLoc loc; } diff --git a/sources/ClangSharp.Interop/CXIdxAttrKind.cs b/sources/ClangSharp.Interop/CXIdxAttrKind.cs index 40d1edff..b65c1fe2 100644 --- a/sources/ClangSharp.Interop/CXIdxAttrKind.cs +++ b/sources/ClangSharp.Interop/CXIdxAttrKind.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXIdxAttrKind { - public enum CXIdxAttrKind - { - CXIdxAttr_Unexposed = 0, - CXIdxAttr_IBAction = 1, - CXIdxAttr_IBOutlet = 2, - CXIdxAttr_IBOutletCollection = 3, - } + CXIdxAttr_Unexposed = 0, + CXIdxAttr_IBAction = 1, + CXIdxAttr_IBOutlet = 2, + CXIdxAttr_IBOutletCollection = 3, } diff --git a/sources/ClangSharp.Interop/CXIdxBaseClassInfo.cs b/sources/ClangSharp.Interop/CXIdxBaseClassInfo.cs index 0488d531..ed98fdd8 100644 --- a/sources/ClangSharp.Interop/CXIdxBaseClassInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxBaseClassInfo.cs @@ -3,15 +3,14 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxBaseClassInfo { - public unsafe partial struct CXIdxBaseClassInfo - { - [NativeTypeName("const CXIdxEntityInfo *")] - public CXIdxEntityInfo* @base; + [NativeTypeName("const CXIdxEntityInfo *")] + public CXIdxEntityInfo* @base; - public CXCursor cursor; + public CXCursor cursor; - public CXIdxLoc loc; - } + public CXIdxLoc loc; } diff --git a/sources/ClangSharp.Interop/CXIdxCXXClassDeclInfo.cs b/sources/ClangSharp.Interop/CXIdxCXXClassDeclInfo.cs index 8f948836..745d41b6 100644 --- a/sources/ClangSharp.Interop/CXIdxCXXClassDeclInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxCXXClassDeclInfo.cs @@ -3,17 +3,16 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxCXXClassDeclInfo { - public unsafe partial struct CXIdxCXXClassDeclInfo - { - [NativeTypeName("const CXIdxDeclInfo *")] - public CXIdxDeclInfo* declInfo; + [NativeTypeName("const CXIdxDeclInfo *")] + public CXIdxDeclInfo* declInfo; - [NativeTypeName("const CXIdxBaseClassInfo *const *")] - public CXIdxBaseClassInfo** bases; + [NativeTypeName("const CXIdxBaseClassInfo *const *")] + public CXIdxBaseClassInfo** bases; - [NativeTypeName("unsigned int")] - public uint numBases; - } + [NativeTypeName("unsigned int")] + public uint numBases; } diff --git a/sources/ClangSharp.Interop/CXIdxContainerInfo.cs b/sources/ClangSharp.Interop/CXIdxContainerInfo.cs index e2ff305d..968a453c 100644 --- a/sources/ClangSharp.Interop/CXIdxContainerInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxContainerInfo.cs @@ -3,10 +3,9 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXIdxContainerInfo { - public partial struct CXIdxContainerInfo - { - public CXCursor cursor; - } + public CXCursor cursor; } diff --git a/sources/ClangSharp.Interop/CXIdxDeclInfo.cs b/sources/ClangSharp.Interop/CXIdxDeclInfo.cs index b27bff1f..cf4c7ab8 100644 --- a/sources/ClangSharp.Interop/CXIdxDeclInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxDeclInfo.cs @@ -3,41 +3,40 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxDeclInfo { - public unsafe partial struct CXIdxDeclInfo - { - [NativeTypeName("const CXIdxEntityInfo *")] - public CXIdxEntityInfo* entityInfo; + [NativeTypeName("const CXIdxEntityInfo *")] + public CXIdxEntityInfo* entityInfo; - public CXCursor cursor; + public CXCursor cursor; - public CXIdxLoc loc; + public CXIdxLoc loc; - [NativeTypeName("const CXIdxContainerInfo *")] - public CXIdxContainerInfo* semanticContainer; + [NativeTypeName("const CXIdxContainerInfo *")] + public CXIdxContainerInfo* semanticContainer; - [NativeTypeName("const CXIdxContainerInfo *")] - public CXIdxContainerInfo* lexicalContainer; + [NativeTypeName("const CXIdxContainerInfo *")] + public CXIdxContainerInfo* lexicalContainer; - public int isRedeclaration; + public int isRedeclaration; - public int isDefinition; + public int isDefinition; - public int isContainer; + public int isContainer; - [NativeTypeName("const CXIdxContainerInfo *")] - public CXIdxContainerInfo* declAsContainer; + [NativeTypeName("const CXIdxContainerInfo *")] + public CXIdxContainerInfo* declAsContainer; - public int isImplicit; + public int isImplicit; - [NativeTypeName("const CXIdxAttrInfo *const *")] - public CXIdxAttrInfo** attributes; + [NativeTypeName("const CXIdxAttrInfo *const *")] + public CXIdxAttrInfo** attributes; - [NativeTypeName("unsigned int")] - public uint numAttributes; + [NativeTypeName("unsigned int")] + public uint numAttributes; - [NativeTypeName("unsigned int")] - public uint flags; - } + [NativeTypeName("unsigned int")] + public uint flags; } diff --git a/sources/ClangSharp.Interop/CXIdxDeclInfoFlags.cs b/sources/ClangSharp.Interop/CXIdxDeclInfoFlags.cs index b4e3e771..ece114b7 100644 --- a/sources/ClangSharp.Interop/CXIdxDeclInfoFlags.cs +++ b/sources/ClangSharp.Interop/CXIdxDeclInfoFlags.cs @@ -3,10 +3,9 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXIdxDeclInfoFlags { - public enum CXIdxDeclInfoFlags - { - CXIdxDeclFlag_Skipped = 0x1, - } + CXIdxDeclFlag_Skipped = 0x1, } diff --git a/sources/ClangSharp.Interop/CXIdxEntityCXXTemplateKind.cs b/sources/ClangSharp.Interop/CXIdxEntityCXXTemplateKind.cs index 1d72b3b9..8e889d8e 100644 --- a/sources/ClangSharp.Interop/CXIdxEntityCXXTemplateKind.cs +++ b/sources/ClangSharp.Interop/CXIdxEntityCXXTemplateKind.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXIdxEntityCXXTemplateKind { - public enum CXIdxEntityCXXTemplateKind - { - CXIdxEntity_NonTemplate = 0, - CXIdxEntity_Template = 1, - CXIdxEntity_TemplatePartialSpecialization = 2, - CXIdxEntity_TemplateSpecialization = 3, - } + CXIdxEntity_NonTemplate = 0, + CXIdxEntity_Template = 1, + CXIdxEntity_TemplatePartialSpecialization = 2, + CXIdxEntity_TemplateSpecialization = 3, } diff --git a/sources/ClangSharp.Interop/CXIdxEntityInfo.cs b/sources/ClangSharp.Interop/CXIdxEntityInfo.cs index 870541a8..d34cd877 100644 --- a/sources/ClangSharp.Interop/CXIdxEntityInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxEntityInfo.cs @@ -3,28 +3,27 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxEntityInfo { - public unsafe partial struct CXIdxEntityInfo - { - public CXIdxEntityKind kind; + public CXIdxEntityKind kind; - public CXIdxEntityCXXTemplateKind templateKind; + public CXIdxEntityCXXTemplateKind templateKind; - public CXIdxEntityLanguage lang; + public CXIdxEntityLanguage lang; - [NativeTypeName("const char *")] - public sbyte* name; + [NativeTypeName("const char *")] + public sbyte* name; - [NativeTypeName("const char *")] - public sbyte* USR; + [NativeTypeName("const char *")] + public sbyte* USR; - public CXCursor cursor; + public CXCursor cursor; - [NativeTypeName("const CXIdxAttrInfo *const *")] - public CXIdxAttrInfo** attributes; + [NativeTypeName("const CXIdxAttrInfo *const *")] + public CXIdxAttrInfo** attributes; - [NativeTypeName("unsigned int")] - public uint numAttributes; - } + [NativeTypeName("unsigned int")] + public uint numAttributes; } diff --git a/sources/ClangSharp.Interop/CXIdxEntityKind.cs b/sources/ClangSharp.Interop/CXIdxEntityKind.cs index 51545cd6..e4b58e2f 100644 --- a/sources/ClangSharp.Interop/CXIdxEntityKind.cs +++ b/sources/ClangSharp.Interop/CXIdxEntityKind.cs @@ -3,36 +3,35 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXIdxEntityKind { - public enum CXIdxEntityKind - { - CXIdxEntity_Unexposed = 0, - CXIdxEntity_Typedef = 1, - CXIdxEntity_Function = 2, - CXIdxEntity_Variable = 3, - CXIdxEntity_Field = 4, - CXIdxEntity_EnumConstant = 5, - CXIdxEntity_ObjCClass = 6, - CXIdxEntity_ObjCProtocol = 7, - CXIdxEntity_ObjCCategory = 8, - CXIdxEntity_ObjCInstanceMethod = 9, - CXIdxEntity_ObjCClassMethod = 10, - CXIdxEntity_ObjCProperty = 11, - CXIdxEntity_ObjCIvar = 12, - CXIdxEntity_Enum = 13, - CXIdxEntity_Struct = 14, - CXIdxEntity_Union = 15, - CXIdxEntity_CXXClass = 16, - CXIdxEntity_CXXNamespace = 17, - CXIdxEntity_CXXNamespaceAlias = 18, - CXIdxEntity_CXXStaticVariable = 19, - CXIdxEntity_CXXStaticMethod = 20, - CXIdxEntity_CXXInstanceMethod = 21, - CXIdxEntity_CXXConstructor = 22, - CXIdxEntity_CXXDestructor = 23, - CXIdxEntity_CXXConversionFunction = 24, - CXIdxEntity_CXXTypeAlias = 25, - CXIdxEntity_CXXInterface = 26, - } + CXIdxEntity_Unexposed = 0, + CXIdxEntity_Typedef = 1, + CXIdxEntity_Function = 2, + CXIdxEntity_Variable = 3, + CXIdxEntity_Field = 4, + CXIdxEntity_EnumConstant = 5, + CXIdxEntity_ObjCClass = 6, + CXIdxEntity_ObjCProtocol = 7, + CXIdxEntity_ObjCCategory = 8, + CXIdxEntity_ObjCInstanceMethod = 9, + CXIdxEntity_ObjCClassMethod = 10, + CXIdxEntity_ObjCProperty = 11, + CXIdxEntity_ObjCIvar = 12, + CXIdxEntity_Enum = 13, + CXIdxEntity_Struct = 14, + CXIdxEntity_Union = 15, + CXIdxEntity_CXXClass = 16, + CXIdxEntity_CXXNamespace = 17, + CXIdxEntity_CXXNamespaceAlias = 18, + CXIdxEntity_CXXStaticVariable = 19, + CXIdxEntity_CXXStaticMethod = 20, + CXIdxEntity_CXXInstanceMethod = 21, + CXIdxEntity_CXXConstructor = 22, + CXIdxEntity_CXXDestructor = 23, + CXIdxEntity_CXXConversionFunction = 24, + CXIdxEntity_CXXTypeAlias = 25, + CXIdxEntity_CXXInterface = 26, } diff --git a/sources/ClangSharp.Interop/CXIdxEntityLanguage.cs b/sources/ClangSharp.Interop/CXIdxEntityLanguage.cs index ebdac6ea..6cf0251d 100644 --- a/sources/ClangSharp.Interop/CXIdxEntityLanguage.cs +++ b/sources/ClangSharp.Interop/CXIdxEntityLanguage.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXIdxEntityLanguage { - public enum CXIdxEntityLanguage - { - CXIdxEntityLang_None = 0, - CXIdxEntityLang_C = 1, - CXIdxEntityLang_ObjC = 2, - CXIdxEntityLang_CXX = 3, - CXIdxEntityLang_Swift = 4, - } + CXIdxEntityLang_None = 0, + CXIdxEntityLang_C = 1, + CXIdxEntityLang_ObjC = 2, + CXIdxEntityLang_CXX = 3, + CXIdxEntityLang_Swift = 4, } diff --git a/sources/ClangSharp.Interop/CXIdxEntityRefInfo.cs b/sources/ClangSharp.Interop/CXIdxEntityRefInfo.cs index f854b1a4..53324e06 100644 --- a/sources/ClangSharp.Interop/CXIdxEntityRefInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxEntityRefInfo.cs @@ -3,25 +3,24 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxEntityRefInfo { - public unsafe partial struct CXIdxEntityRefInfo - { - public CXIdxEntityRefKind kind; + public CXIdxEntityRefKind kind; - public CXCursor cursor; + public CXCursor cursor; - public CXIdxLoc loc; + public CXIdxLoc loc; - [NativeTypeName("const CXIdxEntityInfo *")] - public CXIdxEntityInfo* referencedEntity; + [NativeTypeName("const CXIdxEntityInfo *")] + public CXIdxEntityInfo* referencedEntity; - [NativeTypeName("const CXIdxEntityInfo *")] - public CXIdxEntityInfo* parentEntity; + [NativeTypeName("const CXIdxEntityInfo *")] + public CXIdxEntityInfo* parentEntity; - [NativeTypeName("const CXIdxContainerInfo *")] - public CXIdxContainerInfo* container; + [NativeTypeName("const CXIdxContainerInfo *")] + public CXIdxContainerInfo* container; - public CXSymbolRole role; - } + public CXSymbolRole role; } diff --git a/sources/ClangSharp.Interop/CXIdxEntityRefKind.cs b/sources/ClangSharp.Interop/CXIdxEntityRefKind.cs index bff95de2..521757e6 100644 --- a/sources/ClangSharp.Interop/CXIdxEntityRefKind.cs +++ b/sources/ClangSharp.Interop/CXIdxEntityRefKind.cs @@ -3,11 +3,10 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXIdxEntityRefKind { - public enum CXIdxEntityRefKind - { - CXIdxEntityRef_Direct = 1, - CXIdxEntityRef_Implicit = 2, - } + CXIdxEntityRef_Direct = 1, + CXIdxEntityRef_Implicit = 2, } diff --git a/sources/ClangSharp.Interop/CXIdxIBOutletCollectionAttrInfo.cs b/sources/ClangSharp.Interop/CXIdxIBOutletCollectionAttrInfo.cs index bc6b4c77..cd07a065 100644 --- a/sources/ClangSharp.Interop/CXIdxIBOutletCollectionAttrInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxIBOutletCollectionAttrInfo.cs @@ -3,18 +3,17 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxIBOutletCollectionAttrInfo { - public unsafe partial struct CXIdxIBOutletCollectionAttrInfo - { - [NativeTypeName("const CXIdxAttrInfo *")] - public CXIdxAttrInfo* attrInfo; + [NativeTypeName("const CXIdxAttrInfo *")] + public CXIdxAttrInfo* attrInfo; - [NativeTypeName("const CXIdxEntityInfo *")] - public CXIdxEntityInfo* objcClass; + [NativeTypeName("const CXIdxEntityInfo *")] + public CXIdxEntityInfo* objcClass; - public CXCursor classCursor; + public CXCursor classCursor; - public CXIdxLoc classLoc; - } + public CXIdxLoc classLoc; } diff --git a/sources/ClangSharp.Interop/CXIdxImportedASTFileInfo.cs b/sources/ClangSharp.Interop/CXIdxImportedASTFileInfo.cs index de613135..2c5f5cfa 100644 --- a/sources/ClangSharp.Interop/CXIdxImportedASTFileInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxImportedASTFileInfo.cs @@ -3,18 +3,17 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxImportedASTFileInfo { - public unsafe partial struct CXIdxImportedASTFileInfo - { - [NativeTypeName("CXFile")] - public void* file; + [NativeTypeName("CXFile")] + public void* file; - [NativeTypeName("CXModule")] - public void* module; + [NativeTypeName("CXModule")] + public void* module; - public CXIdxLoc loc; + public CXIdxLoc loc; - public int isImplicit; - } + public int isImplicit; } diff --git a/sources/ClangSharp.Interop/CXIdxIncludedFileInfo.cs b/sources/ClangSharp.Interop/CXIdxIncludedFileInfo.cs index 4c241f3a..c5c1beb3 100644 --- a/sources/ClangSharp.Interop/CXIdxIncludedFileInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxIncludedFileInfo.cs @@ -3,22 +3,21 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxIncludedFileInfo { - public unsafe partial struct CXIdxIncludedFileInfo - { - public CXIdxLoc hashLoc; + public CXIdxLoc hashLoc; - [NativeTypeName("const char *")] - public sbyte* filename; + [NativeTypeName("const char *")] + public sbyte* filename; - [NativeTypeName("CXFile")] - public void* file; + [NativeTypeName("CXFile")] + public void* file; - public int isImport; + public int isImport; - public int isAngled; + public int isAngled; - public int isModuleImport; - } + public int isModuleImport; } diff --git a/sources/ClangSharp.Interop/CXIdxLoc.cs b/sources/ClangSharp.Interop/CXIdxLoc.cs index 88457a5b..56329496 100644 --- a/sources/ClangSharp.Interop/CXIdxLoc.cs +++ b/sources/ClangSharp.Interop/CXIdxLoc.cs @@ -3,29 +3,28 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXIdxLoc { - public partial struct CXIdxLoc - { - [NativeTypeName("void *[2]")] - public _ptr_data_e__FixedBuffer ptr_data; + [NativeTypeName("void *[2]")] + public _ptr_data_e__FixedBuffer ptr_data; - [NativeTypeName("unsigned int")] - public uint int_data; + [NativeTypeName("unsigned int")] + public uint int_data; - public unsafe partial struct _ptr_data_e__FixedBuffer - { - public void* e0; - public void* e1; + public unsafe partial struct _ptr_data_e__FixedBuffer + { + public void* e0; + public void* e1; - public ref void* this[int index] + public ref void* this[int index] + { + get { - get + fixed (void** pThis = &e0) { - fixed (void** pThis = &e0) - { - return ref pThis[index]; - } + return ref pThis[index]; } } } diff --git a/sources/ClangSharp.Interop/CXIdxObjCCategoryDeclInfo.cs b/sources/ClangSharp.Interop/CXIdxObjCCategoryDeclInfo.cs index 1eeddf7d..387c14e7 100644 --- a/sources/ClangSharp.Interop/CXIdxObjCCategoryDeclInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxObjCCategoryDeclInfo.cs @@ -3,21 +3,20 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxObjCCategoryDeclInfo { - public unsafe partial struct CXIdxObjCCategoryDeclInfo - { - [NativeTypeName("const CXIdxObjCContainerDeclInfo *")] - public CXIdxObjCContainerDeclInfo* containerInfo; + [NativeTypeName("const CXIdxObjCContainerDeclInfo *")] + public CXIdxObjCContainerDeclInfo* containerInfo; - [NativeTypeName("const CXIdxEntityInfo *")] - public CXIdxEntityInfo* objcClass; + [NativeTypeName("const CXIdxEntityInfo *")] + public CXIdxEntityInfo* objcClass; - public CXCursor classCursor; + public CXCursor classCursor; - public CXIdxLoc classLoc; + public CXIdxLoc classLoc; - [NativeTypeName("const CXIdxObjCProtocolRefListInfo *")] - public CXIdxObjCProtocolRefListInfo* protocols; - } + [NativeTypeName("const CXIdxObjCProtocolRefListInfo *")] + public CXIdxObjCProtocolRefListInfo* protocols; } diff --git a/sources/ClangSharp.Interop/CXIdxObjCContainerDeclInfo.cs b/sources/ClangSharp.Interop/CXIdxObjCContainerDeclInfo.cs index e748cf84..ecf97ea2 100644 --- a/sources/ClangSharp.Interop/CXIdxObjCContainerDeclInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxObjCContainerDeclInfo.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxObjCContainerDeclInfo { - public unsafe partial struct CXIdxObjCContainerDeclInfo - { - [NativeTypeName("const CXIdxDeclInfo *")] - public CXIdxDeclInfo* declInfo; + [NativeTypeName("const CXIdxDeclInfo *")] + public CXIdxDeclInfo* declInfo; - public CXIdxObjCContainerKind kind; - } + public CXIdxObjCContainerKind kind; } diff --git a/sources/ClangSharp.Interop/CXIdxObjCContainerKind.cs b/sources/ClangSharp.Interop/CXIdxObjCContainerKind.cs index f95d070b..0082e8bc 100644 --- a/sources/ClangSharp.Interop/CXIdxObjCContainerKind.cs +++ b/sources/ClangSharp.Interop/CXIdxObjCContainerKind.cs @@ -3,12 +3,11 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXIdxObjCContainerKind { - public enum CXIdxObjCContainerKind - { - CXIdxObjCContainer_ForwardRef = 0, - CXIdxObjCContainer_Interface = 1, - CXIdxObjCContainer_Implementation = 2, - } + CXIdxObjCContainer_ForwardRef = 0, + CXIdxObjCContainer_Interface = 1, + CXIdxObjCContainer_Implementation = 2, } diff --git a/sources/ClangSharp.Interop/CXIdxObjCInterfaceDeclInfo.cs b/sources/ClangSharp.Interop/CXIdxObjCInterfaceDeclInfo.cs index e7fa9ec3..25629cb6 100644 --- a/sources/ClangSharp.Interop/CXIdxObjCInterfaceDeclInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxObjCInterfaceDeclInfo.cs @@ -3,17 +3,16 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxObjCInterfaceDeclInfo { - public unsafe partial struct CXIdxObjCInterfaceDeclInfo - { - [NativeTypeName("const CXIdxObjCContainerDeclInfo *")] - public CXIdxObjCContainerDeclInfo* containerInfo; + [NativeTypeName("const CXIdxObjCContainerDeclInfo *")] + public CXIdxObjCContainerDeclInfo* containerInfo; - [NativeTypeName("const CXIdxBaseClassInfo *")] - public CXIdxBaseClassInfo* superInfo; + [NativeTypeName("const CXIdxBaseClassInfo *")] + public CXIdxBaseClassInfo* superInfo; - [NativeTypeName("const CXIdxObjCProtocolRefListInfo *")] - public CXIdxObjCProtocolRefListInfo* protocols; - } + [NativeTypeName("const CXIdxObjCProtocolRefListInfo *")] + public CXIdxObjCProtocolRefListInfo* protocols; } diff --git a/sources/ClangSharp.Interop/CXIdxObjCPropertyDeclInfo.cs b/sources/ClangSharp.Interop/CXIdxObjCPropertyDeclInfo.cs index 521f7bee..b8af313e 100644 --- a/sources/ClangSharp.Interop/CXIdxObjCPropertyDeclInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxObjCPropertyDeclInfo.cs @@ -3,17 +3,16 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxObjCPropertyDeclInfo { - public unsafe partial struct CXIdxObjCPropertyDeclInfo - { - [NativeTypeName("const CXIdxDeclInfo *")] - public CXIdxDeclInfo* declInfo; + [NativeTypeName("const CXIdxDeclInfo *")] + public CXIdxDeclInfo* declInfo; - [NativeTypeName("const CXIdxEntityInfo *")] - public CXIdxEntityInfo* getter; + [NativeTypeName("const CXIdxEntityInfo *")] + public CXIdxEntityInfo* getter; - [NativeTypeName("const CXIdxEntityInfo *")] - public CXIdxEntityInfo* setter; - } + [NativeTypeName("const CXIdxEntityInfo *")] + public CXIdxEntityInfo* setter; } diff --git a/sources/ClangSharp.Interop/CXIdxObjCProtocolRefInfo.cs b/sources/ClangSharp.Interop/CXIdxObjCProtocolRefInfo.cs index 1531313a..18c7ab38 100644 --- a/sources/ClangSharp.Interop/CXIdxObjCProtocolRefInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxObjCProtocolRefInfo.cs @@ -3,15 +3,14 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxObjCProtocolRefInfo { - public unsafe partial struct CXIdxObjCProtocolRefInfo - { - [NativeTypeName("const CXIdxEntityInfo *")] - public CXIdxEntityInfo* protocol; + [NativeTypeName("const CXIdxEntityInfo *")] + public CXIdxEntityInfo* protocol; - public CXCursor cursor; + public CXCursor cursor; - public CXIdxLoc loc; - } + public CXIdxLoc loc; } diff --git a/sources/ClangSharp.Interop/CXIdxObjCProtocolRefListInfo.cs b/sources/ClangSharp.Interop/CXIdxObjCProtocolRefListInfo.cs index da87ca37..dba5e216 100644 --- a/sources/ClangSharp.Interop/CXIdxObjCProtocolRefListInfo.cs +++ b/sources/ClangSharp.Interop/CXIdxObjCProtocolRefListInfo.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxObjCProtocolRefListInfo { - public unsafe partial struct CXIdxObjCProtocolRefListInfo - { - [NativeTypeName("const CXIdxObjCProtocolRefInfo *const *")] - public CXIdxObjCProtocolRefInfo** protocols; + [NativeTypeName("const CXIdxObjCProtocolRefInfo *const *")] + public CXIdxObjCProtocolRefInfo** protocols; - [NativeTypeName("unsigned int")] - public uint numProtocols; - } + [NativeTypeName("unsigned int")] + public uint numProtocols; } diff --git a/sources/ClangSharp.Interop/CXInclusionVisitor.cs b/sources/ClangSharp.Interop/CXInclusionVisitor.cs index 80eef2bc..bdb71e51 100644 --- a/sources/ClangSharp.Interop/CXInclusionVisitor.cs +++ b/sources/ClangSharp.Interop/CXInclusionVisitor.cs @@ -5,8 +5,7 @@ using System.Runtime.InteropServices; -namespace ClangSharp.Interop -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public unsafe delegate void CXInclusionVisitor([NativeTypeName("CXFile")] void* included_file, CXSourceLocation* inclusion_stack, [NativeTypeName("unsigned int")] uint include_len, [NativeTypeName("CXClientData")] void* client_data); -} +namespace ClangSharp.Interop; + +[UnmanagedFunctionPointer(CallingConvention.Cdecl)] +public unsafe delegate void CXInclusionVisitor([NativeTypeName("CXFile")] void* included_file, CXSourceLocation* inclusion_stack, [NativeTypeName("unsigned int")] uint include_len, [NativeTypeName("CXClientData")] void* client_data); diff --git a/sources/ClangSharp.Interop/CXIndexOptFlags.cs b/sources/ClangSharp.Interop/CXIndexOptFlags.cs index 15ddcdf7..3268b222 100644 --- a/sources/ClangSharp.Interop/CXIndexOptFlags.cs +++ b/sources/ClangSharp.Interop/CXIndexOptFlags.cs @@ -3,15 +3,14 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXIndexOptFlags { - public enum CXIndexOptFlags - { - CXIndexOpt_None = 0x0, - CXIndexOpt_SuppressRedundantRefs = 0x1, - CXIndexOpt_IndexFunctionLocalSymbols = 0x2, - CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, - CXIndexOpt_SuppressWarnings = 0x8, - CXIndexOpt_SkipParsedBodiesInSession = 0x10, - } + CXIndexOpt_None = 0x0, + CXIndexOpt_SuppressRedundantRefs = 0x1, + CXIndexOpt_IndexFunctionLocalSymbols = 0x2, + CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, + CXIndexOpt_SuppressWarnings = 0x8, + CXIndexOpt_SkipParsedBodiesInSession = 0x10, } diff --git a/sources/ClangSharp.Interop/CXLanguageKind.cs b/sources/ClangSharp.Interop/CXLanguageKind.cs index 394a3ea9..4cf8e6ff 100644 --- a/sources/ClangSharp.Interop/CXLanguageKind.cs +++ b/sources/ClangSharp.Interop/CXLanguageKind.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXLanguageKind { - public enum CXLanguageKind - { - CXLanguage_Invalid = 0, - CXLanguage_C, - CXLanguage_ObjC, - CXLanguage_CPlusPlus, - } + CXLanguage_Invalid = 0, + CXLanguage_C, + CXLanguage_ObjC, + CXLanguage_CPlusPlus, } diff --git a/sources/ClangSharp.Interop/CXLinkageKind.cs b/sources/ClangSharp.Interop/CXLinkageKind.cs index f54f425c..c8ed7fed 100644 --- a/sources/ClangSharp.Interop/CXLinkageKind.cs +++ b/sources/ClangSharp.Interop/CXLinkageKind.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXLinkageKind { - public enum CXLinkageKind - { - CXLinkage_Invalid, - CXLinkage_NoLinkage, - CXLinkage_Internal, - CXLinkage_UniqueExternal, - CXLinkage_External, - } + CXLinkage_Invalid, + CXLinkage_NoLinkage, + CXLinkage_Internal, + CXLinkage_UniqueExternal, + CXLinkage_External, } diff --git a/sources/ClangSharp.Interop/CXLoadDiag_Error.cs b/sources/ClangSharp.Interop/CXLoadDiag_Error.cs index 858195b4..a0a8a3f6 100644 --- a/sources/ClangSharp.Interop/CXLoadDiag_Error.cs +++ b/sources/ClangSharp.Interop/CXLoadDiag_Error.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXLoadDiag_Error { - public enum CXLoadDiag_Error - { - CXLoadDiag_None = 0, - CXLoadDiag_Unknown = 1, - CXLoadDiag_CannotLoad = 2, - CXLoadDiag_InvalidFile = 3, - } + CXLoadDiag_None = 0, + CXLoadDiag_Unknown = 1, + CXLoadDiag_CannotLoad = 2, + CXLoadDiag_InvalidFile = 3, } diff --git a/sources/ClangSharp.Interop/CXModuleMapDescriptorImpl.cs b/sources/ClangSharp.Interop/CXModuleMapDescriptorImpl.cs index 5a40b21a..566fb33d 100644 --- a/sources/ClangSharp.Interop/CXModuleMapDescriptorImpl.cs +++ b/sources/ClangSharp.Interop/CXModuleMapDescriptorImpl.cs @@ -3,9 +3,8 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXModuleMapDescriptorImpl { - public partial struct CXModuleMapDescriptorImpl - { - } } diff --git a/sources/ClangSharp.Interop/CXNameRefFlags.cs b/sources/ClangSharp.Interop/CXNameRefFlags.cs index f8ce9d3c..11440965 100644 --- a/sources/ClangSharp.Interop/CXNameRefFlags.cs +++ b/sources/ClangSharp.Interop/CXNameRefFlags.cs @@ -3,12 +3,11 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXNameRefFlags { - public enum CXNameRefFlags - { - CXNameRange_WantQualifier = 0x1, - CXNameRange_WantTemplateArgs = 0x2, - CXNameRange_WantSinglePiece = 0x4, - } + CXNameRange_WantQualifier = 0x1, + CXNameRange_WantTemplateArgs = 0x2, + CXNameRange_WantSinglePiece = 0x4, } diff --git a/sources/ClangSharp.Interop/CXObjCDeclQualifierKind.cs b/sources/ClangSharp.Interop/CXObjCDeclQualifierKind.cs index 54961133..820c6c7c 100644 --- a/sources/ClangSharp.Interop/CXObjCDeclQualifierKind.cs +++ b/sources/ClangSharp.Interop/CXObjCDeclQualifierKind.cs @@ -3,16 +3,15 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXObjCDeclQualifierKind { - public enum CXObjCDeclQualifierKind - { - CXObjCDeclQualifier_None = 0x0, - CXObjCDeclQualifier_In = 0x1, - CXObjCDeclQualifier_Inout = 0x2, - CXObjCDeclQualifier_Out = 0x4, - CXObjCDeclQualifier_Bycopy = 0x8, - CXObjCDeclQualifier_Byref = 0x10, - CXObjCDeclQualifier_Oneway = 0x20, - } + CXObjCDeclQualifier_None = 0x0, + CXObjCDeclQualifier_In = 0x1, + CXObjCDeclQualifier_Inout = 0x2, + CXObjCDeclQualifier_Out = 0x4, + CXObjCDeclQualifier_Bycopy = 0x8, + CXObjCDeclQualifier_Byref = 0x10, + CXObjCDeclQualifier_Oneway = 0x20, } diff --git a/sources/ClangSharp.Interop/CXObjCPropertyAttrKind.cs b/sources/ClangSharp.Interop/CXObjCPropertyAttrKind.cs index 36341ca0..526615de 100644 --- a/sources/ClangSharp.Interop/CXObjCPropertyAttrKind.cs +++ b/sources/ClangSharp.Interop/CXObjCPropertyAttrKind.cs @@ -3,23 +3,22 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXObjCPropertyAttrKind { - public enum CXObjCPropertyAttrKind - { - CXObjCPropertyAttr_noattr = 0x00, - CXObjCPropertyAttr_readonly = 0x01, - CXObjCPropertyAttr_getter = 0x02, - CXObjCPropertyAttr_assign = 0x04, - CXObjCPropertyAttr_readwrite = 0x08, - CXObjCPropertyAttr_retain = 0x10, - CXObjCPropertyAttr_copy = 0x20, - CXObjCPropertyAttr_nonatomic = 0x40, - CXObjCPropertyAttr_setter = 0x80, - CXObjCPropertyAttr_atomic = 0x100, - CXObjCPropertyAttr_weak = 0x200, - CXObjCPropertyAttr_strong = 0x400, - CXObjCPropertyAttr_unsafe_unretained = 0x800, - CXObjCPropertyAttr_class = 0x1000, - } + CXObjCPropertyAttr_noattr = 0x00, + CXObjCPropertyAttr_readonly = 0x01, + CXObjCPropertyAttr_getter = 0x02, + CXObjCPropertyAttr_assign = 0x04, + CXObjCPropertyAttr_readwrite = 0x08, + CXObjCPropertyAttr_retain = 0x10, + CXObjCPropertyAttr_copy = 0x20, + CXObjCPropertyAttr_nonatomic = 0x40, + CXObjCPropertyAttr_setter = 0x80, + CXObjCPropertyAttr_atomic = 0x100, + CXObjCPropertyAttr_weak = 0x200, + CXObjCPropertyAttr_strong = 0x400, + CXObjCPropertyAttr_unsafe_unretained = 0x800, + CXObjCPropertyAttr_class = 0x1000, } diff --git a/sources/ClangSharp.Interop/CXPlatformAvailability.cs b/sources/ClangSharp.Interop/CXPlatformAvailability.cs index c23d8a43..f248b9e2 100644 --- a/sources/ClangSharp.Interop/CXPlatformAvailability.cs +++ b/sources/ClangSharp.Interop/CXPlatformAvailability.cs @@ -3,20 +3,19 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXPlatformAvailability { - public partial struct CXPlatformAvailability - { - public CXString Platform; + public CXString Platform; - public CXVersion Introduced; + public CXVersion Introduced; - public CXVersion Deprecated; + public CXVersion Deprecated; - public CXVersion Obsoleted; + public CXVersion Obsoleted; - public int Unavailable; + public int Unavailable; - public CXString Message; - } + public CXString Message; } diff --git a/sources/ClangSharp.Interop/CXPrintingPolicyProperty.cs b/sources/ClangSharp.Interop/CXPrintingPolicyProperty.cs index ef33f128..ea24c50e 100644 --- a/sources/ClangSharp.Interop/CXPrintingPolicyProperty.cs +++ b/sources/ClangSharp.Interop/CXPrintingPolicyProperty.cs @@ -3,36 +3,35 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXPrintingPolicyProperty { - public enum CXPrintingPolicyProperty - { - CXPrintingPolicy_Indentation, - CXPrintingPolicy_SuppressSpecifiers, - CXPrintingPolicy_SuppressTagKeyword, - CXPrintingPolicy_IncludeTagDefinition, - CXPrintingPolicy_SuppressScope, - CXPrintingPolicy_SuppressUnwrittenScope, - CXPrintingPolicy_SuppressInitializers, - CXPrintingPolicy_ConstantArraySizeAsWritten, - CXPrintingPolicy_AnonymousTagLocations, - CXPrintingPolicy_SuppressStrongLifetime, - CXPrintingPolicy_SuppressLifetimeQualifiers, - CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, - CXPrintingPolicy_Bool, - CXPrintingPolicy_Restrict, - CXPrintingPolicy_Alignof, - CXPrintingPolicy_UnderscoreAlignof, - CXPrintingPolicy_UseVoidForZeroParams, - CXPrintingPolicy_TerseOutput, - CXPrintingPolicy_PolishForDeclaration, - CXPrintingPolicy_Half, - CXPrintingPolicy_MSWChar, - CXPrintingPolicy_IncludeNewlines, - CXPrintingPolicy_MSVCFormatting, - CXPrintingPolicy_ConstantsAsWritten, - CXPrintingPolicy_SuppressImplicitBase, - CXPrintingPolicy_FullyQualifiedName, - CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName, - } + CXPrintingPolicy_Indentation, + CXPrintingPolicy_SuppressSpecifiers, + CXPrintingPolicy_SuppressTagKeyword, + CXPrintingPolicy_IncludeTagDefinition, + CXPrintingPolicy_SuppressScope, + CXPrintingPolicy_SuppressUnwrittenScope, + CXPrintingPolicy_SuppressInitializers, + CXPrintingPolicy_ConstantArraySizeAsWritten, + CXPrintingPolicy_AnonymousTagLocations, + CXPrintingPolicy_SuppressStrongLifetime, + CXPrintingPolicy_SuppressLifetimeQualifiers, + CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, + CXPrintingPolicy_Bool, + CXPrintingPolicy_Restrict, + CXPrintingPolicy_Alignof, + CXPrintingPolicy_UnderscoreAlignof, + CXPrintingPolicy_UseVoidForZeroParams, + CXPrintingPolicy_TerseOutput, + CXPrintingPolicy_PolishForDeclaration, + CXPrintingPolicy_Half, + CXPrintingPolicy_MSWChar, + CXPrintingPolicy_IncludeNewlines, + CXPrintingPolicy_MSVCFormatting, + CXPrintingPolicy_ConstantsAsWritten, + CXPrintingPolicy_SuppressImplicitBase, + CXPrintingPolicy_FullyQualifiedName, + CXPrintingPolicy_LastProperty = CXPrintingPolicy_FullyQualifiedName, } diff --git a/sources/ClangSharp.Interop/CXRefQualifierKind.cs b/sources/ClangSharp.Interop/CXRefQualifierKind.cs index 265ecbe0..a076b1b5 100644 --- a/sources/ClangSharp.Interop/CXRefQualifierKind.cs +++ b/sources/ClangSharp.Interop/CXRefQualifierKind.cs @@ -3,12 +3,11 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXRefQualifierKind { - public enum CXRefQualifierKind - { - CXRefQualifier_None = 0, - CXRefQualifier_LValue, - CXRefQualifier_RValue, - } + CXRefQualifier_None = 0, + CXRefQualifier_LValue, + CXRefQualifier_RValue, } diff --git a/sources/ClangSharp.Interop/CXReparse_Flags.cs b/sources/ClangSharp.Interop/CXReparse_Flags.cs index 146df608..4dfa3a01 100644 --- a/sources/ClangSharp.Interop/CXReparse_Flags.cs +++ b/sources/ClangSharp.Interop/CXReparse_Flags.cs @@ -3,10 +3,9 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXReparse_Flags { - public enum CXReparse_Flags - { - CXReparse_None = 0x0, - } + CXReparse_None = 0x0, } diff --git a/sources/ClangSharp.Interop/CXResult.cs b/sources/ClangSharp.Interop/CXResult.cs index 7eca03c7..80c7c445 100644 --- a/sources/ClangSharp.Interop/CXResult.cs +++ b/sources/ClangSharp.Interop/CXResult.cs @@ -3,12 +3,11 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXResult { - public enum CXResult - { - CXResult_Success = 0, - CXResult_Invalid = 1, - CXResult_VisitBreak = 2, - } + CXResult_Success = 0, + CXResult_Invalid = 1, + CXResult_VisitBreak = 2, } diff --git a/sources/ClangSharp.Interop/CXSaveError.cs b/sources/ClangSharp.Interop/CXSaveError.cs index 12576a60..d22f73f9 100644 --- a/sources/ClangSharp.Interop/CXSaveError.cs +++ b/sources/ClangSharp.Interop/CXSaveError.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXSaveError { - public enum CXSaveError - { - CXSaveError_None = 0, - CXSaveError_Unknown = 1, - CXSaveError_TranslationErrors = 2, - CXSaveError_InvalidTU = 3, - } + CXSaveError_None = 0, + CXSaveError_Unknown = 1, + CXSaveError_TranslationErrors = 2, + CXSaveError_InvalidTU = 3, } diff --git a/sources/ClangSharp.Interop/CXSaveTranslationUnit_Flags.cs b/sources/ClangSharp.Interop/CXSaveTranslationUnit_Flags.cs index 6c8e24cb..5c35b3ef 100644 --- a/sources/ClangSharp.Interop/CXSaveTranslationUnit_Flags.cs +++ b/sources/ClangSharp.Interop/CXSaveTranslationUnit_Flags.cs @@ -3,10 +3,9 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXSaveTranslationUnit_Flags { - public enum CXSaveTranslationUnit_Flags - { - CXSaveTranslationUnit_None = 0x0, - } + CXSaveTranslationUnit_None = 0x0, } diff --git a/sources/ClangSharp.Interop/CXSourceLocation.cs b/sources/ClangSharp.Interop/CXSourceLocation.cs index 1b753711..ba6dcd9b 100644 --- a/sources/ClangSharp.Interop/CXSourceLocation.cs +++ b/sources/ClangSharp.Interop/CXSourceLocation.cs @@ -3,29 +3,28 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXSourceLocation { - public partial struct CXSourceLocation - { - [NativeTypeName("const void *[2]")] - public _ptr_data_e__FixedBuffer ptr_data; + [NativeTypeName("const void *[2]")] + public _ptr_data_e__FixedBuffer ptr_data; - [NativeTypeName("unsigned int")] - public uint int_data; + [NativeTypeName("unsigned int")] + public uint int_data; - public unsafe partial struct _ptr_data_e__FixedBuffer - { - public void* e0; - public void* e1; + public unsafe partial struct _ptr_data_e__FixedBuffer + { + public void* e0; + public void* e1; - public ref void* this[int index] + public ref void* this[int index] + { + get { - get + fixed (void** pThis = &e0) { - fixed (void** pThis = &e0) - { - return ref pThis[index]; - } + return ref pThis[index]; } } } diff --git a/sources/ClangSharp.Interop/CXSourceRange.cs b/sources/ClangSharp.Interop/CXSourceRange.cs index eb91824e..28e69953 100644 --- a/sources/ClangSharp.Interop/CXSourceRange.cs +++ b/sources/ClangSharp.Interop/CXSourceRange.cs @@ -3,32 +3,31 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXSourceRange { - public partial struct CXSourceRange - { - [NativeTypeName("const void *[2]")] - public _ptr_data_e__FixedBuffer ptr_data; + [NativeTypeName("const void *[2]")] + public _ptr_data_e__FixedBuffer ptr_data; - [NativeTypeName("unsigned int")] - public uint begin_int_data; + [NativeTypeName("unsigned int")] + public uint begin_int_data; - [NativeTypeName("unsigned int")] - public uint end_int_data; + [NativeTypeName("unsigned int")] + public uint end_int_data; - public unsafe partial struct _ptr_data_e__FixedBuffer - { - public void* e0; - public void* e1; + public unsafe partial struct _ptr_data_e__FixedBuffer + { + public void* e0; + public void* e1; - public ref void* this[int index] + public ref void* this[int index] + { + get { - get + fixed (void** pThis = &e0) { - fixed (void** pThis = &e0) - { - return ref pThis[index]; - } + return ref pThis[index]; } } } diff --git a/sources/ClangSharp.Interop/CXSourceRangeList.cs b/sources/ClangSharp.Interop/CXSourceRangeList.cs index cfc62dc7..4babdf7e 100644 --- a/sources/ClangSharp.Interop/CXSourceRangeList.cs +++ b/sources/ClangSharp.Interop/CXSourceRangeList.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXSourceRangeList { - public unsafe partial struct CXSourceRangeList - { - [NativeTypeName("unsigned int")] - public uint count; + [NativeTypeName("unsigned int")] + public uint count; - public CXSourceRange* ranges; - } + public CXSourceRange* ranges; } diff --git a/sources/ClangSharp.Interop/CXString.cs b/sources/ClangSharp.Interop/CXString.cs index 0bc028b3..b5769f22 100644 --- a/sources/ClangSharp.Interop/CXString.cs +++ b/sources/ClangSharp.Interop/CXString.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXString { - public unsafe partial struct CXString - { - [NativeTypeName("const void *")] - public void* data; + [NativeTypeName("const void *")] + public void* data; - [NativeTypeName("unsigned int")] - public uint private_flags; - } + [NativeTypeName("unsigned int")] + public uint private_flags; } diff --git a/sources/ClangSharp.Interop/CXStringSet.cs b/sources/ClangSharp.Interop/CXStringSet.cs index 30c88dd2..81758c0c 100644 --- a/sources/ClangSharp.Interop/CXStringSet.cs +++ b/sources/ClangSharp.Interop/CXStringSet.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXStringSet { - public unsafe partial struct CXStringSet - { - public CXString* Strings; + public CXString* Strings; - [NativeTypeName("unsigned int")] - public uint Count; - } + [NativeTypeName("unsigned int")] + public uint Count; } diff --git a/sources/ClangSharp.Interop/CXSymbolRole.cs b/sources/ClangSharp.Interop/CXSymbolRole.cs index 5c6d63c7..24b4bd3c 100644 --- a/sources/ClangSharp.Interop/CXSymbolRole.cs +++ b/sources/ClangSharp.Interop/CXSymbolRole.cs @@ -3,19 +3,18 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXSymbolRole { - public enum CXSymbolRole - { - CXSymbolRole_None = 0, - CXSymbolRole_Declaration = 1 << 0, - CXSymbolRole_Definition = 1 << 1, - CXSymbolRole_Reference = 1 << 2, - CXSymbolRole_Read = 1 << 3, - CXSymbolRole_Write = 1 << 4, - CXSymbolRole_Call = 1 << 5, - CXSymbolRole_Dynamic = 1 << 6, - CXSymbolRole_AddressOf = 1 << 7, - CXSymbolRole_Implicit = 1 << 8, - } + CXSymbolRole_None = 0, + CXSymbolRole_Declaration = 1 << 0, + CXSymbolRole_Definition = 1 << 1, + CXSymbolRole_Reference = 1 << 2, + CXSymbolRole_Read = 1 << 3, + CXSymbolRole_Write = 1 << 4, + CXSymbolRole_Call = 1 << 5, + CXSymbolRole_Dynamic = 1 << 6, + CXSymbolRole_AddressOf = 1 << 7, + CXSymbolRole_Implicit = 1 << 8, } diff --git a/sources/ClangSharp.Interop/CXTLSKind.cs b/sources/ClangSharp.Interop/CXTLSKind.cs index da45a1c9..cc062b3a 100644 --- a/sources/ClangSharp.Interop/CXTLSKind.cs +++ b/sources/ClangSharp.Interop/CXTLSKind.cs @@ -3,12 +3,11 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXTLSKind { - public enum CXTLSKind - { - CXTLS_None = 0, - CXTLS_Dynamic, - CXTLS_Static, - } + CXTLS_None = 0, + CXTLS_Dynamic, + CXTLS_Static, } diff --git a/sources/ClangSharp.Interop/CXTUResourceUsage.cs b/sources/ClangSharp.Interop/CXTUResourceUsage.cs index 04894c94..c685a465 100644 --- a/sources/ClangSharp.Interop/CXTUResourceUsage.cs +++ b/sources/ClangSharp.Interop/CXTUResourceUsage.cs @@ -3,15 +3,14 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXTUResourceUsage { - public unsafe partial struct CXTUResourceUsage - { - public void* data; + public void* data; - [NativeTypeName("unsigned int")] - public uint numEntries; + [NativeTypeName("unsigned int")] + public uint numEntries; - public CXTUResourceUsageEntry* entries; - } + public CXTUResourceUsageEntry* entries; } diff --git a/sources/ClangSharp.Interop/CXTUResourceUsageEntry.cs b/sources/ClangSharp.Interop/CXTUResourceUsageEntry.cs index 41e5ac3d..ddf5bb93 100644 --- a/sources/ClangSharp.Interop/CXTUResourceUsageEntry.cs +++ b/sources/ClangSharp.Interop/CXTUResourceUsageEntry.cs @@ -5,14 +5,13 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXTUResourceUsageEntry { - public partial struct CXTUResourceUsageEntry - { - [NativeTypeName("enum CXTUResourceUsageKind")] - public CXTUResourceUsageKind kind; + [NativeTypeName("enum CXTUResourceUsageKind")] + public CXTUResourceUsageKind kind; - [NativeTypeName("unsigned long")] - public UIntPtr amount; - } + [NativeTypeName("unsigned long")] + public UIntPtr amount; } diff --git a/sources/ClangSharp.Interop/CXTUResourceUsageKind.cs b/sources/ClangSharp.Interop/CXTUResourceUsageKind.cs index faae467e..5ad0a586 100644 --- a/sources/ClangSharp.Interop/CXTUResourceUsageKind.cs +++ b/sources/ClangSharp.Interop/CXTUResourceUsageKind.cs @@ -3,27 +3,26 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXTUResourceUsageKind { - public enum CXTUResourceUsageKind - { - CXTUResourceUsage_AST = 1, - CXTUResourceUsage_Identifiers = 2, - CXTUResourceUsage_Selectors = 3, - CXTUResourceUsage_GlobalCompletionResults = 4, - CXTUResourceUsage_SourceManagerContentCache = 5, - CXTUResourceUsage_AST_SideTables = 6, - CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, - CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, - CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, - CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, - CXTUResourceUsage_Preprocessor = 11, - CXTUResourceUsage_PreprocessingRecord = 12, - CXTUResourceUsage_SourceManager_DataStructures = 13, - CXTUResourceUsage_Preprocessor_HeaderSearch = 14, - CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, - CXTUResourceUsage_MEMORY_IN_BYTES_END = CXTUResourceUsage_Preprocessor_HeaderSearch, - CXTUResourceUsage_First = CXTUResourceUsage_AST, - CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch, - } + CXTUResourceUsage_AST = 1, + CXTUResourceUsage_Identifiers = 2, + CXTUResourceUsage_Selectors = 3, + CXTUResourceUsage_GlobalCompletionResults = 4, + CXTUResourceUsage_SourceManagerContentCache = 5, + CXTUResourceUsage_AST_SideTables = 6, + CXTUResourceUsage_SourceManager_Membuffer_Malloc = 7, + CXTUResourceUsage_SourceManager_Membuffer_MMap = 8, + CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc = 9, + CXTUResourceUsage_ExternalASTSource_Membuffer_MMap = 10, + CXTUResourceUsage_Preprocessor = 11, + CXTUResourceUsage_PreprocessingRecord = 12, + CXTUResourceUsage_SourceManager_DataStructures = 13, + CXTUResourceUsage_Preprocessor_HeaderSearch = 14, + CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST, + CXTUResourceUsage_MEMORY_IN_BYTES_END = CXTUResourceUsage_Preprocessor_HeaderSearch, + CXTUResourceUsage_First = CXTUResourceUsage_AST, + CXTUResourceUsage_Last = CXTUResourceUsage_Preprocessor_HeaderSearch, } diff --git a/sources/ClangSharp.Interop/CXTargetInfoImpl.cs b/sources/ClangSharp.Interop/CXTargetInfoImpl.cs index b2a04aff..cba81fef 100644 --- a/sources/ClangSharp.Interop/CXTargetInfoImpl.cs +++ b/sources/ClangSharp.Interop/CXTargetInfoImpl.cs @@ -3,9 +3,8 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXTargetInfoImpl { - public partial struct CXTargetInfoImpl - { - } } diff --git a/sources/ClangSharp.Interop/CXTemplateArgumentKind.cs b/sources/ClangSharp.Interop/CXTemplateArgumentKind.cs index f8c32647..f7ce4797 100644 --- a/sources/ClangSharp.Interop/CXTemplateArgumentKind.cs +++ b/sources/ClangSharp.Interop/CXTemplateArgumentKind.cs @@ -3,19 +3,18 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXTemplateArgumentKind { - public enum CXTemplateArgumentKind - { - CXTemplateArgumentKind_Null, - CXTemplateArgumentKind_Type, - CXTemplateArgumentKind_Declaration, - CXTemplateArgumentKind_NullPtr, - CXTemplateArgumentKind_Integral, - CXTemplateArgumentKind_Template, - CXTemplateArgumentKind_TemplateExpansion, - CXTemplateArgumentKind_Expression, - CXTemplateArgumentKind_Pack, - CXTemplateArgumentKind_Invalid, - } + CXTemplateArgumentKind_Null, + CXTemplateArgumentKind_Type, + CXTemplateArgumentKind_Declaration, + CXTemplateArgumentKind_NullPtr, + CXTemplateArgumentKind_Integral, + CXTemplateArgumentKind_Template, + CXTemplateArgumentKind_TemplateExpansion, + CXTemplateArgumentKind_Expression, + CXTemplateArgumentKind_Pack, + CXTemplateArgumentKind_Invalid, } diff --git a/sources/ClangSharp.Interop/CXToken.cs b/sources/ClangSharp.Interop/CXToken.cs index 32b6af4d..591a125d 100644 --- a/sources/ClangSharp.Interop/CXToken.cs +++ b/sources/ClangSharp.Interop/CXToken.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXToken { - public unsafe partial struct CXToken - { - [NativeTypeName("unsigned int [4]")] - public fixed uint int_data[4]; + [NativeTypeName("unsigned int [4]")] + public fixed uint int_data[4]; - public void* ptr_data; - } + public void* ptr_data; } diff --git a/sources/ClangSharp.Interop/CXTokenKind.cs b/sources/ClangSharp.Interop/CXTokenKind.cs index 96db2609..1b91361c 100644 --- a/sources/ClangSharp.Interop/CXTokenKind.cs +++ b/sources/ClangSharp.Interop/CXTokenKind.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXTokenKind { - public enum CXTokenKind - { - CXToken_Punctuation, - CXToken_Keyword, - CXToken_Identifier, - CXToken_Literal, - CXToken_Comment, - } + CXToken_Punctuation, + CXToken_Keyword, + CXToken_Identifier, + CXToken_Literal, + CXToken_Comment, } diff --git a/sources/ClangSharp.Interop/CXTranslationUnitImpl.cs b/sources/ClangSharp.Interop/CXTranslationUnitImpl.cs index bd5c8b0b..2a505185 100644 --- a/sources/ClangSharp.Interop/CXTranslationUnitImpl.cs +++ b/sources/ClangSharp.Interop/CXTranslationUnitImpl.cs @@ -3,9 +3,8 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXTranslationUnitImpl { - public partial struct CXTranslationUnitImpl - { - } } diff --git a/sources/ClangSharp.Interop/CXTranslationUnit_Flags.cs b/sources/ClangSharp.Interop/CXTranslationUnit_Flags.cs index c108f856..3d9f2561 100644 --- a/sources/ClangSharp.Interop/CXTranslationUnit_Flags.cs +++ b/sources/ClangSharp.Interop/CXTranslationUnit_Flags.cs @@ -3,26 +3,25 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXTranslationUnit_Flags { - public enum CXTranslationUnit_Flags - { - CXTranslationUnit_None = 0x0, - CXTranslationUnit_DetailedPreprocessingRecord = 0x01, - CXTranslationUnit_Incomplete = 0x02, - CXTranslationUnit_PrecompiledPreamble = 0x04, - CXTranslationUnit_CacheCompletionResults = 0x08, - CXTranslationUnit_ForSerialization = 0x10, - CXTranslationUnit_CXXChainedPCH = 0x20, - CXTranslationUnit_SkipFunctionBodies = 0x40, - CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80, - CXTranslationUnit_CreatePreambleOnFirstParse = 0x100, - CXTranslationUnit_KeepGoing = 0x200, - CXTranslationUnit_SingleFileParse = 0x400, - CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800, - CXTranslationUnit_IncludeAttributedTypes = 0x1000, - CXTranslationUnit_VisitImplicitAttributes = 0x2000, - CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000, - CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000, - } + CXTranslationUnit_None = 0x0, + CXTranslationUnit_DetailedPreprocessingRecord = 0x01, + CXTranslationUnit_Incomplete = 0x02, + CXTranslationUnit_PrecompiledPreamble = 0x04, + CXTranslationUnit_CacheCompletionResults = 0x08, + CXTranslationUnit_ForSerialization = 0x10, + CXTranslationUnit_CXXChainedPCH = 0x20, + CXTranslationUnit_SkipFunctionBodies = 0x40, + CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = 0x80, + CXTranslationUnit_CreatePreambleOnFirstParse = 0x100, + CXTranslationUnit_KeepGoing = 0x200, + CXTranslationUnit_SingleFileParse = 0x400, + CXTranslationUnit_LimitSkipFunctionBodiesToPreamble = 0x800, + CXTranslationUnit_IncludeAttributedTypes = 0x1000, + CXTranslationUnit_VisitImplicitAttributes = 0x2000, + CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles = 0x4000, + CXTranslationUnit_RetainExcludedConditionalBlocks = 0x8000, } diff --git a/sources/ClangSharp.Interop/CXType.cs b/sources/ClangSharp.Interop/CXType.cs index 7d3edb25..4b19a645 100644 --- a/sources/ClangSharp.Interop/CXType.cs +++ b/sources/ClangSharp.Interop/CXType.cs @@ -3,29 +3,28 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXType { - public partial struct CXType - { - [NativeTypeName("enum CXTypeKind")] - public CXTypeKind kind; + [NativeTypeName("enum CXTypeKind")] + public CXTypeKind kind; - [NativeTypeName("void *[2]")] - public _data_e__FixedBuffer data; + [NativeTypeName("void *[2]")] + public _data_e__FixedBuffer data; - public unsafe partial struct _data_e__FixedBuffer - { - public void* e0; - public void* e1; + public unsafe partial struct _data_e__FixedBuffer + { + public void* e0; + public void* e1; - public ref void* this[int index] + public ref void* this[int index] + { + get { - get + fixed (void** pThis = &e0) { - fixed (void** pThis = &e0) - { - return ref pThis[index]; - } + return ref pThis[index]; } } } diff --git a/sources/ClangSharp.Interop/CXTypeKind.cs b/sources/ClangSharp.Interop/CXTypeKind.cs index 0e843c84..6b661e57 100644 --- a/sources/ClangSharp.Interop/CXTypeKind.cs +++ b/sources/ClangSharp.Interop/CXTypeKind.cs @@ -3,130 +3,129 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXTypeKind { - public enum CXTypeKind - { - CXType_Invalid = 0, - CXType_Unexposed = 1, - CXType_Void = 2, - CXType_Bool = 3, - CXType_Char_U = 4, - CXType_UChar = 5, - CXType_Char16 = 6, - CXType_Char32 = 7, - CXType_UShort = 8, - CXType_UInt = 9, - CXType_ULong = 10, - CXType_ULongLong = 11, - CXType_UInt128 = 12, - CXType_Char_S = 13, - CXType_SChar = 14, - CXType_WChar = 15, - CXType_Short = 16, - CXType_Int = 17, - CXType_Long = 18, - CXType_LongLong = 19, - CXType_Int128 = 20, - CXType_Float = 21, - CXType_Double = 22, - CXType_LongDouble = 23, - CXType_NullPtr = 24, - CXType_Overload = 25, - CXType_Dependent = 26, - CXType_ObjCId = 27, - CXType_ObjCClass = 28, - CXType_ObjCSel = 29, - CXType_Float128 = 30, - CXType_Half = 31, - CXType_Float16 = 32, - CXType_ShortAccum = 33, - CXType_Accum = 34, - CXType_LongAccum = 35, - CXType_UShortAccum = 36, - CXType_UAccum = 37, - CXType_ULongAccum = 38, - CXType_BFloat16 = 39, - CXType_Ibm128 = 40, - CXType_FirstBuiltin = CXType_Void, - CXType_LastBuiltin = CXType_Ibm128, - CXType_Complex = 100, - CXType_Pointer = 101, - CXType_BlockPointer = 102, - CXType_LValueReference = 103, - CXType_RValueReference = 104, - CXType_Record = 105, - CXType_Enum = 106, - CXType_Typedef = 107, - CXType_ObjCInterface = 108, - CXType_ObjCObjectPointer = 109, - CXType_FunctionNoProto = 110, - CXType_FunctionProto = 111, - CXType_ConstantArray = 112, - CXType_Vector = 113, - CXType_IncompleteArray = 114, - CXType_VariableArray = 115, - CXType_DependentSizedArray = 116, - CXType_MemberPointer = 117, - CXType_Auto = 118, - CXType_Elaborated = 119, - CXType_Pipe = 120, - CXType_OCLImage1dRO = 121, - CXType_OCLImage1dArrayRO = 122, - CXType_OCLImage1dBufferRO = 123, - CXType_OCLImage2dRO = 124, - CXType_OCLImage2dArrayRO = 125, - CXType_OCLImage2dDepthRO = 126, - CXType_OCLImage2dArrayDepthRO = 127, - CXType_OCLImage2dMSAARO = 128, - CXType_OCLImage2dArrayMSAARO = 129, - CXType_OCLImage2dMSAADepthRO = 130, - CXType_OCLImage2dArrayMSAADepthRO = 131, - CXType_OCLImage3dRO = 132, - CXType_OCLImage1dWO = 133, - CXType_OCLImage1dArrayWO = 134, - CXType_OCLImage1dBufferWO = 135, - CXType_OCLImage2dWO = 136, - CXType_OCLImage2dArrayWO = 137, - CXType_OCLImage2dDepthWO = 138, - CXType_OCLImage2dArrayDepthWO = 139, - CXType_OCLImage2dMSAAWO = 140, - CXType_OCLImage2dArrayMSAAWO = 141, - CXType_OCLImage2dMSAADepthWO = 142, - CXType_OCLImage2dArrayMSAADepthWO = 143, - CXType_OCLImage3dWO = 144, - CXType_OCLImage1dRW = 145, - CXType_OCLImage1dArrayRW = 146, - CXType_OCLImage1dBufferRW = 147, - CXType_OCLImage2dRW = 148, - CXType_OCLImage2dArrayRW = 149, - CXType_OCLImage2dDepthRW = 150, - CXType_OCLImage2dArrayDepthRW = 151, - CXType_OCLImage2dMSAARW = 152, - CXType_OCLImage2dArrayMSAARW = 153, - CXType_OCLImage2dMSAADepthRW = 154, - CXType_OCLImage2dArrayMSAADepthRW = 155, - CXType_OCLImage3dRW = 156, - CXType_OCLSampler = 157, - CXType_OCLEvent = 158, - CXType_OCLQueue = 159, - CXType_OCLReserveID = 160, - CXType_ObjCObject = 161, - CXType_ObjCTypeParam = 162, - CXType_Attributed = 163, - CXType_OCLIntelSubgroupAVCMcePayload = 164, - CXType_OCLIntelSubgroupAVCImePayload = 165, - CXType_OCLIntelSubgroupAVCRefPayload = 166, - CXType_OCLIntelSubgroupAVCSicPayload = 167, - CXType_OCLIntelSubgroupAVCMceResult = 168, - CXType_OCLIntelSubgroupAVCImeResult = 169, - CXType_OCLIntelSubgroupAVCRefResult = 170, - CXType_OCLIntelSubgroupAVCSicResult = 171, - CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172, - CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173, - CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174, - CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175, - CXType_ExtVector = 176, - CXType_Atomic = 177, - } + CXType_Invalid = 0, + CXType_Unexposed = 1, + CXType_Void = 2, + CXType_Bool = 3, + CXType_Char_U = 4, + CXType_UChar = 5, + CXType_Char16 = 6, + CXType_Char32 = 7, + CXType_UShort = 8, + CXType_UInt = 9, + CXType_ULong = 10, + CXType_ULongLong = 11, + CXType_UInt128 = 12, + CXType_Char_S = 13, + CXType_SChar = 14, + CXType_WChar = 15, + CXType_Short = 16, + CXType_Int = 17, + CXType_Long = 18, + CXType_LongLong = 19, + CXType_Int128 = 20, + CXType_Float = 21, + CXType_Double = 22, + CXType_LongDouble = 23, + CXType_NullPtr = 24, + CXType_Overload = 25, + CXType_Dependent = 26, + CXType_ObjCId = 27, + CXType_ObjCClass = 28, + CXType_ObjCSel = 29, + CXType_Float128 = 30, + CXType_Half = 31, + CXType_Float16 = 32, + CXType_ShortAccum = 33, + CXType_Accum = 34, + CXType_LongAccum = 35, + CXType_UShortAccum = 36, + CXType_UAccum = 37, + CXType_ULongAccum = 38, + CXType_BFloat16 = 39, + CXType_Ibm128 = 40, + CXType_FirstBuiltin = CXType_Void, + CXType_LastBuiltin = CXType_Ibm128, + CXType_Complex = 100, + CXType_Pointer = 101, + CXType_BlockPointer = 102, + CXType_LValueReference = 103, + CXType_RValueReference = 104, + CXType_Record = 105, + CXType_Enum = 106, + CXType_Typedef = 107, + CXType_ObjCInterface = 108, + CXType_ObjCObjectPointer = 109, + CXType_FunctionNoProto = 110, + CXType_FunctionProto = 111, + CXType_ConstantArray = 112, + CXType_Vector = 113, + CXType_IncompleteArray = 114, + CXType_VariableArray = 115, + CXType_DependentSizedArray = 116, + CXType_MemberPointer = 117, + CXType_Auto = 118, + CXType_Elaborated = 119, + CXType_Pipe = 120, + CXType_OCLImage1dRO = 121, + CXType_OCLImage1dArrayRO = 122, + CXType_OCLImage1dBufferRO = 123, + CXType_OCLImage2dRO = 124, + CXType_OCLImage2dArrayRO = 125, + CXType_OCLImage2dDepthRO = 126, + CXType_OCLImage2dArrayDepthRO = 127, + CXType_OCLImage2dMSAARO = 128, + CXType_OCLImage2dArrayMSAARO = 129, + CXType_OCLImage2dMSAADepthRO = 130, + CXType_OCLImage2dArrayMSAADepthRO = 131, + CXType_OCLImage3dRO = 132, + CXType_OCLImage1dWO = 133, + CXType_OCLImage1dArrayWO = 134, + CXType_OCLImage1dBufferWO = 135, + CXType_OCLImage2dWO = 136, + CXType_OCLImage2dArrayWO = 137, + CXType_OCLImage2dDepthWO = 138, + CXType_OCLImage2dArrayDepthWO = 139, + CXType_OCLImage2dMSAAWO = 140, + CXType_OCLImage2dArrayMSAAWO = 141, + CXType_OCLImage2dMSAADepthWO = 142, + CXType_OCLImage2dArrayMSAADepthWO = 143, + CXType_OCLImage3dWO = 144, + CXType_OCLImage1dRW = 145, + CXType_OCLImage1dArrayRW = 146, + CXType_OCLImage1dBufferRW = 147, + CXType_OCLImage2dRW = 148, + CXType_OCLImage2dArrayRW = 149, + CXType_OCLImage2dDepthRW = 150, + CXType_OCLImage2dArrayDepthRW = 151, + CXType_OCLImage2dMSAARW = 152, + CXType_OCLImage2dArrayMSAARW = 153, + CXType_OCLImage2dMSAADepthRW = 154, + CXType_OCLImage2dArrayMSAADepthRW = 155, + CXType_OCLImage3dRW = 156, + CXType_OCLSampler = 157, + CXType_OCLEvent = 158, + CXType_OCLQueue = 159, + CXType_OCLReserveID = 160, + CXType_ObjCObject = 161, + CXType_ObjCTypeParam = 162, + CXType_Attributed = 163, + CXType_OCLIntelSubgroupAVCMcePayload = 164, + CXType_OCLIntelSubgroupAVCImePayload = 165, + CXType_OCLIntelSubgroupAVCRefPayload = 166, + CXType_OCLIntelSubgroupAVCSicPayload = 167, + CXType_OCLIntelSubgroupAVCMceResult = 168, + CXType_OCLIntelSubgroupAVCImeResult = 169, + CXType_OCLIntelSubgroupAVCRefResult = 170, + CXType_OCLIntelSubgroupAVCSicResult = 171, + CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172, + CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173, + CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174, + CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175, + CXType_ExtVector = 176, + CXType_Atomic = 177, } diff --git a/sources/ClangSharp.Interop/CXTypeLayoutError.cs b/sources/ClangSharp.Interop/CXTypeLayoutError.cs index 3f497f14..1d301ac7 100644 --- a/sources/ClangSharp.Interop/CXTypeLayoutError.cs +++ b/sources/ClangSharp.Interop/CXTypeLayoutError.cs @@ -3,15 +3,14 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXTypeLayoutError { - public enum CXTypeLayoutError - { - CXTypeLayoutError_Invalid = -1, - CXTypeLayoutError_Incomplete = -2, - CXTypeLayoutError_Dependent = -3, - CXTypeLayoutError_NotConstantSize = -4, - CXTypeLayoutError_InvalidFieldName = -5, - CXTypeLayoutError_Undeduced = -6, - } + CXTypeLayoutError_Invalid = -1, + CXTypeLayoutError_Incomplete = -2, + CXTypeLayoutError_Dependent = -3, + CXTypeLayoutError_NotConstantSize = -4, + CXTypeLayoutError_InvalidFieldName = -5, + CXTypeLayoutError_Undeduced = -6, } diff --git a/sources/ClangSharp.Interop/CXTypeNullabilityKind.cs b/sources/ClangSharp.Interop/CXTypeNullabilityKind.cs index 3291df34..42800797 100644 --- a/sources/ClangSharp.Interop/CXTypeNullabilityKind.cs +++ b/sources/ClangSharp.Interop/CXTypeNullabilityKind.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXTypeNullabilityKind { - public enum CXTypeNullabilityKind - { - CXTypeNullability_NonNull = 0, - CXTypeNullability_Nullable = 1, - CXTypeNullability_Unspecified = 2, - CXTypeNullability_Invalid = 3, - CXTypeNullability_NullableResult = 4, - } + CXTypeNullability_NonNull = 0, + CXTypeNullability_Nullable = 1, + CXTypeNullability_Unspecified = 2, + CXTypeNullability_Invalid = 3, + CXTypeNullability_NullableResult = 4, } diff --git a/sources/ClangSharp.Interop/CXUnsavedFile.cs b/sources/ClangSharp.Interop/CXUnsavedFile.cs index be17a965..2c889ce3 100644 --- a/sources/ClangSharp.Interop/CXUnsavedFile.cs +++ b/sources/ClangSharp.Interop/CXUnsavedFile.cs @@ -5,17 +5,16 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXUnsavedFile { - public unsafe partial struct CXUnsavedFile - { - [NativeTypeName("const char *")] - public sbyte* Filename; + [NativeTypeName("const char *")] + public sbyte* Filename; - [NativeTypeName("const char *")] - public sbyte* Contents; + [NativeTypeName("const char *")] + public sbyte* Contents; - [NativeTypeName("unsigned long")] - public UIntPtr Length; - } + [NativeTypeName("unsigned long")] + public UIntPtr Length; } diff --git a/sources/ClangSharp.Interop/CXVersion.cs b/sources/ClangSharp.Interop/CXVersion.cs index 7134d2b2..d291b6a1 100644 --- a/sources/ClangSharp.Interop/CXVersion.cs +++ b/sources/ClangSharp.Interop/CXVersion.cs @@ -3,14 +3,13 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXVersion { - public partial struct CXVersion - { - public int Major; + public int Major; - public int Minor; + public int Minor; - public int Subminor; - } + public int Subminor; } diff --git a/sources/ClangSharp.Interop/CXVirtualFileOverlayImpl.cs b/sources/ClangSharp.Interop/CXVirtualFileOverlayImpl.cs index 08c6d42c..3d5f3376 100644 --- a/sources/ClangSharp.Interop/CXVirtualFileOverlayImpl.cs +++ b/sources/ClangSharp.Interop/CXVirtualFileOverlayImpl.cs @@ -3,9 +3,8 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXVirtualFileOverlayImpl { - public partial struct CXVirtualFileOverlayImpl - { - } } diff --git a/sources/ClangSharp.Interop/CXVisibilityKind.cs b/sources/ClangSharp.Interop/CXVisibilityKind.cs index 72fa216e..8da6a109 100644 --- a/sources/ClangSharp.Interop/CXVisibilityKind.cs +++ b/sources/ClangSharp.Interop/CXVisibilityKind.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXVisibilityKind { - public enum CXVisibilityKind - { - CXVisibility_Invalid, - CXVisibility_Hidden, - CXVisibility_Protected, - CXVisibility_Default, - } + CXVisibility_Invalid, + CXVisibility_Hidden, + CXVisibility_Protected, + CXVisibility_Default, } diff --git a/sources/ClangSharp.Interop/CXVisitorResult.cs b/sources/ClangSharp.Interop/CXVisitorResult.cs index 925f7262..2323460f 100644 --- a/sources/ClangSharp.Interop/CXVisitorResult.cs +++ b/sources/ClangSharp.Interop/CXVisitorResult.cs @@ -3,11 +3,10 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CXVisitorResult { - public enum CXVisitorResult - { - CXVisit_Break, - CXVisit_Continue, - } + CXVisit_Break, + CXVisit_Continue, } diff --git a/sources/ClangSharp.Interop/CX_AtomicOperatorKind.cs b/sources/ClangSharp.Interop/CX_AtomicOperatorKind.cs index 2c9b73e0..3bfe6431 100644 --- a/sources/ClangSharp.Interop/CX_AtomicOperatorKind.cs +++ b/sources/ClangSharp.Interop/CX_AtomicOperatorKind.cs @@ -1,72 +1,71 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_AtomicOperatorKind { - public enum CX_AtomicOperatorKind - { - CX_AO_Invalid, - CX_AO__c11_atomic_init, - CX_AO__c11_atomic_load, - CX_AO__c11_atomic_store, - CX_AO__c11_atomic_exchange, - CX_AO__c11_atomic_compare_exchange_strong, - CX_AO__c11_atomic_compare_exchange_weak, - CX_AO__c11_atomic_fetch_add, - CX_AO__c11_atomic_fetch_sub, - CX_AO__c11_atomic_fetch_and, - CX_AO__c11_atomic_fetch_or, - CX_AO__c11_atomic_fetch_xor, - CX_AO__c11_atomic_fetch_nand, - CX_AO__c11_atomic_fetch_max, - CX_AO__c11_atomic_fetch_min, - CX_AO__atomic_load, - CX_AO__atomic_load_n, - CX_AO__atomic_store, - CX_AO__atomic_store_n, - CX_AO__atomic_exchange, - CX_AO__atomic_exchange_n, - CX_AO__atomic_compare_exchange, - CX_AO__atomic_compare_exchange_n, - CX_AO__atomic_fetch_add, - CX_AO__atomic_fetch_sub, - CX_AO__atomic_fetch_and, - CX_AO__atomic_fetch_or, - CX_AO__atomic_fetch_xor, - CX_AO__atomic_fetch_nand, - CX_AO__atomic_add_fetch, - CX_AO__atomic_sub_fetch, - CX_AO__atomic_and_fetch, - CX_AO__atomic_or_fetch, - CX_AO__atomic_xor_fetch, - CX_AO__atomic_max_fetch, - CX_AO__atomic_min_fetch, - CX_AO__atomic_nand_fetch, - CX_AO__opencl_atomic_init, - CX_AO__opencl_atomic_load, - CX_AO__opencl_atomic_store, - CX_AO__opencl_atomic_exchange, - CX_AO__opencl_atomic_compare_exchange_strong, - CX_AO__opencl_atomic_compare_exchange_weak, - CX_AO__opencl_atomic_fetch_add, - CX_AO__opencl_atomic_fetch_sub, - CX_AO__opencl_atomic_fetch_and, - CX_AO__opencl_atomic_fetch_or, - CX_AO__opencl_atomic_fetch_xor, - CX_AO__opencl_atomic_fetch_min, - CX_AO__opencl_atomic_fetch_max, - CX_AO__atomic_fetch_min, - CX_AO__atomic_fetch_max, - CX_AO__hip_atomic_load, - CX_AO__hip_atomic_store, - CX_AO__hip_atomic_compare_exchange_weak, - CX_AO__hip_atomic_compare_exchange_strong, - CX_AO__hip_atomic_exchange, - CX_AO__hip_atomic_fetch_add, - CX_AO__hip_atomic_fetch_and, - CX_AO__hip_atomic_fetch_or, - CX_AO__hip_atomic_fetch_xor, - CX_AO__hip_atomic_fetch_min, - CX_AO__hip_atomic_fetch_max, - } + CX_AO_Invalid, + CX_AO__c11_atomic_init, + CX_AO__c11_atomic_load, + CX_AO__c11_atomic_store, + CX_AO__c11_atomic_exchange, + CX_AO__c11_atomic_compare_exchange_strong, + CX_AO__c11_atomic_compare_exchange_weak, + CX_AO__c11_atomic_fetch_add, + CX_AO__c11_atomic_fetch_sub, + CX_AO__c11_atomic_fetch_and, + CX_AO__c11_atomic_fetch_or, + CX_AO__c11_atomic_fetch_xor, + CX_AO__c11_atomic_fetch_nand, + CX_AO__c11_atomic_fetch_max, + CX_AO__c11_atomic_fetch_min, + CX_AO__atomic_load, + CX_AO__atomic_load_n, + CX_AO__atomic_store, + CX_AO__atomic_store_n, + CX_AO__atomic_exchange, + CX_AO__atomic_exchange_n, + CX_AO__atomic_compare_exchange, + CX_AO__atomic_compare_exchange_n, + CX_AO__atomic_fetch_add, + CX_AO__atomic_fetch_sub, + CX_AO__atomic_fetch_and, + CX_AO__atomic_fetch_or, + CX_AO__atomic_fetch_xor, + CX_AO__atomic_fetch_nand, + CX_AO__atomic_add_fetch, + CX_AO__atomic_sub_fetch, + CX_AO__atomic_and_fetch, + CX_AO__atomic_or_fetch, + CX_AO__atomic_xor_fetch, + CX_AO__atomic_max_fetch, + CX_AO__atomic_min_fetch, + CX_AO__atomic_nand_fetch, + CX_AO__opencl_atomic_init, + CX_AO__opencl_atomic_load, + CX_AO__opencl_atomic_store, + CX_AO__opencl_atomic_exchange, + CX_AO__opencl_atomic_compare_exchange_strong, + CX_AO__opencl_atomic_compare_exchange_weak, + CX_AO__opencl_atomic_fetch_add, + CX_AO__opencl_atomic_fetch_sub, + CX_AO__opencl_atomic_fetch_and, + CX_AO__opencl_atomic_fetch_or, + CX_AO__opencl_atomic_fetch_xor, + CX_AO__opencl_atomic_fetch_min, + CX_AO__opencl_atomic_fetch_max, + CX_AO__atomic_fetch_min, + CX_AO__atomic_fetch_max, + CX_AO__hip_atomic_load, + CX_AO__hip_atomic_store, + CX_AO__hip_atomic_compare_exchange_weak, + CX_AO__hip_atomic_compare_exchange_strong, + CX_AO__hip_atomic_exchange, + CX_AO__hip_atomic_fetch_add, + CX_AO__hip_atomic_fetch_and, + CX_AO__hip_atomic_fetch_or, + CX_AO__hip_atomic_fetch_xor, + CX_AO__hip_atomic_fetch_min, + CX_AO__hip_atomic_fetch_max, } diff --git a/sources/ClangSharp.Interop/CX_AttrKind.cs b/sources/ClangSharp.Interop/CX_AttrKind.cs index d8b235b6..b56644ad 100644 --- a/sources/ClangSharp.Interop/CX_AttrKind.cs +++ b/sources/ClangSharp.Interop/CX_AttrKind.cs @@ -1,374 +1,373 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_AttrKind { - public enum CX_AttrKind - { - CX_AttrKind_Invalid, - CX_AttrKind_AddressSpace, - CX_AttrKind_ArmMveStrictPolymorphism, - CX_AttrKind_BTFTypeTag, - CX_AttrKind_CmseNSCall, - CX_AttrKind_NoDeref, - CX_AttrKind_ObjCGC, - CX_AttrKind_ObjCInertUnsafeUnretained, - CX_AttrKind_ObjCKindOf, - CX_AttrKind_OpenCLConstantAddressSpace, - CX_AttrKind_OpenCLGenericAddressSpace, - CX_AttrKind_OpenCLGlobalAddressSpace, - CX_AttrKind_OpenCLGlobalDeviceAddressSpace, - CX_AttrKind_OpenCLGlobalHostAddressSpace, - CX_AttrKind_OpenCLLocalAddressSpace, - CX_AttrKind_OpenCLPrivateAddressSpace, - CX_AttrKind_Ptr32, - CX_AttrKind_Ptr64, - CX_AttrKind_SPtr, - CX_AttrKind_TypeNonNull, - CX_AttrKind_TypeNullUnspecified, - CX_AttrKind_TypeNullable, - CX_AttrKind_TypeNullableResult, - CX_AttrKind_UPtr, - CX_AttrKind_FallThrough, - CX_AttrKind_Likely, - CX_AttrKind_MustTail, - CX_AttrKind_OpenCLUnrollHint, - CX_AttrKind_Suppress, - CX_AttrKind_Unlikely, - CX_AttrKind_NoMerge, - CX_AttrKind_AArch64VectorPcs, - CX_AttrKind_AcquireHandle, - CX_AttrKind_AnyX86NoCfCheck, - CX_AttrKind_CDecl, - CX_AttrKind_FastCall, - CX_AttrKind_IntelOclBicc, - CX_AttrKind_LifetimeBound, - CX_AttrKind_MSABI, - CX_AttrKind_NSReturnsRetained, - CX_AttrKind_ObjCOwnership, - CX_AttrKind_Pascal, - CX_AttrKind_Pcs, - CX_AttrKind_PreserveAll, - CX_AttrKind_PreserveMost, - CX_AttrKind_RegCall, - CX_AttrKind_StdCall, - CX_AttrKind_SwiftAsyncCall, - CX_AttrKind_SwiftCall, - CX_AttrKind_SysVABI, - CX_AttrKind_ThisCall, - CX_AttrKind_VectorCall, - CX_AttrKind_SwiftAsyncContext, - CX_AttrKind_SwiftContext, - CX_AttrKind_SwiftErrorResult, - CX_AttrKind_SwiftIndirectResult, - CX_AttrKind_Annotate, - CX_AttrKind_CFConsumed, - CX_AttrKind_CarriesDependency, - CX_AttrKind_NSConsumed, - CX_AttrKind_NonNull, - CX_AttrKind_OSConsumed, - CX_AttrKind_PassObjectSize, - CX_AttrKind_ReleaseHandle, - CX_AttrKind_UseHandle, - CX_AttrKind_AMDGPUFlatWorkGroupSize, - CX_AttrKind_AMDGPUNumSGPR, - CX_AttrKind_AMDGPUNumVGPR, - CX_AttrKind_AMDGPUWavesPerEU, - CX_AttrKind_ARMInterrupt, - CX_AttrKind_AVRInterrupt, - CX_AttrKind_AVRSignal, - CX_AttrKind_AcquireCapability, - CX_AttrKind_AcquiredAfter, - CX_AttrKind_AcquiredBefore, - CX_AttrKind_AlignMac68k, - CX_AttrKind_AlignNatural, - CX_AttrKind_Aligned, - CX_AttrKind_AllocAlign, - CX_AttrKind_AllocSize, - CX_AttrKind_AlwaysDestroy, - CX_AttrKind_AlwaysInline, - CX_AttrKind_AnalyzerNoReturn, - CX_AttrKind_AnyX86Interrupt, - CX_AttrKind_AnyX86NoCallerSavedRegisters, - CX_AttrKind_ArcWeakrefUnavailable, - CX_AttrKind_ArgumentWithTypeTag, - CX_AttrKind_ArmBuiltinAlias, - CX_AttrKind_Artificial, - CX_AttrKind_AsmLabel, - CX_AttrKind_AssertCapability, - CX_AttrKind_AssertExclusiveLock, - CX_AttrKind_AssertSharedLock, - CX_AttrKind_AssumeAligned, - CX_AttrKind_Assumption, - CX_AttrKind_Availability, - CX_AttrKind_BPFPreserveAccessIndex, - CX_AttrKind_BTFDeclTag, - CX_AttrKind_Blocks, - CX_AttrKind_Builtin, - CX_AttrKind_C11NoReturn, - CX_AttrKind_CFAuditedTransfer, - CX_AttrKind_CFGuard, - CX_AttrKind_CFICanonicalJumpTable, - CX_AttrKind_CFReturnsNotRetained, - CX_AttrKind_CFReturnsRetained, - CX_AttrKind_CFUnknownTransfer, - CX_AttrKind_CPUDispatch, - CX_AttrKind_CPUSpecific, - CX_AttrKind_CUDAConstant, - CX_AttrKind_CUDADevice, - CX_AttrKind_CUDADeviceBuiltinSurfaceType, - CX_AttrKind_CUDADeviceBuiltinTextureType, - CX_AttrKind_CUDAGlobal, - CX_AttrKind_CUDAHost, - CX_AttrKind_CUDAInvalidTarget, - CX_AttrKind_CUDALaunchBounds, - CX_AttrKind_CUDAShared, - CX_AttrKind_CXX11NoReturn, - CX_AttrKind_CallableWhen, - CX_AttrKind_Callback, - CX_AttrKind_Capability, - CX_AttrKind_CapturedRecord, - CX_AttrKind_Cleanup, - CX_AttrKind_CmseNSEntry, - CX_AttrKind_CodeSeg, - CX_AttrKind_Cold, - CX_AttrKind_Common, - CX_AttrKind_Const, - CX_AttrKind_ConstInit, - CX_AttrKind_Constructor, - CX_AttrKind_Consumable, - CX_AttrKind_ConsumableAutoCast, - CX_AttrKind_ConsumableSetOnRead, - CX_AttrKind_Convergent, - CX_AttrKind_DLLExport, - CX_AttrKind_DLLExportStaticLocal, - CX_AttrKind_DLLImport, - CX_AttrKind_DLLImportStaticLocal, - CX_AttrKind_Deprecated, - CX_AttrKind_Destructor, - CX_AttrKind_DiagnoseAsBuiltin, - CX_AttrKind_DiagnoseIf, - CX_AttrKind_DisableSanitizerInstrumentation, - CX_AttrKind_DisableTailCalls, - CX_AttrKind_EmptyBases, - CX_AttrKind_EnableIf, - CX_AttrKind_EnforceTCB, - CX_AttrKind_EnforceTCBLeaf, - CX_AttrKind_EnumExtensibility, - CX_AttrKind_Error, - CX_AttrKind_ExcludeFromExplicitInstantiation, - CX_AttrKind_ExclusiveTrylockFunction, - CX_AttrKind_ExternalSourceSymbol, - CX_AttrKind_Final, - CX_AttrKind_FlagEnum, - CX_AttrKind_Flatten, - CX_AttrKind_Format, - CX_AttrKind_FormatArg, - CX_AttrKind_GNUInline, - CX_AttrKind_GuardedBy, - CX_AttrKind_GuardedVar, - CX_AttrKind_HIPManaged, - CX_AttrKind_Hot, - CX_AttrKind_IBAction, - CX_AttrKind_IBOutlet, - CX_AttrKind_IBOutletCollection, - CX_AttrKind_InitPriority, - CX_AttrKind_InternalLinkage, - CX_AttrKind_LTOVisibilityPublic, - CX_AttrKind_LayoutVersion, - CX_AttrKind_Leaf, - CX_AttrKind_LockReturned, - CX_AttrKind_LocksExcluded, - CX_AttrKind_M68kInterrupt, - CX_AttrKind_MIGServerRoutine, - CX_AttrKind_MSAllocator, - CX_AttrKind_MSInheritance, - CX_AttrKind_MSNoVTable, - CX_AttrKind_MSP430Interrupt, - CX_AttrKind_MSStruct, - CX_AttrKind_MSVtorDisp, - CX_AttrKind_MaxFieldAlignment, - CX_AttrKind_MayAlias, - CX_AttrKind_MicroMips, - CX_AttrKind_MinSize, - CX_AttrKind_MinVectorWidth, - CX_AttrKind_Mips16, - CX_AttrKind_MipsInterrupt, - CX_AttrKind_MipsLongCall, - CX_AttrKind_MipsShortCall, - CX_AttrKind_NSConsumesSelf, - CX_AttrKind_NSErrorDomain, - CX_AttrKind_NSReturnsAutoreleased, - CX_AttrKind_NSReturnsNotRetained, - CX_AttrKind_Naked, - CX_AttrKind_NoAlias, - CX_AttrKind_NoCommon, - CX_AttrKind_NoDebug, - CX_AttrKind_NoDestroy, - CX_AttrKind_NoDuplicate, - CX_AttrKind_NoInline, - CX_AttrKind_NoInstrumentFunction, - CX_AttrKind_NoMicroMips, - CX_AttrKind_NoMips16, - CX_AttrKind_NoProfileFunction, - CX_AttrKind_NoReturn, - CX_AttrKind_NoSanitize, - CX_AttrKind_NoSpeculativeLoadHardening, - CX_AttrKind_NoSplitStack, - CX_AttrKind_NoStackProtector, - CX_AttrKind_NoThreadSafetyAnalysis, - CX_AttrKind_NoThrow, - CX_AttrKind_NoUniqueAddress, - CX_AttrKind_NotTailCalled, - CX_AttrKind_OMPAllocateDecl, - CX_AttrKind_OMPCaptureNoInit, - CX_AttrKind_OMPDeclareTargetDecl, - CX_AttrKind_OMPDeclareVariant, - CX_AttrKind_OMPThreadPrivateDecl, - CX_AttrKind_OSConsumesThis, - CX_AttrKind_OSReturnsNotRetained, - CX_AttrKind_OSReturnsRetained, - CX_AttrKind_OSReturnsRetainedOnNonZero, - CX_AttrKind_OSReturnsRetainedOnZero, - CX_AttrKind_ObjCBridge, - CX_AttrKind_ObjCBridgeMutable, - CX_AttrKind_ObjCBridgeRelated, - CX_AttrKind_ObjCException, - CX_AttrKind_ObjCExplicitProtocolImpl, - CX_AttrKind_ObjCExternallyRetained, - CX_AttrKind_ObjCIndependentClass, - CX_AttrKind_ObjCMethodFamily, - CX_AttrKind_ObjCNSObject, - CX_AttrKind_ObjCPreciseLifetime, - CX_AttrKind_ObjCRequiresPropertyDefs, - CX_AttrKind_ObjCRequiresSuper, - CX_AttrKind_ObjCReturnsInnerPointer, - CX_AttrKind_ObjCRootClass, - CX_AttrKind_ObjCSubclassingRestricted, - CX_AttrKind_OpenCLIntelReqdSubGroupSize, - CX_AttrKind_OpenCLKernel, - CX_AttrKind_OptimizeNone, - CX_AttrKind_Override, - CX_AttrKind_Owner, - CX_AttrKind_Ownership, - CX_AttrKind_Packed, - CX_AttrKind_ParamTypestate, - CX_AttrKind_PatchableFunctionEntry, - CX_AttrKind_Pointer, - CX_AttrKind_PragmaClangBSSSection, - CX_AttrKind_PragmaClangDataSection, - CX_AttrKind_PragmaClangRelroSection, - CX_AttrKind_PragmaClangRodataSection, - CX_AttrKind_PragmaClangTextSection, - CX_AttrKind_PreferredName, - CX_AttrKind_PtGuardedBy, - CX_AttrKind_PtGuardedVar, - CX_AttrKind_Pure, - CX_AttrKind_RISCVInterrupt, - CX_AttrKind_Reinitializes, - CX_AttrKind_ReleaseCapability, - CX_AttrKind_ReqdWorkGroupSize, - CX_AttrKind_RequiresCapability, - CX_AttrKind_Restrict, - CX_AttrKind_Retain, - CX_AttrKind_ReturnTypestate, - CX_AttrKind_ReturnsNonNull, - CX_AttrKind_ReturnsTwice, - CX_AttrKind_SYCLKernel, - CX_AttrKind_SYCLSpecialClass, - CX_AttrKind_ScopedLockable, - CX_AttrKind_Section, - CX_AttrKind_SelectAny, - CX_AttrKind_Sentinel, - CX_AttrKind_SetTypestate, - CX_AttrKind_SharedTrylockFunction, - CX_AttrKind_SpeculativeLoadHardening, - CX_AttrKind_StandaloneDebug, - CX_AttrKind_StrictFP, - CX_AttrKind_SwiftAsync, - CX_AttrKind_SwiftAsyncError, - CX_AttrKind_SwiftAsyncName, - CX_AttrKind_SwiftAttr, - CX_AttrKind_SwiftBridge, - CX_AttrKind_SwiftBridgedTypedef, - CX_AttrKind_SwiftError, - CX_AttrKind_SwiftName, - CX_AttrKind_SwiftNewType, - CX_AttrKind_SwiftPrivate, - CX_AttrKind_TLSModel, - CX_AttrKind_Target, - CX_AttrKind_TargetClones, - CX_AttrKind_TestTypestate, - CX_AttrKind_TransparentUnion, - CX_AttrKind_TrivialABI, - CX_AttrKind_TryAcquireCapability, - CX_AttrKind_TypeTagForDatatype, - CX_AttrKind_TypeVisibility, - CX_AttrKind_Unavailable, - CX_AttrKind_Uninitialized, - CX_AttrKind_Unused, - CX_AttrKind_Used, - CX_AttrKind_UsingIfExists, - CX_AttrKind_Uuid, - CX_AttrKind_VecReturn, - CX_AttrKind_VecTypeHint, - CX_AttrKind_Visibility, - CX_AttrKind_WarnUnused, - CX_AttrKind_WarnUnusedResult, - CX_AttrKind_Weak, - CX_AttrKind_WeakImport, - CX_AttrKind_WeakRef, - CX_AttrKind_WebAssemblyExportName, - CX_AttrKind_WebAssemblyImportModule, - CX_AttrKind_WebAssemblyImportName, - CX_AttrKind_WorkGroupSizeHint, - CX_AttrKind_X86ForceAlignArgPointer, - CX_AttrKind_XRayInstrument, - CX_AttrKind_XRayLogArgs, - CX_AttrKind_AbiTag, - CX_AttrKind_Alias, - CX_AttrKind_AlignValue, - CX_AttrKind_BuiltinAlias, - CX_AttrKind_CalledOnce, - CX_AttrKind_IFunc, - CX_AttrKind_InitSeg, - CX_AttrKind_LoaderUninitialized, - CX_AttrKind_LoopHint, - CX_AttrKind_Mode, - CX_AttrKind_NoBuiltin, - CX_AttrKind_NoEscape, - CX_AttrKind_OMPCaptureKind, - CX_AttrKind_OMPDeclareSimdDecl, - CX_AttrKind_OMPReferencedVar, - CX_AttrKind_ObjCBoxable, - CX_AttrKind_ObjCClassStub, - CX_AttrKind_ObjCDesignatedInitializer, - CX_AttrKind_ObjCDirect, - CX_AttrKind_ObjCDirectMembers, - CX_AttrKind_ObjCNonLazyClass, - CX_AttrKind_ObjCNonRuntimeProtocol, - CX_AttrKind_ObjCRuntimeName, - CX_AttrKind_ObjCRuntimeVisible, - CX_AttrKind_OpenCLAccess, - CX_AttrKind_Overloadable, - CX_AttrKind_RenderScriptKernel, - CX_AttrKind_SwiftObjCMembers, - CX_AttrKind_Thread, - CX_AttrKind_FirstAttr = CX_AttrKind_AddressSpace, - CX_AttrKind_LastAttr = CX_AttrKind_Thread, - CX_AttrKind_FirstTypeAttr = CX_AttrKind_AddressSpace, - CX_AttrKind_LastTypeAttr = CX_AttrKind_UPtr, - CX_AttrKind_FirstStmtAttr = CX_AttrKind_FallThrough, - CX_AttrKind_LastStmtAttr = CX_AttrKind_Unlikely, - CX_AttrKind_FirstDeclOrStmtAttr = CX_AttrKind_NoMerge, - CX_AttrKind_LastDeclOrStmtAttr = CX_AttrKind_NoMerge, - CX_AttrKind_FirstInheritableAttr = CX_AttrKind_NoMerge, - CX_AttrKind_LastInheritableAttr = CX_AttrKind_XRayLogArgs, - CX_AttrKind_FirstDeclOrTypeAttr = CX_AttrKind_AArch64VectorPcs, - CX_AttrKind_LastDeclOrTypeAttr = CX_AttrKind_VectorCall, - CX_AttrKind_FirstInheritableParamAttr = CX_AttrKind_SwiftAsyncContext, - CX_AttrKind_LastInheritableParamAttr = CX_AttrKind_UseHandle, - CX_AttrKind_FirstParameterABIAttr = CX_AttrKind_SwiftAsyncContext, - CX_AttrKind_LastParameterABIAttr = CX_AttrKind_SwiftIndirectResult, - } + CX_AttrKind_Invalid, + CX_AttrKind_AddressSpace, + CX_AttrKind_ArmMveStrictPolymorphism, + CX_AttrKind_BTFTypeTag, + CX_AttrKind_CmseNSCall, + CX_AttrKind_NoDeref, + CX_AttrKind_ObjCGC, + CX_AttrKind_ObjCInertUnsafeUnretained, + CX_AttrKind_ObjCKindOf, + CX_AttrKind_OpenCLConstantAddressSpace, + CX_AttrKind_OpenCLGenericAddressSpace, + CX_AttrKind_OpenCLGlobalAddressSpace, + CX_AttrKind_OpenCLGlobalDeviceAddressSpace, + CX_AttrKind_OpenCLGlobalHostAddressSpace, + CX_AttrKind_OpenCLLocalAddressSpace, + CX_AttrKind_OpenCLPrivateAddressSpace, + CX_AttrKind_Ptr32, + CX_AttrKind_Ptr64, + CX_AttrKind_SPtr, + CX_AttrKind_TypeNonNull, + CX_AttrKind_TypeNullUnspecified, + CX_AttrKind_TypeNullable, + CX_AttrKind_TypeNullableResult, + CX_AttrKind_UPtr, + CX_AttrKind_FallThrough, + CX_AttrKind_Likely, + CX_AttrKind_MustTail, + CX_AttrKind_OpenCLUnrollHint, + CX_AttrKind_Suppress, + CX_AttrKind_Unlikely, + CX_AttrKind_NoMerge, + CX_AttrKind_AArch64VectorPcs, + CX_AttrKind_AcquireHandle, + CX_AttrKind_AnyX86NoCfCheck, + CX_AttrKind_CDecl, + CX_AttrKind_FastCall, + CX_AttrKind_IntelOclBicc, + CX_AttrKind_LifetimeBound, + CX_AttrKind_MSABI, + CX_AttrKind_NSReturnsRetained, + CX_AttrKind_ObjCOwnership, + CX_AttrKind_Pascal, + CX_AttrKind_Pcs, + CX_AttrKind_PreserveAll, + CX_AttrKind_PreserveMost, + CX_AttrKind_RegCall, + CX_AttrKind_StdCall, + CX_AttrKind_SwiftAsyncCall, + CX_AttrKind_SwiftCall, + CX_AttrKind_SysVABI, + CX_AttrKind_ThisCall, + CX_AttrKind_VectorCall, + CX_AttrKind_SwiftAsyncContext, + CX_AttrKind_SwiftContext, + CX_AttrKind_SwiftErrorResult, + CX_AttrKind_SwiftIndirectResult, + CX_AttrKind_Annotate, + CX_AttrKind_CFConsumed, + CX_AttrKind_CarriesDependency, + CX_AttrKind_NSConsumed, + CX_AttrKind_NonNull, + CX_AttrKind_OSConsumed, + CX_AttrKind_PassObjectSize, + CX_AttrKind_ReleaseHandle, + CX_AttrKind_UseHandle, + CX_AttrKind_AMDGPUFlatWorkGroupSize, + CX_AttrKind_AMDGPUNumSGPR, + CX_AttrKind_AMDGPUNumVGPR, + CX_AttrKind_AMDGPUWavesPerEU, + CX_AttrKind_ARMInterrupt, + CX_AttrKind_AVRInterrupt, + CX_AttrKind_AVRSignal, + CX_AttrKind_AcquireCapability, + CX_AttrKind_AcquiredAfter, + CX_AttrKind_AcquiredBefore, + CX_AttrKind_AlignMac68k, + CX_AttrKind_AlignNatural, + CX_AttrKind_Aligned, + CX_AttrKind_AllocAlign, + CX_AttrKind_AllocSize, + CX_AttrKind_AlwaysDestroy, + CX_AttrKind_AlwaysInline, + CX_AttrKind_AnalyzerNoReturn, + CX_AttrKind_AnyX86Interrupt, + CX_AttrKind_AnyX86NoCallerSavedRegisters, + CX_AttrKind_ArcWeakrefUnavailable, + CX_AttrKind_ArgumentWithTypeTag, + CX_AttrKind_ArmBuiltinAlias, + CX_AttrKind_Artificial, + CX_AttrKind_AsmLabel, + CX_AttrKind_AssertCapability, + CX_AttrKind_AssertExclusiveLock, + CX_AttrKind_AssertSharedLock, + CX_AttrKind_AssumeAligned, + CX_AttrKind_Assumption, + CX_AttrKind_Availability, + CX_AttrKind_BPFPreserveAccessIndex, + CX_AttrKind_BTFDeclTag, + CX_AttrKind_Blocks, + CX_AttrKind_Builtin, + CX_AttrKind_C11NoReturn, + CX_AttrKind_CFAuditedTransfer, + CX_AttrKind_CFGuard, + CX_AttrKind_CFICanonicalJumpTable, + CX_AttrKind_CFReturnsNotRetained, + CX_AttrKind_CFReturnsRetained, + CX_AttrKind_CFUnknownTransfer, + CX_AttrKind_CPUDispatch, + CX_AttrKind_CPUSpecific, + CX_AttrKind_CUDAConstant, + CX_AttrKind_CUDADevice, + CX_AttrKind_CUDADeviceBuiltinSurfaceType, + CX_AttrKind_CUDADeviceBuiltinTextureType, + CX_AttrKind_CUDAGlobal, + CX_AttrKind_CUDAHost, + CX_AttrKind_CUDAInvalidTarget, + CX_AttrKind_CUDALaunchBounds, + CX_AttrKind_CUDAShared, + CX_AttrKind_CXX11NoReturn, + CX_AttrKind_CallableWhen, + CX_AttrKind_Callback, + CX_AttrKind_Capability, + CX_AttrKind_CapturedRecord, + CX_AttrKind_Cleanup, + CX_AttrKind_CmseNSEntry, + CX_AttrKind_CodeSeg, + CX_AttrKind_Cold, + CX_AttrKind_Common, + CX_AttrKind_Const, + CX_AttrKind_ConstInit, + CX_AttrKind_Constructor, + CX_AttrKind_Consumable, + CX_AttrKind_ConsumableAutoCast, + CX_AttrKind_ConsumableSetOnRead, + CX_AttrKind_Convergent, + CX_AttrKind_DLLExport, + CX_AttrKind_DLLExportStaticLocal, + CX_AttrKind_DLLImport, + CX_AttrKind_DLLImportStaticLocal, + CX_AttrKind_Deprecated, + CX_AttrKind_Destructor, + CX_AttrKind_DiagnoseAsBuiltin, + CX_AttrKind_DiagnoseIf, + CX_AttrKind_DisableSanitizerInstrumentation, + CX_AttrKind_DisableTailCalls, + CX_AttrKind_EmptyBases, + CX_AttrKind_EnableIf, + CX_AttrKind_EnforceTCB, + CX_AttrKind_EnforceTCBLeaf, + CX_AttrKind_EnumExtensibility, + CX_AttrKind_Error, + CX_AttrKind_ExcludeFromExplicitInstantiation, + CX_AttrKind_ExclusiveTrylockFunction, + CX_AttrKind_ExternalSourceSymbol, + CX_AttrKind_Final, + CX_AttrKind_FlagEnum, + CX_AttrKind_Flatten, + CX_AttrKind_Format, + CX_AttrKind_FormatArg, + CX_AttrKind_GNUInline, + CX_AttrKind_GuardedBy, + CX_AttrKind_GuardedVar, + CX_AttrKind_HIPManaged, + CX_AttrKind_Hot, + CX_AttrKind_IBAction, + CX_AttrKind_IBOutlet, + CX_AttrKind_IBOutletCollection, + CX_AttrKind_InitPriority, + CX_AttrKind_InternalLinkage, + CX_AttrKind_LTOVisibilityPublic, + CX_AttrKind_LayoutVersion, + CX_AttrKind_Leaf, + CX_AttrKind_LockReturned, + CX_AttrKind_LocksExcluded, + CX_AttrKind_M68kInterrupt, + CX_AttrKind_MIGServerRoutine, + CX_AttrKind_MSAllocator, + CX_AttrKind_MSInheritance, + CX_AttrKind_MSNoVTable, + CX_AttrKind_MSP430Interrupt, + CX_AttrKind_MSStruct, + CX_AttrKind_MSVtorDisp, + CX_AttrKind_MaxFieldAlignment, + CX_AttrKind_MayAlias, + CX_AttrKind_MicroMips, + CX_AttrKind_MinSize, + CX_AttrKind_MinVectorWidth, + CX_AttrKind_Mips16, + CX_AttrKind_MipsInterrupt, + CX_AttrKind_MipsLongCall, + CX_AttrKind_MipsShortCall, + CX_AttrKind_NSConsumesSelf, + CX_AttrKind_NSErrorDomain, + CX_AttrKind_NSReturnsAutoreleased, + CX_AttrKind_NSReturnsNotRetained, + CX_AttrKind_Naked, + CX_AttrKind_NoAlias, + CX_AttrKind_NoCommon, + CX_AttrKind_NoDebug, + CX_AttrKind_NoDestroy, + CX_AttrKind_NoDuplicate, + CX_AttrKind_NoInline, + CX_AttrKind_NoInstrumentFunction, + CX_AttrKind_NoMicroMips, + CX_AttrKind_NoMips16, + CX_AttrKind_NoProfileFunction, + CX_AttrKind_NoReturn, + CX_AttrKind_NoSanitize, + CX_AttrKind_NoSpeculativeLoadHardening, + CX_AttrKind_NoSplitStack, + CX_AttrKind_NoStackProtector, + CX_AttrKind_NoThreadSafetyAnalysis, + CX_AttrKind_NoThrow, + CX_AttrKind_NoUniqueAddress, + CX_AttrKind_NotTailCalled, + CX_AttrKind_OMPAllocateDecl, + CX_AttrKind_OMPCaptureNoInit, + CX_AttrKind_OMPDeclareTargetDecl, + CX_AttrKind_OMPDeclareVariant, + CX_AttrKind_OMPThreadPrivateDecl, + CX_AttrKind_OSConsumesThis, + CX_AttrKind_OSReturnsNotRetained, + CX_AttrKind_OSReturnsRetained, + CX_AttrKind_OSReturnsRetainedOnNonZero, + CX_AttrKind_OSReturnsRetainedOnZero, + CX_AttrKind_ObjCBridge, + CX_AttrKind_ObjCBridgeMutable, + CX_AttrKind_ObjCBridgeRelated, + CX_AttrKind_ObjCException, + CX_AttrKind_ObjCExplicitProtocolImpl, + CX_AttrKind_ObjCExternallyRetained, + CX_AttrKind_ObjCIndependentClass, + CX_AttrKind_ObjCMethodFamily, + CX_AttrKind_ObjCNSObject, + CX_AttrKind_ObjCPreciseLifetime, + CX_AttrKind_ObjCRequiresPropertyDefs, + CX_AttrKind_ObjCRequiresSuper, + CX_AttrKind_ObjCReturnsInnerPointer, + CX_AttrKind_ObjCRootClass, + CX_AttrKind_ObjCSubclassingRestricted, + CX_AttrKind_OpenCLIntelReqdSubGroupSize, + CX_AttrKind_OpenCLKernel, + CX_AttrKind_OptimizeNone, + CX_AttrKind_Override, + CX_AttrKind_Owner, + CX_AttrKind_Ownership, + CX_AttrKind_Packed, + CX_AttrKind_ParamTypestate, + CX_AttrKind_PatchableFunctionEntry, + CX_AttrKind_Pointer, + CX_AttrKind_PragmaClangBSSSection, + CX_AttrKind_PragmaClangDataSection, + CX_AttrKind_PragmaClangRelroSection, + CX_AttrKind_PragmaClangRodataSection, + CX_AttrKind_PragmaClangTextSection, + CX_AttrKind_PreferredName, + CX_AttrKind_PtGuardedBy, + CX_AttrKind_PtGuardedVar, + CX_AttrKind_Pure, + CX_AttrKind_RISCVInterrupt, + CX_AttrKind_Reinitializes, + CX_AttrKind_ReleaseCapability, + CX_AttrKind_ReqdWorkGroupSize, + CX_AttrKind_RequiresCapability, + CX_AttrKind_Restrict, + CX_AttrKind_Retain, + CX_AttrKind_ReturnTypestate, + CX_AttrKind_ReturnsNonNull, + CX_AttrKind_ReturnsTwice, + CX_AttrKind_SYCLKernel, + CX_AttrKind_SYCLSpecialClass, + CX_AttrKind_ScopedLockable, + CX_AttrKind_Section, + CX_AttrKind_SelectAny, + CX_AttrKind_Sentinel, + CX_AttrKind_SetTypestate, + CX_AttrKind_SharedTrylockFunction, + CX_AttrKind_SpeculativeLoadHardening, + CX_AttrKind_StandaloneDebug, + CX_AttrKind_StrictFP, + CX_AttrKind_SwiftAsync, + CX_AttrKind_SwiftAsyncError, + CX_AttrKind_SwiftAsyncName, + CX_AttrKind_SwiftAttr, + CX_AttrKind_SwiftBridge, + CX_AttrKind_SwiftBridgedTypedef, + CX_AttrKind_SwiftError, + CX_AttrKind_SwiftName, + CX_AttrKind_SwiftNewType, + CX_AttrKind_SwiftPrivate, + CX_AttrKind_TLSModel, + CX_AttrKind_Target, + CX_AttrKind_TargetClones, + CX_AttrKind_TestTypestate, + CX_AttrKind_TransparentUnion, + CX_AttrKind_TrivialABI, + CX_AttrKind_TryAcquireCapability, + CX_AttrKind_TypeTagForDatatype, + CX_AttrKind_TypeVisibility, + CX_AttrKind_Unavailable, + CX_AttrKind_Uninitialized, + CX_AttrKind_Unused, + CX_AttrKind_Used, + CX_AttrKind_UsingIfExists, + CX_AttrKind_Uuid, + CX_AttrKind_VecReturn, + CX_AttrKind_VecTypeHint, + CX_AttrKind_Visibility, + CX_AttrKind_WarnUnused, + CX_AttrKind_WarnUnusedResult, + CX_AttrKind_Weak, + CX_AttrKind_WeakImport, + CX_AttrKind_WeakRef, + CX_AttrKind_WebAssemblyExportName, + CX_AttrKind_WebAssemblyImportModule, + CX_AttrKind_WebAssemblyImportName, + CX_AttrKind_WorkGroupSizeHint, + CX_AttrKind_X86ForceAlignArgPointer, + CX_AttrKind_XRayInstrument, + CX_AttrKind_XRayLogArgs, + CX_AttrKind_AbiTag, + CX_AttrKind_Alias, + CX_AttrKind_AlignValue, + CX_AttrKind_BuiltinAlias, + CX_AttrKind_CalledOnce, + CX_AttrKind_IFunc, + CX_AttrKind_InitSeg, + CX_AttrKind_LoaderUninitialized, + CX_AttrKind_LoopHint, + CX_AttrKind_Mode, + CX_AttrKind_NoBuiltin, + CX_AttrKind_NoEscape, + CX_AttrKind_OMPCaptureKind, + CX_AttrKind_OMPDeclareSimdDecl, + CX_AttrKind_OMPReferencedVar, + CX_AttrKind_ObjCBoxable, + CX_AttrKind_ObjCClassStub, + CX_AttrKind_ObjCDesignatedInitializer, + CX_AttrKind_ObjCDirect, + CX_AttrKind_ObjCDirectMembers, + CX_AttrKind_ObjCNonLazyClass, + CX_AttrKind_ObjCNonRuntimeProtocol, + CX_AttrKind_ObjCRuntimeName, + CX_AttrKind_ObjCRuntimeVisible, + CX_AttrKind_OpenCLAccess, + CX_AttrKind_Overloadable, + CX_AttrKind_RenderScriptKernel, + CX_AttrKind_SwiftObjCMembers, + CX_AttrKind_Thread, + CX_AttrKind_FirstAttr = CX_AttrKind_AddressSpace, + CX_AttrKind_LastAttr = CX_AttrKind_Thread, + CX_AttrKind_FirstTypeAttr = CX_AttrKind_AddressSpace, + CX_AttrKind_LastTypeAttr = CX_AttrKind_UPtr, + CX_AttrKind_FirstStmtAttr = CX_AttrKind_FallThrough, + CX_AttrKind_LastStmtAttr = CX_AttrKind_Unlikely, + CX_AttrKind_FirstDeclOrStmtAttr = CX_AttrKind_NoMerge, + CX_AttrKind_LastDeclOrStmtAttr = CX_AttrKind_NoMerge, + CX_AttrKind_FirstInheritableAttr = CX_AttrKind_NoMerge, + CX_AttrKind_LastInheritableAttr = CX_AttrKind_XRayLogArgs, + CX_AttrKind_FirstDeclOrTypeAttr = CX_AttrKind_AArch64VectorPcs, + CX_AttrKind_LastDeclOrTypeAttr = CX_AttrKind_VectorCall, + CX_AttrKind_FirstInheritableParamAttr = CX_AttrKind_SwiftAsyncContext, + CX_AttrKind_LastInheritableParamAttr = CX_AttrKind_UseHandle, + CX_AttrKind_FirstParameterABIAttr = CX_AttrKind_SwiftAsyncContext, + CX_AttrKind_LastParameterABIAttr = CX_AttrKind_SwiftIndirectResult, } diff --git a/sources/ClangSharp.Interop/CX_BinaryOperatorKind.cs b/sources/ClangSharp.Interop/CX_BinaryOperatorKind.cs index 30e6e639..ffeb1036 100644 --- a/sources/ClangSharp.Interop/CX_BinaryOperatorKind.cs +++ b/sources/ClangSharp.Interop/CX_BinaryOperatorKind.cs @@ -1,43 +1,42 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_BinaryOperatorKind { - public enum CX_BinaryOperatorKind - { - CX_BO_Invalid, - CX_BO_PtrMemD, - CX_BO_PtrMemI, - CX_BO_Mul, - CX_BO_Div, - CX_BO_Rem, - CX_BO_Add, - CX_BO_Sub, - CX_BO_Shl, - CX_BO_Shr, - CX_BO_Cmp, - CX_BO_LT, - CX_BO_GT, - CX_BO_LE, - CX_BO_GE, - CX_BO_EQ, - CX_BO_NE, - CX_BO_And, - CX_BO_Xor, - CX_BO_Or, - CX_BO_LAnd, - CX_BO_LOr, - CX_BO_Assign, - CX_BO_MulAssign, - CX_BO_DivAssign, - CX_BO_RemAssign, - CX_BO_AddAssign, - CX_BO_SubAssign, - CX_BO_ShlAssign, - CX_BO_ShrAssign, - CX_BO_AndAssign, - CX_BO_XorAssign, - CX_BO_OrAssign, - CX_BO_Comma, - } + CX_BO_Invalid, + CX_BO_PtrMemD, + CX_BO_PtrMemI, + CX_BO_Mul, + CX_BO_Div, + CX_BO_Rem, + CX_BO_Add, + CX_BO_Sub, + CX_BO_Shl, + CX_BO_Shr, + CX_BO_Cmp, + CX_BO_LT, + CX_BO_GT, + CX_BO_LE, + CX_BO_GE, + CX_BO_EQ, + CX_BO_NE, + CX_BO_And, + CX_BO_Xor, + CX_BO_Or, + CX_BO_LAnd, + CX_BO_LOr, + CX_BO_Assign, + CX_BO_MulAssign, + CX_BO_DivAssign, + CX_BO_RemAssign, + CX_BO_AddAssign, + CX_BO_SubAssign, + CX_BO_ShlAssign, + CX_BO_ShrAssign, + CX_BO_AndAssign, + CX_BO_XorAssign, + CX_BO_OrAssign, + CX_BO_Comma, } diff --git a/sources/ClangSharp.Interop/CX_CXXAccessSpecifier.cs b/sources/ClangSharp.Interop/CX_CXXAccessSpecifier.cs index 8e3f8667..745d6281 100644 --- a/sources/ClangSharp.Interop/CX_CXXAccessSpecifier.cs +++ b/sources/ClangSharp.Interop/CX_CXXAccessSpecifier.cs @@ -3,13 +3,12 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_CXXAccessSpecifier { - public enum CX_CXXAccessSpecifier - { - CX_CXXInvalidAccessSpecifier, - CX_CXXPublic, - CX_CXXProtected, - CX_CXXPrivate, - } + CX_CXXInvalidAccessSpecifier, + CX_CXXPublic, + CX_CXXProtected, + CX_CXXPrivate, } diff --git a/sources/ClangSharp.Interop/CX_CapturedRegionKind.cs b/sources/ClangSharp.Interop/CX_CapturedRegionKind.cs index 7fbab81c..71d01aa3 100644 --- a/sources/ClangSharp.Interop/CX_CapturedRegionKind.cs +++ b/sources/ClangSharp.Interop/CX_CapturedRegionKind.cs @@ -1,13 +1,12 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_CapturedRegionKind { - public enum CX_CapturedRegionKind - { - CX_CR_Invalid, - CX_CR_Default, - CX_CR_ObjCAtFinally, - CX_CR_OpenMP, - } + CX_CR_Invalid, + CX_CR_Default, + CX_CR_ObjCAtFinally, + CX_CR_OpenMP, } diff --git a/sources/ClangSharp.Interop/CX_CastKind.cs b/sources/ClangSharp.Interop/CX_CastKind.cs index 09fc7339..443be8fb 100644 --- a/sources/ClangSharp.Interop/CX_CastKind.cs +++ b/sources/ClangSharp.Interop/CX_CastKind.cs @@ -1,75 +1,74 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_CastKind { - public enum CX_CastKind - { - CX_CK_Invalid, - CX_CK_Dependent, - CX_CK_BitCast, - CX_CK_LValueBitCast, - CX_CK_LValueToRValueBitCast, - CX_CK_LValueToRValue, - CX_CK_NoOp, - CX_CK_BaseToDerived, - CX_CK_DerivedToBase, - CX_CK_UncheckedDerivedToBase, - CX_CK_Dynamic, - CX_CK_ToUnion, - CX_CK_ArrayToPointerDecay, - CX_CK_FunctionToPointerDecay, - CX_CK_NullToPointer, - CX_CK_NullToMemberPointer, - CX_CK_BaseToDerivedMemberPointer, - CX_CK_DerivedToBaseMemberPointer, - CX_CK_MemberPointerToBoolean, - CX_CK_ReinterpretMemberPointer, - CX_CK_UserDefinedConversion, - CX_CK_ConstructorConversion, - CX_CK_IntegralToPointer, - CX_CK_PointerToIntegral, - CX_CK_PointerToBoolean, - CX_CK_ToVoid, - CX_CK_MatrixCast, - CX_CK_VectorSplat, - CX_CK_IntegralCast, - CX_CK_IntegralToBoolean, - CX_CK_IntegralToFloating, - CX_CK_FloatingToFixedPoint, - CX_CK_FixedPointToFloating, - CX_CK_FixedPointCast, - CX_CK_FixedPointToIntegral, - CX_CK_IntegralToFixedPoint, - CX_CK_FixedPointToBoolean, - CX_CK_FloatingToIntegral, - CX_CK_FloatingToBoolean, - CX_CK_BooleanToSignedIntegral, - CX_CK_FloatingCast, - CX_CK_CPointerToObjCPointerCast, - CX_CK_BlockPointerToObjCPointerCast, - CX_CK_AnyPointerToBlockPointerCast, - CX_CK_ObjCObjectLValueCast, - CX_CK_FloatingRealToComplex, - CX_CK_FloatingComplexToReal, - CX_CK_FloatingComplexToBoolean, - CX_CK_FloatingComplexCast, - CX_CK_FloatingComplexToIntegralComplex, - CX_CK_IntegralRealToComplex, - CX_CK_IntegralComplexToReal, - CX_CK_IntegralComplexToBoolean, - CX_CK_IntegralComplexCast, - CX_CK_IntegralComplexToFloatingComplex, - CX_CK_ARCProduceObject, - CX_CK_ARCConsumeObject, - CX_CK_ARCReclaimReturnedObject, - CX_CK_ARCExtendBlockObject, - CX_CK_AtomicToNonAtomic, - CX_CK_NonAtomicToAtomic, - CX_CK_CopyAndAutoreleaseBlockObject, - CX_CK_BuiltinFnToFnPtr, - CX_CK_ZeroToOCLOpaqueType, - CX_CK_AddressSpaceConversion, - CX_CK_IntToOCLSampler, - } + CX_CK_Invalid, + CX_CK_Dependent, + CX_CK_BitCast, + CX_CK_LValueBitCast, + CX_CK_LValueToRValueBitCast, + CX_CK_LValueToRValue, + CX_CK_NoOp, + CX_CK_BaseToDerived, + CX_CK_DerivedToBase, + CX_CK_UncheckedDerivedToBase, + CX_CK_Dynamic, + CX_CK_ToUnion, + CX_CK_ArrayToPointerDecay, + CX_CK_FunctionToPointerDecay, + CX_CK_NullToPointer, + CX_CK_NullToMemberPointer, + CX_CK_BaseToDerivedMemberPointer, + CX_CK_DerivedToBaseMemberPointer, + CX_CK_MemberPointerToBoolean, + CX_CK_ReinterpretMemberPointer, + CX_CK_UserDefinedConversion, + CX_CK_ConstructorConversion, + CX_CK_IntegralToPointer, + CX_CK_PointerToIntegral, + CX_CK_PointerToBoolean, + CX_CK_ToVoid, + CX_CK_MatrixCast, + CX_CK_VectorSplat, + CX_CK_IntegralCast, + CX_CK_IntegralToBoolean, + CX_CK_IntegralToFloating, + CX_CK_FloatingToFixedPoint, + CX_CK_FixedPointToFloating, + CX_CK_FixedPointCast, + CX_CK_FixedPointToIntegral, + CX_CK_IntegralToFixedPoint, + CX_CK_FixedPointToBoolean, + CX_CK_FloatingToIntegral, + CX_CK_FloatingToBoolean, + CX_CK_BooleanToSignedIntegral, + CX_CK_FloatingCast, + CX_CK_CPointerToObjCPointerCast, + CX_CK_BlockPointerToObjCPointerCast, + CX_CK_AnyPointerToBlockPointerCast, + CX_CK_ObjCObjectLValueCast, + CX_CK_FloatingRealToComplex, + CX_CK_FloatingComplexToReal, + CX_CK_FloatingComplexToBoolean, + CX_CK_FloatingComplexCast, + CX_CK_FloatingComplexToIntegralComplex, + CX_CK_IntegralRealToComplex, + CX_CK_IntegralComplexToReal, + CX_CK_IntegralComplexToBoolean, + CX_CK_IntegralComplexCast, + CX_CK_IntegralComplexToFloatingComplex, + CX_CK_ARCProduceObject, + CX_CK_ARCConsumeObject, + CX_CK_ARCReclaimReturnedObject, + CX_CK_ARCExtendBlockObject, + CX_CK_AtomicToNonAtomic, + CX_CK_NonAtomicToAtomic, + CX_CK_CopyAndAutoreleaseBlockObject, + CX_CK_BuiltinFnToFnPtr, + CX_CK_ZeroToOCLOpaqueType, + CX_CK_AddressSpaceConversion, + CX_CK_IntToOCLSampler, } diff --git a/sources/ClangSharp.Interop/CX_CharacterKind.cs b/sources/ClangSharp.Interop/CX_CharacterKind.cs index 50766421..da57dd38 100644 --- a/sources/ClangSharp.Interop/CX_CharacterKind.cs +++ b/sources/ClangSharp.Interop/CX_CharacterKind.cs @@ -1,15 +1,14 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_CharacterKind { - public enum CX_CharacterKind - { - CX_CLK_Invalid, - CX_CLK_Ascii, - CX_CLK_Wide, - CX_CLK_UTF8, - CX_CLK_UTF16, - CX_CLK_UTF32, - } + CX_CLK_Invalid, + CX_CLK_Ascii, + CX_CLK_Wide, + CX_CLK_UTF8, + CX_CLK_UTF16, + CX_CLK_UTF32, } diff --git a/sources/ClangSharp.Interop/CX_ConstructionKind.cs b/sources/ClangSharp.Interop/CX_ConstructionKind.cs index 3727a2fc..0e42bf67 100644 --- a/sources/ClangSharp.Interop/CX_ConstructionKind.cs +++ b/sources/ClangSharp.Interop/CX_ConstructionKind.cs @@ -1,14 +1,13 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_ConstructionKind { - public enum CX_ConstructionKind - { - CX_CK_Invalid, - CX_CK_Complete, - CX_CK_NonVirtualBase, - CX_CK_VirtualBase, - CX_CK_Delegating - } + CX_CK_Invalid, + CX_CK_Complete, + CX_CK_NonVirtualBase, + CX_CK_VirtualBase, + CX_CK_Delegating } diff --git a/sources/ClangSharp.Interop/CX_DeclKind.cs b/sources/ClangSharp.Interop/CX_DeclKind.cs index fad52f75..cdb81287 100644 --- a/sources/ClangSharp.Interop/CX_DeclKind.cs +++ b/sources/ClangSharp.Interop/CX_DeclKind.cs @@ -1,135 +1,134 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_DeclKind { - public enum CX_DeclKind - { - CX_DeclKind_Invalid, - CX_DeclKind_AccessSpec, - CX_DeclKind_Block, - CX_DeclKind_Captured, - CX_DeclKind_ClassScopeFunctionSpecialization, - CX_DeclKind_Empty, - CX_DeclKind_Export, - CX_DeclKind_ExternCContext, - CX_DeclKind_FileScopeAsm, - CX_DeclKind_Friend, - CX_DeclKind_FriendTemplate, - CX_DeclKind_Import, - CX_DeclKind_LifetimeExtendedTemporary, - CX_DeclKind_LinkageSpec, - CX_DeclKind_Using, - CX_DeclKind_UsingEnum, - CX_DeclKind_FirstBaseUsing = CX_DeclKind_Using, - CX_DeclKind_LastBaseUsing = CX_DeclKind_UsingEnum, - CX_DeclKind_Label, - CX_DeclKind_Namespace, - CX_DeclKind_NamespaceAlias, - CX_DeclKind_ObjCCompatibleAlias, - CX_DeclKind_ObjCCategory, - CX_DeclKind_ObjCCategoryImpl, - CX_DeclKind_ObjCImplementation, - CX_DeclKind_FirstObjCImpl = CX_DeclKind_ObjCCategoryImpl, - CX_DeclKind_LastObjCImpl = CX_DeclKind_ObjCImplementation, - CX_DeclKind_ObjCInterface, - CX_DeclKind_ObjCProtocol, - CX_DeclKind_FirstObjCContainer = CX_DeclKind_ObjCCategory, - CX_DeclKind_LastObjCContainer = CX_DeclKind_ObjCProtocol, - CX_DeclKind_ObjCMethod, - CX_DeclKind_ObjCProperty, - CX_DeclKind_BuiltinTemplate, - CX_DeclKind_Concept, - CX_DeclKind_ClassTemplate, - CX_DeclKind_FunctionTemplate, - CX_DeclKind_TypeAliasTemplate, - CX_DeclKind_VarTemplate, - CX_DeclKind_FirstRedeclarableTemplate = CX_DeclKind_ClassTemplate, - CX_DeclKind_LastRedeclarableTemplate = CX_DeclKind_VarTemplate, - CX_DeclKind_TemplateTemplateParm, - CX_DeclKind_FirstTemplate = CX_DeclKind_BuiltinTemplate, - CX_DeclKind_LastTemplate = CX_DeclKind_TemplateTemplateParm, - CX_DeclKind_Enum, - CX_DeclKind_Record, - CX_DeclKind_CXXRecord, - CX_DeclKind_ClassTemplateSpecialization, - CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_FirstClassTemplateSpecialization = CX_DeclKind_ClassTemplateSpecialization, - CX_DeclKind_LastClassTemplateSpecialization = CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_FirstCXXRecord = CX_DeclKind_CXXRecord, - CX_DeclKind_LastCXXRecord = CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_FirstRecord = CX_DeclKind_Record, - CX_DeclKind_LastRecord = CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_FirstTag = CX_DeclKind_Enum, - CX_DeclKind_LastTag = CX_DeclKind_ClassTemplatePartialSpecialization, - CX_DeclKind_TemplateTypeParm, - CX_DeclKind_ObjCTypeParam, - CX_DeclKind_TypeAlias, - CX_DeclKind_Typedef, - CX_DeclKind_FirstTypedefName = CX_DeclKind_ObjCTypeParam, - CX_DeclKind_LastTypedefName = CX_DeclKind_Typedef, - CX_DeclKind_UnresolvedUsingTypename, - CX_DeclKind_FirstType = CX_DeclKind_Enum, - CX_DeclKind_LastType = CX_DeclKind_UnresolvedUsingTypename, - CX_DeclKind_UnresolvedUsingIfExists, - CX_DeclKind_UsingDirective, - CX_DeclKind_UsingPack, - CX_DeclKind_UsingShadow, - CX_DeclKind_ConstructorUsingShadow, - CX_DeclKind_FirstUsingShadow = CX_DeclKind_UsingShadow, - CX_DeclKind_LastUsingShadow = CX_DeclKind_ConstructorUsingShadow, - CX_DeclKind_Binding, - CX_DeclKind_Field, - CX_DeclKind_ObjCAtDefsField, - CX_DeclKind_ObjCIvar, - CX_DeclKind_FirstField = CX_DeclKind_Field, - CX_DeclKind_LastField = CX_DeclKind_ObjCIvar, - CX_DeclKind_Function, - CX_DeclKind_CXXDeductionGuide, - CX_DeclKind_CXXMethod, - CX_DeclKind_CXXConstructor, - CX_DeclKind_CXXConversion, - CX_DeclKind_CXXDestructor, - CX_DeclKind_FirstCXXMethod = CX_DeclKind_CXXMethod, - CX_DeclKind_LastCXXMethod = CX_DeclKind_CXXDestructor, - CX_DeclKind_FirstFunction = CX_DeclKind_Function, - CX_DeclKind_LastFunction = CX_DeclKind_CXXDestructor, - CX_DeclKind_MSProperty, - CX_DeclKind_NonTypeTemplateParm, - CX_DeclKind_Var, - CX_DeclKind_Decomposition, - CX_DeclKind_ImplicitParam, - CX_DeclKind_OMPCapturedExpr, - CX_DeclKind_ParmVar, - CX_DeclKind_VarTemplateSpecialization, - CX_DeclKind_VarTemplatePartialSpecialization, - CX_DeclKind_FirstVarTemplateSpecialization = CX_DeclKind_VarTemplateSpecialization, - CX_DeclKind_LastVarTemplateSpecialization = CX_DeclKind_VarTemplatePartialSpecialization, - CX_DeclKind_FirstVar = CX_DeclKind_Var, - CX_DeclKind_LastVar = CX_DeclKind_VarTemplatePartialSpecialization, - CX_DeclKind_FirstDeclarator = CX_DeclKind_Field, - CX_DeclKind_LastDeclarator = CX_DeclKind_VarTemplatePartialSpecialization, - CX_DeclKind_EnumConstant, - CX_DeclKind_IndirectField, - CX_DeclKind_MSGuid, - CX_DeclKind_OMPDeclareMapper, - CX_DeclKind_OMPDeclareReduction, - CX_DeclKind_TemplateParamObject, - CX_DeclKind_UnresolvedUsingValue, - CX_DeclKind_FirstValue = CX_DeclKind_Binding, - CX_DeclKind_LastValue = CX_DeclKind_UnresolvedUsingValue, - CX_DeclKind_FirstNamed = CX_DeclKind_Using, - CX_DeclKind_LastNamed = CX_DeclKind_UnresolvedUsingValue, - CX_DeclKind_OMPAllocate, - CX_DeclKind_OMPRequires, - CX_DeclKind_OMPThreadPrivate, - CX_DeclKind_ObjCPropertyImpl, - CX_DeclKind_PragmaComment, - CX_DeclKind_PragmaDetectMismatch, - CX_DeclKind_RequiresExprBody, - CX_DeclKind_StaticAssert, - CX_DeclKind_TranslationUnit, - CX_DeclKind_FirstDecl = CX_DeclKind_AccessSpec, - CX_DeclKind_LastDecl = CX_DeclKind_TranslationUnit, - } + CX_DeclKind_Invalid, + CX_DeclKind_AccessSpec, + CX_DeclKind_Block, + CX_DeclKind_Captured, + CX_DeclKind_ClassScopeFunctionSpecialization, + CX_DeclKind_Empty, + CX_DeclKind_Export, + CX_DeclKind_ExternCContext, + CX_DeclKind_FileScopeAsm, + CX_DeclKind_Friend, + CX_DeclKind_FriendTemplate, + CX_DeclKind_Import, + CX_DeclKind_LifetimeExtendedTemporary, + CX_DeclKind_LinkageSpec, + CX_DeclKind_Using, + CX_DeclKind_UsingEnum, + CX_DeclKind_FirstBaseUsing = CX_DeclKind_Using, + CX_DeclKind_LastBaseUsing = CX_DeclKind_UsingEnum, + CX_DeclKind_Label, + CX_DeclKind_Namespace, + CX_DeclKind_NamespaceAlias, + CX_DeclKind_ObjCCompatibleAlias, + CX_DeclKind_ObjCCategory, + CX_DeclKind_ObjCCategoryImpl, + CX_DeclKind_ObjCImplementation, + CX_DeclKind_FirstObjCImpl = CX_DeclKind_ObjCCategoryImpl, + CX_DeclKind_LastObjCImpl = CX_DeclKind_ObjCImplementation, + CX_DeclKind_ObjCInterface, + CX_DeclKind_ObjCProtocol, + CX_DeclKind_FirstObjCContainer = CX_DeclKind_ObjCCategory, + CX_DeclKind_LastObjCContainer = CX_DeclKind_ObjCProtocol, + CX_DeclKind_ObjCMethod, + CX_DeclKind_ObjCProperty, + CX_DeclKind_BuiltinTemplate, + CX_DeclKind_Concept, + CX_DeclKind_ClassTemplate, + CX_DeclKind_FunctionTemplate, + CX_DeclKind_TypeAliasTemplate, + CX_DeclKind_VarTemplate, + CX_DeclKind_FirstRedeclarableTemplate = CX_DeclKind_ClassTemplate, + CX_DeclKind_LastRedeclarableTemplate = CX_DeclKind_VarTemplate, + CX_DeclKind_TemplateTemplateParm, + CX_DeclKind_FirstTemplate = CX_DeclKind_BuiltinTemplate, + CX_DeclKind_LastTemplate = CX_DeclKind_TemplateTemplateParm, + CX_DeclKind_Enum, + CX_DeclKind_Record, + CX_DeclKind_CXXRecord, + CX_DeclKind_ClassTemplateSpecialization, + CX_DeclKind_ClassTemplatePartialSpecialization, + CX_DeclKind_FirstClassTemplateSpecialization = CX_DeclKind_ClassTemplateSpecialization, + CX_DeclKind_LastClassTemplateSpecialization = CX_DeclKind_ClassTemplatePartialSpecialization, + CX_DeclKind_FirstCXXRecord = CX_DeclKind_CXXRecord, + CX_DeclKind_LastCXXRecord = CX_DeclKind_ClassTemplatePartialSpecialization, + CX_DeclKind_FirstRecord = CX_DeclKind_Record, + CX_DeclKind_LastRecord = CX_DeclKind_ClassTemplatePartialSpecialization, + CX_DeclKind_FirstTag = CX_DeclKind_Enum, + CX_DeclKind_LastTag = CX_DeclKind_ClassTemplatePartialSpecialization, + CX_DeclKind_TemplateTypeParm, + CX_DeclKind_ObjCTypeParam, + CX_DeclKind_TypeAlias, + CX_DeclKind_Typedef, + CX_DeclKind_FirstTypedefName = CX_DeclKind_ObjCTypeParam, + CX_DeclKind_LastTypedefName = CX_DeclKind_Typedef, + CX_DeclKind_UnresolvedUsingTypename, + CX_DeclKind_FirstType = CX_DeclKind_Enum, + CX_DeclKind_LastType = CX_DeclKind_UnresolvedUsingTypename, + CX_DeclKind_UnresolvedUsingIfExists, + CX_DeclKind_UsingDirective, + CX_DeclKind_UsingPack, + CX_DeclKind_UsingShadow, + CX_DeclKind_ConstructorUsingShadow, + CX_DeclKind_FirstUsingShadow = CX_DeclKind_UsingShadow, + CX_DeclKind_LastUsingShadow = CX_DeclKind_ConstructorUsingShadow, + CX_DeclKind_Binding, + CX_DeclKind_Field, + CX_DeclKind_ObjCAtDefsField, + CX_DeclKind_ObjCIvar, + CX_DeclKind_FirstField = CX_DeclKind_Field, + CX_DeclKind_LastField = CX_DeclKind_ObjCIvar, + CX_DeclKind_Function, + CX_DeclKind_CXXDeductionGuide, + CX_DeclKind_CXXMethod, + CX_DeclKind_CXXConstructor, + CX_DeclKind_CXXConversion, + CX_DeclKind_CXXDestructor, + CX_DeclKind_FirstCXXMethod = CX_DeclKind_CXXMethod, + CX_DeclKind_LastCXXMethod = CX_DeclKind_CXXDestructor, + CX_DeclKind_FirstFunction = CX_DeclKind_Function, + CX_DeclKind_LastFunction = CX_DeclKind_CXXDestructor, + CX_DeclKind_MSProperty, + CX_DeclKind_NonTypeTemplateParm, + CX_DeclKind_Var, + CX_DeclKind_Decomposition, + CX_DeclKind_ImplicitParam, + CX_DeclKind_OMPCapturedExpr, + CX_DeclKind_ParmVar, + CX_DeclKind_VarTemplateSpecialization, + CX_DeclKind_VarTemplatePartialSpecialization, + CX_DeclKind_FirstVarTemplateSpecialization = CX_DeclKind_VarTemplateSpecialization, + CX_DeclKind_LastVarTemplateSpecialization = CX_DeclKind_VarTemplatePartialSpecialization, + CX_DeclKind_FirstVar = CX_DeclKind_Var, + CX_DeclKind_LastVar = CX_DeclKind_VarTemplatePartialSpecialization, + CX_DeclKind_FirstDeclarator = CX_DeclKind_Field, + CX_DeclKind_LastDeclarator = CX_DeclKind_VarTemplatePartialSpecialization, + CX_DeclKind_EnumConstant, + CX_DeclKind_IndirectField, + CX_DeclKind_MSGuid, + CX_DeclKind_OMPDeclareMapper, + CX_DeclKind_OMPDeclareReduction, + CX_DeclKind_TemplateParamObject, + CX_DeclKind_UnresolvedUsingValue, + CX_DeclKind_FirstValue = CX_DeclKind_Binding, + CX_DeclKind_LastValue = CX_DeclKind_UnresolvedUsingValue, + CX_DeclKind_FirstNamed = CX_DeclKind_Using, + CX_DeclKind_LastNamed = CX_DeclKind_UnresolvedUsingValue, + CX_DeclKind_OMPAllocate, + CX_DeclKind_OMPRequires, + CX_DeclKind_OMPThreadPrivate, + CX_DeclKind_ObjCPropertyImpl, + CX_DeclKind_PragmaComment, + CX_DeclKind_PragmaDetectMismatch, + CX_DeclKind_RequiresExprBody, + CX_DeclKind_StaticAssert, + CX_DeclKind_TranslationUnit, + CX_DeclKind_FirstDecl = CX_DeclKind_AccessSpec, + CX_DeclKind_LastDecl = CX_DeclKind_TranslationUnit, } diff --git a/sources/ClangSharp.Interop/CX_DestructorType.cs b/sources/ClangSharp.Interop/CX_DestructorType.cs index 3e4d6481..ef974db1 100644 --- a/sources/ClangSharp.Interop/CX_DestructorType.cs +++ b/sources/ClangSharp.Interop/CX_DestructorType.cs @@ -1,13 +1,12 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_DestructorType { - public enum CX_DestructorType - { - Deleting, - Complete, - Base, - Comdat - } + Deleting, + Complete, + Base, + Comdat } diff --git a/sources/ClangSharp.Interop/CX_ExprDependence.cs b/sources/ClangSharp.Interop/CX_ExprDependence.cs index dca56064..5a77db0f 100644 --- a/sources/ClangSharp.Interop/CX_ExprDependence.cs +++ b/sources/ClangSharp.Interop/CX_ExprDependence.cs @@ -3,23 +3,22 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +[Flags] +public enum CX_ExprDependence { - [Flags] - public enum CX_ExprDependence - { - CX_ED_None = 0, - CX_ED_UnexpandedPack = 1, - CX_ED_Instantiation = 2, - CX_ED_Type = 4, - CX_ED_Value = 8, - CX_ED_Error = 16, - CX_ED_All = 31, + CX_ED_None = 0, + CX_ED_UnexpandedPack = 1, + CX_ED_Instantiation = 2, + CX_ED_Type = 4, + CX_ED_Value = 8, + CX_ED_Error = 16, + CX_ED_All = 31, - CX_ED_TypeValue = CX_ED_Type | CX_ED_Value, - CX_ED_TypeInstantiation = CX_ED_Type | CX_ED_Instantiation, - CX_ED_ValueInstantiation = CX_ED_Value | CX_ED_Instantiation, - CX_ED_TypeValueInstantiation = CX_ED_Type | CX_ED_Value | CX_ED_Instantiation, - CX_ED_ErrorDependent = CX_ED_Error | CX_ED_ValueInstantiation, - } + CX_ED_TypeValue = CX_ED_Type | CX_ED_Value, + CX_ED_TypeInstantiation = CX_ED_Type | CX_ED_Instantiation, + CX_ED_ValueInstantiation = CX_ED_Value | CX_ED_Instantiation, + CX_ED_TypeValueInstantiation = CX_ED_Type | CX_ED_Value | CX_ED_Instantiation, + CX_ED_ErrorDependent = CX_ED_Error | CX_ED_ValueInstantiation, } diff --git a/sources/ClangSharp.Interop/CX_FloatingSemantics.cs b/sources/ClangSharp.Interop/CX_FloatingSemantics.cs index 831a279e..717bf1b1 100644 --- a/sources/ClangSharp.Interop/CX_FloatingSemantics.cs +++ b/sources/ClangSharp.Interop/CX_FloatingSemantics.cs @@ -1,17 +1,16 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_FloatingSemantics { - public enum CX_FloatingSemantics - { - CX_FLK_Invalid, - CX_FLK_IEEEhalf, - CX_FLK_BFloat, - CX_FLK_IEEEsingle, - CX_FLK_IEEEdouble, - CX_FLK_x87DoubleExtended, - CX_FLK_IEEEquad, - CX_FLK_PPCDoubleDouble, - } + CX_FLK_Invalid, + CX_FLK_IEEEhalf, + CX_FLK_BFloat, + CX_FLK_IEEEsingle, + CX_FLK_IEEEdouble, + CX_FLK_x87DoubleExtended, + CX_FLK_IEEEquad, + CX_FLK_PPCDoubleDouble, } diff --git a/sources/ClangSharp.Interop/CX_OverloadedOperatorKind.cs b/sources/ClangSharp.Interop/CX_OverloadedOperatorKind.cs index d98d12c3..7b0c44b8 100644 --- a/sources/ClangSharp.Interop/CX_OverloadedOperatorKind.cs +++ b/sources/ClangSharp.Interop/CX_OverloadedOperatorKind.cs @@ -1,55 +1,54 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_OverloadedOperatorKind { - public enum CX_OverloadedOperatorKind - { - CX_OO_Invalid, - CX_OO_New, - CX_OO_Delete, - CX_OO_Array_New, - CX_OO_Array_Delete, - CX_OO_Plus, - CX_OO_Minus, - CX_OO_Star, - CX_OO_Slash, - CX_OO_Percent, - CX_OO_Caret, - CX_OO_Amp, - CX_OO_Pipe, - CX_OO_Tilde, - CX_OO_Exclaim, - CX_OO_Equal, - CX_OO_Less, - CX_OO_Greater, - CX_OO_PlusEqual, - CX_OO_MinusEqual, - CX_OO_StarEqual, - CX_OO_SlashEqual, - CX_OO_PercentEqual, - CX_OO_CaretEqual, - CX_OO_AmpEqual, - CX_OO_PipeEqual, - CX_OO_LessLess, - CX_OO_GreaterGreater, - CX_OO_LessLessEqual, - CX_OO_GreaterGreaterEqual, - CX_OO_EqualEqual, - CX_OO_ExclaimEqual, - CX_OO_LessEqual, - CX_OO_GreaterEqual, - CX_OO_Spaceship, - CX_OO_AmpAmp, - CX_OO_PipePipe, - CX_OO_PlusPlus, - CX_OO_MinusMinus, - CX_OO_Comma, - CX_OO_ArrowStar, - CX_OO_Arrow, - CX_OO_Call, - CX_OO_Subscript, - CX_OO_Conditional, - CX_OO_Coawait, - } + CX_OO_Invalid, + CX_OO_New, + CX_OO_Delete, + CX_OO_Array_New, + CX_OO_Array_Delete, + CX_OO_Plus, + CX_OO_Minus, + CX_OO_Star, + CX_OO_Slash, + CX_OO_Percent, + CX_OO_Caret, + CX_OO_Amp, + CX_OO_Pipe, + CX_OO_Tilde, + CX_OO_Exclaim, + CX_OO_Equal, + CX_OO_Less, + CX_OO_Greater, + CX_OO_PlusEqual, + CX_OO_MinusEqual, + CX_OO_StarEqual, + CX_OO_SlashEqual, + CX_OO_PercentEqual, + CX_OO_CaretEqual, + CX_OO_AmpEqual, + CX_OO_PipeEqual, + CX_OO_LessLess, + CX_OO_GreaterGreater, + CX_OO_LessLessEqual, + CX_OO_GreaterGreaterEqual, + CX_OO_EqualEqual, + CX_OO_ExclaimEqual, + CX_OO_LessEqual, + CX_OO_GreaterEqual, + CX_OO_Spaceship, + CX_OO_AmpAmp, + CX_OO_PipePipe, + CX_OO_PlusPlus, + CX_OO_MinusMinus, + CX_OO_Comma, + CX_OO_ArrowStar, + CX_OO_Arrow, + CX_OO_Call, + CX_OO_Subscript, + CX_OO_Conditional, + CX_OO_Coawait, } diff --git a/sources/ClangSharp.Interop/CX_StmtClass.cs b/sources/ClangSharp.Interop/CX_StmtClass.cs index 5b4045ea..83efbad0 100644 --- a/sources/ClangSharp.Interop/CX_StmtClass.cs +++ b/sources/ClangSharp.Interop/CX_StmtClass.cs @@ -1,270 +1,269 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_StmtClass { - public enum CX_StmtClass - { - CX_StmtClass_Invalid, - CX_StmtClass_GCCAsmStmt, - CX_StmtClass_MSAsmStmt, - CX_StmtClass_FirstAsmStmt = CX_StmtClass_GCCAsmStmt, - CX_StmtClass_LastAsmStmt = CX_StmtClass_MSAsmStmt, - CX_StmtClass_BreakStmt, - CX_StmtClass_CXXCatchStmt, - CX_StmtClass_CXXForRangeStmt, - CX_StmtClass_CXXTryStmt, - CX_StmtClass_CapturedStmt, - CX_StmtClass_CompoundStmt, - CX_StmtClass_ContinueStmt, - CX_StmtClass_CoreturnStmt, - CX_StmtClass_CoroutineBodyStmt, - CX_StmtClass_DeclStmt, - CX_StmtClass_DoStmt, - CX_StmtClass_ForStmt, - CX_StmtClass_GotoStmt, - CX_StmtClass_IfStmt, - CX_StmtClass_IndirectGotoStmt, - CX_StmtClass_MSDependentExistsStmt, - CX_StmtClass_NullStmt, - CX_StmtClass_OMPCanonicalLoop, - CX_StmtClass_OMPAtomicDirective, - CX_StmtClass_OMPBarrierDirective, - CX_StmtClass_OMPCancelDirective, - CX_StmtClass_OMPCancellationPointDirective, - CX_StmtClass_OMPCriticalDirective, - CX_StmtClass_OMPDepobjDirective, - CX_StmtClass_OMPDispatchDirective, - CX_StmtClass_OMPFlushDirective, - CX_StmtClass_OMPInteropDirective, - CX_StmtClass_OMPDistributeDirective, - CX_StmtClass_OMPDistributeParallelForDirective, - CX_StmtClass_OMPDistributeParallelForSimdDirective, - CX_StmtClass_OMPDistributeSimdDirective, - CX_StmtClass_OMPForDirective, - CX_StmtClass_OMPForSimdDirective, - CX_StmtClass_OMPGenericLoopDirective, - CX_StmtClass_OMPMasterTaskLoopDirective, - CX_StmtClass_OMPMasterTaskLoopSimdDirective, - CX_StmtClass_OMPParallelForDirective, - CX_StmtClass_OMPParallelForSimdDirective, - CX_StmtClass_OMPParallelMasterTaskLoopDirective, - CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective, - CX_StmtClass_OMPSimdDirective, - CX_StmtClass_OMPTargetParallelForSimdDirective, - CX_StmtClass_OMPTargetSimdDirective, - CX_StmtClass_OMPTargetTeamsDistributeDirective, - CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective, - CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective, - CX_StmtClass_OMPTargetTeamsDistributeSimdDirective, - CX_StmtClass_OMPTaskLoopDirective, - CX_StmtClass_OMPTaskLoopSimdDirective, - CX_StmtClass_OMPTeamsDistributeDirective, - CX_StmtClass_OMPTeamsDistributeParallelForDirective, - CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective, - CX_StmtClass_OMPTeamsDistributeSimdDirective, - CX_StmtClass_FirstOMPLoopDirective = CX_StmtClass_OMPDistributeDirective, - CX_StmtClass_LastOMPLoopDirective = CX_StmtClass_OMPTeamsDistributeSimdDirective, - CX_StmtClass_OMPTileDirective, - CX_StmtClass_OMPUnrollDirective, - CX_StmtClass_FirstOMPLoopTransformationDirective = CX_StmtClass_OMPTileDirective, - CX_StmtClass_LastOMPLoopTransformationDirective = CX_StmtClass_OMPUnrollDirective, - CX_StmtClass_FirstOMPLoopBasedDirective = CX_StmtClass_OMPDistributeDirective, - CX_StmtClass_LastOMPLoopBasedDirective = CX_StmtClass_OMPUnrollDirective, - CX_StmtClass_OMPMaskedDirective, - CX_StmtClass_OMPMasterDirective, - CX_StmtClass_OMPMetaDirective, - CX_StmtClass_OMPOrderedDirective, - CX_StmtClass_OMPParallelDirective, - CX_StmtClass_OMPParallelMasterDirective, - CX_StmtClass_OMPParallelSectionsDirective, - CX_StmtClass_OMPScanDirective, - CX_StmtClass_OMPSectionDirective, - CX_StmtClass_OMPSectionsDirective, - CX_StmtClass_OMPSingleDirective, - CX_StmtClass_OMPTargetDataDirective, - CX_StmtClass_OMPTargetDirective, - CX_StmtClass_OMPTargetEnterDataDirective, - CX_StmtClass_OMPTargetExitDataDirective, - CX_StmtClass_OMPTargetParallelDirective, - CX_StmtClass_OMPTargetParallelForDirective, - CX_StmtClass_OMPTargetTeamsDirective, - CX_StmtClass_OMPTargetUpdateDirective, - CX_StmtClass_OMPTaskDirective, - CX_StmtClass_OMPTaskgroupDirective, - CX_StmtClass_OMPTaskwaitDirective, - CX_StmtClass_OMPTaskyieldDirective, - CX_StmtClass_OMPTeamsDirective, - CX_StmtClass_FirstOMPExecutableDirective = CX_StmtClass_OMPAtomicDirective, - CX_StmtClass_LastOMPExecutableDirective = CX_StmtClass_OMPTeamsDirective, - CX_StmtClass_ObjCAtCatchStmt, - CX_StmtClass_ObjCAtFinallyStmt, - CX_StmtClass_ObjCAtSynchronizedStmt, - CX_StmtClass_ObjCAtThrowStmt, - CX_StmtClass_ObjCAtTryStmt, - CX_StmtClass_ObjCAutoreleasePoolStmt, - CX_StmtClass_ObjCForCollectionStmt, - CX_StmtClass_ReturnStmt, - CX_StmtClass_SEHExceptStmt, - CX_StmtClass_SEHFinallyStmt, - CX_StmtClass_SEHLeaveStmt, - CX_StmtClass_SEHTryStmt, - CX_StmtClass_CaseStmt, - CX_StmtClass_DefaultStmt, - CX_StmtClass_FirstSwitchCase = CX_StmtClass_CaseStmt, - CX_StmtClass_LastSwitchCase = CX_StmtClass_DefaultStmt, - CX_StmtClass_SwitchStmt, - CX_StmtClass_AttributedStmt, - CX_StmtClass_BinaryConditionalOperator, - CX_StmtClass_ConditionalOperator, - CX_StmtClass_FirstAbstractConditionalOperator = CX_StmtClass_BinaryConditionalOperator, - CX_StmtClass_LastAbstractConditionalOperator = CX_StmtClass_ConditionalOperator, - CX_StmtClass_AddrLabelExpr, - CX_StmtClass_ArrayInitIndexExpr, - CX_StmtClass_ArrayInitLoopExpr, - CX_StmtClass_ArraySubscriptExpr, - CX_StmtClass_ArrayTypeTraitExpr, - CX_StmtClass_AsTypeExpr, - CX_StmtClass_AtomicExpr, - CX_StmtClass_BinaryOperator, - CX_StmtClass_CompoundAssignOperator, - CX_StmtClass_FirstBinaryOperator = CX_StmtClass_BinaryOperator, - CX_StmtClass_LastBinaryOperator = CX_StmtClass_CompoundAssignOperator, - CX_StmtClass_BlockExpr, - CX_StmtClass_CXXBindTemporaryExpr, - CX_StmtClass_CXXBoolLiteralExpr, - CX_StmtClass_CXXConstructExpr, - CX_StmtClass_CXXTemporaryObjectExpr, - CX_StmtClass_FirstCXXConstructExpr = CX_StmtClass_CXXConstructExpr, - CX_StmtClass_LastCXXConstructExpr = CX_StmtClass_CXXTemporaryObjectExpr, - CX_StmtClass_CXXDefaultArgExpr, - CX_StmtClass_CXXDefaultInitExpr, - CX_StmtClass_CXXDeleteExpr, - CX_StmtClass_CXXDependentScopeMemberExpr, - CX_StmtClass_CXXFoldExpr, - CX_StmtClass_CXXInheritedCtorInitExpr, - CX_StmtClass_CXXNewExpr, - CX_StmtClass_CXXNoexceptExpr, - CX_StmtClass_CXXNullPtrLiteralExpr, - CX_StmtClass_CXXPseudoDestructorExpr, - CX_StmtClass_CXXRewrittenBinaryOperator, - CX_StmtClass_CXXScalarValueInitExpr, - CX_StmtClass_CXXStdInitializerListExpr, - CX_StmtClass_CXXThisExpr, - CX_StmtClass_CXXThrowExpr, - CX_StmtClass_CXXTypeidExpr, - CX_StmtClass_CXXUnresolvedConstructExpr, - CX_StmtClass_CXXUuidofExpr, - CX_StmtClass_CallExpr, - CX_StmtClass_CUDAKernelCallExpr, - CX_StmtClass_CXXMemberCallExpr, - CX_StmtClass_CXXOperatorCallExpr, - CX_StmtClass_UserDefinedLiteral, - CX_StmtClass_FirstCallExpr = CX_StmtClass_CallExpr, - CX_StmtClass_LastCallExpr = CX_StmtClass_UserDefinedLiteral, - CX_StmtClass_BuiltinBitCastExpr, - CX_StmtClass_CStyleCastExpr, - CX_StmtClass_CXXFunctionalCastExpr, - CX_StmtClass_CXXAddrspaceCastExpr, - CX_StmtClass_CXXConstCastExpr, - CX_StmtClass_CXXDynamicCastExpr, - CX_StmtClass_CXXReinterpretCastExpr, - CX_StmtClass_CXXStaticCastExpr, - CX_StmtClass_FirstCXXNamedCastExpr = CX_StmtClass_CXXAddrspaceCastExpr, - CX_StmtClass_LastCXXNamedCastExpr = CX_StmtClass_CXXStaticCastExpr, - CX_StmtClass_ObjCBridgedCastExpr, - CX_StmtClass_FirstExplicitCastExpr = CX_StmtClass_BuiltinBitCastExpr, - CX_StmtClass_LastExplicitCastExpr = CX_StmtClass_ObjCBridgedCastExpr, - CX_StmtClass_ImplicitCastExpr, - CX_StmtClass_FirstCastExpr = CX_StmtClass_BuiltinBitCastExpr, - CX_StmtClass_LastCastExpr = CX_StmtClass_ImplicitCastExpr, - CX_StmtClass_CharacterLiteral, - CX_StmtClass_ChooseExpr, - CX_StmtClass_CompoundLiteralExpr, - CX_StmtClass_ConceptSpecializationExpr, - CX_StmtClass_ConvertVectorExpr, - CX_StmtClass_CoawaitExpr, - CX_StmtClass_CoyieldExpr, - CX_StmtClass_FirstCoroutineSuspendExpr = CX_StmtClass_CoawaitExpr, - CX_StmtClass_LastCoroutineSuspendExpr = CX_StmtClass_CoyieldExpr, - CX_StmtClass_DeclRefExpr, - CX_StmtClass_DependentCoawaitExpr, - CX_StmtClass_DependentScopeDeclRefExpr, - CX_StmtClass_DesignatedInitExpr, - CX_StmtClass_DesignatedInitUpdateExpr, - CX_StmtClass_ExpressionTraitExpr, - CX_StmtClass_ExtVectorElementExpr, - CX_StmtClass_FixedPointLiteral, - CX_StmtClass_FloatingLiteral, - CX_StmtClass_ConstantExpr, - CX_StmtClass_ExprWithCleanups, - CX_StmtClass_FirstFullExpr = CX_StmtClass_ConstantExpr, - CX_StmtClass_LastFullExpr = CX_StmtClass_ExprWithCleanups, - CX_StmtClass_FunctionParmPackExpr, - CX_StmtClass_GNUNullExpr, - CX_StmtClass_GenericSelectionExpr, - CX_StmtClass_ImaginaryLiteral, - CX_StmtClass_ImplicitValueInitExpr, - CX_StmtClass_InitListExpr, - CX_StmtClass_IntegerLiteral, - CX_StmtClass_LambdaExpr, - CX_StmtClass_MSPropertyRefExpr, - CX_StmtClass_MSPropertySubscriptExpr, - CX_StmtClass_MaterializeTemporaryExpr, - CX_StmtClass_MatrixSubscriptExpr, - CX_StmtClass_MemberExpr, - CX_StmtClass_NoInitExpr, - CX_StmtClass_OMPArraySectionExpr, - CX_StmtClass_OMPArrayShapingExpr, - CX_StmtClass_OMPIteratorExpr, - CX_StmtClass_ObjCArrayLiteral, - CX_StmtClass_ObjCAvailabilityCheckExpr, - CX_StmtClass_ObjCBoolLiteralExpr, - CX_StmtClass_ObjCBoxedExpr, - CX_StmtClass_ObjCDictionaryLiteral, - CX_StmtClass_ObjCEncodeExpr, - CX_StmtClass_ObjCIndirectCopyRestoreExpr, - CX_StmtClass_ObjCIsaExpr, - CX_StmtClass_ObjCIvarRefExpr, - CX_StmtClass_ObjCMessageExpr, - CX_StmtClass_ObjCPropertyRefExpr, - CX_StmtClass_ObjCProtocolExpr, - CX_StmtClass_ObjCSelectorExpr, - CX_StmtClass_ObjCStringLiteral, - CX_StmtClass_ObjCSubscriptRefExpr, - CX_StmtClass_OffsetOfExpr, - CX_StmtClass_OpaqueValueExpr, - CX_StmtClass_UnresolvedLookupExpr, - CX_StmtClass_UnresolvedMemberExpr, - CX_StmtClass_FirstOverloadExpr = CX_StmtClass_UnresolvedLookupExpr, - CX_StmtClass_LastOverloadExpr = CX_StmtClass_UnresolvedMemberExpr, - CX_StmtClass_PackExpansionExpr, - CX_StmtClass_ParenExpr, - CX_StmtClass_ParenListExpr, - CX_StmtClass_PredefinedExpr, - CX_StmtClass_PseudoObjectExpr, - CX_StmtClass_RecoveryExpr, - CX_StmtClass_RequiresExpr, - CX_StmtClass_SYCLUniqueStableNameExpr, - CX_StmtClass_ShuffleVectorExpr, - CX_StmtClass_SizeOfPackExpr, - CX_StmtClass_SourceLocExpr, - CX_StmtClass_StmtExpr, - CX_StmtClass_StringLiteral, - CX_StmtClass_SubstNonTypeTemplateParmExpr, - CX_StmtClass_SubstNonTypeTemplateParmPackExpr, - CX_StmtClass_TypeTraitExpr, - CX_StmtClass_TypoExpr, - CX_StmtClass_UnaryExprOrTypeTraitExpr, - CX_StmtClass_UnaryOperator, - CX_StmtClass_VAArgExpr, - CX_StmtClass_FirstExpr = CX_StmtClass_BinaryConditionalOperator, - CX_StmtClass_LastExpr = CX_StmtClass_VAArgExpr, - CX_StmtClass_LabelStmt, - CX_StmtClass_FirstValueStmt = CX_StmtClass_AttributedStmt, - CX_StmtClass_LastValueStmt = CX_StmtClass_LabelStmt, - CX_StmtClass_WhileStmt, - CX_StmtClass_FirstStmt = CX_StmtClass_GCCAsmStmt, - CX_StmtClass_LastStmt = CX_StmtClass_WhileStmt, - } + CX_StmtClass_Invalid, + CX_StmtClass_GCCAsmStmt, + CX_StmtClass_MSAsmStmt, + CX_StmtClass_FirstAsmStmt = CX_StmtClass_GCCAsmStmt, + CX_StmtClass_LastAsmStmt = CX_StmtClass_MSAsmStmt, + CX_StmtClass_BreakStmt, + CX_StmtClass_CXXCatchStmt, + CX_StmtClass_CXXForRangeStmt, + CX_StmtClass_CXXTryStmt, + CX_StmtClass_CapturedStmt, + CX_StmtClass_CompoundStmt, + CX_StmtClass_ContinueStmt, + CX_StmtClass_CoreturnStmt, + CX_StmtClass_CoroutineBodyStmt, + CX_StmtClass_DeclStmt, + CX_StmtClass_DoStmt, + CX_StmtClass_ForStmt, + CX_StmtClass_GotoStmt, + CX_StmtClass_IfStmt, + CX_StmtClass_IndirectGotoStmt, + CX_StmtClass_MSDependentExistsStmt, + CX_StmtClass_NullStmt, + CX_StmtClass_OMPCanonicalLoop, + CX_StmtClass_OMPAtomicDirective, + CX_StmtClass_OMPBarrierDirective, + CX_StmtClass_OMPCancelDirective, + CX_StmtClass_OMPCancellationPointDirective, + CX_StmtClass_OMPCriticalDirective, + CX_StmtClass_OMPDepobjDirective, + CX_StmtClass_OMPDispatchDirective, + CX_StmtClass_OMPFlushDirective, + CX_StmtClass_OMPInteropDirective, + CX_StmtClass_OMPDistributeDirective, + CX_StmtClass_OMPDistributeParallelForDirective, + CX_StmtClass_OMPDistributeParallelForSimdDirective, + CX_StmtClass_OMPDistributeSimdDirective, + CX_StmtClass_OMPForDirective, + CX_StmtClass_OMPForSimdDirective, + CX_StmtClass_OMPGenericLoopDirective, + CX_StmtClass_OMPMasterTaskLoopDirective, + CX_StmtClass_OMPMasterTaskLoopSimdDirective, + CX_StmtClass_OMPParallelForDirective, + CX_StmtClass_OMPParallelForSimdDirective, + CX_StmtClass_OMPParallelMasterTaskLoopDirective, + CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective, + CX_StmtClass_OMPSimdDirective, + CX_StmtClass_OMPTargetParallelForSimdDirective, + CX_StmtClass_OMPTargetSimdDirective, + CX_StmtClass_OMPTargetTeamsDistributeDirective, + CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective, + CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective, + CX_StmtClass_OMPTargetTeamsDistributeSimdDirective, + CX_StmtClass_OMPTaskLoopDirective, + CX_StmtClass_OMPTaskLoopSimdDirective, + CX_StmtClass_OMPTeamsDistributeDirective, + CX_StmtClass_OMPTeamsDistributeParallelForDirective, + CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective, + CX_StmtClass_OMPTeamsDistributeSimdDirective, + CX_StmtClass_FirstOMPLoopDirective = CX_StmtClass_OMPDistributeDirective, + CX_StmtClass_LastOMPLoopDirective = CX_StmtClass_OMPTeamsDistributeSimdDirective, + CX_StmtClass_OMPTileDirective, + CX_StmtClass_OMPUnrollDirective, + CX_StmtClass_FirstOMPLoopTransformationDirective = CX_StmtClass_OMPTileDirective, + CX_StmtClass_LastOMPLoopTransformationDirective = CX_StmtClass_OMPUnrollDirective, + CX_StmtClass_FirstOMPLoopBasedDirective = CX_StmtClass_OMPDistributeDirective, + CX_StmtClass_LastOMPLoopBasedDirective = CX_StmtClass_OMPUnrollDirective, + CX_StmtClass_OMPMaskedDirective, + CX_StmtClass_OMPMasterDirective, + CX_StmtClass_OMPMetaDirective, + CX_StmtClass_OMPOrderedDirective, + CX_StmtClass_OMPParallelDirective, + CX_StmtClass_OMPParallelMasterDirective, + CX_StmtClass_OMPParallelSectionsDirective, + CX_StmtClass_OMPScanDirective, + CX_StmtClass_OMPSectionDirective, + CX_StmtClass_OMPSectionsDirective, + CX_StmtClass_OMPSingleDirective, + CX_StmtClass_OMPTargetDataDirective, + CX_StmtClass_OMPTargetDirective, + CX_StmtClass_OMPTargetEnterDataDirective, + CX_StmtClass_OMPTargetExitDataDirective, + CX_StmtClass_OMPTargetParallelDirective, + CX_StmtClass_OMPTargetParallelForDirective, + CX_StmtClass_OMPTargetTeamsDirective, + CX_StmtClass_OMPTargetUpdateDirective, + CX_StmtClass_OMPTaskDirective, + CX_StmtClass_OMPTaskgroupDirective, + CX_StmtClass_OMPTaskwaitDirective, + CX_StmtClass_OMPTaskyieldDirective, + CX_StmtClass_OMPTeamsDirective, + CX_StmtClass_FirstOMPExecutableDirective = CX_StmtClass_OMPAtomicDirective, + CX_StmtClass_LastOMPExecutableDirective = CX_StmtClass_OMPTeamsDirective, + CX_StmtClass_ObjCAtCatchStmt, + CX_StmtClass_ObjCAtFinallyStmt, + CX_StmtClass_ObjCAtSynchronizedStmt, + CX_StmtClass_ObjCAtThrowStmt, + CX_StmtClass_ObjCAtTryStmt, + CX_StmtClass_ObjCAutoreleasePoolStmt, + CX_StmtClass_ObjCForCollectionStmt, + CX_StmtClass_ReturnStmt, + CX_StmtClass_SEHExceptStmt, + CX_StmtClass_SEHFinallyStmt, + CX_StmtClass_SEHLeaveStmt, + CX_StmtClass_SEHTryStmt, + CX_StmtClass_CaseStmt, + CX_StmtClass_DefaultStmt, + CX_StmtClass_FirstSwitchCase = CX_StmtClass_CaseStmt, + CX_StmtClass_LastSwitchCase = CX_StmtClass_DefaultStmt, + CX_StmtClass_SwitchStmt, + CX_StmtClass_AttributedStmt, + CX_StmtClass_BinaryConditionalOperator, + CX_StmtClass_ConditionalOperator, + CX_StmtClass_FirstAbstractConditionalOperator = CX_StmtClass_BinaryConditionalOperator, + CX_StmtClass_LastAbstractConditionalOperator = CX_StmtClass_ConditionalOperator, + CX_StmtClass_AddrLabelExpr, + CX_StmtClass_ArrayInitIndexExpr, + CX_StmtClass_ArrayInitLoopExpr, + CX_StmtClass_ArraySubscriptExpr, + CX_StmtClass_ArrayTypeTraitExpr, + CX_StmtClass_AsTypeExpr, + CX_StmtClass_AtomicExpr, + CX_StmtClass_BinaryOperator, + CX_StmtClass_CompoundAssignOperator, + CX_StmtClass_FirstBinaryOperator = CX_StmtClass_BinaryOperator, + CX_StmtClass_LastBinaryOperator = CX_StmtClass_CompoundAssignOperator, + CX_StmtClass_BlockExpr, + CX_StmtClass_CXXBindTemporaryExpr, + CX_StmtClass_CXXBoolLiteralExpr, + CX_StmtClass_CXXConstructExpr, + CX_StmtClass_CXXTemporaryObjectExpr, + CX_StmtClass_FirstCXXConstructExpr = CX_StmtClass_CXXConstructExpr, + CX_StmtClass_LastCXXConstructExpr = CX_StmtClass_CXXTemporaryObjectExpr, + CX_StmtClass_CXXDefaultArgExpr, + CX_StmtClass_CXXDefaultInitExpr, + CX_StmtClass_CXXDeleteExpr, + CX_StmtClass_CXXDependentScopeMemberExpr, + CX_StmtClass_CXXFoldExpr, + CX_StmtClass_CXXInheritedCtorInitExpr, + CX_StmtClass_CXXNewExpr, + CX_StmtClass_CXXNoexceptExpr, + CX_StmtClass_CXXNullPtrLiteralExpr, + CX_StmtClass_CXXPseudoDestructorExpr, + CX_StmtClass_CXXRewrittenBinaryOperator, + CX_StmtClass_CXXScalarValueInitExpr, + CX_StmtClass_CXXStdInitializerListExpr, + CX_StmtClass_CXXThisExpr, + CX_StmtClass_CXXThrowExpr, + CX_StmtClass_CXXTypeidExpr, + CX_StmtClass_CXXUnresolvedConstructExpr, + CX_StmtClass_CXXUuidofExpr, + CX_StmtClass_CallExpr, + CX_StmtClass_CUDAKernelCallExpr, + CX_StmtClass_CXXMemberCallExpr, + CX_StmtClass_CXXOperatorCallExpr, + CX_StmtClass_UserDefinedLiteral, + CX_StmtClass_FirstCallExpr = CX_StmtClass_CallExpr, + CX_StmtClass_LastCallExpr = CX_StmtClass_UserDefinedLiteral, + CX_StmtClass_BuiltinBitCastExpr, + CX_StmtClass_CStyleCastExpr, + CX_StmtClass_CXXFunctionalCastExpr, + CX_StmtClass_CXXAddrspaceCastExpr, + CX_StmtClass_CXXConstCastExpr, + CX_StmtClass_CXXDynamicCastExpr, + CX_StmtClass_CXXReinterpretCastExpr, + CX_StmtClass_CXXStaticCastExpr, + CX_StmtClass_FirstCXXNamedCastExpr = CX_StmtClass_CXXAddrspaceCastExpr, + CX_StmtClass_LastCXXNamedCastExpr = CX_StmtClass_CXXStaticCastExpr, + CX_StmtClass_ObjCBridgedCastExpr, + CX_StmtClass_FirstExplicitCastExpr = CX_StmtClass_BuiltinBitCastExpr, + CX_StmtClass_LastExplicitCastExpr = CX_StmtClass_ObjCBridgedCastExpr, + CX_StmtClass_ImplicitCastExpr, + CX_StmtClass_FirstCastExpr = CX_StmtClass_BuiltinBitCastExpr, + CX_StmtClass_LastCastExpr = CX_StmtClass_ImplicitCastExpr, + CX_StmtClass_CharacterLiteral, + CX_StmtClass_ChooseExpr, + CX_StmtClass_CompoundLiteralExpr, + CX_StmtClass_ConceptSpecializationExpr, + CX_StmtClass_ConvertVectorExpr, + CX_StmtClass_CoawaitExpr, + CX_StmtClass_CoyieldExpr, + CX_StmtClass_FirstCoroutineSuspendExpr = CX_StmtClass_CoawaitExpr, + CX_StmtClass_LastCoroutineSuspendExpr = CX_StmtClass_CoyieldExpr, + CX_StmtClass_DeclRefExpr, + CX_StmtClass_DependentCoawaitExpr, + CX_StmtClass_DependentScopeDeclRefExpr, + CX_StmtClass_DesignatedInitExpr, + CX_StmtClass_DesignatedInitUpdateExpr, + CX_StmtClass_ExpressionTraitExpr, + CX_StmtClass_ExtVectorElementExpr, + CX_StmtClass_FixedPointLiteral, + CX_StmtClass_FloatingLiteral, + CX_StmtClass_ConstantExpr, + CX_StmtClass_ExprWithCleanups, + CX_StmtClass_FirstFullExpr = CX_StmtClass_ConstantExpr, + CX_StmtClass_LastFullExpr = CX_StmtClass_ExprWithCleanups, + CX_StmtClass_FunctionParmPackExpr, + CX_StmtClass_GNUNullExpr, + CX_StmtClass_GenericSelectionExpr, + CX_StmtClass_ImaginaryLiteral, + CX_StmtClass_ImplicitValueInitExpr, + CX_StmtClass_InitListExpr, + CX_StmtClass_IntegerLiteral, + CX_StmtClass_LambdaExpr, + CX_StmtClass_MSPropertyRefExpr, + CX_StmtClass_MSPropertySubscriptExpr, + CX_StmtClass_MaterializeTemporaryExpr, + CX_StmtClass_MatrixSubscriptExpr, + CX_StmtClass_MemberExpr, + CX_StmtClass_NoInitExpr, + CX_StmtClass_OMPArraySectionExpr, + CX_StmtClass_OMPArrayShapingExpr, + CX_StmtClass_OMPIteratorExpr, + CX_StmtClass_ObjCArrayLiteral, + CX_StmtClass_ObjCAvailabilityCheckExpr, + CX_StmtClass_ObjCBoolLiteralExpr, + CX_StmtClass_ObjCBoxedExpr, + CX_StmtClass_ObjCDictionaryLiteral, + CX_StmtClass_ObjCEncodeExpr, + CX_StmtClass_ObjCIndirectCopyRestoreExpr, + CX_StmtClass_ObjCIsaExpr, + CX_StmtClass_ObjCIvarRefExpr, + CX_StmtClass_ObjCMessageExpr, + CX_StmtClass_ObjCPropertyRefExpr, + CX_StmtClass_ObjCProtocolExpr, + CX_StmtClass_ObjCSelectorExpr, + CX_StmtClass_ObjCStringLiteral, + CX_StmtClass_ObjCSubscriptRefExpr, + CX_StmtClass_OffsetOfExpr, + CX_StmtClass_OpaqueValueExpr, + CX_StmtClass_UnresolvedLookupExpr, + CX_StmtClass_UnresolvedMemberExpr, + CX_StmtClass_FirstOverloadExpr = CX_StmtClass_UnresolvedLookupExpr, + CX_StmtClass_LastOverloadExpr = CX_StmtClass_UnresolvedMemberExpr, + CX_StmtClass_PackExpansionExpr, + CX_StmtClass_ParenExpr, + CX_StmtClass_ParenListExpr, + CX_StmtClass_PredefinedExpr, + CX_StmtClass_PseudoObjectExpr, + CX_StmtClass_RecoveryExpr, + CX_StmtClass_RequiresExpr, + CX_StmtClass_SYCLUniqueStableNameExpr, + CX_StmtClass_ShuffleVectorExpr, + CX_StmtClass_SizeOfPackExpr, + CX_StmtClass_SourceLocExpr, + CX_StmtClass_StmtExpr, + CX_StmtClass_StringLiteral, + CX_StmtClass_SubstNonTypeTemplateParmExpr, + CX_StmtClass_SubstNonTypeTemplateParmPackExpr, + CX_StmtClass_TypeTraitExpr, + CX_StmtClass_TypoExpr, + CX_StmtClass_UnaryExprOrTypeTraitExpr, + CX_StmtClass_UnaryOperator, + CX_StmtClass_VAArgExpr, + CX_StmtClass_FirstExpr = CX_StmtClass_BinaryConditionalOperator, + CX_StmtClass_LastExpr = CX_StmtClass_VAArgExpr, + CX_StmtClass_LabelStmt, + CX_StmtClass_FirstValueStmt = CX_StmtClass_AttributedStmt, + CX_StmtClass_LastValueStmt = CX_StmtClass_LabelStmt, + CX_StmtClass_WhileStmt, + CX_StmtClass_FirstStmt = CX_StmtClass_GCCAsmStmt, + CX_StmtClass_LastStmt = CX_StmtClass_WhileStmt, } diff --git a/sources/ClangSharp.Interop/CX_StorageClass.cs b/sources/ClangSharp.Interop/CX_StorageClass.cs index a7bb5de7..1dd780e1 100644 --- a/sources/ClangSharp.Interop/CX_StorageClass.cs +++ b/sources/ClangSharp.Interop/CX_StorageClass.cs @@ -3,17 +3,16 @@ // Ported from https://github.com/llvm/llvm-project/tree/llvmorg-14.0.0/clang/include/clang-c // Original source is Copyright (c) the LLVM Project and Contributors. Licensed under the Apache License v2.0 with LLVM Exceptions. See NOTICE.txt in the project root for license information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_StorageClass { - public enum CX_StorageClass - { - CX_SC_Invalid, - CX_SC_None, - CX_SC_Extern, - CX_SC_Static, - CX_SC_PrivateExtern, - CX_SC_OpenCLWorkGroupLocal, - CX_SC_Auto, - CX_SC_Register, - } + CX_SC_Invalid, + CX_SC_None, + CX_SC_Extern, + CX_SC_Static, + CX_SC_PrivateExtern, + CX_SC_OpenCLWorkGroupLocal, + CX_SC_Auto, + CX_SC_Register, } diff --git a/sources/ClangSharp.Interop/CX_TemplateArgument.cs b/sources/ClangSharp.Interop/CX_TemplateArgument.cs index bc8c1e56..9987fe37 100644 --- a/sources/ClangSharp.Interop/CX_TemplateArgument.cs +++ b/sources/ClangSharp.Interop/CX_TemplateArgument.cs @@ -1,18 +1,17 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CX_TemplateArgument { - public unsafe partial struct CX_TemplateArgument - { - public CXTemplateArgumentKind kind; + public CXTemplateArgumentKind kind; - public int xdata; + public int xdata; - [NativeTypeName("const clang::TemplateArgument *")] - public void* value; + [NativeTypeName("const clang::TemplateArgument *")] + public void* value; - [NativeTypeName("CXTranslationUnit")] - public CXTranslationUnitImpl* tu; - } + [NativeTypeName("CXTranslationUnit")] + public CXTranslationUnitImpl* tu; } diff --git a/sources/ClangSharp.Interop/CX_TemplateArgumentDependence.cs b/sources/ClangSharp.Interop/CX_TemplateArgumentDependence.cs index fc3194fd..d17a8bf6 100644 --- a/sources/ClangSharp.Interop/CX_TemplateArgumentDependence.cs +++ b/sources/ClangSharp.Interop/CX_TemplateArgumentDependence.cs @@ -3,17 +3,16 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +[Flags] +public enum CX_TemplateArgumentDependence { - [Flags] - public enum CX_TemplateArgumentDependence - { - CX_TAD_None = 0, - CX_TAD_UnexpandedPack = 1, - CX_TAD_Instantiation = 2, - CX_TAD_Dependent = 4, - CX_TAD_Error = 8, - CX_TAD_DependentInstantiation = CX_TAD_Dependent | CX_TAD_Instantiation, - CX_TAD_All = 15, - } + CX_TAD_None = 0, + CX_TAD_UnexpandedPack = 1, + CX_TAD_Instantiation = 2, + CX_TAD_Dependent = 4, + CX_TAD_Error = 8, + CX_TAD_DependentInstantiation = CX_TAD_Dependent | CX_TAD_Instantiation, + CX_TAD_All = 15, } diff --git a/sources/ClangSharp.Interop/CX_TemplateArgumentLoc.cs b/sources/ClangSharp.Interop/CX_TemplateArgumentLoc.cs index a98f1a7b..4a8c2cfc 100644 --- a/sources/ClangSharp.Interop/CX_TemplateArgumentLoc.cs +++ b/sources/ClangSharp.Interop/CX_TemplateArgumentLoc.cs @@ -1,14 +1,13 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CX_TemplateArgumentLoc { - public unsafe partial struct CX_TemplateArgumentLoc - { - [NativeTypeName("const clang::TemplateArgumentLoc *")] - public void* value; + [NativeTypeName("const clang::TemplateArgumentLoc *")] + public void* value; - [NativeTypeName("CXTranslationUnit")] - public CXTranslationUnitImpl* tu; - } + [NativeTypeName("CXTranslationUnit")] + public CXTranslationUnitImpl* tu; } diff --git a/sources/ClangSharp.Interop/CX_TemplateName.cs b/sources/ClangSharp.Interop/CX_TemplateName.cs index e5a15e17..a8c28fed 100644 --- a/sources/ClangSharp.Interop/CX_TemplateName.cs +++ b/sources/ClangSharp.Interop/CX_TemplateName.cs @@ -1,16 +1,15 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CX_TemplateName { - public unsafe partial struct CX_TemplateName - { - public CX_TemplateNameKind kind; + public CX_TemplateNameKind kind; - [NativeTypeName("const void *")] - public void* value; + [NativeTypeName("const void *")] + public void* value; - [NativeTypeName("CXTranslationUnit")] - public CXTranslationUnitImpl* tu; - } + [NativeTypeName("CXTranslationUnit")] + public CXTranslationUnitImpl* tu; } diff --git a/sources/ClangSharp.Interop/CX_TemplateNameKind.cs b/sources/ClangSharp.Interop/CX_TemplateNameKind.cs index 63216e0c..d72a5abc 100644 --- a/sources/ClangSharp.Interop/CX_TemplateNameKind.cs +++ b/sources/ClangSharp.Interop/CX_TemplateNameKind.cs @@ -1,17 +1,16 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_TemplateNameKind { - public enum CX_TemplateNameKind - { - CX_TNK_Invalid, - CX_TNK_Template = 1, - CX_TNK_OverloadedTemplate = 2, - CX_TNK_AssumedTemplate = 3, - CX_TNK_QualifiedTemplate = 4, - CX_TNK_DependentTemplate = 5, - CX_TNK_SubstTemplateTemplateParm = 6, - CX_TNK_SubstTemplateTemplateParmPack = 7 - } + CX_TNK_Invalid, + CX_TNK_Template = 1, + CX_TNK_OverloadedTemplate = 2, + CX_TNK_AssumedTemplate = 3, + CX_TNK_QualifiedTemplate = 4, + CX_TNK_DependentTemplate = 5, + CX_TNK_SubstTemplateTemplateParm = 6, + CX_TNK_SubstTemplateTemplateParmPack = 7 } diff --git a/sources/ClangSharp.Interop/CX_TemplateSpecializationKind.cs b/sources/ClangSharp.Interop/CX_TemplateSpecializationKind.cs index d696b603..0889f80b 100644 --- a/sources/ClangSharp.Interop/CX_TemplateSpecializationKind.cs +++ b/sources/ClangSharp.Interop/CX_TemplateSpecializationKind.cs @@ -1,15 +1,14 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_TemplateSpecializationKind { - public enum CX_TemplateSpecializationKind - { - CX_TSK_Invalid, - CX_TSK_Undeclared, - CX_TSK_ImplicitInstantiation, - CX_TSK_ExplicitSpecialization, - CX_TSK_ExplicitInstantiationDeclaration, - CX_TSK_ExplicitInstantiationDefinition, - } + CX_TSK_Invalid, + CX_TSK_Undeclared, + CX_TSK_ImplicitInstantiation, + CX_TSK_ExplicitSpecialization, + CX_TSK_ExplicitInstantiationDeclaration, + CX_TSK_ExplicitInstantiationDefinition, } diff --git a/sources/ClangSharp.Interop/CX_TypeClass.cs b/sources/ClangSharp.Interop/CX_TypeClass.cs index fbdc7599..0710d558 100644 --- a/sources/ClangSharp.Interop/CX_TypeClass.cs +++ b/sources/ClangSharp.Interop/CX_TypeClass.cs @@ -1,66 +1,65 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_TypeClass { - public enum CX_TypeClass - { - CX_TypeClass_Invalid, - CX_TypeClass_Adjusted, - CX_TypeClass_Decayed, - CX_TypeClass_ConstantArray, - CX_TypeClass_DependentSizedArray, - CX_TypeClass_IncompleteArray, - CX_TypeClass_VariableArray, - CX_TypeClass_Atomic, - CX_TypeClass_Attributed, - CX_TypeClass_BitInt, - CX_TypeClass_BlockPointer, - CX_TypeClass_Builtin, - CX_TypeClass_Complex, - CX_TypeClass_Decltype, - CX_TypeClass_Auto, - CX_TypeClass_DeducedTemplateSpecialization, - CX_TypeClass_DependentAddressSpace, - CX_TypeClass_DependentBitInt, - CX_TypeClass_DependentName, - CX_TypeClass_DependentSizedExtVector, - CX_TypeClass_DependentTemplateSpecialization, - CX_TypeClass_DependentVector, - CX_TypeClass_Elaborated, - CX_TypeClass_FunctionNoProto, - CX_TypeClass_FunctionProto, - CX_TypeClass_InjectedClassName, - CX_TypeClass_MacroQualified, - CX_TypeClass_ConstantMatrix, - CX_TypeClass_DependentSizedMatrix, - CX_TypeClass_MemberPointer, - CX_TypeClass_ObjCObjectPointer, - CX_TypeClass_ObjCObject, - CX_TypeClass_ObjCInterface, - CX_TypeClass_ObjCTypeParam, - CX_TypeClass_PackExpansion, - CX_TypeClass_Paren, - CX_TypeClass_Pipe, - CX_TypeClass_Pointer, - CX_TypeClass_LValueReference, - CX_TypeClass_RValueReference, - CX_TypeClass_SubstTemplateTypeParmPack, - CX_TypeClass_SubstTemplateTypeParm, - CX_TypeClass_Enum, - CX_TypeClass_Record, - CX_TypeClass_TemplateSpecialization, - CX_TypeClass_TemplateTypeParm, - CX_TypeClass_TypeOfExpr, - CX_TypeClass_TypeOf, - CX_TypeClass_Typedef, - CX_TypeClass_UnaryTransform, - CX_TypeClass_UnresolvedUsing, - CX_TypeClass_Using, - CX_TypeClass_Vector, - CX_TypeClass_ExtVector, - CX_TypeClass_TypeLast = CX_TypeClass_ExtVector, - CX_TypeClass_TagFirst = CX_TypeClass_Record, - CX_TypeClass_TagLast = CX_TypeClass_Enum, - } + CX_TypeClass_Invalid, + CX_TypeClass_Adjusted, + CX_TypeClass_Decayed, + CX_TypeClass_ConstantArray, + CX_TypeClass_DependentSizedArray, + CX_TypeClass_IncompleteArray, + CX_TypeClass_VariableArray, + CX_TypeClass_Atomic, + CX_TypeClass_Attributed, + CX_TypeClass_BitInt, + CX_TypeClass_BlockPointer, + CX_TypeClass_Builtin, + CX_TypeClass_Complex, + CX_TypeClass_Decltype, + CX_TypeClass_Auto, + CX_TypeClass_DeducedTemplateSpecialization, + CX_TypeClass_DependentAddressSpace, + CX_TypeClass_DependentBitInt, + CX_TypeClass_DependentName, + CX_TypeClass_DependentSizedExtVector, + CX_TypeClass_DependentTemplateSpecialization, + CX_TypeClass_DependentVector, + CX_TypeClass_Elaborated, + CX_TypeClass_FunctionNoProto, + CX_TypeClass_FunctionProto, + CX_TypeClass_InjectedClassName, + CX_TypeClass_MacroQualified, + CX_TypeClass_ConstantMatrix, + CX_TypeClass_DependentSizedMatrix, + CX_TypeClass_MemberPointer, + CX_TypeClass_ObjCObjectPointer, + CX_TypeClass_ObjCObject, + CX_TypeClass_ObjCInterface, + CX_TypeClass_ObjCTypeParam, + CX_TypeClass_PackExpansion, + CX_TypeClass_Paren, + CX_TypeClass_Pipe, + CX_TypeClass_Pointer, + CX_TypeClass_LValueReference, + CX_TypeClass_RValueReference, + CX_TypeClass_SubstTemplateTypeParmPack, + CX_TypeClass_SubstTemplateTypeParm, + CX_TypeClass_Enum, + CX_TypeClass_Record, + CX_TypeClass_TemplateSpecialization, + CX_TypeClass_TemplateTypeParm, + CX_TypeClass_TypeOfExpr, + CX_TypeClass_TypeOf, + CX_TypeClass_Typedef, + CX_TypeClass_UnaryTransform, + CX_TypeClass_UnresolvedUsing, + CX_TypeClass_Using, + CX_TypeClass_Vector, + CX_TypeClass_ExtVector, + CX_TypeClass_TypeLast = CX_TypeClass_ExtVector, + CX_TypeClass_TagFirst = CX_TypeClass_Record, + CX_TypeClass_TagLast = CX_TypeClass_Enum, } diff --git a/sources/ClangSharp.Interop/CX_UnaryExprOrTypeTrait.cs b/sources/ClangSharp.Interop/CX_UnaryExprOrTypeTrait.cs index ffa718ff..3d2450ac 100644 --- a/sources/ClangSharp.Interop/CX_UnaryExprOrTypeTrait.cs +++ b/sources/ClangSharp.Interop/CX_UnaryExprOrTypeTrait.cs @@ -1,16 +1,15 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_UnaryExprOrTypeTrait { - public enum CX_UnaryExprOrTypeTrait - { - CX_UETT_Invalid, - CX_UETT_SizeOf, - CX_UETT_AlignOf, - CX_UETT_PreferredAlignOf, - CX_UETT_VecStep, - CX_UETT_OpenMPRequiredSimdAlign, - CX_UETT_Last = -1 + 1 + 1 + 1 + 1 + 1, - } + CX_UETT_Invalid, + CX_UETT_SizeOf, + CX_UETT_AlignOf, + CX_UETT_PreferredAlignOf, + CX_UETT_VecStep, + CX_UETT_OpenMPRequiredSimdAlign, + CX_UETT_Last = -1 + 1 + 1 + 1 + 1 + 1, } diff --git a/sources/ClangSharp.Interop/CX_UnaryOperatorKind.cs b/sources/ClangSharp.Interop/CX_UnaryOperatorKind.cs index 75ae9128..16862e2d 100644 --- a/sources/ClangSharp.Interop/CX_UnaryOperatorKind.cs +++ b/sources/ClangSharp.Interop/CX_UnaryOperatorKind.cs @@ -1,24 +1,23 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_UnaryOperatorKind { - public enum CX_UnaryOperatorKind - { - CX_UO_Invalid, - CX_UO_PostInc, - CX_UO_PostDec, - CX_UO_PreInc, - CX_UO_PreDec, - CX_UO_AddrOf, - CX_UO_Deref, - CX_UO_Plus, - CX_UO_Minus, - CX_UO_Not, - CX_UO_LNot, - CX_UO_Real, - CX_UO_Imag, - CX_UO_Extension, - CX_UO_Coawait, - } + CX_UO_Invalid, + CX_UO_PostInc, + CX_UO_PostDec, + CX_UO_PreInc, + CX_UO_PreDec, + CX_UO_AddrOf, + CX_UO_Deref, + CX_UO_Plus, + CX_UO_Minus, + CX_UO_Not, + CX_UO_LNot, + CX_UO_Real, + CX_UO_Imag, + CX_UO_Extension, + CX_UO_Coawait, } diff --git a/sources/ClangSharp.Interop/CX_VariableCaptureKind.cs b/sources/ClangSharp.Interop/CX_VariableCaptureKind.cs index 9e4fe4b6..417622d6 100644 --- a/sources/ClangSharp.Interop/CX_VariableCaptureKind.cs +++ b/sources/ClangSharp.Interop/CX_VariableCaptureKind.cs @@ -1,14 +1,13 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public enum CX_VariableCaptureKind { - public enum CX_VariableCaptureKind - { - CX_VCK_Invalid, - CX_VCK_This, - CX_VCK_ByRef, - CX_VCK_ByCopy, - CX_VCK_VLAType - } + CX_VCK_Invalid, + CX_VCK_This, + CX_VCK_ByRef, + CX_VCK_ByCopy, + CX_VCK_VLAType } diff --git a/sources/ClangSharp.Interop/Extensions/CXClientData.cs b/sources/ClangSharp.Interop/Extensions/CXClientData.cs index 236ef24c..e73df948 100644 --- a/sources/ClangSharp.Interop/Extensions/CXClientData.cs +++ b/sources/ClangSharp.Interop/Extensions/CXClientData.cs @@ -2,29 +2,28 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXClientData : IEquatable { - public unsafe partial struct CXClientData : IEquatable + public CXClientData(IntPtr handle) { - public CXClientData(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static explicit operator CXClientData(void* value) => new CXClientData((IntPtr)value); + public static explicit operator CXClientData(void* value) => new CXClientData((IntPtr)value); - public static implicit operator void*(CXClientData value) => (void*)value.Handle; + public static implicit operator void*(CXClientData value) => (void*)value.Handle; - public static bool operator ==(CXClientData left, CXClientData right) => left.Handle == right.Handle; + public static bool operator ==(CXClientData left, CXClientData right) => left.Handle == right.Handle; - public static bool operator !=(CXClientData left, CXClientData right) => left.Handle != right.Handle; + public static bool operator !=(CXClientData left, CXClientData right) => left.Handle != right.Handle; - public override bool Equals(object obj) => (obj is CXClientData other) && Equals(other); + public override bool Equals(object obj) => (obj is CXClientData other) && Equals(other); - public bool Equals(CXClientData other) => this == other; + public bool Equals(CXClientData other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); - } + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXCodeCompleteResults.cs b/sources/ClangSharp.Interop/Extensions/CXCodeCompleteResults.cs index fa7c1794..fdeb5de2 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCodeCompleteResults.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCodeCompleteResults.cs @@ -2,101 +2,100 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXCodeCompleteResults : IDisposable { - public unsafe partial struct CXCodeCompleteResults : IDisposable - { - public static CXCodeComplete_Flags DefaultOptions => (CXCodeComplete_Flags)clang.defaultCodeCompleteOptions(); + public static CXCodeComplete_Flags DefaultOptions => (CXCodeComplete_Flags)clang.defaultCodeCompleteOptions(); - public CXString ContainerUsr + public CXString ContainerUsr + { + get { - get + fixed (CXCodeCompleteResults* pThis = &this) { - fixed (CXCodeCompleteResults* pThis = &this) - { - return clang.codeCompleteGetContainerUSR(pThis); - } + return clang.codeCompleteGetContainerUSR(pThis); } } + } - public ulong Contexts + public ulong Contexts + { + get { - get + fixed (CXCodeCompleteResults* pThis = &this) { - fixed (CXCodeCompleteResults* pThis = &this) - { - return clang.codeCompleteGetContexts(pThis); - } + return clang.codeCompleteGetContexts(pThis); } } + } - public uint NumDiagnostics + public uint NumDiagnostics + { + get { - get + fixed (CXCodeCompleteResults* pThis = &this) { - fixed (CXCodeCompleteResults* pThis = &this) - { - return clang.codeCompleteGetNumDiagnostics(pThis); - } + return clang.codeCompleteGetNumDiagnostics(pThis); } } + } - public CXString ObjCSelector + public CXString ObjCSelector + { + get { - get + fixed (CXCodeCompleteResults* pThis = &this) { - fixed (CXCodeCompleteResults* pThis = &this) - { - return clang.codeCompleteGetObjCSelector(pThis); - } + return clang.codeCompleteGetObjCSelector(pThis); } } + } - public void Dispose() + public void Dispose() + { + fixed (CXCodeCompleteResults* pThis = &this) { - fixed (CXCodeCompleteResults* pThis = &this) - { - clang.disposeCodeCompleteResults(pThis); - } + clang.disposeCodeCompleteResults(pThis); } + } - public CXCursorKind GetContaininerKind(out bool isIncomplete) + public CXCursorKind GetContaininerKind(out bool isIncomplete) + { + fixed (CXCodeCompleteResults* pThis = &this) { - fixed (CXCodeCompleteResults* pThis = &this) - { - uint isIncompleteOut; - var result = clang.codeCompleteGetContainerKind(pThis, &isIncompleteOut); + uint isIncompleteOut; + var result = clang.codeCompleteGetContainerKind(pThis, &isIncompleteOut); - isIncomplete = isIncompleteOut != 0; - return result; - } + isIncomplete = isIncompleteOut != 0; + return result; } + } - public CXDiagnostic GetDiagnostic(uint index) + public CXDiagnostic GetDiagnostic(uint index) + { + fixed (CXCodeCompleteResults* pThis = &this) { - fixed (CXCodeCompleteResults* pThis = &this) - { - return (CXDiagnostic)clang.codeCompleteGetDiagnostic(pThis, index); - } + return (CXDiagnostic)clang.codeCompleteGetDiagnostic(pThis, index); } + } - public CXString GetFixIt(uint completionIndex, uint fixitIndex, out CXSourceRange replacementRange) + public CXString GetFixIt(uint completionIndex, uint fixitIndex, out CXSourceRange replacementRange) + { + fixed (CXCodeCompleteResults* pThis = &this) + fixed (CXSourceRange* pReplacementRange = &replacementRange) { - fixed (CXCodeCompleteResults* pThis = &this) - fixed (CXSourceRange* pReplacementRange = &replacementRange) - { - return clang.getCompletionFixIt(pThis, completionIndex, fixitIndex, pReplacementRange); - } + return clang.getCompletionFixIt(pThis, completionIndex, fixitIndex, pReplacementRange); } + } - public uint GetNumFixIts(uint completionIndex) + public uint GetNumFixIts(uint completionIndex) + { + fixed (CXCodeCompleteResults* pThis = &this) { - fixed (CXCodeCompleteResults* pThis = &this) - { - return clang.getCompletionNumFixIts(pThis, completionIndex); - } + return clang.getCompletionNumFixIts(pThis, completionIndex); } - - public void Sort() => clang.sortCodeCompletionResults(Results, NumResults); } + + public void Sort() => clang.sortCodeCompletionResults(Results, NumResults); } diff --git a/sources/ClangSharp.Interop/Extensions/CXComment.cs b/sources/ClangSharp.Interop/Extensions/CXComment.cs index a1a2d616..12a4e86a 100644 --- a/sources/ClangSharp.Interop/Extensions/CXComment.cs +++ b/sources/ClangSharp.Interop/Extensions/CXComment.cs @@ -1,73 +1,72 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXComment { - public partial struct CXComment - { - public CXString BlockCommandComment_CommandName => clang.BlockCommandComment_getCommandName(this); + public CXString BlockCommandComment_CommandName => clang.BlockCommandComment_getCommandName(this); - public uint BlockCommandComment_NumArgs => clang.BlockCommandComment_getNumArgs(this); + public uint BlockCommandComment_NumArgs => clang.BlockCommandComment_getNumArgs(this); - public CXComment BlockCommandComment_Paragraph => clang.BlockCommandComment_getParagraph(this); + public CXComment BlockCommandComment_Paragraph => clang.BlockCommandComment_getParagraph(this); - public CXString FullComment_AsHtml => clang.FullComment_getAsHTML(this); + public CXString FullComment_AsHtml => clang.FullComment_getAsHTML(this); - public CXString FullComment_AsXml => clang.FullComment_getAsXML(this); + public CXString FullComment_AsXml => clang.FullComment_getAsXML(this); - public uint HtmlStartTag_NumAttrs => clang.HTMLStartTag_getNumAttrs(this); + public uint HtmlStartTag_NumAttrs => clang.HTMLStartTag_getNumAttrs(this); - public bool HtmlStartTagComment_IsSelfClosing => clang.HTMLStartTagComment_isSelfClosing(this) != 0; + public bool HtmlStartTagComment_IsSelfClosing => clang.HTMLStartTagComment_isSelfClosing(this) != 0; - public CXString HtmlTagComment_AsString => clang.HTMLTagComment_getAsString(this); + public CXString HtmlTagComment_AsString => clang.HTMLTagComment_getAsString(this); - public CXString HtmlTagComment_TagName => clang.HTMLTagComment_getTagName(this); + public CXString HtmlTagComment_TagName => clang.HTMLTagComment_getTagName(this); - public CXString InlineCommandComment_CommandName => clang.InlineCommandComment_getCommandName(this); + public CXString InlineCommandComment_CommandName => clang.InlineCommandComment_getCommandName(this); - public uint InlineCommandComment_NumArgs => clang.InlineCommandComment_getNumArgs(this); + public uint InlineCommandComment_NumArgs => clang.InlineCommandComment_getNumArgs(this); - public CXCommentInlineCommandRenderKind InlineCommandComment_RenderKind => clang.InlineCommandComment_getRenderKind(this); + public CXCommentInlineCommandRenderKind InlineCommandComment_RenderKind => clang.InlineCommandComment_getRenderKind(this); - public bool InlineContentComment_HasTrailingNewline => clang.InlineContentComment_hasTrailingNewline(this) != 0; + public bool InlineContentComment_HasTrailingNewline => clang.InlineContentComment_hasTrailingNewline(this) != 0; - public bool IsWhitespace => clang.Comment_isWhitespace(this) != 0; + public bool IsWhitespace => clang.Comment_isWhitespace(this) != 0; - public CXCommentKind Kind => clang.Comment_getKind(this); + public CXCommentKind Kind => clang.Comment_getKind(this); - public uint NumChildren => clang.Comment_getNumChildren(this); + public uint NumChildren => clang.Comment_getNumChildren(this); - public CXCommentParamPassDirection ParamCommandComment_Direction => clang.ParamCommandComment_getDirection(this); + public CXCommentParamPassDirection ParamCommandComment_Direction => clang.ParamCommandComment_getDirection(this); - public bool ParamCommandComment_IsDirectionExplicit => clang.ParamCommandComment_isDirectionExplicit(this) != 0; + public bool ParamCommandComment_IsDirectionExplicit => clang.ParamCommandComment_isDirectionExplicit(this) != 0; - public bool ParamCommandComment_IsParamIndexValid => clang.ParamCommandComment_isParamIndexValid(this) != 0; + public bool ParamCommandComment_IsParamIndexValid => clang.ParamCommandComment_isParamIndexValid(this) != 0; - public uint ParamCommandComment_ParamIndex => clang.ParamCommandComment_getParamIndex(this); + public uint ParamCommandComment_ParamIndex => clang.ParamCommandComment_getParamIndex(this); - public CXString ParamCommandComment_ParamName => clang.ParamCommandComment_getParamName(this); + public CXString ParamCommandComment_ParamName => clang.ParamCommandComment_getParamName(this); - public CXString TextComment_Text => clang.TextComment_getText(this); + public CXString TextComment_Text => clang.TextComment_getText(this); - public uint TParamCommandComment_Depth => clang.TParamCommandComment_getDepth(this); + public uint TParamCommandComment_Depth => clang.TParamCommandComment_getDepth(this); - public CXString TParamCommandComment_ParamName => clang.TParamCommandComment_getParamName(this); + public CXString TParamCommandComment_ParamName => clang.TParamCommandComment_getParamName(this); - public bool TParamCommandComment_IsParamPositionValid => clang.TParamCommandComment_isParamPositionValid(this) != 0; + public bool TParamCommandComment_IsParamPositionValid => clang.TParamCommandComment_isParamPositionValid(this) != 0; - public CXString VerbatimBlockLineComment_Text => clang.VerbatimBlockLineComment_getText(this); + public CXString VerbatimBlockLineComment_Text => clang.VerbatimBlockLineComment_getText(this); - public CXString VerbatimLineComment_Text => clang.VerbatimLineComment_getText(this); + public CXString VerbatimLineComment_Text => clang.VerbatimLineComment_getText(this); - public CXString BlockCommandComment_GetArgText(uint index) => clang.BlockCommandComment_getArgText(this, index); + public CXString BlockCommandComment_GetArgText(uint index) => clang.BlockCommandComment_getArgText(this, index); - public CXComment GetChild(uint index) => clang.Comment_getChild(this, index); + public CXComment GetChild(uint index) => clang.Comment_getChild(this, index); - public CXString HtmlStartTag_GetAttrName(uint index) => clang.HTMLStartTag_getAttrName(this, index); + public CXString HtmlStartTag_GetAttrName(uint index) => clang.HTMLStartTag_getAttrName(this, index); - public CXString HtmlStartTag_GetAttrValue(uint index) => clang.HTMLStartTag_getAttrValue(this, index); + public CXString HtmlStartTag_GetAttrValue(uint index) => clang.HTMLStartTag_getAttrValue(this, index); - public CXString InlineCommandComment_GetArgText(uint index) => clang.InlineCommandComment_getArgText(this, index); + public CXString InlineCommandComment_GetArgText(uint index) => clang.InlineCommandComment_getArgText(this, index); - public uint TParamCommandComment_GetIndex(uint depth) => clang.TParamCommandComment_getIndex(this, depth); - } + public uint TParamCommandComment_GetIndex(uint depth) => clang.TParamCommandComment_getIndex(this, depth); } diff --git a/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs b/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs index dd176f5d..0e8a18ca 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs @@ -2,56 +2,55 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXCompilationDatabase : IDisposable, IEquatable { - public unsafe partial struct CXCompilationDatabase : IDisposable, IEquatable + public CXCompilationDatabase(IntPtr handle) { - public CXCompilationDatabase(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public CXCompileCommands AllCompileCommands => (CXCompileCommands)clang.CompilationDatabase_getAllCompileCommands(this); + public CXCompileCommands AllCompileCommands => (CXCompileCommands)clang.CompilationDatabase_getAllCompileCommands(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static explicit operator CXCompilationDatabase(void* value) => new CXCompilationDatabase((IntPtr)value); + public static explicit operator CXCompilationDatabase(void* value) => new CXCompilationDatabase((IntPtr)value); - public static implicit operator void*(CXCompilationDatabase value) => (void*)value.Handle; + public static implicit operator void*(CXCompilationDatabase value) => (void*)value.Handle; - public static bool operator ==(CXCompilationDatabase left, CXCompilationDatabase right) => left.Handle == right.Handle; + public static bool operator ==(CXCompilationDatabase left, CXCompilationDatabase right) => left.Handle == right.Handle; - public static bool operator !=(CXCompilationDatabase left, CXCompilationDatabase right) => left.Handle != right.Handle; + public static bool operator !=(CXCompilationDatabase left, CXCompilationDatabase right) => left.Handle != right.Handle; - public static CXCompilationDatabase FromDirectory(string buildDir, out CXCompilationDatabase_Error errorCode) - { - using var marshaledBuildDir = new MarshaledString(buildDir); + public static CXCompilationDatabase FromDirectory(string buildDir, out CXCompilationDatabase_Error errorCode) + { + using var marshaledBuildDir = new MarshaledString(buildDir); - fixed (CXCompilationDatabase_Error* pErrorCode = &errorCode) - { - return (CXCompilationDatabase)clang.CompilationDatabase_fromDirectory(marshaledBuildDir, pErrorCode); - } + fixed (CXCompilationDatabase_Error* pErrorCode = &errorCode) + { + return (CXCompilationDatabase)clang.CompilationDatabase_fromDirectory(marshaledBuildDir, pErrorCode); } + } - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.CompilationDatabase_dispose(this); - Handle = IntPtr.Zero; - } + clang.CompilationDatabase_dispose(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXCompilationDatabase other) && Equals(other); + public override bool Equals(object obj) => (obj is CXCompilationDatabase other) && Equals(other); - public bool Equals(CXCompilationDatabase other) => this == other; + public bool Equals(CXCompilationDatabase other) => this == other; - public CXCompileCommands GetCompileCommands(string completeFileName) - { - using var marshaledCompleteFileName = new MarshaledString(completeFileName); - return (CXCompileCommands)clang.CompilationDatabase_getCompileCommands(this, marshaledCompleteFileName); - } - - public override int GetHashCode() => Handle.GetHashCode(); + public CXCompileCommands GetCompileCommands(string completeFileName) + { + using var marshaledCompleteFileName = new MarshaledString(completeFileName); + return (CXCompileCommands)clang.CompilationDatabase_getCompileCommands(this, marshaledCompleteFileName); } + + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs b/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs index cf73a092..b74185ec 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs @@ -2,43 +2,42 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXCompileCommand : IEquatable { - public unsafe partial struct CXCompileCommand : IEquatable + public CXCompileCommand(IntPtr handle) { - public CXCompileCommand(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public CXString Directory => clang.CompileCommand_getDirectory(this); + public CXString Directory => clang.CompileCommand_getDirectory(this); - public CXString Filename => clang.CompileCommand_getFilename(this); + public CXString Filename => clang.CompileCommand_getFilename(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public uint NumArgs => clang.CompileCommand_getNumArgs(this); + public uint NumArgs => clang.CompileCommand_getNumArgs(this); - public uint NumMappedSources => clang.CompileCommand_getNumMappedSources(this); + public uint NumMappedSources => clang.CompileCommand_getNumMappedSources(this); - public static explicit operator CXCompileCommand(void* value) => new CXCompileCommand((IntPtr)value); + public static explicit operator CXCompileCommand(void* value) => new CXCompileCommand((IntPtr)value); - public static implicit operator void*(CXCompileCommand value) => (void*)value.Handle; + public static implicit operator void*(CXCompileCommand value) => (void*)value.Handle; - public static bool operator ==(CXCompileCommand left, CXCompileCommand right) => left.Handle == right.Handle; + public static bool operator ==(CXCompileCommand left, CXCompileCommand right) => left.Handle == right.Handle; - public static bool operator !=(CXCompileCommand left, CXCompileCommand right) => left.Handle != right.Handle; + public static bool operator !=(CXCompileCommand left, CXCompileCommand right) => left.Handle != right.Handle; - public override bool Equals(object obj) => (obj is CXCompileCommand other) && Equals(other); + public override bool Equals(object obj) => (obj is CXCompileCommand other) && Equals(other); - public bool Equals(CXCompileCommand other) => this == other; + public bool Equals(CXCompileCommand other) => this == other; - public CXString GetArg(uint index) => clang.CompileCommand_getArg(this, index); + public CXString GetArg(uint index) => clang.CompileCommand_getArg(this, index); - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public CXString GetMappedSourceContent(uint index) => clang.CompileCommand_getMappedSourceContent(this, index); + public CXString GetMappedSourceContent(uint index) => clang.CompileCommand_getMappedSourceContent(this, index); - public CXString GetMappedSourcePath(uint index) => clang.CompileCommand_getMappedSourcePath(this, index); - } + public CXString GetMappedSourcePath(uint index) => clang.CompileCommand_getMappedSourcePath(this, index); } diff --git a/sources/ClangSharp.Interop/Extensions/CXCompileCommands.cs b/sources/ClangSharp.Interop/Extensions/CXCompileCommands.cs index 71b9d072..05da1260 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompileCommands.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompileCommands.cs @@ -4,58 +4,57 @@ using System.Collections; using System.Collections.Generic; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXCompileCommands : IDisposable, IEquatable, IReadOnlyCollection { - public unsafe partial struct CXCompileCommands : IDisposable, IEquatable, IReadOnlyCollection + public CXCompileCommands(IntPtr handle) { - public CXCompileCommands(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public CXCompileCommand this[uint index] => GetCommand(index); + public CXCompileCommand this[uint index] => GetCommand(index); - public int Count => (int)Size; + public int Count => (int)Size; - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public uint Size => clang.CompileCommands_getSize(this); + public uint Size => clang.CompileCommands_getSize(this); - public static explicit operator CXCompileCommands(void* value) => new CXCompileCommands((IntPtr)value); + public static explicit operator CXCompileCommands(void* value) => new CXCompileCommands((IntPtr)value); - public static implicit operator void*(CXCompileCommands value) => (void*)value.Handle; + public static implicit operator void*(CXCompileCommands value) => (void*)value.Handle; - public static bool operator ==(CXCompileCommands left, CXCompileCommands right) => left.Handle == right.Handle; + public static bool operator ==(CXCompileCommands left, CXCompileCommands right) => left.Handle == right.Handle; - public static bool operator !=(CXCompileCommands left, CXCompileCommands right) => left.Handle != right.Handle; + public static bool operator !=(CXCompileCommands left, CXCompileCommands right) => left.Handle != right.Handle; - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.CompilationDatabase_dispose(this); - Handle = IntPtr.Zero; - } + clang.CompilationDatabase_dispose(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXCompileCommands other) && Equals(other); + public override bool Equals(object obj) => (obj is CXCompileCommands other) && Equals(other); - public bool Equals(CXCompileCommands other) => this == other; + public bool Equals(CXCompileCommands other) => this == other; - public CXCompileCommand GetCommand(uint index) => (CXCompileCommand)clang.CompileCommands_getCommand(this, index); + public CXCompileCommand GetCommand(uint index) => (CXCompileCommand)clang.CompileCommands_getCommand(this, index); - public IEnumerator GetEnumerator() - { - var count = Size; + public IEnumerator GetEnumerator() + { + var count = Size; - for (var index = 0u; index < count; index++) - { - yield return GetCommand(index); - } + for (var index = 0u; index < count; index++) + { + yield return GetCommand(index); } + } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - public override int GetHashCode() => Handle.GetHashCode(); - } + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs b/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs index e6629775..b042a218 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs @@ -2,55 +2,54 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXCompletionString : IEquatable { - public unsafe partial struct CXCompletionString : IEquatable + public CXCompletionString(IntPtr handle) { - public CXCompletionString(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public CXAvailabilityKind Availability => clang.getCompletionAvailability(this); + public CXAvailabilityKind Availability => clang.getCompletionAvailability(this); - public CXString BriefComment => clang.getCompletionBriefComment(this); + public CXString BriefComment => clang.getCompletionBriefComment(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public uint NumAnnotations => clang.getCompletionNumAnnotations(this); + public uint NumAnnotations => clang.getCompletionNumAnnotations(this); - public uint NumChunks => clang.getNumCompletionChunks(this); + public uint NumChunks => clang.getNumCompletionChunks(this); - public uint Priority => clang.getCompletionPriority(this); + public uint Priority => clang.getCompletionPriority(this); - public static explicit operator CXCompletionString(void* value) => new CXCompletionString((IntPtr)value); + public static explicit operator CXCompletionString(void* value) => new CXCompletionString((IntPtr)value); - public static implicit operator void*(CXCompletionString value) => (void*)value.Handle; + public static implicit operator void*(CXCompletionString value) => (void*)value.Handle; - public static bool operator ==(CXCompletionString left, CXCompletionString right) => left.Handle == right.Handle; + public static bool operator ==(CXCompletionString left, CXCompletionString right) => left.Handle == right.Handle; - public static bool operator !=(CXCompletionString left, CXCompletionString right) => left.Handle != right.Handle; + public static bool operator !=(CXCompletionString left, CXCompletionString right) => left.Handle != right.Handle; - public override bool Equals(object obj) => (obj is CXCompletionString other) && Equals(other); + public override bool Equals(object obj) => (obj is CXCompletionString other) && Equals(other); - public bool Equals(CXCompletionString other) => this == other; + public bool Equals(CXCompletionString other) => this == other; - public CXString GetAnnotation(uint index) => clang.getCompletionAnnotation(this, index); + public CXString GetAnnotation(uint index) => clang.getCompletionAnnotation(this, index); - public CXCompletionString GetChunkCompletionString(uint index) => (CXCompletionString)clang.getCompletionChunkCompletionString(this, index); + public CXCompletionString GetChunkCompletionString(uint index) => (CXCompletionString)clang.getCompletionChunkCompletionString(this, index); - public CXCompletionChunkKind GetChunkKind(uint index) => clang.getCompletionChunkKind(this, index); + public CXCompletionChunkKind GetChunkKind(uint index) => clang.getCompletionChunkKind(this, index); - public CXString GetChunkText(uint index) => clang.getCompletionChunkText(this, index); + public CXString GetChunkText(uint index) => clang.getCompletionChunkText(this, index); - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public CXString GetParent(out CXCursorKind kind) + public CXString GetParent(out CXCursorKind kind) + { + fixed (CXCursorKind* pKind = &kind) { - fixed (CXCursorKind* pKind = &kind) - { - return clang.getCompletionParent(this, pKind); - } + return clang.getCompletionParent(this, pKind); } } } diff --git a/sources/ClangSharp.Interop/Extensions/CXCursor.cs b/sources/ClangSharp.Interop/Extensions/CXCursor.cs index e58251e2..18e755b4 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCursor.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCursor.cs @@ -4,1621 +4,1620 @@ using System.Diagnostics; using System.Runtime.InteropServices; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +[DebuggerDisplay("{DebuggerDisplayString,nq}")] +public unsafe partial struct CXCursor : IEquatable { - [DebuggerDisplay("{DebuggerDisplayString,nq}")] - public unsafe partial struct CXCursor : IEquatable - { - public static CXCursor Null => clang.getNullCursor(); + public static CXCursor Null => clang.getNullCursor(); - public CXType ArgumentType => clangsharp.Cursor_getArgumentType(this); + public CXType ArgumentType => clangsharp.Cursor_getArgumentType(this); - public long ArraySize => clangsharp.Cursor_getArraySize(this); + public long ArraySize => clangsharp.Cursor_getArraySize(this); - public CXCursor AsFunction => clangsharp.Cursor_getAsFunction(this); + public CXCursor AsFunction => clangsharp.Cursor_getAsFunction(this); - public CX_AtomicOperatorKind AtomicOperatorKind => clangsharp.Cursor_getAtomicOpcode(this); + public CX_AtomicOperatorKind AtomicOperatorKind => clangsharp.Cursor_getAtomicOpcode(this); - public CX_AttrKind AttrKind => clangsharp.Cursor_getAttrKind(this); + public CX_AttrKind AttrKind => clangsharp.Cursor_getAttrKind(this); - public string AttrKindSpelling + public string AttrKindSpelling + { + get { - get + Debug.Assert(CX_AttrKind.CX_AttrKind_FirstDeclOrTypeAttr == CX_AttrKind.CX_AttrKind_AArch64VectorPcs); + Debug.Assert(CX_AttrKind.CX_AttrKind_LastDeclOrTypeAttr == CX_AttrKind.CX_AttrKind_VectorCall); + Debug.Assert(CX_AttrKind.CX_AttrKind_FirstInheritableParamAttr == CX_AttrKind.CX_AttrKind_SwiftAsyncContext); + Debug.Assert(CX_AttrKind.CX_AttrKind_LastInheritableParamAttr == CX_AttrKind.CX_AttrKind_UseHandle); + Debug.Assert(CX_AttrKind.CX_AttrKind_FirstParameterABIAttr == CX_AttrKind.CX_AttrKind_SwiftAsyncContext); + Debug.Assert(CX_AttrKind.CX_AttrKind_LastParameterABIAttr == CX_AttrKind.CX_AttrKind_SwiftIndirectResult); + Debug.Assert(CX_AttrKind.CX_AttrKind_LastAttr == CX_AttrKind.CX_AttrKind_Thread); + Debug.Assert(CX_AttrKind.CX_AttrKind_FirstTypeAttr == CX_AttrKind.CX_AttrKind_AddressSpace); + Debug.Assert(CX_AttrKind.CX_AttrKind_LastTypeAttr == CX_AttrKind.CX_AttrKind_UPtr); + Debug.Assert(CX_AttrKind.CX_AttrKind_FirstStmtAttr == CX_AttrKind.CX_AttrKind_FallThrough); + Debug.Assert(CX_AttrKind.CX_AttrKind_LastStmtAttr == CX_AttrKind.CX_AttrKind_Unlikely); + Debug.Assert(CX_AttrKind.CX_AttrKind_FirstInheritableAttr == CX_AttrKind.CX_AttrKind_NoMerge); + Debug.Assert(CX_AttrKind.CX_AttrKind_LastInheritableAttr == CX_AttrKind.CX_AttrKind_XRayLogArgs); + + return AttrKind switch { - Debug.Assert(CX_AttrKind.CX_AttrKind_FirstDeclOrTypeAttr == CX_AttrKind.CX_AttrKind_AArch64VectorPcs); - Debug.Assert(CX_AttrKind.CX_AttrKind_LastDeclOrTypeAttr == CX_AttrKind.CX_AttrKind_VectorCall); - Debug.Assert(CX_AttrKind.CX_AttrKind_FirstInheritableParamAttr == CX_AttrKind.CX_AttrKind_SwiftAsyncContext); - Debug.Assert(CX_AttrKind.CX_AttrKind_LastInheritableParamAttr == CX_AttrKind.CX_AttrKind_UseHandle); - Debug.Assert(CX_AttrKind.CX_AttrKind_FirstParameterABIAttr == CX_AttrKind.CX_AttrKind_SwiftAsyncContext); - Debug.Assert(CX_AttrKind.CX_AttrKind_LastParameterABIAttr == CX_AttrKind.CX_AttrKind_SwiftIndirectResult); - Debug.Assert(CX_AttrKind.CX_AttrKind_LastAttr == CX_AttrKind.CX_AttrKind_Thread); - Debug.Assert(CX_AttrKind.CX_AttrKind_FirstTypeAttr == CX_AttrKind.CX_AttrKind_AddressSpace); - Debug.Assert(CX_AttrKind.CX_AttrKind_LastTypeAttr == CX_AttrKind.CX_AttrKind_UPtr); - Debug.Assert(CX_AttrKind.CX_AttrKind_FirstStmtAttr == CX_AttrKind.CX_AttrKind_FallThrough); - Debug.Assert(CX_AttrKind.CX_AttrKind_LastStmtAttr == CX_AttrKind.CX_AttrKind_Unlikely); - Debug.Assert(CX_AttrKind.CX_AttrKind_FirstInheritableAttr == CX_AttrKind.CX_AttrKind_NoMerge); - Debug.Assert(CX_AttrKind.CX_AttrKind_LastInheritableAttr == CX_AttrKind.CX_AttrKind_XRayLogArgs); - - return AttrKind switch - { - CX_AttrKind.CX_AttrKind_Invalid => "Invalid", - CX_AttrKind.CX_AttrKind_AddressSpace => "AddressSpace", - CX_AttrKind.CX_AttrKind_ArmMveStrictPolymorphism => "ArmMveStrictPolymorphism", - CX_AttrKind.CX_AttrKind_CmseNSCall => "CmseNSCall", - CX_AttrKind.CX_AttrKind_NoDeref => "NoDeref", - CX_AttrKind.CX_AttrKind_ObjCGC => "ObjCGC", - CX_AttrKind.CX_AttrKind_ObjCInertUnsafeUnretained => "ObjCInertUnsafeUnretained", - CX_AttrKind.CX_AttrKind_ObjCKindOf => "ObjCKindOf", - CX_AttrKind.CX_AttrKind_OpenCLConstantAddressSpace => "OpenCLConstantAddressSpace", - CX_AttrKind.CX_AttrKind_OpenCLGenericAddressSpace => "OpenCLGenericAddressSpace", - CX_AttrKind.CX_AttrKind_OpenCLGlobalAddressSpace => "OpenCLGlobalAddressSpace", - CX_AttrKind.CX_AttrKind_OpenCLLocalAddressSpace => "OpenCLLocalAddressSpace", - CX_AttrKind.CX_AttrKind_OpenCLPrivateAddressSpace => "OpenCLPrivateAddressSpace", - CX_AttrKind.CX_AttrKind_Ptr32 => "Ptr32", - CX_AttrKind.CX_AttrKind_Ptr64 => "Ptr64", - CX_AttrKind.CX_AttrKind_SPtr => "SPtr", - CX_AttrKind.CX_AttrKind_TypeNonNull => "TypeNonNull", - CX_AttrKind.CX_AttrKind_TypeNullUnspecified => "TypeNullUnspecified", - CX_AttrKind.CX_AttrKind_TypeNullable => "TypeNullable", - CX_AttrKind.CX_AttrKind_UPtr => "UPtr", - CX_AttrKind.CX_AttrKind_FallThrough => "FallThrough", - CX_AttrKind.CX_AttrKind_NoMerge => "NoMerge", - CX_AttrKind.CX_AttrKind_Suppress => "Suppress", - CX_AttrKind.CX_AttrKind_AArch64VectorPcs => "AArch64VectorPcs", - CX_AttrKind.CX_AttrKind_AcquireHandle => "AcquireHandle", - CX_AttrKind.CX_AttrKind_AnyX86NoCfCheck => "AnyX86NoCfCheck", - CX_AttrKind.CX_AttrKind_CDecl => "CDecl", - CX_AttrKind.CX_AttrKind_FastCall => "FastCall", - CX_AttrKind.CX_AttrKind_IntelOclBicc => "IntelOclBicc", - CX_AttrKind.CX_AttrKind_LifetimeBound => "LifetimeBound", - CX_AttrKind.CX_AttrKind_MSABI => "MSABI", - CX_AttrKind.CX_AttrKind_NSReturnsRetained => "NSReturnsRetained", - CX_AttrKind.CX_AttrKind_ObjCOwnership => "ObjCOwnership", - CX_AttrKind.CX_AttrKind_Pascal => "Pascal", - CX_AttrKind.CX_AttrKind_Pcs => "Pcs", - CX_AttrKind.CX_AttrKind_PreserveAll => "PreserveAll", - CX_AttrKind.CX_AttrKind_PreserveMost => "PreserveMost", - CX_AttrKind.CX_AttrKind_RegCall => "RegCall", - CX_AttrKind.CX_AttrKind_StdCall => "StdCall", - CX_AttrKind.CX_AttrKind_SwiftCall => "SwiftCall", - CX_AttrKind.CX_AttrKind_SysVABI => "SysVABI", - CX_AttrKind.CX_AttrKind_ThisCall => "ThisCall", - CX_AttrKind.CX_AttrKind_VectorCall => "VectorCall", - CX_AttrKind.CX_AttrKind_SwiftContext => "SwiftContext", - CX_AttrKind.CX_AttrKind_SwiftErrorResult => "SwiftErrorResult", - CX_AttrKind.CX_AttrKind_SwiftIndirectResult => "SwiftIndirectResult", - CX_AttrKind.CX_AttrKind_Annotate => "Annotate", - CX_AttrKind.CX_AttrKind_CFConsumed => "CFConsumed", - CX_AttrKind.CX_AttrKind_CarriesDependency => "CarriesDependency", - CX_AttrKind.CX_AttrKind_NSConsumed => "NSConsumed", - CX_AttrKind.CX_AttrKind_NonNull => "NonNull", - CX_AttrKind.CX_AttrKind_OSConsumed => "OSConsumed", - CX_AttrKind.CX_AttrKind_PassObjectSize => "PassObjectSize", - CX_AttrKind.CX_AttrKind_ReleaseHandle => "ReleaseHandle", - CX_AttrKind.CX_AttrKind_UseHandle => "UseHandle", - CX_AttrKind.CX_AttrKind_AMDGPUFlatWorkGroupSize => "AMDGPUFlatWorkGroupSize", - CX_AttrKind.CX_AttrKind_AMDGPUNumSGPR => "AMDGPUNumSGPR", - CX_AttrKind.CX_AttrKind_AMDGPUNumVGPR => "AMDGPUNumVGPR", - CX_AttrKind.CX_AttrKind_AMDGPUWavesPerEU => "AMDGPUWavesPerEU", - CX_AttrKind.CX_AttrKind_ARMInterrupt => "ARMInterrupt", - CX_AttrKind.CX_AttrKind_AVRInterrupt => "AVRInterrupt", - CX_AttrKind.CX_AttrKind_AVRSignal => "AVRSignal", - CX_AttrKind.CX_AttrKind_AcquireCapability => "AcquireCapability", - CX_AttrKind.CX_AttrKind_AcquiredAfter => "AcquiredAfter", - CX_AttrKind.CX_AttrKind_AcquiredBefore => "AcquiredBefore", - CX_AttrKind.CX_AttrKind_AlignMac68k => "AlignMac68k", - CX_AttrKind.CX_AttrKind_Aligned => "Aligned", - CX_AttrKind.CX_AttrKind_AllocAlign => "AllocAlign", - CX_AttrKind.CX_AttrKind_AllocSize => "AllocSize", - CX_AttrKind.CX_AttrKind_AlwaysDestroy => "AlwaysDestroy", - CX_AttrKind.CX_AttrKind_AlwaysInline => "AlwaysInline", - CX_AttrKind.CX_AttrKind_AnalyzerNoReturn => "AnalyzerNoReturn", - CX_AttrKind.CX_AttrKind_AnyX86Interrupt => "AnyX86Interrupt", - CX_AttrKind.CX_AttrKind_AnyX86NoCallerSavedRegisters => "AnyX86NoCallerSavedRegisters", - CX_AttrKind.CX_AttrKind_ArcWeakrefUnavailable => "ArcWeakrefUnavailable", - CX_AttrKind.CX_AttrKind_ArgumentWithTypeTag => "ArgumentWithTypeTag", - CX_AttrKind.CX_AttrKind_ArmBuiltinAlias => "ArmBuiltinAlias", - CX_AttrKind.CX_AttrKind_Artificial => "Artificial", - CX_AttrKind.CX_AttrKind_AsmLabel => "AsmLabel", - CX_AttrKind.CX_AttrKind_AssertCapability => "AssertCapability", - CX_AttrKind.CX_AttrKind_AssertExclusiveLock => "AssertExclusiveLock", - CX_AttrKind.CX_AttrKind_AssertSharedLock => "AssertSharedLock", - CX_AttrKind.CX_AttrKind_AssumeAligned => "AssumeAligned", - CX_AttrKind.CX_AttrKind_Availability => "Availability", - CX_AttrKind.CX_AttrKind_BPFPreserveAccessIndex => "BPFPreserveAccessIndex", - CX_AttrKind.CX_AttrKind_Blocks => "Blocks", - CX_AttrKind.CX_AttrKind_C11NoReturn => "C11NoReturn", - CX_AttrKind.CX_AttrKind_CFAuditedTransfer => "CFAuditedTransfer", - CX_AttrKind.CX_AttrKind_CFGuard => "CFGuard", - CX_AttrKind.CX_AttrKind_CFICanonicalJumpTable => "CFICanonicalJumpTable", - CX_AttrKind.CX_AttrKind_CFReturnsNotRetained => "CFReturnsNotRetained", - CX_AttrKind.CX_AttrKind_CFReturnsRetained => "CFReturnsRetained", - CX_AttrKind.CX_AttrKind_CFUnknownTransfer => "CFUnknownTransfer", - CX_AttrKind.CX_AttrKind_CPUDispatch => "CPUDispatch", - CX_AttrKind.CX_AttrKind_CPUSpecific => "CPUSpecific", - CX_AttrKind.CX_AttrKind_CUDAConstant => "CUDAConstant", - CX_AttrKind.CX_AttrKind_CUDADevice => "CUDADevice", - CX_AttrKind.CX_AttrKind_CUDADeviceBuiltinSurfaceType => "CUDADeviceBuiltinSurfaceType", - CX_AttrKind.CX_AttrKind_CUDADeviceBuiltinTextureType => "CUDADeviceBuiltinTextureType", - CX_AttrKind.CX_AttrKind_CUDAGlobal => "CUDAGlobal", - CX_AttrKind.CX_AttrKind_CUDAHost => "CUDAHost", - CX_AttrKind.CX_AttrKind_CUDAInvalidTarget => "CUDAInvalidTarget", - CX_AttrKind.CX_AttrKind_CUDALaunchBounds => "CUDALaunchBounds", - CX_AttrKind.CX_AttrKind_CUDAShared => "CUDAShared", - CX_AttrKind.CX_AttrKind_CXX11NoReturn => "CXX11NoReturn", - CX_AttrKind.CX_AttrKind_CallableWhen => "CallableWhen", - CX_AttrKind.CX_AttrKind_Callback => "Callback", - CX_AttrKind.CX_AttrKind_Capability => "Capability", - CX_AttrKind.CX_AttrKind_CapturedRecord => "CapturedRecord", - CX_AttrKind.CX_AttrKind_Cleanup => "Cleanup", - CX_AttrKind.CX_AttrKind_CmseNSEntry => "CmseNSEntry", - CX_AttrKind.CX_AttrKind_CodeSeg => "CodeSeg", - CX_AttrKind.CX_AttrKind_Cold => "Cold", - CX_AttrKind.CX_AttrKind_Common => "Common", - CX_AttrKind.CX_AttrKind_Const => "Const", - CX_AttrKind.CX_AttrKind_ConstInit => "ConstInit", - CX_AttrKind.CX_AttrKind_Constructor => "Constructor", - CX_AttrKind.CX_AttrKind_Consumable => "Consumable", - CX_AttrKind.CX_AttrKind_ConsumableAutoCast => "ConsumableAutoCast", - CX_AttrKind.CX_AttrKind_ConsumableSetOnRead => "ConsumableSetOnRead", - CX_AttrKind.CX_AttrKind_Convergent => "Convergent", - CX_AttrKind.CX_AttrKind_DLLExport => "DLLExport", - CX_AttrKind.CX_AttrKind_DLLExportStaticLocal => "DLLExportStaticLocal", - CX_AttrKind.CX_AttrKind_DLLImport => "DLLImport", - CX_AttrKind.CX_AttrKind_DLLImportStaticLocal => "DLLImportStaticLocal", - CX_AttrKind.CX_AttrKind_Deprecated => "Deprecated", - CX_AttrKind.CX_AttrKind_Destructor => "Destructor", - CX_AttrKind.CX_AttrKind_DiagnoseIf => "DiagnoseIf", - CX_AttrKind.CX_AttrKind_DisableTailCalls => "DisableTailCalls", - CX_AttrKind.CX_AttrKind_EmptyBases => "EmptyBases", - CX_AttrKind.CX_AttrKind_EnableIf => "EnableIf", - CX_AttrKind.CX_AttrKind_EnumExtensibility => "EnumExtensibility", - CX_AttrKind.CX_AttrKind_ExcludeFromExplicitInstantiation => "ExcludeFromExplicitInstantiation", - CX_AttrKind.CX_AttrKind_ExclusiveTrylockFunction => "ExclusiveTrylockFunction", - CX_AttrKind.CX_AttrKind_ExternalSourceSymbol => "ExternalSourceSymbol", - CX_AttrKind.CX_AttrKind_Final => "Final", - CX_AttrKind.CX_AttrKind_FlagEnum => "FlagEnum", - CX_AttrKind.CX_AttrKind_Flatten => "Flatten", - CX_AttrKind.CX_AttrKind_Format => "Format", - CX_AttrKind.CX_AttrKind_FormatArg => "FormatArg", - CX_AttrKind.CX_AttrKind_GNUInline => "GNUInline", - CX_AttrKind.CX_AttrKind_GuardedBy => "GuardedBy", - CX_AttrKind.CX_AttrKind_GuardedVar => "GuardedVar", - CX_AttrKind.CX_AttrKind_Hot => "Hot", - CX_AttrKind.CX_AttrKind_IBAction => "IBAction", - CX_AttrKind.CX_AttrKind_IBOutlet => "IBOutlet", - CX_AttrKind.CX_AttrKind_IBOutletCollection => "IBOutletCollection", - CX_AttrKind.CX_AttrKind_InitPriority => "InitPriority", - CX_AttrKind.CX_AttrKind_InternalLinkage => "InternalLinkage", - CX_AttrKind.CX_AttrKind_LTOVisibilityPublic => "LTOVisibilityPublic", - CX_AttrKind.CX_AttrKind_LayoutVersion => "LayoutVersion", - CX_AttrKind.CX_AttrKind_LockReturned => "LockReturned", - CX_AttrKind.CX_AttrKind_LocksExcluded => "LocksExcluded", - CX_AttrKind.CX_AttrKind_MIGServerRoutine => "MIGServerRoutine", - CX_AttrKind.CX_AttrKind_MSAllocator => "MSAllocator", - CX_AttrKind.CX_AttrKind_MSInheritance => "MSInheritance", - CX_AttrKind.CX_AttrKind_MSNoVTable => "MSNoVTable", - CX_AttrKind.CX_AttrKind_MSP430Interrupt => "MSP430Interrupt", - CX_AttrKind.CX_AttrKind_MSStruct => "MSStruct", - CX_AttrKind.CX_AttrKind_MSVtorDisp => "MSVtorDisp", - CX_AttrKind.CX_AttrKind_MaxFieldAlignment => "MaxFieldAlignment", - CX_AttrKind.CX_AttrKind_MayAlias => "MayAlias", - CX_AttrKind.CX_AttrKind_MicroMips => "MicroMips", - CX_AttrKind.CX_AttrKind_MinSize => "MinSize", - CX_AttrKind.CX_AttrKind_MinVectorWidth => "MinVectorWidth", - CX_AttrKind.CX_AttrKind_Mips16 => "Mips16", - CX_AttrKind.CX_AttrKind_MipsInterrupt => "MipsInterrupt", - CX_AttrKind.CX_AttrKind_MipsLongCall => "MipsLongCall", - CX_AttrKind.CX_AttrKind_MipsShortCall => "MipsShortCall", - CX_AttrKind.CX_AttrKind_NSConsumesSelf => "NSConsumesSelf", - CX_AttrKind.CX_AttrKind_NSReturnsAutoreleased => "NSReturnsAutoreleased", - CX_AttrKind.CX_AttrKind_NSReturnsNotRetained => "NSReturnsNotRetained", - CX_AttrKind.CX_AttrKind_Naked => "Naked", - CX_AttrKind.CX_AttrKind_NoAlias => "NoAlias", - CX_AttrKind.CX_AttrKind_NoCommon => "NoCommon", - CX_AttrKind.CX_AttrKind_NoDebug => "NoDebug", - CX_AttrKind.CX_AttrKind_NoDestroy => "NoDestroy", - CX_AttrKind.CX_AttrKind_NoDuplicate => "NoDuplicate", - CX_AttrKind.CX_AttrKind_NoInline => "NoInline", - CX_AttrKind.CX_AttrKind_NoInstrumentFunction => "NoInstrumentFunction", - CX_AttrKind.CX_AttrKind_NoMicroMips => "NoMicroMips", - CX_AttrKind.CX_AttrKind_NoMips16 => "NoMips16", - CX_AttrKind.CX_AttrKind_NoReturn => "NoReturn", - CX_AttrKind.CX_AttrKind_NoSanitize => "NoSanitize", - CX_AttrKind.CX_AttrKind_NoSpeculativeLoadHardening => "NoSpeculativeLoadHardening", - CX_AttrKind.CX_AttrKind_NoSplitStack => "NoSplitStack", - CX_AttrKind.CX_AttrKind_NoStackProtector => "NoStackProtector", - CX_AttrKind.CX_AttrKind_NoThreadSafetyAnalysis => "NoThreadSafetyAnalysis", - CX_AttrKind.CX_AttrKind_NoThrow => "NoThrow", - CX_AttrKind.CX_AttrKind_NoUniqueAddress => "NoUniqueAddress", - CX_AttrKind.CX_AttrKind_NotTailCalled => "NotTailCalled", - CX_AttrKind.CX_AttrKind_OMPAllocateDecl => "OMPAllocateDecl", - CX_AttrKind.CX_AttrKind_OMPCaptureNoInit => "OMPCaptureNoInit", - CX_AttrKind.CX_AttrKind_OMPDeclareTargetDecl => "OMPDeclareTargetDecl", - CX_AttrKind.CX_AttrKind_OMPDeclareVariant => "OMPDeclareVariant", - CX_AttrKind.CX_AttrKind_OMPThreadPrivateDecl => "OMPThreadPrivateDecl", - CX_AttrKind.CX_AttrKind_OSConsumesThis => "OSConsumesThis", - CX_AttrKind.CX_AttrKind_OSReturnsNotRetained => "OSReturnsNotRetained", - CX_AttrKind.CX_AttrKind_OSReturnsRetained => "OSReturnsRetained", - CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnNonZero => "OSReturnsRetainedOnNonZero", - CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnZero => "OSReturnsRetainedOnZero", - CX_AttrKind.CX_AttrKind_ObjCBridge => "ObjCBridge", - CX_AttrKind.CX_AttrKind_ObjCBridgeMutable => "ObjCBridgeMutable", - CX_AttrKind.CX_AttrKind_ObjCBridgeRelated => "ObjCBridgeRelated", - CX_AttrKind.CX_AttrKind_ObjCException => "ObjCException", - CX_AttrKind.CX_AttrKind_ObjCExplicitProtocolImpl => "ObjCExplicitProtocolImpl", - CX_AttrKind.CX_AttrKind_ObjCExternallyRetained => "ObjCExternallyRetained", - CX_AttrKind.CX_AttrKind_ObjCIndependentClass => "ObjCIndependentClass", - CX_AttrKind.CX_AttrKind_ObjCMethodFamily => "ObjCMethodFamily", - CX_AttrKind.CX_AttrKind_ObjCNSObject => "ObjCNSObject", - CX_AttrKind.CX_AttrKind_ObjCPreciseLifetime => "ObjCPreciseLifetime", - CX_AttrKind.CX_AttrKind_ObjCRequiresPropertyDefs => "ObjCRequiresPropertyDefs", - CX_AttrKind.CX_AttrKind_ObjCRequiresSuper => "ObjCRequiresSuper", - CX_AttrKind.CX_AttrKind_ObjCReturnsInnerPointer => "ObjCReturnsInnerPointer", - CX_AttrKind.CX_AttrKind_ObjCRootClass => "ObjCRootClass", - CX_AttrKind.CX_AttrKind_ObjCSubclassingRestricted => "ObjCSubclassingRestricted", - CX_AttrKind.CX_AttrKind_OpenCLIntelReqdSubGroupSize => "OpenCLIntelReqdSubGroupSize", - CX_AttrKind.CX_AttrKind_OpenCLKernel => "OpenCLKernel", - CX_AttrKind.CX_AttrKind_OpenCLUnrollHint => "OpenCLUnrollHint", - CX_AttrKind.CX_AttrKind_OptimizeNone => "OptimizeNone", - CX_AttrKind.CX_AttrKind_Override => "Override", - CX_AttrKind.CX_AttrKind_Owner => "Owner", - CX_AttrKind.CX_AttrKind_Ownership => "Ownership", - CX_AttrKind.CX_AttrKind_Packed => "Packed", - CX_AttrKind.CX_AttrKind_ParamTypestate => "ParamTypestate", - CX_AttrKind.CX_AttrKind_PatchableFunctionEntry => "PatchableFunctionEntry", - CX_AttrKind.CX_AttrKind_Pointer => "Pointer", - CX_AttrKind.CX_AttrKind_PragmaClangBSSSection => "PragmaClangBSSSection", - CX_AttrKind.CX_AttrKind_PragmaClangDataSection => "PragmaClangDataSection", - CX_AttrKind.CX_AttrKind_PragmaClangRelroSection => "PragmaClangRelroSection", - CX_AttrKind.CX_AttrKind_PragmaClangRodataSection => "PragmaClangRodataSection", - CX_AttrKind.CX_AttrKind_PragmaClangTextSection => "PragmaClangTextSection", - CX_AttrKind.CX_AttrKind_PtGuardedBy => "PtGuardedBy", - CX_AttrKind.CX_AttrKind_PtGuardedVar => "PtGuardedVar", - CX_AttrKind.CX_AttrKind_Pure => "Pure", - CX_AttrKind.CX_AttrKind_RISCVInterrupt => "RISCVInterrupt", - CX_AttrKind.CX_AttrKind_Reinitializes => "Reinitializes", - CX_AttrKind.CX_AttrKind_ReleaseCapability => "ReleaseCapability", - CX_AttrKind.CX_AttrKind_ReqdWorkGroupSize => "ReqdWorkGroupSize", - CX_AttrKind.CX_AttrKind_RequiresCapability => "RequiresCapability", - CX_AttrKind.CX_AttrKind_Restrict => "Restrict", - CX_AttrKind.CX_AttrKind_ReturnTypestate => "ReturnTypestate", - CX_AttrKind.CX_AttrKind_ReturnsNonNull => "ReturnsNonNull", - CX_AttrKind.CX_AttrKind_ReturnsTwice => "ReturnsTwice", - CX_AttrKind.CX_AttrKind_SYCLKernel => "SYCLKernel", - CX_AttrKind.CX_AttrKind_ScopedLockable => "ScopedLockable", - CX_AttrKind.CX_AttrKind_Section => "Section", - CX_AttrKind.CX_AttrKind_SelectAny => "SelectAny", - CX_AttrKind.CX_AttrKind_Sentinel => "Sentinel", - CX_AttrKind.CX_AttrKind_SetTypestate => "SetTypestate", - CX_AttrKind.CX_AttrKind_SharedTrylockFunction => "SharedTrylockFunction", - CX_AttrKind.CX_AttrKind_SpeculativeLoadHardening => "SpeculativeLoadHardening", - CX_AttrKind.CX_AttrKind_TLSModel => "TLSModel", - CX_AttrKind.CX_AttrKind_Target => "Target", - CX_AttrKind.CX_AttrKind_TestTypestate => "TestTypestate", - CX_AttrKind.CX_AttrKind_TransparentUnion => "TransparentUnion", - CX_AttrKind.CX_AttrKind_TrivialABI => "TrivialABI", - CX_AttrKind.CX_AttrKind_TryAcquireCapability => "TryAcquireCapability", - CX_AttrKind.CX_AttrKind_TypeTagForDatatype => "TypeTagForDatatype", - CX_AttrKind.CX_AttrKind_TypeVisibility => "TypeVisibility", - CX_AttrKind.CX_AttrKind_Unavailable => "Unavailable", - CX_AttrKind.CX_AttrKind_Uninitialized => "Uninitialized", - CX_AttrKind.CX_AttrKind_Unused => "Unused", - CX_AttrKind.CX_AttrKind_Used => "Used", - CX_AttrKind.CX_AttrKind_Uuid => "Uuid", - CX_AttrKind.CX_AttrKind_VecReturn => "VecReturn", - CX_AttrKind.CX_AttrKind_VecTypeHint => "VecTypeHint", - CX_AttrKind.CX_AttrKind_Visibility => "Visibility", - CX_AttrKind.CX_AttrKind_WarnUnused => "WarnUnused", - CX_AttrKind.CX_AttrKind_WarnUnusedResult => "WarnUnusedResult", - CX_AttrKind.CX_AttrKind_Weak => "Weak", - CX_AttrKind.CX_AttrKind_WeakImport => "WeakImport", - CX_AttrKind.CX_AttrKind_WeakRef => "WeakRef", - CX_AttrKind.CX_AttrKind_WebAssemblyExportName => "WebAssemblyExportName", - CX_AttrKind.CX_AttrKind_WebAssemblyImportModule => "WebAssemblyImportModule", - CX_AttrKind.CX_AttrKind_WebAssemblyImportName => "WebAssemblyImportName", - CX_AttrKind.CX_AttrKind_WorkGroupSizeHint => "WorkGroupSizeHint", - CX_AttrKind.CX_AttrKind_X86ForceAlignArgPointer => "X86ForceAlignArgPointer", - CX_AttrKind.CX_AttrKind_XRayInstrument => "XRayInstrument", - CX_AttrKind.CX_AttrKind_XRayLogArgs => "XRayLogArgs", - CX_AttrKind.CX_AttrKind_AbiTag => "AbiTag", - CX_AttrKind.CX_AttrKind_Alias => "Alias", - CX_AttrKind.CX_AttrKind_AlignValue => "AlignValue", - CX_AttrKind.CX_AttrKind_IFunc => "IFunc", - CX_AttrKind.CX_AttrKind_InitSeg => "InitSeg", - CX_AttrKind.CX_AttrKind_LoaderUninitialized => "LoaderUninitialized", - CX_AttrKind.CX_AttrKind_LoopHint => "LoopHint", - CX_AttrKind.CX_AttrKind_Mode => "Mode", - CX_AttrKind.CX_AttrKind_NoBuiltin => "NoBuiltin", - CX_AttrKind.CX_AttrKind_NoEscape => "NoEscape", - CX_AttrKind.CX_AttrKind_OMPCaptureKind => "OMPCaptureKind", - CX_AttrKind.CX_AttrKind_OMPDeclareSimdDecl => "OMPDeclareSimdDecl", - CX_AttrKind.CX_AttrKind_OMPReferencedVar => "OMPReferencedVar", - CX_AttrKind.CX_AttrKind_ObjCBoxable => "ObjCBoxable", - CX_AttrKind.CX_AttrKind_ObjCClassStub => "ObjCClassStub", - CX_AttrKind.CX_AttrKind_ObjCDesignatedInitializer => "ObjCDesignatedInitializer", - CX_AttrKind.CX_AttrKind_ObjCDirect => "ObjCDirect", - CX_AttrKind.CX_AttrKind_ObjCDirectMembers => "ObjCDirectMembers", - CX_AttrKind.CX_AttrKind_ObjCNonLazyClass => "ObjCNonLazyClass", - CX_AttrKind.CX_AttrKind_ObjCRuntimeName => "ObjCRuntimeName", - CX_AttrKind.CX_AttrKind_ObjCRuntimeVisible => "ObjCRuntimeVisible", - CX_AttrKind.CX_AttrKind_OpenCLAccess => "OpenCLAccess", - CX_AttrKind.CX_AttrKind_Overloadable => "Overloadable", - CX_AttrKind.CX_AttrKind_RenderScriptKernel => "RenderScriptKernel", - CX_AttrKind.CX_AttrKind_Thread => "Thread", - _ => Kind.ToString()[12..], - }; - } + CX_AttrKind.CX_AttrKind_Invalid => "Invalid", + CX_AttrKind.CX_AttrKind_AddressSpace => "AddressSpace", + CX_AttrKind.CX_AttrKind_ArmMveStrictPolymorphism => "ArmMveStrictPolymorphism", + CX_AttrKind.CX_AttrKind_CmseNSCall => "CmseNSCall", + CX_AttrKind.CX_AttrKind_NoDeref => "NoDeref", + CX_AttrKind.CX_AttrKind_ObjCGC => "ObjCGC", + CX_AttrKind.CX_AttrKind_ObjCInertUnsafeUnretained => "ObjCInertUnsafeUnretained", + CX_AttrKind.CX_AttrKind_ObjCKindOf => "ObjCKindOf", + CX_AttrKind.CX_AttrKind_OpenCLConstantAddressSpace => "OpenCLConstantAddressSpace", + CX_AttrKind.CX_AttrKind_OpenCLGenericAddressSpace => "OpenCLGenericAddressSpace", + CX_AttrKind.CX_AttrKind_OpenCLGlobalAddressSpace => "OpenCLGlobalAddressSpace", + CX_AttrKind.CX_AttrKind_OpenCLLocalAddressSpace => "OpenCLLocalAddressSpace", + CX_AttrKind.CX_AttrKind_OpenCLPrivateAddressSpace => "OpenCLPrivateAddressSpace", + CX_AttrKind.CX_AttrKind_Ptr32 => "Ptr32", + CX_AttrKind.CX_AttrKind_Ptr64 => "Ptr64", + CX_AttrKind.CX_AttrKind_SPtr => "SPtr", + CX_AttrKind.CX_AttrKind_TypeNonNull => "TypeNonNull", + CX_AttrKind.CX_AttrKind_TypeNullUnspecified => "TypeNullUnspecified", + CX_AttrKind.CX_AttrKind_TypeNullable => "TypeNullable", + CX_AttrKind.CX_AttrKind_UPtr => "UPtr", + CX_AttrKind.CX_AttrKind_FallThrough => "FallThrough", + CX_AttrKind.CX_AttrKind_NoMerge => "NoMerge", + CX_AttrKind.CX_AttrKind_Suppress => "Suppress", + CX_AttrKind.CX_AttrKind_AArch64VectorPcs => "AArch64VectorPcs", + CX_AttrKind.CX_AttrKind_AcquireHandle => "AcquireHandle", + CX_AttrKind.CX_AttrKind_AnyX86NoCfCheck => "AnyX86NoCfCheck", + CX_AttrKind.CX_AttrKind_CDecl => "CDecl", + CX_AttrKind.CX_AttrKind_FastCall => "FastCall", + CX_AttrKind.CX_AttrKind_IntelOclBicc => "IntelOclBicc", + CX_AttrKind.CX_AttrKind_LifetimeBound => "LifetimeBound", + CX_AttrKind.CX_AttrKind_MSABI => "MSABI", + CX_AttrKind.CX_AttrKind_NSReturnsRetained => "NSReturnsRetained", + CX_AttrKind.CX_AttrKind_ObjCOwnership => "ObjCOwnership", + CX_AttrKind.CX_AttrKind_Pascal => "Pascal", + CX_AttrKind.CX_AttrKind_Pcs => "Pcs", + CX_AttrKind.CX_AttrKind_PreserveAll => "PreserveAll", + CX_AttrKind.CX_AttrKind_PreserveMost => "PreserveMost", + CX_AttrKind.CX_AttrKind_RegCall => "RegCall", + CX_AttrKind.CX_AttrKind_StdCall => "StdCall", + CX_AttrKind.CX_AttrKind_SwiftCall => "SwiftCall", + CX_AttrKind.CX_AttrKind_SysVABI => "SysVABI", + CX_AttrKind.CX_AttrKind_ThisCall => "ThisCall", + CX_AttrKind.CX_AttrKind_VectorCall => "VectorCall", + CX_AttrKind.CX_AttrKind_SwiftContext => "SwiftContext", + CX_AttrKind.CX_AttrKind_SwiftErrorResult => "SwiftErrorResult", + CX_AttrKind.CX_AttrKind_SwiftIndirectResult => "SwiftIndirectResult", + CX_AttrKind.CX_AttrKind_Annotate => "Annotate", + CX_AttrKind.CX_AttrKind_CFConsumed => "CFConsumed", + CX_AttrKind.CX_AttrKind_CarriesDependency => "CarriesDependency", + CX_AttrKind.CX_AttrKind_NSConsumed => "NSConsumed", + CX_AttrKind.CX_AttrKind_NonNull => "NonNull", + CX_AttrKind.CX_AttrKind_OSConsumed => "OSConsumed", + CX_AttrKind.CX_AttrKind_PassObjectSize => "PassObjectSize", + CX_AttrKind.CX_AttrKind_ReleaseHandle => "ReleaseHandle", + CX_AttrKind.CX_AttrKind_UseHandle => "UseHandle", + CX_AttrKind.CX_AttrKind_AMDGPUFlatWorkGroupSize => "AMDGPUFlatWorkGroupSize", + CX_AttrKind.CX_AttrKind_AMDGPUNumSGPR => "AMDGPUNumSGPR", + CX_AttrKind.CX_AttrKind_AMDGPUNumVGPR => "AMDGPUNumVGPR", + CX_AttrKind.CX_AttrKind_AMDGPUWavesPerEU => "AMDGPUWavesPerEU", + CX_AttrKind.CX_AttrKind_ARMInterrupt => "ARMInterrupt", + CX_AttrKind.CX_AttrKind_AVRInterrupt => "AVRInterrupt", + CX_AttrKind.CX_AttrKind_AVRSignal => "AVRSignal", + CX_AttrKind.CX_AttrKind_AcquireCapability => "AcquireCapability", + CX_AttrKind.CX_AttrKind_AcquiredAfter => "AcquiredAfter", + CX_AttrKind.CX_AttrKind_AcquiredBefore => "AcquiredBefore", + CX_AttrKind.CX_AttrKind_AlignMac68k => "AlignMac68k", + CX_AttrKind.CX_AttrKind_Aligned => "Aligned", + CX_AttrKind.CX_AttrKind_AllocAlign => "AllocAlign", + CX_AttrKind.CX_AttrKind_AllocSize => "AllocSize", + CX_AttrKind.CX_AttrKind_AlwaysDestroy => "AlwaysDestroy", + CX_AttrKind.CX_AttrKind_AlwaysInline => "AlwaysInline", + CX_AttrKind.CX_AttrKind_AnalyzerNoReturn => "AnalyzerNoReturn", + CX_AttrKind.CX_AttrKind_AnyX86Interrupt => "AnyX86Interrupt", + CX_AttrKind.CX_AttrKind_AnyX86NoCallerSavedRegisters => "AnyX86NoCallerSavedRegisters", + CX_AttrKind.CX_AttrKind_ArcWeakrefUnavailable => "ArcWeakrefUnavailable", + CX_AttrKind.CX_AttrKind_ArgumentWithTypeTag => "ArgumentWithTypeTag", + CX_AttrKind.CX_AttrKind_ArmBuiltinAlias => "ArmBuiltinAlias", + CX_AttrKind.CX_AttrKind_Artificial => "Artificial", + CX_AttrKind.CX_AttrKind_AsmLabel => "AsmLabel", + CX_AttrKind.CX_AttrKind_AssertCapability => "AssertCapability", + CX_AttrKind.CX_AttrKind_AssertExclusiveLock => "AssertExclusiveLock", + CX_AttrKind.CX_AttrKind_AssertSharedLock => "AssertSharedLock", + CX_AttrKind.CX_AttrKind_AssumeAligned => "AssumeAligned", + CX_AttrKind.CX_AttrKind_Availability => "Availability", + CX_AttrKind.CX_AttrKind_BPFPreserveAccessIndex => "BPFPreserveAccessIndex", + CX_AttrKind.CX_AttrKind_Blocks => "Blocks", + CX_AttrKind.CX_AttrKind_C11NoReturn => "C11NoReturn", + CX_AttrKind.CX_AttrKind_CFAuditedTransfer => "CFAuditedTransfer", + CX_AttrKind.CX_AttrKind_CFGuard => "CFGuard", + CX_AttrKind.CX_AttrKind_CFICanonicalJumpTable => "CFICanonicalJumpTable", + CX_AttrKind.CX_AttrKind_CFReturnsNotRetained => "CFReturnsNotRetained", + CX_AttrKind.CX_AttrKind_CFReturnsRetained => "CFReturnsRetained", + CX_AttrKind.CX_AttrKind_CFUnknownTransfer => "CFUnknownTransfer", + CX_AttrKind.CX_AttrKind_CPUDispatch => "CPUDispatch", + CX_AttrKind.CX_AttrKind_CPUSpecific => "CPUSpecific", + CX_AttrKind.CX_AttrKind_CUDAConstant => "CUDAConstant", + CX_AttrKind.CX_AttrKind_CUDADevice => "CUDADevice", + CX_AttrKind.CX_AttrKind_CUDADeviceBuiltinSurfaceType => "CUDADeviceBuiltinSurfaceType", + CX_AttrKind.CX_AttrKind_CUDADeviceBuiltinTextureType => "CUDADeviceBuiltinTextureType", + CX_AttrKind.CX_AttrKind_CUDAGlobal => "CUDAGlobal", + CX_AttrKind.CX_AttrKind_CUDAHost => "CUDAHost", + CX_AttrKind.CX_AttrKind_CUDAInvalidTarget => "CUDAInvalidTarget", + CX_AttrKind.CX_AttrKind_CUDALaunchBounds => "CUDALaunchBounds", + CX_AttrKind.CX_AttrKind_CUDAShared => "CUDAShared", + CX_AttrKind.CX_AttrKind_CXX11NoReturn => "CXX11NoReturn", + CX_AttrKind.CX_AttrKind_CallableWhen => "CallableWhen", + CX_AttrKind.CX_AttrKind_Callback => "Callback", + CX_AttrKind.CX_AttrKind_Capability => "Capability", + CX_AttrKind.CX_AttrKind_CapturedRecord => "CapturedRecord", + CX_AttrKind.CX_AttrKind_Cleanup => "Cleanup", + CX_AttrKind.CX_AttrKind_CmseNSEntry => "CmseNSEntry", + CX_AttrKind.CX_AttrKind_CodeSeg => "CodeSeg", + CX_AttrKind.CX_AttrKind_Cold => "Cold", + CX_AttrKind.CX_AttrKind_Common => "Common", + CX_AttrKind.CX_AttrKind_Const => "Const", + CX_AttrKind.CX_AttrKind_ConstInit => "ConstInit", + CX_AttrKind.CX_AttrKind_Constructor => "Constructor", + CX_AttrKind.CX_AttrKind_Consumable => "Consumable", + CX_AttrKind.CX_AttrKind_ConsumableAutoCast => "ConsumableAutoCast", + CX_AttrKind.CX_AttrKind_ConsumableSetOnRead => "ConsumableSetOnRead", + CX_AttrKind.CX_AttrKind_Convergent => "Convergent", + CX_AttrKind.CX_AttrKind_DLLExport => "DLLExport", + CX_AttrKind.CX_AttrKind_DLLExportStaticLocal => "DLLExportStaticLocal", + CX_AttrKind.CX_AttrKind_DLLImport => "DLLImport", + CX_AttrKind.CX_AttrKind_DLLImportStaticLocal => "DLLImportStaticLocal", + CX_AttrKind.CX_AttrKind_Deprecated => "Deprecated", + CX_AttrKind.CX_AttrKind_Destructor => "Destructor", + CX_AttrKind.CX_AttrKind_DiagnoseIf => "DiagnoseIf", + CX_AttrKind.CX_AttrKind_DisableTailCalls => "DisableTailCalls", + CX_AttrKind.CX_AttrKind_EmptyBases => "EmptyBases", + CX_AttrKind.CX_AttrKind_EnableIf => "EnableIf", + CX_AttrKind.CX_AttrKind_EnumExtensibility => "EnumExtensibility", + CX_AttrKind.CX_AttrKind_ExcludeFromExplicitInstantiation => "ExcludeFromExplicitInstantiation", + CX_AttrKind.CX_AttrKind_ExclusiveTrylockFunction => "ExclusiveTrylockFunction", + CX_AttrKind.CX_AttrKind_ExternalSourceSymbol => "ExternalSourceSymbol", + CX_AttrKind.CX_AttrKind_Final => "Final", + CX_AttrKind.CX_AttrKind_FlagEnum => "FlagEnum", + CX_AttrKind.CX_AttrKind_Flatten => "Flatten", + CX_AttrKind.CX_AttrKind_Format => "Format", + CX_AttrKind.CX_AttrKind_FormatArg => "FormatArg", + CX_AttrKind.CX_AttrKind_GNUInline => "GNUInline", + CX_AttrKind.CX_AttrKind_GuardedBy => "GuardedBy", + CX_AttrKind.CX_AttrKind_GuardedVar => "GuardedVar", + CX_AttrKind.CX_AttrKind_Hot => "Hot", + CX_AttrKind.CX_AttrKind_IBAction => "IBAction", + CX_AttrKind.CX_AttrKind_IBOutlet => "IBOutlet", + CX_AttrKind.CX_AttrKind_IBOutletCollection => "IBOutletCollection", + CX_AttrKind.CX_AttrKind_InitPriority => "InitPriority", + CX_AttrKind.CX_AttrKind_InternalLinkage => "InternalLinkage", + CX_AttrKind.CX_AttrKind_LTOVisibilityPublic => "LTOVisibilityPublic", + CX_AttrKind.CX_AttrKind_LayoutVersion => "LayoutVersion", + CX_AttrKind.CX_AttrKind_LockReturned => "LockReturned", + CX_AttrKind.CX_AttrKind_LocksExcluded => "LocksExcluded", + CX_AttrKind.CX_AttrKind_MIGServerRoutine => "MIGServerRoutine", + CX_AttrKind.CX_AttrKind_MSAllocator => "MSAllocator", + CX_AttrKind.CX_AttrKind_MSInheritance => "MSInheritance", + CX_AttrKind.CX_AttrKind_MSNoVTable => "MSNoVTable", + CX_AttrKind.CX_AttrKind_MSP430Interrupt => "MSP430Interrupt", + CX_AttrKind.CX_AttrKind_MSStruct => "MSStruct", + CX_AttrKind.CX_AttrKind_MSVtorDisp => "MSVtorDisp", + CX_AttrKind.CX_AttrKind_MaxFieldAlignment => "MaxFieldAlignment", + CX_AttrKind.CX_AttrKind_MayAlias => "MayAlias", + CX_AttrKind.CX_AttrKind_MicroMips => "MicroMips", + CX_AttrKind.CX_AttrKind_MinSize => "MinSize", + CX_AttrKind.CX_AttrKind_MinVectorWidth => "MinVectorWidth", + CX_AttrKind.CX_AttrKind_Mips16 => "Mips16", + CX_AttrKind.CX_AttrKind_MipsInterrupt => "MipsInterrupt", + CX_AttrKind.CX_AttrKind_MipsLongCall => "MipsLongCall", + CX_AttrKind.CX_AttrKind_MipsShortCall => "MipsShortCall", + CX_AttrKind.CX_AttrKind_NSConsumesSelf => "NSConsumesSelf", + CX_AttrKind.CX_AttrKind_NSReturnsAutoreleased => "NSReturnsAutoreleased", + CX_AttrKind.CX_AttrKind_NSReturnsNotRetained => "NSReturnsNotRetained", + CX_AttrKind.CX_AttrKind_Naked => "Naked", + CX_AttrKind.CX_AttrKind_NoAlias => "NoAlias", + CX_AttrKind.CX_AttrKind_NoCommon => "NoCommon", + CX_AttrKind.CX_AttrKind_NoDebug => "NoDebug", + CX_AttrKind.CX_AttrKind_NoDestroy => "NoDestroy", + CX_AttrKind.CX_AttrKind_NoDuplicate => "NoDuplicate", + CX_AttrKind.CX_AttrKind_NoInline => "NoInline", + CX_AttrKind.CX_AttrKind_NoInstrumentFunction => "NoInstrumentFunction", + CX_AttrKind.CX_AttrKind_NoMicroMips => "NoMicroMips", + CX_AttrKind.CX_AttrKind_NoMips16 => "NoMips16", + CX_AttrKind.CX_AttrKind_NoReturn => "NoReturn", + CX_AttrKind.CX_AttrKind_NoSanitize => "NoSanitize", + CX_AttrKind.CX_AttrKind_NoSpeculativeLoadHardening => "NoSpeculativeLoadHardening", + CX_AttrKind.CX_AttrKind_NoSplitStack => "NoSplitStack", + CX_AttrKind.CX_AttrKind_NoStackProtector => "NoStackProtector", + CX_AttrKind.CX_AttrKind_NoThreadSafetyAnalysis => "NoThreadSafetyAnalysis", + CX_AttrKind.CX_AttrKind_NoThrow => "NoThrow", + CX_AttrKind.CX_AttrKind_NoUniqueAddress => "NoUniqueAddress", + CX_AttrKind.CX_AttrKind_NotTailCalled => "NotTailCalled", + CX_AttrKind.CX_AttrKind_OMPAllocateDecl => "OMPAllocateDecl", + CX_AttrKind.CX_AttrKind_OMPCaptureNoInit => "OMPCaptureNoInit", + CX_AttrKind.CX_AttrKind_OMPDeclareTargetDecl => "OMPDeclareTargetDecl", + CX_AttrKind.CX_AttrKind_OMPDeclareVariant => "OMPDeclareVariant", + CX_AttrKind.CX_AttrKind_OMPThreadPrivateDecl => "OMPThreadPrivateDecl", + CX_AttrKind.CX_AttrKind_OSConsumesThis => "OSConsumesThis", + CX_AttrKind.CX_AttrKind_OSReturnsNotRetained => "OSReturnsNotRetained", + CX_AttrKind.CX_AttrKind_OSReturnsRetained => "OSReturnsRetained", + CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnNonZero => "OSReturnsRetainedOnNonZero", + CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnZero => "OSReturnsRetainedOnZero", + CX_AttrKind.CX_AttrKind_ObjCBridge => "ObjCBridge", + CX_AttrKind.CX_AttrKind_ObjCBridgeMutable => "ObjCBridgeMutable", + CX_AttrKind.CX_AttrKind_ObjCBridgeRelated => "ObjCBridgeRelated", + CX_AttrKind.CX_AttrKind_ObjCException => "ObjCException", + CX_AttrKind.CX_AttrKind_ObjCExplicitProtocolImpl => "ObjCExplicitProtocolImpl", + CX_AttrKind.CX_AttrKind_ObjCExternallyRetained => "ObjCExternallyRetained", + CX_AttrKind.CX_AttrKind_ObjCIndependentClass => "ObjCIndependentClass", + CX_AttrKind.CX_AttrKind_ObjCMethodFamily => "ObjCMethodFamily", + CX_AttrKind.CX_AttrKind_ObjCNSObject => "ObjCNSObject", + CX_AttrKind.CX_AttrKind_ObjCPreciseLifetime => "ObjCPreciseLifetime", + CX_AttrKind.CX_AttrKind_ObjCRequiresPropertyDefs => "ObjCRequiresPropertyDefs", + CX_AttrKind.CX_AttrKind_ObjCRequiresSuper => "ObjCRequiresSuper", + CX_AttrKind.CX_AttrKind_ObjCReturnsInnerPointer => "ObjCReturnsInnerPointer", + CX_AttrKind.CX_AttrKind_ObjCRootClass => "ObjCRootClass", + CX_AttrKind.CX_AttrKind_ObjCSubclassingRestricted => "ObjCSubclassingRestricted", + CX_AttrKind.CX_AttrKind_OpenCLIntelReqdSubGroupSize => "OpenCLIntelReqdSubGroupSize", + CX_AttrKind.CX_AttrKind_OpenCLKernel => "OpenCLKernel", + CX_AttrKind.CX_AttrKind_OpenCLUnrollHint => "OpenCLUnrollHint", + CX_AttrKind.CX_AttrKind_OptimizeNone => "OptimizeNone", + CX_AttrKind.CX_AttrKind_Override => "Override", + CX_AttrKind.CX_AttrKind_Owner => "Owner", + CX_AttrKind.CX_AttrKind_Ownership => "Ownership", + CX_AttrKind.CX_AttrKind_Packed => "Packed", + CX_AttrKind.CX_AttrKind_ParamTypestate => "ParamTypestate", + CX_AttrKind.CX_AttrKind_PatchableFunctionEntry => "PatchableFunctionEntry", + CX_AttrKind.CX_AttrKind_Pointer => "Pointer", + CX_AttrKind.CX_AttrKind_PragmaClangBSSSection => "PragmaClangBSSSection", + CX_AttrKind.CX_AttrKind_PragmaClangDataSection => "PragmaClangDataSection", + CX_AttrKind.CX_AttrKind_PragmaClangRelroSection => "PragmaClangRelroSection", + CX_AttrKind.CX_AttrKind_PragmaClangRodataSection => "PragmaClangRodataSection", + CX_AttrKind.CX_AttrKind_PragmaClangTextSection => "PragmaClangTextSection", + CX_AttrKind.CX_AttrKind_PtGuardedBy => "PtGuardedBy", + CX_AttrKind.CX_AttrKind_PtGuardedVar => "PtGuardedVar", + CX_AttrKind.CX_AttrKind_Pure => "Pure", + CX_AttrKind.CX_AttrKind_RISCVInterrupt => "RISCVInterrupt", + CX_AttrKind.CX_AttrKind_Reinitializes => "Reinitializes", + CX_AttrKind.CX_AttrKind_ReleaseCapability => "ReleaseCapability", + CX_AttrKind.CX_AttrKind_ReqdWorkGroupSize => "ReqdWorkGroupSize", + CX_AttrKind.CX_AttrKind_RequiresCapability => "RequiresCapability", + CX_AttrKind.CX_AttrKind_Restrict => "Restrict", + CX_AttrKind.CX_AttrKind_ReturnTypestate => "ReturnTypestate", + CX_AttrKind.CX_AttrKind_ReturnsNonNull => "ReturnsNonNull", + CX_AttrKind.CX_AttrKind_ReturnsTwice => "ReturnsTwice", + CX_AttrKind.CX_AttrKind_SYCLKernel => "SYCLKernel", + CX_AttrKind.CX_AttrKind_ScopedLockable => "ScopedLockable", + CX_AttrKind.CX_AttrKind_Section => "Section", + CX_AttrKind.CX_AttrKind_SelectAny => "SelectAny", + CX_AttrKind.CX_AttrKind_Sentinel => "Sentinel", + CX_AttrKind.CX_AttrKind_SetTypestate => "SetTypestate", + CX_AttrKind.CX_AttrKind_SharedTrylockFunction => "SharedTrylockFunction", + CX_AttrKind.CX_AttrKind_SpeculativeLoadHardening => "SpeculativeLoadHardening", + CX_AttrKind.CX_AttrKind_TLSModel => "TLSModel", + CX_AttrKind.CX_AttrKind_Target => "Target", + CX_AttrKind.CX_AttrKind_TestTypestate => "TestTypestate", + CX_AttrKind.CX_AttrKind_TransparentUnion => "TransparentUnion", + CX_AttrKind.CX_AttrKind_TrivialABI => "TrivialABI", + CX_AttrKind.CX_AttrKind_TryAcquireCapability => "TryAcquireCapability", + CX_AttrKind.CX_AttrKind_TypeTagForDatatype => "TypeTagForDatatype", + CX_AttrKind.CX_AttrKind_TypeVisibility => "TypeVisibility", + CX_AttrKind.CX_AttrKind_Unavailable => "Unavailable", + CX_AttrKind.CX_AttrKind_Uninitialized => "Uninitialized", + CX_AttrKind.CX_AttrKind_Unused => "Unused", + CX_AttrKind.CX_AttrKind_Used => "Used", + CX_AttrKind.CX_AttrKind_Uuid => "Uuid", + CX_AttrKind.CX_AttrKind_VecReturn => "VecReturn", + CX_AttrKind.CX_AttrKind_VecTypeHint => "VecTypeHint", + CX_AttrKind.CX_AttrKind_Visibility => "Visibility", + CX_AttrKind.CX_AttrKind_WarnUnused => "WarnUnused", + CX_AttrKind.CX_AttrKind_WarnUnusedResult => "WarnUnusedResult", + CX_AttrKind.CX_AttrKind_Weak => "Weak", + CX_AttrKind.CX_AttrKind_WeakImport => "WeakImport", + CX_AttrKind.CX_AttrKind_WeakRef => "WeakRef", + CX_AttrKind.CX_AttrKind_WebAssemblyExportName => "WebAssemblyExportName", + CX_AttrKind.CX_AttrKind_WebAssemblyImportModule => "WebAssemblyImportModule", + CX_AttrKind.CX_AttrKind_WebAssemblyImportName => "WebAssemblyImportName", + CX_AttrKind.CX_AttrKind_WorkGroupSizeHint => "WorkGroupSizeHint", + CX_AttrKind.CX_AttrKind_X86ForceAlignArgPointer => "X86ForceAlignArgPointer", + CX_AttrKind.CX_AttrKind_XRayInstrument => "XRayInstrument", + CX_AttrKind.CX_AttrKind_XRayLogArgs => "XRayLogArgs", + CX_AttrKind.CX_AttrKind_AbiTag => "AbiTag", + CX_AttrKind.CX_AttrKind_Alias => "Alias", + CX_AttrKind.CX_AttrKind_AlignValue => "AlignValue", + CX_AttrKind.CX_AttrKind_IFunc => "IFunc", + CX_AttrKind.CX_AttrKind_InitSeg => "InitSeg", + CX_AttrKind.CX_AttrKind_LoaderUninitialized => "LoaderUninitialized", + CX_AttrKind.CX_AttrKind_LoopHint => "LoopHint", + CX_AttrKind.CX_AttrKind_Mode => "Mode", + CX_AttrKind.CX_AttrKind_NoBuiltin => "NoBuiltin", + CX_AttrKind.CX_AttrKind_NoEscape => "NoEscape", + CX_AttrKind.CX_AttrKind_OMPCaptureKind => "OMPCaptureKind", + CX_AttrKind.CX_AttrKind_OMPDeclareSimdDecl => "OMPDeclareSimdDecl", + CX_AttrKind.CX_AttrKind_OMPReferencedVar => "OMPReferencedVar", + CX_AttrKind.CX_AttrKind_ObjCBoxable => "ObjCBoxable", + CX_AttrKind.CX_AttrKind_ObjCClassStub => "ObjCClassStub", + CX_AttrKind.CX_AttrKind_ObjCDesignatedInitializer => "ObjCDesignatedInitializer", + CX_AttrKind.CX_AttrKind_ObjCDirect => "ObjCDirect", + CX_AttrKind.CX_AttrKind_ObjCDirectMembers => "ObjCDirectMembers", + CX_AttrKind.CX_AttrKind_ObjCNonLazyClass => "ObjCNonLazyClass", + CX_AttrKind.CX_AttrKind_ObjCRuntimeName => "ObjCRuntimeName", + CX_AttrKind.CX_AttrKind_ObjCRuntimeVisible => "ObjCRuntimeVisible", + CX_AttrKind.CX_AttrKind_OpenCLAccess => "OpenCLAccess", + CX_AttrKind.CX_AttrKind_Overloadable => "Overloadable", + CX_AttrKind.CX_AttrKind_RenderScriptKernel => "RenderScriptKernel", + CX_AttrKind.CX_AttrKind_Thread => "Thread", + _ => Kind.ToString()[12..], + }; } + } - public CXAvailabilityKind Availability => clang.getCursorAvailability(this); + public CXAvailabilityKind Availability => clang.getCursorAvailability(this); - public CX_BinaryOperatorKind BinaryOperatorKind => clangsharp.Cursor_getBinaryOpcode(this); + public CX_BinaryOperatorKind BinaryOperatorKind => clangsharp.Cursor_getBinaryOpcode(this); - public CXString BinaryOperatorKindSpelling => clangsharp.Cursor_getBinaryOpcodeSpelling(BinaryOperatorKind); + public CXString BinaryOperatorKindSpelling => clangsharp.Cursor_getBinaryOpcodeSpelling(BinaryOperatorKind); - public CXCursor BindingExpr => clangsharp.Cursor_getBindingExpr(this); + public CXCursor BindingExpr => clangsharp.Cursor_getBindingExpr(this); - public CXCursor BitWidth => clangsharp.Cursor_getBitWidth(this); + public CXCursor BitWidth => clangsharp.Cursor_getBitWidth(this); - public CXCursor BlockManglingContextDecl => clangsharp.Cursor_getBlockManglingContextDecl(this); + public CXCursor BlockManglingContextDecl => clangsharp.Cursor_getBlockManglingContextDecl(this); - public int BlockManglingNumber => clangsharp.Cursor_getBlockManglingNumber(this); + public int BlockManglingNumber => clangsharp.Cursor_getBlockManglingNumber(this); - public bool BlockMissingReturnType => clangsharp.Cursor_getBlockMissingReturnType(this) != 0; + public bool BlockMissingReturnType => clangsharp.Cursor_getBlockMissingReturnType(this) != 0; - public CXCursor Body => clangsharp.Cursor_getBody(this); + public CXCursor Body => clangsharp.Cursor_getBody(this); - public CXString BriefCommentText => clang.Cursor_getBriefCommentText(this); + public CXString BriefCommentText => clang.Cursor_getBriefCommentText(this); - public CXType CallResultType => clangsharp.Cursor_getCallResultType(this); + public CXType CallResultType => clangsharp.Cursor_getCallResultType(this); - public bool CanAvoidCopyToHeap => clangsharp.Cursor_getCanAvoidCopyToHeap(this) != 0; + public bool CanAvoidCopyToHeap => clangsharp.Cursor_getCanAvoidCopyToHeap(this) != 0; - public CXCursor CanonicalCursor => clangsharp.Cursor_getCanonical(this); + public CXCursor CanonicalCursor => clangsharp.Cursor_getCanonical(this); - public CXCursor CapturedDecl => clangsharp.Cursor_getCapturedDecl(this); + public CXCursor CapturedDecl => clangsharp.Cursor_getCapturedDecl(this); - public CXCursor CapturedRecordDecl => clangsharp.Cursor_getCapturedRecordDecl(this); + public CXCursor CapturedRecordDecl => clangsharp.Cursor_getCapturedRecordDecl(this); - public CX_CapturedRegionKind CapturedRegionKind => clangsharp.Cursor_getCapturedRegionKind(this); + public CX_CapturedRegionKind CapturedRegionKind => clangsharp.Cursor_getCapturedRegionKind(this); - public CXCursor CapturedStmt => clangsharp.Cursor_getCapturedStmt(this); + public CXCursor CapturedStmt => clangsharp.Cursor_getCapturedStmt(this); - public bool CapturesCXXThis => clangsharp.Cursor_getCapturesCXXThis(this) != 0; + public bool CapturesCXXThis => clangsharp.Cursor_getCapturesCXXThis(this) != 0; - public CX_CastKind CastKind => clangsharp.Cursor_getCastKind(this); + public CX_CastKind CastKind => clangsharp.Cursor_getCastKind(this); - public string CastKindSpelling + public string CastKindSpelling + { + get { - get + return CastKind switch { - return CastKind switch - { - CX_CastKind.CX_CK_Invalid => "Invalid", - CX_CastKind.CX_CK_Dependent => "Dependent", - CX_CastKind.CX_CK_BitCast => "BitCast", - CX_CastKind.CX_CK_LValueBitCast => "LValueBitCast", - CX_CastKind.CX_CK_LValueToRValueBitCast => "LValueToRValueBitCast", - CX_CastKind.CX_CK_LValueToRValue => "LValueToRValue", - CX_CastKind.CX_CK_NoOp => "NoOp", - CX_CastKind.CX_CK_BaseToDerived => "BaseToDerived", - CX_CastKind.CX_CK_DerivedToBase => "DerivedToBase", - CX_CastKind.CX_CK_UncheckedDerivedToBase => "UncheckedDerivedToBase", - CX_CastKind.CX_CK_Dynamic => "Dynamic", - CX_CastKind.CX_CK_ToUnion => "ToUnion", - CX_CastKind.CX_CK_ArrayToPointerDecay => "ArrayToPointerDecay", - CX_CastKind.CX_CK_FunctionToPointerDecay => "FunctionToPointerDecay", - CX_CastKind.CX_CK_NullToPointer => "NullToPointer", - CX_CastKind.CX_CK_NullToMemberPointer => "NullToMemberPointer", - CX_CastKind.CX_CK_BaseToDerivedMemberPointer => "BaseToDerivedMemberPointer", - CX_CastKind.CX_CK_DerivedToBaseMemberPointer => "DerivedToBaseMemberPointer", - CX_CastKind.CX_CK_MemberPointerToBoolean => "MemberPointerToBoolean", - CX_CastKind.CX_CK_ReinterpretMemberPointer => "ReinterpretMemberPointer", - CX_CastKind.CX_CK_UserDefinedConversion => "UserDefinedConversion", - CX_CastKind.CX_CK_ConstructorConversion => "ConstructorConversion", - CX_CastKind.CX_CK_IntegralToPointer => "IntegralToPointer", - CX_CastKind.CX_CK_PointerToIntegral => "PointerToIntegral", - CX_CastKind.CX_CK_PointerToBoolean => "PointerToBoolean", - CX_CastKind.CX_CK_ToVoid => "ToVoid", - CX_CastKind.CX_CK_MatrixCast => "MatrixCast", - CX_CastKind.CX_CK_VectorSplat => "VectorSplat", - CX_CastKind.CX_CK_IntegralCast => "IntegralCast", - CX_CastKind.CX_CK_IntegralToBoolean => "IntegralToBoolean", - CX_CastKind.CX_CK_IntegralToFloating => "IntegralToFloating", - CX_CastKind.CX_CK_FixedPointCast => "FixedPointCast", - CX_CastKind.CX_CK_FixedPointToIntegral => "FixedPointToIntegral", - CX_CastKind.CX_CK_IntegralToFixedPoint => "IntegralToFixedPoint", - CX_CastKind.CX_CK_FixedPointToBoolean => "FixedPointToBoolean", - CX_CastKind.CX_CK_FloatingToIntegral => "FloatingToIntegral", - CX_CastKind.CX_CK_FloatingToBoolean => "FloatingToBoolean", - CX_CastKind.CX_CK_BooleanToSignedIntegral => "BooleanToSignedIntegral", - CX_CastKind.CX_CK_FloatingCast => "FloatingCast", - CX_CastKind.CX_CK_CPointerToObjCPointerCast => "CPointerToObjCPointerCast", - CX_CastKind.CX_CK_BlockPointerToObjCPointerCast => "BlockPointerToObjCPointerCast", - CX_CastKind.CX_CK_AnyPointerToBlockPointerCast => "AnyPointerToBlockPointerCast", - CX_CastKind.CX_CK_ObjCObjectLValueCast => "ObjCObjectLValueCast", - CX_CastKind.CX_CK_FloatingRealToComplex => "FloatingRealToComplex", - CX_CastKind.CX_CK_FloatingComplexToReal => "FloatingComplexToReal", - CX_CastKind.CX_CK_FloatingComplexToBoolean => "FloatingComplexToBoolean", - CX_CastKind.CX_CK_FloatingComplexCast => "FloatingComplexCast", - CX_CastKind.CX_CK_FloatingComplexToIntegralComplex => "FloatingComplexToIntegralComplex", - CX_CastKind.CX_CK_IntegralRealToComplex => "IntegralRealToComplex", - CX_CastKind.CX_CK_IntegralComplexToReal => "IntegralComplexToReal", - CX_CastKind.CX_CK_IntegralComplexToBoolean => "IntegralComplexToBoolean", - CX_CastKind.CX_CK_IntegralComplexCast => "IntegralComplexCast", - CX_CastKind.CX_CK_IntegralComplexToFloatingComplex => "IntegralComplexToFloatingComplex", - CX_CastKind.CX_CK_ARCProduceObject => "ARCProduceObject", - CX_CastKind.CX_CK_ARCConsumeObject => "ARCConsumeObject", - CX_CastKind.CX_CK_ARCReclaimReturnedObject => "ARCReclaimReturnedObject", - CX_CastKind.CX_CK_ARCExtendBlockObject => "ARCExtendBlockObject", - CX_CastKind.CX_CK_AtomicToNonAtomic => "AtomicToNonAtomic", - CX_CastKind.CX_CK_NonAtomicToAtomic => "NonAtomicToAtomic", - CX_CastKind.CX_CK_CopyAndAutoreleaseBlockObject => "CopyAndAutoreleaseBlockObject", - CX_CastKind.CX_CK_BuiltinFnToFnPtr => "BuiltinFnToFnPtr", - CX_CastKind.CX_CK_ZeroToOCLOpaqueType => "ZeroToOCLOpaqueType", - CX_CastKind.CX_CK_AddressSpaceConversion => "AddressSpaceConversion", - CX_CastKind.CX_CK_IntToOCLSampler => "IntToOCLSampler", - _ => CastKind.ToString()[6..], - }; - } + CX_CastKind.CX_CK_Invalid => "Invalid", + CX_CastKind.CX_CK_Dependent => "Dependent", + CX_CastKind.CX_CK_BitCast => "BitCast", + CX_CastKind.CX_CK_LValueBitCast => "LValueBitCast", + CX_CastKind.CX_CK_LValueToRValueBitCast => "LValueToRValueBitCast", + CX_CastKind.CX_CK_LValueToRValue => "LValueToRValue", + CX_CastKind.CX_CK_NoOp => "NoOp", + CX_CastKind.CX_CK_BaseToDerived => "BaseToDerived", + CX_CastKind.CX_CK_DerivedToBase => "DerivedToBase", + CX_CastKind.CX_CK_UncheckedDerivedToBase => "UncheckedDerivedToBase", + CX_CastKind.CX_CK_Dynamic => "Dynamic", + CX_CastKind.CX_CK_ToUnion => "ToUnion", + CX_CastKind.CX_CK_ArrayToPointerDecay => "ArrayToPointerDecay", + CX_CastKind.CX_CK_FunctionToPointerDecay => "FunctionToPointerDecay", + CX_CastKind.CX_CK_NullToPointer => "NullToPointer", + CX_CastKind.CX_CK_NullToMemberPointer => "NullToMemberPointer", + CX_CastKind.CX_CK_BaseToDerivedMemberPointer => "BaseToDerivedMemberPointer", + CX_CastKind.CX_CK_DerivedToBaseMemberPointer => "DerivedToBaseMemberPointer", + CX_CastKind.CX_CK_MemberPointerToBoolean => "MemberPointerToBoolean", + CX_CastKind.CX_CK_ReinterpretMemberPointer => "ReinterpretMemberPointer", + CX_CastKind.CX_CK_UserDefinedConversion => "UserDefinedConversion", + CX_CastKind.CX_CK_ConstructorConversion => "ConstructorConversion", + CX_CastKind.CX_CK_IntegralToPointer => "IntegralToPointer", + CX_CastKind.CX_CK_PointerToIntegral => "PointerToIntegral", + CX_CastKind.CX_CK_PointerToBoolean => "PointerToBoolean", + CX_CastKind.CX_CK_ToVoid => "ToVoid", + CX_CastKind.CX_CK_MatrixCast => "MatrixCast", + CX_CastKind.CX_CK_VectorSplat => "VectorSplat", + CX_CastKind.CX_CK_IntegralCast => "IntegralCast", + CX_CastKind.CX_CK_IntegralToBoolean => "IntegralToBoolean", + CX_CastKind.CX_CK_IntegralToFloating => "IntegralToFloating", + CX_CastKind.CX_CK_FixedPointCast => "FixedPointCast", + CX_CastKind.CX_CK_FixedPointToIntegral => "FixedPointToIntegral", + CX_CastKind.CX_CK_IntegralToFixedPoint => "IntegralToFixedPoint", + CX_CastKind.CX_CK_FixedPointToBoolean => "FixedPointToBoolean", + CX_CastKind.CX_CK_FloatingToIntegral => "FloatingToIntegral", + CX_CastKind.CX_CK_FloatingToBoolean => "FloatingToBoolean", + CX_CastKind.CX_CK_BooleanToSignedIntegral => "BooleanToSignedIntegral", + CX_CastKind.CX_CK_FloatingCast => "FloatingCast", + CX_CastKind.CX_CK_CPointerToObjCPointerCast => "CPointerToObjCPointerCast", + CX_CastKind.CX_CK_BlockPointerToObjCPointerCast => "BlockPointerToObjCPointerCast", + CX_CastKind.CX_CK_AnyPointerToBlockPointerCast => "AnyPointerToBlockPointerCast", + CX_CastKind.CX_CK_ObjCObjectLValueCast => "ObjCObjectLValueCast", + CX_CastKind.CX_CK_FloatingRealToComplex => "FloatingRealToComplex", + CX_CastKind.CX_CK_FloatingComplexToReal => "FloatingComplexToReal", + CX_CastKind.CX_CK_FloatingComplexToBoolean => "FloatingComplexToBoolean", + CX_CastKind.CX_CK_FloatingComplexCast => "FloatingComplexCast", + CX_CastKind.CX_CK_FloatingComplexToIntegralComplex => "FloatingComplexToIntegralComplex", + CX_CastKind.CX_CK_IntegralRealToComplex => "IntegralRealToComplex", + CX_CastKind.CX_CK_IntegralComplexToReal => "IntegralComplexToReal", + CX_CastKind.CX_CK_IntegralComplexToBoolean => "IntegralComplexToBoolean", + CX_CastKind.CX_CK_IntegralComplexCast => "IntegralComplexCast", + CX_CastKind.CX_CK_IntegralComplexToFloatingComplex => "IntegralComplexToFloatingComplex", + CX_CastKind.CX_CK_ARCProduceObject => "ARCProduceObject", + CX_CastKind.CX_CK_ARCConsumeObject => "ARCConsumeObject", + CX_CastKind.CX_CK_ARCReclaimReturnedObject => "ARCReclaimReturnedObject", + CX_CastKind.CX_CK_ARCExtendBlockObject => "ARCExtendBlockObject", + CX_CastKind.CX_CK_AtomicToNonAtomic => "AtomicToNonAtomic", + CX_CastKind.CX_CK_NonAtomicToAtomic => "NonAtomicToAtomic", + CX_CastKind.CX_CK_CopyAndAutoreleaseBlockObject => "CopyAndAutoreleaseBlockObject", + CX_CastKind.CX_CK_BuiltinFnToFnPtr => "BuiltinFnToFnPtr", + CX_CastKind.CX_CK_ZeroToOCLOpaqueType => "ZeroToOCLOpaqueType", + CX_CastKind.CX_CK_AddressSpaceConversion => "AddressSpaceConversion", + CX_CastKind.CX_CK_IntToOCLSampler => "IntToOCLSampler", + _ => CastKind.ToString()[6..], + }; } + } - public CX_CharacterKind CharacterLiteralKind => clangsharp.Cursor_getCharacterLiteralKind(this); + public CX_CharacterKind CharacterLiteralKind => clangsharp.Cursor_getCharacterLiteralKind(this); - public uint CharacterLiteralValue => clangsharp.Cursor_getCharacterLiteralValue(this); + public uint CharacterLiteralValue => clangsharp.Cursor_getCharacterLiteralValue(this); - public CXSourceRange CommentRange => clang.Cursor_getCommentRange(this); + public CXSourceRange CommentRange => clang.Cursor_getCommentRange(this); - public CXCompletionString CompletionString => (CXCompletionString)clang.getCursorCompletionString(this); + public CXCompletionString CompletionString => (CXCompletionString)clang.getCursorCompletionString(this); - public CXType ComputationLhsType => clangsharp.Cursor_getComputationLhsType(this); + public CXType ComputationLhsType => clangsharp.Cursor_getComputationLhsType(this); - public CXType ComputationResultType => clangsharp.Cursor_getComputationResultType(this); + public CXType ComputationResultType => clangsharp.Cursor_getComputationResultType(this); - public CXCursor ConstraintExpr => clangsharp.Cursor_getConstraintExpr(this); + public CXCursor ConstraintExpr => clangsharp.Cursor_getConstraintExpr(this); - public CXCursor ConstructedBaseClass => clangsharp.Cursor_getConstructedBaseClass(this); + public CXCursor ConstructedBaseClass => clangsharp.Cursor_getConstructedBaseClass(this); - public CXCursor ConstructedBaseClassShadowDecl => clangsharp.Cursor_getConstructedBaseClassShadowDecl(this); + public CXCursor ConstructedBaseClassShadowDecl => clangsharp.Cursor_getConstructedBaseClassShadowDecl(this); - public CX_ConstructionKind ConstructionKind => clangsharp.Cursor_getConstructionKind(this); + public CX_ConstructionKind ConstructionKind => clangsharp.Cursor_getConstructionKind(this); - public bool ConstructsVirtualBase => clangsharp.Cursor_getConstructsVirtualBase(this) != 0; + public bool ConstructsVirtualBase => clangsharp.Cursor_getConstructsVirtualBase(this) != 0; - public CXCursor ContextParam => clangsharp.Cursor_getContextParam(this); + public CXCursor ContextParam => clangsharp.Cursor_getContextParam(this); - public int ContextParamPosition => clangsharp.Cursor_getContextParamPosition(this); + public int ContextParamPosition => clangsharp.Cursor_getContextParamPosition(this); - public CX_CXXAccessSpecifier CXXAccessSpecifier => clang.getCXXAccessSpecifier(this); + public CX_CXXAccessSpecifier CXXAccessSpecifier => clang.getCXXAccessSpecifier(this); - public bool BoolLiteralValue => clangsharp.Cursor_getBoolLiteralValue(this) != 0; + public bool BoolLiteralValue => clangsharp.Cursor_getBoolLiteralValue(this) != 0; - public bool CXXConstructor_IsConvertingConstructor => clang.CXXConstructor_isConvertingConstructor(this) != 0; + public bool CXXConstructor_IsConvertingConstructor => clang.CXXConstructor_isConvertingConstructor(this) != 0; - public bool CXXConstructor_IsCopyConstructor => clang.CXXConstructor_isCopyConstructor(this) != 0; + public bool CXXConstructor_IsCopyConstructor => clang.CXXConstructor_isCopyConstructor(this) != 0; - public bool CXXConstructor_IsDefaultConstructor => clang.CXXConstructor_isDefaultConstructor(this) != 0; + public bool CXXConstructor_IsDefaultConstructor => clang.CXXConstructor_isDefaultConstructor(this) != 0; - public bool CXXConstructor_IsMoveConstructor => clang.CXXConstructor_isMoveConstructor(this) != 0; + public bool CXXConstructor_IsMoveConstructor => clang.CXXConstructor_isMoveConstructor(this) != 0; - public bool CXXField_IsMutable => clang.CXXField_isMutable(this) != 0; + public bool CXXField_IsMutable => clang.CXXField_isMutable(this) != 0; - public CXStringSet* CXXManglings => clang.Cursor_getCXXManglings(this); + public CXStringSet* CXXManglings => clang.Cursor_getCXXManglings(this); - public bool CXXMethod_IsConst => clang.CXXMethod_isConst(this) != 0; + public bool CXXMethod_IsConst => clang.CXXMethod_isConst(this) != 0; - public bool CXXMethod_IsDefaulted => clang.CXXMethod_isDefaulted(this) != 0; + public bool CXXMethod_IsDefaulted => clang.CXXMethod_isDefaulted(this) != 0; - public bool CXXMethod_IsPureVirtual => clang.CXXMethod_isPureVirtual(this) != 0; + public bool CXXMethod_IsPureVirtual => clang.CXXMethod_isPureVirtual(this) != 0; - public bool CXXMethod_IsStatic => clang.CXXMethod_isStatic(this) != 0; + public bool CXXMethod_IsStatic => clang.CXXMethod_isStatic(this) != 0; - public bool CXXMethod_IsVirtual => clang.CXXMethod_isVirtual(this) != 0; + public bool CXXMethod_IsVirtual => clang.CXXMethod_isVirtual(this) != 0; - public bool CXXRecord_IsAbstract => clang.CXXRecord_isAbstract(this) != 0; + public bool CXXRecord_IsAbstract => clang.CXXRecord_isAbstract(this) != 0; - public CXType DeclaredReturnType => clangsharp.Cursor_getDeclaredReturnType(this); + public CXType DeclaredReturnType => clangsharp.Cursor_getDeclaredReturnType(this); - public CX_DeclKind DeclKind => clangsharp.Cursor_getDeclKind(this); + public CX_DeclKind DeclKind => clangsharp.Cursor_getDeclKind(this); - public string DeclKindSpelling + public string DeclKindSpelling + { + get { - get + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstObjCImpl == CX_DeclKind.CX_DeclKind_ObjCCategoryImpl); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastObjCImpl == CX_DeclKind.CX_DeclKind_ObjCImplementation); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstObjCContainer == CX_DeclKind.CX_DeclKind_ObjCCategory); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastObjCContainer == CX_DeclKind.CX_DeclKind_ObjCProtocol); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstRedeclarableTemplate == CX_DeclKind.CX_DeclKind_ClassTemplate); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastRedeclarableTemplate == CX_DeclKind.CX_DeclKind_VarTemplate); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstTemplate == CX_DeclKind.CX_DeclKind_BuiltinTemplate); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastTemplate == CX_DeclKind.CX_DeclKind_TemplateTemplateParm); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstClassTemplateSpecialization == CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastClassTemplateSpecialization == CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstCXXRecord == CX_DeclKind.CX_DeclKind_CXXRecord); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastCXXRecord == CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstRecord == CX_DeclKind.CX_DeclKind_Record); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastRecord == CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstTag == CX_DeclKind.CX_DeclKind_Enum); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastTag == CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstTypedefName == CX_DeclKind.CX_DeclKind_ObjCTypeParam); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastTypedefName == CX_DeclKind.CX_DeclKind_Typedef); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstType == CX_DeclKind.CX_DeclKind_Enum); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastType == CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstUsingShadow == CX_DeclKind.CX_DeclKind_UsingShadow); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastUsingShadow == CX_DeclKind.CX_DeclKind_ConstructorUsingShadow); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstField == CX_DeclKind.CX_DeclKind_Field); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastField == CX_DeclKind.CX_DeclKind_ObjCIvar); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstCXXMethod == CX_DeclKind.CX_DeclKind_CXXMethod); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastCXXMethod == CX_DeclKind.CX_DeclKind_CXXDestructor); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstFunction == CX_DeclKind.CX_DeclKind_Function); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastFunction == CX_DeclKind.CX_DeclKind_CXXDestructor); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstVarTemplateSpecialization == CX_DeclKind.CX_DeclKind_VarTemplateSpecialization); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastVarTemplateSpecialization == CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstVar == CX_DeclKind.CX_DeclKind_Var); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastVar == CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstDeclarator == CX_DeclKind.CX_DeclKind_Field); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastDeclarator == CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstValue == CX_DeclKind.CX_DeclKind_Binding); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastValue == CX_DeclKind.CX_DeclKind_UnresolvedUsingValue); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstNamed == CX_DeclKind.CX_DeclKind_Using); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastNamed == CX_DeclKind.CX_DeclKind_UnresolvedUsingValue); + Debug.Assert(CX_DeclKind.CX_DeclKind_FirstDecl == CX_DeclKind.CX_DeclKind_AccessSpec); + Debug.Assert(CX_DeclKind.CX_DeclKind_LastDecl == CX_DeclKind.CX_DeclKind_TranslationUnit); + + return DeclKind switch { - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstObjCImpl == CX_DeclKind.CX_DeclKind_ObjCCategoryImpl); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastObjCImpl == CX_DeclKind.CX_DeclKind_ObjCImplementation); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstObjCContainer == CX_DeclKind.CX_DeclKind_ObjCCategory); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastObjCContainer == CX_DeclKind.CX_DeclKind_ObjCProtocol); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstRedeclarableTemplate == CX_DeclKind.CX_DeclKind_ClassTemplate); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastRedeclarableTemplate == CX_DeclKind.CX_DeclKind_VarTemplate); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstTemplate == CX_DeclKind.CX_DeclKind_BuiltinTemplate); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastTemplate == CX_DeclKind.CX_DeclKind_TemplateTemplateParm); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstClassTemplateSpecialization == CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastClassTemplateSpecialization == CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstCXXRecord == CX_DeclKind.CX_DeclKind_CXXRecord); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastCXXRecord == CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstRecord == CX_DeclKind.CX_DeclKind_Record); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastRecord == CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstTag == CX_DeclKind.CX_DeclKind_Enum); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastTag == CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstTypedefName == CX_DeclKind.CX_DeclKind_ObjCTypeParam); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastTypedefName == CX_DeclKind.CX_DeclKind_Typedef); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstType == CX_DeclKind.CX_DeclKind_Enum); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastType == CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstUsingShadow == CX_DeclKind.CX_DeclKind_UsingShadow); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastUsingShadow == CX_DeclKind.CX_DeclKind_ConstructorUsingShadow); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstField == CX_DeclKind.CX_DeclKind_Field); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastField == CX_DeclKind.CX_DeclKind_ObjCIvar); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstCXXMethod == CX_DeclKind.CX_DeclKind_CXXMethod); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastCXXMethod == CX_DeclKind.CX_DeclKind_CXXDestructor); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstFunction == CX_DeclKind.CX_DeclKind_Function); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastFunction == CX_DeclKind.CX_DeclKind_CXXDestructor); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstVarTemplateSpecialization == CX_DeclKind.CX_DeclKind_VarTemplateSpecialization); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastVarTemplateSpecialization == CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstVar == CX_DeclKind.CX_DeclKind_Var); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastVar == CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstDeclarator == CX_DeclKind.CX_DeclKind_Field); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastDeclarator == CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstValue == CX_DeclKind.CX_DeclKind_Binding); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastValue == CX_DeclKind.CX_DeclKind_UnresolvedUsingValue); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstNamed == CX_DeclKind.CX_DeclKind_Using); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastNamed == CX_DeclKind.CX_DeclKind_UnresolvedUsingValue); - Debug.Assert(CX_DeclKind.CX_DeclKind_FirstDecl == CX_DeclKind.CX_DeclKind_AccessSpec); - Debug.Assert(CX_DeclKind.CX_DeclKind_LastDecl == CX_DeclKind.CX_DeclKind_TranslationUnit); - - return DeclKind switch - { - CX_DeclKind.CX_DeclKind_Invalid => "Invalid", - CX_DeclKind.CX_DeclKind_AccessSpec => "AccessSpec", - CX_DeclKind.CX_DeclKind_Block => "Block", - CX_DeclKind.CX_DeclKind_Captured => "Captured", - CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization => "ClassScopeFunctionSpecialization", - CX_DeclKind.CX_DeclKind_Empty => "Empty", - CX_DeclKind.CX_DeclKind_Export => "Export", - CX_DeclKind.CX_DeclKind_ExternCContext => "ExternCContext", - CX_DeclKind.CX_DeclKind_FileScopeAsm => "FileScopeAsm", - CX_DeclKind.CX_DeclKind_Friend => "Friend", - CX_DeclKind.CX_DeclKind_FriendTemplate => "FriendTemplate", - CX_DeclKind.CX_DeclKind_Import => "Import", - CX_DeclKind.CX_DeclKind_LifetimeExtendedTemporary => "LifetimeExtendedTemporary", - CX_DeclKind.CX_DeclKind_LinkageSpec => "LinkageSpec", - CX_DeclKind.CX_DeclKind_Label => "Label", - CX_DeclKind.CX_DeclKind_Namespace => "Namespace", - CX_DeclKind.CX_DeclKind_NamespaceAlias => "NamespaceAlias", - CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias => "ObjCCompatibleAlias", - CX_DeclKind.CX_DeclKind_ObjCCategory => "ObjCCategory", - CX_DeclKind.CX_DeclKind_ObjCCategoryImpl => "ObjCCategoryImpl", - CX_DeclKind.CX_DeclKind_ObjCImplementation => "ObjCImplementation", - CX_DeclKind.CX_DeclKind_ObjCInterface => "ObjCInterface", - CX_DeclKind.CX_DeclKind_ObjCProtocol => "ObjCProtocol", - CX_DeclKind.CX_DeclKind_ObjCMethod => "ObjCMethod", - CX_DeclKind.CX_DeclKind_ObjCProperty => "ObjCProperty", - CX_DeclKind.CX_DeclKind_BuiltinTemplate => "BuiltinTemplate", - CX_DeclKind.CX_DeclKind_Concept => "Concept", - CX_DeclKind.CX_DeclKind_ClassTemplate => "ClassTemplate", - CX_DeclKind.CX_DeclKind_FunctionTemplate => "FunctionTemplate", - CX_DeclKind.CX_DeclKind_TypeAliasTemplate => "TypeAliasTemplate", - CX_DeclKind.CX_DeclKind_VarTemplate => "VarTemplate", - CX_DeclKind.CX_DeclKind_TemplateTemplateParm => "TemplateTemplateParm", - CX_DeclKind.CX_DeclKind_Enum => "Enum", - CX_DeclKind.CX_DeclKind_Record => "Record", - CX_DeclKind.CX_DeclKind_CXXRecord => "CXXRecord", - CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization => "ClassTemplateSpecialization", - CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization => "ClassTemplatePartialSpecialization", - CX_DeclKind.CX_DeclKind_TemplateTypeParm => "TemplateTypeParm", - CX_DeclKind.CX_DeclKind_ObjCTypeParam => "ObjCTypeParam", - CX_DeclKind.CX_DeclKind_TypeAlias => "TypeAlias", - CX_DeclKind.CX_DeclKind_Typedef => "Typedef", - CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename => "UnresolvedUsingTypename", - CX_DeclKind.CX_DeclKind_Using => "Using", - CX_DeclKind.CX_DeclKind_UsingDirective => "UsingDirective", - CX_DeclKind.CX_DeclKind_UsingPack => "UsingPack", - CX_DeclKind.CX_DeclKind_UsingShadow => "UsingShadow", - CX_DeclKind.CX_DeclKind_ConstructorUsingShadow => "ConstructorUsingShadow", - CX_DeclKind.CX_DeclKind_Binding => "Binding", - CX_DeclKind.CX_DeclKind_Field => "Field", - CX_DeclKind.CX_DeclKind_ObjCAtDefsField => "ObjCAtDefsField", - CX_DeclKind.CX_DeclKind_ObjCIvar => "ObjCIvar", - CX_DeclKind.CX_DeclKind_Function => "Function", - CX_DeclKind.CX_DeclKind_CXXDeductionGuide => "CXXDeductionGuide", - CX_DeclKind.CX_DeclKind_CXXMethod => "CXXMethod", - CX_DeclKind.CX_DeclKind_CXXConstructor => "CXXConstructor", - CX_DeclKind.CX_DeclKind_CXXConversion => "CXXConversion", - CX_DeclKind.CX_DeclKind_CXXDestructor => "CXXDestructor", - CX_DeclKind.CX_DeclKind_MSProperty => "MSProperty", - CX_DeclKind.CX_DeclKind_NonTypeTemplateParm => "NonTypeTemplateParm", - CX_DeclKind.CX_DeclKind_Var => "Var", - CX_DeclKind.CX_DeclKind_Decomposition => "Decomposition", - CX_DeclKind.CX_DeclKind_ImplicitParam => "ImplicitParam", - CX_DeclKind.CX_DeclKind_OMPCapturedExpr => "OMPCapturedExpr", - CX_DeclKind.CX_DeclKind_ParmVar => "ParmVar", - CX_DeclKind.CX_DeclKind_VarTemplateSpecialization => "VarTemplateSpecialization", - CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization => "VarTemplatePartialSpecialization", - CX_DeclKind.CX_DeclKind_EnumConstant => "EnumConstant", - CX_DeclKind.CX_DeclKind_IndirectField => "IndirectField", - CX_DeclKind.CX_DeclKind_MSGuid => "MSGuid", - CX_DeclKind.CX_DeclKind_OMPDeclareMapper => "OMPDeclareMapper", - CX_DeclKind.CX_DeclKind_OMPDeclareReduction => "OMPDeclareReduction", - CX_DeclKind.CX_DeclKind_UnresolvedUsingValue => "UnresolvedUsingValue", - CX_DeclKind.CX_DeclKind_OMPAllocate => "OMPAllocate", - CX_DeclKind.CX_DeclKind_OMPRequires => "OMPRequires", - CX_DeclKind.CX_DeclKind_OMPThreadPrivate => "OMPThreadPrivate", - CX_DeclKind.CX_DeclKind_ObjCPropertyImpl => "ObjCPropertyImpl", - CX_DeclKind.CX_DeclKind_PragmaComment => "PragmaComment", - CX_DeclKind.CX_DeclKind_PragmaDetectMismatch => "PragmaDetectMismatch", - CX_DeclKind.CX_DeclKind_RequiresExprBody => "RequiresExprBody", - CX_DeclKind.CX_DeclKind_StaticAssert => "StaticAssert", - CX_DeclKind.CX_DeclKind_TranslationUnit => "TranslationUnit", - _ => Kind.ToString()[12..], - }; - } + CX_DeclKind.CX_DeclKind_Invalid => "Invalid", + CX_DeclKind.CX_DeclKind_AccessSpec => "AccessSpec", + CX_DeclKind.CX_DeclKind_Block => "Block", + CX_DeclKind.CX_DeclKind_Captured => "Captured", + CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization => "ClassScopeFunctionSpecialization", + CX_DeclKind.CX_DeclKind_Empty => "Empty", + CX_DeclKind.CX_DeclKind_Export => "Export", + CX_DeclKind.CX_DeclKind_ExternCContext => "ExternCContext", + CX_DeclKind.CX_DeclKind_FileScopeAsm => "FileScopeAsm", + CX_DeclKind.CX_DeclKind_Friend => "Friend", + CX_DeclKind.CX_DeclKind_FriendTemplate => "FriendTemplate", + CX_DeclKind.CX_DeclKind_Import => "Import", + CX_DeclKind.CX_DeclKind_LifetimeExtendedTemporary => "LifetimeExtendedTemporary", + CX_DeclKind.CX_DeclKind_LinkageSpec => "LinkageSpec", + CX_DeclKind.CX_DeclKind_Label => "Label", + CX_DeclKind.CX_DeclKind_Namespace => "Namespace", + CX_DeclKind.CX_DeclKind_NamespaceAlias => "NamespaceAlias", + CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias => "ObjCCompatibleAlias", + CX_DeclKind.CX_DeclKind_ObjCCategory => "ObjCCategory", + CX_DeclKind.CX_DeclKind_ObjCCategoryImpl => "ObjCCategoryImpl", + CX_DeclKind.CX_DeclKind_ObjCImplementation => "ObjCImplementation", + CX_DeclKind.CX_DeclKind_ObjCInterface => "ObjCInterface", + CX_DeclKind.CX_DeclKind_ObjCProtocol => "ObjCProtocol", + CX_DeclKind.CX_DeclKind_ObjCMethod => "ObjCMethod", + CX_DeclKind.CX_DeclKind_ObjCProperty => "ObjCProperty", + CX_DeclKind.CX_DeclKind_BuiltinTemplate => "BuiltinTemplate", + CX_DeclKind.CX_DeclKind_Concept => "Concept", + CX_DeclKind.CX_DeclKind_ClassTemplate => "ClassTemplate", + CX_DeclKind.CX_DeclKind_FunctionTemplate => "FunctionTemplate", + CX_DeclKind.CX_DeclKind_TypeAliasTemplate => "TypeAliasTemplate", + CX_DeclKind.CX_DeclKind_VarTemplate => "VarTemplate", + CX_DeclKind.CX_DeclKind_TemplateTemplateParm => "TemplateTemplateParm", + CX_DeclKind.CX_DeclKind_Enum => "Enum", + CX_DeclKind.CX_DeclKind_Record => "Record", + CX_DeclKind.CX_DeclKind_CXXRecord => "CXXRecord", + CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization => "ClassTemplateSpecialization", + CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization => "ClassTemplatePartialSpecialization", + CX_DeclKind.CX_DeclKind_TemplateTypeParm => "TemplateTypeParm", + CX_DeclKind.CX_DeclKind_ObjCTypeParam => "ObjCTypeParam", + CX_DeclKind.CX_DeclKind_TypeAlias => "TypeAlias", + CX_DeclKind.CX_DeclKind_Typedef => "Typedef", + CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename => "UnresolvedUsingTypename", + CX_DeclKind.CX_DeclKind_Using => "Using", + CX_DeclKind.CX_DeclKind_UsingDirective => "UsingDirective", + CX_DeclKind.CX_DeclKind_UsingPack => "UsingPack", + CX_DeclKind.CX_DeclKind_UsingShadow => "UsingShadow", + CX_DeclKind.CX_DeclKind_ConstructorUsingShadow => "ConstructorUsingShadow", + CX_DeclKind.CX_DeclKind_Binding => "Binding", + CX_DeclKind.CX_DeclKind_Field => "Field", + CX_DeclKind.CX_DeclKind_ObjCAtDefsField => "ObjCAtDefsField", + CX_DeclKind.CX_DeclKind_ObjCIvar => "ObjCIvar", + CX_DeclKind.CX_DeclKind_Function => "Function", + CX_DeclKind.CX_DeclKind_CXXDeductionGuide => "CXXDeductionGuide", + CX_DeclKind.CX_DeclKind_CXXMethod => "CXXMethod", + CX_DeclKind.CX_DeclKind_CXXConstructor => "CXXConstructor", + CX_DeclKind.CX_DeclKind_CXXConversion => "CXXConversion", + CX_DeclKind.CX_DeclKind_CXXDestructor => "CXXDestructor", + CX_DeclKind.CX_DeclKind_MSProperty => "MSProperty", + CX_DeclKind.CX_DeclKind_NonTypeTemplateParm => "NonTypeTemplateParm", + CX_DeclKind.CX_DeclKind_Var => "Var", + CX_DeclKind.CX_DeclKind_Decomposition => "Decomposition", + CX_DeclKind.CX_DeclKind_ImplicitParam => "ImplicitParam", + CX_DeclKind.CX_DeclKind_OMPCapturedExpr => "OMPCapturedExpr", + CX_DeclKind.CX_DeclKind_ParmVar => "ParmVar", + CX_DeclKind.CX_DeclKind_VarTemplateSpecialization => "VarTemplateSpecialization", + CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization => "VarTemplatePartialSpecialization", + CX_DeclKind.CX_DeclKind_EnumConstant => "EnumConstant", + CX_DeclKind.CX_DeclKind_IndirectField => "IndirectField", + CX_DeclKind.CX_DeclKind_MSGuid => "MSGuid", + CX_DeclKind.CX_DeclKind_OMPDeclareMapper => "OMPDeclareMapper", + CX_DeclKind.CX_DeclKind_OMPDeclareReduction => "OMPDeclareReduction", + CX_DeclKind.CX_DeclKind_UnresolvedUsingValue => "UnresolvedUsingValue", + CX_DeclKind.CX_DeclKind_OMPAllocate => "OMPAllocate", + CX_DeclKind.CX_DeclKind_OMPRequires => "OMPRequires", + CX_DeclKind.CX_DeclKind_OMPThreadPrivate => "OMPThreadPrivate", + CX_DeclKind.CX_DeclKind_ObjCPropertyImpl => "ObjCPropertyImpl", + CX_DeclKind.CX_DeclKind_PragmaComment => "PragmaComment", + CX_DeclKind.CX_DeclKind_PragmaDetectMismatch => "PragmaDetectMismatch", + CX_DeclKind.CX_DeclKind_RequiresExprBody => "RequiresExprBody", + CX_DeclKind.CX_DeclKind_StaticAssert => "StaticAssert", + CX_DeclKind.CX_DeclKind_TranslationUnit => "TranslationUnit", + _ => Kind.ToString()[12..], + }; } + } - public CXString DeclObjCTypeEncoding => clang.getDeclObjCTypeEncoding(this); + public CXString DeclObjCTypeEncoding => clang.getDeclObjCTypeEncoding(this); - public CXCursor DecomposedDecl => clangsharp.Cursor_getDecomposedDecl(this); + public CXCursor DecomposedDecl => clangsharp.Cursor_getDecomposedDecl(this); - public CXCursor DefaultArg => clangsharp.Cursor_getDefaultArg(this); + public CXCursor DefaultArg => clangsharp.Cursor_getDefaultArg(this); - public CXType DefaultArgType => clangsharp.Cursor_getDefaultArgType(this); + public CXType DefaultArgType => clangsharp.Cursor_getDefaultArgType(this); - public CXCursor Definition => clangsharp.Cursor_getDefinition(this); + public CXCursor Definition => clangsharp.Cursor_getDefinition(this); - public CXCursor DependentLambdaCallOperator => clangsharp.Cursor_getDependentLambdaCallOperator(this); + public CXCursor DependentLambdaCallOperator => clangsharp.Cursor_getDependentLambdaCallOperator(this); - public CXCursor DescribedCursorTemplate => clangsharp.Cursor_getDescribedCursorTemplate(this); + public CXCursor DescribedCursorTemplate => clangsharp.Cursor_getDescribedCursorTemplate(this); - public CXCursor DescribedTemplate => clangsharp.Cursor_getDescribedTemplate(this); + public CXCursor DescribedTemplate => clangsharp.Cursor_getDescribedTemplate(this); - public CXCursor Destructor => clangsharp.Cursor_getDestructor(this); + public CXCursor Destructor => clangsharp.Cursor_getDestructor(this); - public CXString DisplayName => clang.getCursorDisplayName(this); + public CXString DisplayName => clang.getCursorDisplayName(this); - public bool DoesNotEscape => clangsharp.Cursor_getDoesNotEscape(this) != 0; + public bool DoesNotEscape => clangsharp.Cursor_getDoesNotEscape(this) != 0; - public bool DoesUsualArrayDeleteWantSize => clangsharp.Cursor_getDoesUsualArrayDeleteWantSize(this) != 0; + public bool DoesUsualArrayDeleteWantSize => clangsharp.Cursor_getDoesUsualArrayDeleteWantSize(this) != 0; - public ulong EnumConstantDeclUnsignedValue => clang.getEnumConstantDeclUnsignedValue(this); + public ulong EnumConstantDeclUnsignedValue => clang.getEnumConstantDeclUnsignedValue(this); - public long EnumConstantDeclValue => clang.getEnumConstantDeclValue(this); + public long EnumConstantDeclValue => clang.getEnumConstantDeclValue(this); - public CXType EnumDecl_IntegerType => clang.getEnumDeclIntegerType(this); + public CXType EnumDecl_IntegerType => clang.getEnumDeclIntegerType(this); - public bool EnumDecl_IsScoped => clang.EnumDecl_isScoped(this) != 0; + public bool EnumDecl_IsScoped => clang.EnumDecl_isScoped(this) != 0; - public CXType EnumDecl_PromotionType => clangsharp.Cursor_getEnumDeclPromotionType(this); + public CXType EnumDecl_PromotionType => clangsharp.Cursor_getEnumDeclPromotionType(this); - public CXEvalResult Evaluate => (CXEvalResult)clang.Cursor_Evaluate(this); + public CXEvalResult Evaluate => (CXEvalResult)clang.Cursor_Evaluate(this); - public int ExceptionSpecificationType => clang.getCursorExceptionSpecificationType(this); + public int ExceptionSpecificationType => clang.getCursorExceptionSpecificationType(this); - public CX_ExprDependence ExprDependence => clangsharp.Cursor_getExprDependence(this); + public CX_ExprDependence ExprDependence => clangsharp.Cursor_getExprDependence(this); - public CXSourceRange Extent => clang.getCursorExtent(this); + public CXSourceRange Extent => clang.getCursorExtent(this); - public CX_FloatingSemantics FloatingLiteralSemantics => clangsharp.Cursor_getFloatingLiteralSemantics(this); + public CX_FloatingSemantics FloatingLiteralSemantics => clangsharp.Cursor_getFloatingLiteralSemantics(this); - public double FloatingLiteralValueAsApproximateDouble => clangsharp.Cursor_getFloatingLiteralValueAsApproximateDouble(this); + public double FloatingLiteralValueAsApproximateDouble => clangsharp.Cursor_getFloatingLiteralValueAsApproximateDouble(this); - public int FieldDeclBitWidth => clang.getFieldDeclBitWidth(this); + public int FieldDeclBitWidth => clang.getFieldDeclBitWidth(this); - public int FieldIndex => clangsharp.Cursor_getFieldIndex(this); + public int FieldIndex => clangsharp.Cursor_getFieldIndex(this); - public CXCursor FoundDecl => clangsharp.Cursor_getFoundDecl(this); + public CXCursor FoundDecl => clangsharp.Cursor_getFoundDecl(this); - public CXCursor FriendDecl => clangsharp.Cursor_getFriendDecl(this); + public CXCursor FriendDecl => clangsharp.Cursor_getFriendDecl(this); - public int FunctionScopeDepth => clangsharp.Cursor_getFunctionScopeDepth(this); + public int FunctionScopeDepth => clangsharp.Cursor_getFunctionScopeDepth(this); - public int FunctionScopeIndex => clangsharp.Cursor_getFunctionScopeIndex(this); + public int FunctionScopeIndex => clangsharp.Cursor_getFunctionScopeIndex(this); - public Guid GuidValue => clangsharp.Cursor_getGuidValue(this); + public Guid GuidValue => clangsharp.Cursor_getGuidValue(this); - public bool HadMultipleCandidates => clangsharp.Cursor_getHadMultipleCandidates(this) != 0; + public bool HadMultipleCandidates => clangsharp.Cursor_getHadMultipleCandidates(this) != 0; - public bool HasAttrs => clang.Cursor_hasAttrs(this) != 0; + public bool HasAttrs => clang.Cursor_hasAttrs(this) != 0; - public bool HasBody => clangsharp.Cursor_getHasBody(this) != 0; + public bool HasBody => clangsharp.Cursor_getHasBody(this) != 0; - public bool HasDefaultArg => clangsharp.Cursor_getHasDefaultArg(this) != 0; + public bool HasDefaultArg => clangsharp.Cursor_getHasDefaultArg(this) != 0; - public bool HasElseStorage => clangsharp.Cursor_getHasElseStorage(this) != 0; + public bool HasElseStorage => clangsharp.Cursor_getHasElseStorage(this) != 0; - public bool HasExplicitTemplateArgs => clangsharp.Cursor_getHasExplicitTemplateArgs(this) != 0; + public bool HasExplicitTemplateArgs => clangsharp.Cursor_getHasExplicitTemplateArgs(this) != 0; - public bool HasImplicitReturnZero => clangsharp.Cursor_getHasImplicitReturnZero(this) != 0; + public bool HasImplicitReturnZero => clangsharp.Cursor_getHasImplicitReturnZero(this) != 0; - public bool HasInheritedDefaultArg => clangsharp.Cursor_getHasInheritedDefaultArg(this) != 0; + public bool HasInheritedDefaultArg => clangsharp.Cursor_getHasInheritedDefaultArg(this) != 0; - public bool HasInit => clangsharp.Cursor_getHasInit(this) != 0; + public bool HasInit => clangsharp.Cursor_getHasInit(this) != 0; - public bool HasInitStorage => clangsharp.Cursor_getHasInitStorage(this) != 0; + public bool HasInitStorage => clangsharp.Cursor_getHasInitStorage(this) != 0; - public bool HasLeadingEmptyMacro => clangsharp.Cursor_getHasLeadingEmptyMacro(this) != 0; + public bool HasLeadingEmptyMacro => clangsharp.Cursor_getHasLeadingEmptyMacro(this) != 0; - public bool HasLocalStorage => clangsharp.Cursor_getHasLocalStorage(this) != 0; + public bool HasLocalStorage => clangsharp.Cursor_getHasLocalStorage(this) != 0; - public bool HasPlaceholderTypeConstraint => clangsharp.Cursor_getHasPlaceholderTypeConstraint(this) != 0; + public bool HasPlaceholderTypeConstraint => clangsharp.Cursor_getHasPlaceholderTypeConstraint(this) != 0; - public uint Hash => clang.hashCursor(this); + public uint Hash => clang.hashCursor(this); - public bool HasTemplateKeyword => clangsharp.Cursor_getHasTemplateKeyword(this) != 0; + public bool HasTemplateKeyword => clangsharp.Cursor_getHasTemplateKeyword(this) != 0; - public bool HasUserDeclaredConstructor => clangsharp.Cursor_getHasUserDeclaredConstructor(this) != 0; + public bool HasUserDeclaredConstructor => clangsharp.Cursor_getHasUserDeclaredConstructor(this) != 0; - public bool HasUserDeclaredCopyAssignment => clangsharp.Cursor_getHasUserDeclaredCopyAssignment(this) != 0; + public bool HasUserDeclaredCopyAssignment => clangsharp.Cursor_getHasUserDeclaredCopyAssignment(this) != 0; - public bool HasUserDeclaredCopyConstructor => clangsharp.Cursor_getHasUserDeclaredCopyConstructor(this) != 0; + public bool HasUserDeclaredCopyConstructor => clangsharp.Cursor_getHasUserDeclaredCopyConstructor(this) != 0; - public bool HasUserDeclaredDestructor => clangsharp.Cursor_getHasUserDeclaredDestructor(this) != 0; + public bool HasUserDeclaredDestructor => clangsharp.Cursor_getHasUserDeclaredDestructor(this) != 0; - public bool HasUserDeclaredMoveAssignment => clangsharp.Cursor_getHasUserDeclaredMoveAssignment(this) != 0; + public bool HasUserDeclaredMoveAssignment => clangsharp.Cursor_getHasUserDeclaredMoveAssignment(this) != 0; - public bool HasUserDeclaredMoveConstructor => clangsharp.Cursor_getHasUserDeclaredMoveConstructor(this) != 0; + public bool HasUserDeclaredMoveConstructor => clangsharp.Cursor_getHasUserDeclaredMoveConstructor(this) != 0; - public bool HasUserDeclaredMoveOperation => clangsharp.Cursor_getHasUserDeclaredMoveOperation(this) != 0; + public bool HasUserDeclaredMoveOperation => clangsharp.Cursor_getHasUserDeclaredMoveOperation(this) != 0; - public bool HasVarDeclExternalStorage => clang.Cursor_hasVarDeclExternalStorage(this) != 0; + public bool HasVarDeclExternalStorage => clang.Cursor_hasVarDeclExternalStorage(this) != 0; - public bool HasVarDeclGlobalStorage => clang.Cursor_hasVarDeclGlobalStorage(this) != 0; + public bool HasVarDeclGlobalStorage => clang.Cursor_hasVarDeclGlobalStorage(this) != 0; - public bool HasVarStorage => clangsharp.Cursor_getHasVarStorage(this) != 0; + public bool HasVarStorage => clangsharp.Cursor_getHasVarStorage(this) != 0; - public CXType IBOutletCollectionType => clang.getIBOutletCollectionType(this); + public CXType IBOutletCollectionType => clang.getIBOutletCollectionType(this); - public CXFile IncludedFile => (CXFile)clang.getIncludedFile(this); + public CXFile IncludedFile => (CXFile)clang.getIncludedFile(this); - public CXCursor InClassInitializer => clangsharp.Cursor_getInClassInitializer(this); + public CXCursor InClassInitializer => clangsharp.Cursor_getInClassInitializer(this); - public CXCursor InheritedConstructor => clangsharp.Cursor_getInheritedConstructor(this); + public CXCursor InheritedConstructor => clangsharp.Cursor_getInheritedConstructor(this); - public bool InheritedFromVBase => clangsharp.Cursor_getInheritedFromVBase(this) != 0; + public bool InheritedFromVBase => clangsharp.Cursor_getInheritedFromVBase(this) != 0; - public CXCursor InitExpr => clangsharp.Cursor_getInitExpr(this); + public CXCursor InitExpr => clangsharp.Cursor_getInitExpr(this); - public CXType InjectedSpecializationType => clangsharp.Cursor_getInjectedSpecializationType(this); + public CXType InjectedSpecializationType => clangsharp.Cursor_getInjectedSpecializationType(this); - public CXCursor InstantiatedFromMember => clangsharp.Cursor_getInstantiatedFromMember(this); + public CXCursor InstantiatedFromMember => clangsharp.Cursor_getInstantiatedFromMember(this); - public long IntegerLiteralValue => clangsharp.Cursor_getIntegerLiteralValue(this); + public long IntegerLiteralValue => clangsharp.Cursor_getIntegerLiteralValue(this); - public bool IsAllEnumCasesCovered => clangsharp.Cursor_getIsAllEnumCasesCovered(this) != 0; + public bool IsAllEnumCasesCovered => clangsharp.Cursor_getIsAllEnumCasesCovered(this) != 0; - public bool IsAlwaysNull => clangsharp.Cursor_getIsAlwaysNull(this) != 0; + public bool IsAlwaysNull => clangsharp.Cursor_getIsAlwaysNull(this) != 0; - public bool IsAnonymous => clang.Cursor_isAnonymous(this) != 0; + public bool IsAnonymous => clang.Cursor_isAnonymous(this) != 0; - public bool IsAnonymousRecordDecl => clang.Cursor_isAnonymousRecordDecl(this) != 0; + public bool IsAnonymousRecordDecl => clang.Cursor_isAnonymousRecordDecl(this) != 0; - public bool IsAnonymousStructOrUnion => clangsharp.Cursor_getIsAnonymousStructOrUnion(this) != 0; + public bool IsAnonymousStructOrUnion => clangsharp.Cursor_getIsAnonymousStructOrUnion(this) != 0; - public bool IsArgumentType => clangsharp.Cursor_getIsArgumentType(this) != 0; + public bool IsArgumentType => clangsharp.Cursor_getIsArgumentType(this) != 0; - public bool IsArrayForm => clangsharp.Cursor_getIsArrayForm(this) != 0; + public bool IsArrayForm => clangsharp.Cursor_getIsArrayForm(this) != 0; - public bool IsArrayFormAsWritten => clangsharp.Cursor_getIsArrayFormAsWritten(this) != 0; + public bool IsArrayFormAsWritten => clangsharp.Cursor_getIsArrayFormAsWritten(this) != 0; - public bool IsArrow => clangsharp.Cursor_getIsArrow(this) != 0; + public bool IsArrow => clangsharp.Cursor_getIsArrow(this) != 0; - public bool IsAttribute => clang.isAttribute(Kind) != 0; + public bool IsAttribute => clang.isAttribute(Kind) != 0; - public bool IsBitField => clang.Cursor_isBitField(this) != 0; + public bool IsBitField => clang.Cursor_isBitField(this) != 0; - public bool IsCanonical => Equals(CanonicalCursor); + public bool IsCanonical => Equals(CanonicalCursor); - public bool IsClassExtension => clangsharp.Cursor_getIsClassExtension(this) != 0; + public bool IsClassExtension => clangsharp.Cursor_getIsClassExtension(this) != 0; - public bool IsCompleteDefinition => clangsharp.Cursor_getIsCompleteDefinition(this) != 0; + public bool IsCompleteDefinition => clangsharp.Cursor_getIsCompleteDefinition(this) != 0; - public bool IsConditionTrue => clangsharp.Cursor_getIsConditionTrue(this) != 0; + public bool IsConditionTrue => clangsharp.Cursor_getIsConditionTrue(this) != 0; - public bool IsConstexpr => clangsharp.Cursor_getIsConstexpr(this) != 0; + public bool IsConstexpr => clangsharp.Cursor_getIsConstexpr(this) != 0; - public bool IsConversionFromLambda => clangsharp.Cursor_getIsConversionFromLambda(this) != 0; + public bool IsConversionFromLambda => clangsharp.Cursor_getIsConversionFromLambda(this) != 0; - public bool IsCopyOrMoveConstructor => clangsharp.Cursor_getIsCopyOrMoveConstructor(this) != 0; + public bool IsCopyOrMoveConstructor => clangsharp.Cursor_getIsCopyOrMoveConstructor(this) != 0; - public bool IsCXXTry => clangsharp.Cursor_getIsCXXTry(this) != 0; + public bool IsCXXTry => clangsharp.Cursor_getIsCXXTry(this) != 0; - public bool IsDeclaration => clang.isDeclaration(Kind) != 0; + public bool IsDeclaration => clang.isDeclaration(Kind) != 0; - public bool IsDefined => clangsharp.Cursor_getIsDefined(this) != 0; + public bool IsDefined => clangsharp.Cursor_getIsDefined(this) != 0; - public bool IsDefinition => clang.isCursorDefinition(this) != 0; + public bool IsDefinition => clang.isCursorDefinition(this) != 0; - public bool IsDelegatingConstructor => clangsharp.Cursor_getIsDelegatingConstructor(this) != 0; + public bool IsDelegatingConstructor => clangsharp.Cursor_getIsDelegatingConstructor(this) != 0; - public bool IsDeleted => clangsharp.Cursor_getIsDeleted(this) != 0; + public bool IsDeleted => clangsharp.Cursor_getIsDeleted(this) != 0; - public bool IsDeprecated => clangsharp.Cursor_getIsDeprecated(this) != 0; + public bool IsDeprecated => clangsharp.Cursor_getIsDeprecated(this) != 0; - public bool IsDynamicCall => clang.Cursor_isDynamicCall(this) != 0; + public bool IsDynamicCall => clang.Cursor_isDynamicCall(this) != 0; - public bool IsElidable => clangsharp.Cursor_getIsElidable(this) != 0; + public bool IsElidable => clangsharp.Cursor_getIsElidable(this) != 0; - public bool IsExplicitlyDefaulted => clangsharp.Cursor_getIsExplicitlyDefaulted(this) != 0; + public bool IsExplicitlyDefaulted => clangsharp.Cursor_getIsExplicitlyDefaulted(this) != 0; - public bool IsExpression => clang.isExpression(Kind) != 0; + public bool IsExpression => clang.isExpression(Kind) != 0; - public bool IsExternC => clangsharp.Cursor_getIsExternC(this) != 0; + public bool IsExternC => clangsharp.Cursor_getIsExternC(this) != 0; - public bool IsExpandedParameterPack => clangsharp.Cursor_getIsExpandedParameterPack(this) != 0; + public bool IsExpandedParameterPack => clangsharp.Cursor_getIsExpandedParameterPack(this) != 0; - public bool IsFileScope => clangsharp.Cursor_getIsFileScope(this) != 0; + public bool IsFileScope => clangsharp.Cursor_getIsFileScope(this) != 0; - public bool IsFunctionInlined => clang.Cursor_isFunctionInlined(this) != 0; + public bool IsFunctionInlined => clang.Cursor_isFunctionInlined(this) != 0; - public bool IsGlobal => clangsharp.Cursor_getIsGlobal(this) != 0; + public bool IsGlobal => clangsharp.Cursor_getIsGlobal(this) != 0; - public bool IsInjectedClassName => clangsharp.Cursor_getIsInjectedClassName(this) != 0; + public bool IsInjectedClassName => clangsharp.Cursor_getIsInjectedClassName(this) != 0; - public bool IsInlineNamespace => clang.Cursor_isInlineNamespace(this) != 0; + public bool IsInlineNamespace => clang.Cursor_isInlineNamespace(this) != 0; - public bool IsIfExists => clangsharp.Cursor_getIsIfExists(this) != 0; + public bool IsIfExists => clangsharp.Cursor_getIsIfExists(this) != 0; - public bool IsImplicit => clangsharp.Cursor_getIsImplicit(this) != 0; + public bool IsImplicit => clangsharp.Cursor_getIsImplicit(this) != 0; - public bool IsIncomplete => clangsharp.Cursor_getIsIncomplete(this) != 0; + public bool IsIncomplete => clangsharp.Cursor_getIsIncomplete(this) != 0; - public bool IsInheritingConstructor => clangsharp.Cursor_getIsInheritingConstructor(this) != 0; + public bool IsInheritingConstructor => clangsharp.Cursor_getIsInheritingConstructor(this) != 0; - public bool IsInvalid => clang.isInvalid(Kind) != 0; + public bool IsInvalid => clang.isInvalid(Kind) != 0; - public bool IsInvalidDeclaration => clang.isInvalidDeclaration(this) != 0; + public bool IsInvalidDeclaration => clang.isInvalidDeclaration(this) != 0; - public bool IsListInitialization => clangsharp.Cursor_getIsListInitialization(this) != 0; + public bool IsListInitialization => clangsharp.Cursor_getIsListInitialization(this) != 0; - public bool IsLocalVarDecl => clangsharp.Cursor_getIsLocalVarDecl(this) != 0; + public bool IsLocalVarDecl => clangsharp.Cursor_getIsLocalVarDecl(this) != 0; - public bool IsLocalVarDeclOrParm => clangsharp.Cursor_getIsLocalVarDeclOrParm(this) != 0; + public bool IsLocalVarDeclOrParm => clangsharp.Cursor_getIsLocalVarDeclOrParm(this) != 0; - public bool IsMacroBuiltIn => clang.Cursor_isMacroBuiltin(this) != 0; + public bool IsMacroBuiltIn => clang.Cursor_isMacroBuiltin(this) != 0; - public bool IsMacroFunctionLike => clang.Cursor_isMacroFunctionLike(this) != 0; + public bool IsMacroFunctionLike => clang.Cursor_isMacroFunctionLike(this) != 0; - public bool IsMemberSpecialization => clangsharp.Cursor_getIsMemberSpecialization(this) != 0; + public bool IsMemberSpecialization => clangsharp.Cursor_getIsMemberSpecialization(this) != 0; - public bool IsNegative => clangsharp.Cursor_getIsNegative(this) != 0; + public bool IsNegative => clangsharp.Cursor_getIsNegative(this) != 0; - public bool IsNonNegative => clangsharp.Cursor_getIsNonNegative(this) != 0; + public bool IsNonNegative => clangsharp.Cursor_getIsNonNegative(this) != 0; - public bool IsNoReturn => clangsharp.Cursor_getIsNoReturn(this) != 0; + public bool IsNoReturn => clangsharp.Cursor_getIsNoReturn(this) != 0; - public bool IsNothrow => clangsharp.Cursor_getIsNothrow(this) != 0; + public bool IsNothrow => clangsharp.Cursor_getIsNothrow(this) != 0; - public bool IsNull => clang.Cursor_isNull(this) != 0; + public bool IsNull => clang.Cursor_isNull(this) != 0; - public bool IsObjCOptional => clang.Cursor_isObjCOptional(this) != 0; + public bool IsObjCOptional => clang.Cursor_isObjCOptional(this) != 0; - public bool IsOverloadedOperator => clangsharp.Cursor_getIsOverloadedOperator(this) != 0; + public bool IsOverloadedOperator => clangsharp.Cursor_getIsOverloadedOperator(this) != 0; - public bool IsPackExpansion => clangsharp.Cursor_getIsPackExpansion(this) != 0; + public bool IsPackExpansion => clangsharp.Cursor_getIsPackExpansion(this) != 0; - public bool IsParameterPack => clangsharp.Cursor_getIsParameterPack(this) != 0; + public bool IsParameterPack => clangsharp.Cursor_getIsParameterPack(this) != 0; - public bool IsPartiallySubstituted => clangsharp.Cursor_getIsPartiallySubstituted(this) != 0; + public bool IsPartiallySubstituted => clangsharp.Cursor_getIsPartiallySubstituted(this) != 0; - public bool IsPotentiallyEvaluated => clangsharp.Cursor_getIsPotentiallyEvaluated(this) != 0; + public bool IsPotentiallyEvaluated => clangsharp.Cursor_getIsPotentiallyEvaluated(this) != 0; - public bool IsPreprocessing => clang.isPreprocessing(Kind) != 0; + public bool IsPreprocessing => clang.isPreprocessing(Kind) != 0; - public bool IsPure => clangsharp.Cursor_getIsPure(this) != 0; + public bool IsPure => clangsharp.Cursor_getIsPure(this) != 0; - public bool IsReference => clang.isReference(Kind) != 0; + public bool IsReference => clang.isReference(Kind) != 0; - public bool IsResultDependent => clangsharp.Cursor_getIsResultDependent(this) != 0; + public bool IsResultDependent => clangsharp.Cursor_getIsResultDependent(this) != 0; - public bool IsStdInitListInitialization => clangsharp.Cursor_getIsStdInitListInitialization(this) != 0; + public bool IsStdInitListInitialization => clangsharp.Cursor_getIsStdInitListInitialization(this) != 0; - public bool IsSigned => clangsharp.Cursor_getIsSigned(this) != 0; + public bool IsSigned => clangsharp.Cursor_getIsSigned(this) != 0; - public bool IsStatement => clang.isStatement(Kind) != 0; + public bool IsStatement => clang.isStatement(Kind) != 0; - public bool IsStatic => clangsharp.Cursor_getIsStatic(this) != 0; + public bool IsStatic => clangsharp.Cursor_getIsStatic(this) != 0; - public bool IsStaticDataMember => clangsharp.Cursor_getIsStaticDataMember(this) != 0; + public bool IsStaticDataMember => clangsharp.Cursor_getIsStaticDataMember(this) != 0; - public bool IsStrictlyPositive => clangsharp.Cursor_getIsStrictlyPositive(this) != 0; + public bool IsStrictlyPositive => clangsharp.Cursor_getIsStrictlyPositive(this) != 0; - public bool IsTemplated => clangsharp.Cursor_getIsTemplated(this) != 0; + public bool IsTemplated => clangsharp.Cursor_getIsTemplated(this) != 0; - public bool IsThisDeclarationADefinition => clangsharp.Cursor_getIsThisDeclarationADefinition(this) != 0; + public bool IsThisDeclarationADefinition => clangsharp.Cursor_getIsThisDeclarationADefinition(this) != 0; - public bool IsThrownVariableInScope => clangsharp.Cursor_getIsThrownVariableInScope(this) != 0; + public bool IsThrownVariableInScope => clangsharp.Cursor_getIsThrownVariableInScope(this) != 0; - public bool IsTranslationUnit => clang.isTranslationUnit(Kind) != 0; + public bool IsTranslationUnit => clang.isTranslationUnit(Kind) != 0; - public bool IsTransparent => clangsharp.Cursor_getIsTransparent(this) != 0; + public bool IsTransparent => clangsharp.Cursor_getIsTransparent(this) != 0; - public bool IsTypeConcept => clangsharp.Cursor_getIsTypeConcept(this) != 0; + public bool IsTypeConcept => clangsharp.Cursor_getIsTypeConcept(this) != 0; - public bool IsUnavailable => clangsharp.Cursor_getIsUnavailable(this) != 0; + public bool IsUnavailable => clangsharp.Cursor_getIsUnavailable(this) != 0; - public bool IsUnconditionallyVisible => clangsharp.Cursor_getIsUnconditionallyVisible(this) != 0; + public bool IsUnconditionallyVisible => clangsharp.Cursor_getIsUnconditionallyVisible(this) != 0; - public bool IsUnexposed => clang.isUnexposed(Kind) != 0; + public bool IsUnexposed => clang.isUnexposed(Kind) != 0; - public bool IsUnnamedBitfield => clangsharp.Cursor_getIsUnnamedBitfield(this) != 0; + public bool IsUnnamedBitfield => clangsharp.Cursor_getIsUnnamedBitfield(this) != 0; - public bool IsUnsigned => clangsharp.Cursor_getIsUnsigned(this) != 0; + public bool IsUnsigned => clangsharp.Cursor_getIsUnsigned(this) != 0; - public bool IsUnsupportedFriend => clangsharp.Cursor_getIsUnsupportedFriend(this) != 0; + public bool IsUnsupportedFriend => clangsharp.Cursor_getIsUnsupportedFriend(this) != 0; - public bool IsUserProvided => clangsharp.Cursor_getIsUserProvided(this) != 0; + public bool IsUserProvided => clangsharp.Cursor_getIsUserProvided(this) != 0; - public bool IsVariadic => clangsharp.Cursor_getIsVariadic(this) != 0; + public bool IsVariadic => clangsharp.Cursor_getIsVariadic(this) != 0; - public bool IsVirtualBase => clang.isVirtualBase(this) != 0; + public bool IsVirtualBase => clang.isVirtualBase(this) != 0; - public CXCursorKind Kind => clang.getCursorKind(this); + public CXCursorKind Kind => clang.getCursorKind(this); - public CXString KindSpelling => clang.getCursorKindSpelling(Kind); + public CXString KindSpelling => clang.getCursorKindSpelling(Kind); - public CXCursor LambdaCallOperator => clangsharp.Cursor_getLambdaCallOperator(this); + public CXCursor LambdaCallOperator => clangsharp.Cursor_getLambdaCallOperator(this); - public CXCursor LambdaContextDecl => clangsharp.Cursor_getLambdaContextDecl(this); + public CXCursor LambdaContextDecl => clangsharp.Cursor_getLambdaContextDecl(this); - public CXCursor LambdaStaticInvoker => clangsharp.Cursor_getLambdaStaticInvoker(this); + public CXCursor LambdaStaticInvoker => clangsharp.Cursor_getLambdaStaticInvoker(this); - public CXLanguageKind Language => clang.getCursorLanguage(this); + public CXLanguageKind Language => clang.getCursorLanguage(this); - public CXCursor LexicalParent => clang.getCursorLexicalParent(this); + public CXCursor LexicalParent => clang.getCursorLexicalParent(this); - public CXCursor LhsExpr => clangsharp.Cursor_getLhsExpr(this); + public CXCursor LhsExpr => clangsharp.Cursor_getLhsExpr(this); - public CXLinkageKind Linkage => clang.getCursorLinkage(this); + public CXLinkageKind Linkage => clang.getCursorLinkage(this); - public CXSourceLocation Location => clang.getCursorLocation(this); + public CXSourceLocation Location => clang.getCursorLocation(this); - public CXString Mangling => clang.Cursor_getMangling(this); + public CXString Mangling => clang.Cursor_getMangling(this); - public uint MaxAlignment => clangsharp.Cursor_getMaxAlignment(this); + public uint MaxAlignment => clangsharp.Cursor_getMaxAlignment(this); - public CXModule Module => (CXModule)clang.Cursor_getModule(this); + public CXModule Module => (CXModule)clang.Cursor_getModule(this); - public CXCursor MostRecentDecl => clangsharp.Cursor_getMostRecentDecl(this); + public CXCursor MostRecentDecl => clangsharp.Cursor_getMostRecentDecl(this); - public CXString Name => clangsharp.Cursor_getName(this); + public CXString Name => clangsharp.Cursor_getName(this); - public CXCursor NextDeclInContext => clangsharp.Cursor_getNextDeclInContext(this); + public CXCursor NextDeclInContext => clangsharp.Cursor_getNextDeclInContext(this); - public CXCursor NextSwitchCase => clangsharp.Cursor_getNextSwitchCase(this); + public CXCursor NextSwitchCase => clangsharp.Cursor_getNextSwitchCase(this); - public CXCursor NominatedBaseClass => clangsharp.Cursor_getNominatedBaseClass(this); + public CXCursor NominatedBaseClass => clangsharp.Cursor_getNominatedBaseClass(this); - public CXCursor NominatedBaseClassShadowDecl => clangsharp.Cursor_getNominatedBaseClassShadowDecl(this); + public CXCursor NominatedBaseClassShadowDecl => clangsharp.Cursor_getNominatedBaseClassShadowDecl(this); - public CXCursor NonClosureContext => clangsharp.Cursor_getNonClosureContext(this); + public CXCursor NonClosureContext => clangsharp.Cursor_getNonClosureContext(this); - public int NumAssociatedConstraints => clangsharp.Cursor_getNumAssociatedConstraints(this); + public int NumAssociatedConstraints => clangsharp.Cursor_getNumAssociatedConstraints(this); - public int NumArguments => clangsharp.Cursor_getNumArguments(this); + public int NumArguments => clangsharp.Cursor_getNumArguments(this); - public int NumAssocs => clangsharp.Cursor_getNumAssocs(this); + public int NumAssocs => clangsharp.Cursor_getNumAssocs(this); - public int NumAttrs => clangsharp.Cursor_getNumAttrs(this); + public int NumAttrs => clangsharp.Cursor_getNumAttrs(this); - public int NumBases => clangsharp.Cursor_getNumBases(this); + public int NumBases => clangsharp.Cursor_getNumBases(this); - public int NumBindings => clangsharp.Cursor_getNumBindings(this); + public int NumBindings => clangsharp.Cursor_getNumBindings(this); - public int NumCaptures => clangsharp.Cursor_getNumCaptures(this); + public int NumCaptures => clangsharp.Cursor_getNumCaptures(this); - public int NumChildren => clangsharp.Cursor_getNumChildren(this); + public int NumChildren => clangsharp.Cursor_getNumChildren(this); - public int NumCtors => clangsharp.Cursor_getNumCtors(this); + public int NumCtors => clangsharp.Cursor_getNumCtors(this); - public int NumDecls => clangsharp.Cursor_getNumDecls(this); + public int NumDecls => clangsharp.Cursor_getNumDecls(this); - public int NumEnumerators => clangsharp.Cursor_getNumEnumerators(this); + public int NumEnumerators => clangsharp.Cursor_getNumEnumerators(this); - public int NumExpansionTypes => clangsharp.Cursor_getNumExpansionTypes(this); + public int NumExpansionTypes => clangsharp.Cursor_getNumExpansionTypes(this); - public int NumExprs => clangsharp.Cursor_getNumExprs(this); + public int NumExprs => clangsharp.Cursor_getNumExprs(this); - public int NumFields => clangsharp.Cursor_getNumFields(this); + public int NumFields => clangsharp.Cursor_getNumFields(this); - public int NumFriends => clangsharp.Cursor_getNumFriends(this); + public int NumFriends => clangsharp.Cursor_getNumFriends(this); - public int NumMethods => clangsharp.Cursor_getNumMethods(this); + public int NumMethods => clangsharp.Cursor_getNumMethods(this); - public uint NumOverloadedDecls => clang.getNumOverloadedDecls(this); + public uint NumOverloadedDecls => clang.getNumOverloadedDecls(this); - public int NumProtocols => clangsharp.Cursor_getNumProtocols(this); + public int NumProtocols => clangsharp.Cursor_getNumProtocols(this); - public int NumSpecializations => clangsharp.Cursor_getNumSpecializations(this); + public int NumSpecializations => clangsharp.Cursor_getNumSpecializations(this); - public int NumTemplateArguments => clangsharp.Cursor_getNumTemplateArguments(this); + public int NumTemplateArguments => clangsharp.Cursor_getNumTemplateArguments(this); - public int NumTemplateParameterLists => clangsharp.Cursor_getNumTemplateParameterLists(this); + public int NumTemplateParameterLists => clangsharp.Cursor_getNumTemplateParameterLists(this); - public int NumVBases => clangsharp.Cursor_getNumVBases(this); + public int NumVBases => clangsharp.Cursor_getNumVBases(this); - public CXObjCDeclQualifierKind ObjCDeclQualifiers => (CXObjCDeclQualifierKind)clang.Cursor_getObjCDeclQualifiers(this); + public CXObjCDeclQualifierKind ObjCDeclQualifiers => (CXObjCDeclQualifierKind)clang.Cursor_getObjCDeclQualifiers(this); - public CXStringSet* ObjCManglings => clang.Cursor_getObjCManglings(this); + public CXStringSet* ObjCManglings => clang.Cursor_getObjCManglings(this); - public CXString ObjCPropertyGetterName => clang.Cursor_getObjCPropertyGetterName(this); + public CXString ObjCPropertyGetterName => clang.Cursor_getObjCPropertyGetterName(this); - public CXString ObjCPropertySetterName => clang.Cursor_getObjCPropertySetterName(this); + public CXString ObjCPropertySetterName => clang.Cursor_getObjCPropertySetterName(this); - public int ObjCSelectorIndex => clang.Cursor_getObjCSelectorIndex(this); + public int ObjCSelectorIndex => clang.Cursor_getObjCSelectorIndex(this); - public long OffsetOfField => clang.Cursor_getOffsetOfField(this); + public long OffsetOfField => clang.Cursor_getOffsetOfField(this); - public CXCursor OpaqueValue => clangsharp.Cursor_getOpaqueValue(this); + public CXCursor OpaqueValue => clangsharp.Cursor_getOpaqueValue(this); - public CXType OriginalType => clangsharp.Cursor_getOriginalType(this); + public CXType OriginalType => clangsharp.Cursor_getOriginalType(this); - public CX_OverloadedOperatorKind OverloadedOperatorKind => clangsharp.Cursor_getOverloadedOperatorKind(this); + public CX_OverloadedOperatorKind OverloadedOperatorKind => clangsharp.Cursor_getOverloadedOperatorKind(this); - public ReadOnlySpan OverriddenCursors + public ReadOnlySpan OverriddenCursors + { + get { - get - { - CXCursor* overridden; - uint numOverridden; + CXCursor* overridden; + uint numOverridden; - clang.getOverriddenCursors(this, &overridden, &numOverridden); - return new ReadOnlySpan(overridden, (int)numOverridden); - } + clang.getOverriddenCursors(this, &overridden, &numOverridden); + return new ReadOnlySpan(overridden, (int)numOverridden); } + } - public int PackLength => clangsharp.Cursor_getPackLength(this); + public int PackLength => clangsharp.Cursor_getPackLength(this); - public CXCursor ParentFunctionOrMethod => clangsharp.Cursor_getParentFunctionOrMethod(this); + public CXCursor ParentFunctionOrMethod => clangsharp.Cursor_getParentFunctionOrMethod(this); - public CXComment ParsedComment => clang.Cursor_getParsedComment(this); + public CXComment ParsedComment => clang.Cursor_getParsedComment(this); - public CXCursor PlaceholderTypeConstraint => clangsharp.Cursor_getPlaceholderTypeConstraint(this); + public CXCursor PlaceholderTypeConstraint => clangsharp.Cursor_getPlaceholderTypeConstraint(this); - public CXCursor PreviousDecl => clangsharp.Cursor_getPreviousDecl(this); + public CXCursor PreviousDecl => clangsharp.Cursor_getPreviousDecl(this); - public CXCursor PrimaryTemplate => clangsharp.Cursor_getPrimaryTemplate(this); + public CXCursor PrimaryTemplate => clangsharp.Cursor_getPrimaryTemplate(this); - public CXPrintingPolicy PrintingPolicy => (CXPrintingPolicy)clang.getCursorPrintingPolicy(this); + public CXPrintingPolicy PrintingPolicy => (CXPrintingPolicy)clang.getCursorPrintingPolicy(this); - public CXString RawCommentText => clang.Cursor_getRawCommentText(this); + public CXString RawCommentText => clang.Cursor_getRawCommentText(this); - public CXType ReceiverType => !IsExpression ? default : clang.Cursor_getReceiverType(this); + public CXType ReceiverType => !IsExpression ? default : clang.Cursor_getReceiverType(this); - public CXCursor RedeclContext => clangsharp.Cursor_getRedeclContext(this); + public CXCursor RedeclContext => clangsharp.Cursor_getRedeclContext(this); - public CXCursor Referenced => clangsharp.Cursor_getReferenced(this); + public CXCursor Referenced => clangsharp.Cursor_getReferenced(this); - public bool RequiresZeroInitialization => clangsharp.Cursor_getRequiresZeroInitialization(this) != 0; + public bool RequiresZeroInitialization => clangsharp.Cursor_getRequiresZeroInitialization(this) != 0; - public int ResultIndex => clangsharp.Cursor_getResultIndex(this); + public int ResultIndex => clangsharp.Cursor_getResultIndex(this); - public CXType ResultType => clang.getCursorResultType(this); + public CXType ResultType => clang.getCursorResultType(this); - public CXType ReturnType => clangsharp.Cursor_getReturnType(this); + public CXType ReturnType => clangsharp.Cursor_getReturnType(this); - public CXCursor RhsExpr => clangsharp.Cursor_getRhsExpr(this); + public CXCursor RhsExpr => clangsharp.Cursor_getRhsExpr(this); - public CXCursor SemanticParent => clang.getCursorSemanticParent(this); + public CXCursor SemanticParent => clang.getCursorSemanticParent(this); - public bool ShouldCopy => clangsharp.Cursor_getShouldCopy(this) != 0; + public bool ShouldCopy => clangsharp.Cursor_getShouldCopy(this) != 0; - public CXSourceRange SourceRange => clangsharp.Cursor_getSourceRange(this); + public CXSourceRange SourceRange => clangsharp.Cursor_getSourceRange(this); - public CXCursor SpecializedCursorTemplate => clang.getSpecializedCursorTemplate(this); + public CXCursor SpecializedCursorTemplate => clang.getSpecializedCursorTemplate(this); - public CXString Spelling => clang.getCursorSpelling(this); + public CXString Spelling => clang.getCursorSpelling(this); - public CX_StmtClass StmtClass => clangsharp.Cursor_getStmtClass(this); + public CX_StmtClass StmtClass => clangsharp.Cursor_getStmtClass(this); - public string StmtClassSpelling + public string StmtClassSpelling + { + get { - get + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstAsmStmt == CX_StmtClass.CX_StmtClass_GCCAsmStmt); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastAsmStmt == CX_StmtClass.CX_StmtClass_MSAsmStmt); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstOMPLoopDirective == CX_StmtClass.CX_StmtClass_OMPDistributeDirective); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastOMPLoopDirective == CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstOMPExecutableDirective == CX_StmtClass.CX_StmtClass_OMPAtomicDirective); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastOMPExecutableDirective == CX_StmtClass.CX_StmtClass_OMPTeamsDirective); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstSwitchCase == CX_StmtClass.CX_StmtClass_CaseStmt); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastSwitchCase == CX_StmtClass.CX_StmtClass_DefaultStmt); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstAbstractConditionalOperator == CX_StmtClass.CX_StmtClass_BinaryConditionalOperator); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastAbstractConditionalOperator == CX_StmtClass.CX_StmtClass_ConditionalOperator); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstBinaryOperator == CX_StmtClass.CX_StmtClass_BinaryOperator); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastBinaryOperator == CX_StmtClass.CX_StmtClass_CompoundAssignOperator); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCXXConstructExpr == CX_StmtClass.CX_StmtClass_CXXConstructExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastCXXConstructExpr == CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCallExpr == CX_StmtClass.CX_StmtClass_CallExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastCallExpr == CX_StmtClass.CX_StmtClass_UserDefinedLiteral); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCXXNamedCastExpr == CX_StmtClass.CX_StmtClass_CXXAddrspaceCastExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastCXXNamedCastExpr == CX_StmtClass.CX_StmtClass_CXXStaticCastExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstExplicitCastExpr == CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastExplicitCastExpr == CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCastExpr == CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastCastExpr == CX_StmtClass.CX_StmtClass_ImplicitCastExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCoroutineSuspendExpr == CX_StmtClass.CX_StmtClass_CoawaitExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastCoroutineSuspendExpr == CX_StmtClass.CX_StmtClass_CoyieldExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstFullExpr == CX_StmtClass.CX_StmtClass_ConstantExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastFullExpr == CX_StmtClass.CX_StmtClass_ExprWithCleanups); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstOverloadExpr == CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastOverloadExpr == CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstExpr == CX_StmtClass.CX_StmtClass_BinaryConditionalOperator); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastExpr == CX_StmtClass.CX_StmtClass_VAArgExpr); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstValueStmt == CX_StmtClass.CX_StmtClass_AttributedStmt); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastValueStmt == CX_StmtClass.CX_StmtClass_LabelStmt); + Debug.Assert(CX_StmtClass.CX_StmtClass_FirstStmt == CX_StmtClass.CX_StmtClass_GCCAsmStmt); + Debug.Assert(CX_StmtClass.CX_StmtClass_LastStmt == CX_StmtClass.CX_StmtClass_WhileStmt); + + return StmtClass switch { - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstAsmStmt == CX_StmtClass.CX_StmtClass_GCCAsmStmt); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastAsmStmt == CX_StmtClass.CX_StmtClass_MSAsmStmt); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstOMPLoopDirective == CX_StmtClass.CX_StmtClass_OMPDistributeDirective); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastOMPLoopDirective == CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstOMPExecutableDirective == CX_StmtClass.CX_StmtClass_OMPAtomicDirective); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastOMPExecutableDirective == CX_StmtClass.CX_StmtClass_OMPTeamsDirective); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstSwitchCase == CX_StmtClass.CX_StmtClass_CaseStmt); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastSwitchCase == CX_StmtClass.CX_StmtClass_DefaultStmt); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstAbstractConditionalOperator == CX_StmtClass.CX_StmtClass_BinaryConditionalOperator); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastAbstractConditionalOperator == CX_StmtClass.CX_StmtClass_ConditionalOperator); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstBinaryOperator == CX_StmtClass.CX_StmtClass_BinaryOperator); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastBinaryOperator == CX_StmtClass.CX_StmtClass_CompoundAssignOperator); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCXXConstructExpr == CX_StmtClass.CX_StmtClass_CXXConstructExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastCXXConstructExpr == CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCallExpr == CX_StmtClass.CX_StmtClass_CallExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastCallExpr == CX_StmtClass.CX_StmtClass_UserDefinedLiteral); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCXXNamedCastExpr == CX_StmtClass.CX_StmtClass_CXXAddrspaceCastExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastCXXNamedCastExpr == CX_StmtClass.CX_StmtClass_CXXStaticCastExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstExplicitCastExpr == CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastExplicitCastExpr == CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCastExpr == CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastCastExpr == CX_StmtClass.CX_StmtClass_ImplicitCastExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstCoroutineSuspendExpr == CX_StmtClass.CX_StmtClass_CoawaitExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastCoroutineSuspendExpr == CX_StmtClass.CX_StmtClass_CoyieldExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstFullExpr == CX_StmtClass.CX_StmtClass_ConstantExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastFullExpr == CX_StmtClass.CX_StmtClass_ExprWithCleanups); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstOverloadExpr == CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastOverloadExpr == CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstExpr == CX_StmtClass.CX_StmtClass_BinaryConditionalOperator); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastExpr == CX_StmtClass.CX_StmtClass_VAArgExpr); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstValueStmt == CX_StmtClass.CX_StmtClass_AttributedStmt); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastValueStmt == CX_StmtClass.CX_StmtClass_LabelStmt); - Debug.Assert(CX_StmtClass.CX_StmtClass_FirstStmt == CX_StmtClass.CX_StmtClass_GCCAsmStmt); - Debug.Assert(CX_StmtClass.CX_StmtClass_LastStmt == CX_StmtClass.CX_StmtClass_WhileStmt); - - return StmtClass switch - { - CX_StmtClass.CX_StmtClass_Invalid => "Invalid", - CX_StmtClass.CX_StmtClass_GCCAsmStmt => "GCCAsmStmt", - CX_StmtClass.CX_StmtClass_MSAsmStmt => "MSAsmStmt", - CX_StmtClass.CX_StmtClass_BreakStmt => "BreakStmt", - CX_StmtClass.CX_StmtClass_CXXCatchStmt => "CXXCatchStmt", - CX_StmtClass.CX_StmtClass_CXXForRangeStmt => "CXXForRangeStmt", - CX_StmtClass.CX_StmtClass_CXXTryStmt => "CXXTryStmt", - CX_StmtClass.CX_StmtClass_CapturedStmt => "CapturedStmt", - CX_StmtClass.CX_StmtClass_CompoundStmt => "CompoundStmt", - CX_StmtClass.CX_StmtClass_ContinueStmt => "ContinueStmt", - CX_StmtClass.CX_StmtClass_CoreturnStmt => "CoreturnStmt", - CX_StmtClass.CX_StmtClass_CoroutineBodyStmt => "CoroutineBodyStmt", - CX_StmtClass.CX_StmtClass_DeclStmt => "DeclStmt", - CX_StmtClass.CX_StmtClass_DoStmt => "DoStmt", - CX_StmtClass.CX_StmtClass_ForStmt => "ForStmt", - CX_StmtClass.CX_StmtClass_GotoStmt => "GotoStmt", - CX_StmtClass.CX_StmtClass_IfStmt => "IfStmt", - CX_StmtClass.CX_StmtClass_IndirectGotoStmt => "IndirectGotoStmt", - CX_StmtClass.CX_StmtClass_MSDependentExistsStmt => "MSDependentExistsStmt", - CX_StmtClass.CX_StmtClass_NullStmt => "NullStmt", - CX_StmtClass.CX_StmtClass_OMPAtomicDirective => "OMPAtomicDirective", - CX_StmtClass.CX_StmtClass_OMPBarrierDirective => "OMPBarrierDirective", - CX_StmtClass.CX_StmtClass_OMPCancelDirective => "OMPCancelDirective", - CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective => "OMPCancellationPointDirective", - CX_StmtClass.CX_StmtClass_OMPCriticalDirective => "OMPCriticalDirective", - CX_StmtClass.CX_StmtClass_OMPDepobjDirective => "OMPDepobjDirective", - CX_StmtClass.CX_StmtClass_OMPFlushDirective => "OMPFlushDirective", - CX_StmtClass.CX_StmtClass_OMPDistributeDirective => "OMPDistributeDirective", - CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective => "OMPDistributeParallelForDirective", - CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective => "OMPDistributeParallelForSimdDirective", - CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective => "OMPDistributeSimdDirective", - CX_StmtClass.CX_StmtClass_OMPForDirective => "OMPForDirective", - CX_StmtClass.CX_StmtClass_OMPForSimdDirective => "OMPForSimdDirective", - CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopDirective => "OMPMasterTaskLoopDirective", - CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopSimdDirective => "OMPMasterTaskLoopSimdDirective", - CX_StmtClass.CX_StmtClass_OMPParallelForDirective => "OMPParallelForDirective", - CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective => "OMPParallelForSimdDirective", - CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopDirective => "OMPParallelMasterTaskLoopDirective", - CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective => "OMPParallelMasterTaskLoopSimdDirective", - CX_StmtClass.CX_StmtClass_OMPSimdDirective => "OMPSimdDirective", - CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective => "OMPTargetParallelForSimdDirective", - CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective => "OMPTargetSimdDirective", - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective => "OMPTargetTeamsDistributeDirective", - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective => "OMPTargetTeamsDistributeParallelForDirective", - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective => "OMPTargetTeamsDistributeParallelForSimdDirective", - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective => "OMPTargetTeamsDistributeSimdDirective", - CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective => "OMPTaskLoopDirective", - CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective => "OMPTaskLoopSimdDirective", - CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective => "OMPTeamsDistributeDirective", - CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective => "OMPTeamsDistributeParallelForDirective", - CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective => "OMPTeamsDistributeParallelForSimdDirective", - CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective => "OMPTeamsDistributeSimdDirective", - CX_StmtClass.CX_StmtClass_OMPMasterDirective => "OMPMasterDirective", - CX_StmtClass.CX_StmtClass_OMPOrderedDirective => "OMPOrderedDirective", - CX_StmtClass.CX_StmtClass_OMPParallelDirective => "OMPParallelDirective", - CX_StmtClass.CX_StmtClass_OMPParallelMasterDirective => "OMPParallelMasterDirective", - CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective => "OMPParallelSectionsDirective", - CX_StmtClass.CX_StmtClass_OMPScanDirective => "OMPScanDirective", - CX_StmtClass.CX_StmtClass_OMPSectionDirective => "OMPSectionDirective", - CX_StmtClass.CX_StmtClass_OMPSectionsDirective => "OMPSectionsDirective", - CX_StmtClass.CX_StmtClass_OMPSingleDirective => "OMPSingleDirective", - CX_StmtClass.CX_StmtClass_OMPTargetDataDirective => "OMPTargetDataDirective", - CX_StmtClass.CX_StmtClass_OMPTargetDirective => "OMPTargetDirective", - CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective => "OMPTargetEnterDataDirective", - CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective => "OMPTargetExitDataDirective", - CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective => "OMPTargetParallelDirective", - CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective => "OMPTargetParallelForDirective", - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective => "OMPTargetTeamsDirective", - CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective => "OMPTargetUpdateDirective", - CX_StmtClass.CX_StmtClass_OMPTaskDirective => "OMPTaskDirective", - CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective => "OMPTaskgroupDirective", - CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective => "OMPTaskwaitDirective", - CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective => "OMPTaskyieldDirective", - CX_StmtClass.CX_StmtClass_OMPTeamsDirective => "OMPTeamsDirective", - CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt => "ObjCAtCatchStmt", - CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt => "ObjCAtFinallyStmt", - CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt => "ObjCAtSynchronizedStmt", - CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt => "ObjCAtThrowStmt", - CX_StmtClass.CX_StmtClass_ObjCAtTryStmt => "ObjCAtTryStmt", - CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt => "ObjCAutoreleasePoolStmt", - CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt => "ObjCForCollectionStmt", - CX_StmtClass.CX_StmtClass_ReturnStmt => "ReturnStmt", - CX_StmtClass.CX_StmtClass_SEHExceptStmt => "SEHExceptStmt", - CX_StmtClass.CX_StmtClass_SEHFinallyStmt => "SEHFinallyStmt", - CX_StmtClass.CX_StmtClass_SEHLeaveStmt => "SEHLeaveStmt", - CX_StmtClass.CX_StmtClass_SEHTryStmt => "SEHTryStmt", - CX_StmtClass.CX_StmtClass_CaseStmt => "CaseStmt", - CX_StmtClass.CX_StmtClass_DefaultStmt => "DefaultStmt", - CX_StmtClass.CX_StmtClass_SwitchStmt => "SwitchStmt", - CX_StmtClass.CX_StmtClass_AttributedStmt => "AttributedStmt", - CX_StmtClass.CX_StmtClass_BinaryConditionalOperator => "BinaryConditionalOperator", - CX_StmtClass.CX_StmtClass_ConditionalOperator => "ConditionalOperator", - CX_StmtClass.CX_StmtClass_AddrLabelExpr => "AddrLabelExpr", - CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr => "ArrayInitIndexExpr", - CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr => "ArrayInitLoopExpr", - CX_StmtClass.CX_StmtClass_ArraySubscriptExpr => "ArraySubscriptExpr", - CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr => "ArrayTypeTraitExpr", - CX_StmtClass.CX_StmtClass_AsTypeExpr => "AsTypeExpr", - CX_StmtClass.CX_StmtClass_AtomicExpr => "AtomicExpr", - CX_StmtClass.CX_StmtClass_BinaryOperator => "BinaryOperator", - CX_StmtClass.CX_StmtClass_CompoundAssignOperator => "CompoundAssignOperator", - CX_StmtClass.CX_StmtClass_BlockExpr => "BlockExpr", - CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr => "CXXBindTemporaryExpr", - CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr => "CXXBoolLiteralExpr", - CX_StmtClass.CX_StmtClass_CXXConstructExpr => "CXXConstructExpr", - CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr => "CXXTemporaryObjectExpr", - CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr => "CXXDefaultArgExpr", - CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr => "CXXDefaultInitExpr", - CX_StmtClass.CX_StmtClass_CXXDeleteExpr => "CXXDeleteExpr", - CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr => "CXXDependentScopeMemberExpr", - CX_StmtClass.CX_StmtClass_CXXFoldExpr => "CXXFoldExpr", - CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr => "CXXInheritedCtorInitExpr", - CX_StmtClass.CX_StmtClass_CXXNewExpr => "CXXNewExpr", - CX_StmtClass.CX_StmtClass_CXXNoexceptExpr => "CXXNoexceptExpr", - CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr => "CXXNullPtrLiteralExpr", - CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr => "CXXPseudoDestructorExpr", - CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator => "CXXRewrittenBinaryOperator", - CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr => "CXXScalarValueInitExpr", - CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr => "CXXStdInitializerListExpr", - CX_StmtClass.CX_StmtClass_CXXThisExpr => "CXXThisExpr", - CX_StmtClass.CX_StmtClass_CXXThrowExpr => "CXXThrowExpr", - CX_StmtClass.CX_StmtClass_CXXTypeidExpr => "CXXTypeidExpr", - CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr => "CXXUnresolvedConstructExpr", - CX_StmtClass.CX_StmtClass_CXXUuidofExpr => "CXXUuidofExpr", - CX_StmtClass.CX_StmtClass_CallExpr => "CallExpr", - CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr => "CUDAKernelCallExpr", - CX_StmtClass.CX_StmtClass_CXXMemberCallExpr => "CXXMemberCallExpr", - CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr => "CXXOperatorCallExpr", - CX_StmtClass.CX_StmtClass_UserDefinedLiteral => "UserDefinedLiteral", - CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr => "BuiltinBitCastExpr", - CX_StmtClass.CX_StmtClass_CStyleCastExpr => "CStyleCastExpr", - CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr => "CXXFunctionalCastExpr", - CX_StmtClass.CX_StmtClass_CXXAddrspaceCastExpr => "CXXAddrspaceCastExpr", - CX_StmtClass.CX_StmtClass_CXXConstCastExpr => "CXXConstCastExpr", - CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr => "CXXDynamicCastExpr", - CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr => "CXXReinterpretCastExpr", - CX_StmtClass.CX_StmtClass_CXXStaticCastExpr => "CXXStaticCastExpr", - CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr => "ObjCBridgedCastExpr", - CX_StmtClass.CX_StmtClass_ImplicitCastExpr => "ImplicitCastExpr", - CX_StmtClass.CX_StmtClass_CharacterLiteral => "CharacterLiteral", - CX_StmtClass.CX_StmtClass_ChooseExpr => "ChooseExpr", - CX_StmtClass.CX_StmtClass_CompoundLiteralExpr => "CompoundLiteralExpr", - CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr => "ConceptSpecializationExpr", - CX_StmtClass.CX_StmtClass_ConvertVectorExpr => "ConvertVectorExpr", - CX_StmtClass.CX_StmtClass_CoawaitExpr => "CoawaitExpr", - CX_StmtClass.CX_StmtClass_CoyieldExpr => "CoyieldExpr", - CX_StmtClass.CX_StmtClass_DeclRefExpr => "DeclRefExpr", - CX_StmtClass.CX_StmtClass_DependentCoawaitExpr => "DependentCoawaitExpr", - CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr => "DependentScopeDeclRefExpr", - CX_StmtClass.CX_StmtClass_DesignatedInitExpr => "DesignatedInitExpr", - CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr => "DesignatedInitUpdateExpr", - CX_StmtClass.CX_StmtClass_ExpressionTraitExpr => "ExpressionTraitExpr", - CX_StmtClass.CX_StmtClass_ExtVectorElementExpr => "ExtVectorElementExpr", - CX_StmtClass.CX_StmtClass_FixedPointLiteral => "FixedPointLiteral", - CX_StmtClass.CX_StmtClass_FloatingLiteral => "FloatingLiteral", - CX_StmtClass.CX_StmtClass_ConstantExpr => "ConstantExpr", - CX_StmtClass.CX_StmtClass_ExprWithCleanups => "ExprWithCleanups", - CX_StmtClass.CX_StmtClass_FunctionParmPackExpr => "FunctionParmPackExpr", - CX_StmtClass.CX_StmtClass_GNUNullExpr => "GNUNullExpr", - CX_StmtClass.CX_StmtClass_GenericSelectionExpr => "GenericSelectionExpr", - CX_StmtClass.CX_StmtClass_ImaginaryLiteral => "ImaginaryLiteral", - CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr => "ImplicitValueInitExpr", - CX_StmtClass.CX_StmtClass_InitListExpr => "InitListExpr", - CX_StmtClass.CX_StmtClass_IntegerLiteral => "IntegerLiteral", - CX_StmtClass.CX_StmtClass_LambdaExpr => "LambdaExpr", - CX_StmtClass.CX_StmtClass_MSPropertyRefExpr => "MSPropertyRefExpr", - CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr => "MSPropertySubscriptExpr", - CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr => "MaterializeTemporaryExpr", - CX_StmtClass.CX_StmtClass_MatrixSubscriptExpr => "MatrixSubscriptExpr", - CX_StmtClass.CX_StmtClass_MemberExpr => "MemberExpr", - CX_StmtClass.CX_StmtClass_NoInitExpr => "NoInitExpr", - CX_StmtClass.CX_StmtClass_OMPArraySectionExpr => "OMPArraySectionExpr", - CX_StmtClass.CX_StmtClass_OMPArrayShapingExpr => "OMPArrayShapingExpr", - CX_StmtClass.CX_StmtClass_OMPIteratorExpr => "OMPIteratorExpr", - CX_StmtClass.CX_StmtClass_ObjCArrayLiteral => "ObjCArrayLiteral", - CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr => "ObjCAvailabilityCheckExpr", - CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr => "ObjCBoolLiteralExpr", - CX_StmtClass.CX_StmtClass_ObjCBoxedExpr => "ObjCBoxedExpr", - CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral => "ObjCDictionaryLiteral", - CX_StmtClass.CX_StmtClass_ObjCEncodeExpr => "ObjCEncodeExpr", - CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr => "ObjCIndirectCopyRestoreExpr", - CX_StmtClass.CX_StmtClass_ObjCIsaExpr => "ObjCIsaExpr", - CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr => "ObjCIvarRefExpr", - CX_StmtClass.CX_StmtClass_ObjCMessageExpr => "ObjCMessageExpr", - CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr => "ObjCPropertyRefExpr", - CX_StmtClass.CX_StmtClass_ObjCProtocolExpr => "ObjCProtocolExpr", - CX_StmtClass.CX_StmtClass_ObjCSelectorExpr => "ObjCSelectorExpr", - CX_StmtClass.CX_StmtClass_ObjCStringLiteral => "ObjCStringLiteral", - CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr => "ObjCSubscriptRefExpr", - CX_StmtClass.CX_StmtClass_OffsetOfExpr => "OffsetOfExpr", - CX_StmtClass.CX_StmtClass_OpaqueValueExpr => "OpaqueValueExpr", - CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr => "UnresolvedLookupExpr", - CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr => "UnresolvedMemberExpr", - CX_StmtClass.CX_StmtClass_PackExpansionExpr => "PackExpansionExpr", - CX_StmtClass.CX_StmtClass_ParenExpr => "ParenExpr", - CX_StmtClass.CX_StmtClass_ParenListExpr => "ParenListExpr", - CX_StmtClass.CX_StmtClass_PredefinedExpr => "PredefinedExpr", - CX_StmtClass.CX_StmtClass_PseudoObjectExpr => "PseudoObjectExpr", - CX_StmtClass.CX_StmtClass_RecoveryExpr => "RecoveryExpr", - CX_StmtClass.CX_StmtClass_RequiresExpr => "RequiresExpr", - CX_StmtClass.CX_StmtClass_ShuffleVectorExpr => "ShuffleVectorExpr", - CX_StmtClass.CX_StmtClass_SizeOfPackExpr => "SizeOfPackExpr", - CX_StmtClass.CX_StmtClass_SourceLocExpr => "SourceLocExpr", - CX_StmtClass.CX_StmtClass_StmtExpr => "StmtExpr", - CX_StmtClass.CX_StmtClass_StringLiteral => "StringLiteral", - CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr => "SubstNonTypeTemplateParmExpr", - CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr => "SubstNonTypeTemplateParmPackExpr", - CX_StmtClass.CX_StmtClass_TypeTraitExpr => "TypeTraitExpr", - CX_StmtClass.CX_StmtClass_TypoExpr => "TypoExpr", - CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr => "UnaryExprOrTypeTraitExpr", - CX_StmtClass.CX_StmtClass_UnaryOperator => "UnaryOperator", - CX_StmtClass.CX_StmtClass_VAArgExpr => "VAArgExpr", - CX_StmtClass.CX_StmtClass_LabelStmt => "LabelStmt", - CX_StmtClass.CX_StmtClass_WhileStmt => "WhileStmt", - _ => StmtClass.ToString()[13..], - }; - } + CX_StmtClass.CX_StmtClass_Invalid => "Invalid", + CX_StmtClass.CX_StmtClass_GCCAsmStmt => "GCCAsmStmt", + CX_StmtClass.CX_StmtClass_MSAsmStmt => "MSAsmStmt", + CX_StmtClass.CX_StmtClass_BreakStmt => "BreakStmt", + CX_StmtClass.CX_StmtClass_CXXCatchStmt => "CXXCatchStmt", + CX_StmtClass.CX_StmtClass_CXXForRangeStmt => "CXXForRangeStmt", + CX_StmtClass.CX_StmtClass_CXXTryStmt => "CXXTryStmt", + CX_StmtClass.CX_StmtClass_CapturedStmt => "CapturedStmt", + CX_StmtClass.CX_StmtClass_CompoundStmt => "CompoundStmt", + CX_StmtClass.CX_StmtClass_ContinueStmt => "ContinueStmt", + CX_StmtClass.CX_StmtClass_CoreturnStmt => "CoreturnStmt", + CX_StmtClass.CX_StmtClass_CoroutineBodyStmt => "CoroutineBodyStmt", + CX_StmtClass.CX_StmtClass_DeclStmt => "DeclStmt", + CX_StmtClass.CX_StmtClass_DoStmt => "DoStmt", + CX_StmtClass.CX_StmtClass_ForStmt => "ForStmt", + CX_StmtClass.CX_StmtClass_GotoStmt => "GotoStmt", + CX_StmtClass.CX_StmtClass_IfStmt => "IfStmt", + CX_StmtClass.CX_StmtClass_IndirectGotoStmt => "IndirectGotoStmt", + CX_StmtClass.CX_StmtClass_MSDependentExistsStmt => "MSDependentExistsStmt", + CX_StmtClass.CX_StmtClass_NullStmt => "NullStmt", + CX_StmtClass.CX_StmtClass_OMPAtomicDirective => "OMPAtomicDirective", + CX_StmtClass.CX_StmtClass_OMPBarrierDirective => "OMPBarrierDirective", + CX_StmtClass.CX_StmtClass_OMPCancelDirective => "OMPCancelDirective", + CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective => "OMPCancellationPointDirective", + CX_StmtClass.CX_StmtClass_OMPCriticalDirective => "OMPCriticalDirective", + CX_StmtClass.CX_StmtClass_OMPDepobjDirective => "OMPDepobjDirective", + CX_StmtClass.CX_StmtClass_OMPFlushDirective => "OMPFlushDirective", + CX_StmtClass.CX_StmtClass_OMPDistributeDirective => "OMPDistributeDirective", + CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective => "OMPDistributeParallelForDirective", + CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective => "OMPDistributeParallelForSimdDirective", + CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective => "OMPDistributeSimdDirective", + CX_StmtClass.CX_StmtClass_OMPForDirective => "OMPForDirective", + CX_StmtClass.CX_StmtClass_OMPForSimdDirective => "OMPForSimdDirective", + CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopDirective => "OMPMasterTaskLoopDirective", + CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopSimdDirective => "OMPMasterTaskLoopSimdDirective", + CX_StmtClass.CX_StmtClass_OMPParallelForDirective => "OMPParallelForDirective", + CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective => "OMPParallelForSimdDirective", + CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopDirective => "OMPParallelMasterTaskLoopDirective", + CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective => "OMPParallelMasterTaskLoopSimdDirective", + CX_StmtClass.CX_StmtClass_OMPSimdDirective => "OMPSimdDirective", + CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective => "OMPTargetParallelForSimdDirective", + CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective => "OMPTargetSimdDirective", + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective => "OMPTargetTeamsDistributeDirective", + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective => "OMPTargetTeamsDistributeParallelForDirective", + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective => "OMPTargetTeamsDistributeParallelForSimdDirective", + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective => "OMPTargetTeamsDistributeSimdDirective", + CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective => "OMPTaskLoopDirective", + CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective => "OMPTaskLoopSimdDirective", + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective => "OMPTeamsDistributeDirective", + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective => "OMPTeamsDistributeParallelForDirective", + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective => "OMPTeamsDistributeParallelForSimdDirective", + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective => "OMPTeamsDistributeSimdDirective", + CX_StmtClass.CX_StmtClass_OMPMasterDirective => "OMPMasterDirective", + CX_StmtClass.CX_StmtClass_OMPOrderedDirective => "OMPOrderedDirective", + CX_StmtClass.CX_StmtClass_OMPParallelDirective => "OMPParallelDirective", + CX_StmtClass.CX_StmtClass_OMPParallelMasterDirective => "OMPParallelMasterDirective", + CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective => "OMPParallelSectionsDirective", + CX_StmtClass.CX_StmtClass_OMPScanDirective => "OMPScanDirective", + CX_StmtClass.CX_StmtClass_OMPSectionDirective => "OMPSectionDirective", + CX_StmtClass.CX_StmtClass_OMPSectionsDirective => "OMPSectionsDirective", + CX_StmtClass.CX_StmtClass_OMPSingleDirective => "OMPSingleDirective", + CX_StmtClass.CX_StmtClass_OMPTargetDataDirective => "OMPTargetDataDirective", + CX_StmtClass.CX_StmtClass_OMPTargetDirective => "OMPTargetDirective", + CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective => "OMPTargetEnterDataDirective", + CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective => "OMPTargetExitDataDirective", + CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective => "OMPTargetParallelDirective", + CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective => "OMPTargetParallelForDirective", + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective => "OMPTargetTeamsDirective", + CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective => "OMPTargetUpdateDirective", + CX_StmtClass.CX_StmtClass_OMPTaskDirective => "OMPTaskDirective", + CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective => "OMPTaskgroupDirective", + CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective => "OMPTaskwaitDirective", + CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective => "OMPTaskyieldDirective", + CX_StmtClass.CX_StmtClass_OMPTeamsDirective => "OMPTeamsDirective", + CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt => "ObjCAtCatchStmt", + CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt => "ObjCAtFinallyStmt", + CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt => "ObjCAtSynchronizedStmt", + CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt => "ObjCAtThrowStmt", + CX_StmtClass.CX_StmtClass_ObjCAtTryStmt => "ObjCAtTryStmt", + CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt => "ObjCAutoreleasePoolStmt", + CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt => "ObjCForCollectionStmt", + CX_StmtClass.CX_StmtClass_ReturnStmt => "ReturnStmt", + CX_StmtClass.CX_StmtClass_SEHExceptStmt => "SEHExceptStmt", + CX_StmtClass.CX_StmtClass_SEHFinallyStmt => "SEHFinallyStmt", + CX_StmtClass.CX_StmtClass_SEHLeaveStmt => "SEHLeaveStmt", + CX_StmtClass.CX_StmtClass_SEHTryStmt => "SEHTryStmt", + CX_StmtClass.CX_StmtClass_CaseStmt => "CaseStmt", + CX_StmtClass.CX_StmtClass_DefaultStmt => "DefaultStmt", + CX_StmtClass.CX_StmtClass_SwitchStmt => "SwitchStmt", + CX_StmtClass.CX_StmtClass_AttributedStmt => "AttributedStmt", + CX_StmtClass.CX_StmtClass_BinaryConditionalOperator => "BinaryConditionalOperator", + CX_StmtClass.CX_StmtClass_ConditionalOperator => "ConditionalOperator", + CX_StmtClass.CX_StmtClass_AddrLabelExpr => "AddrLabelExpr", + CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr => "ArrayInitIndexExpr", + CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr => "ArrayInitLoopExpr", + CX_StmtClass.CX_StmtClass_ArraySubscriptExpr => "ArraySubscriptExpr", + CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr => "ArrayTypeTraitExpr", + CX_StmtClass.CX_StmtClass_AsTypeExpr => "AsTypeExpr", + CX_StmtClass.CX_StmtClass_AtomicExpr => "AtomicExpr", + CX_StmtClass.CX_StmtClass_BinaryOperator => "BinaryOperator", + CX_StmtClass.CX_StmtClass_CompoundAssignOperator => "CompoundAssignOperator", + CX_StmtClass.CX_StmtClass_BlockExpr => "BlockExpr", + CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr => "CXXBindTemporaryExpr", + CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr => "CXXBoolLiteralExpr", + CX_StmtClass.CX_StmtClass_CXXConstructExpr => "CXXConstructExpr", + CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr => "CXXTemporaryObjectExpr", + CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr => "CXXDefaultArgExpr", + CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr => "CXXDefaultInitExpr", + CX_StmtClass.CX_StmtClass_CXXDeleteExpr => "CXXDeleteExpr", + CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr => "CXXDependentScopeMemberExpr", + CX_StmtClass.CX_StmtClass_CXXFoldExpr => "CXXFoldExpr", + CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr => "CXXInheritedCtorInitExpr", + CX_StmtClass.CX_StmtClass_CXXNewExpr => "CXXNewExpr", + CX_StmtClass.CX_StmtClass_CXXNoexceptExpr => "CXXNoexceptExpr", + CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr => "CXXNullPtrLiteralExpr", + CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr => "CXXPseudoDestructorExpr", + CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator => "CXXRewrittenBinaryOperator", + CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr => "CXXScalarValueInitExpr", + CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr => "CXXStdInitializerListExpr", + CX_StmtClass.CX_StmtClass_CXXThisExpr => "CXXThisExpr", + CX_StmtClass.CX_StmtClass_CXXThrowExpr => "CXXThrowExpr", + CX_StmtClass.CX_StmtClass_CXXTypeidExpr => "CXXTypeidExpr", + CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr => "CXXUnresolvedConstructExpr", + CX_StmtClass.CX_StmtClass_CXXUuidofExpr => "CXXUuidofExpr", + CX_StmtClass.CX_StmtClass_CallExpr => "CallExpr", + CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr => "CUDAKernelCallExpr", + CX_StmtClass.CX_StmtClass_CXXMemberCallExpr => "CXXMemberCallExpr", + CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr => "CXXOperatorCallExpr", + CX_StmtClass.CX_StmtClass_UserDefinedLiteral => "UserDefinedLiteral", + CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr => "BuiltinBitCastExpr", + CX_StmtClass.CX_StmtClass_CStyleCastExpr => "CStyleCastExpr", + CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr => "CXXFunctionalCastExpr", + CX_StmtClass.CX_StmtClass_CXXAddrspaceCastExpr => "CXXAddrspaceCastExpr", + CX_StmtClass.CX_StmtClass_CXXConstCastExpr => "CXXConstCastExpr", + CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr => "CXXDynamicCastExpr", + CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr => "CXXReinterpretCastExpr", + CX_StmtClass.CX_StmtClass_CXXStaticCastExpr => "CXXStaticCastExpr", + CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr => "ObjCBridgedCastExpr", + CX_StmtClass.CX_StmtClass_ImplicitCastExpr => "ImplicitCastExpr", + CX_StmtClass.CX_StmtClass_CharacterLiteral => "CharacterLiteral", + CX_StmtClass.CX_StmtClass_ChooseExpr => "ChooseExpr", + CX_StmtClass.CX_StmtClass_CompoundLiteralExpr => "CompoundLiteralExpr", + CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr => "ConceptSpecializationExpr", + CX_StmtClass.CX_StmtClass_ConvertVectorExpr => "ConvertVectorExpr", + CX_StmtClass.CX_StmtClass_CoawaitExpr => "CoawaitExpr", + CX_StmtClass.CX_StmtClass_CoyieldExpr => "CoyieldExpr", + CX_StmtClass.CX_StmtClass_DeclRefExpr => "DeclRefExpr", + CX_StmtClass.CX_StmtClass_DependentCoawaitExpr => "DependentCoawaitExpr", + CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr => "DependentScopeDeclRefExpr", + CX_StmtClass.CX_StmtClass_DesignatedInitExpr => "DesignatedInitExpr", + CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr => "DesignatedInitUpdateExpr", + CX_StmtClass.CX_StmtClass_ExpressionTraitExpr => "ExpressionTraitExpr", + CX_StmtClass.CX_StmtClass_ExtVectorElementExpr => "ExtVectorElementExpr", + CX_StmtClass.CX_StmtClass_FixedPointLiteral => "FixedPointLiteral", + CX_StmtClass.CX_StmtClass_FloatingLiteral => "FloatingLiteral", + CX_StmtClass.CX_StmtClass_ConstantExpr => "ConstantExpr", + CX_StmtClass.CX_StmtClass_ExprWithCleanups => "ExprWithCleanups", + CX_StmtClass.CX_StmtClass_FunctionParmPackExpr => "FunctionParmPackExpr", + CX_StmtClass.CX_StmtClass_GNUNullExpr => "GNUNullExpr", + CX_StmtClass.CX_StmtClass_GenericSelectionExpr => "GenericSelectionExpr", + CX_StmtClass.CX_StmtClass_ImaginaryLiteral => "ImaginaryLiteral", + CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr => "ImplicitValueInitExpr", + CX_StmtClass.CX_StmtClass_InitListExpr => "InitListExpr", + CX_StmtClass.CX_StmtClass_IntegerLiteral => "IntegerLiteral", + CX_StmtClass.CX_StmtClass_LambdaExpr => "LambdaExpr", + CX_StmtClass.CX_StmtClass_MSPropertyRefExpr => "MSPropertyRefExpr", + CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr => "MSPropertySubscriptExpr", + CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr => "MaterializeTemporaryExpr", + CX_StmtClass.CX_StmtClass_MatrixSubscriptExpr => "MatrixSubscriptExpr", + CX_StmtClass.CX_StmtClass_MemberExpr => "MemberExpr", + CX_StmtClass.CX_StmtClass_NoInitExpr => "NoInitExpr", + CX_StmtClass.CX_StmtClass_OMPArraySectionExpr => "OMPArraySectionExpr", + CX_StmtClass.CX_StmtClass_OMPArrayShapingExpr => "OMPArrayShapingExpr", + CX_StmtClass.CX_StmtClass_OMPIteratorExpr => "OMPIteratorExpr", + CX_StmtClass.CX_StmtClass_ObjCArrayLiteral => "ObjCArrayLiteral", + CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr => "ObjCAvailabilityCheckExpr", + CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr => "ObjCBoolLiteralExpr", + CX_StmtClass.CX_StmtClass_ObjCBoxedExpr => "ObjCBoxedExpr", + CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral => "ObjCDictionaryLiteral", + CX_StmtClass.CX_StmtClass_ObjCEncodeExpr => "ObjCEncodeExpr", + CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr => "ObjCIndirectCopyRestoreExpr", + CX_StmtClass.CX_StmtClass_ObjCIsaExpr => "ObjCIsaExpr", + CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr => "ObjCIvarRefExpr", + CX_StmtClass.CX_StmtClass_ObjCMessageExpr => "ObjCMessageExpr", + CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr => "ObjCPropertyRefExpr", + CX_StmtClass.CX_StmtClass_ObjCProtocolExpr => "ObjCProtocolExpr", + CX_StmtClass.CX_StmtClass_ObjCSelectorExpr => "ObjCSelectorExpr", + CX_StmtClass.CX_StmtClass_ObjCStringLiteral => "ObjCStringLiteral", + CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr => "ObjCSubscriptRefExpr", + CX_StmtClass.CX_StmtClass_OffsetOfExpr => "OffsetOfExpr", + CX_StmtClass.CX_StmtClass_OpaqueValueExpr => "OpaqueValueExpr", + CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr => "UnresolvedLookupExpr", + CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr => "UnresolvedMemberExpr", + CX_StmtClass.CX_StmtClass_PackExpansionExpr => "PackExpansionExpr", + CX_StmtClass.CX_StmtClass_ParenExpr => "ParenExpr", + CX_StmtClass.CX_StmtClass_ParenListExpr => "ParenListExpr", + CX_StmtClass.CX_StmtClass_PredefinedExpr => "PredefinedExpr", + CX_StmtClass.CX_StmtClass_PseudoObjectExpr => "PseudoObjectExpr", + CX_StmtClass.CX_StmtClass_RecoveryExpr => "RecoveryExpr", + CX_StmtClass.CX_StmtClass_RequiresExpr => "RequiresExpr", + CX_StmtClass.CX_StmtClass_ShuffleVectorExpr => "ShuffleVectorExpr", + CX_StmtClass.CX_StmtClass_SizeOfPackExpr => "SizeOfPackExpr", + CX_StmtClass.CX_StmtClass_SourceLocExpr => "SourceLocExpr", + CX_StmtClass.CX_StmtClass_StmtExpr => "StmtExpr", + CX_StmtClass.CX_StmtClass_StringLiteral => "StringLiteral", + CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr => "SubstNonTypeTemplateParmExpr", + CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr => "SubstNonTypeTemplateParmPackExpr", + CX_StmtClass.CX_StmtClass_TypeTraitExpr => "TypeTraitExpr", + CX_StmtClass.CX_StmtClass_TypoExpr => "TypoExpr", + CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr => "UnaryExprOrTypeTraitExpr", + CX_StmtClass.CX_StmtClass_UnaryOperator => "UnaryOperator", + CX_StmtClass.CX_StmtClass_VAArgExpr => "VAArgExpr", + CX_StmtClass.CX_StmtClass_LabelStmt => "LabelStmt", + CX_StmtClass.CX_StmtClass_WhileStmt => "WhileStmt", + _ => StmtClass.ToString()[13..], + }; } + } - public CX_StorageClass StorageClass => clang.Cursor_getStorageClass(this); + public CX_StorageClass StorageClass => clang.Cursor_getStorageClass(this); - public CXString StringLiteralValue => clangsharp.Cursor_getStringLiteralValue(this); + public CXString StringLiteralValue => clangsharp.Cursor_getStringLiteralValue(this); - public CXCursor SubExpr => clangsharp.Cursor_getSubExpr(this); + public CXCursor SubExpr => clangsharp.Cursor_getSubExpr(this); - public CXCursor SubExprAsWritten => clangsharp.Cursor_getSubExprAsWritten(this); + public CXCursor SubExprAsWritten => clangsharp.Cursor_getSubExprAsWritten(this); - public CXCursor SubStmt => clangsharp.Cursor_getSubStmt(this); + public CXCursor SubStmt => clangsharp.Cursor_getSubStmt(this); - public CXCursor TargetUnionField => clangsharp.Cursor_getTargetUnionField(this); + public CXCursor TargetUnionField => clangsharp.Cursor_getTargetUnionField(this); - public CXCursorKind TemplateCursorKind => clang.getTemplateCursorKind(this); + public CXCursorKind TemplateCursorKind => clang.getTemplateCursorKind(this); - public CXCursor TemplatedDecl => clangsharp.Cursor_getTemplatedDecl(this); + public CXCursor TemplatedDecl => clangsharp.Cursor_getTemplatedDecl(this); - public CXCursor TemplateInstantiationPattern => clangsharp.Cursor_getTemplateInstantiationPattern(this); + public CXCursor TemplateInstantiationPattern => clangsharp.Cursor_getTemplateInstantiationPattern(this); - public CX_TemplateSpecializationKind TemplateSpecializationKind => clangsharp.Cursor_getTemplateSpecializationKind(this); + public CX_TemplateSpecializationKind TemplateSpecializationKind => clangsharp.Cursor_getTemplateSpecializationKind(this); - public int TemplateTypeParmDepth => clangsharp.Cursor_getTemplateTypeParmDepth(this); + public int TemplateTypeParmDepth => clangsharp.Cursor_getTemplateTypeParmDepth(this); - public int TemplateTypeParmIndex => clangsharp.Cursor_getTemplateTypeParmIndex(this); + public int TemplateTypeParmIndex => clangsharp.Cursor_getTemplateTypeParmIndex(this); - public int TemplateTypeParmPosition => clangsharp.Cursor_getTemplateTypeParmPosition(this); + public int TemplateTypeParmPosition => clangsharp.Cursor_getTemplateTypeParmPosition(this); - public CXType ThisObjectType => clangsharp.Cursor_getThisObjectType(this); + public CXType ThisObjectType => clangsharp.Cursor_getThisObjectType(this); - public CXType ThisType => clangsharp.Cursor_getThisType(this); + public CXType ThisType => clangsharp.Cursor_getThisType(this); - public CXTLSKind TlsKind => clang.getCursorTLSKind(this); + public CXTLSKind TlsKind => clang.getCursorTLSKind(this); - public CXCursor TrailingRequiresClause => clangsharp.Cursor_getTrailingRequiresClause(this); + public CXCursor TrailingRequiresClause => clangsharp.Cursor_getTrailingRequiresClause(this); - public CXTranslationUnit TranslationUnit => clang.Cursor_getTranslationUnit(this); + public CXTranslationUnit TranslationUnit => clang.Cursor_getTranslationUnit(this); - public CXType Type => clang.getCursorType(this); + public CXType Type => clang.getCursorType(this); - public CXType TypeOperand => clangsharp.Cursor_getTypeOperand(this); + public CXType TypeOperand => clangsharp.Cursor_getTypeOperand(this); - public CXType TypedefDeclUnderlyingType => clang.getTypedefDeclUnderlyingType(this); + public CXType TypedefDeclUnderlyingType => clang.getTypedefDeclUnderlyingType(this); - public CXCursor TypedefNameForAnonDecl => clangsharp.Cursor_getTypedefNameForAnonDecl(this); + public CXCursor TypedefNameForAnonDecl => clangsharp.Cursor_getTypedefNameForAnonDecl(this); - public CX_UnaryExprOrTypeTrait UnaryExprOrTypeTraitKind => clangsharp.Cursor_getUnaryExprOrTypeTraitKind(this); + public CX_UnaryExprOrTypeTrait UnaryExprOrTypeTraitKind => clangsharp.Cursor_getUnaryExprOrTypeTraitKind(this); - public CX_UnaryOperatorKind UnaryOperatorKind => clangsharp.Cursor_getUnaryOpcode(this); + public CX_UnaryOperatorKind UnaryOperatorKind => clangsharp.Cursor_getUnaryOpcode(this); - public CXString UnaryOperatorKindSpelling => clangsharp.Cursor_getUnaryOpcodeSpelling(UnaryOperatorKind); + public CXString UnaryOperatorKindSpelling => clangsharp.Cursor_getUnaryOpcodeSpelling(UnaryOperatorKind); - public CXCursor UnderlyingDecl => clangsharp.Cursor_getUnderlyingDecl(this); + public CXCursor UnderlyingDecl => clangsharp.Cursor_getUnderlyingDecl(this); - public CXCursor UninstantiatedDefaultArg => clangsharp.Cursor_getUninstantiatedDefaultArg(this); + public CXCursor UninstantiatedDefaultArg => clangsharp.Cursor_getUninstantiatedDefaultArg(this); - public CXCursor UsedContext => clangsharp.Cursor_getUsedContext(this); + public CXCursor UsedContext => clangsharp.Cursor_getUsedContext(this); - public CXString Usr => clang.getCursorUSR(this); + public CXString Usr => clang.getCursorUSR(this); - public CXVisibilityKind Visibility => clang.getCursorVisibility(this); + public CXVisibilityKind Visibility => clang.getCursorVisibility(this); - public long VtblIdx => clangsharp.Cursor_getVtblIdx(this); + public long VtblIdx => clangsharp.Cursor_getVtblIdx(this); - internal string DebuggerDisplayString + internal string DebuggerDisplayString + { + get { - get + if (AttrKind != CX_AttrKind.CX_AttrKind_Invalid) { - if (AttrKind != CX_AttrKind.CX_AttrKind_Invalid) - { - return $"{AttrKindSpelling}: {this}"; - } - else if (DeclKind != CX_DeclKind.CX_DeclKind_Invalid) + return $"{AttrKindSpelling}: {this}"; + } + else if (DeclKind != CX_DeclKind.CX_DeclKind_Invalid) + { + return $"{DeclKindSpelling}: {this}"; + } + else if (StmtClass != CX_StmtClass.CX_StmtClass_Invalid) + { + var additionalInfo = string.Empty; + + if (BinaryOperatorKind != CX_BinaryOperatorKind.CX_BO_Invalid) { - return $"{DeclKindSpelling}: {this}"; + additionalInfo = $" ({BinaryOperatorKindSpelling})"; } - else if (StmtClass != CX_StmtClass.CX_StmtClass_Invalid) + else if (CastKind != CX_CastKind.CX_CK_Invalid) { - var additionalInfo = string.Empty; - - if (BinaryOperatorKind != CX_BinaryOperatorKind.CX_BO_Invalid) - { - additionalInfo = $" ({BinaryOperatorKindSpelling})"; - } - else if (CastKind != CX_CastKind.CX_CK_Invalid) - { - additionalInfo = $" ({CastKindSpelling})"; - } - else if (UnaryOperatorKind != CX_UnaryOperatorKind.CX_UO_Invalid) - { - additionalInfo = $" ({UnaryOperatorKindSpelling})"; - } - - return $"{StmtClassSpelling}: {this}{additionalInfo}"; + additionalInfo = $" ({CastKindSpelling})"; } - else + else if (UnaryOperatorKind != CX_UnaryOperatorKind.CX_UO_Invalid) { - return $"{KindSpelling}: {this}"; + additionalInfo = $" ({UnaryOperatorKindSpelling})"; } + + return $"{StmtClassSpelling}: {this}{additionalInfo}"; + } + else + { + return $"{KindSpelling}: {this}"; } } + } - public static bool operator ==(CXCursor left, CXCursor right) => clang.equalCursors(left, right) != 0; + public static bool operator ==(CXCursor left, CXCursor right) => clang.equalCursors(left, right) != 0; - public static bool operator !=(CXCursor left, CXCursor right) => clang.equalCursors(left, right) == 0; + public static bool operator !=(CXCursor left, CXCursor right) => clang.equalCursors(left, right) == 0; - public bool CapturesVariable(CXCursor var) => clangsharp.Cursor_getCapturesVariable(this, var) != 0; + public bool CapturesVariable(CXCursor var) => clangsharp.Cursor_getCapturesVariable(this, var) != 0; - public static void DisposeOverriddenCursors(ReadOnlySpan overridden) + public static void DisposeOverriddenCursors(ReadOnlySpan overridden) + { + fixed (CXCursor* pOverridden = overridden) { - fixed (CXCursor* pOverridden = overridden) - { - clang.disposeOverriddenCursors(pOverridden); - } + clang.disposeOverriddenCursors(pOverridden); } + } - public override bool Equals(object obj) => (obj is CXCursor other) && Equals(other); + public override bool Equals(object obj) => (obj is CXCursor other) && Equals(other); - public bool Equals(CXCursor other) => this == other; + public bool Equals(CXCursor other) => this == other; - public CXResult FindReferencesInFile(CXFile file, CXCursorAndRangeVisitor visitor) => clang.findReferencesInFile(this, file, visitor); + public CXResult FindReferencesInFile(CXFile file, CXCursorAndRangeVisitor visitor) => clang.findReferencesInFile(this, file, visitor); - public CXCursor GetAssociatedConstraint(uint index) => clangsharp.Cursor_getAssociatedConstraint(this, index); + public CXCursor GetAssociatedConstraint(uint index) => clangsharp.Cursor_getAssociatedConstraint(this, index); - public CXCursor GetArgument(uint index) => clangsharp.Cursor_getArgument(this, index); + public CXCursor GetArgument(uint index) => clangsharp.Cursor_getArgument(this, index); - public CXCursor GetAttr(uint index) => clangsharp.Cursor_getAttr(this, index); + public CXCursor GetAttr(uint index) => clangsharp.Cursor_getAttr(this, index); - public CXCursor GetBase(uint index) => clangsharp.Cursor_getBase(this, index); + public CXCursor GetBase(uint index) => clangsharp.Cursor_getBase(this, index); - public CXCursor GetBindingDecl(uint index) => clangsharp.Cursor_getBindingDecl(this, index); + public CXCursor GetBindingDecl(uint index) => clangsharp.Cursor_getBindingDecl(this, index); - public CXCursor GetCtor(uint index) => clangsharp.Cursor_getCtor(this, index); + public CXCursor GetCtor(uint index) => clangsharp.Cursor_getCtor(this, index); - public CXCursor GetCaptureCopyExpr(uint index) => clangsharp.Cursor_getCaptureCopyExpr(this, index); + public CXCursor GetCaptureCopyExpr(uint index) => clangsharp.Cursor_getCaptureCopyExpr(this, index); - public CXCursor GetCapturedVar(uint index) => clangsharp.Cursor_getCapturedVar(this, index); + public CXCursor GetCapturedVar(uint index) => clangsharp.Cursor_getCapturedVar(this, index); - public CX_VariableCaptureKind GetCaptureKind(uint index) => clangsharp.Cursor_getCaptureKind(this, index); + public CX_VariableCaptureKind GetCaptureKind(uint index) => clangsharp.Cursor_getCaptureKind(this, index); - public bool GetCaptureHasCopyExpr(uint index) => clangsharp.Cursor_getCaptureHasCopyExpr(this, index) != 0; + public bool GetCaptureHasCopyExpr(uint index) => clangsharp.Cursor_getCaptureHasCopyExpr(this, index) != 0; - public bool GetCaptureIsByRef(uint index) => clangsharp.Cursor_getCaptureIsByRef(this, index) != 0; + public bool GetCaptureIsByRef(uint index) => clangsharp.Cursor_getCaptureIsByRef(this, index) != 0; - public bool GetCaptureIsEscapingByRef(uint index) => clangsharp.Cursor_getCaptureIsEscapingByRef(this, index) != 0; + public bool GetCaptureIsEscapingByRef(uint index) => clangsharp.Cursor_getCaptureIsEscapingByRef(this, index) != 0; - public bool GetCaptureIsNested(uint index) => clangsharp.Cursor_getCaptureIsNested(this, index) != 0; + public bool GetCaptureIsNested(uint index) => clangsharp.Cursor_getCaptureIsNested(this, index) != 0; - public bool GetCaptureIsNonEscapingByRef(uint index) => clangsharp.Cursor_getCaptureIsNonEscapingByRef(this, index) != 0; + public bool GetCaptureIsNonEscapingByRef(uint index) => clangsharp.Cursor_getCaptureIsNonEscapingByRef(this, index) != 0; - public CXCursor GetCaptureVariable(uint index) => clangsharp.Cursor_getCaptureVariable(this, index); + public CXCursor GetCaptureVariable(uint index) => clangsharp.Cursor_getCaptureVariable(this, index); - public CXCursor GetChild(uint index) => clangsharp.Cursor_getChild(this, index); + public CXCursor GetChild(uint index) => clangsharp.Cursor_getChild(this, index); - public CXCursor GetDecl(uint index) => clangsharp.Cursor_getDecl(this, index); + public CXCursor GetDecl(uint index) => clangsharp.Cursor_getDecl(this, index); - public void GetDefinitionSpellingAndExtent(out string spelling, out uint startLine, out uint startColumn, out uint endLine, out uint endColumn) + public void GetDefinitionSpellingAndExtent(out string spelling, out uint startLine, out uint startColumn, out uint endLine, out uint endColumn) + { + fixed (uint* pStartLine = &startLine) + fixed (uint* pStartColumn = &startColumn) + fixed (uint* pEndLine = &endLine) + fixed (uint* pEndColumn = &endColumn) { - fixed (uint* pStartLine = &startLine) - fixed (uint* pStartColumn = &startColumn) - fixed (uint* pEndLine = &endLine) - fixed (uint* pEndColumn = &endColumn) - { - sbyte* startBuf; - sbyte* endBuf; - clang.getDefinitionSpellingAndExtent(this, &startBuf, &endBuf, pStartLine, pStartColumn, pEndLine, pEndColumn); - spelling = new ReadOnlySpan(startBuf, (int)(endBuf - startBuf)).AsString(); - } + sbyte* startBuf; + sbyte* endBuf; + clang.getDefinitionSpellingAndExtent(this, &startBuf, &endBuf, pStartLine, pStartColumn, pEndLine, pEndColumn); + spelling = new ReadOnlySpan(startBuf, (int)(endBuf - startBuf)).AsString(); } + } - public CXCursor GetEnumerator(uint index) => clangsharp.Cursor_getEnumerator(this, index); + public CXCursor GetEnumerator(uint index) => clangsharp.Cursor_getEnumerator(this, index); - public CXType GetExpansionType(uint index) => clangsharp.Cursor_getExpansionType(this, index); + public CXType GetExpansionType(uint index) => clangsharp.Cursor_getExpansionType(this, index); - public CXCursor GetExpr(uint index) => clangsharp.Cursor_getExpr(this, index); + public CXCursor GetExpr(uint index) => clangsharp.Cursor_getExpr(this, index); - public CXCursor GetField(uint index) => clangsharp.Cursor_getField(this, index); + public CXCursor GetField(uint index) => clangsharp.Cursor_getField(this, index); - public CXCursor GetFriend(uint index) => clangsharp.Cursor_getFriend(this, index); + public CXCursor GetFriend(uint index) => clangsharp.Cursor_getFriend(this, index); - public override int GetHashCode() => (int)Hash; + public override int GetHashCode() => (int)Hash; - public bool GetIsExternalSymbol(out CXString language, out CXString definedIn, out bool isGenerated) + public bool GetIsExternalSymbol(out CXString language, out CXString definedIn, out bool isGenerated) + { + fixed (CXString* pLanguage = &language) + fixed (CXString* pDefinedIn = &definedIn) { - fixed (CXString* pLanguage = &language) - fixed (CXString* pDefinedIn = &definedIn) - { - uint isGeneratedOut; - var result = clang.Cursor_isExternalSymbol(this, pLanguage, pDefinedIn, &isGeneratedOut); - isGenerated = isGeneratedOut != 0; - return result != 0; - } + uint isGeneratedOut; + var result = clang.Cursor_isExternalSymbol(this, pLanguage, pDefinedIn, &isGeneratedOut); + isGenerated = isGeneratedOut != 0; + return result != 0; } + } - public CXCursor GetMethod(uint index) => clangsharp.Cursor_getMethod(this, index); + public CXCursor GetMethod(uint index) => clangsharp.Cursor_getMethod(this, index); - public int GetNumTemplateParameters(uint listIndex) => clangsharp.Cursor_getNumTemplateParameters(this, listIndex); + public int GetNumTemplateParameters(uint listIndex) => clangsharp.Cursor_getNumTemplateParameters(this, listIndex); - public CXObjCPropertyAttrKind GetObjCPropertyAttributes(uint reserved) => (CXObjCPropertyAttrKind)clang.Cursor_getObjCPropertyAttributes(this, reserved); + public CXObjCPropertyAttrKind GetObjCPropertyAttributes(uint reserved) => (CXObjCPropertyAttrKind)clang.Cursor_getObjCPropertyAttributes(this, reserved); - public CXCursor GetOverloadedDecl(uint index) => clang.getOverloadedDecl(this, index); + public CXCursor GetOverloadedDecl(uint index) => clang.getOverloadedDecl(this, index); - public int GetPlatformAvailability(out bool alwaysDeprecated, out CXString deprecatedMessage, out bool alwaysUnavailable, out CXString unavailableMessage, Span availability) + public int GetPlatformAvailability(out bool alwaysDeprecated, out CXString deprecatedMessage, out bool alwaysUnavailable, out CXString unavailableMessage, Span availability) + { + fixed (CXString* pDeprecatedMessage = &deprecatedMessage) + fixed (CXString* pUnavailableMessage = &unavailableMessage) + fixed (CXPlatformAvailability* pAvailability = availability) { - fixed (CXString* pDeprecatedMessage = &deprecatedMessage) - fixed (CXString* pUnavailableMessage = &unavailableMessage) - fixed (CXPlatformAvailability* pAvailability = availability) - { - int alwaysDeprecatedOut; - int alwaysUnavailableOut; - var result = clang.getCursorPlatformAvailability(this, &alwaysDeprecatedOut, pDeprecatedMessage, &alwaysUnavailableOut, pUnavailableMessage, pAvailability, availability.Length); - alwaysDeprecated = alwaysDeprecatedOut != 0; - alwaysUnavailable = alwaysUnavailableOut != 0; - return result; - } + int alwaysDeprecatedOut; + int alwaysUnavailableOut; + var result = clang.getCursorPlatformAvailability(this, &alwaysDeprecatedOut, pDeprecatedMessage, &alwaysUnavailableOut, pUnavailableMessage, pAvailability, availability.Length); + alwaysDeprecated = alwaysDeprecatedOut != 0; + alwaysUnavailable = alwaysUnavailableOut != 0; + return result; } + } - public CXString GetPrettyPrinted(CXPrintingPolicy policy) => clang.getCursorPrettyPrinted(this, policy); + public CXString GetPrettyPrinted(CXPrintingPolicy policy) => clang.getCursorPrettyPrinted(this, policy); - public CXCursor GetProtocol(uint index) => clangsharp.Cursor_getProtocol(this, index); + public CXCursor GetProtocol(uint index) => clangsharp.Cursor_getProtocol(this, index); - public CXSourceRange GetReferenceNameRange(CXNameRefFlags nameFlags, uint pieceIndex) => clang.getCursorReferenceNameRange(this, (uint)nameFlags, pieceIndex); + public CXSourceRange GetReferenceNameRange(CXNameRefFlags nameFlags, uint pieceIndex) => clang.getCursorReferenceNameRange(this, (uint)nameFlags, pieceIndex); - public CXCursor GetSpecialization(uint index) => clangsharp.Cursor_getSpecialization(this, index); + public CXCursor GetSpecialization(uint index) => clangsharp.Cursor_getSpecialization(this, index); - public CXSourceRange GetSpellingNameRange(uint pieceIndex, uint options) => clang.Cursor_getSpellingNameRange(this, pieceIndex, options); + public CXSourceRange GetSpellingNameRange(uint pieceIndex, uint options) => clang.Cursor_getSpellingNameRange(this, pieceIndex, options); - public CXCursor GetSubDecl(uint i) => clangsharp.Cursor_getSubDecl(this, i); + public CXCursor GetSubDecl(uint i) => clangsharp.Cursor_getSubDecl(this, i); - public CX_TemplateArgument GetTemplateArgument(uint index) => clangsharp.Cursor_getTemplateArgument(this, index); + public CX_TemplateArgument GetTemplateArgument(uint index) => clangsharp.Cursor_getTemplateArgument(this, index); - public CX_TemplateArgumentLoc GetTemplateArgumentLoc(uint index) => clangsharp.Cursor_getTemplateArgumentLoc(this, index); + public CX_TemplateArgumentLoc GetTemplateArgumentLoc(uint index) => clangsharp.Cursor_getTemplateArgumentLoc(this, index); - public CXCursor GetTemplateParameter(uint listIndex, uint parameterIndex) => clangsharp.Cursor_getTemplateParameter(this, listIndex, parameterIndex); + public CXCursor GetTemplateParameter(uint listIndex, uint parameterIndex) => clangsharp.Cursor_getTemplateParameter(this, listIndex, parameterIndex); - public CXType GetTemplateArgumentType(uint i) => clang.Cursor_getTemplateArgumentType(this, i); + public CXType GetTemplateArgumentType(uint i) => clang.Cursor_getTemplateArgumentType(this, i); - public ulong GetTemplateArgumentUnsignedValue(uint i) => clang.Cursor_getTemplateArgumentUnsignedValue(this, i); + public ulong GetTemplateArgumentUnsignedValue(uint i) => clang.Cursor_getTemplateArgumentUnsignedValue(this, i); - public long GetTemplateArgumentValue(uint i) => clang.Cursor_getTemplateArgumentValue(this, i); + public long GetTemplateArgumentValue(uint i) => clang.Cursor_getTemplateArgumentValue(this, i); - public CXCursor GetVBase(uint index) => clangsharp.Cursor_getVBase(this, index); + public CXCursor GetVBase(uint index) => clangsharp.Cursor_getVBase(this, index); - public override string ToString() => Spelling.ToString(); + public override string ToString() => Spelling.ToString(); - public CXChildVisitResult VisitChildren(CXCursorVisitor visitor, CXClientData clientData) - { - var pVisitor = Marshal.GetFunctionPointerForDelegate(visitor); - var result = (CXChildVisitResult)clang.visitChildren(this, pVisitor, clientData); + public CXChildVisitResult VisitChildren(CXCursorVisitor visitor, CXClientData clientData) + { + var pVisitor = Marshal.GetFunctionPointerForDelegate(visitor); + var result = (CXChildVisitResult)clang.visitChildren(this, pVisitor, clientData); - GC.KeepAlive(visitor); - return result; - } + GC.KeepAlive(visitor); + return result; } } diff --git a/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs b/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs index 77eced7b..32829266 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs @@ -2,44 +2,43 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXCursorSet : IDisposable, IEquatable { - public unsafe partial struct CXCursorSet : IDisposable, IEquatable + public CXCursorSet(IntPtr handle) { - public CXCursorSet(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static implicit operator CXCursorSet(CXCursorSetImpl* value) => new CXCursorSet((IntPtr)value); + public static implicit operator CXCursorSet(CXCursorSetImpl* value) => new CXCursorSet((IntPtr)value); - public static implicit operator CXCursorSetImpl*(CXCursorSet value) => (CXCursorSetImpl*)value.Handle; + public static implicit operator CXCursorSetImpl*(CXCursorSet value) => (CXCursorSetImpl*)value.Handle; - public static bool operator ==(CXCursorSet left, CXCursorSet right) => left.Handle == right.Handle; + public static bool operator ==(CXCursorSet left, CXCursorSet right) => left.Handle == right.Handle; - public static bool operator !=(CXCursorSet left, CXCursorSet right) => left.Handle != right.Handle; + public static bool operator !=(CXCursorSet left, CXCursorSet right) => left.Handle != right.Handle; - public static CXCursorSet Create() => clang.createCXCursorSet(); + public static CXCursorSet Create() => clang.createCXCursorSet(); - public bool Contains(CXCursor cursor) => clang.CXCursorSet_contains(this, cursor) != 0; + public bool Contains(CXCursor cursor) => clang.CXCursorSet_contains(this, cursor) != 0; - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.disposeCXCursorSet(this); - Handle = IntPtr.Zero; - } + clang.disposeCXCursorSet(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXCursorSet other) && Equals(other); + public override bool Equals(object obj) => (obj is CXCursorSet other) && Equals(other); - public bool Equals(CXCursorSet other) => this == other; + public bool Equals(CXCursorSet other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public bool Insert(CXCursor cursor) => clang.CXCursorSet_insert(this, cursor) != 0; - } + public bool Insert(CXCursor cursor) => clang.CXCursorSet_insert(this, cursor) != 0; } diff --git a/sources/ClangSharp.Interop/Extensions/CXDiagnostic.cs b/sources/ClangSharp.Interop/Extensions/CXDiagnostic.cs index 9104eb5f..a058a87c 100644 --- a/sources/ClangSharp.Interop/Extensions/CXDiagnostic.cs +++ b/sources/ClangSharp.Interop/Extensions/CXDiagnostic.cs @@ -2,81 +2,80 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXDiagnostic : IDisposable, IEquatable { - public unsafe partial struct CXDiagnostic : IDisposable, IEquatable + public CXDiagnostic(IntPtr handle) { - public CXDiagnostic(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public static CXDiagnosticDisplayOptions DefaultDisplayOptions => (CXDiagnosticDisplayOptions)clang.defaultDiagnosticDisplayOptions(); + public static CXDiagnosticDisplayOptions DefaultDisplayOptions => (CXDiagnosticDisplayOptions)clang.defaultDiagnosticDisplayOptions(); - public uint Category => clang.getDiagnosticCategory(this); + public uint Category => clang.getDiagnosticCategory(this); - public CXString CategoryText => clang.getDiagnosticCategoryText(this); + public CXString CategoryText => clang.getDiagnosticCategoryText(this); - public CXDiagnosticSet ChildDiagnostics => (CXDiagnosticSet)clang.getChildDiagnostics(this); + public CXDiagnosticSet ChildDiagnostics => (CXDiagnosticSet)clang.getChildDiagnostics(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public CXSourceLocation Location => clang.getDiagnosticLocation(this); + public CXSourceLocation Location => clang.getDiagnosticLocation(this); - public uint NumFixIts => clang.getDiagnosticNumFixIts(this); + public uint NumFixIts => clang.getDiagnosticNumFixIts(this); - public uint NumRanges => clang.getDiagnosticNumRanges(this); + public uint NumRanges => clang.getDiagnosticNumRanges(this); - public CXDiagnosticSeverity Severity => clang.getDiagnosticSeverity(this); + public CXDiagnosticSeverity Severity => clang.getDiagnosticSeverity(this); - public CXString Spelling => clang.getDiagnosticSpelling(this); + public CXString Spelling => clang.getDiagnosticSpelling(this); - public static explicit operator CXDiagnostic(void* value) => new CXDiagnostic((IntPtr)value); + public static explicit operator CXDiagnostic(void* value) => new CXDiagnostic((IntPtr)value); - public static implicit operator void*(CXDiagnostic value) => (void*)value.Handle; + public static implicit operator void*(CXDiagnostic value) => (void*)value.Handle; - public static bool operator ==(CXDiagnostic left, CXDiagnostic right) => left.Handle == right.Handle; + public static bool operator ==(CXDiagnostic left, CXDiagnostic right) => left.Handle == right.Handle; - public static bool operator !=(CXDiagnostic left, CXDiagnostic right) => left.Handle != right.Handle; + public static bool operator !=(CXDiagnostic left, CXDiagnostic right) => left.Handle != right.Handle; - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.disposeDiagnostic(this); - Handle = IntPtr.Zero; - } + clang.disposeDiagnostic(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXDiagnostic other) && Equals(other); + public override bool Equals(object obj) => (obj is CXDiagnostic other) && Equals(other); - public bool Equals(CXDiagnostic other) => this == other; + public bool Equals(CXDiagnostic other) => this == other; - public CXString Format(CXDiagnosticDisplayOptions options) => clang.formatDiagnostic(this, (uint)options); + public CXString Format(CXDiagnosticDisplayOptions options) => clang.formatDiagnostic(this, (uint)options); - [Obsolete("Use " + nameof(CategoryText) + " instead.")] - public static CXString GetCategoryName(uint category) => clang.getDiagnosticCategoryName(category); + [Obsolete("Use " + nameof(CategoryText) + " instead.")] + public static CXString GetCategoryName(uint category) => clang.getDiagnosticCategoryName(category); - public CXString GetFixIt(uint fixIt, out CXSourceRange replacementRange) + public CXString GetFixIt(uint fixIt, out CXSourceRange replacementRange) + { + fixed (CXSourceRange* pReplacementRange = &replacementRange) { - fixed (CXSourceRange* pReplacementRange = &replacementRange) - { - return clang.getDiagnosticFixIt(this, fixIt, pReplacementRange); - } + return clang.getDiagnosticFixIt(this, fixIt, pReplacementRange); } + } - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public CXString GetOption(out CXString disable) + public CXString GetOption(out CXString disable) + { + fixed (CXString* pDisable = &disable) { - fixed (CXString* pDisable = &disable) - { - return clang.getDiagnosticOption(this, pDisable); - } + return clang.getDiagnosticOption(this, pDisable); } + } - public CXSourceRange GetRange(uint range) => clang.getDiagnosticRange(this, range); + public CXSourceRange GetRange(uint range) => clang.getDiagnosticRange(this, range); - public override string ToString() => Spelling.ToString(); - } + public override string ToString() => Spelling.ToString(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs b/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs index a92d267e..36ba35ef 100644 --- a/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs +++ b/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs @@ -4,69 +4,68 @@ using System.Collections; using System.Collections.Generic; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXDiagnosticSet : IDisposable, IEquatable, IReadOnlyCollection { - public unsafe partial struct CXDiagnosticSet : IDisposable, IEquatable, IReadOnlyCollection + public static CXDiagnosticSet Load(string file, out CXLoadDiag_Error error, out CXString errorString) { - public static CXDiagnosticSet Load(string file, out CXLoadDiag_Error error, out CXString errorString) - { - using var marshaledFile = new MarshaledString(file); - - fixed (CXLoadDiag_Error* pError = &error) - fixed (CXString* pErrorString = &errorString) - { - return (CXDiagnosticSet)clang.loadDiagnostics(marshaledFile, pError, pErrorString); - } - } + using var marshaledFile = new MarshaledString(file); - public CXDiagnosticSet(IntPtr handle) + fixed (CXLoadDiag_Error* pError = &error) + fixed (CXString* pErrorString = &errorString) { - Handle = handle; + return (CXDiagnosticSet)clang.loadDiagnostics(marshaledFile, pError, pErrorString); } + } + + public CXDiagnosticSet(IntPtr handle) + { + Handle = handle; + } - public CXDiagnostic this[uint index] => GetDiagnostic(index); + public CXDiagnostic this[uint index] => GetDiagnostic(index); - public int Count => (int)NumDiagnostics; + public int Count => (int)NumDiagnostics; - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public uint NumDiagnostics => clang.getNumDiagnosticsInSet(this); + public uint NumDiagnostics => clang.getNumDiagnosticsInSet(this); - public static explicit operator CXDiagnosticSet(void* value) => new CXDiagnosticSet((IntPtr)value); + public static explicit operator CXDiagnosticSet(void* value) => new CXDiagnosticSet((IntPtr)value); - public static implicit operator void*(CXDiagnosticSet value) => (void*)value.Handle; + public static implicit operator void*(CXDiagnosticSet value) => (void*)value.Handle; - public static bool operator ==(CXDiagnosticSet left, CXDiagnosticSet right) => left.Handle == right.Handle; + public static bool operator ==(CXDiagnosticSet left, CXDiagnosticSet right) => left.Handle == right.Handle; - public static bool operator !=(CXDiagnosticSet left, CXDiagnosticSet right) => left.Handle != right.Handle; + public static bool operator !=(CXDiagnosticSet left, CXDiagnosticSet right) => left.Handle != right.Handle; - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.disposeDiagnosticSet(this); - Handle = IntPtr.Zero; - } + clang.disposeDiagnosticSet(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXDiagnosticSet other) && Equals(other); + public override bool Equals(object obj) => (obj is CXDiagnosticSet other) && Equals(other); - public bool Equals(CXDiagnosticSet other) => this == other; + public bool Equals(CXDiagnosticSet other) => this == other; - public CXDiagnostic GetDiagnostic(uint index) => (CXDiagnostic)clang.getDiagnosticInSet(this, index); + public CXDiagnostic GetDiagnostic(uint index) => (CXDiagnostic)clang.getDiagnosticInSet(this, index); - public IEnumerator GetEnumerator() - { - var count = NumDiagnostics; + public IEnumerator GetEnumerator() + { + var count = NumDiagnostics; - for (var index = 0u; index < count; index++) - { - yield return GetDiagnostic(index); - } + for (var index = 0u; index < count; index++) + { + yield return GetDiagnostic(index); } + } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - public override int GetHashCode() => Handle.GetHashCode(); - } + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs b/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs index 84c18043..70083ad8 100644 --- a/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs +++ b/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs @@ -2,66 +2,65 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXEvalResult : IDisposable, IEquatable { - public unsafe partial struct CXEvalResult : IDisposable, IEquatable + public CXEvalResult(IntPtr handle) { - public CXEvalResult(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public double AsDouble => (Kind == CXEvalResultKind.CXEval_Float) ? clang.EvalResult_getAsDouble(this) : 0; + public double AsDouble => (Kind == CXEvalResultKind.CXEval_Float) ? clang.EvalResult_getAsDouble(this) : 0; - public int AsInt => (Kind == CXEvalResultKind.CXEval_Int) ? clang.EvalResult_getAsInt(this) : 0; + public int AsInt => (Kind == CXEvalResultKind.CXEval_Int) ? clang.EvalResult_getAsInt(this) : 0; - public long AsLongLong => (Kind == CXEvalResultKind.CXEval_Int) ? clang.EvalResult_getAsLongLong(this) : 0; + public long AsLongLong => (Kind == CXEvalResultKind.CXEval_Int) ? clang.EvalResult_getAsLongLong(this) : 0; - public string AsStr + public string AsStr + { + get { - get - { - var pStr = Kind == CXEvalResultKind.CXEval_StrLiteral ? clang.EvalResult_getAsStr(this) : null; + var pStr = Kind == CXEvalResultKind.CXEval_StrLiteral ? clang.EvalResult_getAsStr(this) : null; - if (pStr is null) - { - return string.Empty; - } - - var span = new ReadOnlySpan(pStr, int.MaxValue); - return span.Slice(0, span.IndexOf((byte)'\0')).AsString(); + if (pStr is null) + { + return string.Empty; } + + var span = new ReadOnlySpan(pStr, int.MaxValue); + return span.Slice(0, span.IndexOf((byte)'\0')).AsString(); } + } - public ulong AsUnsigned => (Kind == CXEvalResultKind.CXEval_Int) ? clang.EvalResult_getAsUnsigned(this) : 0; + public ulong AsUnsigned => (Kind == CXEvalResultKind.CXEval_Int) ? clang.EvalResult_getAsUnsigned(this) : 0; - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public bool IsUnsignedInt => (Kind == CXEvalResultKind.CXEval_Int) && (clang.EvalResult_isUnsignedInt(this) != 0); + public bool IsUnsignedInt => (Kind == CXEvalResultKind.CXEval_Int) && (clang.EvalResult_isUnsignedInt(this) != 0); - public CXEvalResultKind Kind => clang.EvalResult_getKind(this); + public CXEvalResultKind Kind => clang.EvalResult_getKind(this); - public static explicit operator CXEvalResult(void* value) => new CXEvalResult((IntPtr)value); + public static explicit operator CXEvalResult(void* value) => new CXEvalResult((IntPtr)value); - public static implicit operator void*(CXEvalResult value) => (void*)value.Handle; + public static implicit operator void*(CXEvalResult value) => (void*)value.Handle; - public static bool operator ==(CXEvalResult left, CXEvalResult right) => left.Handle == right.Handle; + public static bool operator ==(CXEvalResult left, CXEvalResult right) => left.Handle == right.Handle; - public static bool operator !=(CXEvalResult left, CXEvalResult right) => left.Handle != right.Handle; + public static bool operator !=(CXEvalResult left, CXEvalResult right) => left.Handle != right.Handle; - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.EvalResult_dispose(this); - Handle = IntPtr.Zero; - } + clang.EvalResult_dispose(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXEvalResult other) && Equals(other); + public override bool Equals(object obj) => (obj is CXEvalResult other) && Equals(other); - public bool Equals(CXEvalResult other) => this == other; + public bool Equals(CXEvalResult other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); - } + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXFile.cs b/sources/ClangSharp.Interop/Extensions/CXFile.cs index a992e839..55b7dc47 100644 --- a/sources/ClangSharp.Interop/Extensions/CXFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXFile.cs @@ -2,45 +2,44 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXFile : IEquatable { - public unsafe partial struct CXFile : IEquatable + public CXFile(IntPtr handle) { - public CXFile(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public CXString Name => clang.getFileName(this); + public CXString Name => clang.getFileName(this); - public long Time => clang.getFileTime(this); + public long Time => clang.getFileTime(this); - public static explicit operator CXFile(void* value) => new CXFile((IntPtr)value); + public static explicit operator CXFile(void* value) => new CXFile((IntPtr)value); - public static implicit operator void*(CXFile value) => (void*)value.Handle; + public static implicit operator void*(CXFile value) => (void*)value.Handle; - public static bool operator ==(CXFile left, CXFile right) => clang.File_isEqual(left, right) != 0; + public static bool operator ==(CXFile left, CXFile right) => clang.File_isEqual(left, right) != 0; - public static bool operator !=(CXFile left, CXFile right) => clang.File_isEqual(left, right) == 0; + public static bool operator !=(CXFile left, CXFile right) => clang.File_isEqual(left, right) == 0; - public override bool Equals(object obj) => (obj is CXFile other) && Equals(other); + public override bool Equals(object obj) => (obj is CXFile other) && Equals(other); - public bool Equals(CXFile other) => this == other; + public bool Equals(CXFile other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public override string ToString() => Name.ToString(); + public override string ToString() => Name.ToString(); - public bool TryGetUniqueId(out CXFileUniqueID id) + public bool TryGetUniqueId(out CXFileUniqueID id) + { + fixed (CXFileUniqueID* pId = &id) { - fixed (CXFileUniqueID* pId = &id) - { - return clang.getFileUniqueID(this, pId) == 0; - } + return clang.getFileUniqueID(this, pId) == 0; } - - public CXString TryGetRealPathName() => clang.File_tryGetRealPathName(this); } + + public CXString TryGetRealPathName() => clang.File_tryGetRealPathName(this); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxAttrInfo.cs b/sources/ClangSharp.Interop/Extensions/CXIdxAttrInfo.cs index 79375bf3..9828cbd0 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxAttrInfo.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxAttrInfo.cs @@ -1,17 +1,16 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxAttrInfo { - public unsafe partial struct CXIdxAttrInfo + public CXIdxIBOutletCollectionAttrInfo* IBOutletCollectionAttrInfo { - public CXIdxIBOutletCollectionAttrInfo* IBOutletCollectionAttrInfo + get { - get + fixed (CXIdxAttrInfo* pThis = &this) { - fixed (CXIdxAttrInfo* pThis = &this) - { - return clang.index_getIBOutletCollectionAttrInfo(pThis); - } + return clang.index_getIBOutletCollectionAttrInfo(pThis); } } } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs index 969c976e..17e409f6 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs @@ -2,29 +2,28 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxClientASTFile : IEquatable { - public unsafe partial struct CXIdxClientASTFile : IEquatable + public CXIdxClientASTFile(IntPtr handle) { - public CXIdxClientASTFile(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static explicit operator CXIdxClientASTFile(void* value) => new CXIdxClientASTFile((IntPtr)value); + public static explicit operator CXIdxClientASTFile(void* value) => new CXIdxClientASTFile((IntPtr)value); - public static implicit operator void*(CXIdxClientASTFile value) => (void*)value.Handle; + public static implicit operator void*(CXIdxClientASTFile value) => (void*)value.Handle; - public static bool operator ==(CXIdxClientASTFile left, CXIdxClientASTFile right) => left.Handle == right.Handle; + public static bool operator ==(CXIdxClientASTFile left, CXIdxClientASTFile right) => left.Handle == right.Handle; - public static bool operator !=(CXIdxClientASTFile left, CXIdxClientASTFile right) => left.Handle != right.Handle; + public static bool operator !=(CXIdxClientASTFile left, CXIdxClientASTFile right) => left.Handle != right.Handle; - public override bool Equals(object obj) => (obj is CXIdxClientASTFile other) && Equals(other); + public override bool Equals(object obj) => (obj is CXIdxClientASTFile other) && Equals(other); - public bool Equals(CXIdxClientASTFile other) => this == other; + public bool Equals(CXIdxClientASTFile other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); - } + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs index bef65724..03c6fd72 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs @@ -2,29 +2,28 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxClientContainer : IEquatable { - public unsafe partial struct CXIdxClientContainer : IEquatable + public CXIdxClientContainer(IntPtr handle) { - public CXIdxClientContainer(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static explicit operator CXIdxClientContainer(void* value) => new CXIdxClientContainer((IntPtr)value); + public static explicit operator CXIdxClientContainer(void* value) => new CXIdxClientContainer((IntPtr)value); - public static implicit operator void*(CXIdxClientContainer value) => (void*)value.Handle; + public static implicit operator void*(CXIdxClientContainer value) => (void*)value.Handle; - public static bool operator ==(CXIdxClientContainer left, CXIdxClientContainer right) => left.Handle == right.Handle; + public static bool operator ==(CXIdxClientContainer left, CXIdxClientContainer right) => left.Handle == right.Handle; - public static bool operator !=(CXIdxClientContainer left, CXIdxClientContainer right) => left.Handle != right.Handle; + public static bool operator !=(CXIdxClientContainer left, CXIdxClientContainer right) => left.Handle != right.Handle; - public override bool Equals(object obj) => (obj is CXIdxClientContainer other) && Equals(other); + public override bool Equals(object obj) => (obj is CXIdxClientContainer other) && Equals(other); - public bool Equals(CXIdxClientContainer other) => this == other; + public bool Equals(CXIdxClientContainer other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); - } + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs index 3f334dac..af03ab8a 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs @@ -2,29 +2,28 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxClientEntity : IEquatable { - public unsafe partial struct CXIdxClientEntity : IEquatable + public CXIdxClientEntity(IntPtr handle) { - public CXIdxClientEntity(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static explicit operator CXIdxClientEntity(void* value) => new CXIdxClientEntity((IntPtr)value); + public static explicit operator CXIdxClientEntity(void* value) => new CXIdxClientEntity((IntPtr)value); - public static implicit operator void*(CXIdxClientEntity value) => (void*)value.Handle; + public static implicit operator void*(CXIdxClientEntity value) => (void*)value.Handle; - public static bool operator ==(CXIdxClientEntity left, CXIdxClientEntity right) => left.Handle == right.Handle; + public static bool operator ==(CXIdxClientEntity left, CXIdxClientEntity right) => left.Handle == right.Handle; - public static bool operator !=(CXIdxClientEntity left, CXIdxClientEntity right) => left.Handle != right.Handle; + public static bool operator !=(CXIdxClientEntity left, CXIdxClientEntity right) => left.Handle != right.Handle; - public override bool Equals(object obj) => (obj is CXIdxClientEntity other) && Equals(other); + public override bool Equals(object obj) => (obj is CXIdxClientEntity other) && Equals(other); - public bool Equals(CXIdxClientEntity other) => this == other; + public bool Equals(CXIdxClientEntity other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); - } + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs index 3dc15b13..30ee0d24 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs @@ -2,29 +2,28 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxClientFile : IEquatable { - public unsafe partial struct CXIdxClientFile : IEquatable + public CXIdxClientFile(IntPtr handle) { - public CXIdxClientFile(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static explicit operator CXIdxClientFile(void* value) => new CXIdxClientFile((IntPtr)value); + public static explicit operator CXIdxClientFile(void* value) => new CXIdxClientFile((IntPtr)value); - public static implicit operator void*(CXIdxClientFile value) => (void*)value.Handle; + public static implicit operator void*(CXIdxClientFile value) => (void*)value.Handle; - public static bool operator ==(CXIdxClientFile left, CXIdxClientFile right) => left.Handle == right.Handle; + public static bool operator ==(CXIdxClientFile left, CXIdxClientFile right) => left.Handle == right.Handle; - public static bool operator !=(CXIdxClientFile left, CXIdxClientFile right) => left.Handle != right.Handle; + public static bool operator !=(CXIdxClientFile left, CXIdxClientFile right) => left.Handle != right.Handle; - public override bool Equals(object obj) => (obj is CXIdxClientFile other) && Equals(other); + public override bool Equals(object obj) => (obj is CXIdxClientFile other) && Equals(other); - public bool Equals(CXIdxClientFile other) => this == other; + public bool Equals(CXIdxClientFile other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); - } + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxContainerInfo.cs b/sources/ClangSharp.Interop/Extensions/CXIdxContainerInfo.cs index 676ab422..490182d6 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxContainerInfo.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxContainerInfo.cs @@ -1,25 +1,24 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxContainerInfo { - public unsafe partial struct CXIdxContainerInfo + public CXIdxClientContainer ClientContainer { - public CXIdxClientContainer ClientContainer + get { - get + fixed (CXIdxContainerInfo* pThis = &this) { - fixed (CXIdxContainerInfo* pThis = &this) - { - return (CXIdxClientContainer)clang.index_getClientContainer(pThis); - } + return (CXIdxClientContainer)clang.index_getClientContainer(pThis); } + } - set + set + { + fixed (CXIdxContainerInfo* pThis = &this) { - fixed (CXIdxContainerInfo* pThis = &this) - { - clang.index_setClientContainer(pThis, value); - } + clang.index_setClientContainer(pThis, value); } } } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxDeclInfo.cs b/sources/ClangSharp.Interop/Extensions/CXIdxDeclInfo.cs index a5d68370..ef60248d 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxDeclInfo.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxDeclInfo.cs @@ -1,72 +1,71 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxDeclInfo { - public unsafe partial struct CXIdxDeclInfo + public CXIdxCXXClassDeclInfo* CXXClassDeclInfo { - public CXIdxCXXClassDeclInfo* CXXClassDeclInfo + get { - get + fixed (CXIdxDeclInfo* pThis = &this) { - fixed (CXIdxDeclInfo* pThis = &this) - { - return clang.index_getCXXClassDeclInfo(pThis); - } + return clang.index_getCXXClassDeclInfo(pThis); } } + } - public CXIdxObjCCategoryDeclInfo* ObjCCategoryDeclInfo + public CXIdxObjCCategoryDeclInfo* ObjCCategoryDeclInfo + { + get { - get + fixed (CXIdxDeclInfo* pThis = &this) { - fixed (CXIdxDeclInfo* pThis = &this) - { - return clang.index_getObjCCategoryDeclInfo(pThis); - } + return clang.index_getObjCCategoryDeclInfo(pThis); } } + } - public CXIdxObjCContainerDeclInfo* ObjCContainerDeclInfo + public CXIdxObjCContainerDeclInfo* ObjCContainerDeclInfo + { + get { - get + fixed (CXIdxDeclInfo* pThis = &this) { - fixed (CXIdxDeclInfo* pThis = &this) - { - return clang.index_getObjCContainerDeclInfo(pThis); - } + return clang.index_getObjCContainerDeclInfo(pThis); } } + } - public CXIdxObjCInterfaceDeclInfo* ObjCInterfaceDeclInfo + public CXIdxObjCInterfaceDeclInfo* ObjCInterfaceDeclInfo + { + get { - get + fixed (CXIdxDeclInfo* pThis = &this) { - fixed (CXIdxDeclInfo* pThis = &this) - { - return clang.index_getObjCInterfaceDeclInfo(pThis); - } + return clang.index_getObjCInterfaceDeclInfo(pThis); } } + } - public CXIdxObjCPropertyDeclInfo* ObjCPropertyDeclInfo + public CXIdxObjCPropertyDeclInfo* ObjCPropertyDeclInfo + { + get { - get + fixed (CXIdxDeclInfo* pThis = &this) { - fixed (CXIdxDeclInfo* pThis = &this) - { - return clang.index_getObjCPropertyDeclInfo(pThis); - } + return clang.index_getObjCPropertyDeclInfo(pThis); } } + } - public CXIdxObjCProtocolRefListInfo* ObjCProtocolRefListInfo + public CXIdxObjCProtocolRefListInfo* ObjCProtocolRefListInfo + { + get { - get + fixed (CXIdxDeclInfo* pThis = &this) { - fixed (CXIdxDeclInfo* pThis = &this) - { - return clang.index_getObjCProtocolRefListInfo(pThis); - } + return clang.index_getObjCProtocolRefListInfo(pThis); } } } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxEntityInfo.cs b/sources/ClangSharp.Interop/Extensions/CXIdxEntityInfo.cs index 3f9c9bf5..5f1c50fc 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxEntityInfo.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxEntityInfo.cs @@ -1,28 +1,27 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxEntityInfo { - public unsafe partial struct CXIdxEntityInfo + public CXIdxClientEntity ClientEntity { - public CXIdxClientEntity ClientEntity + get { - get + fixed (CXIdxEntityInfo* pThis = &this) { - fixed (CXIdxEntityInfo* pThis = &this) - { - return (CXIdxClientEntity)clang.index_getClientEntity(pThis); - } + return (CXIdxClientEntity)clang.index_getClientEntity(pThis); } + } - set + set + { + fixed (CXIdxEntityInfo* pThis = &this) { - fixed (CXIdxEntityInfo* pThis = &this) - { - clang.index_setClientEntity(pThis, value); - } + clang.index_setClientEntity(pThis, value); } } - - public bool IsObjCContainer => clang.index_isEntityObjCContainerKind(kind) != 0; } + + public bool IsObjCContainer => clang.index_isEntityObjCContainerKind(kind) != 0; } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxLoc.cs b/sources/ClangSharp.Interop/Extensions/CXIdxLoc.cs index 5a890423..76aa7bd0 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxLoc.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxLoc.cs @@ -1,21 +1,20 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIdxLoc { - public unsafe partial struct CXIdxLoc - { - public CXSourceLocation SourceLocation => clang.indexLoc_getCXSourceLocation(this); + public CXSourceLocation SourceLocation => clang.indexLoc_getCXSourceLocation(this); - public void GetFileLocation(out CXIdxClientFile indexFile, out CXFile file, out uint line, out uint column, out uint offset) + public void GetFileLocation(out CXIdxClientFile indexFile, out CXFile file, out uint line, out uint column, out uint offset) + { + fixed (CXIdxClientFile* pIndexFile = &indexFile) + fixed (CXFile* pFile = &file) + fixed (uint* pLine = &line) + fixed (uint* pColumn = &column) + fixed (uint* pOffset = &offset) { - fixed (CXIdxClientFile* pIndexFile = &indexFile) - fixed (CXFile* pFile = &file) - fixed (uint* pLine = &line) - fixed (uint* pColumn = &column) - fixed (uint* pOffset = &offset) - { - clang.indexLoc_getFileLocation(this, (void**)pIndexFile, (void**)pFile, pLine, pColumn, pOffset); - } + clang.indexLoc_getFileLocation(this, (void**)pIndexFile, (void**)pFile, pLine, pColumn, pOffset); } } } diff --git a/sources/ClangSharp.Interop/Extensions/CXIndex.cs b/sources/ClangSharp.Interop/Extensions/CXIndex.cs index af7064ef..68284b36 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIndex.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIndex.cs @@ -2,52 +2,51 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIndex : IDisposable, IEquatable { - public unsafe partial struct CXIndex : IDisposable, IEquatable + public CXIndex(IntPtr handle) + { + Handle = handle; + } + + public CXGlobalOptFlags GlobalOptions { - public CXIndex(IntPtr handle) + get { - Handle = handle; + return (CXGlobalOptFlags)clang.CXIndex_getGlobalOptions(this); } - public CXGlobalOptFlags GlobalOptions + set { - get - { - return (CXGlobalOptFlags)clang.CXIndex_getGlobalOptions(this); - } - - set - { - clang.CXIndex_setGlobalOptions(this, (uint)value); - } + clang.CXIndex_setGlobalOptions(this, (uint)value); } + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static explicit operator CXIndex(void* value) => new CXIndex((IntPtr)value); + public static explicit operator CXIndex(void* value) => new CXIndex((IntPtr)value); - public static implicit operator void*(CXIndex value) => (void*)value.Handle; + public static implicit operator void*(CXIndex value) => (void*)value.Handle; - public static bool operator ==(CXIndex left, CXIndex right) => left.Handle == right.Handle; + public static bool operator ==(CXIndex left, CXIndex right) => left.Handle == right.Handle; - public static bool operator !=(CXIndex left, CXIndex right) => left.Handle != right.Handle; + public static bool operator !=(CXIndex left, CXIndex right) => left.Handle != right.Handle; - public static CXIndex Create(bool excludeDeclarationsFromPch = false, bool displayDiagnostics = false) => (CXIndex)clang.createIndex(excludeDeclarationsFromPch ? 1 : 0, displayDiagnostics ? 1 : 0); + public static CXIndex Create(bool excludeDeclarationsFromPch = false, bool displayDiagnostics = false) => (CXIndex)clang.createIndex(excludeDeclarationsFromPch ? 1 : 0, displayDiagnostics ? 1 : 0); - public void Dispose() => clang.disposeIndex(this); + public void Dispose() => clang.disposeIndex(this); - public override bool Equals(object obj) => (obj is CXIndex other) && Equals(other); + public override bool Equals(object obj) => (obj is CXIndex other) && Equals(other); - public bool Equals(CXIndex other) => this == other; + public bool Equals(CXIndex other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public void SetInvocationEmissionPathOption(string Path) - { - using var marshaledPath = new MarshaledString(Path); - clang.CXIndex_setInvocationEmissionPathOption(this, marshaledPath); - } + public void SetInvocationEmissionPathOption(string Path) + { + using var marshaledPath = new MarshaledString(Path); + clang.CXIndex_setInvocationEmissionPathOption(this, marshaledPath); } } diff --git a/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs b/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs index e744891b..255bd44e 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs @@ -2,78 +2,77 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXIndexAction : IDisposable, IEquatable { - public unsafe partial struct CXIndexAction : IDisposable, IEquatable + public CXIndexAction(IntPtr handle) { - public CXIndexAction(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static explicit operator CXIndexAction(void* value) => new CXIndexAction((IntPtr)value); + public static explicit operator CXIndexAction(void* value) => new CXIndexAction((IntPtr)value); - public static implicit operator void*(CXIndexAction value) => (void*)value.Handle; + public static implicit operator void*(CXIndexAction value) => (void*)value.Handle; - public static bool operator ==(CXIndexAction left, CXIndexAction right) => left.Handle == right.Handle; + public static bool operator ==(CXIndexAction left, CXIndexAction right) => left.Handle == right.Handle; - public static bool operator !=(CXIndexAction left, CXIndexAction right) => left.Handle != right.Handle; + public static bool operator !=(CXIndexAction left, CXIndexAction right) => left.Handle != right.Handle; - public static CXIndexAction Create(CXIndex index) => (CXIndexAction)clang.IndexAction_create(index); + public static CXIndexAction Create(CXIndex index) => (CXIndexAction)clang.IndexAction_create(index); - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.IndexAction_dispose(this); - Handle = IntPtr.Zero; - } + clang.IndexAction_dispose(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXIndexAction other) && Equals(other); + public override bool Equals(object obj) => (obj is CXIndexAction other) && Equals(other); - public bool Equals(CXIndexAction other) => this == other; + public bool Equals(CXIndexAction other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public bool TryIndexSourceFile(CXClientData clientData, ReadOnlySpan indexCallbacks, CXIndexOptFlags indexOptions, string sourceFilename, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, out CXTranslationUnit tu, CXTranslationUnit_Flags tuOptions) + public bool TryIndexSourceFile(CXClientData clientData, ReadOnlySpan indexCallbacks, CXIndexOptFlags indexOptions, string sourceFilename, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, out CXTranslationUnit tu, CXTranslationUnit_Flags tuOptions) + { + using var marshaledSourceFilename = new MarshaledString(sourceFilename); + using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); + + fixed (IndexerCallbacks* pIndexCallbacks = indexCallbacks) + fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) + fixed (CXTranslationUnit* pTU = &tu) { - using var marshaledSourceFilename = new MarshaledString(sourceFilename); - using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); - - fixed (IndexerCallbacks* pIndexCallbacks = indexCallbacks) - fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) - fixed (CXTranslationUnit* pTU = &tu) - { - var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; - marshaledCommandLineArgs.Fill(pCommandLineArgs); - return clang.indexSourceFile(this, clientData, pIndexCallbacks, (uint)indexCallbacks.Length, (uint)indexOptions, marshaledSourceFilename, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (CXTranslationUnitImpl**)pTU, (uint)tuOptions) == 0; - } + var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; + marshaledCommandLineArgs.Fill(pCommandLineArgs); + return clang.indexSourceFile(this, clientData, pIndexCallbacks, (uint)indexCallbacks.Length, (uint)indexOptions, marshaledSourceFilename, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (CXTranslationUnitImpl**)pTU, (uint)tuOptions) == 0; } + } + + public bool TryIndexSourceFileFullArgv(CXClientData clientData, ReadOnlySpan indexCallbacks, CXIndexOptFlags indexOptions, string sourceFilename, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, out CXTranslationUnit tu, CXTranslationUnit_Flags tuOptions) + { + using var marshaledSourceFilename = new MarshaledString(sourceFilename); + using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); - public bool TryIndexSourceFileFullArgv(CXClientData clientData, ReadOnlySpan indexCallbacks, CXIndexOptFlags indexOptions, string sourceFilename, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, out CXTranslationUnit tu, CXTranslationUnit_Flags tuOptions) + fixed (IndexerCallbacks* pIndexCallbacks = indexCallbacks) + fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) + fixed (CXTranslationUnit* pTU = &tu) { - using var marshaledSourceFilename = new MarshaledString(sourceFilename); - using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); - - fixed (IndexerCallbacks* pIndexCallbacks = indexCallbacks) - fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) - fixed (CXTranslationUnit* pTU = &tu) - { - var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; - marshaledCommandLineArgs.Fill(pCommandLineArgs); - return clang.indexSourceFileFullArgv(this, clientData, pIndexCallbacks, (uint)indexCallbacks.Length, (uint)indexOptions, marshaledSourceFilename, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (CXTranslationUnitImpl**)pTU, (uint)tuOptions) == 0; - } + var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; + marshaledCommandLineArgs.Fill(pCommandLineArgs); + return clang.indexSourceFileFullArgv(this, clientData, pIndexCallbacks, (uint)indexCallbacks.Length, (uint)indexOptions, marshaledSourceFilename, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (CXTranslationUnitImpl**)pTU, (uint)tuOptions) == 0; } + } - public bool TryIndexTranslationUnit(CXClientData clientData, ReadOnlySpan indexCallbacks, CXIndexOptFlags indexOptions, CXTranslationUnit tu) + public bool TryIndexTranslationUnit(CXClientData clientData, ReadOnlySpan indexCallbacks, CXIndexOptFlags indexOptions, CXTranslationUnit tu) + { + fixed (IndexerCallbacks* pIndexCallbacks = indexCallbacks) { - fixed (IndexerCallbacks* pIndexCallbacks = indexCallbacks) - { - return clang.indexTranslationUnit(this, clientData, pIndexCallbacks, (uint)indexCallbacks.Length, (uint)indexOptions, tu) == 0; - } + return clang.indexTranslationUnit(this, clientData, pIndexCallbacks, (uint)indexCallbacks.Length, (uint)indexOptions, tu) == 0; } } } diff --git a/sources/ClangSharp.Interop/Extensions/CXModule.cs b/sources/ClangSharp.Interop/Extensions/CXModule.cs index 67d95b18..72eba8a8 100644 --- a/sources/ClangSharp.Interop/Extensions/CXModule.cs +++ b/sources/ClangSharp.Interop/Extensions/CXModule.cs @@ -2,45 +2,44 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXModule : IEquatable { - public unsafe partial struct CXModule : IEquatable + public CXModule(IntPtr handle) { - public CXModule(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public CXFile AstFile => (CXFile)clang.Module_getASTFile(this); + public CXFile AstFile => (CXFile)clang.Module_getASTFile(this); - public CXString FullName => clang.Module_getFullName(this); + public CXString FullName => clang.Module_getFullName(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public bool IsSystem => clang.Module_isSystem(this) != 0; + public bool IsSystem => clang.Module_isSystem(this) != 0; - public CXString Name => clang.Module_getName(this); + public CXString Name => clang.Module_getName(this); - public CXModule Parent => (CXModule)clang.Module_getParent(this); + public CXModule Parent => (CXModule)clang.Module_getParent(this); - public static explicit operator CXModule(void* value) => new CXModule((IntPtr)value); + public static explicit operator CXModule(void* value) => new CXModule((IntPtr)value); - public static implicit operator void*(CXModule value) => (void*)value.Handle; + public static implicit operator void*(CXModule value) => (void*)value.Handle; - public static bool operator ==(CXModule left, CXModule right) => left.Handle == right.Handle; + public static bool operator ==(CXModule left, CXModule right) => left.Handle == right.Handle; - public static bool operator !=(CXModule left, CXModule right) => left.Handle != right.Handle; + public static bool operator !=(CXModule left, CXModule right) => left.Handle != right.Handle; - public override bool Equals(object obj) => (obj is CXModule other) && Equals(other); + public override bool Equals(object obj) => (obj is CXModule other) && Equals(other); - public bool Equals(CXModule other) => this == other; + public bool Equals(CXModule other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public uint GetNumTopLevelHeaders(CXTranslationUnit translationUnit) => clang.Module_getNumTopLevelHeaders(translationUnit, this); + public uint GetNumTopLevelHeaders(CXTranslationUnit translationUnit) => clang.Module_getNumTopLevelHeaders(translationUnit, this); - public CXFile GetTopLevelHeader(CXTranslationUnit translationUnit, uint index) => (CXFile)clang.Module_getTopLevelHeader(translationUnit, this, index); + public CXFile GetTopLevelHeader(CXTranslationUnit translationUnit, uint index) => (CXFile)clang.Module_getTopLevelHeader(translationUnit, this, index); - public override string ToString() => FullName.ToString(); - } + public override string ToString() => FullName.ToString(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs b/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs index 236083d8..237b9b28 100644 --- a/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs +++ b/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs @@ -2,71 +2,70 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXModuleMapDescriptor : IDisposable, IEquatable { - public unsafe partial struct CXModuleMapDescriptor : IDisposable, IEquatable + public CXModuleMapDescriptor(IntPtr handle) { - public CXModuleMapDescriptor(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static implicit operator CXModuleMapDescriptor(CXModuleMapDescriptorImpl* value) => new CXModuleMapDescriptor((IntPtr)value); + public static implicit operator CXModuleMapDescriptor(CXModuleMapDescriptorImpl* value) => new CXModuleMapDescriptor((IntPtr)value); - public static implicit operator CXModuleMapDescriptorImpl*(CXModuleMapDescriptor value) => (CXModuleMapDescriptorImpl*)value.Handle; + public static implicit operator CXModuleMapDescriptorImpl*(CXModuleMapDescriptor value) => (CXModuleMapDescriptorImpl*)value.Handle; - public static bool operator ==(CXModuleMapDescriptor left, CXModuleMapDescriptor right) => left.Handle == right.Handle; + public static bool operator ==(CXModuleMapDescriptor left, CXModuleMapDescriptor right) => left.Handle == right.Handle; - public static bool operator !=(CXModuleMapDescriptor left, CXModuleMapDescriptor right) => left.Handle != right.Handle; + public static bool operator !=(CXModuleMapDescriptor left, CXModuleMapDescriptor right) => left.Handle != right.Handle; - public static CXModuleMapDescriptor Create(uint options) => clang.ModuleMapDescriptor_create(options); + public static CXModuleMapDescriptor Create(uint options) => clang.ModuleMapDescriptor_create(options); - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.ModuleMapDescriptor_dispose(this); - Handle = IntPtr.Zero; - } + clang.ModuleMapDescriptor_dispose(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXModuleMapDescriptor other) && Equals(other); + public override bool Equals(object obj) => (obj is CXModuleMapDescriptor other) && Equals(other); - public bool Equals(CXModuleMapDescriptor other) => this == other; + public bool Equals(CXModuleMapDescriptor other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public CXErrorCode SetFrameworkModuleName(string name) - { - var marshaledName = new MarshaledString(name); - return clang.ModuleMapDescriptor_setFrameworkModuleName(this, marshaledName); - } + public CXErrorCode SetFrameworkModuleName(string name) + { + var marshaledName = new MarshaledString(name); + return clang.ModuleMapDescriptor_setFrameworkModuleName(this, marshaledName); + } - public CXErrorCode SetUmbrellaHeader(string name) - { - using var marshaledName = new MarshaledString(name); - return clang.ModuleMapDescriptor_setUmbrellaHeader(this, marshaledName); - } + public CXErrorCode SetUmbrellaHeader(string name) + { + using var marshaledName = new MarshaledString(name); + return clang.ModuleMapDescriptor_setUmbrellaHeader(this, marshaledName); + } - public Span WriteToBuffer(uint options, out CXErrorCode errorCode) - { - sbyte* pBuffer; uint size; - errorCode = clang.ModuleMapDescriptor_writeToBuffer(this, options, &pBuffer, &size); + public Span WriteToBuffer(uint options, out CXErrorCode errorCode) + { + sbyte* pBuffer; uint size; + errorCode = clang.ModuleMapDescriptor_writeToBuffer(this, options, &pBuffer, &size); #if NETSTANDARD - var result = new byte[checked((int)size)]; + var result = new byte[checked((int)size)]; - fixed (byte* pResult = result) - { - Buffer.MemoryCopy(pBuffer, pResult, size, size); - } + fixed (byte* pResult = result) + { + Buffer.MemoryCopy(pBuffer, pResult, size, size); + } - return result; + return result; #else - return new Span(pBuffer, (int)size); + return new Span(pBuffer, (int)size); #endif - } } } diff --git a/sources/ClangSharp.Interop/Extensions/CXPlatformAvailability.cs b/sources/ClangSharp.Interop/Extensions/CXPlatformAvailability.cs index 539b64b1..7d3f3d7a 100644 --- a/sources/ClangSharp.Interop/Extensions/CXPlatformAvailability.cs +++ b/sources/ClangSharp.Interop/Extensions/CXPlatformAvailability.cs @@ -2,16 +2,15 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXPlatformAvailability : IDisposable { - public unsafe partial struct CXPlatformAvailability : IDisposable + public void Dispose() { - public void Dispose() + fixed (CXPlatformAvailability* pThis = &this) { - fixed (CXPlatformAvailability* pThis = &this) - { - clang.disposeCXPlatformAvailability(pThis); - } + clang.disposeCXPlatformAvailability(pThis); } } } diff --git a/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs b/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs index 31d35600..80a2368c 100644 --- a/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs +++ b/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs @@ -2,42 +2,41 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXPrintingPolicy : IDisposable, IEquatable { - public unsafe partial struct CXPrintingPolicy : IDisposable, IEquatable + public CXPrintingPolicy(IntPtr handle) { - public CXPrintingPolicy(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static explicit operator CXPrintingPolicy(void* value) => new CXPrintingPolicy((IntPtr)value); + public static explicit operator CXPrintingPolicy(void* value) => new CXPrintingPolicy((IntPtr)value); - public static implicit operator void*(CXPrintingPolicy value) => (void*)value.Handle; + public static implicit operator void*(CXPrintingPolicy value) => (void*)value.Handle; - public static bool operator ==(CXPrintingPolicy left, CXPrintingPolicy right) => left.Handle == right.Handle; + public static bool operator ==(CXPrintingPolicy left, CXPrintingPolicy right) => left.Handle == right.Handle; - public static bool operator !=(CXPrintingPolicy left, CXPrintingPolicy right) => left.Handle != right.Handle; + public static bool operator !=(CXPrintingPolicy left, CXPrintingPolicy right) => left.Handle != right.Handle; - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.PrintingPolicy_dispose(this); - Handle = IntPtr.Zero; - } + clang.PrintingPolicy_dispose(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXPrintingPolicy other) && Equals(other); + public override bool Equals(object obj) => (obj is CXPrintingPolicy other) && Equals(other); - public bool Equals(CXPrintingPolicy other) => this == other; + public bool Equals(CXPrintingPolicy other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public uint GetProperty(CXPrintingPolicyProperty property) => clang.PrintingPolicy_getProperty(this, property); + public uint GetProperty(CXPrintingPolicyProperty property) => clang.PrintingPolicy_getProperty(this, property); - public void SetProperty(CXPrintingPolicyProperty property, uint value) => clang.PrintingPolicy_setProperty(this, property, value); - } + public void SetProperty(CXPrintingPolicyProperty property, uint value) => clang.PrintingPolicy_setProperty(this, property, value); } diff --git a/sources/ClangSharp.Interop/Extensions/CXRemapping.cs b/sources/ClangSharp.Interop/Extensions/CXRemapping.cs index 19749c9d..878e875a 100644 --- a/sources/ClangSharp.Interop/Extensions/CXRemapping.cs +++ b/sources/ClangSharp.Interop/Extensions/CXRemapping.cs @@ -2,64 +2,63 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXRemapping : IDisposable, IEquatable { - public unsafe partial struct CXRemapping : IDisposable, IEquatable + public CXRemapping(IntPtr handle) { - public CXRemapping(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public static CXRemapping GetRemappings(string path) - { - using var marshaledPath = new MarshaledString(path); - return (CXRemapping)clang.getRemappings(marshaledPath); - } + public static CXRemapping GetRemappings(string path) + { + using var marshaledPath = new MarshaledString(path); + return (CXRemapping)clang.getRemappings(marshaledPath); + } - public static CXRemapping GetRemappingsFromFileList(ReadOnlySpan filePaths) - { - using var marshaledPaths = new MarshaledStringArray(filePaths); - var pMarshaledPaths = stackalloc sbyte*[filePaths.Length]; + public static CXRemapping GetRemappingsFromFileList(ReadOnlySpan filePaths) + { + using var marshaledPaths = new MarshaledStringArray(filePaths); + var pMarshaledPaths = stackalloc sbyte*[filePaths.Length]; - marshaledPaths.Fill(pMarshaledPaths); - return (CXRemapping)clang.getRemappingsFromFileList(pMarshaledPaths, (uint)filePaths.Length); - } + marshaledPaths.Fill(pMarshaledPaths); + return (CXRemapping)clang.getRemappingsFromFileList(pMarshaledPaths, (uint)filePaths.Length); + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public uint NumFiles => clang.remap_getNumFiles(this); + public uint NumFiles => clang.remap_getNumFiles(this); - public static explicit operator CXRemapping(void* value) => new CXRemapping((IntPtr)value); + public static explicit operator CXRemapping(void* value) => new CXRemapping((IntPtr)value); - public static implicit operator void*(CXRemapping value) => (void*)value.Handle; + public static implicit operator void*(CXRemapping value) => (void*)value.Handle; - public static bool operator ==(CXRemapping left, CXRemapping right) => left.Handle == right.Handle; + public static bool operator ==(CXRemapping left, CXRemapping right) => left.Handle == right.Handle; - public static bool operator !=(CXRemapping left, CXRemapping right) => left.Handle != right.Handle; + public static bool operator !=(CXRemapping left, CXRemapping right) => left.Handle != right.Handle; - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.remap_dispose(this); - Handle = IntPtr.Zero; - } + clang.remap_dispose(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXRemapping other) && Equals(other); + public override bool Equals(object obj) => (obj is CXRemapping other) && Equals(other); - public bool Equals(CXRemapping other) => this == other; + public bool Equals(CXRemapping other) => this == other; - public void GetFilenames(uint index, out CXString original, out CXString transformed) + public void GetFilenames(uint index, out CXString original, out CXString transformed) + { + fixed (CXString* pOriginal = &original) + fixed (CXString* pTransformed = &transformed) { - fixed (CXString* pOriginal = &original) - fixed (CXString* pTransformed = &transformed) - { - clang.remap_getFilenames(this, index, pOriginal, pTransformed); - } + clang.remap_getFilenames(this, index, pOriginal, pTransformed); } - - public override int GetHashCode() => Handle.GetHashCode(); } + + public override int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXSourceLocation.cs b/sources/ClangSharp.Interop/Extensions/CXSourceLocation.cs index 1802a094..e5f4fec2 100644 --- a/sources/ClangSharp.Interop/Extensions/CXSourceLocation.cs +++ b/sources/ClangSharp.Interop/Extensions/CXSourceLocation.cs @@ -2,84 +2,83 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXSourceLocation : IEquatable { - public unsafe partial struct CXSourceLocation : IEquatable - { - public static CXSourceLocation Null => clang.getNullLocation(); + public static CXSourceLocation Null => clang.getNullLocation(); - public bool IsFromMainFile => clang.Location_isFromMainFile(this) != 0; + public bool IsFromMainFile => clang.Location_isFromMainFile(this) != 0; - public bool IsInSystemHeader => clang.Location_isInSystemHeader(this) != 0; + public bool IsInSystemHeader => clang.Location_isInSystemHeader(this) != 0; - public static bool operator ==(CXSourceLocation left, CXSourceLocation right) => clang.equalLocations(left, right) != 0; + public static bool operator ==(CXSourceLocation left, CXSourceLocation right) => clang.equalLocations(left, right) != 0; - public static bool operator !=(CXSourceLocation left, CXSourceLocation right) => clang.equalLocations(left, right) == 0; + public static bool operator !=(CXSourceLocation left, CXSourceLocation right) => clang.equalLocations(left, right) == 0; - public override bool Equals(object obj) => (obj is CXSourceLocation other) && Equals(other); + public override bool Equals(object obj) => (obj is CXSourceLocation other) && Equals(other); - public bool Equals(CXSourceLocation other) => this == other; + public bool Equals(CXSourceLocation other) => this == other; - public void GetExpansionLocation(out CXFile file, out uint line, out uint column, out uint offset) + public void GetExpansionLocation(out CXFile file, out uint line, out uint column, out uint offset) + { + fixed (CXFile* pFile = &file) + fixed (uint* pLine = &line) + fixed (uint* pColumn = &column) + fixed (uint* pOffset = &offset) { - fixed (CXFile* pFile = &file) - fixed (uint* pLine = &line) - fixed (uint* pColumn = &column) - fixed (uint* pOffset = &offset) - { - clang.getExpansionLocation(this, (void**)pFile, pLine, pColumn, pOffset); - } + clang.getExpansionLocation(this, (void**)pFile, pLine, pColumn, pOffset); } + } - public void GetFileLocation(out CXFile file, out uint line, out uint column, out uint offset) + public void GetFileLocation(out CXFile file, out uint line, out uint column, out uint offset) + { + fixed (CXFile* pFile = &file) + fixed (uint* pLine = &line) + fixed (uint* pColumn = &column) + fixed (uint* pOffset = &offset) { - fixed (CXFile* pFile = &file) - fixed (uint* pLine = &line) - fixed (uint* pColumn = &column) - fixed (uint* pOffset = &offset) - { - clang.getFileLocation(this, (void**)pFile, pLine, pColumn, pOffset); - } + clang.getFileLocation(this, (void**)pFile, pLine, pColumn, pOffset); } + } - public override int GetHashCode() => HashCode.Combine(ptr_data, int_data); + public override int GetHashCode() => HashCode.Combine(ptr_data, int_data); - public void GetInstantiationLocation(out CXFile file, out uint line, out uint column, out uint offset) + public void GetInstantiationLocation(out CXFile file, out uint line, out uint column, out uint offset) + { + fixed (CXFile* pFile = &file) + fixed (uint* pLine = &line) + fixed (uint* pColumn = &column) + fixed (uint* pOffset = &offset) { - fixed (CXFile* pFile = &file) - fixed (uint* pLine = &line) - fixed (uint* pColumn = &column) - fixed (uint* pOffset = &offset) - { - clang.getInstantiationLocation(this, (void**)pFile, pLine, pColumn, pOffset); - } + clang.getInstantiationLocation(this, (void**)pFile, pLine, pColumn, pOffset); } + } - public void GetPresumedLocation(out CXString fileName, out uint line, out uint column) + public void GetPresumedLocation(out CXString fileName, out uint line, out uint column) + { + fixed (CXString* pFileName = &fileName) + fixed (uint* pLine = &line) + fixed (uint* pColumn = &column) { - fixed (CXString* pFileName = &fileName) - fixed (uint* pLine = &line) - fixed (uint* pColumn = &column) - { - clang.getPresumedLocation(this, pFileName, pLine, pColumn); - } + clang.getPresumedLocation(this, pFileName, pLine, pColumn); } + } - public void GetSpellingLocation(out CXFile file, out uint line, out uint column, out uint offset) + public void GetSpellingLocation(out CXFile file, out uint line, out uint column, out uint offset) + { + fixed (CXFile* pFile = &file) + fixed (uint* pLine = &line) + fixed (uint* pColumn = &column) + fixed (uint* pOffset = &offset) { - fixed (CXFile* pFile = &file) - fixed (uint* pLine = &line) - fixed (uint* pColumn = &column) - fixed (uint* pOffset = &offset) - { - clang.getSpellingLocation(this, (void**)pFile, pLine, pColumn, pOffset); - } + clang.getSpellingLocation(this, (void**)pFile, pLine, pColumn, pOffset); } + } - public override string ToString() - { - GetSpellingLocation(out var file, out var line, out var column, out _); - return $"Line {line}, Column {column} in {file}"; - } + public override string ToString() + { + GetSpellingLocation(out var file, out var line, out var column, out _); + return $"Line {line}, Column {column} in {file}"; } } diff --git a/sources/ClangSharp.Interop/Extensions/CXSourceRange.cs b/sources/ClangSharp.Interop/Extensions/CXSourceRange.cs index 033197a1..43480978 100644 --- a/sources/ClangSharp.Interop/Extensions/CXSourceRange.cs +++ b/sources/ClangSharp.Interop/Extensions/CXSourceRange.cs @@ -2,32 +2,31 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXSourceRange : IEquatable { - public partial struct CXSourceRange : IEquatable - { - public static CXSourceRange Null => clang.getNullRange(); + public static CXSourceRange Null => clang.getNullRange(); - public CXSourceLocation End => clang.getRangeEnd(this); + public CXSourceLocation End => clang.getRangeEnd(this); - public bool IsNull => clang.Range_isNull(this) != 0; + public bool IsNull => clang.Range_isNull(this) != 0; - public CXSourceLocation Start => clang.getRangeStart(this); + public CXSourceLocation Start => clang.getRangeStart(this); - public static bool operator ==(CXSourceRange left, CXSourceRange right) => Equals(left, right); + public static bool operator ==(CXSourceRange left, CXSourceRange right) => Equals(left, right); - public static bool operator !=(CXSourceRange left, CXSourceRange right) => !Equals(left, right); + public static bool operator !=(CXSourceRange left, CXSourceRange right) => !Equals(left, right); - public static bool Equals(CXSourceRange range1, CXSourceRange range2) => clang.equalRanges(range1, range2) != 0; + public static bool Equals(CXSourceRange range1, CXSourceRange range2) => clang.equalRanges(range1, range2) != 0; - public static CXSourceRange Create(CXSourceLocation begin, CXSourceLocation end) => clang.getRange(begin, end); + public static CXSourceRange Create(CXSourceLocation begin, CXSourceLocation end) => clang.getRange(begin, end); - public override bool Equals(object obj) => (obj is CXSourceRange other) && Equals(other); + public override bool Equals(object obj) => (obj is CXSourceRange other) && Equals(other); - public bool Equals(CXSourceRange other) => this == other; + public bool Equals(CXSourceRange other) => this == other; - public override int GetHashCode() => HashCode.Combine(ptr_data, begin_int_data, end_int_data); + public override int GetHashCode() => HashCode.Combine(ptr_data, begin_int_data, end_int_data); - public override string ToString() => $"{Start} to {End}"; - } + public override string ToString() => $"{Start} to {End}"; } diff --git a/sources/ClangSharp.Interop/Extensions/CXSourceRangeList.cs b/sources/ClangSharp.Interop/Extensions/CXSourceRangeList.cs index 81e485f0..475858ec 100644 --- a/sources/ClangSharp.Interop/Extensions/CXSourceRangeList.cs +++ b/sources/ClangSharp.Interop/Extensions/CXSourceRangeList.cs @@ -4,32 +4,31 @@ using System.Collections; using System.Collections.Generic; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXSourceRangeList : IDisposable, IReadOnlyCollection { - public unsafe partial struct CXSourceRangeList : IDisposable, IReadOnlyCollection - { - public unsafe CXSourceRange this[uint index] => ranges[index]; + public unsafe CXSourceRange this[uint index] => ranges[index]; - public int Count => (int)count; + public int Count => (int)count; - public void Dispose() + public void Dispose() + { + fixed (CXSourceRangeList* pThis = &this) { - fixed (CXSourceRangeList* pThis = &this) - { - clang.disposeSourceRangeList(pThis); - } + clang.disposeSourceRangeList(pThis); } + } - public IEnumerator GetEnumerator() - { - var count = (uint)Count; + public IEnumerator GetEnumerator() + { + var count = (uint)Count; - for (var index = 0u; index < count; index++) - { - yield return this[index]; - } + for (var index = 0u; index < count; index++) + { + yield return this[index]; } - - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXString.cs b/sources/ClangSharp.Interop/Extensions/CXString.cs index 96342078..b1c76dfa 100644 --- a/sources/ClangSharp.Interop/Extensions/CXString.cs +++ b/sources/ClangSharp.Interop/Extensions/CXString.cs @@ -2,65 +2,64 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXString : IDisposable { - public unsafe partial struct CXString : IDisposable + public static CXString ConstructUsr_ObjCClass(string className) { - public static CXString ConstructUsr_ObjCClass(string className) - { - using var marshaledClassName = new MarshaledString(className); - return clang.constructUSR_ObjCClass(marshaledClassName); - } + using var marshaledClassName = new MarshaledString(className); + return clang.constructUSR_ObjCClass(marshaledClassName); + } - public static CXString ConstructUsr_ObjCCategory(string className, string categoryName) - { - using var marshaledClassName = new MarshaledString(className); - using var marshaledCategoryName = new MarshaledString(categoryName); - return clang.constructUSR_ObjCCategory(marshaledClassName, marshaledCategoryName); - } + public static CXString ConstructUsr_ObjCCategory(string className, string categoryName) + { + using var marshaledClassName = new MarshaledString(className); + using var marshaledCategoryName = new MarshaledString(categoryName); + return clang.constructUSR_ObjCCategory(marshaledClassName, marshaledCategoryName); + } - public static CXString ConstructUsr_ObjCProtocol(string protocolName) - { - using var marshaledProtocolName = new MarshaledString(protocolName); - return clang.constructUSR_ObjCProtocol(marshaledProtocolName); - } + public static CXString ConstructUsr_ObjCProtocol(string protocolName) + { + using var marshaledProtocolName = new MarshaledString(protocolName); + return clang.constructUSR_ObjCProtocol(marshaledProtocolName); + } - public static CXString ConstructUsr_ObjCIvar(string name, CXString classUsr) - { - using var marshaledName = new MarshaledString(name); - return clang.constructUSR_ObjCIvar(marshaledName, classUsr); - } + public static CXString ConstructUsr_ObjCIvar(string name, CXString classUsr) + { + using var marshaledName = new MarshaledString(name); + return clang.constructUSR_ObjCIvar(marshaledName, classUsr); + } - public static CXString ConstructUsr_ObjCMethod(string name, bool isInstanceMethod, CXString classUsr) - { - using var marshaledName = new MarshaledString(name); - return clang.constructUSR_ObjCMethod(marshaledName, isInstanceMethod ? 1u : 0u, classUsr); - } + public static CXString ConstructUsr_ObjCMethod(string name, bool isInstanceMethod, CXString classUsr) + { + using var marshaledName = new MarshaledString(name); + return clang.constructUSR_ObjCMethod(marshaledName, isInstanceMethod ? 1u : 0u, classUsr); + } - public static CXString ConstructUsr_ObjCProperty(string property, CXString classUsr) - { - using var marshaledProperty = new MarshaledString(property); - return clang.constructUSR_ObjCProperty(marshaledProperty, classUsr); - } + public static CXString ConstructUsr_ObjCProperty(string property, CXString classUsr) + { + using var marshaledProperty = new MarshaledString(property); + return clang.constructUSR_ObjCProperty(marshaledProperty, classUsr); + } - public string CString + public string CString + { + get { - get - { - var pCString = clang.getCString(this); + var pCString = clang.getCString(this); - if (pCString is null) - { - return string.Empty; - } - - var span = new ReadOnlySpan(pCString, int.MaxValue); - return span.Slice(0, span.IndexOf((byte)'\0')).AsString(); + if (pCString is null) + { + return string.Empty; } + + var span = new ReadOnlySpan(pCString, int.MaxValue); + return span.Slice(0, span.IndexOf((byte)'\0')).AsString(); } + } - public void Dispose() => clang.disposeString(this); + public void Dispose() => clang.disposeString(this); - public override string ToString() => CString; - } + public override string ToString() => CString; } diff --git a/sources/ClangSharp.Interop/Extensions/CXStringSet.cs b/sources/ClangSharp.Interop/Extensions/CXStringSet.cs index 58bcf397..9509db2e 100644 --- a/sources/ClangSharp.Interop/Extensions/CXStringSet.cs +++ b/sources/ClangSharp.Interop/Extensions/CXStringSet.cs @@ -4,32 +4,31 @@ using System.Collections; using System.Collections.Generic; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXStringSet : IDisposable, IReadOnlyCollection { - public unsafe partial struct CXStringSet : IDisposable, IReadOnlyCollection - { - public CXString this[uint index] => Strings[index]; + public CXString this[uint index] => Strings[index]; - int IReadOnlyCollection.Count => (int)Count; + int IReadOnlyCollection.Count => (int)Count; - public void Dispose() + public void Dispose() + { + fixed (CXStringSet* pThis = &this) { - fixed (CXStringSet* pThis = &this) - { - clang.disposeStringSet(pThis); - } + clang.disposeStringSet(pThis); } + } - public IEnumerator GetEnumerator() - { - var count = Count; + public IEnumerator GetEnumerator() + { + var count = Count; - for (var index = 0u; index < count; index++) - { - yield return this[index]; - } + for (var index = 0u; index < count; index++) + { + yield return this[index]; } - - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXTUResourceUsage.cs b/sources/ClangSharp.Interop/Extensions/CXTUResourceUsage.cs index fbaf9cf1..ed272c9a 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTUResourceUsage.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTUResourceUsage.cs @@ -4,26 +4,25 @@ using System.Collections; using System.Collections.Generic; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct CXTUResourceUsage : IDisposable, IReadOnlyCollection { - public partial struct CXTUResourceUsage : IDisposable, IReadOnlyCollection - { - public unsafe CXTUResourceUsageEntry this[uint index] => entries[index]; + public unsafe CXTUResourceUsageEntry this[uint index] => entries[index]; - public int Count => (int)numEntries; + public int Count => (int)numEntries; - public void Dispose() => clang.disposeCXTUResourceUsage(this); + public void Dispose() => clang.disposeCXTUResourceUsage(this); - public IEnumerator GetEnumerator() - { - var count = (uint)Count; + public IEnumerator GetEnumerator() + { + var count = (uint)Count; - for (var index = 0u; index < count; index++) - { - yield return this[index]; - } + for (var index = 0u; index < count; index++) + { + yield return this[index]; } - - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXTUResourceUsageEntry.cs b/sources/ClangSharp.Interop/Extensions/CXTUResourceUsageEntry.cs index 5619309d..e3b7c657 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTUResourceUsageEntry.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTUResourceUsageEntry.cs @@ -2,26 +2,25 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXTUResourceUsageEntry { - public unsafe partial struct CXTUResourceUsageEntry + public string Name { - public string Name + get { - get - { - var pName = clang.getTUResourceUsageName(kind); + var pName = clang.getTUResourceUsageName(kind); - if (pName is null) - { - return string.Empty; - } - - var span = new ReadOnlySpan(pName, int.MaxValue); - return span.Slice(0, span.IndexOf((byte)'\0')).AsString(); + if (pName is null) + { + return string.Empty; } - } - public override string ToString() => Name; + var span = new ReadOnlySpan(pName, int.MaxValue); + return span.Slice(0, span.IndexOf((byte)'\0')).AsString(); + } } + + public override string ToString() => Name; } diff --git a/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs b/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs index 31d00bfa..49bb1f7e 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs @@ -2,44 +2,43 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXTargetInfo : IDisposable, IEquatable { - public unsafe partial struct CXTargetInfo : IDisposable, IEquatable + public CXTargetInfo(IntPtr handle) { - public CXTargetInfo(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public int PointerWidth => clang.TargetInfo_getPointerWidth(this); + public int PointerWidth => clang.TargetInfo_getPointerWidth(this); - public CXString Triple => clang.TargetInfo_getTriple(this); + public CXString Triple => clang.TargetInfo_getTriple(this); - public static implicit operator CXTargetInfo(CXTargetInfoImpl* value) => new CXTargetInfo((IntPtr)value); + public static implicit operator CXTargetInfo(CXTargetInfoImpl* value) => new CXTargetInfo((IntPtr)value); - public static implicit operator CXTargetInfoImpl*(CXTargetInfo value) => (CXTargetInfoImpl*)value.Handle; + public static implicit operator CXTargetInfoImpl*(CXTargetInfo value) => (CXTargetInfoImpl*)value.Handle; - public static bool operator ==(CXTargetInfo left, CXTargetInfo right) => left.Handle == right.Handle; + public static bool operator ==(CXTargetInfo left, CXTargetInfo right) => left.Handle == right.Handle; - public static bool operator !=(CXTargetInfo left, CXTargetInfo right) => left.Handle != right.Handle; + public static bool operator !=(CXTargetInfo left, CXTargetInfo right) => left.Handle != right.Handle; - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.TargetInfo_dispose(this); - Handle = IntPtr.Zero; - } + clang.TargetInfo_dispose(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXTargetInfo other) && Equals(other); + public override bool Equals(object obj) => (obj is CXTargetInfo other) && Equals(other); - public bool Equals(CXTargetInfo other) => this == other; + public bool Equals(CXTargetInfo other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public override string ToString() => Triple.ToString(); - } + public override string ToString() => Triple.ToString(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXToken.cs b/sources/ClangSharp.Interop/Extensions/CXToken.cs index 02a580fb..098975b7 100644 --- a/sources/ClangSharp.Interop/Extensions/CXToken.cs +++ b/sources/ClangSharp.Interop/Extensions/CXToken.cs @@ -2,42 +2,41 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXToken : IEquatable { - public unsafe partial struct CXToken : IEquatable - { - public CXTokenKind Kind => clang.getTokenKind(this); + public CXTokenKind Kind => clang.getTokenKind(this); - public static bool operator ==(CXToken left, CXToken right) - { - return (left.int_data[0] == right.int_data[0]) && - (left.int_data[1] == right.int_data[1]) && - (left.int_data[2] == right.int_data[2]) && - (left.int_data[3] == right.int_data[3]) && - (left.ptr_data == right.ptr_data); - } + public static bool operator ==(CXToken left, CXToken right) + { + return (left.int_data[0] == right.int_data[0]) && + (left.int_data[1] == right.int_data[1]) && + (left.int_data[2] == right.int_data[2]) && + (left.int_data[3] == right.int_data[3]) && + (left.ptr_data == right.ptr_data); + } - public static bool operator !=(CXToken left, CXToken right) - { - return (left.int_data[0] != right.int_data[0]) || - (left.int_data[1] != right.int_data[1]) || - (left.int_data[2] != right.int_data[2]) || - (left.int_data[3] != right.int_data[3]) || - (left.ptr_data != right.ptr_data); - } + public static bool operator !=(CXToken left, CXToken right) + { + return (left.int_data[0] != right.int_data[0]) || + (left.int_data[1] != right.int_data[1]) || + (left.int_data[2] != right.int_data[2]) || + (left.int_data[3] != right.int_data[3]) || + (left.ptr_data != right.ptr_data); + } - public override bool Equals(object obj) => (obj is CXSourceRange other) && Equals(other); + public override bool Equals(object obj) => (obj is CXSourceRange other) && Equals(other); - public bool Equals(CXToken other) => this == other; + public bool Equals(CXToken other) => this == other; - public CXSourceRange GetExtent(CXTranslationUnit translationUnit) => clang.getTokenExtent(translationUnit, this); + public CXSourceRange GetExtent(CXTranslationUnit translationUnit) => clang.getTokenExtent(translationUnit, this); - public override int GetHashCode() => HashCode.Combine(int_data[0], int_data[1], int_data[2], int_data[3], (IntPtr)ptr_data); + public override int GetHashCode() => HashCode.Combine(int_data[0], int_data[1], int_data[2], int_data[3], (IntPtr)ptr_data); - public CXSourceLocation GetLocation(CXTranslationUnit translationUnit) => clang.getTokenLocation(translationUnit, this); + public CXSourceLocation GetLocation(CXTranslationUnit translationUnit) => clang.getTokenLocation(translationUnit, this); - public CXString GetSpelling(CXTranslationUnit translationUnit) => clang.getTokenSpelling(translationUnit, this); + public CXString GetSpelling(CXTranslationUnit translationUnit) => clang.getTokenSpelling(translationUnit, this); - public override string ToString() => ""; - } + public override string ToString() => ""; } diff --git a/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs b/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs index 6dda2370..8bc668fc 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs @@ -3,241 +3,240 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXTranslationUnit : IDisposable, IEquatable { - public unsafe partial struct CXTranslationUnit : IDisposable, IEquatable + public CXTranslationUnit(IntPtr handle) { - public CXTranslationUnit(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public static CXTranslationUnit_Flags DefaultEditingOptions => (CXTranslationUnit_Flags)clang.defaultEditingTranslationUnitOptions(); + public static CXTranslationUnit_Flags DefaultEditingOptions => (CXTranslationUnit_Flags)clang.defaultEditingTranslationUnitOptions(); - public CXSourceRangeList* AllSkippedRanges => clang.getAllSkippedRanges(this); + public CXSourceRangeList* AllSkippedRanges => clang.getAllSkippedRanges(this); - public CXCursor Cursor => clang.getTranslationUnitCursor(this); + public CXCursor Cursor => clang.getTranslationUnitCursor(this); - public CXReparse_Flags DefaultReparseOptions => (CXReparse_Flags)clang.defaultReparseOptions(this); + public CXReparse_Flags DefaultReparseOptions => (CXReparse_Flags)clang.defaultReparseOptions(this); - public CXSaveTranslationUnit_Flags DefaultSaveOptions => (CXSaveTranslationUnit_Flags)clang.defaultSaveOptions(this); + public CXSaveTranslationUnit_Flags DefaultSaveOptions => (CXSaveTranslationUnit_Flags)clang.defaultSaveOptions(this); - public CXDiagnosticSet DiagnosticSet => (CXDiagnosticSet)clang.getDiagnosticSetFromTU(this); + public CXDiagnosticSet DiagnosticSet => (CXDiagnosticSet)clang.getDiagnosticSetFromTU(this); - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public uint NumDiagnostics => clang.getNumDiagnostics(this); + public uint NumDiagnostics => clang.getNumDiagnostics(this); - public CXTUResourceUsage ResourceUsage => clang.getCXTUResourceUsage(this); + public CXTUResourceUsage ResourceUsage => clang.getCXTUResourceUsage(this); - public CXString Spelling => clang.getTranslationUnitSpelling(this); + public CXString Spelling => clang.getTranslationUnitSpelling(this); - public CXTargetInfo TargetInfo => clang.getTranslationUnitTargetInfo(this); + public CXTargetInfo TargetInfo => clang.getTranslationUnitTargetInfo(this); - public static implicit operator CXTranslationUnit(CXTranslationUnitImpl* value) => new CXTranslationUnit((IntPtr)value); + public static implicit operator CXTranslationUnit(CXTranslationUnitImpl* value) => new CXTranslationUnit((IntPtr)value); - public static implicit operator CXTranslationUnitImpl*(CXTranslationUnit value) => (CXTranslationUnitImpl*)value.Handle; + public static implicit operator CXTranslationUnitImpl*(CXTranslationUnit value) => (CXTranslationUnitImpl*)value.Handle; - public static bool operator ==(CXTranslationUnit left, CXTranslationUnit right) => left.Handle == right.Handle; + public static bool operator ==(CXTranslationUnit left, CXTranslationUnit right) => left.Handle == right.Handle; - public static bool operator !=(CXTranslationUnit left, CXTranslationUnit right) => left.Handle != right.Handle; + public static bool operator !=(CXTranslationUnit left, CXTranslationUnit right) => left.Handle != right.Handle; - public static CXTranslationUnit Create(CXIndex index, string astFileName) - { - using var marshaledAstFileName = new MarshaledString(astFileName); - return clang.createTranslationUnit(index, marshaledAstFileName); - } + public static CXTranslationUnit Create(CXIndex index, string astFileName) + { + using var marshaledAstFileName = new MarshaledString(astFileName); + return clang.createTranslationUnit(index, marshaledAstFileName); + } - public static CXErrorCode Create(CXIndex index, string astFileName, out CXTranslationUnit translationUnit) - { - using var marshaledAstFileName = new MarshaledString(astFileName); + public static CXErrorCode Create(CXIndex index, string astFileName, out CXTranslationUnit translationUnit) + { + using var marshaledAstFileName = new MarshaledString(astFileName); - fixed (CXTranslationUnit* pTranslationUnit = &translationUnit) - { - return clang.createTranslationUnit2(index, marshaledAstFileName, (CXTranslationUnitImpl**)pTranslationUnit); - } + fixed (CXTranslationUnit* pTranslationUnit = &translationUnit) + { + return clang.createTranslationUnit2(index, marshaledAstFileName, (CXTranslationUnitImpl**)pTranslationUnit); } + } - public static CXTranslationUnit CreateFromSourceFile(CXIndex index, string sourceFileName, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles) + public static CXTranslationUnit CreateFromSourceFile(CXIndex index, string sourceFileName, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles) + { + using var marshaledSourceFileName = new MarshaledString(sourceFileName); + using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); + + fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) { - using var marshaledSourceFileName = new MarshaledString(sourceFileName); - using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); - - fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) - { - var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; - marshaledCommandLineArgs.Fill(pCommandLineArgs); - return clang.createTranslationUnitFromSourceFile(index, marshaledSourceFileName, commandLineArgs.Length, pCommandLineArgs, (uint)unsavedFiles.Length, pUnsavedFiles); - } + var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; + marshaledCommandLineArgs.Fill(pCommandLineArgs); + return clang.createTranslationUnitFromSourceFile(index, marshaledSourceFileName, commandLineArgs.Length, pCommandLineArgs, (uint)unsavedFiles.Length, pUnsavedFiles); } + } - public static CXTranslationUnit Parse(CXIndex index, string sourceFileName, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, CXTranslationUnit_Flags options) + public static CXTranslationUnit Parse(CXIndex index, string sourceFileName, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, CXTranslationUnit_Flags options) + { + using var marshaledSourceFileName = new MarshaledString(sourceFileName); + using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); + + fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) { - using var marshaledSourceFileName = new MarshaledString(sourceFileName); - using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); - - fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) - { - var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; - marshaledCommandLineArgs.Fill(pCommandLineArgs); - return clang.parseTranslationUnit(index, marshaledSourceFileName, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (uint)options); - } + var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; + marshaledCommandLineArgs.Fill(pCommandLineArgs); + return clang.parseTranslationUnit(index, marshaledSourceFileName, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (uint)options); } + } + + public static CXErrorCode TryParse(CXIndex index, string sourceFileName, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, CXTranslationUnit_Flags options, out CXTranslationUnit translationUnit) + { + using var marshaledSourceFileName = new MarshaledString(sourceFileName); + using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); - public static CXErrorCode TryParse(CXIndex index, string sourceFileName, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, CXTranslationUnit_Flags options, out CXTranslationUnit translationUnit) + fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) + fixed (CXTranslationUnit* pTranslationUnit = &translationUnit) { - using var marshaledSourceFileName = new MarshaledString(sourceFileName); - using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); - - fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) - fixed (CXTranslationUnit* pTranslationUnit = &translationUnit) - { - var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; - marshaledCommandLineArgs.Fill(pCommandLineArgs); - return clang.parseTranslationUnit2(index, marshaledSourceFileName, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (uint)options, (CXTranslationUnitImpl**)pTranslationUnit); - } + var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; + marshaledCommandLineArgs.Fill(pCommandLineArgs); + return clang.parseTranslationUnit2(index, marshaledSourceFileName, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (uint)options, (CXTranslationUnitImpl**)pTranslationUnit); } + } + + public static CXErrorCode TryParseFullArgv(CXIndex index, string sourceFileName, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, CXTranslationUnit_Flags options, out CXTranslationUnit translationUnit) + { + using var marshaledSourceFileName = new MarshaledString(sourceFileName); + using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); - public static CXErrorCode TryParseFullArgv(CXIndex index, string sourceFileName, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, CXTranslationUnit_Flags options, out CXTranslationUnit translationUnit) + fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) + fixed (CXTranslationUnit* pTranslationUnit = &translationUnit) { - using var marshaledSourceFileName = new MarshaledString(sourceFileName); - using var marshaledCommandLineArgs = new MarshaledStringArray(commandLineArgs); - - fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) - fixed (CXTranslationUnit* pTranslationUnit = &translationUnit) - { - var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; - marshaledCommandLineArgs.Fill(pCommandLineArgs); - return clang.parseTranslationUnit2FullArgv(index, marshaledSourceFileName, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (uint)options, (CXTranslationUnitImpl**)pTranslationUnit); - } + var pCommandLineArgs = stackalloc sbyte*[commandLineArgs.Length]; + marshaledCommandLineArgs.Fill(pCommandLineArgs); + return clang.parseTranslationUnit2FullArgv(index, marshaledSourceFileName, pCommandLineArgs, commandLineArgs.Length, pUnsavedFiles, (uint)unsavedFiles.Length, (uint)options, (CXTranslationUnitImpl**)pTranslationUnit); } + } - public void AnnotateTokens(ReadOnlySpan tokens, Span cursors) + public void AnnotateTokens(ReadOnlySpan tokens, Span cursors) + { + fixed (CXToken* pTokens = tokens) + fixed (CXCursor* pCursors = cursors) { - fixed (CXToken* pTokens = tokens) - fixed (CXCursor* pCursors = cursors) - { - clang.annotateTokens(this, pTokens, (uint)tokens.Length, pCursors); - } + clang.annotateTokens(this, pTokens, (uint)tokens.Length, pCursors); } + } - public CXCodeCompleteResults* CodeCompleteAt(string completeFilename, uint completeLine, uint completeColumn, ReadOnlySpan unsavedFiles, CXCodeComplete_Flags options) - { - using var marshaledCompleteFilename = new MarshaledString(completeFilename); + public CXCodeCompleteResults* CodeCompleteAt(string completeFilename, uint completeLine, uint completeColumn, ReadOnlySpan unsavedFiles, CXCodeComplete_Flags options) + { + using var marshaledCompleteFilename = new MarshaledString(completeFilename); - fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) - { - return clang.codeCompleteAt(this, marshaledCompleteFilename, completeLine, completeColumn, pUnsavedFiles, (uint)unsavedFiles.Length, (uint)options); - } + fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) + { + return clang.codeCompleteAt(this, marshaledCompleteFilename, completeLine, completeColumn, pUnsavedFiles, (uint)unsavedFiles.Length, (uint)options); } + } - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.disposeTranslationUnit(this); - Handle = IntPtr.Zero; - } + clang.disposeTranslationUnit(this); + Handle = IntPtr.Zero; } + } - public void DisposeTokens(ReadOnlySpan tokens) + public void DisposeTokens(ReadOnlySpan tokens) + { + fixed (CXToken* pTokens = tokens) { - fixed (CXToken* pTokens = tokens) - { - clang.disposeTokens(this, pTokens, (uint)tokens.Length); - } + clang.disposeTokens(this, pTokens, (uint)tokens.Length); } + } - public override bool Equals(object obj) => (obj is CXTranslationUnit other) && Equals(other); + public override bool Equals(object obj) => (obj is CXTranslationUnit other) && Equals(other); - public bool Equals(CXTranslationUnit other) => this == other; + public bool Equals(CXTranslationUnit other) => this == other; - public CXResult FindIncludesInFile(CXFile file, CXCursorAndRangeVisitor visitor) => clang.findIncludesInFile(this, file, visitor); + public CXResult FindIncludesInFile(CXFile file, CXCursorAndRangeVisitor visitor) => clang.findIncludesInFile(this, file, visitor); - public CXCursor GetCursor(CXSourceLocation location) => clang.getCursor(this, location); + public CXCursor GetCursor(CXSourceLocation location) => clang.getCursor(this, location); - public CXDiagnostic GetDiagnostic(uint index) => (CXDiagnostic)clang.getDiagnostic(this, index); + public CXDiagnostic GetDiagnostic(uint index) => (CXDiagnostic)clang.getDiagnostic(this, index); - public CXFile GetFile(string fileName) - { - using var marshaledFileName = new MarshaledString(fileName); - return GetFile(marshaledFileName.AsSpan()); - } + public CXFile GetFile(string fileName) + { + using var marshaledFileName = new MarshaledString(fileName); + return GetFile(marshaledFileName.AsSpan()); + } - public CXFile GetFile(ReadOnlySpan fileName) + public CXFile GetFile(ReadOnlySpan fileName) + { + fixed (byte* pFileName = fileName) { - fixed (byte* pFileName = fileName) - { - return (CXFile)clang.getFile(this, (sbyte*)pFileName); - } + return (CXFile)clang.getFile(this, (sbyte*)pFileName); } + } - public ReadOnlySpan GetFileContents(CXFile file, out UIntPtr size) + public ReadOnlySpan GetFileContents(CXFile file, out UIntPtr size) + { + fixed (UIntPtr* pSize = &size) { - fixed (UIntPtr* pSize = &size) - { - var pFileContents = clang.getFileContents(this, file, pSize); - return new ReadOnlySpan(pFileContents, (int)size); - } + var pFileContents = clang.getFileContents(this, file, pSize); + return new ReadOnlySpan(pFileContents, (int)size); } + } - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public void GetInclusions(CXInclusionVisitor visitor, CXClientData clientData) - { - var pVisitor = Marshal.GetFunctionPointerForDelegate(visitor); - clang.getInclusions(this, pVisitor, clientData); - GC.KeepAlive(visitor); - } + public void GetInclusions(CXInclusionVisitor visitor, CXClientData clientData) + { + var pVisitor = Marshal.GetFunctionPointerForDelegate(visitor); + clang.getInclusions(this, pVisitor, clientData); + GC.KeepAlive(visitor); + } - public CXSourceLocation GetLocation(CXFile file, uint line, uint column) => clang.getLocation(this, file, line, column); + public CXSourceLocation GetLocation(CXFile file, uint line, uint column) => clang.getLocation(this, file, line, column); - public CXSourceLocation GetLocationForOffset(CXFile file, uint offset) => clang.getLocationForOffset(this, file, offset); + public CXSourceLocation GetLocationForOffset(CXFile file, uint offset) => clang.getLocationForOffset(this, file, offset); - public CXModule GetModuleForFile(CXFile file) => (CXModule)clang.getModuleForFile(this, file); + public CXModule GetModuleForFile(CXFile file) => (CXModule)clang.getModuleForFile(this, file); - public CXSourceRangeList* GetSkippedRanges(CXFile file) => clang.getSkippedRanges(this, file); + public CXSourceRangeList* GetSkippedRanges(CXFile file) => clang.getSkippedRanges(this, file); - public CXToken* GetToken(CXSourceLocation sourceLocation) => clang.getToken(this, sourceLocation); + public CXToken* GetToken(CXSourceLocation sourceLocation) => clang.getToken(this, sourceLocation); - public bool IsFileMultipleIncludeGuarded(CXFile file) => clang.isFileMultipleIncludeGuarded(this, file) != 0; + public bool IsFileMultipleIncludeGuarded(CXFile file) => clang.isFileMultipleIncludeGuarded(this, file) != 0; - public CXErrorCode Reparse(ReadOnlySpan unsavedFiles, CXReparse_Flags options) + public CXErrorCode Reparse(ReadOnlySpan unsavedFiles, CXReparse_Flags options) + { + fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) { - fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) - { - return (CXErrorCode)clang.reparseTranslationUnit(this, (uint)unsavedFiles.Length, pUnsavedFiles, (uint)options); - } + return (CXErrorCode)clang.reparseTranslationUnit(this, (uint)unsavedFiles.Length, pUnsavedFiles, (uint)options); } + } - public CXSaveError Save(string fileName, CXSaveTranslationUnit_Flags options) - { - using var marshaledFileName = new MarshaledString(fileName); - return (CXSaveError)clang.saveTranslationUnit(this, marshaledFileName, (uint)options); - } + public CXSaveError Save(string fileName, CXSaveTranslationUnit_Flags options) + { + using var marshaledFileName = new MarshaledString(fileName); + return (CXSaveError)clang.saveTranslationUnit(this, marshaledFileName, (uint)options); + } - public bool Suspend() => clang.suspendTranslationUnit(this) != 0; + public bool Suspend() => clang.suspendTranslationUnit(this) != 0; - public Span Tokenize(CXSourceRange sourceRange) - { - CXToken* pTokens; uint numTokens; - clang.tokenize(this, sourceRange, &pTokens, &numTokens); + public Span Tokenize(CXSourceRange sourceRange) + { + CXToken* pTokens; uint numTokens; + clang.tokenize(this, sourceRange, &pTokens, &numTokens); #if NETSTANDARD - var result = new CXToken[checked((int)numTokens)]; + var result = new CXToken[checked((int)numTokens)]; - fixed (CXToken* pResult = result) - { - var size = sizeof(CXToken) * numTokens; - Buffer.MemoryCopy(pTokens, pResult, size, size); - } + fixed (CXToken* pResult = result) + { + var size = sizeof(CXToken) * numTokens; + Buffer.MemoryCopy(pTokens, pResult, size, size); + } - return result; + return result; #else - return new Span(pTokens, (int)numTokens); + return new Span(pTokens, (int)numTokens); #endif - } - - public override string ToString() => Spelling.ToString(); } + + public override string ToString() => Spelling.ToString(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXType.cs b/sources/ClangSharp.Interop/Extensions/CXType.cs index cb864a69..21d8b2a5 100644 --- a/sources/ClangSharp.Interop/Extensions/CXType.cs +++ b/sources/ClangSharp.Interop/Extensions/CXType.cs @@ -4,252 +4,251 @@ using System.Diagnostics; using System.Runtime.InteropServices; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +[DebuggerDisplay("{DebuggerDisplayString,nq}")] +public unsafe partial struct CXType : IEquatable { - [DebuggerDisplay("{DebuggerDisplayString,nq}")] - public unsafe partial struct CXType : IEquatable - { - public uint AddressSpace => (kind != CXTypeKind.CXType_Invalid) ? clang.getAddressSpace(this) : default; + public uint AddressSpace => (kind != CXTypeKind.CXType_Invalid) ? clang.getAddressSpace(this) : default; - public CXCursor AddrSpaceExpr => clangsharp.Type_getAddrSpaceExpr(this); + public CXCursor AddrSpaceExpr => clangsharp.Type_getAddrSpaceExpr(this); - public CXType AdjustedType => clangsharp.Type_getAdjustedType(this); + public CXType AdjustedType => clangsharp.Type_getAdjustedType(this); - public long AlignOf => clang.Type_getAlignOf(this); + public long AlignOf => clang.Type_getAlignOf(this); - public CXType ArrayElementType => clang.getArrayElementType(this); + public CXType ArrayElementType => clang.getArrayElementType(this); - public long ArraySize => clang.getArraySize(this); + public long ArraySize => clang.getArraySize(this); - public CX_AttrKind AttrKind => clangsharp.Type_getAttrKind(this); + public CX_AttrKind AttrKind => clangsharp.Type_getAttrKind(this); - public CXType BaseType => clangsharp.Type_getBaseType(this); + public CXType BaseType => clangsharp.Type_getBaseType(this); - public CXType CanonicalType => clang.getCanonicalType(this); + public CXType CanonicalType => clang.getCanonicalType(this); - public CXType ClassType => clang.Type_getClassType(this); + public CXType ClassType => clang.Type_getClassType(this); - public CXCursor ColumnExpr => clangsharp.Type_getColumnExpr(this); + public CXCursor ColumnExpr => clangsharp.Type_getColumnExpr(this); - public CXRefQualifierKind CXXRefQualifier => clang.Type_getCXXRefQualifier(this); + public CXRefQualifierKind CXXRefQualifier => clang.Type_getCXXRefQualifier(this); - public CXType DecayedType => clangsharp.Type_getDecayedType(this); + public CXType DecayedType => clangsharp.Type_getDecayedType(this); - public CXCursor Declaration => clangsharp.Type_getDeclaration(this); + public CXCursor Declaration => clangsharp.Type_getDeclaration(this); - public CXType DeducedType => clangsharp.Type_getDeducedType(this); + public CXType DeducedType => clangsharp.Type_getDeducedType(this); - public int Depth => clangsharp.Type_getDepth(this); + public int Depth => clangsharp.Type_getDepth(this); - public CXType Desugar => clangsharp.Type_desugar(this); + public CXType Desugar => clangsharp.Type_desugar(this); - public CXType ElementType => clangsharp.Type_getElementType(this); + public CXType ElementType => clangsharp.Type_getElementType(this); - public CXType EquivalentType => clangsharp.Type_getEquivalentType(this); + public CXType EquivalentType => clangsharp.Type_getEquivalentType(this); - public CXCursor_ExceptionSpecificationKind ExceptionSpecificationType => (CXCursor_ExceptionSpecificationKind)clang.getExceptionSpecificationType(this); + public CXCursor_ExceptionSpecificationKind ExceptionSpecificationType => (CXCursor_ExceptionSpecificationKind)clang.getExceptionSpecificationType(this); - public CXCallingConv FunctionTypeCallingConv => clang.getFunctionTypeCallingConv(this); + public CXCallingConv FunctionTypeCallingConv => clang.getFunctionTypeCallingConv(this); - public int Index => clangsharp.Type_getIndex(this); + public int Index => clangsharp.Type_getIndex(this); - public CXType InjectedSpecializationType => clangsharp.Type_getInjectedSpecializationType(this); + public CXType InjectedSpecializationType => clangsharp.Type_getInjectedSpecializationType(this); - public CXType InjectedTST => clangsharp.Type_getInjectedTST(this); + public CXType InjectedTST => clangsharp.Type_getInjectedTST(this); - public bool IsCanonical => Equals(CanonicalType); + public bool IsCanonical => Equals(CanonicalType); - public bool IsConstQualified => clang.isConstQualifiedType(this) != 0; + public bool IsConstQualified => clang.isConstQualifiedType(this) != 0; - public bool IsFunctionTypeVariadic => clang.isFunctionTypeVariadic(this) != 0; + public bool IsFunctionTypeVariadic => clang.isFunctionTypeVariadic(this) != 0; - public bool IsPODType => clang.isPODType(this) != 0; + public bool IsPODType => clang.isPODType(this) != 0; - public bool IsRestrictQualified => clang.isRestrictQualifiedType(this) != 0; + public bool IsRestrictQualified => clang.isRestrictQualifiedType(this) != 0; - public bool IsSigned => clangsharp.Type_getIsSigned(this) != 0; + public bool IsSigned => clangsharp.Type_getIsSigned(this) != 0; - public bool IsSugared => clangsharp.Type_getIsSugared(this) != 0; + public bool IsSugared => clangsharp.Type_getIsSugared(this) != 0; - public bool IsTransparentTagTypedef => clang.Type_isTransparentTagTypedef(this) != 0; + public bool IsTransparentTagTypedef => clang.Type_isTransparentTagTypedef(this) != 0; - public bool IsTypeAlias => clangsharp.Type_getIsTypeAlias(this) != 0; + public bool IsTypeAlias => clangsharp.Type_getIsTypeAlias(this) != 0; - public bool IsUnsigned => clangsharp.Type_getIsUnsigned(this) != 0; + public bool IsUnsigned => clangsharp.Type_getIsUnsigned(this) != 0; - public bool IsVolatileQualified => clang.isVolatileQualifiedType(this) != 0; + public bool IsVolatileQualified => clang.isVolatileQualifiedType(this) != 0; - public CXString KindSpelling => clang.getTypeKindSpelling(kind); + public CXString KindSpelling => clang.getTypeKindSpelling(kind); - public CXType ModifiedType => clangsharp.Type_getModifiedType(this); + public CXType ModifiedType => clangsharp.Type_getModifiedType(this); - public CXType NamedType => clang.Type_getNamedType(this); + public CXType NamedType => clang.Type_getNamedType(this); - public CXTypeNullabilityKind Nullability => clang.Type_getNullability(this); + public CXTypeNullabilityKind Nullability => clang.Type_getNullability(this); - public int NumArgTypes => clang.getNumArgTypes(this); + public int NumArgTypes => clang.getNumArgTypes(this); - public int NumBits => clangsharp.Type_getNumBits(this); + public int NumBits => clangsharp.Type_getNumBits(this); - public CXCursor NumBitsExpr => clangsharp.Type_getNumBitsExpr(this); + public CXCursor NumBitsExpr => clangsharp.Type_getNumBitsExpr(this); - public int NumColumns => clangsharp.Type_getNumColumns(this); + public int NumColumns => clangsharp.Type_getNumColumns(this); - public int NumElementsFlattened => clangsharp.Type_getNumElementsFlattened(this); + public int NumElementsFlattened => clangsharp.Type_getNumElementsFlattened(this); - public int NumRows => clangsharp.Type_getNumRows(this); + public int NumRows => clangsharp.Type_getNumRows(this); - public long NumElements => clang.getNumElements(this); + public long NumElements => clang.getNumElements(this); - public uint NumObjCProtocolRefs => clang.Type_getNumObjCProtocolRefs(this); + public uint NumObjCProtocolRefs => clang.Type_getNumObjCProtocolRefs(this); - public uint NumObjCTypeArgs => clang.Type_getNumObjCTypeArgs(this); + public uint NumObjCTypeArgs => clang.Type_getNumObjCTypeArgs(this); - public int NumTemplateArguments => clang.Type_getNumTemplateArguments(this); + public int NumTemplateArguments => clang.Type_getNumTemplateArguments(this); - public CXType ObjCObjectBaseType => clang.Type_getObjCObjectBaseType(this); + public CXType ObjCObjectBaseType => clang.Type_getObjCObjectBaseType(this); - public CXType OriginalType => clangsharp.Type_getOriginalType(this); + public CXType OriginalType => clangsharp.Type_getOriginalType(this); - public CXCursor OwnedTagDecl => clangsharp.Type_getOwnedTagDecl(this); + public CXCursor OwnedTagDecl => clangsharp.Type_getOwnedTagDecl(this); - public CXType PointeeType => clangsharp.Type_getPointeeType(this); + public CXType PointeeType => clangsharp.Type_getPointeeType(this); - public CXType ResultType => clang.getResultType(this); + public CXType ResultType => clang.getResultType(this); - public CXCursor RowExpr => clangsharp.Type_getRowExpr(this); + public CXCursor RowExpr => clangsharp.Type_getRowExpr(this); - public CXCursor SizeExpr => clangsharp.Type_getSizeExpr(this); + public CXCursor SizeExpr => clangsharp.Type_getSizeExpr(this); - public long SizeOf => clang.Type_getSizeOf(this); + public long SizeOf => clang.Type_getSizeOf(this); - public CXString Spelling => clang.getTypeSpelling(this); + public CXString Spelling => clang.getTypeSpelling(this); - public CX_TemplateName TemplateName + public CX_TemplateName TemplateName + { + get { - get - { - var TN = clangsharp.Type_getTemplateName(this); - TN.tu = (CXTranslationUnitImpl*)data[1]; - return TN; - } + var TN = clangsharp.Type_getTemplateName(this); + TN.tu = (CXTranslationUnitImpl*)data[1]; + return TN; } + } - public CX_TypeClass TypeClass => clangsharp.Type_getTypeClass(this); + public CX_TypeClass TypeClass => clangsharp.Type_getTypeClass(this); - public string TypeClassSpelling + public string TypeClassSpelling + { + get { - get + Debug.Assert(CX_TypeClass.CX_TypeClass_TypeLast == CX_TypeClass.CX_TypeClass_ExtVector); + Debug.Assert(CX_TypeClass.CX_TypeClass_TagFirst == CX_TypeClass.CX_TypeClass_Record); + Debug.Assert(CX_TypeClass.CX_TypeClass_TagLast == CX_TypeClass.CX_TypeClass_Enum); + + return TypeClass switch { - Debug.Assert(CX_TypeClass.CX_TypeClass_TypeLast == CX_TypeClass.CX_TypeClass_ExtVector); - Debug.Assert(CX_TypeClass.CX_TypeClass_TagFirst == CX_TypeClass.CX_TypeClass_Record); - Debug.Assert(CX_TypeClass.CX_TypeClass_TagLast == CX_TypeClass.CX_TypeClass_Enum); - - return TypeClass switch - { - CX_TypeClass.CX_TypeClass_Invalid => "Invalid", - CX_TypeClass.CX_TypeClass_Adjusted => "Adjusted", - CX_TypeClass.CX_TypeClass_Decayed => "Decayed", - CX_TypeClass.CX_TypeClass_ConstantArray => "ConstantArray", - CX_TypeClass.CX_TypeClass_DependentSizedArray => "DependentSizedArray", - CX_TypeClass.CX_TypeClass_IncompleteArray => "IncompleteArray", - CX_TypeClass.CX_TypeClass_VariableArray => "VariableArray", - CX_TypeClass.CX_TypeClass_Atomic => "Atomic", - CX_TypeClass.CX_TypeClass_Attributed => "Attributed", - CX_TypeClass.CX_TypeClass_BlockPointer => "BlockPointer", - CX_TypeClass.CX_TypeClass_Builtin => "Builtin", - CX_TypeClass.CX_TypeClass_Complex => "Complex", - CX_TypeClass.CX_TypeClass_Decltype => "Decltype", - CX_TypeClass.CX_TypeClass_Auto => "Auto", - CX_TypeClass.CX_TypeClass_DeducedTemplateSpecialization => "DeducedTemplateSpecialization", - CX_TypeClass.CX_TypeClass_DependentAddressSpace => "DependentAddressSpace", - CX_TypeClass.CX_TypeClass_DependentBitInt => "DependentBitInt", - CX_TypeClass.CX_TypeClass_DependentName => "DependentName", - CX_TypeClass.CX_TypeClass_DependentSizedExtVector => "DependentSizedExtVector", - CX_TypeClass.CX_TypeClass_DependentTemplateSpecialization => "DependentTemplateSpecialization", - CX_TypeClass.CX_TypeClass_DependentVector => "DependentVector", - CX_TypeClass.CX_TypeClass_Elaborated => "Elaborated", - CX_TypeClass.CX_TypeClass_BitInt => "BitInt", - CX_TypeClass.CX_TypeClass_FunctionNoProto => "FunctionNoProto", - CX_TypeClass.CX_TypeClass_FunctionProto => "FunctionProto", - CX_TypeClass.CX_TypeClass_InjectedClassName => "InjectedClassName", - CX_TypeClass.CX_TypeClass_MacroQualified => "MacroQualified", - CX_TypeClass.CX_TypeClass_ConstantMatrix => "ConstantMatrix", - CX_TypeClass.CX_TypeClass_DependentSizedMatrix => "DependentSizedMatrix", - CX_TypeClass.CX_TypeClass_MemberPointer => "MemberPointer", - CX_TypeClass.CX_TypeClass_ObjCObjectPointer => "ObjCObjectPointer", - CX_TypeClass.CX_TypeClass_ObjCObject => "ObjCObject", - CX_TypeClass.CX_TypeClass_ObjCInterface => "ObjCInterface", - CX_TypeClass.CX_TypeClass_ObjCTypeParam => "ObjCTypeParam", - CX_TypeClass.CX_TypeClass_PackExpansion => "PackExpansion", - CX_TypeClass.CX_TypeClass_Paren => "Paren", - CX_TypeClass.CX_TypeClass_Pipe => "Pipe", - CX_TypeClass.CX_TypeClass_Pointer => "Pointer", - CX_TypeClass.CX_TypeClass_LValueReference => "LValueReference", - CX_TypeClass.CX_TypeClass_RValueReference => "RValueReference", - CX_TypeClass.CX_TypeClass_SubstTemplateTypeParmPack => "SubstTemplateTypeParmPack", - CX_TypeClass.CX_TypeClass_SubstTemplateTypeParm => "SubstTemplateTypeParm", - CX_TypeClass.CX_TypeClass_Enum => "Enum", - CX_TypeClass.CX_TypeClass_Record => "Record", - CX_TypeClass.CX_TypeClass_TemplateSpecialization => "TemplateSpecialization", - CX_TypeClass.CX_TypeClass_TemplateTypeParm => "TemplateTypeParm", - CX_TypeClass.CX_TypeClass_TypeOfExpr => "TypeOfExpr", - CX_TypeClass.CX_TypeClass_TypeOf => "TypeOf", - CX_TypeClass.CX_TypeClass_Typedef => "Typedef", - CX_TypeClass.CX_TypeClass_UnaryTransform => "UnaryTransform", - CX_TypeClass.CX_TypeClass_UnresolvedUsing => "UnresolvedUsing", - CX_TypeClass.CX_TypeClass_Vector => "Vector", - CX_TypeClass.CX_TypeClass_ExtVector => "ExtVector", - _ => TypeClass.ToString()[13..], - }; - } + CX_TypeClass.CX_TypeClass_Invalid => "Invalid", + CX_TypeClass.CX_TypeClass_Adjusted => "Adjusted", + CX_TypeClass.CX_TypeClass_Decayed => "Decayed", + CX_TypeClass.CX_TypeClass_ConstantArray => "ConstantArray", + CX_TypeClass.CX_TypeClass_DependentSizedArray => "DependentSizedArray", + CX_TypeClass.CX_TypeClass_IncompleteArray => "IncompleteArray", + CX_TypeClass.CX_TypeClass_VariableArray => "VariableArray", + CX_TypeClass.CX_TypeClass_Atomic => "Atomic", + CX_TypeClass.CX_TypeClass_Attributed => "Attributed", + CX_TypeClass.CX_TypeClass_BlockPointer => "BlockPointer", + CX_TypeClass.CX_TypeClass_Builtin => "Builtin", + CX_TypeClass.CX_TypeClass_Complex => "Complex", + CX_TypeClass.CX_TypeClass_Decltype => "Decltype", + CX_TypeClass.CX_TypeClass_Auto => "Auto", + CX_TypeClass.CX_TypeClass_DeducedTemplateSpecialization => "DeducedTemplateSpecialization", + CX_TypeClass.CX_TypeClass_DependentAddressSpace => "DependentAddressSpace", + CX_TypeClass.CX_TypeClass_DependentBitInt => "DependentBitInt", + CX_TypeClass.CX_TypeClass_DependentName => "DependentName", + CX_TypeClass.CX_TypeClass_DependentSizedExtVector => "DependentSizedExtVector", + CX_TypeClass.CX_TypeClass_DependentTemplateSpecialization => "DependentTemplateSpecialization", + CX_TypeClass.CX_TypeClass_DependentVector => "DependentVector", + CX_TypeClass.CX_TypeClass_Elaborated => "Elaborated", + CX_TypeClass.CX_TypeClass_BitInt => "BitInt", + CX_TypeClass.CX_TypeClass_FunctionNoProto => "FunctionNoProto", + CX_TypeClass.CX_TypeClass_FunctionProto => "FunctionProto", + CX_TypeClass.CX_TypeClass_InjectedClassName => "InjectedClassName", + CX_TypeClass.CX_TypeClass_MacroQualified => "MacroQualified", + CX_TypeClass.CX_TypeClass_ConstantMatrix => "ConstantMatrix", + CX_TypeClass.CX_TypeClass_DependentSizedMatrix => "DependentSizedMatrix", + CX_TypeClass.CX_TypeClass_MemberPointer => "MemberPointer", + CX_TypeClass.CX_TypeClass_ObjCObjectPointer => "ObjCObjectPointer", + CX_TypeClass.CX_TypeClass_ObjCObject => "ObjCObject", + CX_TypeClass.CX_TypeClass_ObjCInterface => "ObjCInterface", + CX_TypeClass.CX_TypeClass_ObjCTypeParam => "ObjCTypeParam", + CX_TypeClass.CX_TypeClass_PackExpansion => "PackExpansion", + CX_TypeClass.CX_TypeClass_Paren => "Paren", + CX_TypeClass.CX_TypeClass_Pipe => "Pipe", + CX_TypeClass.CX_TypeClass_Pointer => "Pointer", + CX_TypeClass.CX_TypeClass_LValueReference => "LValueReference", + CX_TypeClass.CX_TypeClass_RValueReference => "RValueReference", + CX_TypeClass.CX_TypeClass_SubstTemplateTypeParmPack => "SubstTemplateTypeParmPack", + CX_TypeClass.CX_TypeClass_SubstTemplateTypeParm => "SubstTemplateTypeParm", + CX_TypeClass.CX_TypeClass_Enum => "Enum", + CX_TypeClass.CX_TypeClass_Record => "Record", + CX_TypeClass.CX_TypeClass_TemplateSpecialization => "TemplateSpecialization", + CX_TypeClass.CX_TypeClass_TemplateTypeParm => "TemplateTypeParm", + CX_TypeClass.CX_TypeClass_TypeOfExpr => "TypeOfExpr", + CX_TypeClass.CX_TypeClass_TypeOf => "TypeOf", + CX_TypeClass.CX_TypeClass_Typedef => "Typedef", + CX_TypeClass.CX_TypeClass_UnaryTransform => "UnaryTransform", + CX_TypeClass.CX_TypeClass_UnresolvedUsing => "UnresolvedUsing", + CX_TypeClass.CX_TypeClass_Vector => "Vector", + CX_TypeClass.CX_TypeClass_ExtVector => "ExtVector", + _ => TypeClass.ToString()[13..], + }; } + } - public CXString TypedefName => clang.getTypedefName(this); + public CXString TypedefName => clang.getTypedefName(this); - public CXCursor UnderlyingExpr => clangsharp.Type_getUnderlyingExpr(this); + public CXCursor UnderlyingExpr => clangsharp.Type_getUnderlyingExpr(this); - public CXType UnderlyingType => clangsharp.Type_getUnderlyingType(this); + public CXType UnderlyingType => clangsharp.Type_getUnderlyingType(this); - public CXType ValueType => clang.Type_getValueType(this); + public CXType ValueType => clang.Type_getValueType(this); - internal string DebuggerDisplayString => $"{TypeClassSpelling}: {this}"; + internal string DebuggerDisplayString => $"{TypeClassSpelling}: {this}"; - public static bool operator ==(CXType left, CXType right) => clang.equalTypes(left, right) != 0; + public static bool operator ==(CXType left, CXType right) => clang.equalTypes(left, right) != 0; - public static bool operator !=(CXType left, CXType right) => clang.equalTypes(left, right) == 0; + public static bool operator !=(CXType left, CXType right) => clang.equalTypes(left, right) == 0; - public override bool Equals(object obj) => (obj is CXType other) && Equals(other); + public override bool Equals(object obj) => (obj is CXType other) && Equals(other); - public bool Equals(CXType other) => this == other; + public bool Equals(CXType other) => this == other; - public CXType GetArgType(uint i) => clang.getArgType(this, i); + public CXType GetArgType(uint i) => clang.getArgType(this, i); - public override int GetHashCode() => HashCode.Combine(kind, (IntPtr)data[0], (IntPtr)data[1]); + public override int GetHashCode() => HashCode.Combine(kind, (IntPtr)data[0], (IntPtr)data[1]); - public CXString GetObjCEncoding() => clang.Type_getObjCEncoding(this); + public CXString GetObjCEncoding() => clang.Type_getObjCEncoding(this); - public CXCursor GetObjCProtocolDecl(uint i) => clang.Type_getObjCProtocolDecl(this, i); + public CXCursor GetObjCProtocolDecl(uint i) => clang.Type_getObjCProtocolDecl(this, i); - public CXType GetObjCTypeArg(uint i) => clang.Type_getObjCTypeArg(this, i); + public CXType GetObjCTypeArg(uint i) => clang.Type_getObjCTypeArg(this, i); - public long GetOffsetOf(string s) - { - using var marshaledS = new MarshaledString(s); - return clang.Type_getOffsetOf(this, marshaledS); - } + public long GetOffsetOf(string s) + { + using var marshaledS = new MarshaledString(s); + return clang.Type_getOffsetOf(this, marshaledS); + } - public CX_TemplateArgument GetTemplateArgument(uint i) => clangsharp.Type_getTemplateArgument(this, i); + public CX_TemplateArgument GetTemplateArgument(uint i) => clangsharp.Type_getTemplateArgument(this, i); - public override string ToString() => Spelling.ToString(); + public override string ToString() => Spelling.ToString(); - public CXVisitorResult VisitFields(CXFieldVisitor visitor, CXClientData clientData) - { - var pVisitor = Marshal.GetFunctionPointerForDelegate(visitor); - var result = (CXVisitorResult)clang.Type_visitFields(this, pVisitor, clientData); + public CXVisitorResult VisitFields(CXFieldVisitor visitor, CXClientData clientData) + { + var pVisitor = Marshal.GetFunctionPointerForDelegate(visitor); + var result = (CXVisitorResult)clang.Type_visitFields(this, pVisitor, clientData); - GC.KeepAlive(visitor); - return result; - } + GC.KeepAlive(visitor); + return result; } } diff --git a/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs b/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs index 8e5d5b3d..a6676daa 100644 --- a/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs @@ -4,82 +4,81 @@ using System.Runtime.InteropServices; using System.Text; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXUnsavedFile : IDisposable { - public unsafe partial struct CXUnsavedFile : IDisposable + public static CXUnsavedFile Create(string filename, string contents) { - public static CXUnsavedFile Create(string filename, string contents) + IntPtr pFilename, pContents; + int filenameLength, contentsLength; + + if ((filename is null) || (filename.Length == 0)) { - IntPtr pFilename, pContents; - int filenameLength, contentsLength; + pFilename = IntPtr.Zero; + } + else + { + var filenameBytes = Encoding.UTF8.GetBytes(filename); + filenameLength = filenameBytes.Length; + pFilename = Marshal.AllocHGlobal(filenameLength + 1); + Marshal.Copy(filenameBytes, 0, pFilename, filenameLength); + Marshal.WriteByte(pFilename, filenameLength, 0); + } - if ((filename is null) || (filename.Length == 0)) - { - pFilename = IntPtr.Zero; - } - else - { - var filenameBytes = Encoding.UTF8.GetBytes(filename); - filenameLength = filenameBytes.Length; - pFilename = Marshal.AllocHGlobal(filenameLength + 1); - Marshal.Copy(filenameBytes, 0, pFilename, filenameLength); - Marshal.WriteByte(pFilename, filenameLength, 0); - } + if ((contents is null) || (contents.Length == 0)) + { + contentsLength = 0; + pContents = IntPtr.Zero; + } + else + { + var contentsBytes = Encoding.UTF8.GetBytes(contents); + contentsLength = contentsBytes.Length; + pContents = Marshal.AllocHGlobal(contentsLength + 1); + Marshal.Copy(contentsBytes, 0, pContents, contentsLength); + Marshal.WriteByte(pContents, contentsLength, 0); + } - if ((contents is null) || (contents.Length == 0)) - { - contentsLength = 0; - pContents = IntPtr.Zero; - } - else - { - var contentsBytes = Encoding.UTF8.GetBytes(contents); - contentsLength = contentsBytes.Length; - pContents = Marshal.AllocHGlobal(contentsLength + 1); - Marshal.Copy(contentsBytes, 0, pContents, contentsLength); - Marshal.WriteByte(pContents, contentsLength, 0); - } + return new CXUnsavedFile() + { + Filename = (sbyte*)pFilename, + Contents = (sbyte*)pContents, + Length = (UIntPtr)contentsLength + }; + } - return new CXUnsavedFile() - { - Filename = (sbyte*)pFilename, - Contents = (sbyte*)pContents, - Length = (UIntPtr)contentsLength - }; + public void Dispose() + { + if (Filename != null) + { + Marshal.FreeHGlobal((IntPtr)Filename); + Filename = null; } - public void Dispose() + if (Contents != null) { - if (Filename != null) - { - Marshal.FreeHGlobal((IntPtr)Filename); - Filename = null; - } - - if (Contents != null) - { - Marshal.FreeHGlobal((IntPtr)Contents); - Contents = null; - Length = (UIntPtr)0; - } + Marshal.FreeHGlobal((IntPtr)Contents); + Contents = null; + Length = (UIntPtr)0; } + } - public ReadOnlySpan ContentsSpan => new ReadOnlySpan(Contents, (int)Length); + public ReadOnlySpan ContentsSpan => new ReadOnlySpan(Contents, (int)Length); - public string FilenameString + public string FilenameString + { + get { - get - { - var pFilename = Filename; - - if (pFilename is null) - { - return string.Empty; - } + var pFilename = Filename; - var span = new ReadOnlySpan(pFilename, int.MaxValue); - return span.Slice(0, span.IndexOf((byte)'\0')).AsString(); + if (pFilename is null) + { + return string.Empty; } + + var span = new ReadOnlySpan(pFilename, int.MaxValue); + return span.Slice(0, span.IndexOf((byte)'\0')).AsString(); } } - } +} diff --git a/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs b/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs index 6348616b..1eb2d179 100644 --- a/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs +++ b/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs @@ -2,68 +2,67 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CXVirtualFileOverlay : IDisposable, IEquatable { - public unsafe partial struct CXVirtualFileOverlay : IDisposable, IEquatable + public CXVirtualFileOverlay(IntPtr handle) { - public CXVirtualFileOverlay(IntPtr handle) - { - Handle = handle; - } + Handle = handle; + } - public IntPtr Handle { get; set; } + public IntPtr Handle { get; set; } - public static implicit operator CXVirtualFileOverlay(CXVirtualFileOverlayImpl* value) => new CXVirtualFileOverlay((IntPtr)value); + public static implicit operator CXVirtualFileOverlay(CXVirtualFileOverlayImpl* value) => new CXVirtualFileOverlay((IntPtr)value); - public static implicit operator CXVirtualFileOverlayImpl*(CXVirtualFileOverlay value) => (CXVirtualFileOverlayImpl*)value.Handle; + public static implicit operator CXVirtualFileOverlayImpl*(CXVirtualFileOverlay value) => (CXVirtualFileOverlayImpl*)value.Handle; - public static bool operator ==(CXVirtualFileOverlay left, CXVirtualFileOverlay right) => left.Handle == right.Handle; + public static bool operator ==(CXVirtualFileOverlay left, CXVirtualFileOverlay right) => left.Handle == right.Handle; - public static bool operator !=(CXVirtualFileOverlay left, CXVirtualFileOverlay right) => left.Handle != right.Handle; + public static bool operator !=(CXVirtualFileOverlay left, CXVirtualFileOverlay right) => left.Handle != right.Handle; - public static CXVirtualFileOverlay Create(uint options) => clang.VirtualFileOverlay_create(options); + public static CXVirtualFileOverlay Create(uint options) => clang.VirtualFileOverlay_create(options); - public CXErrorCode AddFileMapping(string virtualPath, string realPath) - { - using var marshaledVirtualPath = new MarshaledString(virtualPath); - using var marshaledRealPath = new MarshaledString(realPath); - return clang.VirtualFileOverlay_addFileMapping(this, marshaledVirtualPath, marshaledRealPath); - } + public CXErrorCode AddFileMapping(string virtualPath, string realPath) + { + using var marshaledVirtualPath = new MarshaledString(virtualPath); + using var marshaledRealPath = new MarshaledString(realPath); + return clang.VirtualFileOverlay_addFileMapping(this, marshaledVirtualPath, marshaledRealPath); + } - public void Dispose() + public void Dispose() + { + if (Handle != IntPtr.Zero) { - if (Handle != IntPtr.Zero) - { - clang.VirtualFileOverlay_dispose(this); - Handle = IntPtr.Zero; - } + clang.VirtualFileOverlay_dispose(this); + Handle = IntPtr.Zero; } + } - public override bool Equals(object obj) => (obj is CXVirtualFileOverlay other) && Equals(other); + public override bool Equals(object obj) => (obj is CXVirtualFileOverlay other) && Equals(other); - public bool Equals(CXVirtualFileOverlay other) => this == other; + public bool Equals(CXVirtualFileOverlay other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override int GetHashCode() => Handle.GetHashCode(); - public CXErrorCode SetCaseSensitivity(bool caseSensitive) => clang.VirtualFileOverlay_setCaseSensitivity(this, caseSensitive ? 1 : 0); + public CXErrorCode SetCaseSensitivity(bool caseSensitive) => clang.VirtualFileOverlay_setCaseSensitivity(this, caseSensitive ? 1 : 0); - public Span WriteToBuffer(uint options, out CXErrorCode errorCode) - { - sbyte* pBuffer; uint size; - errorCode = clang.VirtualFileOverlay_writeToBuffer(this, options, &pBuffer, &size); + public Span WriteToBuffer(uint options, out CXErrorCode errorCode) + { + sbyte* pBuffer; uint size; + errorCode = clang.VirtualFileOverlay_writeToBuffer(this, options, &pBuffer, &size); #if NETSTANDARD - var result = new byte[checked((int)size)]; + var result = new byte[checked((int)size)]; - fixed (byte* pResult = result) - { - Buffer.MemoryCopy(pBuffer, pResult, size, size); - } + fixed (byte* pResult = result) + { + Buffer.MemoryCopy(pBuffer, pResult, size, size); + } - return result; + return result; #else - return new Span(pBuffer, (int)size); + return new Span(pBuffer, (int)size); #endif - } } } diff --git a/sources/ClangSharp.Interop/Extensions/CX_TemplateArgument.cs b/sources/ClangSharp.Interop/Extensions/CX_TemplateArgument.cs index a0c9f2e1..2dcf942e 100644 --- a/sources/ClangSharp.Interop/Extensions/CX_TemplateArgument.cs +++ b/sources/ClangSharp.Interop/Extensions/CX_TemplateArgument.cs @@ -2,38 +2,37 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CX_TemplateArgument : IDisposable { - public unsafe partial struct CX_TemplateArgument : IDisposable - { - public CXCursor AsDecl => clangsharp.TemplateArgument_getAsDecl(this); + public CXCursor AsDecl => clangsharp.TemplateArgument_getAsDecl(this); - public CXCursor AsExpr => clangsharp.TemplateArgument_getAsExpr(this); + public CXCursor AsExpr => clangsharp.TemplateArgument_getAsExpr(this); - public long AsIntegral => clangsharp.TemplateArgument_getAsIntegral(this); + public long AsIntegral => clangsharp.TemplateArgument_getAsIntegral(this); - public CX_TemplateName AsTemplate => clangsharp.TemplateArgument_getAsTemplate(this); + public CX_TemplateName AsTemplate => clangsharp.TemplateArgument_getAsTemplate(this); - public CX_TemplateName AsTemplateOrTemplatePattern => clangsharp.TemplateArgument_getAsTemplateOrTemplatePattern(this); + public CX_TemplateName AsTemplateOrTemplatePattern => clangsharp.TemplateArgument_getAsTemplateOrTemplatePattern(this); - public CXType AsType => clangsharp.TemplateArgument_getAsType(this); + public CXType AsType => clangsharp.TemplateArgument_getAsType(this); - public CX_TemplateArgumentDependence Dependence => clangsharp.TemplateArgument_getDependence(this); + public CX_TemplateArgumentDependence Dependence => clangsharp.TemplateArgument_getDependence(this); - public CXType IntegralType => clangsharp.TemplateArgument_getIntegralType(this); + public CXType IntegralType => clangsharp.TemplateArgument_getIntegralType(this); - public CXType NonTypeTemplateArgumentType => clangsharp.TemplateArgument_getNonTypeTemplateArgumentType(this); + public CXType NonTypeTemplateArgumentType => clangsharp.TemplateArgument_getNonTypeTemplateArgumentType(this); - public CXType NullPtrType => clangsharp.TemplateArgument_getNullPtrType(this); + public CXType NullPtrType => clangsharp.TemplateArgument_getNullPtrType(this); - public int NumPackElements => clangsharp.TemplateArgument_getNumPackElements(this); + public int NumPackElements => clangsharp.TemplateArgument_getNumPackElements(this); - public CX_TemplateArgument PackExpansionPattern => clangsharp.TemplateArgument_getPackExpansionPattern(this); + public CX_TemplateArgument PackExpansionPattern => clangsharp.TemplateArgument_getPackExpansionPattern(this); - public CXType ParamTypeForDecl => clangsharp.TemplateArgument_getParamTypeForDecl(this); + public CXType ParamTypeForDecl => clangsharp.TemplateArgument_getParamTypeForDecl(this); - public CX_TemplateArgument GetPackElement(uint i) => clangsharp.TemplateArgument_getPackElement(this, i); + public CX_TemplateArgument GetPackElement(uint i) => clangsharp.TemplateArgument_getPackElement(this, i); - public void Dispose() => clangsharp.TemplateArgument_dispose(this); - } + public void Dispose() => clangsharp.TemplateArgument_dispose(this); } diff --git a/sources/ClangSharp.Interop/Extensions/CX_TemplateArgumentLoc.cs b/sources/ClangSharp.Interop/Extensions/CX_TemplateArgumentLoc.cs index 533a6aa0..a8a7eabd 100644 --- a/sources/ClangSharp.Interop/Extensions/CX_TemplateArgumentLoc.cs +++ b/sources/ClangSharp.Interop/Extensions/CX_TemplateArgumentLoc.cs @@ -1,21 +1,20 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CX_TemplateArgumentLoc { - public unsafe partial struct CX_TemplateArgumentLoc - { - public CX_TemplateArgument Argument => clangsharp.TemplateArgumentLoc_getArgument(this); + public CX_TemplateArgument Argument => clangsharp.TemplateArgumentLoc_getArgument(this); - public CXSourceLocation Location => clangsharp.TemplateArgumentLoc_getLocation(this); + public CXSourceLocation Location => clangsharp.TemplateArgumentLoc_getLocation(this); - public CXCursor SourceDeclExpression => clangsharp.TemplateArgumentLoc_getSourceDeclExpression(this); + public CXCursor SourceDeclExpression => clangsharp.TemplateArgumentLoc_getSourceDeclExpression(this); - public CXCursor SourceExpression => clangsharp.TemplateArgumentLoc_getSourceExpression(this); + public CXCursor SourceExpression => clangsharp.TemplateArgumentLoc_getSourceExpression(this); - public CXCursor SourceIntegralExpression => clangsharp.TemplateArgumentLoc_getSourceIntegralExpression(this); + public CXCursor SourceIntegralExpression => clangsharp.TemplateArgumentLoc_getSourceIntegralExpression(this); - public CXCursor SourceNullPtrExpression => clangsharp.TemplateArgumentLoc_getSourceNullPtrExpression(this); + public CXCursor SourceNullPtrExpression => clangsharp.TemplateArgumentLoc_getSourceNullPtrExpression(this); - public CXSourceRange SourceRange => clangsharp.TemplateArgumentLoc_getSourceRange(this); - } + public CXSourceRange SourceRange => clangsharp.TemplateArgumentLoc_getSourceRange(this); } diff --git a/sources/ClangSharp.Interop/Extensions/CX_TemplateName.cs b/sources/ClangSharp.Interop/Extensions/CX_TemplateName.cs index eddd295c..b2a35743 100644 --- a/sources/ClangSharp.Interop/Extensions/CX_TemplateName.cs +++ b/sources/ClangSharp.Interop/Extensions/CX_TemplateName.cs @@ -1,10 +1,9 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from https://github.com/dotnet/clangsharp/blob/main/sources/libClangSharp -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe partial struct CX_TemplateName { - public unsafe partial struct CX_TemplateName - { - public CXCursor AsTemplateDecl => clangsharp.TemplateName_getAsTemplateDecl(this); - } + public CXCursor AsTemplateDecl => clangsharp.TemplateName_getAsTemplateDecl(this); } diff --git a/sources/ClangSharp.Interop/Extensions/clang.ResolveLibrary.cs b/sources/ClangSharp.Interop/Extensions/clang.ResolveLibrary.cs index 64f83f47..95212acd 100644 --- a/sources/ClangSharp.Interop/Extensions/clang.ResolveLibrary.cs +++ b/sources/ClangSharp.Interop/Extensions/clang.ResolveLibrary.cs @@ -1,62 +1,62 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System; +using System.Linq; using System.Reflection; using System.Runtime.InteropServices; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public static unsafe partial class clang { - public static unsafe partial class clang + public static event DllImportResolver ResolveLibrary; + + static clang() { - public static event DllImportResolver ResolveLibrary; + NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), OnDllImport); + } - static clang() - { - NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), OnDllImport); - } + private static IntPtr OnDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) + { + return TryResolveLibrary(libraryName, assembly, searchPath, out var nativeLibrary) + ? nativeLibrary + : libraryName.Equals("libclang") && TryResolveClang(assembly, searchPath, out nativeLibrary) + ? nativeLibrary + : libraryName.Equals("libClangSharp") && TryResolveClangSharp(assembly, searchPath, out nativeLibrary) + ? nativeLibrary + : IntPtr.Zero; + } - private static IntPtr OnDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) - { - return TryResolveLibrary(libraryName, assembly, searchPath, out var nativeLibrary) - ? nativeLibrary - : libraryName.Equals("libclang") && TryResolveClang(assembly, searchPath, out nativeLibrary) - ? nativeLibrary - : libraryName.Equals("libClangSharp") && TryResolveClangSharp(assembly, searchPath, out nativeLibrary) - ? nativeLibrary - : IntPtr.Zero; - } + private static bool TryResolveClang(Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) + { + return (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libclang.so.13", assembly, searchPath, out nativeLibrary)) + || (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libclang-13", assembly, searchPath, out nativeLibrary)) + || (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libclang.so.1", assembly, searchPath, out nativeLibrary)) + || NativeLibrary.TryLoad("libclang", assembly, searchPath, out nativeLibrary); + } - private static bool TryResolveClang(Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) - { - return (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libclang.so.13", assembly, searchPath, out nativeLibrary)) - || (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libclang-13", assembly, searchPath, out nativeLibrary)) - || (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libclang.so.1", assembly, searchPath, out nativeLibrary)) - || NativeLibrary.TryLoad("libclang", assembly, searchPath, out nativeLibrary); - } + private static bool TryResolveClangSharp(Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) => NativeLibrary.TryLoad("libClangSharp", assembly, searchPath, out nativeLibrary); - private static bool TryResolveClangSharp(Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) => NativeLibrary.TryLoad("libClangSharp", assembly, searchPath, out nativeLibrary); + private static bool TryResolveLibrary(string libraryName, Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) + { + var resolveLibrary = ResolveLibrary; - private static bool TryResolveLibrary(string libraryName, Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) + if (resolveLibrary != null) { - var resolveLibrary = ResolveLibrary; + var resolvers = resolveLibrary.GetInvocationList(); - if (resolveLibrary != null) + foreach (DllImportResolver resolver in resolvers.Cast()) { - var resolvers = resolveLibrary.GetInvocationList(); + nativeLibrary = resolver(libraryName, assembly, searchPath); - foreach (DllImportResolver resolver in resolvers) + if (nativeLibrary != IntPtr.Zero) { - nativeLibrary = resolver(libraryName, assembly, searchPath); - - if (nativeLibrary != IntPtr.Zero) - { - return true; - } + return true; } } - - nativeLibrary = IntPtr.Zero; - return false; } + + nativeLibrary = IntPtr.Zero; + return false; } } diff --git a/sources/ClangSharp.Interop/IndexerCallbacks.cs b/sources/ClangSharp.Interop/IndexerCallbacks.cs index d6e0bb6d..f065ff94 100644 --- a/sources/ClangSharp.Interop/IndexerCallbacks.cs +++ b/sources/ClangSharp.Interop/IndexerCallbacks.cs @@ -5,32 +5,31 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public partial struct IndexerCallbacks { - public partial struct IndexerCallbacks - { - [NativeTypeName("int (*)(CXClientData, void *)")] - public IntPtr abortQuery; + [NativeTypeName("int (*)(CXClientData, void *)")] + public IntPtr abortQuery; - [NativeTypeName("void (*)(CXClientData, CXDiagnosticSet, void *)")] - public IntPtr diagnostic; + [NativeTypeName("void (*)(CXClientData, CXDiagnosticSet, void *)")] + public IntPtr diagnostic; - [NativeTypeName("CXIdxClientFile (*)(CXClientData, CXFile, void *)")] - public IntPtr enteredMainFile; + [NativeTypeName("CXIdxClientFile (*)(CXClientData, CXFile, void *)")] + public IntPtr enteredMainFile; - [NativeTypeName("CXIdxClientFile (*)(CXClientData, const CXIdxIncludedFileInfo *)")] - public IntPtr ppIncludedFile; + [NativeTypeName("CXIdxClientFile (*)(CXClientData, const CXIdxIncludedFileInfo *)")] + public IntPtr ppIncludedFile; - [NativeTypeName("CXIdxClientASTFile (*)(CXClientData, const CXIdxImportedASTFileInfo *)")] - public IntPtr importedASTFile; + [NativeTypeName("CXIdxClientASTFile (*)(CXClientData, const CXIdxImportedASTFileInfo *)")] + public IntPtr importedASTFile; - [NativeTypeName("CXIdxClientContainer (*)(CXClientData, void *)")] - public IntPtr startedTranslationUnit; + [NativeTypeName("CXIdxClientContainer (*)(CXClientData, void *)")] + public IntPtr startedTranslationUnit; - [NativeTypeName("void (*)(CXClientData, const CXIdxDeclInfo *)")] - public IntPtr indexDeclaration; + [NativeTypeName("void (*)(CXClientData, const CXIdxDeclInfo *)")] + public IntPtr indexDeclaration; - [NativeTypeName("void (*)(CXClientData, const CXIdxEntityRefInfo *)")] - public IntPtr indexEntityReference; - } + [NativeTypeName("void (*)(CXClientData, const CXIdxEntityRefInfo *)")] + public IntPtr indexEntityReference; } diff --git a/sources/ClangSharp.Interop/Internals/Index.cs b/sources/ClangSharp.Interop/Internals/Index.cs index 8abfd8f4..bd5a75a0 100644 --- a/sources/ClangSharp.Interop/Internals/Index.cs +++ b/sources/ClangSharp.Interop/Internals/Index.cs @@ -4,64 +4,63 @@ #if NETSTANDARD2_0 using System.Runtime.CompilerServices; -namespace System +namespace System; + +internal readonly struct Index : IEquatable { - internal readonly struct Index : IEquatable - { - private readonly int _value; + private readonly int _value; - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Index(int value, bool fromEnd = false) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public Index(int value, bool fromEnd = false) + { + if (value < 0) { - if (value < 0) - { - throw new ArgumentOutOfRangeException(nameof(value)); - } - - _value = fromEnd ? ~value : value; + throw new ArgumentOutOfRangeException(nameof(value)); } - private Index(int value) - { - _value = value; - } + _value = fromEnd ? ~value : value; + } - public static Index Start => new Index(0); + private Index(int value) + { + _value = value; + } + + public static Index Start => new Index(0); - public static Index End => new Index(~0); + public static Index End => new Index(~0); - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Index FromStart(int value) => value < 0 ? throw new ArgumentOutOfRangeException(nameof(value)) : new Index(value); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Index FromStart(int value) => value < 0 ? throw new ArgumentOutOfRangeException(nameof(value)) : new Index(value); - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Index FromEnd(int value) => value < 0 ? throw new ArgumentOutOfRangeException(nameof(value)) : new Index(~value); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Index FromEnd(int value) => value < 0 ? throw new ArgumentOutOfRangeException(nameof(value)) : new Index(~value); - public int Value => _value < 0 ? ~_value : _value; + public int Value => _value < 0 ? ~_value : _value; - public bool IsFromEnd => _value < 0; + public bool IsFromEnd => _value < 0; - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public int GetOffset(int length) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int GetOffset(int length) + { + var offset = _value; + if (IsFromEnd) { - var offset = _value; - if (IsFromEnd) - { - offset += length + 1; - } - return offset; + offset += length + 1; } + return offset; + } - public override bool Equals(object value) => value is Index index && _value == index._value; + public override bool Equals(object value) => value is Index index && _value == index._value; - public bool Equals(Index other) => _value == other._value; + public bool Equals(Index other) => _value == other._value; - public override int GetHashCode() => _value; + public override int GetHashCode() => _value; - public static implicit operator Index(int value) => FromStart(value); + public static implicit operator Index(int value) => FromStart(value); - public override string ToString() => IsFromEnd ? ToStringFromEnd() : ((uint)Value).ToString(); + public override string ToString() => IsFromEnd ? ToStringFromEnd() : ((uint)Value).ToString(); - private string ToStringFromEnd() => '^' + Value.ToString(); - } + private string ToStringFromEnd() => '^' + Value.ToString(); } #endif diff --git a/sources/ClangSharp.Interop/Internals/MarshaledString.cs b/sources/ClangSharp.Interop/Internals/MarshaledString.cs index 1bab7fe6..77de0915 100644 --- a/sources/ClangSharp.Interop/Internals/MarshaledString.cs +++ b/sources/ClangSharp.Interop/Internals/MarshaledString.cs @@ -4,55 +4,54 @@ using System.Runtime.InteropServices; using System.Text; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe struct MarshaledString : IDisposable { - public unsafe struct MarshaledString : IDisposable + public MarshaledString(string input) { - public MarshaledString(string input) + int length; + IntPtr value; + + if (input is null) + { + length = 0; + value = IntPtr.Zero; + } + else { - int length; - IntPtr value; - - if (input is null) - { - length = 0; - value = IntPtr.Zero; - } - else - { - var valueBytes = (input.Length != 0) ? Encoding.UTF8.GetBytes(input) : Array.Empty(); - length = valueBytes.Length; - value = Marshal.AllocHGlobal(length + 1); - Marshal.Copy(valueBytes, 0, value, length); - Marshal.WriteByte(value, length, 0); - } - - Length = length; - Value = (sbyte*)value; + var valueBytes = (input.Length != 0) ? Encoding.UTF8.GetBytes(input) : Array.Empty(); + length = valueBytes.Length; + value = Marshal.AllocHGlobal(length + 1); + Marshal.Copy(valueBytes, 0, value, length); + Marshal.WriteByte(value, length, 0); } - public ReadOnlySpan AsSpan() => new ReadOnlySpan(Value, Length); + Length = length; + Value = (sbyte*)value; + } + + public ReadOnlySpan AsSpan() => new ReadOnlySpan(Value, Length); - public int Length { get; private set; } + public int Length { get; private set; } - public sbyte* Value { get; private set; } + public sbyte* Value { get; private set; } - public void Dispose() + public void Dispose() + { + if (Value != null) { - if (Value != null) - { - Marshal.FreeHGlobal((IntPtr)Value); - Value = null; - Length = 0; - } + Marshal.FreeHGlobal((IntPtr)Value); + Value = null; + Length = 0; } + } - public static implicit operator sbyte*(in MarshaledString value) => value.Value; + public static implicit operator sbyte*(in MarshaledString value) => value.Value; - public override string ToString() - { - var span = new ReadOnlySpan(Value, Length); - return span.AsString(); - } + public override string ToString() + { + var span = new ReadOnlySpan(Value, Length); + return span.AsString(); } } diff --git a/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs b/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs index 773a5ca5..6746e805 100644 --- a/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs +++ b/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs @@ -2,52 +2,51 @@ using System; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public unsafe ref struct MarshaledStringArray { - public unsafe ref struct MarshaledStringArray - { - private MarshaledString[] _values; + private MarshaledString[] _values; - public MarshaledStringArray(ReadOnlySpan inputs) + public MarshaledStringArray(ReadOnlySpan inputs) + { + if (inputs.Length == 0) { - if (inputs.Length == 0) - { - _values = null; - } - else - { - _values = new MarshaledString[inputs.Length]; + _values = null; + } + else + { + _values = new MarshaledString[inputs.Length]; - for (var i = 0; i < inputs.Length; i++) - { - _values[i] = new MarshaledString(inputs[i]); - } + for (var i = 0; i < inputs.Length; i++) + { + _values[i] = new MarshaledString(inputs[i]); } } + } - public ReadOnlySpan Values => _values; + public ReadOnlySpan Values => _values; - public void Dispose() + public void Dispose() + { + if (_values != null) { - if (_values != null) + for (var i = 0; i < _values.Length; i++) { - for (var i = 0; i < _values.Length; i++) - { - _values[i].Dispose(); - } - - _values = null; + _values[i].Dispose(); } + + _values = null; } + } - public void Fill(sbyte** pDestination) + public void Fill(sbyte** pDestination) + { + if (_values != null) { - if (_values != null) + for (var i = 0; i < _values.Length; i++) { - for (var i = 0; i < _values.Length; i++) - { - pDestination[i] = Values[i]; - } + pDestination[i] = Values[i]; } } } diff --git a/sources/ClangSharp.Interop/Internals/NativeTypeNameAttribute.cs b/sources/ClangSharp.Interop/Internals/NativeTypeNameAttribute.cs index 62647781..abd87224 100644 --- a/sources/ClangSharp.Interop/Internals/NativeTypeNameAttribute.cs +++ b/sources/ClangSharp.Interop/Internals/NativeTypeNameAttribute.cs @@ -3,17 +3,16 @@ using System; using System.Diagnostics; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +[Conditional("DEBUG")] +[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] +internal sealed class NativeTypeNameAttribute : Attribute { - [Conditional("DEBUG")] - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] - internal sealed class NativeTypeNameAttribute : Attribute + public NativeTypeNameAttribute(string name) { - public NativeTypeNameAttribute(string name) - { - Name = name; - } - - public string Name { get; } + Name = name; } + + public string Name { get; } } diff --git a/sources/ClangSharp.Interop/Internals/Range.cs b/sources/ClangSharp.Interop/Internals/Range.cs index 86f5a888..20559031 100644 --- a/sources/ClangSharp.Interop/Internals/Range.cs +++ b/sources/ClangSharp.Interop/Internals/Range.cs @@ -4,52 +4,51 @@ #if NETSTANDARD2_0 using System.Runtime.CompilerServices; -namespace System +namespace System; + +internal readonly struct Range : IEquatable { - internal readonly struct Range : IEquatable - { - public Index Start { get; } + public Index Start { get; } - public Index End { get; } + public Index End { get; } - public Range(Index start, Index end) - { - Start = start; - End = end; - } + public Range(Index start, Index end) + { + Start = start; + End = end; + } - public override bool Equals(object value) => - value is Range r && - r.Start.Equals(Start) && - r.End.Equals(End); + public override bool Equals(object value) => + value is Range r && + r.Start.Equals(Start) && + r.End.Equals(End); - public bool Equals(Range other) => other.Start.Equals(Start) && other.End.Equals(End); + public bool Equals(Range other) => other.Start.Equals(Start) && other.End.Equals(End); - public override int GetHashCode() => HashCode.Combine(Start.GetHashCode(), End.GetHashCode()); + public override int GetHashCode() => HashCode.Combine(Start.GetHashCode(), End.GetHashCode()); - public override string ToString() => Start.ToString() + ".." + End.ToString(); + public override string ToString() => Start.ToString() + ".." + End.ToString(); - public static Range StartAt(Index start) => new Range(start, Index.End); + public static Range StartAt(Index start) => new Range(start, Index.End); - public static Range EndAt(Index end) => new Range(Index.Start, end); + public static Range EndAt(Index end) => new Range(Index.Start, end); - public static Range All => new Range(Index.Start, Index.End); + public static Range All => new Range(Index.Start, Index.End); - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public (int Offset, int Length) GetOffsetAndLength(int length) - { - int start; - var startIndex = Start; - start = startIndex.IsFromEnd ? length - startIndex.Value : startIndex.Value; + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public (int Offset, int Length) GetOffsetAndLength(int length) + { + int start; + var startIndex = Start; + start = startIndex.IsFromEnd ? length - startIndex.Value : startIndex.Value; - int end; - var endIndex = End; - end = endIndex.IsFromEnd ? length - endIndex.Value : endIndex.Value; + int end; + var endIndex = End; + end = endIndex.IsFromEnd ? length - endIndex.Value : endIndex.Value; - return (uint)end > (uint)length || (uint)start > (uint)end - ? throw new ArgumentOutOfRangeException(nameof(length)) - : (start, end - start); - } + return (uint)end > (uint)length || (uint)start > (uint)end + ? throw new ArgumentOutOfRangeException(nameof(length)) + : (start, end - start); } } #endif diff --git a/sources/ClangSharp.Interop/Internals/SpanExtensions.cs b/sources/ClangSharp.Interop/Internals/SpanExtensions.cs index 79bb591a..52c6592f 100644 --- a/sources/ClangSharp.Interop/Internals/SpanExtensions.cs +++ b/sources/ClangSharp.Interop/Internals/SpanExtensions.cs @@ -3,59 +3,58 @@ using System; using System.Text; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public static unsafe class SpanExtensions { - public static unsafe class SpanExtensions + public static string AsString(this Span self) => AsString((ReadOnlySpan)self); + + public static string AsString(this ReadOnlySpan self) + { + if (self.IsEmpty) + { + return string.Empty; + } + + fixed (byte* pSelf = self) + { + return Encoding.UTF8.GetString(pSelf, self.Length); + } + } + + public static string AsString(this ReadOnlySpan self) { - public static string AsString(this Span self) => AsString((ReadOnlySpan)self); + if (self.IsEmpty) + { + return string.Empty; + } - public static string AsString(this ReadOnlySpan self) + fixed (ushort* pSelf = self) { - if (self.IsEmpty) - { - return string.Empty; - } - - fixed (byte* pSelf = self) - { - return Encoding.UTF8.GetString(pSelf, self.Length); - } + return Encoding.Unicode.GetString((byte*)pSelf, self.Length * 2); } + } - public static string AsString(this ReadOnlySpan self) + public static string AsString(this ReadOnlySpan self) + { + if (self.IsEmpty) { - if (self.IsEmpty) - { - return string.Empty; - } - - fixed (ushort* pSelf = self) - { - return Encoding.Unicode.GetString((byte*)pSelf, self.Length * 2); - } + return string.Empty; } - public static string AsString(this ReadOnlySpan self) + fixed (uint* pSelf = self) { - if (self.IsEmpty) - { - return string.Empty; - } - - fixed (uint* pSelf = self) - { - return Encoding.UTF32.GetString((byte*)pSelf, self.Length * 4); - } + return Encoding.UTF32.GetString((byte*)pSelf, self.Length * 4); } + } - public static void ClangFree(this Span self) => ClangFree((ReadOnlySpan)self); + public static void ClangFree(this Span self) => ClangFree((ReadOnlySpan)self); - public static void ClangFree(this ReadOnlySpan self) + public static void ClangFree(this ReadOnlySpan self) + { + fixed (byte* pSelf = self) { - fixed (byte* pSelf = self) - { - clang.free(pSelf); - } + clang.free(pSelf); } } } diff --git a/sources/ClangSharp.Interop/clang.cs b/sources/ClangSharp.Interop/clang.cs index e215e047..db07148f 100644 --- a/sources/ClangSharp.Interop/clang.cs +++ b/sources/ClangSharp.Interop/clang.cs @@ -6,1381 +6,1380 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public static unsafe partial class clang { - public static unsafe partial class clang - { - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getBuildSessionTimestamp", ExactSpelling = true)] - [return: NativeTypeName("unsigned long long")] - public static extern ulong getBuildSessionTimestamp(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getBuildSessionTimestamp", ExactSpelling = true)] + [return: NativeTypeName("unsigned long long")] + public static extern ulong getBuildSessionTimestamp(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_create", ExactSpelling = true)] - [return: NativeTypeName("CXVirtualFileOverlay")] - public static extern CXVirtualFileOverlayImpl* VirtualFileOverlay_create([NativeTypeName("unsigned int")] uint options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_create", ExactSpelling = true)] + [return: NativeTypeName("CXVirtualFileOverlay")] + public static extern CXVirtualFileOverlayImpl* VirtualFileOverlay_create([NativeTypeName("unsigned int")] uint options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_addFileMapping", ExactSpelling = true)] - [return: NativeTypeName("enum CXErrorCode")] - public static extern CXErrorCode VirtualFileOverlay_addFileMapping([NativeTypeName("CXVirtualFileOverlay")] CXVirtualFileOverlayImpl* param0, [NativeTypeName("const char *")] sbyte* virtualPath, [NativeTypeName("const char *")] sbyte* realPath); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_addFileMapping", ExactSpelling = true)] + [return: NativeTypeName("enum CXErrorCode")] + public static extern CXErrorCode VirtualFileOverlay_addFileMapping([NativeTypeName("CXVirtualFileOverlay")] CXVirtualFileOverlayImpl* param0, [NativeTypeName("const char *")] sbyte* virtualPath, [NativeTypeName("const char *")] sbyte* realPath); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_setCaseSensitivity", ExactSpelling = true)] - [return: NativeTypeName("enum CXErrorCode")] - public static extern CXErrorCode VirtualFileOverlay_setCaseSensitivity([NativeTypeName("CXVirtualFileOverlay")] CXVirtualFileOverlayImpl* param0, int caseSensitive); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_setCaseSensitivity", ExactSpelling = true)] + [return: NativeTypeName("enum CXErrorCode")] + public static extern CXErrorCode VirtualFileOverlay_setCaseSensitivity([NativeTypeName("CXVirtualFileOverlay")] CXVirtualFileOverlayImpl* param0, int caseSensitive); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_writeToBuffer", ExactSpelling = true)] - [return: NativeTypeName("enum CXErrorCode")] - public static extern CXErrorCode VirtualFileOverlay_writeToBuffer([NativeTypeName("CXVirtualFileOverlay")] CXVirtualFileOverlayImpl* param0, [NativeTypeName("unsigned int")] uint options, [NativeTypeName("char **")] sbyte** out_buffer_ptr, [NativeTypeName("unsigned int *")] uint* out_buffer_size); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_writeToBuffer", ExactSpelling = true)] + [return: NativeTypeName("enum CXErrorCode")] + public static extern CXErrorCode VirtualFileOverlay_writeToBuffer([NativeTypeName("CXVirtualFileOverlay")] CXVirtualFileOverlayImpl* param0, [NativeTypeName("unsigned int")] uint options, [NativeTypeName("char **")] sbyte** out_buffer_ptr, [NativeTypeName("unsigned int *")] uint* out_buffer_size); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_free", ExactSpelling = true)] - public static extern void free(void* buffer); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_free", ExactSpelling = true)] + public static extern void free(void* buffer); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_dispose", ExactSpelling = true)] - public static extern void VirtualFileOverlay_dispose([NativeTypeName("CXVirtualFileOverlay")] CXVirtualFileOverlayImpl* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VirtualFileOverlay_dispose", ExactSpelling = true)] + public static extern void VirtualFileOverlay_dispose([NativeTypeName("CXVirtualFileOverlay")] CXVirtualFileOverlayImpl* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_create", ExactSpelling = true)] - [return: NativeTypeName("CXModuleMapDescriptor")] - public static extern CXModuleMapDescriptorImpl* ModuleMapDescriptor_create([NativeTypeName("unsigned int")] uint options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_create", ExactSpelling = true)] + [return: NativeTypeName("CXModuleMapDescriptor")] + public static extern CXModuleMapDescriptorImpl* ModuleMapDescriptor_create([NativeTypeName("unsigned int")] uint options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_setFrameworkModuleName", ExactSpelling = true)] - [return: NativeTypeName("enum CXErrorCode")] - public static extern CXErrorCode ModuleMapDescriptor_setFrameworkModuleName([NativeTypeName("CXModuleMapDescriptor")] CXModuleMapDescriptorImpl* param0, [NativeTypeName("const char *")] sbyte* name); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_setFrameworkModuleName", ExactSpelling = true)] + [return: NativeTypeName("enum CXErrorCode")] + public static extern CXErrorCode ModuleMapDescriptor_setFrameworkModuleName([NativeTypeName("CXModuleMapDescriptor")] CXModuleMapDescriptorImpl* param0, [NativeTypeName("const char *")] sbyte* name); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_setUmbrellaHeader", ExactSpelling = true)] - [return: NativeTypeName("enum CXErrorCode")] - public static extern CXErrorCode ModuleMapDescriptor_setUmbrellaHeader([NativeTypeName("CXModuleMapDescriptor")] CXModuleMapDescriptorImpl* param0, [NativeTypeName("const char *")] sbyte* name); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_setUmbrellaHeader", ExactSpelling = true)] + [return: NativeTypeName("enum CXErrorCode")] + public static extern CXErrorCode ModuleMapDescriptor_setUmbrellaHeader([NativeTypeName("CXModuleMapDescriptor")] CXModuleMapDescriptorImpl* param0, [NativeTypeName("const char *")] sbyte* name); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_writeToBuffer", ExactSpelling = true)] - [return: NativeTypeName("enum CXErrorCode")] - public static extern CXErrorCode ModuleMapDescriptor_writeToBuffer([NativeTypeName("CXModuleMapDescriptor")] CXModuleMapDescriptorImpl* param0, [NativeTypeName("unsigned int")] uint options, [NativeTypeName("char **")] sbyte** out_buffer_ptr, [NativeTypeName("unsigned int *")] uint* out_buffer_size); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_writeToBuffer", ExactSpelling = true)] + [return: NativeTypeName("enum CXErrorCode")] + public static extern CXErrorCode ModuleMapDescriptor_writeToBuffer([NativeTypeName("CXModuleMapDescriptor")] CXModuleMapDescriptorImpl* param0, [NativeTypeName("unsigned int")] uint options, [NativeTypeName("char **")] sbyte** out_buffer_ptr, [NativeTypeName("unsigned int *")] uint* out_buffer_size); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_dispose", ExactSpelling = true)] - public static extern void ModuleMapDescriptor_dispose([NativeTypeName("CXModuleMapDescriptor")] CXModuleMapDescriptorImpl* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ModuleMapDescriptor_dispose", ExactSpelling = true)] + public static extern void ModuleMapDescriptor_dispose([NativeTypeName("CXModuleMapDescriptor")] CXModuleMapDescriptorImpl* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompilationDatabase_fromDirectory", ExactSpelling = true)] - [return: NativeTypeName("CXCompilationDatabase")] - public static extern void* CompilationDatabase_fromDirectory([NativeTypeName("const char *")] sbyte* BuildDir, CXCompilationDatabase_Error* ErrorCode); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompilationDatabase_fromDirectory", ExactSpelling = true)] + [return: NativeTypeName("CXCompilationDatabase")] + public static extern void* CompilationDatabase_fromDirectory([NativeTypeName("const char *")] sbyte* BuildDir, CXCompilationDatabase_Error* ErrorCode); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompilationDatabase_dispose", ExactSpelling = true)] - public static extern void CompilationDatabase_dispose([NativeTypeName("CXCompilationDatabase")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompilationDatabase_dispose", ExactSpelling = true)] + public static extern void CompilationDatabase_dispose([NativeTypeName("CXCompilationDatabase")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompilationDatabase_getCompileCommands", ExactSpelling = true)] - [return: NativeTypeName("CXCompileCommands")] - public static extern void* CompilationDatabase_getCompileCommands([NativeTypeName("CXCompilationDatabase")] void* param0, [NativeTypeName("const char *")] sbyte* CompleteFileName); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompilationDatabase_getCompileCommands", ExactSpelling = true)] + [return: NativeTypeName("CXCompileCommands")] + public static extern void* CompilationDatabase_getCompileCommands([NativeTypeName("CXCompilationDatabase")] void* param0, [NativeTypeName("const char *")] sbyte* CompleteFileName); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompilationDatabase_getAllCompileCommands", ExactSpelling = true)] - [return: NativeTypeName("CXCompileCommands")] - public static extern void* CompilationDatabase_getAllCompileCommands([NativeTypeName("CXCompilationDatabase")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompilationDatabase_getAllCompileCommands", ExactSpelling = true)] + [return: NativeTypeName("CXCompileCommands")] + public static extern void* CompilationDatabase_getAllCompileCommands([NativeTypeName("CXCompilationDatabase")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommands_dispose", ExactSpelling = true)] - public static extern void CompileCommands_dispose([NativeTypeName("CXCompileCommands")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommands_dispose", ExactSpelling = true)] + public static extern void CompileCommands_dispose([NativeTypeName("CXCompileCommands")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommands_getSize", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CompileCommands_getSize([NativeTypeName("CXCompileCommands")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommands_getSize", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CompileCommands_getSize([NativeTypeName("CXCompileCommands")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommands_getCommand", ExactSpelling = true)] - [return: NativeTypeName("CXCompileCommand")] - public static extern void* CompileCommands_getCommand([NativeTypeName("CXCompileCommands")] void* param0, [NativeTypeName("unsigned int")] uint I); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommands_getCommand", ExactSpelling = true)] + [return: NativeTypeName("CXCompileCommand")] + public static extern void* CompileCommands_getCommand([NativeTypeName("CXCompileCommands")] void* param0, [NativeTypeName("unsigned int")] uint I); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getDirectory", ExactSpelling = true)] - public static extern CXString CompileCommand_getDirectory([NativeTypeName("CXCompileCommand")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getDirectory", ExactSpelling = true)] + public static extern CXString CompileCommand_getDirectory([NativeTypeName("CXCompileCommand")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getFilename", ExactSpelling = true)] - public static extern CXString CompileCommand_getFilename([NativeTypeName("CXCompileCommand")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getFilename", ExactSpelling = true)] + public static extern CXString CompileCommand_getFilename([NativeTypeName("CXCompileCommand")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getNumArgs", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CompileCommand_getNumArgs([NativeTypeName("CXCompileCommand")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getNumArgs", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CompileCommand_getNumArgs([NativeTypeName("CXCompileCommand")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getArg", ExactSpelling = true)] - public static extern CXString CompileCommand_getArg([NativeTypeName("CXCompileCommand")] void* param0, [NativeTypeName("unsigned int")] uint I); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getArg", ExactSpelling = true)] + public static extern CXString CompileCommand_getArg([NativeTypeName("CXCompileCommand")] void* param0, [NativeTypeName("unsigned int")] uint I); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getNumMappedSources", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CompileCommand_getNumMappedSources([NativeTypeName("CXCompileCommand")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getNumMappedSources", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CompileCommand_getNumMappedSources([NativeTypeName("CXCompileCommand")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getMappedSourcePath", ExactSpelling = true)] - public static extern CXString CompileCommand_getMappedSourcePath([NativeTypeName("CXCompileCommand")] void* param0, [NativeTypeName("unsigned int")] uint I); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getMappedSourcePath", ExactSpelling = true)] + public static extern CXString CompileCommand_getMappedSourcePath([NativeTypeName("CXCompileCommand")] void* param0, [NativeTypeName("unsigned int")] uint I); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getMappedSourceContent", ExactSpelling = true)] - public static extern CXString CompileCommand_getMappedSourceContent([NativeTypeName("CXCompileCommand")] void* param0, [NativeTypeName("unsigned int")] uint I); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CompileCommand_getMappedSourceContent", ExactSpelling = true)] + public static extern CXString CompileCommand_getMappedSourceContent([NativeTypeName("CXCompileCommand")] void* param0, [NativeTypeName("unsigned int")] uint I); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCString", ExactSpelling = true)] - [return: NativeTypeName("const char *")] - public static extern sbyte* getCString(CXString @string); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCString", ExactSpelling = true)] + [return: NativeTypeName("const char *")] + public static extern sbyte* getCString(CXString @string); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeString", ExactSpelling = true)] - public static extern void disposeString(CXString @string); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeString", ExactSpelling = true)] + public static extern void disposeString(CXString @string); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeStringSet", ExactSpelling = true)] - public static extern void disposeStringSet(CXStringSet* set); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeStringSet", ExactSpelling = true)] + public static extern void disposeStringSet(CXStringSet* set); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getParsedComment", ExactSpelling = true)] - public static extern CXComment Cursor_getParsedComment(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getParsedComment", ExactSpelling = true)] + public static extern CXComment Cursor_getParsedComment(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Comment_getKind", ExactSpelling = true)] - [return: NativeTypeName("enum CXCommentKind")] - public static extern CXCommentKind Comment_getKind(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Comment_getKind", ExactSpelling = true)] + [return: NativeTypeName("enum CXCommentKind")] + public static extern CXCommentKind Comment_getKind(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Comment_getNumChildren", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Comment_getNumChildren(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Comment_getNumChildren", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Comment_getNumChildren(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Comment_getChild", ExactSpelling = true)] - public static extern CXComment Comment_getChild(CXComment Comment, [NativeTypeName("unsigned int")] uint ChildIdx); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Comment_getChild", ExactSpelling = true)] + public static extern CXComment Comment_getChild(CXComment Comment, [NativeTypeName("unsigned int")] uint ChildIdx); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Comment_isWhitespace", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Comment_isWhitespace(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Comment_isWhitespace", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Comment_isWhitespace(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineContentComment_hasTrailingNewline", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint InlineContentComment_hasTrailingNewline(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineContentComment_hasTrailingNewline", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint InlineContentComment_hasTrailingNewline(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TextComment_getText", ExactSpelling = true)] - public static extern CXString TextComment_getText(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TextComment_getText", ExactSpelling = true)] + public static extern CXString TextComment_getText(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineCommandComment_getCommandName", ExactSpelling = true)] - public static extern CXString InlineCommandComment_getCommandName(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineCommandComment_getCommandName", ExactSpelling = true)] + public static extern CXString InlineCommandComment_getCommandName(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineCommandComment_getRenderKind", ExactSpelling = true)] - [return: NativeTypeName("enum CXCommentInlineCommandRenderKind")] - public static extern CXCommentInlineCommandRenderKind InlineCommandComment_getRenderKind(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineCommandComment_getRenderKind", ExactSpelling = true)] + [return: NativeTypeName("enum CXCommentInlineCommandRenderKind")] + public static extern CXCommentInlineCommandRenderKind InlineCommandComment_getRenderKind(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineCommandComment_getNumArgs", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint InlineCommandComment_getNumArgs(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineCommandComment_getNumArgs", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint InlineCommandComment_getNumArgs(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineCommandComment_getArgText", ExactSpelling = true)] - public static extern CXString InlineCommandComment_getArgText(CXComment Comment, [NativeTypeName("unsigned int")] uint ArgIdx); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_InlineCommandComment_getArgText", ExactSpelling = true)] + public static extern CXString InlineCommandComment_getArgText(CXComment Comment, [NativeTypeName("unsigned int")] uint ArgIdx); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLTagComment_getTagName", ExactSpelling = true)] - public static extern CXString HTMLTagComment_getTagName(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLTagComment_getTagName", ExactSpelling = true)] + public static extern CXString HTMLTagComment_getTagName(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLStartTagComment_isSelfClosing", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint HTMLStartTagComment_isSelfClosing(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLStartTagComment_isSelfClosing", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint HTMLStartTagComment_isSelfClosing(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLStartTag_getNumAttrs", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint HTMLStartTag_getNumAttrs(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLStartTag_getNumAttrs", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint HTMLStartTag_getNumAttrs(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLStartTag_getAttrName", ExactSpelling = true)] - public static extern CXString HTMLStartTag_getAttrName(CXComment Comment, [NativeTypeName("unsigned int")] uint AttrIdx); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLStartTag_getAttrName", ExactSpelling = true)] + public static extern CXString HTMLStartTag_getAttrName(CXComment Comment, [NativeTypeName("unsigned int")] uint AttrIdx); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLStartTag_getAttrValue", ExactSpelling = true)] - public static extern CXString HTMLStartTag_getAttrValue(CXComment Comment, [NativeTypeName("unsigned int")] uint AttrIdx); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLStartTag_getAttrValue", ExactSpelling = true)] + public static extern CXString HTMLStartTag_getAttrValue(CXComment Comment, [NativeTypeName("unsigned int")] uint AttrIdx); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_BlockCommandComment_getCommandName", ExactSpelling = true)] - public static extern CXString BlockCommandComment_getCommandName(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_BlockCommandComment_getCommandName", ExactSpelling = true)] + public static extern CXString BlockCommandComment_getCommandName(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_BlockCommandComment_getNumArgs", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint BlockCommandComment_getNumArgs(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_BlockCommandComment_getNumArgs", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint BlockCommandComment_getNumArgs(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_BlockCommandComment_getArgText", ExactSpelling = true)] - public static extern CXString BlockCommandComment_getArgText(CXComment Comment, [NativeTypeName("unsigned int")] uint ArgIdx); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_BlockCommandComment_getArgText", ExactSpelling = true)] + public static extern CXString BlockCommandComment_getArgText(CXComment Comment, [NativeTypeName("unsigned int")] uint ArgIdx); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_BlockCommandComment_getParagraph", ExactSpelling = true)] - public static extern CXComment BlockCommandComment_getParagraph(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_BlockCommandComment_getParagraph", ExactSpelling = true)] + public static extern CXComment BlockCommandComment_getParagraph(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_getParamName", ExactSpelling = true)] - public static extern CXString ParamCommandComment_getParamName(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_getParamName", ExactSpelling = true)] + public static extern CXString ParamCommandComment_getParamName(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_isParamIndexValid", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint ParamCommandComment_isParamIndexValid(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_isParamIndexValid", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint ParamCommandComment_isParamIndexValid(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_getParamIndex", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint ParamCommandComment_getParamIndex(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_getParamIndex", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint ParamCommandComment_getParamIndex(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_isDirectionExplicit", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint ParamCommandComment_isDirectionExplicit(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_isDirectionExplicit", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint ParamCommandComment_isDirectionExplicit(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_getDirection", ExactSpelling = true)] - [return: NativeTypeName("enum CXCommentParamPassDirection")] - public static extern CXCommentParamPassDirection ParamCommandComment_getDirection(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_ParamCommandComment_getDirection", ExactSpelling = true)] + [return: NativeTypeName("enum CXCommentParamPassDirection")] + public static extern CXCommentParamPassDirection ParamCommandComment_getDirection(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TParamCommandComment_getParamName", ExactSpelling = true)] - public static extern CXString TParamCommandComment_getParamName(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TParamCommandComment_getParamName", ExactSpelling = true)] + public static extern CXString TParamCommandComment_getParamName(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TParamCommandComment_isParamPositionValid", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint TParamCommandComment_isParamPositionValid(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TParamCommandComment_isParamPositionValid", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint TParamCommandComment_isParamPositionValid(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TParamCommandComment_getDepth", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint TParamCommandComment_getDepth(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TParamCommandComment_getDepth", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint TParamCommandComment_getDepth(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TParamCommandComment_getIndex", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint TParamCommandComment_getIndex(CXComment Comment, [NativeTypeName("unsigned int")] uint Depth); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TParamCommandComment_getIndex", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint TParamCommandComment_getIndex(CXComment Comment, [NativeTypeName("unsigned int")] uint Depth); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VerbatimBlockLineComment_getText", ExactSpelling = true)] - public static extern CXString VerbatimBlockLineComment_getText(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VerbatimBlockLineComment_getText", ExactSpelling = true)] + public static extern CXString VerbatimBlockLineComment_getText(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VerbatimLineComment_getText", ExactSpelling = true)] - public static extern CXString VerbatimLineComment_getText(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_VerbatimLineComment_getText", ExactSpelling = true)] + public static extern CXString VerbatimLineComment_getText(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLTagComment_getAsString", ExactSpelling = true)] - public static extern CXString HTMLTagComment_getAsString(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_HTMLTagComment_getAsString", ExactSpelling = true)] + public static extern CXString HTMLTagComment_getAsString(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_FullComment_getAsHTML", ExactSpelling = true)] - public static extern CXString FullComment_getAsHTML(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_FullComment_getAsHTML", ExactSpelling = true)] + public static extern CXString FullComment_getAsHTML(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_FullComment_getAsXML", ExactSpelling = true)] - public static extern CXString FullComment_getAsXML(CXComment Comment); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_FullComment_getAsXML", ExactSpelling = true)] + public static extern CXString FullComment_getAsXML(CXComment Comment); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_install_aborting_llvm_fatal_error_handler", ExactSpelling = true)] - public static extern void install_aborting_llvm_fatal_error_handler(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_install_aborting_llvm_fatal_error_handler", ExactSpelling = true)] + public static extern void install_aborting_llvm_fatal_error_handler(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_uninstall_llvm_fatal_error_handler", ExactSpelling = true)] - public static extern void uninstall_llvm_fatal_error_handler(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_uninstall_llvm_fatal_error_handler", ExactSpelling = true)] + public static extern void uninstall_llvm_fatal_error_handler(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createIndex", ExactSpelling = true)] - [return: NativeTypeName("CXIndex")] - public static extern void* createIndex(int excludeDeclarationsFromPCH, int displayDiagnostics); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createIndex", ExactSpelling = true)] + [return: NativeTypeName("CXIndex")] + public static extern void* createIndex(int excludeDeclarationsFromPCH, int displayDiagnostics); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeIndex", ExactSpelling = true)] - public static extern void disposeIndex([NativeTypeName("CXIndex")] void* index); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeIndex", ExactSpelling = true)] + public static extern void disposeIndex([NativeTypeName("CXIndex")] void* index); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXIndex_setGlobalOptions", ExactSpelling = true)] - public static extern void CXIndex_setGlobalOptions([NativeTypeName("CXIndex")] void* param0, [NativeTypeName("unsigned int")] uint options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXIndex_setGlobalOptions", ExactSpelling = true)] + public static extern void CXIndex_setGlobalOptions([NativeTypeName("CXIndex")] void* param0, [NativeTypeName("unsigned int")] uint options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXIndex_getGlobalOptions", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXIndex_getGlobalOptions([NativeTypeName("CXIndex")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXIndex_getGlobalOptions", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXIndex_getGlobalOptions([NativeTypeName("CXIndex")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXIndex_setInvocationEmissionPathOption", ExactSpelling = true)] - public static extern void CXIndex_setInvocationEmissionPathOption([NativeTypeName("CXIndex")] void* param0, [NativeTypeName("const char *")] sbyte* Path); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXIndex_setInvocationEmissionPathOption", ExactSpelling = true)] + public static extern void CXIndex_setInvocationEmissionPathOption([NativeTypeName("CXIndex")] void* param0, [NativeTypeName("const char *")] sbyte* Path); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileName", ExactSpelling = true)] - public static extern CXString getFileName([NativeTypeName("CXFile")] void* SFile); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileName", ExactSpelling = true)] + public static extern CXString getFileName([NativeTypeName("CXFile")] void* SFile); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileTime", ExactSpelling = true)] - [return: NativeTypeName("time_t")] - public static extern long getFileTime([NativeTypeName("CXFile")] void* SFile); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileTime", ExactSpelling = true)] + [return: NativeTypeName("time_t")] + public static extern long getFileTime([NativeTypeName("CXFile")] void* SFile); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileUniqueID", ExactSpelling = true)] - public static extern int getFileUniqueID([NativeTypeName("CXFile")] void* file, CXFileUniqueID* outID); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileUniqueID", ExactSpelling = true)] + public static extern int getFileUniqueID([NativeTypeName("CXFile")] void* file, CXFileUniqueID* outID); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isFileMultipleIncludeGuarded", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isFileMultipleIncludeGuarded([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isFileMultipleIncludeGuarded", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isFileMultipleIncludeGuarded([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFile", ExactSpelling = true)] - [return: NativeTypeName("CXFile")] - public static extern void* getFile([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("const char *")] sbyte* file_name); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFile", ExactSpelling = true)] + [return: NativeTypeName("CXFile")] + public static extern void* getFile([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("const char *")] sbyte* file_name); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileContents", ExactSpelling = true)] - [return: NativeTypeName("const char *")] - public static extern sbyte* getFileContents([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file, [NativeTypeName("size_t *")] UIntPtr* size); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileContents", ExactSpelling = true)] + [return: NativeTypeName("const char *")] + public static extern sbyte* getFileContents([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file, [NativeTypeName("size_t *")] UIntPtr* size); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_File_isEqual", ExactSpelling = true)] - public static extern int File_isEqual([NativeTypeName("CXFile")] void* file1, [NativeTypeName("CXFile")] void* file2); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_File_isEqual", ExactSpelling = true)] + public static extern int File_isEqual([NativeTypeName("CXFile")] void* file1, [NativeTypeName("CXFile")] void* file2); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_File_tryGetRealPathName", ExactSpelling = true)] - public static extern CXString File_tryGetRealPathName([NativeTypeName("CXFile")] void* file); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_File_tryGetRealPathName", ExactSpelling = true)] + public static extern CXString File_tryGetRealPathName([NativeTypeName("CXFile")] void* file); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNullLocation", ExactSpelling = true)] - public static extern CXSourceLocation getNullLocation(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNullLocation", ExactSpelling = true)] + public static extern CXSourceLocation getNullLocation(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_equalLocations", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint equalLocations(CXSourceLocation loc1, CXSourceLocation loc2); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_equalLocations", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint equalLocations(CXSourceLocation loc1, CXSourceLocation loc2); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getLocation", ExactSpelling = true)] - public static extern CXSourceLocation getLocation([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file, [NativeTypeName("unsigned int")] uint line, [NativeTypeName("unsigned int")] uint column); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getLocation", ExactSpelling = true)] + public static extern CXSourceLocation getLocation([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file, [NativeTypeName("unsigned int")] uint line, [NativeTypeName("unsigned int")] uint column); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getLocationForOffset", ExactSpelling = true)] - public static extern CXSourceLocation getLocationForOffset([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file, [NativeTypeName("unsigned int")] uint offset); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getLocationForOffset", ExactSpelling = true)] + public static extern CXSourceLocation getLocationForOffset([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file, [NativeTypeName("unsigned int")] uint offset); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Location_isInSystemHeader", ExactSpelling = true)] - public static extern int Location_isInSystemHeader(CXSourceLocation location); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Location_isInSystemHeader", ExactSpelling = true)] + public static extern int Location_isInSystemHeader(CXSourceLocation location); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Location_isFromMainFile", ExactSpelling = true)] - public static extern int Location_isFromMainFile(CXSourceLocation location); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Location_isFromMainFile", ExactSpelling = true)] + public static extern int Location_isFromMainFile(CXSourceLocation location); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNullRange", ExactSpelling = true)] - public static extern CXSourceRange getNullRange(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNullRange", ExactSpelling = true)] + public static extern CXSourceRange getNullRange(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRange", ExactSpelling = true)] - public static extern CXSourceRange getRange(CXSourceLocation begin, CXSourceLocation end); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRange", ExactSpelling = true)] + public static extern CXSourceRange getRange(CXSourceLocation begin, CXSourceLocation end); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_equalRanges", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint equalRanges(CXSourceRange range1, CXSourceRange range2); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_equalRanges", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint equalRanges(CXSourceRange range1, CXSourceRange range2); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Range_isNull", ExactSpelling = true)] - public static extern int Range_isNull(CXSourceRange range); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Range_isNull", ExactSpelling = true)] + public static extern int Range_isNull(CXSourceRange range); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getExpansionLocation", ExactSpelling = true)] - public static extern void getExpansionLocation(CXSourceLocation location, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getExpansionLocation", ExactSpelling = true)] + public static extern void getExpansionLocation(CXSourceLocation location, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getPresumedLocation", ExactSpelling = true)] - public static extern void getPresumedLocation(CXSourceLocation location, CXString* filename, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getPresumedLocation", ExactSpelling = true)] + public static extern void getPresumedLocation(CXSourceLocation location, CXString* filename, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getInstantiationLocation", ExactSpelling = true)] - public static extern void getInstantiationLocation(CXSourceLocation location, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getInstantiationLocation", ExactSpelling = true)] + public static extern void getInstantiationLocation(CXSourceLocation location, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getSpellingLocation", ExactSpelling = true)] - public static extern void getSpellingLocation(CXSourceLocation location, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getSpellingLocation", ExactSpelling = true)] + public static extern void getSpellingLocation(CXSourceLocation location, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileLocation", ExactSpelling = true)] - public static extern void getFileLocation(CXSourceLocation location, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFileLocation", ExactSpelling = true)] + public static extern void getFileLocation(CXSourceLocation location, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRangeStart", ExactSpelling = true)] - public static extern CXSourceLocation getRangeStart(CXSourceRange range); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRangeStart", ExactSpelling = true)] + public static extern CXSourceLocation getRangeStart(CXSourceRange range); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRangeEnd", ExactSpelling = true)] - public static extern CXSourceLocation getRangeEnd(CXSourceRange range); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRangeEnd", ExactSpelling = true)] + public static extern CXSourceLocation getRangeEnd(CXSourceRange range); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getSkippedRanges", ExactSpelling = true)] - public static extern CXSourceRangeList* getSkippedRanges([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getSkippedRanges", ExactSpelling = true)] + public static extern CXSourceRangeList* getSkippedRanges([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXFile")] void* file); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getAllSkippedRanges", ExactSpelling = true)] - public static extern CXSourceRangeList* getAllSkippedRanges([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getAllSkippedRanges", ExactSpelling = true)] + public static extern CXSourceRangeList* getAllSkippedRanges([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeSourceRangeList", ExactSpelling = true)] - public static extern void disposeSourceRangeList(CXSourceRangeList* ranges); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeSourceRangeList", ExactSpelling = true)] + public static extern void disposeSourceRangeList(CXSourceRangeList* ranges); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumDiagnosticsInSet", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getNumDiagnosticsInSet([NativeTypeName("CXDiagnosticSet")] void* Diags); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumDiagnosticsInSet", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getNumDiagnosticsInSet([NativeTypeName("CXDiagnosticSet")] void* Diags); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticInSet", ExactSpelling = true)] - [return: NativeTypeName("CXDiagnostic")] - public static extern void* getDiagnosticInSet([NativeTypeName("CXDiagnosticSet")] void* Diags, [NativeTypeName("unsigned int")] uint Index); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticInSet", ExactSpelling = true)] + [return: NativeTypeName("CXDiagnostic")] + public static extern void* getDiagnosticInSet([NativeTypeName("CXDiagnosticSet")] void* Diags, [NativeTypeName("unsigned int")] uint Index); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_loadDiagnostics", ExactSpelling = true)] - [return: NativeTypeName("CXDiagnosticSet")] - public static extern void* loadDiagnostics([NativeTypeName("const char *")] sbyte* file, [NativeTypeName("enum CXLoadDiag_Error *")] CXLoadDiag_Error* error, CXString* errorString); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_loadDiagnostics", ExactSpelling = true)] + [return: NativeTypeName("CXDiagnosticSet")] + public static extern void* loadDiagnostics([NativeTypeName("const char *")] sbyte* file, [NativeTypeName("enum CXLoadDiag_Error *")] CXLoadDiag_Error* error, CXString* errorString); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeDiagnosticSet", ExactSpelling = true)] - public static extern void disposeDiagnosticSet([NativeTypeName("CXDiagnosticSet")] void* Diags); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeDiagnosticSet", ExactSpelling = true)] + public static extern void disposeDiagnosticSet([NativeTypeName("CXDiagnosticSet")] void* Diags); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getChildDiagnostics", ExactSpelling = true)] - [return: NativeTypeName("CXDiagnosticSet")] - public static extern void* getChildDiagnostics([NativeTypeName("CXDiagnostic")] void* D); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getChildDiagnostics", ExactSpelling = true)] + [return: NativeTypeName("CXDiagnosticSet")] + public static extern void* getChildDiagnostics([NativeTypeName("CXDiagnostic")] void* D); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumDiagnostics", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getNumDiagnostics([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* Unit); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumDiagnostics", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getNumDiagnostics([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* Unit); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnostic", ExactSpelling = true)] - [return: NativeTypeName("CXDiagnostic")] - public static extern void* getDiagnostic([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* Unit, [NativeTypeName("unsigned int")] uint Index); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnostic", ExactSpelling = true)] + [return: NativeTypeName("CXDiagnostic")] + public static extern void* getDiagnostic([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* Unit, [NativeTypeName("unsigned int")] uint Index); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticSetFromTU", ExactSpelling = true)] - [return: NativeTypeName("CXDiagnosticSet")] - public static extern void* getDiagnosticSetFromTU([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* Unit); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticSetFromTU", ExactSpelling = true)] + [return: NativeTypeName("CXDiagnosticSet")] + public static extern void* getDiagnosticSetFromTU([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* Unit); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeDiagnostic", ExactSpelling = true)] - public static extern void disposeDiagnostic([NativeTypeName("CXDiagnostic")] void* Diagnostic); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeDiagnostic", ExactSpelling = true)] + public static extern void disposeDiagnostic([NativeTypeName("CXDiagnostic")] void* Diagnostic); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_formatDiagnostic", ExactSpelling = true)] - public static extern CXString formatDiagnostic([NativeTypeName("CXDiagnostic")] void* Diagnostic, [NativeTypeName("unsigned int")] uint Options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_formatDiagnostic", ExactSpelling = true)] + public static extern CXString formatDiagnostic([NativeTypeName("CXDiagnostic")] void* Diagnostic, [NativeTypeName("unsigned int")] uint Options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultDiagnosticDisplayOptions", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint defaultDiagnosticDisplayOptions(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultDiagnosticDisplayOptions", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint defaultDiagnosticDisplayOptions(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticSeverity", ExactSpelling = true)] - [return: NativeTypeName("enum CXDiagnosticSeverity")] - public static extern CXDiagnosticSeverity getDiagnosticSeverity([NativeTypeName("CXDiagnostic")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticSeverity", ExactSpelling = true)] + [return: NativeTypeName("enum CXDiagnosticSeverity")] + public static extern CXDiagnosticSeverity getDiagnosticSeverity([NativeTypeName("CXDiagnostic")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticLocation", ExactSpelling = true)] - public static extern CXSourceLocation getDiagnosticLocation([NativeTypeName("CXDiagnostic")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticLocation", ExactSpelling = true)] + public static extern CXSourceLocation getDiagnosticLocation([NativeTypeName("CXDiagnostic")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticSpelling", ExactSpelling = true)] - public static extern CXString getDiagnosticSpelling([NativeTypeName("CXDiagnostic")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticSpelling", ExactSpelling = true)] + public static extern CXString getDiagnosticSpelling([NativeTypeName("CXDiagnostic")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticOption", ExactSpelling = true)] - public static extern CXString getDiagnosticOption([NativeTypeName("CXDiagnostic")] void* Diag, CXString* Disable); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticOption", ExactSpelling = true)] + public static extern CXString getDiagnosticOption([NativeTypeName("CXDiagnostic")] void* Diag, CXString* Disable); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticCategory", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getDiagnosticCategory([NativeTypeName("CXDiagnostic")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticCategory", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getDiagnosticCategory([NativeTypeName("CXDiagnostic")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticCategoryName", ExactSpelling = true)] - public static extern CXString getDiagnosticCategoryName([NativeTypeName("unsigned int")] uint Category); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticCategoryName", ExactSpelling = true)] + public static extern CXString getDiagnosticCategoryName([NativeTypeName("unsigned int")] uint Category); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticCategoryText", ExactSpelling = true)] - public static extern CXString getDiagnosticCategoryText([NativeTypeName("CXDiagnostic")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticCategoryText", ExactSpelling = true)] + public static extern CXString getDiagnosticCategoryText([NativeTypeName("CXDiagnostic")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticNumRanges", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getDiagnosticNumRanges([NativeTypeName("CXDiagnostic")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticNumRanges", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getDiagnosticNumRanges([NativeTypeName("CXDiagnostic")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticRange", ExactSpelling = true)] - public static extern CXSourceRange getDiagnosticRange([NativeTypeName("CXDiagnostic")] void* Diagnostic, [NativeTypeName("unsigned int")] uint Range); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticRange", ExactSpelling = true)] + public static extern CXSourceRange getDiagnosticRange([NativeTypeName("CXDiagnostic")] void* Diagnostic, [NativeTypeName("unsigned int")] uint Range); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticNumFixIts", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getDiagnosticNumFixIts([NativeTypeName("CXDiagnostic")] void* Diagnostic); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticNumFixIts", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getDiagnosticNumFixIts([NativeTypeName("CXDiagnostic")] void* Diagnostic); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticFixIt", ExactSpelling = true)] - public static extern CXString getDiagnosticFixIt([NativeTypeName("CXDiagnostic")] void* Diagnostic, [NativeTypeName("unsigned int")] uint FixIt, CXSourceRange* ReplacementRange); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticFixIt", ExactSpelling = true)] + public static extern CXString getDiagnosticFixIt([NativeTypeName("CXDiagnostic")] void* Diagnostic, [NativeTypeName("unsigned int")] uint FixIt, CXSourceRange* ReplacementRange); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTranslationUnitSpelling", ExactSpelling = true)] - public static extern CXString getTranslationUnitSpelling([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* CTUnit); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTranslationUnitSpelling", ExactSpelling = true)] + public static extern CXString getTranslationUnitSpelling([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* CTUnit); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createTranslationUnitFromSourceFile", ExactSpelling = true)] - [return: NativeTypeName("CXTranslationUnit")] - public static extern CXTranslationUnitImpl* createTranslationUnitFromSourceFile([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* source_filename, int num_clang_command_line_args, [NativeTypeName("const char *const *")] sbyte** clang_command_line_args, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createTranslationUnitFromSourceFile", ExactSpelling = true)] + [return: NativeTypeName("CXTranslationUnit")] + public static extern CXTranslationUnitImpl* createTranslationUnitFromSourceFile([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* source_filename, int num_clang_command_line_args, [NativeTypeName("const char *const *")] sbyte** clang_command_line_args, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createTranslationUnit", ExactSpelling = true)] - [return: NativeTypeName("CXTranslationUnit")] - public static extern CXTranslationUnitImpl* createTranslationUnit([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* ast_filename); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createTranslationUnit", ExactSpelling = true)] + [return: NativeTypeName("CXTranslationUnit")] + public static extern CXTranslationUnitImpl* createTranslationUnit([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* ast_filename); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createTranslationUnit2", ExactSpelling = true)] - [return: NativeTypeName("enum CXErrorCode")] - public static extern CXErrorCode createTranslationUnit2([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* ast_filename, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createTranslationUnit2", ExactSpelling = true)] + [return: NativeTypeName("enum CXErrorCode")] + public static extern CXErrorCode createTranslationUnit2([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* ast_filename, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultEditingTranslationUnitOptions", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint defaultEditingTranslationUnitOptions(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultEditingTranslationUnitOptions", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint defaultEditingTranslationUnitOptions(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_parseTranslationUnit", ExactSpelling = true)] - [return: NativeTypeName("CXTranslationUnit")] - public static extern CXTranslationUnitImpl* parseTranslationUnit([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("unsigned int")] uint options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_parseTranslationUnit", ExactSpelling = true)] + [return: NativeTypeName("CXTranslationUnit")] + public static extern CXTranslationUnitImpl* parseTranslationUnit([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("unsigned int")] uint options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_parseTranslationUnit2", ExactSpelling = true)] - [return: NativeTypeName("enum CXErrorCode")] - public static extern CXErrorCode parseTranslationUnit2([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("unsigned int")] uint options, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_parseTranslationUnit2", ExactSpelling = true)] + [return: NativeTypeName("enum CXErrorCode")] + public static extern CXErrorCode parseTranslationUnit2([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("unsigned int")] uint options, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_parseTranslationUnit2FullArgv", ExactSpelling = true)] - [return: NativeTypeName("enum CXErrorCode")] - public static extern CXErrorCode parseTranslationUnit2FullArgv([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("unsigned int")] uint options, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_parseTranslationUnit2FullArgv", ExactSpelling = true)] + [return: NativeTypeName("enum CXErrorCode")] + public static extern CXErrorCode parseTranslationUnit2FullArgv([NativeTypeName("CXIndex")] void* CIdx, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("unsigned int")] uint options, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultSaveOptions", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint defaultSaveOptions([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultSaveOptions", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint defaultSaveOptions([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_saveTranslationUnit", ExactSpelling = true)] - public static extern int saveTranslationUnit([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, [NativeTypeName("const char *")] sbyte* FileName, [NativeTypeName("unsigned int")] uint options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_saveTranslationUnit", ExactSpelling = true)] + public static extern int saveTranslationUnit([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, [NativeTypeName("const char *")] sbyte* FileName, [NativeTypeName("unsigned int")] uint options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_suspendTranslationUnit", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint suspendTranslationUnit([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_suspendTranslationUnit", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint suspendTranslationUnit([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeTranslationUnit", ExactSpelling = true)] - public static extern void disposeTranslationUnit([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeTranslationUnit", ExactSpelling = true)] + public static extern void disposeTranslationUnit([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultReparseOptions", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint defaultReparseOptions([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultReparseOptions", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint defaultReparseOptions([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_reparseTranslationUnit", ExactSpelling = true)] - public static extern int reparseTranslationUnit([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_reparseTranslationUnit", ExactSpelling = true)] + public static extern int reparseTranslationUnit([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTUResourceUsageName", ExactSpelling = true)] - [return: NativeTypeName("const char *")] - public static extern sbyte* getTUResourceUsageName([NativeTypeName("enum CXTUResourceUsageKind")] CXTUResourceUsageKind kind); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTUResourceUsageName", ExactSpelling = true)] + [return: NativeTypeName("const char *")] + public static extern sbyte* getTUResourceUsageName([NativeTypeName("enum CXTUResourceUsageKind")] CXTUResourceUsageKind kind); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCXTUResourceUsage", ExactSpelling = true)] - public static extern CXTUResourceUsage getCXTUResourceUsage([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCXTUResourceUsage", ExactSpelling = true)] + public static extern CXTUResourceUsage getCXTUResourceUsage([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeCXTUResourceUsage", ExactSpelling = true)] - public static extern void disposeCXTUResourceUsage(CXTUResourceUsage usage); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeCXTUResourceUsage", ExactSpelling = true)] + public static extern void disposeCXTUResourceUsage(CXTUResourceUsage usage); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTranslationUnitTargetInfo", ExactSpelling = true)] - [return: NativeTypeName("CXTargetInfo")] - public static extern CXTargetInfoImpl* getTranslationUnitTargetInfo([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* CTUnit); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTranslationUnitTargetInfo", ExactSpelling = true)] + [return: NativeTypeName("CXTargetInfo")] + public static extern CXTargetInfoImpl* getTranslationUnitTargetInfo([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* CTUnit); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TargetInfo_dispose", ExactSpelling = true)] - public static extern void TargetInfo_dispose([NativeTypeName("CXTargetInfo")] CXTargetInfoImpl* Info); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TargetInfo_dispose", ExactSpelling = true)] + public static extern void TargetInfo_dispose([NativeTypeName("CXTargetInfo")] CXTargetInfoImpl* Info); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TargetInfo_getTriple", ExactSpelling = true)] - public static extern CXString TargetInfo_getTriple([NativeTypeName("CXTargetInfo")] CXTargetInfoImpl* Info); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TargetInfo_getTriple", ExactSpelling = true)] + public static extern CXString TargetInfo_getTriple([NativeTypeName("CXTargetInfo")] CXTargetInfoImpl* Info); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TargetInfo_getPointerWidth", ExactSpelling = true)] - public static extern int TargetInfo_getPointerWidth([NativeTypeName("CXTargetInfo")] CXTargetInfoImpl* Info); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_TargetInfo_getPointerWidth", ExactSpelling = true)] + public static extern int TargetInfo_getPointerWidth([NativeTypeName("CXTargetInfo")] CXTargetInfoImpl* Info); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNullCursor", ExactSpelling = true)] - public static extern CXCursor getNullCursor(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNullCursor", ExactSpelling = true)] + public static extern CXCursor getNullCursor(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTranslationUnitCursor", ExactSpelling = true)] - public static extern CXCursor getTranslationUnitCursor([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTranslationUnitCursor", ExactSpelling = true)] + public static extern CXCursor getTranslationUnitCursor([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_equalCursors", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint equalCursors(CXCursor param0, CXCursor param1); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_equalCursors", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint equalCursors(CXCursor param0, CXCursor param1); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isNull", ExactSpelling = true)] - public static extern int Cursor_isNull(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isNull", ExactSpelling = true)] + public static extern int Cursor_isNull(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_hashCursor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint hashCursor(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_hashCursor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint hashCursor(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorKind", ExactSpelling = true)] - [return: NativeTypeName("enum CXCursorKind")] - public static extern CXCursorKind getCursorKind(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorKind", ExactSpelling = true)] + [return: NativeTypeName("enum CXCursorKind")] + public static extern CXCursorKind getCursorKind(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isDeclaration", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isDeclaration([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isDeclaration", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isDeclaration([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isInvalidDeclaration", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isInvalidDeclaration(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isInvalidDeclaration", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isInvalidDeclaration(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isReference", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isReference([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isReference", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isReference([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isExpression", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isExpression([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isExpression", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isExpression([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isStatement", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isStatement([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isStatement", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isStatement([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isAttribute", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isAttribute([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isAttribute", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isAttribute([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_hasAttrs", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_hasAttrs(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_hasAttrs", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_hasAttrs(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isInvalid", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isInvalid([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isInvalid", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isInvalid([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isTranslationUnit", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isTranslationUnit([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isTranslationUnit", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isTranslationUnit([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isPreprocessing", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isPreprocessing([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isPreprocessing", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isPreprocessing([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isUnexposed", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isUnexposed([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isUnexposed", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isUnexposed([NativeTypeName("enum CXCursorKind")] CXCursorKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorLinkage", ExactSpelling = true)] - [return: NativeTypeName("enum CXLinkageKind")] - public static extern CXLinkageKind getCursorLinkage(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorLinkage", ExactSpelling = true)] + [return: NativeTypeName("enum CXLinkageKind")] + public static extern CXLinkageKind getCursorLinkage(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorVisibility", ExactSpelling = true)] - [return: NativeTypeName("enum CXVisibilityKind")] - public static extern CXVisibilityKind getCursorVisibility(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorVisibility", ExactSpelling = true)] + [return: NativeTypeName("enum CXVisibilityKind")] + public static extern CXVisibilityKind getCursorVisibility(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorAvailability", ExactSpelling = true)] - [return: NativeTypeName("enum CXAvailabilityKind")] - public static extern CXAvailabilityKind getCursorAvailability(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorAvailability", ExactSpelling = true)] + [return: NativeTypeName("enum CXAvailabilityKind")] + public static extern CXAvailabilityKind getCursorAvailability(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorPlatformAvailability", ExactSpelling = true)] - public static extern int getCursorPlatformAvailability(CXCursor cursor, int* always_deprecated, CXString* deprecated_message, int* always_unavailable, CXString* unavailable_message, CXPlatformAvailability* availability, int availability_size); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorPlatformAvailability", ExactSpelling = true)] + public static extern int getCursorPlatformAvailability(CXCursor cursor, int* always_deprecated, CXString* deprecated_message, int* always_unavailable, CXString* unavailable_message, CXPlatformAvailability* availability, int availability_size); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeCXPlatformAvailability", ExactSpelling = true)] - public static extern void disposeCXPlatformAvailability(CXPlatformAvailability* availability); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeCXPlatformAvailability", ExactSpelling = true)] + public static extern void disposeCXPlatformAvailability(CXPlatformAvailability* availability); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getVarDeclInitializer", ExactSpelling = true)] - public static extern CXCursor Cursor_getVarDeclInitializer(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getVarDeclInitializer", ExactSpelling = true)] + public static extern CXCursor Cursor_getVarDeclInitializer(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_hasVarDeclGlobalStorage", ExactSpelling = true)] - public static extern int Cursor_hasVarDeclGlobalStorage(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_hasVarDeclGlobalStorage", ExactSpelling = true)] + public static extern int Cursor_hasVarDeclGlobalStorage(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_hasVarDeclExternalStorage", ExactSpelling = true)] - public static extern int Cursor_hasVarDeclExternalStorage(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_hasVarDeclExternalStorage", ExactSpelling = true)] + public static extern int Cursor_hasVarDeclExternalStorage(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorLanguage", ExactSpelling = true)] - [return: NativeTypeName("enum CXLanguageKind")] - public static extern CXLanguageKind getCursorLanguage(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorLanguage", ExactSpelling = true)] + [return: NativeTypeName("enum CXLanguageKind")] + public static extern CXLanguageKind getCursorLanguage(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorTLSKind", ExactSpelling = true)] - [return: NativeTypeName("enum CXTLSKind")] - public static extern CXTLSKind getCursorTLSKind(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorTLSKind", ExactSpelling = true)] + [return: NativeTypeName("enum CXTLSKind")] + public static extern CXTLSKind getCursorTLSKind(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTranslationUnit", ExactSpelling = true)] - [return: NativeTypeName("CXTranslationUnit")] - public static extern CXTranslationUnitImpl* Cursor_getTranslationUnit(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTranslationUnit", ExactSpelling = true)] + [return: NativeTypeName("CXTranslationUnit")] + public static extern CXTranslationUnitImpl* Cursor_getTranslationUnit(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createCXCursorSet", ExactSpelling = true)] - [return: NativeTypeName("CXCursorSet")] - public static extern CXCursorSetImpl* createCXCursorSet(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_createCXCursorSet", ExactSpelling = true)] + [return: NativeTypeName("CXCursorSet")] + public static extern CXCursorSetImpl* createCXCursorSet(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeCXCursorSet", ExactSpelling = true)] - public static extern void disposeCXCursorSet([NativeTypeName("CXCursorSet")] CXCursorSetImpl* cset); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeCXCursorSet", ExactSpelling = true)] + public static extern void disposeCXCursorSet([NativeTypeName("CXCursorSet")] CXCursorSetImpl* cset); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXCursorSet_contains", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXCursorSet_contains([NativeTypeName("CXCursorSet")] CXCursorSetImpl* cset, CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXCursorSet_contains", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXCursorSet_contains([NativeTypeName("CXCursorSet")] CXCursorSetImpl* cset, CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXCursorSet_insert", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXCursorSet_insert([NativeTypeName("CXCursorSet")] CXCursorSetImpl* cset, CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXCursorSet_insert", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXCursorSet_insert([NativeTypeName("CXCursorSet")] CXCursorSetImpl* cset, CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorSemanticParent", ExactSpelling = true)] - public static extern CXCursor getCursorSemanticParent(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorSemanticParent", ExactSpelling = true)] + public static extern CXCursor getCursorSemanticParent(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorLexicalParent", ExactSpelling = true)] - public static extern CXCursor getCursorLexicalParent(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorLexicalParent", ExactSpelling = true)] + public static extern CXCursor getCursorLexicalParent(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getOverriddenCursors", ExactSpelling = true)] - public static extern void getOverriddenCursors(CXCursor cursor, CXCursor** overridden, [NativeTypeName("unsigned int *")] uint* num_overridden); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getOverriddenCursors", ExactSpelling = true)] + public static extern void getOverriddenCursors(CXCursor cursor, CXCursor** overridden, [NativeTypeName("unsigned int *")] uint* num_overridden); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeOverriddenCursors", ExactSpelling = true)] - public static extern void disposeOverriddenCursors(CXCursor* overridden); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeOverriddenCursors", ExactSpelling = true)] + public static extern void disposeOverriddenCursors(CXCursor* overridden); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getIncludedFile", ExactSpelling = true)] - [return: NativeTypeName("CXFile")] - public static extern void* getIncludedFile(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getIncludedFile", ExactSpelling = true)] + [return: NativeTypeName("CXFile")] + public static extern void* getIncludedFile(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursor", ExactSpelling = true)] - public static extern CXCursor getCursor([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, CXSourceLocation param1); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursor", ExactSpelling = true)] + public static extern CXCursor getCursor([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, CXSourceLocation param1); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorLocation", ExactSpelling = true)] - public static extern CXSourceLocation getCursorLocation(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorLocation", ExactSpelling = true)] + public static extern CXSourceLocation getCursorLocation(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorExtent", ExactSpelling = true)] - public static extern CXSourceRange getCursorExtent(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorExtent", ExactSpelling = true)] + public static extern CXSourceRange getCursorExtent(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorType", ExactSpelling = true)] - public static extern CXType getCursorType(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorType", ExactSpelling = true)] + public static extern CXType getCursorType(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypeSpelling", ExactSpelling = true)] - public static extern CXString getTypeSpelling(CXType CT); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypeSpelling", ExactSpelling = true)] + public static extern CXString getTypeSpelling(CXType CT); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypedefDeclUnderlyingType", ExactSpelling = true)] - public static extern CXType getTypedefDeclUnderlyingType(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypedefDeclUnderlyingType", ExactSpelling = true)] + public static extern CXType getTypedefDeclUnderlyingType(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getEnumDeclIntegerType", ExactSpelling = true)] - public static extern CXType getEnumDeclIntegerType(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getEnumDeclIntegerType", ExactSpelling = true)] + public static extern CXType getEnumDeclIntegerType(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getEnumConstantDeclValue", ExactSpelling = true)] - [return: NativeTypeName("long long")] - public static extern long getEnumConstantDeclValue(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getEnumConstantDeclValue", ExactSpelling = true)] + [return: NativeTypeName("long long")] + public static extern long getEnumConstantDeclValue(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getEnumConstantDeclUnsignedValue", ExactSpelling = true)] - [return: NativeTypeName("unsigned long long")] - public static extern ulong getEnumConstantDeclUnsignedValue(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getEnumConstantDeclUnsignedValue", ExactSpelling = true)] + [return: NativeTypeName("unsigned long long")] + public static extern ulong getEnumConstantDeclUnsignedValue(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFieldDeclBitWidth", ExactSpelling = true)] - public static extern int getFieldDeclBitWidth(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFieldDeclBitWidth", ExactSpelling = true)] + public static extern int getFieldDeclBitWidth(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getNumArguments", ExactSpelling = true)] - public static extern int Cursor_getNumArguments(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getNumArguments", ExactSpelling = true)] + public static extern int Cursor_getNumArguments(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getArgument", ExactSpelling = true)] - public static extern CXCursor Cursor_getArgument(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getArgument", ExactSpelling = true)] + public static extern CXCursor Cursor_getArgument(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getNumTemplateArguments", ExactSpelling = true)] - public static extern int Cursor_getNumTemplateArguments(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getNumTemplateArguments", ExactSpelling = true)] + public static extern int Cursor_getNumTemplateArguments(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTemplateArgumentKind", ExactSpelling = true)] - [return: NativeTypeName("enum CXTemplateArgumentKind")] - public static extern CXTemplateArgumentKind Cursor_getTemplateArgumentKind(CXCursor C, [NativeTypeName("unsigned int")] uint I); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTemplateArgumentKind", ExactSpelling = true)] + [return: NativeTypeName("enum CXTemplateArgumentKind")] + public static extern CXTemplateArgumentKind Cursor_getTemplateArgumentKind(CXCursor C, [NativeTypeName("unsigned int")] uint I); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTemplateArgumentType", ExactSpelling = true)] - public static extern CXType Cursor_getTemplateArgumentType(CXCursor C, [NativeTypeName("unsigned int")] uint I); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTemplateArgumentType", ExactSpelling = true)] + public static extern CXType Cursor_getTemplateArgumentType(CXCursor C, [NativeTypeName("unsigned int")] uint I); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTemplateArgumentValue", ExactSpelling = true)] - [return: NativeTypeName("long long")] - public static extern long Cursor_getTemplateArgumentValue(CXCursor C, [NativeTypeName("unsigned int")] uint I); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTemplateArgumentValue", ExactSpelling = true)] + [return: NativeTypeName("long long")] + public static extern long Cursor_getTemplateArgumentValue(CXCursor C, [NativeTypeName("unsigned int")] uint I); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTemplateArgumentUnsignedValue", ExactSpelling = true)] - [return: NativeTypeName("unsigned long long")] - public static extern ulong Cursor_getTemplateArgumentUnsignedValue(CXCursor C, [NativeTypeName("unsigned int")] uint I); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getTemplateArgumentUnsignedValue", ExactSpelling = true)] + [return: NativeTypeName("unsigned long long")] + public static extern ulong Cursor_getTemplateArgumentUnsignedValue(CXCursor C, [NativeTypeName("unsigned int")] uint I); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_equalTypes", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint equalTypes(CXType A, CXType B); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_equalTypes", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint equalTypes(CXType A, CXType B); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCanonicalType", ExactSpelling = true)] - public static extern CXType getCanonicalType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCanonicalType", ExactSpelling = true)] + public static extern CXType getCanonicalType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isConstQualifiedType", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isConstQualifiedType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isConstQualifiedType", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isConstQualifiedType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isMacroFunctionLike", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isMacroFunctionLike(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isMacroFunctionLike", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isMacroFunctionLike(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isMacroBuiltin", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isMacroBuiltin(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isMacroBuiltin", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isMacroBuiltin(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isFunctionInlined", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isFunctionInlined(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isFunctionInlined", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isFunctionInlined(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isVolatileQualifiedType", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isVolatileQualifiedType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isVolatileQualifiedType", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isVolatileQualifiedType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isRestrictQualifiedType", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isRestrictQualifiedType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isRestrictQualifiedType", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isRestrictQualifiedType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getAddressSpace", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getAddressSpace(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getAddressSpace", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getAddressSpace(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypedefName", ExactSpelling = true)] - public static extern CXString getTypedefName(CXType CT); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypedefName", ExactSpelling = true)] + public static extern CXString getTypedefName(CXType CT); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getPointeeType", ExactSpelling = true)] - public static extern CXType getPointeeType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getPointeeType", ExactSpelling = true)] + public static extern CXType getPointeeType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypeDeclaration", ExactSpelling = true)] - public static extern CXCursor getTypeDeclaration(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypeDeclaration", ExactSpelling = true)] + public static extern CXCursor getTypeDeclaration(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDeclObjCTypeEncoding", ExactSpelling = true)] - public static extern CXString getDeclObjCTypeEncoding(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDeclObjCTypeEncoding", ExactSpelling = true)] + public static extern CXString getDeclObjCTypeEncoding(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getObjCEncoding", ExactSpelling = true)] - public static extern CXString Type_getObjCEncoding(CXType type); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getObjCEncoding", ExactSpelling = true)] + public static extern CXString Type_getObjCEncoding(CXType type); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypeKindSpelling", ExactSpelling = true)] - public static extern CXString getTypeKindSpelling([NativeTypeName("enum CXTypeKind")] CXTypeKind K); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTypeKindSpelling", ExactSpelling = true)] + public static extern CXString getTypeKindSpelling([NativeTypeName("enum CXTypeKind")] CXTypeKind K); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFunctionTypeCallingConv", ExactSpelling = true)] - [return: NativeTypeName("enum CXCallingConv")] - public static extern CXCallingConv getFunctionTypeCallingConv(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getFunctionTypeCallingConv", ExactSpelling = true)] + [return: NativeTypeName("enum CXCallingConv")] + public static extern CXCallingConv getFunctionTypeCallingConv(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getResultType", ExactSpelling = true)] - public static extern CXType getResultType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getResultType", ExactSpelling = true)] + public static extern CXType getResultType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getExceptionSpecificationType", ExactSpelling = true)] - public static extern int getExceptionSpecificationType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getExceptionSpecificationType", ExactSpelling = true)] + public static extern int getExceptionSpecificationType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumArgTypes", ExactSpelling = true)] - public static extern int getNumArgTypes(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumArgTypes", ExactSpelling = true)] + public static extern int getNumArgTypes(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getArgType", ExactSpelling = true)] - public static extern CXType getArgType(CXType T, [NativeTypeName("unsigned int")] uint i); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getArgType", ExactSpelling = true)] + public static extern CXType getArgType(CXType T, [NativeTypeName("unsigned int")] uint i); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getObjCObjectBaseType", ExactSpelling = true)] - public static extern CXType Type_getObjCObjectBaseType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getObjCObjectBaseType", ExactSpelling = true)] + public static extern CXType Type_getObjCObjectBaseType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNumObjCProtocolRefs", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Type_getNumObjCProtocolRefs(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNumObjCProtocolRefs", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Type_getNumObjCProtocolRefs(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getObjCProtocolDecl", ExactSpelling = true)] - public static extern CXCursor Type_getObjCProtocolDecl(CXType T, [NativeTypeName("unsigned int")] uint i); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getObjCProtocolDecl", ExactSpelling = true)] + public static extern CXCursor Type_getObjCProtocolDecl(CXType T, [NativeTypeName("unsigned int")] uint i); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNumObjCTypeArgs", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Type_getNumObjCTypeArgs(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNumObjCTypeArgs", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Type_getNumObjCTypeArgs(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getObjCTypeArg", ExactSpelling = true)] - public static extern CXType Type_getObjCTypeArg(CXType T, [NativeTypeName("unsigned int")] uint i); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getObjCTypeArg", ExactSpelling = true)] + public static extern CXType Type_getObjCTypeArg(CXType T, [NativeTypeName("unsigned int")] uint i); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isFunctionTypeVariadic", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isFunctionTypeVariadic(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isFunctionTypeVariadic", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isFunctionTypeVariadic(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorResultType", ExactSpelling = true)] - public static extern CXType getCursorResultType(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorResultType", ExactSpelling = true)] + public static extern CXType getCursorResultType(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorExceptionSpecificationType", ExactSpelling = true)] - public static extern int getCursorExceptionSpecificationType(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorExceptionSpecificationType", ExactSpelling = true)] + public static extern int getCursorExceptionSpecificationType(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isPODType", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isPODType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isPODType", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isPODType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getElementType", ExactSpelling = true)] - public static extern CXType getElementType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getElementType", ExactSpelling = true)] + public static extern CXType getElementType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumElements", ExactSpelling = true)] - [return: NativeTypeName("long long")] - public static extern long getNumElements(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumElements", ExactSpelling = true)] + [return: NativeTypeName("long long")] + public static extern long getNumElements(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getArrayElementType", ExactSpelling = true)] - public static extern CXType getArrayElementType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getArrayElementType", ExactSpelling = true)] + public static extern CXType getArrayElementType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getArraySize", ExactSpelling = true)] - [return: NativeTypeName("long long")] - public static extern long getArraySize(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getArraySize", ExactSpelling = true)] + [return: NativeTypeName("long long")] + public static extern long getArraySize(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNamedType", ExactSpelling = true)] - public static extern CXType Type_getNamedType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNamedType", ExactSpelling = true)] + public static extern CXType Type_getNamedType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_isTransparentTagTypedef", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Type_isTransparentTagTypedef(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_isTransparentTagTypedef", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Type_isTransparentTagTypedef(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNullability", ExactSpelling = true)] - [return: NativeTypeName("enum CXTypeNullabilityKind")] - public static extern CXTypeNullabilityKind Type_getNullability(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNullability", ExactSpelling = true)] + [return: NativeTypeName("enum CXTypeNullabilityKind")] + public static extern CXTypeNullabilityKind Type_getNullability(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getAlignOf", ExactSpelling = true)] - [return: NativeTypeName("long long")] - public static extern long Type_getAlignOf(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getAlignOf", ExactSpelling = true)] + [return: NativeTypeName("long long")] + public static extern long Type_getAlignOf(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getClassType", ExactSpelling = true)] - public static extern CXType Type_getClassType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getClassType", ExactSpelling = true)] + public static extern CXType Type_getClassType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getSizeOf", ExactSpelling = true)] - [return: NativeTypeName("long long")] - public static extern long Type_getSizeOf(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getSizeOf", ExactSpelling = true)] + [return: NativeTypeName("long long")] + public static extern long Type_getSizeOf(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getOffsetOf", ExactSpelling = true)] - [return: NativeTypeName("long long")] - public static extern long Type_getOffsetOf(CXType T, [NativeTypeName("const char *")] sbyte* S); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getOffsetOf", ExactSpelling = true)] + [return: NativeTypeName("long long")] + public static extern long Type_getOffsetOf(CXType T, [NativeTypeName("const char *")] sbyte* S); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getModifiedType", ExactSpelling = true)] - public static extern CXType Type_getModifiedType(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getModifiedType", ExactSpelling = true)] + public static extern CXType Type_getModifiedType(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getValueType", ExactSpelling = true)] - public static extern CXType Type_getValueType(CXType CT); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getValueType", ExactSpelling = true)] + public static extern CXType Type_getValueType(CXType CT); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getOffsetOfField", ExactSpelling = true)] - [return: NativeTypeName("long long")] - public static extern long Cursor_getOffsetOfField(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getOffsetOfField", ExactSpelling = true)] + [return: NativeTypeName("long long")] + public static extern long Cursor_getOffsetOfField(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isAnonymous", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isAnonymous(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isAnonymous", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isAnonymous(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isAnonymousRecordDecl", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isAnonymousRecordDecl(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isAnonymousRecordDecl", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isAnonymousRecordDecl(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isInlineNamespace", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isInlineNamespace(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isInlineNamespace", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isInlineNamespace(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNumTemplateArguments", ExactSpelling = true)] - public static extern int Type_getNumTemplateArguments(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getNumTemplateArguments", ExactSpelling = true)] + public static extern int Type_getNumTemplateArguments(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getTemplateArgumentAsType", ExactSpelling = true)] - public static extern CXType Type_getTemplateArgumentAsType(CXType T, [NativeTypeName("unsigned int")] uint i); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getTemplateArgumentAsType", ExactSpelling = true)] + public static extern CXType Type_getTemplateArgumentAsType(CXType T, [NativeTypeName("unsigned int")] uint i); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getCXXRefQualifier", ExactSpelling = true)] - [return: NativeTypeName("enum CXRefQualifierKind")] - public static extern CXRefQualifierKind Type_getCXXRefQualifier(CXType T); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_getCXXRefQualifier", ExactSpelling = true)] + [return: NativeTypeName("enum CXRefQualifierKind")] + public static extern CXRefQualifierKind Type_getCXXRefQualifier(CXType T); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isBitField", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isBitField(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isBitField", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isBitField(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isVirtualBase", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isVirtualBase(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isVirtualBase", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isVirtualBase(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCXXAccessSpecifier", ExactSpelling = true)] - [return: NativeTypeName("enum CX_CXXAccessSpecifier")] - public static extern CX_CXXAccessSpecifier getCXXAccessSpecifier(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCXXAccessSpecifier", ExactSpelling = true)] + [return: NativeTypeName("enum CX_CXXAccessSpecifier")] + public static extern CX_CXXAccessSpecifier getCXXAccessSpecifier(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getStorageClass", ExactSpelling = true)] - [return: NativeTypeName("enum CX_StorageClass")] - public static extern CX_StorageClass Cursor_getStorageClass(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getStorageClass", ExactSpelling = true)] + [return: NativeTypeName("enum CX_StorageClass")] + public static extern CX_StorageClass Cursor_getStorageClass(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumOverloadedDecls", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getNumOverloadedDecls(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumOverloadedDecls", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getNumOverloadedDecls(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getOverloadedDecl", ExactSpelling = true)] - public static extern CXCursor getOverloadedDecl(CXCursor cursor, [NativeTypeName("unsigned int")] uint index); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getOverloadedDecl", ExactSpelling = true)] + public static extern CXCursor getOverloadedDecl(CXCursor cursor, [NativeTypeName("unsigned int")] uint index); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getIBOutletCollectionType", ExactSpelling = true)] - public static extern CXType getIBOutletCollectionType(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getIBOutletCollectionType", ExactSpelling = true)] + public static extern CXType getIBOutletCollectionType(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_visitChildren", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint visitChildren(CXCursor parent, [NativeTypeName("CXCursorVisitor")] IntPtr visitor, [NativeTypeName("CXClientData")] void* client_data); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_visitChildren", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint visitChildren(CXCursor parent, [NativeTypeName("CXCursorVisitor")] IntPtr visitor, [NativeTypeName("CXClientData")] void* client_data); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorUSR", ExactSpelling = true)] - public static extern CXString getCursorUSR(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorUSR", ExactSpelling = true)] + public static extern CXString getCursorUSR(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCClass", ExactSpelling = true)] - public static extern CXString constructUSR_ObjCClass([NativeTypeName("const char *")] sbyte* class_name); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCClass", ExactSpelling = true)] + public static extern CXString constructUSR_ObjCClass([NativeTypeName("const char *")] sbyte* class_name); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCCategory", ExactSpelling = true)] - public static extern CXString constructUSR_ObjCCategory([NativeTypeName("const char *")] sbyte* class_name, [NativeTypeName("const char *")] sbyte* category_name); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCCategory", ExactSpelling = true)] + public static extern CXString constructUSR_ObjCCategory([NativeTypeName("const char *")] sbyte* class_name, [NativeTypeName("const char *")] sbyte* category_name); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCProtocol", ExactSpelling = true)] - public static extern CXString constructUSR_ObjCProtocol([NativeTypeName("const char *")] sbyte* protocol_name); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCProtocol", ExactSpelling = true)] + public static extern CXString constructUSR_ObjCProtocol([NativeTypeName("const char *")] sbyte* protocol_name); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCIvar", ExactSpelling = true)] - public static extern CXString constructUSR_ObjCIvar([NativeTypeName("const char *")] sbyte* name, CXString classUSR); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCIvar", ExactSpelling = true)] + public static extern CXString constructUSR_ObjCIvar([NativeTypeName("const char *")] sbyte* name, CXString classUSR); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCMethod", ExactSpelling = true)] - public static extern CXString constructUSR_ObjCMethod([NativeTypeName("const char *")] sbyte* name, [NativeTypeName("unsigned int")] uint isInstanceMethod, CXString classUSR); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCMethod", ExactSpelling = true)] + public static extern CXString constructUSR_ObjCMethod([NativeTypeName("const char *")] sbyte* name, [NativeTypeName("unsigned int")] uint isInstanceMethod, CXString classUSR); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCProperty", ExactSpelling = true)] - public static extern CXString constructUSR_ObjCProperty([NativeTypeName("const char *")] sbyte* property, CXString classUSR); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_constructUSR_ObjCProperty", ExactSpelling = true)] + public static extern CXString constructUSR_ObjCProperty([NativeTypeName("const char *")] sbyte* property, CXString classUSR); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorSpelling", ExactSpelling = true)] - public static extern CXString getCursorSpelling(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorSpelling", ExactSpelling = true)] + public static extern CXString getCursorSpelling(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getSpellingNameRange", ExactSpelling = true)] - public static extern CXSourceRange Cursor_getSpellingNameRange(CXCursor param0, [NativeTypeName("unsigned int")] uint pieceIndex, [NativeTypeName("unsigned int")] uint options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getSpellingNameRange", ExactSpelling = true)] + public static extern CXSourceRange Cursor_getSpellingNameRange(CXCursor param0, [NativeTypeName("unsigned int")] uint pieceIndex, [NativeTypeName("unsigned int")] uint options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_PrintingPolicy_getProperty", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint PrintingPolicy_getProperty([NativeTypeName("CXPrintingPolicy")] void* Policy, [NativeTypeName("enum CXPrintingPolicyProperty")] CXPrintingPolicyProperty Property); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_PrintingPolicy_getProperty", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint PrintingPolicy_getProperty([NativeTypeName("CXPrintingPolicy")] void* Policy, [NativeTypeName("enum CXPrintingPolicyProperty")] CXPrintingPolicyProperty Property); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_PrintingPolicy_setProperty", ExactSpelling = true)] - public static extern void PrintingPolicy_setProperty([NativeTypeName("CXPrintingPolicy")] void* Policy, [NativeTypeName("enum CXPrintingPolicyProperty")] CXPrintingPolicyProperty Property, [NativeTypeName("unsigned int")] uint Value); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_PrintingPolicy_setProperty", ExactSpelling = true)] + public static extern void PrintingPolicy_setProperty([NativeTypeName("CXPrintingPolicy")] void* Policy, [NativeTypeName("enum CXPrintingPolicyProperty")] CXPrintingPolicyProperty Property, [NativeTypeName("unsigned int")] uint Value); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorPrintingPolicy", ExactSpelling = true)] - [return: NativeTypeName("CXPrintingPolicy")] - public static extern void* getCursorPrintingPolicy(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorPrintingPolicy", ExactSpelling = true)] + [return: NativeTypeName("CXPrintingPolicy")] + public static extern void* getCursorPrintingPolicy(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_PrintingPolicy_dispose", ExactSpelling = true)] - public static extern void PrintingPolicy_dispose([NativeTypeName("CXPrintingPolicy")] void* Policy); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_PrintingPolicy_dispose", ExactSpelling = true)] + public static extern void PrintingPolicy_dispose([NativeTypeName("CXPrintingPolicy")] void* Policy); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorPrettyPrinted", ExactSpelling = true)] - public static extern CXString getCursorPrettyPrinted(CXCursor Cursor, [NativeTypeName("CXPrintingPolicy")] void* Policy); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorPrettyPrinted", ExactSpelling = true)] + public static extern CXString getCursorPrettyPrinted(CXCursor Cursor, [NativeTypeName("CXPrintingPolicy")] void* Policy); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorDisplayName", ExactSpelling = true)] - public static extern CXString getCursorDisplayName(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorDisplayName", ExactSpelling = true)] + public static extern CXString getCursorDisplayName(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorReferenced", ExactSpelling = true)] - public static extern CXCursor getCursorReferenced(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorReferenced", ExactSpelling = true)] + public static extern CXCursor getCursorReferenced(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorDefinition", ExactSpelling = true)] - public static extern CXCursor getCursorDefinition(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorDefinition", ExactSpelling = true)] + public static extern CXCursor getCursorDefinition(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isCursorDefinition", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint isCursorDefinition(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_isCursorDefinition", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint isCursorDefinition(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCanonicalCursor", ExactSpelling = true)] - public static extern CXCursor getCanonicalCursor(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCanonicalCursor", ExactSpelling = true)] + public static extern CXCursor getCanonicalCursor(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCSelectorIndex", ExactSpelling = true)] - public static extern int Cursor_getObjCSelectorIndex(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCSelectorIndex", ExactSpelling = true)] + public static extern int Cursor_getObjCSelectorIndex(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isDynamicCall", ExactSpelling = true)] - public static extern int Cursor_isDynamicCall(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isDynamicCall", ExactSpelling = true)] + public static extern int Cursor_isDynamicCall(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getReceiverType", ExactSpelling = true)] - public static extern CXType Cursor_getReceiverType(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getReceiverType", ExactSpelling = true)] + public static extern CXType Cursor_getReceiverType(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCPropertyAttributes", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getObjCPropertyAttributes(CXCursor C, [NativeTypeName("unsigned int")] uint reserved); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCPropertyAttributes", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getObjCPropertyAttributes(CXCursor C, [NativeTypeName("unsigned int")] uint reserved); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCPropertyGetterName", ExactSpelling = true)] - public static extern CXString Cursor_getObjCPropertyGetterName(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCPropertyGetterName", ExactSpelling = true)] + public static extern CXString Cursor_getObjCPropertyGetterName(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCPropertySetterName", ExactSpelling = true)] - public static extern CXString Cursor_getObjCPropertySetterName(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCPropertySetterName", ExactSpelling = true)] + public static extern CXString Cursor_getObjCPropertySetterName(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCDeclQualifiers", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getObjCDeclQualifiers(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCDeclQualifiers", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getObjCDeclQualifiers(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isObjCOptional", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isObjCOptional(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isObjCOptional", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isObjCOptional(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isVariadic", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isVariadic(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isVariadic", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isVariadic(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isExternalSymbol", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_isExternalSymbol(CXCursor C, CXString* language, CXString* definedIn, [NativeTypeName("unsigned int *")] uint* isGenerated); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_isExternalSymbol", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_isExternalSymbol(CXCursor C, CXString* language, CXString* definedIn, [NativeTypeName("unsigned int *")] uint* isGenerated); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getCommentRange", ExactSpelling = true)] - public static extern CXSourceRange Cursor_getCommentRange(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getCommentRange", ExactSpelling = true)] + public static extern CXSourceRange Cursor_getCommentRange(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getRawCommentText", ExactSpelling = true)] - public static extern CXString Cursor_getRawCommentText(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getRawCommentText", ExactSpelling = true)] + public static extern CXString Cursor_getRawCommentText(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getBriefCommentText", ExactSpelling = true)] - public static extern CXString Cursor_getBriefCommentText(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getBriefCommentText", ExactSpelling = true)] + public static extern CXString Cursor_getBriefCommentText(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getMangling", ExactSpelling = true)] - public static extern CXString Cursor_getMangling(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getMangling", ExactSpelling = true)] + public static extern CXString Cursor_getMangling(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getCXXManglings", ExactSpelling = true)] - public static extern CXStringSet* Cursor_getCXXManglings(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getCXXManglings", ExactSpelling = true)] + public static extern CXStringSet* Cursor_getCXXManglings(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCManglings", ExactSpelling = true)] - public static extern CXStringSet* Cursor_getObjCManglings(CXCursor param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getObjCManglings", ExactSpelling = true)] + public static extern CXStringSet* Cursor_getObjCManglings(CXCursor param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getModule", ExactSpelling = true)] - [return: NativeTypeName("CXModule")] - public static extern void* Cursor_getModule(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_getModule", ExactSpelling = true)] + [return: NativeTypeName("CXModule")] + public static extern void* Cursor_getModule(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getModuleForFile", ExactSpelling = true)] - [return: NativeTypeName("CXModule")] - public static extern void* getModuleForFile([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, [NativeTypeName("CXFile")] void* param1); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getModuleForFile", ExactSpelling = true)] + [return: NativeTypeName("CXModule")] + public static extern void* getModuleForFile([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, [NativeTypeName("CXFile")] void* param1); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getASTFile", ExactSpelling = true)] - [return: NativeTypeName("CXFile")] - public static extern void* Module_getASTFile([NativeTypeName("CXModule")] void* Module); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getASTFile", ExactSpelling = true)] + [return: NativeTypeName("CXFile")] + public static extern void* Module_getASTFile([NativeTypeName("CXModule")] void* Module); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getParent", ExactSpelling = true)] - [return: NativeTypeName("CXModule")] - public static extern void* Module_getParent([NativeTypeName("CXModule")] void* Module); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getParent", ExactSpelling = true)] + [return: NativeTypeName("CXModule")] + public static extern void* Module_getParent([NativeTypeName("CXModule")] void* Module); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getName", ExactSpelling = true)] - public static extern CXString Module_getName([NativeTypeName("CXModule")] void* Module); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getName", ExactSpelling = true)] + public static extern CXString Module_getName([NativeTypeName("CXModule")] void* Module); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getFullName", ExactSpelling = true)] - public static extern CXString Module_getFullName([NativeTypeName("CXModule")] void* Module); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getFullName", ExactSpelling = true)] + public static extern CXString Module_getFullName([NativeTypeName("CXModule")] void* Module); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_isSystem", ExactSpelling = true)] - public static extern int Module_isSystem([NativeTypeName("CXModule")] void* Module); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_isSystem", ExactSpelling = true)] + public static extern int Module_isSystem([NativeTypeName("CXModule")] void* Module); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getNumTopLevelHeaders", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Module_getNumTopLevelHeaders([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, [NativeTypeName("CXModule")] void* Module); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getNumTopLevelHeaders", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Module_getNumTopLevelHeaders([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, [NativeTypeName("CXModule")] void* Module); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getTopLevelHeader", ExactSpelling = true)] - [return: NativeTypeName("CXFile")] - public static extern void* Module_getTopLevelHeader([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, [NativeTypeName("CXModule")] void* Module, [NativeTypeName("unsigned int")] uint Index); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Module_getTopLevelHeader", ExactSpelling = true)] + [return: NativeTypeName("CXFile")] + public static extern void* Module_getTopLevelHeader([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, [NativeTypeName("CXModule")] void* Module, [NativeTypeName("unsigned int")] uint Index); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXConstructor_isConvertingConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXConstructor_isConvertingConstructor(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXConstructor_isConvertingConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXConstructor_isConvertingConstructor(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXConstructor_isCopyConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXConstructor_isCopyConstructor(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXConstructor_isCopyConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXConstructor_isCopyConstructor(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXConstructor_isDefaultConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXConstructor_isDefaultConstructor(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXConstructor_isDefaultConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXConstructor_isDefaultConstructor(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXConstructor_isMoveConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXConstructor_isMoveConstructor(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXConstructor_isMoveConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXConstructor_isMoveConstructor(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXField_isMutable", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXField_isMutable(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXField_isMutable", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXField_isMutable(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isDefaulted", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXMethod_isDefaulted(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isDefaulted", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXMethod_isDefaulted(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isPureVirtual", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXMethod_isPureVirtual(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isPureVirtual", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXMethod_isPureVirtual(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isStatic", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXMethod_isStatic(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isStatic", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXMethod_isStatic(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isVirtual", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXMethod_isVirtual(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isVirtual", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXMethod_isVirtual(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXRecord_isAbstract", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXRecord_isAbstract(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXRecord_isAbstract", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXRecord_isAbstract(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EnumDecl_isScoped", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint EnumDecl_isScoped(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EnumDecl_isScoped", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint EnumDecl_isScoped(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isConst", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint CXXMethod_isConst(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXXMethod_isConst", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint CXXMethod_isConst(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTemplateCursorKind", ExactSpelling = true)] - [return: NativeTypeName("enum CXCursorKind")] - public static extern CXCursorKind getTemplateCursorKind(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTemplateCursorKind", ExactSpelling = true)] + [return: NativeTypeName("enum CXCursorKind")] + public static extern CXCursorKind getTemplateCursorKind(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getSpecializedCursorTemplate", ExactSpelling = true)] - public static extern CXCursor getSpecializedCursorTemplate(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getSpecializedCursorTemplate", ExactSpelling = true)] + public static extern CXCursor getSpecializedCursorTemplate(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorReferenceNameRange", ExactSpelling = true)] - public static extern CXSourceRange getCursorReferenceNameRange(CXCursor C, [NativeTypeName("unsigned int")] uint NameFlags, [NativeTypeName("unsigned int")] uint PieceIndex); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorReferenceNameRange", ExactSpelling = true)] + public static extern CXSourceRange getCursorReferenceNameRange(CXCursor C, [NativeTypeName("unsigned int")] uint NameFlags, [NativeTypeName("unsigned int")] uint PieceIndex); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getToken", ExactSpelling = true)] - public static extern CXToken* getToken([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, CXSourceLocation Location); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getToken", ExactSpelling = true)] + public static extern CXToken* getToken([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, CXSourceLocation Location); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTokenKind", ExactSpelling = true)] - public static extern CXTokenKind getTokenKind(CXToken param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTokenKind", ExactSpelling = true)] + public static extern CXTokenKind getTokenKind(CXToken param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTokenSpelling", ExactSpelling = true)] - public static extern CXString getTokenSpelling([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, CXToken param1); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTokenSpelling", ExactSpelling = true)] + public static extern CXString getTokenSpelling([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, CXToken param1); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTokenLocation", ExactSpelling = true)] - public static extern CXSourceLocation getTokenLocation([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, CXToken param1); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTokenLocation", ExactSpelling = true)] + public static extern CXSourceLocation getTokenLocation([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, CXToken param1); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTokenExtent", ExactSpelling = true)] - public static extern CXSourceRange getTokenExtent([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, CXToken param1); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getTokenExtent", ExactSpelling = true)] + public static extern CXSourceRange getTokenExtent([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param0, CXToken param1); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_tokenize", ExactSpelling = true)] - public static extern void tokenize([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, CXSourceRange Range, CXToken** Tokens, [NativeTypeName("unsigned int *")] uint* NumTokens); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_tokenize", ExactSpelling = true)] + public static extern void tokenize([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, CXSourceRange Range, CXToken** Tokens, [NativeTypeName("unsigned int *")] uint* NumTokens); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_annotateTokens", ExactSpelling = true)] - public static extern void annotateTokens([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, CXToken* Tokens, [NativeTypeName("unsigned int")] uint NumTokens, CXCursor* Cursors); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_annotateTokens", ExactSpelling = true)] + public static extern void annotateTokens([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, CXToken* Tokens, [NativeTypeName("unsigned int")] uint NumTokens, CXCursor* Cursors); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeTokens", ExactSpelling = true)] - public static extern void disposeTokens([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, CXToken* Tokens, [NativeTypeName("unsigned int")] uint NumTokens); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeTokens", ExactSpelling = true)] + public static extern void disposeTokens([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, CXToken* Tokens, [NativeTypeName("unsigned int")] uint NumTokens); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorKindSpelling", ExactSpelling = true)] - public static extern CXString getCursorKindSpelling([NativeTypeName("enum CXCursorKind")] CXCursorKind Kind); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorKindSpelling", ExactSpelling = true)] + public static extern CXString getCursorKindSpelling([NativeTypeName("enum CXCursorKind")] CXCursorKind Kind); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDefinitionSpellingAndExtent", ExactSpelling = true)] - public static extern void getDefinitionSpellingAndExtent(CXCursor param0, [NativeTypeName("const char **")] sbyte** startBuf, [NativeTypeName("const char **")] sbyte** endBuf, [NativeTypeName("unsigned int *")] uint* startLine, [NativeTypeName("unsigned int *")] uint* startColumn, [NativeTypeName("unsigned int *")] uint* endLine, [NativeTypeName("unsigned int *")] uint* endColumn); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDefinitionSpellingAndExtent", ExactSpelling = true)] + public static extern void getDefinitionSpellingAndExtent(CXCursor param0, [NativeTypeName("const char **")] sbyte** startBuf, [NativeTypeName("const char **")] sbyte** endBuf, [NativeTypeName("unsigned int *")] uint* startLine, [NativeTypeName("unsigned int *")] uint* startColumn, [NativeTypeName("unsigned int *")] uint* endLine, [NativeTypeName("unsigned int *")] uint* endColumn); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_enableStackTraces", ExactSpelling = true)] - public static extern void enableStackTraces(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_enableStackTraces", ExactSpelling = true)] + public static extern void enableStackTraces(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_executeOnThread", ExactSpelling = true)] - public static extern void executeOnThread([NativeTypeName("void (*)(void *)")] IntPtr fn, void* user_data, [NativeTypeName("unsigned int")] uint stack_size); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_executeOnThread", ExactSpelling = true)] + public static extern void executeOnThread([NativeTypeName("void (*)(void *)")] IntPtr fn, void* user_data, [NativeTypeName("unsigned int")] uint stack_size); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionChunkKind", ExactSpelling = true)] - [return: NativeTypeName("enum CXCompletionChunkKind")] - public static extern CXCompletionChunkKind getCompletionChunkKind([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("unsigned int")] uint chunk_number); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionChunkKind", ExactSpelling = true)] + [return: NativeTypeName("enum CXCompletionChunkKind")] + public static extern CXCompletionChunkKind getCompletionChunkKind([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("unsigned int")] uint chunk_number); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionChunkText", ExactSpelling = true)] - public static extern CXString getCompletionChunkText([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("unsigned int")] uint chunk_number); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionChunkText", ExactSpelling = true)] + public static extern CXString getCompletionChunkText([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("unsigned int")] uint chunk_number); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionChunkCompletionString", ExactSpelling = true)] - [return: NativeTypeName("CXCompletionString")] - public static extern void* getCompletionChunkCompletionString([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("unsigned int")] uint chunk_number); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionChunkCompletionString", ExactSpelling = true)] + [return: NativeTypeName("CXCompletionString")] + public static extern void* getCompletionChunkCompletionString([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("unsigned int")] uint chunk_number); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumCompletionChunks", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getNumCompletionChunks([NativeTypeName("CXCompletionString")] void* completion_string); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getNumCompletionChunks", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getNumCompletionChunks([NativeTypeName("CXCompletionString")] void* completion_string); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionPriority", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getCompletionPriority([NativeTypeName("CXCompletionString")] void* completion_string); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionPriority", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getCompletionPriority([NativeTypeName("CXCompletionString")] void* completion_string); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionAvailability", ExactSpelling = true)] - [return: NativeTypeName("enum CXAvailabilityKind")] - public static extern CXAvailabilityKind getCompletionAvailability([NativeTypeName("CXCompletionString")] void* completion_string); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionAvailability", ExactSpelling = true)] + [return: NativeTypeName("enum CXAvailabilityKind")] + public static extern CXAvailabilityKind getCompletionAvailability([NativeTypeName("CXCompletionString")] void* completion_string); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionNumAnnotations", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getCompletionNumAnnotations([NativeTypeName("CXCompletionString")] void* completion_string); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionNumAnnotations", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getCompletionNumAnnotations([NativeTypeName("CXCompletionString")] void* completion_string); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionAnnotation", ExactSpelling = true)] - public static extern CXString getCompletionAnnotation([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("unsigned int")] uint annotation_number); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionAnnotation", ExactSpelling = true)] + public static extern CXString getCompletionAnnotation([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("unsigned int")] uint annotation_number); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionParent", ExactSpelling = true)] - public static extern CXString getCompletionParent([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("enum CXCursorKind *")] CXCursorKind* kind); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionParent", ExactSpelling = true)] + public static extern CXString getCompletionParent([NativeTypeName("CXCompletionString")] void* completion_string, [NativeTypeName("enum CXCursorKind *")] CXCursorKind* kind); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionBriefComment", ExactSpelling = true)] - public static extern CXString getCompletionBriefComment([NativeTypeName("CXCompletionString")] void* completion_string); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionBriefComment", ExactSpelling = true)] + public static extern CXString getCompletionBriefComment([NativeTypeName("CXCompletionString")] void* completion_string); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorCompletionString", ExactSpelling = true)] - [return: NativeTypeName("CXCompletionString")] - public static extern void* getCursorCompletionString(CXCursor cursor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCursorCompletionString", ExactSpelling = true)] + [return: NativeTypeName("CXCompletionString")] + public static extern void* getCursorCompletionString(CXCursor cursor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionNumFixIts", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint getCompletionNumFixIts(CXCodeCompleteResults* results, [NativeTypeName("unsigned int")] uint completion_index); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionNumFixIts", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint getCompletionNumFixIts(CXCodeCompleteResults* results, [NativeTypeName("unsigned int")] uint completion_index); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionFixIt", ExactSpelling = true)] - public static extern CXString getCompletionFixIt(CXCodeCompleteResults* results, [NativeTypeName("unsigned int")] uint completion_index, [NativeTypeName("unsigned int")] uint fixit_index, CXSourceRange* replacement_range); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getCompletionFixIt", ExactSpelling = true)] + public static extern CXString getCompletionFixIt(CXCodeCompleteResults* results, [NativeTypeName("unsigned int")] uint completion_index, [NativeTypeName("unsigned int")] uint fixit_index, CXSourceRange* replacement_range); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultCodeCompleteOptions", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint defaultCodeCompleteOptions(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_defaultCodeCompleteOptions", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint defaultCodeCompleteOptions(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteAt", ExactSpelling = true)] - public static extern CXCodeCompleteResults* codeCompleteAt([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, [NativeTypeName("const char *")] sbyte* complete_filename, [NativeTypeName("unsigned int")] uint complete_line, [NativeTypeName("unsigned int")] uint complete_column, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("unsigned int")] uint options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteAt", ExactSpelling = true)] + public static extern CXCodeCompleteResults* codeCompleteAt([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, [NativeTypeName("const char *")] sbyte* complete_filename, [NativeTypeName("unsigned int")] uint complete_line, [NativeTypeName("unsigned int")] uint complete_column, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("unsigned int")] uint options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_sortCodeCompletionResults", ExactSpelling = true)] - public static extern void sortCodeCompletionResults(CXCompletionResult* Results, [NativeTypeName("unsigned int")] uint NumResults); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_sortCodeCompletionResults", ExactSpelling = true)] + public static extern void sortCodeCompletionResults(CXCompletionResult* Results, [NativeTypeName("unsigned int")] uint NumResults); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeCodeCompleteResults", ExactSpelling = true)] - public static extern void disposeCodeCompleteResults(CXCodeCompleteResults* Results); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_disposeCodeCompleteResults", ExactSpelling = true)] + public static extern void disposeCodeCompleteResults(CXCodeCompleteResults* Results); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetNumDiagnostics", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint codeCompleteGetNumDiagnostics(CXCodeCompleteResults* Results); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetNumDiagnostics", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint codeCompleteGetNumDiagnostics(CXCodeCompleteResults* Results); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetDiagnostic", ExactSpelling = true)] - [return: NativeTypeName("CXDiagnostic")] - public static extern void* codeCompleteGetDiagnostic(CXCodeCompleteResults* Results, [NativeTypeName("unsigned int")] uint Index); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetDiagnostic", ExactSpelling = true)] + [return: NativeTypeName("CXDiagnostic")] + public static extern void* codeCompleteGetDiagnostic(CXCodeCompleteResults* Results, [NativeTypeName("unsigned int")] uint Index); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetContexts", ExactSpelling = true)] - [return: NativeTypeName("unsigned long long")] - public static extern ulong codeCompleteGetContexts(CXCodeCompleteResults* Results); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetContexts", ExactSpelling = true)] + [return: NativeTypeName("unsigned long long")] + public static extern ulong codeCompleteGetContexts(CXCodeCompleteResults* Results); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetContainerKind", ExactSpelling = true)] - [return: NativeTypeName("enum CXCursorKind")] - public static extern CXCursorKind codeCompleteGetContainerKind(CXCodeCompleteResults* Results, [NativeTypeName("unsigned int *")] uint* IsIncomplete); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetContainerKind", ExactSpelling = true)] + [return: NativeTypeName("enum CXCursorKind")] + public static extern CXCursorKind codeCompleteGetContainerKind(CXCodeCompleteResults* Results, [NativeTypeName("unsigned int *")] uint* IsIncomplete); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetContainerUSR", ExactSpelling = true)] - public static extern CXString codeCompleteGetContainerUSR(CXCodeCompleteResults* Results); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetContainerUSR", ExactSpelling = true)] + public static extern CXString codeCompleteGetContainerUSR(CXCodeCompleteResults* Results); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetObjCSelector", ExactSpelling = true)] - public static extern CXString codeCompleteGetObjCSelector(CXCodeCompleteResults* Results); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_codeCompleteGetObjCSelector", ExactSpelling = true)] + public static extern CXString codeCompleteGetObjCSelector(CXCodeCompleteResults* Results); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getClangVersion", ExactSpelling = true)] - public static extern CXString getClangVersion(); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getClangVersion", ExactSpelling = true)] + public static extern CXString getClangVersion(); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_toggleCrashRecovery", ExactSpelling = true)] - public static extern void toggleCrashRecovery([NativeTypeName("unsigned int")] uint isEnabled); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_toggleCrashRecovery", ExactSpelling = true)] + public static extern void toggleCrashRecovery([NativeTypeName("unsigned int")] uint isEnabled); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getInclusions", ExactSpelling = true)] - public static extern void getInclusions([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXInclusionVisitor")] IntPtr visitor, [NativeTypeName("CXClientData")] void* client_data); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getInclusions", ExactSpelling = true)] + public static extern void getInclusions([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* tu, [NativeTypeName("CXInclusionVisitor")] IntPtr visitor, [NativeTypeName("CXClientData")] void* client_data); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_Evaluate", ExactSpelling = true)] - [return: NativeTypeName("CXEvalResult")] - public static extern void* Cursor_Evaluate(CXCursor C); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Cursor_Evaluate", ExactSpelling = true)] + [return: NativeTypeName("CXEvalResult")] + public static extern void* Cursor_Evaluate(CXCursor C); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getKind", ExactSpelling = true)] - public static extern CXEvalResultKind EvalResult_getKind([NativeTypeName("CXEvalResult")] void* E); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getKind", ExactSpelling = true)] + public static extern CXEvalResultKind EvalResult_getKind([NativeTypeName("CXEvalResult")] void* E); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsInt", ExactSpelling = true)] - public static extern int EvalResult_getAsInt([NativeTypeName("CXEvalResult")] void* E); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsInt", ExactSpelling = true)] + public static extern int EvalResult_getAsInt([NativeTypeName("CXEvalResult")] void* E); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsLongLong", ExactSpelling = true)] - [return: NativeTypeName("long long")] - public static extern long EvalResult_getAsLongLong([NativeTypeName("CXEvalResult")] void* E); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsLongLong", ExactSpelling = true)] + [return: NativeTypeName("long long")] + public static extern long EvalResult_getAsLongLong([NativeTypeName("CXEvalResult")] void* E); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_isUnsignedInt", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint EvalResult_isUnsignedInt([NativeTypeName("CXEvalResult")] void* E); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_isUnsignedInt", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint EvalResult_isUnsignedInt([NativeTypeName("CXEvalResult")] void* E); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsUnsigned", ExactSpelling = true)] - [return: NativeTypeName("unsigned long long")] - public static extern ulong EvalResult_getAsUnsigned([NativeTypeName("CXEvalResult")] void* E); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsUnsigned", ExactSpelling = true)] + [return: NativeTypeName("unsigned long long")] + public static extern ulong EvalResult_getAsUnsigned([NativeTypeName("CXEvalResult")] void* E); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsDouble", ExactSpelling = true)] - public static extern double EvalResult_getAsDouble([NativeTypeName("CXEvalResult")] void* E); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsDouble", ExactSpelling = true)] + public static extern double EvalResult_getAsDouble([NativeTypeName("CXEvalResult")] void* E); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsStr", ExactSpelling = true)] - [return: NativeTypeName("const char *")] - public static extern sbyte* EvalResult_getAsStr([NativeTypeName("CXEvalResult")] void* E); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_getAsStr", ExactSpelling = true)] + [return: NativeTypeName("const char *")] + public static extern sbyte* EvalResult_getAsStr([NativeTypeName("CXEvalResult")] void* E); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_dispose", ExactSpelling = true)] - public static extern void EvalResult_dispose([NativeTypeName("CXEvalResult")] void* E); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_EvalResult_dispose", ExactSpelling = true)] + public static extern void EvalResult_dispose([NativeTypeName("CXEvalResult")] void* E); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRemappings", ExactSpelling = true)] - [return: NativeTypeName("CXRemapping")] - public static extern void* getRemappings([NativeTypeName("const char *")] sbyte* path); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRemappings", ExactSpelling = true)] + [return: NativeTypeName("CXRemapping")] + public static extern void* getRemappings([NativeTypeName("const char *")] sbyte* path); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRemappingsFromFileList", ExactSpelling = true)] - [return: NativeTypeName("CXRemapping")] - public static extern void* getRemappingsFromFileList([NativeTypeName("const char **")] sbyte** filePaths, [NativeTypeName("unsigned int")] uint numFiles); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getRemappingsFromFileList", ExactSpelling = true)] + [return: NativeTypeName("CXRemapping")] + public static extern void* getRemappingsFromFileList([NativeTypeName("const char **")] sbyte** filePaths, [NativeTypeName("unsigned int")] uint numFiles); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_remap_getNumFiles", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint remap_getNumFiles([NativeTypeName("CXRemapping")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_remap_getNumFiles", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint remap_getNumFiles([NativeTypeName("CXRemapping")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_remap_getFilenames", ExactSpelling = true)] - public static extern void remap_getFilenames([NativeTypeName("CXRemapping")] void* param0, [NativeTypeName("unsigned int")] uint index, CXString* original, CXString* transformed); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_remap_getFilenames", ExactSpelling = true)] + public static extern void remap_getFilenames([NativeTypeName("CXRemapping")] void* param0, [NativeTypeName("unsigned int")] uint index, CXString* original, CXString* transformed); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_remap_dispose", ExactSpelling = true)] - public static extern void remap_dispose([NativeTypeName("CXRemapping")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_remap_dispose", ExactSpelling = true)] + public static extern void remap_dispose([NativeTypeName("CXRemapping")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_findReferencesInFile", ExactSpelling = true)] - public static extern CXResult findReferencesInFile(CXCursor cursor, [NativeTypeName("CXFile")] void* file, CXCursorAndRangeVisitor visitor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_findReferencesInFile", ExactSpelling = true)] + public static extern CXResult findReferencesInFile(CXCursor cursor, [NativeTypeName("CXFile")] void* file, CXCursorAndRangeVisitor visitor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_findIncludesInFile", ExactSpelling = true)] - public static extern CXResult findIncludesInFile([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, [NativeTypeName("CXFile")] void* file, CXCursorAndRangeVisitor visitor); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_findIncludesInFile", ExactSpelling = true)] + public static extern CXResult findIncludesInFile([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU, [NativeTypeName("CXFile")] void* file, CXCursorAndRangeVisitor visitor); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_isEntityObjCContainerKind", ExactSpelling = true)] - public static extern int index_isEntityObjCContainerKind(CXIdxEntityKind param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_isEntityObjCContainerKind", ExactSpelling = true)] + public static extern int index_isEntityObjCContainerKind(CXIdxEntityKind param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCContainerDeclInfo", ExactSpelling = true)] - [return: NativeTypeName("const CXIdxObjCContainerDeclInfo *")] - public static extern CXIdxObjCContainerDeclInfo* index_getObjCContainerDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCContainerDeclInfo", ExactSpelling = true)] + [return: NativeTypeName("const CXIdxObjCContainerDeclInfo *")] + public static extern CXIdxObjCContainerDeclInfo* index_getObjCContainerDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCInterfaceDeclInfo", ExactSpelling = true)] - [return: NativeTypeName("const CXIdxObjCInterfaceDeclInfo *")] - public static extern CXIdxObjCInterfaceDeclInfo* index_getObjCInterfaceDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCInterfaceDeclInfo", ExactSpelling = true)] + [return: NativeTypeName("const CXIdxObjCInterfaceDeclInfo *")] + public static extern CXIdxObjCInterfaceDeclInfo* index_getObjCInterfaceDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCCategoryDeclInfo", ExactSpelling = true)] - [return: NativeTypeName("const CXIdxObjCCategoryDeclInfo *")] - public static extern CXIdxObjCCategoryDeclInfo* index_getObjCCategoryDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCCategoryDeclInfo", ExactSpelling = true)] + [return: NativeTypeName("const CXIdxObjCCategoryDeclInfo *")] + public static extern CXIdxObjCCategoryDeclInfo* index_getObjCCategoryDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCProtocolRefListInfo", ExactSpelling = true)] - [return: NativeTypeName("const CXIdxObjCProtocolRefListInfo *")] - public static extern CXIdxObjCProtocolRefListInfo* index_getObjCProtocolRefListInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCProtocolRefListInfo", ExactSpelling = true)] + [return: NativeTypeName("const CXIdxObjCProtocolRefListInfo *")] + public static extern CXIdxObjCProtocolRefListInfo* index_getObjCProtocolRefListInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCPropertyDeclInfo", ExactSpelling = true)] - [return: NativeTypeName("const CXIdxObjCPropertyDeclInfo *")] - public static extern CXIdxObjCPropertyDeclInfo* index_getObjCPropertyDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getObjCPropertyDeclInfo", ExactSpelling = true)] + [return: NativeTypeName("const CXIdxObjCPropertyDeclInfo *")] + public static extern CXIdxObjCPropertyDeclInfo* index_getObjCPropertyDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getIBOutletCollectionAttrInfo", ExactSpelling = true)] - [return: NativeTypeName("const CXIdxIBOutletCollectionAttrInfo *")] - public static extern CXIdxIBOutletCollectionAttrInfo* index_getIBOutletCollectionAttrInfo([NativeTypeName("const CXIdxAttrInfo *")] CXIdxAttrInfo* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getIBOutletCollectionAttrInfo", ExactSpelling = true)] + [return: NativeTypeName("const CXIdxIBOutletCollectionAttrInfo *")] + public static extern CXIdxIBOutletCollectionAttrInfo* index_getIBOutletCollectionAttrInfo([NativeTypeName("const CXIdxAttrInfo *")] CXIdxAttrInfo* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getCXXClassDeclInfo", ExactSpelling = true)] - [return: NativeTypeName("const CXIdxCXXClassDeclInfo *")] - public static extern CXIdxCXXClassDeclInfo* index_getCXXClassDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getCXXClassDeclInfo", ExactSpelling = true)] + [return: NativeTypeName("const CXIdxCXXClassDeclInfo *")] + public static extern CXIdxCXXClassDeclInfo* index_getCXXClassDeclInfo([NativeTypeName("const CXIdxDeclInfo *")] CXIdxDeclInfo* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getClientContainer", ExactSpelling = true)] - [return: NativeTypeName("CXIdxClientContainer")] - public static extern void* index_getClientContainer([NativeTypeName("const CXIdxContainerInfo *")] CXIdxContainerInfo* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getClientContainer", ExactSpelling = true)] + [return: NativeTypeName("CXIdxClientContainer")] + public static extern void* index_getClientContainer([NativeTypeName("const CXIdxContainerInfo *")] CXIdxContainerInfo* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_setClientContainer", ExactSpelling = true)] - public static extern void index_setClientContainer([NativeTypeName("const CXIdxContainerInfo *")] CXIdxContainerInfo* param0, [NativeTypeName("CXIdxClientContainer")] void* param1); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_setClientContainer", ExactSpelling = true)] + public static extern void index_setClientContainer([NativeTypeName("const CXIdxContainerInfo *")] CXIdxContainerInfo* param0, [NativeTypeName("CXIdxClientContainer")] void* param1); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getClientEntity", ExactSpelling = true)] - [return: NativeTypeName("CXIdxClientEntity")] - public static extern void* index_getClientEntity([NativeTypeName("const CXIdxEntityInfo *")] CXIdxEntityInfo* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_getClientEntity", ExactSpelling = true)] + [return: NativeTypeName("CXIdxClientEntity")] + public static extern void* index_getClientEntity([NativeTypeName("const CXIdxEntityInfo *")] CXIdxEntityInfo* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_setClientEntity", ExactSpelling = true)] - public static extern void index_setClientEntity([NativeTypeName("const CXIdxEntityInfo *")] CXIdxEntityInfo* param0, [NativeTypeName("CXIdxClientEntity")] void* param1); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_index_setClientEntity", ExactSpelling = true)] + public static extern void index_setClientEntity([NativeTypeName("const CXIdxEntityInfo *")] CXIdxEntityInfo* param0, [NativeTypeName("CXIdxClientEntity")] void* param1); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_IndexAction_create", ExactSpelling = true)] - [return: NativeTypeName("CXIndexAction")] - public static extern void* IndexAction_create([NativeTypeName("CXIndex")] void* CIdx); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_IndexAction_create", ExactSpelling = true)] + [return: NativeTypeName("CXIndexAction")] + public static extern void* IndexAction_create([NativeTypeName("CXIndex")] void* CIdx); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_IndexAction_dispose", ExactSpelling = true)] - public static extern void IndexAction_dispose([NativeTypeName("CXIndexAction")] void* param0); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_IndexAction_dispose", ExactSpelling = true)] + public static extern void IndexAction_dispose([NativeTypeName("CXIndexAction")] void* param0); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexSourceFile", ExactSpelling = true)] - public static extern int indexSourceFile([NativeTypeName("CXIndexAction")] void* param0, [NativeTypeName("CXClientData")] void* client_data, IndexerCallbacks* index_callbacks, [NativeTypeName("unsigned int")] uint index_callbacks_size, [NativeTypeName("unsigned int")] uint index_options, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU, [NativeTypeName("unsigned int")] uint TU_options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexSourceFile", ExactSpelling = true)] + public static extern int indexSourceFile([NativeTypeName("CXIndexAction")] void* param0, [NativeTypeName("CXClientData")] void* client_data, IndexerCallbacks* index_callbacks, [NativeTypeName("unsigned int")] uint index_callbacks_size, [NativeTypeName("unsigned int")] uint index_options, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU, [NativeTypeName("unsigned int")] uint TU_options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexSourceFileFullArgv", ExactSpelling = true)] - public static extern int indexSourceFileFullArgv([NativeTypeName("CXIndexAction")] void* param0, [NativeTypeName("CXClientData")] void* client_data, IndexerCallbacks* index_callbacks, [NativeTypeName("unsigned int")] uint index_callbacks_size, [NativeTypeName("unsigned int")] uint index_options, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU, [NativeTypeName("unsigned int")] uint TU_options); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexSourceFileFullArgv", ExactSpelling = true)] + public static extern int indexSourceFileFullArgv([NativeTypeName("CXIndexAction")] void* param0, [NativeTypeName("CXClientData")] void* client_data, IndexerCallbacks* index_callbacks, [NativeTypeName("unsigned int")] uint index_callbacks_size, [NativeTypeName("unsigned int")] uint index_options, [NativeTypeName("const char *")] sbyte* source_filename, [NativeTypeName("const char *const *")] sbyte** command_line_args, int num_command_line_args, [NativeTypeName("struct CXUnsavedFile *")] CXUnsavedFile* unsaved_files, [NativeTypeName("unsigned int")] uint num_unsaved_files, [NativeTypeName("CXTranslationUnit *")] CXTranslationUnitImpl** out_TU, [NativeTypeName("unsigned int")] uint TU_options); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexTranslationUnit", ExactSpelling = true)] - public static extern int indexTranslationUnit([NativeTypeName("CXIndexAction")] void* param0, [NativeTypeName("CXClientData")] void* client_data, IndexerCallbacks* index_callbacks, [NativeTypeName("unsigned int")] uint index_callbacks_size, [NativeTypeName("unsigned int")] uint index_options, [NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param5); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexTranslationUnit", ExactSpelling = true)] + public static extern int indexTranslationUnit([NativeTypeName("CXIndexAction")] void* param0, [NativeTypeName("CXClientData")] void* client_data, IndexerCallbacks* index_callbacks, [NativeTypeName("unsigned int")] uint index_callbacks_size, [NativeTypeName("unsigned int")] uint index_options, [NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* param5); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexLoc_getFileLocation", ExactSpelling = true)] - public static extern void indexLoc_getFileLocation(CXIdxLoc loc, [NativeTypeName("CXIdxClientFile *")] void** indexFile, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexLoc_getFileLocation", ExactSpelling = true)] + public static extern void indexLoc_getFileLocation(CXIdxLoc loc, [NativeTypeName("CXIdxClientFile *")] void** indexFile, [NativeTypeName("CXFile *")] void** file, [NativeTypeName("unsigned int *")] uint* line, [NativeTypeName("unsigned int *")] uint* column, [NativeTypeName("unsigned int *")] uint* offset); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexLoc_getCXSourceLocation", ExactSpelling = true)] - public static extern CXSourceLocation indexLoc_getCXSourceLocation(CXIdxLoc loc); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_indexLoc_getCXSourceLocation", ExactSpelling = true)] + public static extern CXSourceLocation indexLoc_getCXSourceLocation(CXIdxLoc loc); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_visitFields", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Type_visitFields(CXType T, [NativeTypeName("CXFieldVisitor")] IntPtr visitor, [NativeTypeName("CXClientData")] void* client_data); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_Type_visitFields", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Type_visitFields(CXType T, [NativeTypeName("CXFieldVisitor")] IntPtr visitor, [NativeTypeName("CXClientData")] void* client_data); - [NativeTypeName("#define CINDEX_VERSION_MAJOR 0")] - public const int CINDEX_VERSION_MAJOR = 0; + [NativeTypeName("#define CINDEX_VERSION_MAJOR 0")] + public const int CINDEX_VERSION_MAJOR = 0; - [NativeTypeName("#define CINDEX_VERSION_MINOR 62")] - public const int CINDEX_VERSION_MINOR = 62; + [NativeTypeName("#define CINDEX_VERSION_MINOR 62")] + public const int CINDEX_VERSION_MINOR = 62; - [NativeTypeName("#define CINDEX_VERSION CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)")] - public const int CINDEX_VERSION = (((0) * 10000) + ((62) * 1)); + [NativeTypeName("#define CINDEX_VERSION CINDEX_VERSION_ENCODE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)")] + public const int CINDEX_VERSION = (((0) * 10000) + ((62) * 1)); - [NativeTypeName("#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)")] - public static ReadOnlySpan CINDEX_VERSION_STRING => new byte[] { 0x30, 0x2E, 0x36, 0x32, 0x00 }; + [NativeTypeName("#define CINDEX_VERSION_STRING CINDEX_VERSION_STRINGIZE(CINDEX_VERSION_MAJOR, CINDEX_VERSION_MINOR)")] + public static ReadOnlySpan CINDEX_VERSION_STRING => new byte[] { 0x30, 0x2E, 0x36, 0x32, 0x00 }; - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_create", ExactSpelling = true)] - [return: NativeTypeName("CXRewriter")] - public static extern void* CXRewriter_create([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_create", ExactSpelling = true)] + [return: NativeTypeName("CXRewriter")] + public static extern void* CXRewriter_create([NativeTypeName("CXTranslationUnit")] CXTranslationUnitImpl* TU); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_insertTextBefore", ExactSpelling = true)] - public static extern void CXRewriter_insertTextBefore([NativeTypeName("CXRewriter")] void* Rew, CXSourceLocation Loc, [NativeTypeName("const char *")] sbyte* Insert); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_insertTextBefore", ExactSpelling = true)] + public static extern void CXRewriter_insertTextBefore([NativeTypeName("CXRewriter")] void* Rew, CXSourceLocation Loc, [NativeTypeName("const char *")] sbyte* Insert); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_replaceText", ExactSpelling = true)] - public static extern void CXRewriter_replaceText([NativeTypeName("CXRewriter")] void* Rew, CXSourceRange ToBeReplaced, [NativeTypeName("const char *")] sbyte* Replacement); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_replaceText", ExactSpelling = true)] + public static extern void CXRewriter_replaceText([NativeTypeName("CXRewriter")] void* Rew, CXSourceRange ToBeReplaced, [NativeTypeName("const char *")] sbyte* Replacement); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_removeText", ExactSpelling = true)] - public static extern void CXRewriter_removeText([NativeTypeName("CXRewriter")] void* Rew, CXSourceRange ToBeRemoved); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_removeText", ExactSpelling = true)] + public static extern void CXRewriter_removeText([NativeTypeName("CXRewriter")] void* Rew, CXSourceRange ToBeRemoved); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_overwriteChangedFiles", ExactSpelling = true)] - public static extern int CXRewriter_overwriteChangedFiles([NativeTypeName("CXRewriter")] void* Rew); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_overwriteChangedFiles", ExactSpelling = true)] + public static extern int CXRewriter_overwriteChangedFiles([NativeTypeName("CXRewriter")] void* Rew); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_writeMainFileToStdOut", ExactSpelling = true)] - public static extern void CXRewriter_writeMainFileToStdOut([NativeTypeName("CXRewriter")] void* Rew); + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_writeMainFileToStdOut", ExactSpelling = true)] + public static extern void CXRewriter_writeMainFileToStdOut([NativeTypeName("CXRewriter")] void* Rew); - [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_dispose", ExactSpelling = true)] - public static extern void CXRewriter_dispose([NativeTypeName("CXRewriter")] void* Rew); - } + [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_CXRewriter_dispose", ExactSpelling = true)] + public static extern void CXRewriter_dispose([NativeTypeName("CXRewriter")] void* Rew); } diff --git a/sources/ClangSharp.Interop/clangsharp.cs b/sources/ClangSharp.Interop/clangsharp.cs index 2d62b4a7..bab80662 100644 --- a/sources/ClangSharp.Interop/clangsharp.cs +++ b/sources/ClangSharp.Interop/clangsharp.cs @@ -4,1055 +4,1054 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop +namespace ClangSharp.Interop; + +public static partial class clangsharp { - public static partial class clangsharp - { - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getArgument", ExactSpelling = true)] - public static extern CXCursor Cursor_getArgument(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getArgument", ExactSpelling = true)] + public static extern CXCursor Cursor_getArgument(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getArgumentType", ExactSpelling = true)] - public static extern CXType Cursor_getArgumentType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getArgumentType", ExactSpelling = true)] + public static extern CXType Cursor_getArgumentType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getArraySize", ExactSpelling = true)] - [return: NativeTypeName("int64_t")] - public static extern long Cursor_getArraySize(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getArraySize", ExactSpelling = true)] + [return: NativeTypeName("int64_t")] + public static extern long Cursor_getArraySize(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAssociatedConstraint", ExactSpelling = true)] - public static extern CXCursor Cursor_getAssociatedConstraint(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAssociatedConstraint", ExactSpelling = true)] + public static extern CXCursor Cursor_getAssociatedConstraint(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAsFunction", ExactSpelling = true)] - public static extern CXCursor Cursor_getAsFunction(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAsFunction", ExactSpelling = true)] + public static extern CXCursor Cursor_getAsFunction(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAtomicOpcode", ExactSpelling = true)] - public static extern CX_AtomicOperatorKind Cursor_getAtomicOpcode(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAtomicOpcode", ExactSpelling = true)] + public static extern CX_AtomicOperatorKind Cursor_getAtomicOpcode(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAttr", ExactSpelling = true)] - public static extern CXCursor Cursor_getAttr(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAttr", ExactSpelling = true)] + public static extern CXCursor Cursor_getAttr(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAttrKind", ExactSpelling = true)] - public static extern CX_AttrKind Cursor_getAttrKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getAttrKind", ExactSpelling = true)] + public static extern CX_AttrKind Cursor_getAttrKind(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBase", ExactSpelling = true)] - public static extern CXCursor Cursor_getBase(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBase", ExactSpelling = true)] + public static extern CXCursor Cursor_getBase(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBinaryOpcode", ExactSpelling = true)] - public static extern CX_BinaryOperatorKind Cursor_getBinaryOpcode(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBinaryOpcode", ExactSpelling = true)] + public static extern CX_BinaryOperatorKind Cursor_getBinaryOpcode(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBinaryOpcodeSpelling", ExactSpelling = true)] - public static extern CXString Cursor_getBinaryOpcodeSpelling(CX_BinaryOperatorKind Op); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBinaryOpcodeSpelling", ExactSpelling = true)] + public static extern CXString Cursor_getBinaryOpcodeSpelling(CX_BinaryOperatorKind Op); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBindingDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getBindingDecl(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBindingDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getBindingDecl(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBindingExpr", ExactSpelling = true)] - public static extern CXCursor Cursor_getBindingExpr(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBindingExpr", ExactSpelling = true)] + public static extern CXCursor Cursor_getBindingExpr(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBitWidth", ExactSpelling = true)] - public static extern CXCursor Cursor_getBitWidth(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBitWidth", ExactSpelling = true)] + public static extern CXCursor Cursor_getBitWidth(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBlockManglingContextDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getBlockManglingContextDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBlockManglingContextDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getBlockManglingContextDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBlockManglingNumber", ExactSpelling = true)] - public static extern int Cursor_getBlockManglingNumber(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBlockManglingNumber", ExactSpelling = true)] + public static extern int Cursor_getBlockManglingNumber(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBlockMissingReturnType", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getBlockMissingReturnType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBlockMissingReturnType", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getBlockMissingReturnType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBody", ExactSpelling = true)] - public static extern CXCursor Cursor_getBody(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBody", ExactSpelling = true)] + public static extern CXCursor Cursor_getBody(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCallResultType", ExactSpelling = true)] - public static extern CXType Cursor_getCallResultType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCallResultType", ExactSpelling = true)] + public static extern CXType Cursor_getCallResultType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCanAvoidCopyToHeap", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getCanAvoidCopyToHeap(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCanAvoidCopyToHeap", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getCanAvoidCopyToHeap(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCanonical", ExactSpelling = true)] - public static extern CXCursor Cursor_getCanonical(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCanonical", ExactSpelling = true)] + public static extern CXCursor Cursor_getCanonical(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureCopyExpr", ExactSpelling = true)] - public static extern CXCursor Cursor_getCaptureCopyExpr(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureCopyExpr", ExactSpelling = true)] + public static extern CXCursor Cursor_getCaptureCopyExpr(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedVar", ExactSpelling = true)] - public static extern CXCursor Cursor_getCapturedVar(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedVar", ExactSpelling = true)] + public static extern CXCursor Cursor_getCapturedVar(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureKind", ExactSpelling = true)] - public static extern CX_VariableCaptureKind Cursor_getCaptureKind(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureKind", ExactSpelling = true)] + public static extern CX_VariableCaptureKind Cursor_getCaptureKind(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureHasCopyExpr", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getCaptureHasCopyExpr(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureHasCopyExpr", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getCaptureHasCopyExpr(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureIsByRef", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getCaptureIsByRef(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureIsByRef", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getCaptureIsByRef(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureIsEscapingByRef", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getCaptureIsEscapingByRef(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureIsEscapingByRef", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getCaptureIsEscapingByRef(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureIsNested", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getCaptureIsNested(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureIsNested", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getCaptureIsNested(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureIsNonEscapingByRef", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getCaptureIsNonEscapingByRef(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureIsNonEscapingByRef", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getCaptureIsNonEscapingByRef(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getCapturedDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getCapturedDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedRecordDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getCapturedRecordDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedRecordDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getCapturedRecordDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedRegionKind", ExactSpelling = true)] - public static extern CX_CapturedRegionKind Cursor_getCapturedRegionKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedRegionKind", ExactSpelling = true)] + public static extern CX_CapturedRegionKind Cursor_getCapturedRegionKind(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedStmt", ExactSpelling = true)] - public static extern CXCursor Cursor_getCapturedStmt(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturedStmt", ExactSpelling = true)] + public static extern CXCursor Cursor_getCapturedStmt(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturesCXXThis", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getCapturesCXXThis(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturesCXXThis", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getCapturesCXXThis(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturesVariable", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getCapturesVariable(CXCursor C, CXCursor V); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCapturesVariable", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getCapturesVariable(CXCursor C, CXCursor V); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureVariable", ExactSpelling = true)] - public static extern CXCursor Cursor_getCaptureVariable(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCaptureVariable", ExactSpelling = true)] + public static extern CXCursor Cursor_getCaptureVariable(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCastKind", ExactSpelling = true)] - public static extern CX_CastKind Cursor_getCastKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCastKind", ExactSpelling = true)] + public static extern CX_CastKind Cursor_getCastKind(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCharacterLiteralKind", ExactSpelling = true)] - public static extern CX_CharacterKind Cursor_getCharacterLiteralKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCharacterLiteralKind", ExactSpelling = true)] + public static extern CX_CharacterKind Cursor_getCharacterLiteralKind(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCharacterLiteralValue", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getCharacterLiteralValue(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCharacterLiteralValue", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getCharacterLiteralValue(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getChild", ExactSpelling = true)] - public static extern CXCursor Cursor_getChild(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getChild", ExactSpelling = true)] + public static extern CXCursor Cursor_getChild(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getComputationLhsType", ExactSpelling = true)] - public static extern CXType Cursor_getComputationLhsType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getComputationLhsType", ExactSpelling = true)] + public static extern CXType Cursor_getComputationLhsType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getComputationResultType", ExactSpelling = true)] - public static extern CXType Cursor_getComputationResultType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getComputationResultType", ExactSpelling = true)] + public static extern CXType Cursor_getComputationResultType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstraintExpr", ExactSpelling = true)] - public static extern CXCursor Cursor_getConstraintExpr(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstraintExpr", ExactSpelling = true)] + public static extern CXCursor Cursor_getConstraintExpr(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstructedBaseClass", ExactSpelling = true)] - public static extern CXCursor Cursor_getConstructedBaseClass(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstructedBaseClass", ExactSpelling = true)] + public static extern CXCursor Cursor_getConstructedBaseClass(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstructedBaseClassShadowDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getConstructedBaseClassShadowDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstructedBaseClassShadowDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getConstructedBaseClassShadowDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstructionKind", ExactSpelling = true)] - public static extern CX_ConstructionKind Cursor_getConstructionKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstructionKind", ExactSpelling = true)] + public static extern CX_ConstructionKind Cursor_getConstructionKind(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstructsVirtualBase", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getConstructsVirtualBase(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getConstructsVirtualBase", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getConstructsVirtualBase(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getContextParam", ExactSpelling = true)] - public static extern CXCursor Cursor_getContextParam(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getContextParam", ExactSpelling = true)] + public static extern CXCursor Cursor_getContextParam(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getContextParamPosition", ExactSpelling = true)] - public static extern int Cursor_getContextParamPosition(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getContextParamPosition", ExactSpelling = true)] + public static extern int Cursor_getContextParamPosition(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCtor", ExactSpelling = true)] - public static extern CXCursor Cursor_getCtor(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getCtor", ExactSpelling = true)] + public static extern CXCursor Cursor_getCtor(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBoolLiteralValue", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getBoolLiteralValue(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getBoolLiteralValue", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getBoolLiteralValue(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDeclaredReturnType", ExactSpelling = true)] - public static extern CXType Cursor_getDeclaredReturnType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDeclaredReturnType", ExactSpelling = true)] + public static extern CXType Cursor_getDeclaredReturnType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getDecl(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getDecl(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDeclKind", ExactSpelling = true)] - public static extern CX_DeclKind Cursor_getDeclKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDeclKind", ExactSpelling = true)] + public static extern CX_DeclKind Cursor_getDeclKind(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDecomposedDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getDecomposedDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDecomposedDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getDecomposedDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDefaultArg", ExactSpelling = true)] - public static extern CXCursor Cursor_getDefaultArg(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDefaultArg", ExactSpelling = true)] + public static extern CXCursor Cursor_getDefaultArg(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDefaultArgType", ExactSpelling = true)] - public static extern CXType Cursor_getDefaultArgType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDefaultArgType", ExactSpelling = true)] + public static extern CXType Cursor_getDefaultArgType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDefinition", ExactSpelling = true)] - public static extern CXCursor Cursor_getDefinition(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDefinition", ExactSpelling = true)] + public static extern CXCursor Cursor_getDefinition(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDependentLambdaCallOperator", ExactSpelling = true)] - public static extern CXCursor Cursor_getDependentLambdaCallOperator(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDependentLambdaCallOperator", ExactSpelling = true)] + public static extern CXCursor Cursor_getDependentLambdaCallOperator(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDescribedCursorTemplate", ExactSpelling = true)] - public static extern CXCursor Cursor_getDescribedCursorTemplate(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDescribedCursorTemplate", ExactSpelling = true)] + public static extern CXCursor Cursor_getDescribedCursorTemplate(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDescribedTemplate", ExactSpelling = true)] - public static extern CXCursor Cursor_getDescribedTemplate(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDescribedTemplate", ExactSpelling = true)] + public static extern CXCursor Cursor_getDescribedTemplate(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDestructor", ExactSpelling = true)] - public static extern CXCursor Cursor_getDestructor(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDestructor", ExactSpelling = true)] + public static extern CXCursor Cursor_getDestructor(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDoesNotEscape", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getDoesNotEscape(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDoesNotEscape", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getDoesNotEscape(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDoesUsualArrayDeleteWantSize", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getDoesUsualArrayDeleteWantSize(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDoesUsualArrayDeleteWantSize", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getDoesUsualArrayDeleteWantSize(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getEnumDeclPromotionType", ExactSpelling = true)] - public static extern CXType Cursor_getEnumDeclPromotionType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getEnumDeclPromotionType", ExactSpelling = true)] + public static extern CXType Cursor_getEnumDeclPromotionType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getEnumerator", ExactSpelling = true)] - public static extern CXCursor Cursor_getEnumerator(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getEnumerator", ExactSpelling = true)] + public static extern CXCursor Cursor_getEnumerator(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getExpansionType", ExactSpelling = true)] - public static extern CXType Cursor_getExpansionType(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getExpansionType", ExactSpelling = true)] + public static extern CXType Cursor_getExpansionType(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getExpr", ExactSpelling = true)] - public static extern CXCursor Cursor_getExpr(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getExpr", ExactSpelling = true)] + public static extern CXCursor Cursor_getExpr(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getExprDependence", ExactSpelling = true)] - public static extern CX_ExprDependence Cursor_getExprDependence(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getExprDependence", ExactSpelling = true)] + public static extern CX_ExprDependence Cursor_getExprDependence(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFieldIndex", ExactSpelling = true)] - public static extern int Cursor_getFieldIndex(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFieldIndex", ExactSpelling = true)] + public static extern int Cursor_getFieldIndex(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFloatingLiteralSemantics", ExactSpelling = true)] - public static extern CX_FloatingSemantics Cursor_getFloatingLiteralSemantics(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFloatingLiteralSemantics", ExactSpelling = true)] + public static extern CX_FloatingSemantics Cursor_getFloatingLiteralSemantics(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFloatingLiteralValueAsApproximateDouble", ExactSpelling = true)] - public static extern double Cursor_getFloatingLiteralValueAsApproximateDouble(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFloatingLiteralValueAsApproximateDouble", ExactSpelling = true)] + public static extern double Cursor_getFloatingLiteralValueAsApproximateDouble(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFoundDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getFoundDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFoundDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getFoundDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getField", ExactSpelling = true)] - public static extern CXCursor Cursor_getField(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getField", ExactSpelling = true)] + public static extern CXCursor Cursor_getField(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFriend", ExactSpelling = true)] - public static extern CXCursor Cursor_getFriend(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFriend", ExactSpelling = true)] + public static extern CXCursor Cursor_getFriend(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFriendDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getFriendDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFriendDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getFriendDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFunctionScopeDepth", ExactSpelling = true)] - public static extern int Cursor_getFunctionScopeDepth(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFunctionScopeDepth", ExactSpelling = true)] + public static extern int Cursor_getFunctionScopeDepth(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFunctionScopeIndex", ExactSpelling = true)] - public static extern int Cursor_getFunctionScopeIndex(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getFunctionScopeIndex", ExactSpelling = true)] + public static extern int Cursor_getFunctionScopeIndex(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getGuidValue", ExactSpelling = true)] - [return: NativeTypeName("clang::MSGuidDeclParts")] - public static extern Guid Cursor_getGuidValue(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getGuidValue", ExactSpelling = true)] + [return: NativeTypeName("clang::MSGuidDeclParts")] + public static extern Guid Cursor_getGuidValue(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHadMultipleCandidates", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHadMultipleCandidates(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHadMultipleCandidates", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHadMultipleCandidates(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasBody", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasBody(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasBody", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasBody(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasDefaultArg", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasDefaultArg(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasDefaultArg", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasDefaultArg(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasElseStorage", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasElseStorage(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasElseStorage", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasElseStorage(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasExplicitTemplateArgs", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasExplicitTemplateArgs(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasExplicitTemplateArgs", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasExplicitTemplateArgs(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasImplicitReturnZero", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasImplicitReturnZero(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasImplicitReturnZero", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasImplicitReturnZero(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasInheritedDefaultArg", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasInheritedDefaultArg(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasInheritedDefaultArg", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasInheritedDefaultArg(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasInit", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasInit(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasInit", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasInit(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasInitStorage", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasInitStorage(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasInitStorage", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasInitStorage(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasLeadingEmptyMacro", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasLeadingEmptyMacro(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasLeadingEmptyMacro", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasLeadingEmptyMacro(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasLocalStorage", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasLocalStorage(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasLocalStorage", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasLocalStorage(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasPlaceholderTypeConstraint", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasPlaceholderTypeConstraint(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasPlaceholderTypeConstraint", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasPlaceholderTypeConstraint(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasTemplateKeyword", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasTemplateKeyword(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasTemplateKeyword", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasTemplateKeyword(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasUserDeclaredConstructor(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasUserDeclaredConstructor(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredCopyAssignment", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasUserDeclaredCopyAssignment(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredCopyAssignment", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasUserDeclaredCopyAssignment(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredCopyConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasUserDeclaredCopyConstructor(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredCopyConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasUserDeclaredCopyConstructor(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredDestructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasUserDeclaredDestructor(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredDestructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasUserDeclaredDestructor(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredMoveAssignment", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasUserDeclaredMoveAssignment(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredMoveAssignment", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasUserDeclaredMoveAssignment(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredMoveConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasUserDeclaredMoveConstructor(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredMoveConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasUserDeclaredMoveConstructor(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredMoveOperation", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasUserDeclaredMoveOperation(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasUserDeclaredMoveOperation", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasUserDeclaredMoveOperation(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasVarStorage", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getHasVarStorage(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHasVarStorage", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getHasVarStorage(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHoldingVar", ExactSpelling = true)] - public static extern CXCursor Cursor_getHoldingVar(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getHoldingVar", ExactSpelling = true)] + public static extern CXCursor Cursor_getHoldingVar(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInClassInitializer", ExactSpelling = true)] - public static extern CXCursor Cursor_getInClassInitializer(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInClassInitializer", ExactSpelling = true)] + public static extern CXCursor Cursor_getInClassInitializer(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInheritedConstructor", ExactSpelling = true)] - public static extern CXCursor Cursor_getInheritedConstructor(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInheritedConstructor", ExactSpelling = true)] + public static extern CXCursor Cursor_getInheritedConstructor(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInheritedFromVBase", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getInheritedFromVBase(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInheritedFromVBase", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getInheritedFromVBase(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInitExpr", ExactSpelling = true)] - public static extern CXCursor Cursor_getInitExpr(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInitExpr", ExactSpelling = true)] + public static extern CXCursor Cursor_getInitExpr(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInjectedSpecializationType", ExactSpelling = true)] - public static extern CXType Cursor_getInjectedSpecializationType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInjectedSpecializationType", ExactSpelling = true)] + public static extern CXType Cursor_getInjectedSpecializationType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInstantiatedFromMember", ExactSpelling = true)] - public static extern CXCursor Cursor_getInstantiatedFromMember(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getInstantiatedFromMember", ExactSpelling = true)] + public static extern CXCursor Cursor_getInstantiatedFromMember(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIntegerLiteralValue", ExactSpelling = true)] - [return: NativeTypeName("int64_t")] - public static extern long Cursor_getIntegerLiteralValue(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIntegerLiteralValue", ExactSpelling = true)] + [return: NativeTypeName("int64_t")] + public static extern long Cursor_getIntegerLiteralValue(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsAllEnumCasesCovered", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsAllEnumCasesCovered(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsAllEnumCasesCovered", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsAllEnumCasesCovered(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsAlwaysNull", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsAlwaysNull(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsAlwaysNull", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsAlwaysNull(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsAnonymousStructOrUnion", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsAnonymousStructOrUnion(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsAnonymousStructOrUnion", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsAnonymousStructOrUnion(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsArgumentType", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsArgumentType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsArgumentType", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsArgumentType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsArrayForm", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsArrayForm(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsArrayForm", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsArrayForm(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsArrayFormAsWritten", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsArrayFormAsWritten(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsArrayFormAsWritten", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsArrayFormAsWritten(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsArrow", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsArrow(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsArrow", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsArrow(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsClassExtension", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsClassExtension(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsClassExtension", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsClassExtension(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsCompleteDefinition", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsCompleteDefinition(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsCompleteDefinition", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsCompleteDefinition(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsConditionTrue", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsConditionTrue(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsConditionTrue", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsConditionTrue(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsConstexpr", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsConstexpr(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsConstexpr", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsConstexpr(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsConversionFromLambda", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsConversionFromLambda(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsConversionFromLambda", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsConversionFromLambda(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsCopyOrMoveConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsCopyOrMoveConstructor(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsCopyOrMoveConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsCopyOrMoveConstructor(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsCXXTry", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsCXXTry(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsCXXTry", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsCXXTry(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsDefined", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsDefined(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsDefined", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsDefined(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsDelegatingConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsDelegatingConstructor(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsDelegatingConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsDelegatingConstructor(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsDeleted", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsDeleted(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsDeleted", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsDeleted(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsDeprecated", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsDeprecated(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsDeprecated", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsDeprecated(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsElidable", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsElidable(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsElidable", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsElidable(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsExpandedParameterPack", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsExpandedParameterPack(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsExpandedParameterPack", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsExpandedParameterPack(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsExplicitlyDefaulted", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsExplicitlyDefaulted(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsExplicitlyDefaulted", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsExplicitlyDefaulted(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsExternC", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsExternC(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsExternC", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsExternC(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsFileScope", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsFileScope(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsFileScope", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsFileScope(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsGlobal", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsGlobal(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsGlobal", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsGlobal(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsInjectedClassName", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsInjectedClassName(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsInjectedClassName", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsInjectedClassName(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsIfExists", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsIfExists(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsIfExists", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsIfExists(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsImplicit", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsImplicit(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsImplicit", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsImplicit(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsIncomplete", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsIncomplete(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsIncomplete", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsIncomplete(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsInheritingConstructor", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsInheritingConstructor(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsInheritingConstructor", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsInheritingConstructor(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsListInitialization", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsListInitialization(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsListInitialization", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsListInitialization(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsLocalVarDecl", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsLocalVarDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsLocalVarDecl", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsLocalVarDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsLocalVarDeclOrParm", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsLocalVarDeclOrParm(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsLocalVarDeclOrParm", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsLocalVarDeclOrParm(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsMemberSpecialization", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsMemberSpecialization(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsMemberSpecialization", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsMemberSpecialization(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsNegative", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsNegative(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsNegative", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsNegative(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsNonNegative", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsNonNegative(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsNonNegative", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsNonNegative(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsNoReturn", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsNoReturn(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsNoReturn", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsNoReturn(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsNothrow", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsNothrow(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsNothrow", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsNothrow(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsOverloadedOperator", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsOverloadedOperator(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsOverloadedOperator", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsOverloadedOperator(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPackExpansion", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsPackExpansion(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPackExpansion", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsPackExpansion(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsParameterPack", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsParameterPack(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsParameterPack", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsParameterPack(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPartiallySubstituted", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsPartiallySubstituted(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPartiallySubstituted", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsPartiallySubstituted(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPotentiallyEvaluated", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsPotentiallyEvaluated(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPotentiallyEvaluated", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsPotentiallyEvaluated(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPure", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsPure(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsPure", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsPure(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsResultDependent", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsResultDependent(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsResultDependent", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsResultDependent(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsReversed", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsReversed(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsReversed", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsReversed(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsSigned", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsSigned(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsSigned", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsSigned(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsStatic", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsStatic(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsStatic", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsStatic(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsStaticDataMember", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsStaticDataMember(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsStaticDataMember", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsStaticDataMember(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsStdInitListInitialization", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsStdInitListInitialization(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsStdInitListInitialization", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsStdInitListInitialization(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsStrictlyPositive", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsStrictlyPositive(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsStrictlyPositive", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsStrictlyPositive(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsTemplated", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsTemplated(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsTemplated", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsTemplated(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsThisDeclarationADefinition", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsThisDeclarationADefinition(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsThisDeclarationADefinition", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsThisDeclarationADefinition(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsThrownVariableInScope", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsThrownVariableInScope(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsThrownVariableInScope", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsThrownVariableInScope(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsTransparent", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsTransparent(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsTransparent", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsTransparent(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsTypeConcept", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsTypeConcept(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsTypeConcept", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsTypeConcept(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnavailable", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsUnavailable(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnavailable", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsUnavailable(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnconditionallyVisible", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsUnconditionallyVisible(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnconditionallyVisible", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsUnconditionallyVisible(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnnamedBitfield", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsUnnamedBitfield(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnnamedBitfield", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsUnnamedBitfield(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnsigned", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsUnsigned(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnsigned", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsUnsigned(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnsupportedFriend", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsUnsupportedFriend(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUnsupportedFriend", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsUnsupportedFriend(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUserProvided", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsUserProvided(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsUserProvided", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsUserProvided(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsVariadic", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getIsVariadic(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getIsVariadic", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getIsVariadic(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getLambdaCallOperator", ExactSpelling = true)] - public static extern CXCursor Cursor_getLambdaCallOperator(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getLambdaCallOperator", ExactSpelling = true)] + public static extern CXCursor Cursor_getLambdaCallOperator(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getLambdaContextDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getLambdaContextDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getLambdaContextDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getLambdaContextDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getLambdaStaticInvoker", ExactSpelling = true)] - public static extern CXCursor Cursor_getLambdaStaticInvoker(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getLambdaStaticInvoker", ExactSpelling = true)] + public static extern CXCursor Cursor_getLambdaStaticInvoker(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getLhsExpr", ExactSpelling = true)] - public static extern CXCursor Cursor_getLhsExpr(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getLhsExpr", ExactSpelling = true)] + public static extern CXCursor Cursor_getLhsExpr(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getMaxAlignment", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getMaxAlignment(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getMaxAlignment", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getMaxAlignment(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getMethod", ExactSpelling = true)] - public static extern CXCursor Cursor_getMethod(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getMethod", ExactSpelling = true)] + public static extern CXCursor Cursor_getMethod(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getMostRecentDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getMostRecentDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getMostRecentDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getMostRecentDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getName", ExactSpelling = true)] - public static extern CXString Cursor_getName(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getName", ExactSpelling = true)] + public static extern CXString Cursor_getName(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNextDeclInContext", ExactSpelling = true)] - public static extern CXCursor Cursor_getNextDeclInContext(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNextDeclInContext", ExactSpelling = true)] + public static extern CXCursor Cursor_getNextDeclInContext(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNextSwitchCase", ExactSpelling = true)] - public static extern CXCursor Cursor_getNextSwitchCase(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNextSwitchCase", ExactSpelling = true)] + public static extern CXCursor Cursor_getNextSwitchCase(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNominatedBaseClass", ExactSpelling = true)] - public static extern CXCursor Cursor_getNominatedBaseClass(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNominatedBaseClass", ExactSpelling = true)] + public static extern CXCursor Cursor_getNominatedBaseClass(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNominatedBaseClassShadowDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getNominatedBaseClassShadowDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNominatedBaseClassShadowDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getNominatedBaseClassShadowDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNonClosureContext", ExactSpelling = true)] - public static extern CXCursor Cursor_getNonClosureContext(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNonClosureContext", ExactSpelling = true)] + public static extern CXCursor Cursor_getNonClosureContext(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumArguments", ExactSpelling = true)] - public static extern int Cursor_getNumArguments(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumArguments", ExactSpelling = true)] + public static extern int Cursor_getNumArguments(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumAssocs", ExactSpelling = true)] - public static extern int Cursor_getNumAssocs(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumAssocs", ExactSpelling = true)] + public static extern int Cursor_getNumAssocs(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumAssociatedConstraints", ExactSpelling = true)] - public static extern int Cursor_getNumAssociatedConstraints(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumAssociatedConstraints", ExactSpelling = true)] + public static extern int Cursor_getNumAssociatedConstraints(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumAttrs", ExactSpelling = true)] - public static extern int Cursor_getNumAttrs(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumAttrs", ExactSpelling = true)] + public static extern int Cursor_getNumAttrs(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumBases", ExactSpelling = true)] - public static extern int Cursor_getNumBases(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumBases", ExactSpelling = true)] + public static extern int Cursor_getNumBases(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumBindings", ExactSpelling = true)] - public static extern int Cursor_getNumBindings(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumBindings", ExactSpelling = true)] + public static extern int Cursor_getNumBindings(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumCaptures", ExactSpelling = true)] - public static extern int Cursor_getNumCaptures(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumCaptures", ExactSpelling = true)] + public static extern int Cursor_getNumCaptures(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumChildren", ExactSpelling = true)] - public static extern int Cursor_getNumChildren(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumChildren", ExactSpelling = true)] + public static extern int Cursor_getNumChildren(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumCtors", ExactSpelling = true)] - public static extern int Cursor_getNumCtors(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumCtors", ExactSpelling = true)] + public static extern int Cursor_getNumCtors(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumDecls", ExactSpelling = true)] - public static extern int Cursor_getNumDecls(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumDecls", ExactSpelling = true)] + public static extern int Cursor_getNumDecls(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumEnumerators", ExactSpelling = true)] - public static extern int Cursor_getNumEnumerators(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumEnumerators", ExactSpelling = true)] + public static extern int Cursor_getNumEnumerators(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumExpansionTypes", ExactSpelling = true)] - public static extern int Cursor_getNumExpansionTypes(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumExpansionTypes", ExactSpelling = true)] + public static extern int Cursor_getNumExpansionTypes(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumExprs", ExactSpelling = true)] - public static extern int Cursor_getNumExprs(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumExprs", ExactSpelling = true)] + public static extern int Cursor_getNumExprs(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumFields", ExactSpelling = true)] - public static extern int Cursor_getNumFields(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumFields", ExactSpelling = true)] + public static extern int Cursor_getNumFields(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumFriends", ExactSpelling = true)] - public static extern int Cursor_getNumFriends(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumFriends", ExactSpelling = true)] + public static extern int Cursor_getNumFriends(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumMethods", ExactSpelling = true)] - public static extern int Cursor_getNumMethods(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumMethods", ExactSpelling = true)] + public static extern int Cursor_getNumMethods(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumProtocols", ExactSpelling = true)] - public static extern int Cursor_getNumProtocols(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumProtocols", ExactSpelling = true)] + public static extern int Cursor_getNumProtocols(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumSpecializations", ExactSpelling = true)] - public static extern int Cursor_getNumSpecializations(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumSpecializations", ExactSpelling = true)] + public static extern int Cursor_getNumSpecializations(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumTemplateArguments", ExactSpelling = true)] - public static extern int Cursor_getNumTemplateArguments(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumTemplateArguments", ExactSpelling = true)] + public static extern int Cursor_getNumTemplateArguments(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumTemplateParameters", ExactSpelling = true)] - public static extern int Cursor_getNumTemplateParameters(CXCursor C, [NativeTypeName("unsigned int")] uint listIndex); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumTemplateParameters", ExactSpelling = true)] + public static extern int Cursor_getNumTemplateParameters(CXCursor C, [NativeTypeName("unsigned int")] uint listIndex); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumTemplateParameterLists", ExactSpelling = true)] - public static extern int Cursor_getNumTemplateParameterLists(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumTemplateParameterLists", ExactSpelling = true)] + public static extern int Cursor_getNumTemplateParameterLists(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumVBases", ExactSpelling = true)] - public static extern int Cursor_getNumVBases(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getNumVBases", ExactSpelling = true)] + public static extern int Cursor_getNumVBases(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getOpaqueValue", ExactSpelling = true)] - public static extern CXCursor Cursor_getOpaqueValue(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getOpaqueValue", ExactSpelling = true)] + public static extern CXCursor Cursor_getOpaqueValue(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getOriginalType", ExactSpelling = true)] - public static extern CXType Cursor_getOriginalType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getOriginalType", ExactSpelling = true)] + public static extern CXType Cursor_getOriginalType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getOverloadedOperatorKind", ExactSpelling = true)] - public static extern CX_OverloadedOperatorKind Cursor_getOverloadedOperatorKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getOverloadedOperatorKind", ExactSpelling = true)] + public static extern CX_OverloadedOperatorKind Cursor_getOverloadedOperatorKind(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getPackLength", ExactSpelling = true)] - public static extern int Cursor_getPackLength(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getPackLength", ExactSpelling = true)] + public static extern int Cursor_getPackLength(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getParentFunctionOrMethod", ExactSpelling = true)] - public static extern CXCursor Cursor_getParentFunctionOrMethod(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getParentFunctionOrMethod", ExactSpelling = true)] + public static extern CXCursor Cursor_getParentFunctionOrMethod(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getPlaceholderTypeConstraint", ExactSpelling = true)] - public static extern CXCursor Cursor_getPlaceholderTypeConstraint(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getPlaceholderTypeConstraint", ExactSpelling = true)] + public static extern CXCursor Cursor_getPlaceholderTypeConstraint(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getPreviousDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getPreviousDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getPreviousDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getPreviousDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getPrimaryTemplate", ExactSpelling = true)] - public static extern CXCursor Cursor_getPrimaryTemplate(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getPrimaryTemplate", ExactSpelling = true)] + public static extern CXCursor Cursor_getPrimaryTemplate(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getProtocol", ExactSpelling = true)] - public static extern CXCursor Cursor_getProtocol(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getProtocol", ExactSpelling = true)] + public static extern CXCursor Cursor_getProtocol(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getRedeclContext", ExactSpelling = true)] - public static extern CXCursor Cursor_getRedeclContext(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getRedeclContext", ExactSpelling = true)] + public static extern CXCursor Cursor_getRedeclContext(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getReferenced", ExactSpelling = true)] - public static extern CXCursor Cursor_getReferenced(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getReferenced", ExactSpelling = true)] + public static extern CXCursor Cursor_getReferenced(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getRequiresZeroInitialization", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getRequiresZeroInitialization(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getRequiresZeroInitialization", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getRequiresZeroInitialization(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getResultIndex", ExactSpelling = true)] - public static extern int Cursor_getResultIndex(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getResultIndex", ExactSpelling = true)] + public static extern int Cursor_getResultIndex(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getReturnType", ExactSpelling = true)] - public static extern CXType Cursor_getReturnType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getReturnType", ExactSpelling = true)] + public static extern CXType Cursor_getReturnType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getRhsExpr", ExactSpelling = true)] - public static extern CXCursor Cursor_getRhsExpr(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getRhsExpr", ExactSpelling = true)] + public static extern CXCursor Cursor_getRhsExpr(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getShouldCopy", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Cursor_getShouldCopy(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getShouldCopy", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Cursor_getShouldCopy(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSourceRange", ExactSpelling = true)] - public static extern CXSourceRange Cursor_getSourceRange(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSourceRange", ExactSpelling = true)] + public static extern CXSourceRange Cursor_getSourceRange(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSpecialization", ExactSpelling = true)] - public static extern CXCursor Cursor_getSpecialization(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSpecialization", ExactSpelling = true)] + public static extern CXCursor Cursor_getSpecialization(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getStmtClass", ExactSpelling = true)] - public static extern CX_StmtClass Cursor_getStmtClass(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getStmtClass", ExactSpelling = true)] + public static extern CX_StmtClass Cursor_getStmtClass(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getStringLiteralValue", ExactSpelling = true)] - public static extern CXString Cursor_getStringLiteralValue(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getStringLiteralValue", ExactSpelling = true)] + public static extern CXString Cursor_getStringLiteralValue(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSubDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getSubDecl(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSubDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getSubDecl(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSubExpr", ExactSpelling = true)] - public static extern CXCursor Cursor_getSubExpr(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSubExpr", ExactSpelling = true)] + public static extern CXCursor Cursor_getSubExpr(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSubExprAsWritten", ExactSpelling = true)] - public static extern CXCursor Cursor_getSubExprAsWritten(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSubExprAsWritten", ExactSpelling = true)] + public static extern CXCursor Cursor_getSubExprAsWritten(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSubStmt", ExactSpelling = true)] - public static extern CXCursor Cursor_getSubStmt(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getSubStmt", ExactSpelling = true)] + public static extern CXCursor Cursor_getSubStmt(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTargetUnionField", ExactSpelling = true)] - public static extern CXCursor Cursor_getTargetUnionField(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTargetUnionField", ExactSpelling = true)] + public static extern CXCursor Cursor_getTargetUnionField(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateArgument", ExactSpelling = true)] - public static extern CX_TemplateArgument Cursor_getTemplateArgument(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateArgument", ExactSpelling = true)] + public static extern CX_TemplateArgument Cursor_getTemplateArgument(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateArgumentLoc", ExactSpelling = true)] - public static extern CX_TemplateArgumentLoc Cursor_getTemplateArgumentLoc(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateArgumentLoc", ExactSpelling = true)] + public static extern CX_TemplateArgumentLoc Cursor_getTemplateArgumentLoc(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateParameter", ExactSpelling = true)] - public static extern CXCursor Cursor_getTemplateParameter(CXCursor C, [NativeTypeName("unsigned int")] uint listIndex, [NativeTypeName("unsigned int")] uint parameterIndex); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateParameter", ExactSpelling = true)] + public static extern CXCursor Cursor_getTemplateParameter(CXCursor C, [NativeTypeName("unsigned int")] uint listIndex, [NativeTypeName("unsigned int")] uint parameterIndex); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplatedDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getTemplatedDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplatedDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getTemplatedDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateInstantiationPattern", ExactSpelling = true)] - public static extern CXCursor Cursor_getTemplateInstantiationPattern(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateInstantiationPattern", ExactSpelling = true)] + public static extern CXCursor Cursor_getTemplateInstantiationPattern(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateSpecializationKind", ExactSpelling = true)] - public static extern CX_TemplateSpecializationKind Cursor_getTemplateSpecializationKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateSpecializationKind", ExactSpelling = true)] + public static extern CX_TemplateSpecializationKind Cursor_getTemplateSpecializationKind(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateTypeParmDepth", ExactSpelling = true)] - public static extern int Cursor_getTemplateTypeParmDepth(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateTypeParmDepth", ExactSpelling = true)] + public static extern int Cursor_getTemplateTypeParmDepth(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateTypeParmIndex", ExactSpelling = true)] - public static extern int Cursor_getTemplateTypeParmIndex(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateTypeParmIndex", ExactSpelling = true)] + public static extern int Cursor_getTemplateTypeParmIndex(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateTypeParmPosition", ExactSpelling = true)] - public static extern int Cursor_getTemplateTypeParmPosition(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTemplateTypeParmPosition", ExactSpelling = true)] + public static extern int Cursor_getTemplateTypeParmPosition(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getThisObjectType", ExactSpelling = true)] - public static extern CXType Cursor_getThisObjectType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getThisObjectType", ExactSpelling = true)] + public static extern CXType Cursor_getThisObjectType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getThisType", ExactSpelling = true)] - public static extern CXType Cursor_getThisType(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getThisType", ExactSpelling = true)] + public static extern CXType Cursor_getThisType(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTrailingRequiresClause", ExactSpelling = true)] - public static extern CXCursor Cursor_getTrailingRequiresClause(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTrailingRequiresClause", ExactSpelling = true)] + public static extern CXCursor Cursor_getTrailingRequiresClause(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTypedefNameForAnonDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getTypedefNameForAnonDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTypedefNameForAnonDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getTypedefNameForAnonDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTypeOperand", ExactSpelling = true)] - public static extern CXType Cursor_getTypeOperand(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getTypeOperand", ExactSpelling = true)] + public static extern CXType Cursor_getTypeOperand(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUnaryExprOrTypeTraitKind", ExactSpelling = true)] - public static extern CX_UnaryExprOrTypeTrait Cursor_getUnaryExprOrTypeTraitKind(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUnaryExprOrTypeTraitKind", ExactSpelling = true)] + public static extern CX_UnaryExprOrTypeTrait Cursor_getUnaryExprOrTypeTraitKind(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUnaryOpcode", ExactSpelling = true)] - public static extern CX_UnaryOperatorKind Cursor_getUnaryOpcode(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUnaryOpcode", ExactSpelling = true)] + public static extern CX_UnaryOperatorKind Cursor_getUnaryOpcode(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUnaryOpcodeSpelling", ExactSpelling = true)] - public static extern CXString Cursor_getUnaryOpcodeSpelling(CX_UnaryOperatorKind Op); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUnaryOpcodeSpelling", ExactSpelling = true)] + public static extern CXString Cursor_getUnaryOpcodeSpelling(CX_UnaryOperatorKind Op); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUnderlyingDecl", ExactSpelling = true)] - public static extern CXCursor Cursor_getUnderlyingDecl(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUnderlyingDecl", ExactSpelling = true)] + public static extern CXCursor Cursor_getUnderlyingDecl(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUninstantiatedDefaultArg", ExactSpelling = true)] - public static extern CXCursor Cursor_getUninstantiatedDefaultArg(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUninstantiatedDefaultArg", ExactSpelling = true)] + public static extern CXCursor Cursor_getUninstantiatedDefaultArg(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUsedContext", ExactSpelling = true)] - public static extern CXCursor Cursor_getUsedContext(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getUsedContext", ExactSpelling = true)] + public static extern CXCursor Cursor_getUsedContext(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getVBase", ExactSpelling = true)] - public static extern CXCursor Cursor_getVBase(CXCursor C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getVBase", ExactSpelling = true)] + public static extern CXCursor Cursor_getVBase(CXCursor C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDtorVtblIdx", ExactSpelling = true)] - [return: NativeTypeName("int64_t")] - public static extern long Cursor_getDtorVtblIdx(CXCursor C, CX_DestructorType dtor); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getDtorVtblIdx", ExactSpelling = true)] + [return: NativeTypeName("int64_t")] + public static extern long Cursor_getDtorVtblIdx(CXCursor C, CX_DestructorType dtor); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getVtblIdx", ExactSpelling = true)] - [return: NativeTypeName("int64_t")] - public static extern long Cursor_getVtblIdx(CXCursor C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Cursor_getVtblIdx", ExactSpelling = true)] + [return: NativeTypeName("int64_t")] + public static extern long Cursor_getVtblIdx(CXCursor C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_getVersion", ExactSpelling = true)] - public static extern CXString getVersion(); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_getVersion", ExactSpelling = true)] + public static extern CXString getVersion(); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_dispose", ExactSpelling = true)] - public static extern void TemplateArgument_dispose(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_dispose", ExactSpelling = true)] + public static extern void TemplateArgument_dispose(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsDecl", ExactSpelling = true)] - public static extern CXCursor TemplateArgument_getAsDecl(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsDecl", ExactSpelling = true)] + public static extern CXCursor TemplateArgument_getAsDecl(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsExpr", ExactSpelling = true)] - public static extern CXCursor TemplateArgument_getAsExpr(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsExpr", ExactSpelling = true)] + public static extern CXCursor TemplateArgument_getAsExpr(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsIntegral", ExactSpelling = true)] - [return: NativeTypeName("int64_t")] - public static extern long TemplateArgument_getAsIntegral(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsIntegral", ExactSpelling = true)] + [return: NativeTypeName("int64_t")] + public static extern long TemplateArgument_getAsIntegral(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsTemplate", ExactSpelling = true)] - public static extern CX_TemplateName TemplateArgument_getAsTemplate(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsTemplate", ExactSpelling = true)] + public static extern CX_TemplateName TemplateArgument_getAsTemplate(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsTemplateOrTemplatePattern", ExactSpelling = true)] - public static extern CX_TemplateName TemplateArgument_getAsTemplateOrTemplatePattern(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsTemplateOrTemplatePattern", ExactSpelling = true)] + public static extern CX_TemplateName TemplateArgument_getAsTemplateOrTemplatePattern(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsType", ExactSpelling = true)] - public static extern CXType TemplateArgument_getAsType(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getAsType", ExactSpelling = true)] + public static extern CXType TemplateArgument_getAsType(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getDependence", ExactSpelling = true)] - public static extern CX_TemplateArgumentDependence TemplateArgument_getDependence(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getDependence", ExactSpelling = true)] + public static extern CX_TemplateArgumentDependence TemplateArgument_getDependence(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getIntegralType", ExactSpelling = true)] - public static extern CXType TemplateArgument_getIntegralType(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getIntegralType", ExactSpelling = true)] + public static extern CXType TemplateArgument_getIntegralType(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getNonTypeTemplateArgumentType", ExactSpelling = true)] - public static extern CXType TemplateArgument_getNonTypeTemplateArgumentType(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getNonTypeTemplateArgumentType", ExactSpelling = true)] + public static extern CXType TemplateArgument_getNonTypeTemplateArgumentType(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getNullPtrType", ExactSpelling = true)] - public static extern CXType TemplateArgument_getNullPtrType(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getNullPtrType", ExactSpelling = true)] + public static extern CXType TemplateArgument_getNullPtrType(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getNumPackElements", ExactSpelling = true)] - public static extern int TemplateArgument_getNumPackElements(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getNumPackElements", ExactSpelling = true)] + public static extern int TemplateArgument_getNumPackElements(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getPackElement", ExactSpelling = true)] - public static extern CX_TemplateArgument TemplateArgument_getPackElement(CX_TemplateArgument T, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getPackElement", ExactSpelling = true)] + public static extern CX_TemplateArgument TemplateArgument_getPackElement(CX_TemplateArgument T, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getPackExpansionPattern", ExactSpelling = true)] - public static extern CX_TemplateArgument TemplateArgument_getPackExpansionPattern(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getPackExpansionPattern", ExactSpelling = true)] + public static extern CX_TemplateArgument TemplateArgument_getPackExpansionPattern(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getParamTypeForDecl", ExactSpelling = true)] - public static extern CXType TemplateArgument_getParamTypeForDecl(CX_TemplateArgument T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgument_getParamTypeForDecl", ExactSpelling = true)] + public static extern CXType TemplateArgument_getParamTypeForDecl(CX_TemplateArgument T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getArgument", ExactSpelling = true)] - public static extern CX_TemplateArgument TemplateArgumentLoc_getArgument(CX_TemplateArgumentLoc T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getArgument", ExactSpelling = true)] + public static extern CX_TemplateArgument TemplateArgumentLoc_getArgument(CX_TemplateArgumentLoc T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getLocation", ExactSpelling = true)] - public static extern CXSourceLocation TemplateArgumentLoc_getLocation(CX_TemplateArgumentLoc T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getLocation", ExactSpelling = true)] + public static extern CXSourceLocation TemplateArgumentLoc_getLocation(CX_TemplateArgumentLoc T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceDeclExpression", ExactSpelling = true)] - public static extern CXCursor TemplateArgumentLoc_getSourceDeclExpression(CX_TemplateArgumentLoc T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceDeclExpression", ExactSpelling = true)] + public static extern CXCursor TemplateArgumentLoc_getSourceDeclExpression(CX_TemplateArgumentLoc T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceExpression", ExactSpelling = true)] - public static extern CXCursor TemplateArgumentLoc_getSourceExpression(CX_TemplateArgumentLoc T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceExpression", ExactSpelling = true)] + public static extern CXCursor TemplateArgumentLoc_getSourceExpression(CX_TemplateArgumentLoc T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceIntegralExpression", ExactSpelling = true)] - public static extern CXCursor TemplateArgumentLoc_getSourceIntegralExpression(CX_TemplateArgumentLoc T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceIntegralExpression", ExactSpelling = true)] + public static extern CXCursor TemplateArgumentLoc_getSourceIntegralExpression(CX_TemplateArgumentLoc T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceNullPtrExpression", ExactSpelling = true)] - public static extern CXCursor TemplateArgumentLoc_getSourceNullPtrExpression(CX_TemplateArgumentLoc T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceNullPtrExpression", ExactSpelling = true)] + public static extern CXCursor TemplateArgumentLoc_getSourceNullPtrExpression(CX_TemplateArgumentLoc T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceRange", ExactSpelling = true)] - public static extern CXSourceRange TemplateArgumentLoc_getSourceRange(CX_TemplateArgumentLoc T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateArgumentLoc_getSourceRange", ExactSpelling = true)] + public static extern CXSourceRange TemplateArgumentLoc_getSourceRange(CX_TemplateArgumentLoc T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateName_getAsTemplateDecl", ExactSpelling = true)] - public static extern CXCursor TemplateName_getAsTemplateDecl(CX_TemplateName T); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_TemplateName_getAsTemplateDecl", ExactSpelling = true)] + public static extern CXCursor TemplateName_getAsTemplateDecl(CX_TemplateName T); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_desugar", ExactSpelling = true)] - public static extern CXType Type_desugar(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_desugar", ExactSpelling = true)] + public static extern CXType Type_desugar(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getAddrSpaceExpr", ExactSpelling = true)] - public static extern CXCursor Type_getAddrSpaceExpr(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getAddrSpaceExpr", ExactSpelling = true)] + public static extern CXCursor Type_getAddrSpaceExpr(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getAdjustedType", ExactSpelling = true)] - public static extern CXType Type_getAdjustedType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getAdjustedType", ExactSpelling = true)] + public static extern CXType Type_getAdjustedType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getAttrKind", ExactSpelling = true)] - public static extern CX_AttrKind Type_getAttrKind(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getAttrKind", ExactSpelling = true)] + public static extern CX_AttrKind Type_getAttrKind(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getBaseType", ExactSpelling = true)] - public static extern CXType Type_getBaseType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getBaseType", ExactSpelling = true)] + public static extern CXType Type_getBaseType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getColumnExpr", ExactSpelling = true)] - public static extern CXCursor Type_getColumnExpr(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getColumnExpr", ExactSpelling = true)] + public static extern CXCursor Type_getColumnExpr(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getDecayedType", ExactSpelling = true)] - public static extern CXType Type_getDecayedType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getDecayedType", ExactSpelling = true)] + public static extern CXType Type_getDecayedType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getDeclaration", ExactSpelling = true)] - public static extern CXCursor Type_getDeclaration(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getDeclaration", ExactSpelling = true)] + public static extern CXCursor Type_getDeclaration(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getDeducedType", ExactSpelling = true)] - public static extern CXType Type_getDeducedType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getDeducedType", ExactSpelling = true)] + public static extern CXType Type_getDeducedType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getDepth", ExactSpelling = true)] - public static extern int Type_getDepth(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getDepth", ExactSpelling = true)] + public static extern int Type_getDepth(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getElementType", ExactSpelling = true)] - public static extern CXType Type_getElementType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getElementType", ExactSpelling = true)] + public static extern CXType Type_getElementType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getEquivalentType", ExactSpelling = true)] - public static extern CXType Type_getEquivalentType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getEquivalentType", ExactSpelling = true)] + public static extern CXType Type_getEquivalentType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIndex", ExactSpelling = true)] - public static extern int Type_getIndex(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIndex", ExactSpelling = true)] + public static extern int Type_getIndex(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getInjectedSpecializationType", ExactSpelling = true)] - public static extern CXType Type_getInjectedSpecializationType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getInjectedSpecializationType", ExactSpelling = true)] + public static extern CXType Type_getInjectedSpecializationType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getInjectedTST", ExactSpelling = true)] - public static extern CXType Type_getInjectedTST(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getInjectedTST", ExactSpelling = true)] + public static extern CXType Type_getInjectedTST(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIsSigned", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Type_getIsSigned(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIsSigned", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Type_getIsSigned(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIsSugared", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Type_getIsSugared(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIsSugared", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Type_getIsSugared(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIsTypeAlias", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Type_getIsTypeAlias(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIsTypeAlias", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Type_getIsTypeAlias(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIsUnsigned", ExactSpelling = true)] - [return: NativeTypeName("unsigned int")] - public static extern uint Type_getIsUnsigned(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getIsUnsigned", ExactSpelling = true)] + [return: NativeTypeName("unsigned int")] + public static extern uint Type_getIsUnsigned(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getModifiedType", ExactSpelling = true)] - public static extern CXType Type_getModifiedType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getModifiedType", ExactSpelling = true)] + public static extern CXType Type_getModifiedType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumBits", ExactSpelling = true)] - public static extern int Type_getNumBits(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumBits", ExactSpelling = true)] + public static extern int Type_getNumBits(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumBitsExpr", ExactSpelling = true)] - public static extern CXCursor Type_getNumBitsExpr(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumBitsExpr", ExactSpelling = true)] + public static extern CXCursor Type_getNumBitsExpr(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumColumns", ExactSpelling = true)] - public static extern int Type_getNumColumns(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumColumns", ExactSpelling = true)] + public static extern int Type_getNumColumns(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumElementsFlattened", ExactSpelling = true)] - public static extern int Type_getNumElementsFlattened(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumElementsFlattened", ExactSpelling = true)] + public static extern int Type_getNumElementsFlattened(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumRows", ExactSpelling = true)] - public static extern int Type_getNumRows(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getNumRows", ExactSpelling = true)] + public static extern int Type_getNumRows(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getOriginalType", ExactSpelling = true)] - public static extern CXType Type_getOriginalType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getOriginalType", ExactSpelling = true)] + public static extern CXType Type_getOriginalType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getOwnedTagDecl", ExactSpelling = true)] - public static extern CXCursor Type_getOwnedTagDecl(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getOwnedTagDecl", ExactSpelling = true)] + public static extern CXCursor Type_getOwnedTagDecl(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getPointeeType", ExactSpelling = true)] - public static extern CXType Type_getPointeeType(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getPointeeType", ExactSpelling = true)] + public static extern CXType Type_getPointeeType(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getRowExpr", ExactSpelling = true)] - public static extern CXCursor Type_getRowExpr(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getRowExpr", ExactSpelling = true)] + public static extern CXCursor Type_getRowExpr(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getSizeExpr", ExactSpelling = true)] - public static extern CXCursor Type_getSizeExpr(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getSizeExpr", ExactSpelling = true)] + public static extern CXCursor Type_getSizeExpr(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getTemplateArgument", ExactSpelling = true)] - public static extern CX_TemplateArgument Type_getTemplateArgument(CXType C, [NativeTypeName("unsigned int")] uint i); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getTemplateArgument", ExactSpelling = true)] + public static extern CX_TemplateArgument Type_getTemplateArgument(CXType C, [NativeTypeName("unsigned int")] uint i); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getTemplateName", ExactSpelling = true)] - public static extern CX_TemplateName Type_getTemplateName(CXType C); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getTemplateName", ExactSpelling = true)] + public static extern CX_TemplateName Type_getTemplateName(CXType C); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getTypeClass", ExactSpelling = true)] - public static extern CX_TypeClass Type_getTypeClass(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getTypeClass", ExactSpelling = true)] + public static extern CX_TypeClass Type_getTypeClass(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getUnderlyingExpr", ExactSpelling = true)] - public static extern CXCursor Type_getUnderlyingExpr(CXType CT); + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getUnderlyingExpr", ExactSpelling = true)] + public static extern CXCursor Type_getUnderlyingExpr(CXType CT); - [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getUnderlyingType", ExactSpelling = true)] - public static extern CXType Type_getUnderlyingType(CXType CT); - } + [DllImport("libClangSharp", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clangsharp_Type_getUnderlyingType", ExactSpelling = true)] + public static extern CXType Type_getUnderlyingType(CXType CT); } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/AccessSpecifier.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/AccessSpecifier.cs index 08ecf475..38927c59 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/AccessSpecifier.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/AccessSpecifier.cs @@ -1,15 +1,14 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +public enum AccessSpecifier : byte { - public enum AccessSpecifier : byte - { - None, - Public, - Protected, - ProtectedInternal, - Internal, - PrivateProtected, - Private - } + None, + Public, + Protected, + ProtectedInternal, + Internal, + PrivateProtected, + Private } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumDesc.cs index b77d4255..9dfd2cd7 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumDesc.cs @@ -1,30 +1,29 @@ using System; using ClangSharp.Interop; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +public struct EnumDesc { - public struct EnumDesc - { - public AccessSpecifier AccessSpecifier { get; set; } - public string TypeName { get; set; } - public string EscapedName { get; set; } - public string NativeType { get; set; } - public CXSourceLocation? Location { get; set; } - public EnumFlags Flags { get; set; } + public AccessSpecifier AccessSpecifier { get; set; } + public string TypeName { get; set; } + public string EscapedName { get; set; } + public string NativeType { get; set; } + public CXSourceLocation? Location { get; set; } + public EnumFlags Flags { get; set; } - public bool IsNested + public bool IsNested + { + get { - get - { - return (Flags & EnumFlags.Nested) != 0; - } + return (Flags & EnumFlags.Nested) != 0; + } - set - { - Flags = value ? Flags | EnumFlags.Nested : Flags & ~EnumFlags.Nested; - } + set + { + Flags = value ? Flags | EnumFlags.Nested : Flags & ~EnumFlags.Nested; } - public Action WriteCustomAttrs { get; set; } - public object CustomAttrGeneratorData { get; set; } } + public Action WriteCustomAttrs { get; set; } + public object CustomAttrGeneratorData { get; set; } } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumFlags.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumFlags.cs index c96e7c4f..0e773f28 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumFlags.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumFlags.cs @@ -2,12 +2,11 @@ using System; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +[Flags] +public enum EnumFlags { - [Flags] - public enum EnumFlags - { - None = 0, - Nested = 1 << 0, - } + None = 0, + Nested = 1 << 0, } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/FieldDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/FieldDesc.cs index 040bf9bb..15ccf154 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/FieldDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/FieldDesc.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +internal struct FieldDesc { - internal struct FieldDesc - { - public AccessSpecifier AccessSpecifier { get; set; } - public string NativeTypeName { get; set; } - public string EscapedName { get; set; } - public string ParentName { get; set; } - public int? Offset { get; set; } - public bool NeedsNewKeyword { get; set; } - public bool NeedsUnscopedRef { get; set; } - public bool HasBody { get; set; } - public string InheritedFrom { get; set; } - public CXSourceLocation? Location { get; set; } - public Action WriteCustomAttrs { get; set; } - public object CustomAttrGeneratorData { get; set; } - } + public AccessSpecifier AccessSpecifier { get; set; } + public string NativeTypeName { get; set; } + public string EscapedName { get; set; } + public string ParentName { get; set; } + public int? Offset { get; set; } + public bool NeedsNewKeyword { get; set; } + public bool NeedsUnscopedRef { get; set; } + public bool HasBody { get; set; } + public string InheritedFrom { get; set; } + public CXSourceLocation? Location { get; set; } + public Action WriteCustomAttrs { get; set; } + public object CustomAttrGeneratorData { get; set; } } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/FunctionOrDelegateDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/FunctionOrDelegateDesc.cs index cce4e862..8d0dadcf 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/FunctionOrDelegateDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/FunctionOrDelegateDesc.cs @@ -4,250 +4,249 @@ using System.Runtime.InteropServices; using ClangSharp.Interop; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +internal struct FunctionOrDelegateDesc { - internal struct FunctionOrDelegateDesc + public AccessSpecifier AccessSpecifier { get; set; } + public string NativeTypeName { get; set; } + public string EscapedName { get; set; } + public string EntryPoint { get; set; } + public string ParentName { get; set; } + public string LibraryPath { get; set; } + public string ReturnType { get; set; } + public CallingConvention CallingConvention { get; set; } + public FunctionOrDelegateFlags Flags { get; set; } + public long? VtblIndex { get; set; } + public CXSourceLocation? Location { get; set; } + public bool HasBody { get; set; } + public bool IsInherited { get; set; } + public bool NeedsUnscopedRef { get; set; } + + public bool IsVirtual { - public AccessSpecifier AccessSpecifier { get; set; } - public string NativeTypeName { get; set; } - public string EscapedName { get; set; } - public string EntryPoint { get; set; } - public string ParentName { get; set; } - public string LibraryPath { get; set; } - public string ReturnType { get; set; } - public CallingConvention CallingConvention { get; set; } - public FunctionOrDelegateFlags Flags { get; set; } - public long? VtblIndex { get; set; } - public CXSourceLocation? Location { get; set; } - public bool HasBody { get; set; } - public bool IsInherited { get; set; } - public bool NeedsUnscopedRef { get; set; } - - public bool IsVirtual + get { - get - { - return (Flags & FunctionOrDelegateFlags.IsVirtual) != 0; - } - - set - { - Flags = value ? Flags | FunctionOrDelegateFlags.IsVirtual : Flags & ~FunctionOrDelegateFlags.IsVirtual; - } + return (Flags & FunctionOrDelegateFlags.IsVirtual) != 0; } - - public bool IsDllImport + + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsDllImport) != 0; - } + Flags = value ? Flags | FunctionOrDelegateFlags.IsVirtual : Flags & ~FunctionOrDelegateFlags.IsVirtual; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.IsDllImport - : Flags & ~FunctionOrDelegateFlags.IsDllImport; - } + public bool IsDllImport + { + get + { + return (Flags & FunctionOrDelegateFlags.IsDllImport) != 0; } - public bool IsManualImport + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsManualImport) != 0; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.IsDllImport + : Flags & ~FunctionOrDelegateFlags.IsDllImport; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.IsManualImport - : Flags & ~FunctionOrDelegateFlags.IsManualImport; - } + public bool IsManualImport + { + get + { + return (Flags & FunctionOrDelegateFlags.IsManualImport) != 0; } - public bool HasFnPtrCodeGen + set { - get - { - return (Flags & FunctionOrDelegateFlags.HasFnPtrCodeGen) != 0; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.IsManualImport + : Flags & ~FunctionOrDelegateFlags.IsManualImport; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.HasFnPtrCodeGen - : Flags & ~FunctionOrDelegateFlags.HasFnPtrCodeGen; - } + public bool HasFnPtrCodeGen + { + get + { + return (Flags & FunctionOrDelegateFlags.HasFnPtrCodeGen) != 0; } - public bool IsAggressivelyInlined + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsAggressivelyInlined) != 0; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.HasFnPtrCodeGen + : Flags & ~FunctionOrDelegateFlags.HasFnPtrCodeGen; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.IsAggressivelyInlined - : Flags & ~FunctionOrDelegateFlags.IsAggressivelyInlined; - } + public bool IsAggressivelyInlined + { + get + { + return (Flags & FunctionOrDelegateFlags.IsAggressivelyInlined) != 0; } - public bool SetLastError + set { - get - { - return (Flags & FunctionOrDelegateFlags.SetLastError) != 0; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.IsAggressivelyInlined + : Flags & ~FunctionOrDelegateFlags.IsAggressivelyInlined; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.SetLastError - : Flags & ~FunctionOrDelegateFlags.SetLastError; - } + public bool SetLastError + { + get + { + return (Flags & FunctionOrDelegateFlags.SetLastError) != 0; } - public bool IsCxx + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsCxx) != 0; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.SetLastError + : Flags & ~FunctionOrDelegateFlags.SetLastError; + } + } - set - { - Flags = value ? Flags | FunctionOrDelegateFlags.IsCxx : Flags & ~FunctionOrDelegateFlags.IsCxx; - } + public bool IsCxx + { + get + { + return (Flags & FunctionOrDelegateFlags.IsCxx) != 0; } - public bool NeedsNewKeyword + set { - get - { - return (Flags & FunctionOrDelegateFlags.NeedsNewKeyword) != 0; - } + Flags = value ? Flags | FunctionOrDelegateFlags.IsCxx : Flags & ~FunctionOrDelegateFlags.IsCxx; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.NeedsNewKeyword - : Flags & ~FunctionOrDelegateFlags.NeedsNewKeyword; - } + public bool NeedsNewKeyword + { + get + { + return (Flags & FunctionOrDelegateFlags.NeedsNewKeyword) != 0; } - public bool IsUnsafe + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsUnsafe) != 0; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.NeedsNewKeyword + : Flags & ~FunctionOrDelegateFlags.NeedsNewKeyword; + } + } - set - { - Flags = value ? Flags | FunctionOrDelegateFlags.IsUnsafe : Flags & ~FunctionOrDelegateFlags.IsUnsafe; - } + public bool IsUnsafe + { + get + { + return (Flags & FunctionOrDelegateFlags.IsUnsafe) != 0; } - public bool IsCtxCxxRecord + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsCtxCxxRecord) != 0; - } + Flags = value ? Flags | FunctionOrDelegateFlags.IsUnsafe : Flags & ~FunctionOrDelegateFlags.IsUnsafe; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.IsCtxCxxRecord - : Flags & ~FunctionOrDelegateFlags.IsCtxCxxRecord; - } + public bool IsCtxCxxRecord + { + get + { + return (Flags & FunctionOrDelegateFlags.IsCtxCxxRecord) != 0; } - public bool IsCxxRecordCtxUnsafe + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsCxxRecordCtxUnsafe) != 0; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.IsCtxCxxRecord + : Flags & ~FunctionOrDelegateFlags.IsCtxCxxRecord; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.IsCxxRecordCtxUnsafe - : Flags & ~FunctionOrDelegateFlags.IsCxxRecordCtxUnsafe; - } + public bool IsCxxRecordCtxUnsafe + { + get + { + return (Flags & FunctionOrDelegateFlags.IsCxxRecordCtxUnsafe) != 0; } - public bool IsMemberFunction + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsMemberFunction) != 0; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.IsCxxRecordCtxUnsafe + : Flags & ~FunctionOrDelegateFlags.IsCxxRecordCtxUnsafe; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.IsMemberFunction - : Flags & ~FunctionOrDelegateFlags.IsMemberFunction; - } + public bool IsMemberFunction + { + get + { + return (Flags & FunctionOrDelegateFlags.IsMemberFunction) != 0; } - public bool? IsStatic + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsStatic) != 0 - ? true - : (Flags & FunctionOrDelegateFlags.IsNotStatic) != 0 ? false : null; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.IsMemberFunction + : Flags & ~FunctionOrDelegateFlags.IsMemberFunction; + } + } - set - { - Flags = value switch { - // true - static, false - not static, null - infer - true => Flags | (FunctionOrDelegateFlags.IsStatic & ~FunctionOrDelegateFlags.IsNotStatic), - false => (Flags & ~FunctionOrDelegateFlags.IsStatic) | FunctionOrDelegateFlags.IsNotStatic, - null => Flags & ~FunctionOrDelegateFlags.IsStatic & ~FunctionOrDelegateFlags.IsNotStatic - }; - } + public bool? IsStatic + { + get + { + return (Flags & FunctionOrDelegateFlags.IsStatic) != 0 + ? true + : (Flags & FunctionOrDelegateFlags.IsNotStatic) != 0 ? false : null; } - public bool NeedsReturnFixup + set { - get - { - return (Flags & FunctionOrDelegateFlags.NeedsReturnFixup) != 0; - } + Flags = value switch { + // true - static, false - not static, null - infer + true => Flags | (FunctionOrDelegateFlags.IsStatic & ~FunctionOrDelegateFlags.IsNotStatic), + false => (Flags & ~FunctionOrDelegateFlags.IsStatic) | FunctionOrDelegateFlags.IsNotStatic, + null => Flags & ~FunctionOrDelegateFlags.IsStatic & ~FunctionOrDelegateFlags.IsNotStatic + }; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.NeedsReturnFixup - : Flags & ~FunctionOrDelegateFlags.NeedsReturnFixup; - } + public bool NeedsReturnFixup + { + get + { + return (Flags & FunctionOrDelegateFlags.NeedsReturnFixup) != 0; } - public bool IsCxxConstructor + set { - get - { - return (Flags & FunctionOrDelegateFlags.IsCxxConstructor) != 0; - } + Flags = value + ? Flags | FunctionOrDelegateFlags.NeedsReturnFixup + : Flags & ~FunctionOrDelegateFlags.NeedsReturnFixup; + } + } - set - { - Flags = value - ? Flags | FunctionOrDelegateFlags.IsCxxConstructor - : Flags & ~FunctionOrDelegateFlags.IsCxxConstructor; - } + public bool IsCxxConstructor + { + get + { + return (Flags & FunctionOrDelegateFlags.IsCxxConstructor) != 0; } - public Action WriteCustomAttrs { get; set; } - public object CustomAttrGeneratorData { get; set; } + set + { + Flags = value + ? Flags | FunctionOrDelegateFlags.IsCxxConstructor + : Flags & ~FunctionOrDelegateFlags.IsCxxConstructor; + } } + + public Action WriteCustomAttrs { get; set; } + public object CustomAttrGeneratorData { get; set; } } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.Visit.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.Visit.cs index 6ff97891..7a71c669 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.Visit.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.Visit.cs @@ -2,15 +2,14 @@ using System; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +internal partial interface IOutputBuilder { - internal partial interface IOutputBuilder - { - void WriteDivider(bool force = false); - void SuppressDivider(); + void WriteDivider(bool force = false); + void SuppressDivider(); - void WriteCustomAttribute(string attribute, Action callback = null); - void WriteIid(string name, Guid value); - void EmitUsingDirective(string directive); - } + void WriteCustomAttribute(string attribute, Action callback = null); + void WriteIid(string name, Guid value); + void EmitUsingDirective(string directive); } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.VisitDecl.cs index 2c89eb20..0c86e849 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.VisitDecl.cs @@ -1,78 +1,77 @@ using ClangSharp.CSharp; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +internal partial interface IOutputBuilder { - internal partial interface IOutputBuilder - { - bool IsUncheckedContext { get; } + bool IsUncheckedContext { get; } - void BeginInnerValue(); - void EndInnerValue(); + void BeginInnerValue(); + void EndInnerValue(); - void BeginInnerCast(); - void WriteCastType(string targetTypeName); - void EndInnerCast(); + void BeginInnerCast(); + void WriteCastType(string targetTypeName); + void EndInnerCast(); - void BeginUnchecked(); - void EndUnchecked(); + void BeginUnchecked(); + void EndUnchecked(); - void BeginValue(in ValueDesc desc); - void WriteConstantValue(long value); - void WriteConstantValue(ulong value); - void EndValue(in ValueDesc desc); + void BeginValue(in ValueDesc desc); + void WriteConstantValue(long value); + void WriteConstantValue(ulong value); + void EndValue(in ValueDesc desc); - void BeginEnum(in EnumDesc desc); - void EndEnum(in EnumDesc desc); + void BeginEnum(in EnumDesc desc); + void EndEnum(in EnumDesc desc); - void BeginField(in FieldDesc desc); - void WriteFixedCountField(string typeName, string escapedName, string fixedName, string count); - void WriteRegularField(string typeName, string escapedName); - void EndField(in FieldDesc desc); + void BeginField(in FieldDesc desc); + void WriteFixedCountField(string typeName, string escapedName, string fixedName, string count); + void WriteRegularField(string typeName, string escapedName); + void EndField(in FieldDesc desc); - void BeginFunctionOrDelegate(in FunctionOrDelegateDesc info, ref bool isMethodClassUnsafe); - void BeginFunctionInnerPrototype(in FunctionOrDelegateDesc info); - void BeginParameter(in ParameterDesc info); - void BeginParameterDefault(); - void EndParameterDefault(); - void EndParameter(in ParameterDesc info); - void WriteParameterSeparator(); - void EndFunctionInnerPrototype(in FunctionOrDelegateDesc info); - void BeginConstructorInitializer(string memberRefName, string memberInitName); - void EndConstructorInitializer(); - void BeginBody(bool isExpressionBody = false); - void BeginConstructorInitializers(); - void EndConstructorInitializers(); - void BeginInnerFunctionBody(); - void EndInnerFunctionBody(); - void EndBody(bool isExpressionBody = false); - void EndFunctionOrDelegate(in FunctionOrDelegateDesc info); + void BeginFunctionOrDelegate(in FunctionOrDelegateDesc info, ref bool isMethodClassUnsafe); + void BeginFunctionInnerPrototype(in FunctionOrDelegateDesc info); + void BeginParameter(in ParameterDesc info); + void BeginParameterDefault(); + void EndParameterDefault(); + void EndParameter(in ParameterDesc info); + void WriteParameterSeparator(); + void EndFunctionInnerPrototype(in FunctionOrDelegateDesc info); + void BeginConstructorInitializer(string memberRefName, string memberInitName); + void EndConstructorInitializer(); + void BeginBody(bool isExpressionBody = false); + void BeginConstructorInitializers(); + void EndConstructorInitializers(); + void BeginInnerFunctionBody(); + void EndInnerFunctionBody(); + void EndBody(bool isExpressionBody = false); + void EndFunctionOrDelegate(in FunctionOrDelegateDesc info); - void BeginStruct(in StructDesc info); - void BeginMarkerInterface(string[] baseTypeNames); - void EndMarkerInterface(); - void BeginExplicitVtbl(); - void EndExplicitVtbl(); - void EndStruct(in StructDesc info); + void BeginStruct(in StructDesc info); + void BeginMarkerInterface(string[] baseTypeNames); + void EndMarkerInterface(); + void BeginExplicitVtbl(); + void EndExplicitVtbl(); + void EndStruct(in StructDesc info); - void EmitCompatibleCodeSupport(); - void EmitFnPtrSupport(); - void EmitSystemSupport(); + void EmitCompatibleCodeSupport(); + void EmitFnPtrSupport(); + void EmitSystemSupport(); - CSharpOutputBuilder BeginCSharpCode(); - void EndCSharpCode(CSharpOutputBuilder output); + CSharpOutputBuilder BeginCSharpCode(); + void EndCSharpCode(CSharpOutputBuilder output); - void BeginGetter(bool aggressivelyInlined); - void EndGetter(); - void BeginSetter(bool aggressivelyInlined); - void EndSetter(); + void BeginGetter(bool aggressivelyInlined); + void EndGetter(); + void BeginSetter(bool aggressivelyInlined); + void EndSetter(); - void BeginIndexer(AccessSpecifier accessSpecifier, bool isUnsafe, bool needsUnscopedRef); - void WriteIndexer(string typeName); - void BeginIndexerParameters(); - void EndIndexerParameters(); - void EndIndexer(); + void BeginIndexer(AccessSpecifier accessSpecifier, bool isUnsafe, bool needsUnscopedRef); + void WriteIndexer(string typeName); + void BeginIndexerParameters(); + void EndIndexerParameters(); + void EndIndexer(); - void BeginDereference(); - void EndDereference(); - } + void BeginDereference(); + void EndDereference(); } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.cs index 380a77e2..8cfe31fb 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/IOutputBuilder.cs @@ -1,9 +1,8 @@ -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +internal partial interface IOutputBuilder { - internal partial interface IOutputBuilder - { - bool IsTestOutput { get; } - string Name { get; } - string Extension { get; } - } + bool IsTestOutput { get; } + string Name { get; } + string Extension { get; } } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/ParameterDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/ParameterDesc.cs index 5fe4d8c3..37b62be6 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/ParameterDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/ParameterDesc.cs @@ -4,17 +4,16 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +internal struct ParameterDesc { - internal struct ParameterDesc - { - public string Type { get; set; } - public string Name { get; set; } - public string NativeTypeName { get; set; } - public IEnumerable CppAttributes { get; set; } - public Action WriteCustomAttrs { get; set; } - public object CustomAttrGeneratorData { get; set; } - public CXSourceLocation? Location { get; set; } - public bool IsForManualImport { get; set; } - } + public string Type { get; set; } + public string Name { get; set; } + public string NativeTypeName { get; set; } + public IEnumerable CppAttributes { get; set; } + public Action WriteCustomAttrs { get; set; } + public object CustomAttrGeneratorData { get; set; } + public CXSourceLocation? Location { get; set; } + public bool IsForManualImport { get; set; } } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/StructDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/StructDesc.cs index 90481988..910a4518 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/StructDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/StructDesc.cs @@ -5,114 +5,113 @@ using System.Runtime.InteropServices; using ClangSharp.Interop; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +internal struct StructDesc { - internal struct StructDesc + public AccessSpecifier AccessSpecifier { get; set; } + public string EscapedName { get; set; } + public string NativeType { get; set; } + public string NativeInheritance { get; set; } + public LayoutDesc Layout { get; set; } + public Guid? Uuid { get; set; } + public StructFlags Flags { get; set; } + public CXSourceLocation? Location { get; set; } + + public bool IsNested { - public AccessSpecifier AccessSpecifier { get; set; } - public string EscapedName { get; set; } - public string NativeType { get; set; } - public string NativeInheritance { get; set; } - public LayoutDesc Layout { get; set; } - public Guid? Uuid { get; set; } - public StructFlags Flags { get; set; } - public CXSourceLocation? Location { get; set; } - - public bool IsNested + get { - get - { - return (Flags & StructFlags.Nested) != 0; - } - - set - { - Flags = value ? Flags | StructFlags.Nested : Flags & ~StructFlags.Nested; - } + return (Flags & StructFlags.Nested) != 0; } - public bool IsUnsafe + set { - get - { - return (Flags & StructFlags.Unsafe) != 0; - } - - set - { - Flags = value ? Flags | StructFlags.Unsafe : Flags & ~StructFlags.Unsafe; - } + Flags = value ? Flags | StructFlags.Nested : Flags & ~StructFlags.Nested; } + } - public bool HasVtbl + public bool IsUnsafe + { + get { - get - { - return (Flags & StructFlags.Vtbl) != 0; - } + return (Flags & StructFlags.Unsafe) != 0; + } - set - { - Flags = value ? Flags | StructFlags.Vtbl : Flags & ~StructFlags.Vtbl; - } + set + { + Flags = value ? Flags | StructFlags.Unsafe : Flags & ~StructFlags.Unsafe; } + } - public bool IsUnion + public bool HasVtbl + { + get { - get - { - return (Flags & StructFlags.Union) != 0; - } + return (Flags & StructFlags.Vtbl) != 0; + } - set - { - Flags = value ? Flags | StructFlags.Union : Flags & ~StructFlags.Union; - } + set + { + Flags = value ? Flags | StructFlags.Vtbl : Flags & ~StructFlags.Vtbl; } + } - public Action WriteCustomAttrs { get; set; } - public object CustomAttrGeneratorData { get; set; } + public bool IsUnion + { + get + { + return (Flags & StructFlags.Union) != 0; + } - public StructLayoutAttribute LayoutAttribute + set { - get - { - var layout = Layout; + Flags = value ? Flags | StructFlags.Union : Flags & ~StructFlags.Union; + } + } - if (IsUnion) - { - Debug.Assert(layout.Kind == LayoutKind.Explicit); + public Action WriteCustomAttrs { get; set; } + public object CustomAttrGeneratorData { get; set; } - var attribute = new StructLayoutAttribute(layout.Kind); + public StructLayoutAttribute LayoutAttribute + { + get + { + var layout = Layout; - if (layout.Pack != 0) - { - attribute.Pack = (int)layout.Pack; - } + if (IsUnion) + { + Debug.Assert(layout.Kind == LayoutKind.Explicit); - return attribute; - } + var attribute = new StructLayoutAttribute(layout.Kind); if (layout.Pack != 0) { - return new StructLayoutAttribute(layout.Kind) { - Pack = (int)layout.Pack - }; + attribute.Pack = (int)layout.Pack; } - return null; + return attribute; } - } - public struct LayoutDesc - { - public long Alignment32 { get; set; } - public long Alignment64 { get; set; } - public long Size32 { get; set; } - public long Size64 { get; set; } - public long Pack { get; set; } - public long MaxFieldAlignment { get; set; } - public LayoutKind Kind { get; set; } + if (layout.Pack != 0) + { + return new StructLayoutAttribute(layout.Kind) { + Pack = (int)layout.Pack + }; + } + + return null; } } + + public struct LayoutDesc + { + public long Alignment32 { get; set; } + public long Alignment64 { get; set; } + public long Size32 { get; set; } + public long Size64 { get; set; } + public long Pack { get; set; } + public long MaxFieldAlignment { get; set; } + public LayoutKind Kind { get; set; } + } } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/StructFlags.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/StructFlags.cs index 2a74fa34..e1dee003 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/StructFlags.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/StructFlags.cs @@ -2,15 +2,14 @@ using System; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +[Flags] +public enum StructFlags { - [Flags] - public enum StructFlags - { - None = 0, - Unsafe = 1 << 0, - Vtbl = 1 << 1, - Union = 1 << 2, - Nested = 1 << 3, - } + None = 0, + Unsafe = 1 << 0, + Vtbl = 1 << 1, + Union = 1 << 2, + Nested = 1 << 3, } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueDesc.cs index 1c0aa1ae..93f079e4 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueDesc.cs @@ -3,25 +3,24 @@ using System; using ClangSharp.Interop; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +internal struct ValueDesc { - internal struct ValueDesc - { - public AccessSpecifier AccessSpecifier { get; set; } - public string TypeName { get; set; } - public string EscapedName { get; set; } - public string NativeTypeName { get; set; } + public AccessSpecifier AccessSpecifier { get; set; } + public string TypeName { get; set; } + public string EscapedName { get; set; } + public string NativeTypeName { get; set; } - public string ParentName { get; set; } - public ValueKind Kind { get; set; } - public ValueFlags Flags { get; set; } - public CXSourceLocation? Location { get; set; } + public string ParentName { get; set; } + public ValueKind Kind { get; set; } + public ValueFlags Flags { get; set; } + public CXSourceLocation? Location { get; set; } - public bool HasInitializer => Flags.HasFlag(ValueFlags.Initializer); - public bool IsArray => Flags.HasFlag(ValueFlags.Array); - public bool IsConstant => Flags.HasFlag(ValueFlags.Constant); - public bool IsCopy => Flags.HasFlag(ValueFlags.Copy); - public Action WriteCustomAttrs { get; set; } - public object CustomAttrGeneratorData { get; set; } - } + public bool HasInitializer => Flags.HasFlag(ValueFlags.Initializer); + public bool IsArray => Flags.HasFlag(ValueFlags.Array); + public bool IsConstant => Flags.HasFlag(ValueFlags.Constant); + public bool IsCopy => Flags.HasFlag(ValueFlags.Copy); + public Action WriteCustomAttrs { get; set; } + public object CustomAttrGeneratorData { get; set; } } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueKind.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueKind.cs index 548d7cfe..41a2f898 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueKind.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueKind.cs @@ -1,14 +1,13 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +internal enum ValueKind { - internal enum ValueKind - { - Unknown, - Primitive, - Enumerator, - Unmanaged, - String, - GuidMember, - } + Unknown, + Primitive, + Enumerator, + Unmanaged, + String, + GuidMember, } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueModifiers.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueModifiers.cs index f677a4a5..a0baec37 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueModifiers.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueModifiers.cs @@ -2,15 +2,14 @@ using System; -namespace ClangSharp.Abstractions +namespace ClangSharp.Abstractions; + +[Flags] +internal enum ValueFlags { - [Flags] - internal enum ValueFlags - { - None = 0, - Initializer = 1 << 0, - Constant = 1 << 1, - Copy = 1 << 2, - Array = 1 << 3, - } + None = 0, + Initializer = 1 << 0, + Constant = 1 << 1, + Copy = 1 << 2, + Array = 1 << 3, } diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs index ca03e2b1..fd0ecef8 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs @@ -3,139 +3,138 @@ using System; using System.Runtime.CompilerServices; -namespace ClangSharp.CSharp +namespace ClangSharp.CSharp; + +internal partial class CSharpOutputBuilder { - internal partial class CSharpOutputBuilder + private bool _customAttrIsForParameter = false; + public void WriteCustomAttribute(string attribute, Action callback = null) { - private bool _customAttrIsForParameter = false; - public void WriteCustomAttribute(string attribute, Action callback = null) + if (attribute.Equals("Flags") || attribute.Equals("Obsolete")) { - if (attribute.Equals("Flags") || attribute.Equals("Obsolete")) - { - AddUsingDirective("System"); - } - else if (attribute.Equals("EditorBrowsable") || attribute.StartsWith("EditorBrowsable(")) - { - AddUsingDirective("System.ComponentModel"); - } - else if (attribute.Equals("UnscopedRef")) - { - AddUsingDirective("System.Diagnostics.CodeAnalysis"); - } - else if (attribute.StartsWith("Guid(")|| attribute.Equals("Optional") || attribute.StartsWith("Optional, DefaultParameterValue(")) - { - AddUsingDirective("System.Runtime.InteropServices"); - } - else if (attribute.StartsWith("SupportedOSPlatform(")) - { - AddUsingDirective("System.Runtime.Versioning"); - } + AddUsingDirective("System"); + } + else if (attribute.Equals("EditorBrowsable") || attribute.StartsWith("EditorBrowsable(")) + { + AddUsingDirective("System.ComponentModel"); + } + else if (attribute.Equals("UnscopedRef")) + { + AddUsingDirective("System.Diagnostics.CodeAnalysis"); + } + else if (attribute.StartsWith("Guid(")|| attribute.Equals("Optional") || attribute.StartsWith("Optional, DefaultParameterValue(")) + { + AddUsingDirective("System.Runtime.InteropServices"); + } + else if (attribute.StartsWith("SupportedOSPlatform(")) + { + AddUsingDirective("System.Runtime.Versioning"); + } - if (!_customAttrIsForParameter) - { - WriteIndentation(); - } + if (!_customAttrIsForParameter) + { + WriteIndentation(); + } - Write('['); - Write(attribute); - callback?.Invoke(); - Write(']'); + Write('['); + Write(attribute); + callback?.Invoke(); + Write(']'); - if (!_customAttrIsForParameter) - { - WriteNewline(); - } - else - { - Write(' '); - } + if (!_customAttrIsForParameter) + { + WriteNewline(); + } + else + { + Write(' '); } + } - public void WriteDivider(bool force = false) + public void WriteDivider(bool force = false) + { + if (force) { - if (force) - { - WriteNewline(); - } - else - { - NeedsNewline = true; - } + WriteNewline(); } + else + { + NeedsNewline = true; + } + } - public void SuppressDivider() => NeedsNewline = false; + public void SuppressDivider() => NeedsNewline = false; - public void WriteIid(string name, Guid value) + public void WriteIid(string name, Guid value) + { + if (_config.GenerateUnmanagedConstants) { - if (_config.GenerateUnmanagedConstants) - { - AddUsingDirective("System"); - AddUsingDirective("System.Diagnostics"); - AddUsingDirective("System.Runtime.CompilerServices"); - AddUsingDirective("System.Runtime.InteropServices"); + AddUsingDirective("System"); + AddUsingDirective("System.Diagnostics"); + AddUsingDirective("System.Runtime.CompilerServices"); + AddUsingDirective("System.Runtime.InteropServices"); - WriteIndented("public static ref readonly Guid "); - WriteLine(name); - WriteBlockStart(); + WriteIndented("public static ref readonly Guid "); + WriteLine(name); + WriteBlockStart(); - WriteIndentedLine("get"); - WriteBlockStart(); + WriteIndentedLine("get"); + WriteBlockStart(); - WriteIndentedLine("ReadOnlySpan data = new byte[] {"); - IncreaseIndentation(); - WriteIndentation(); + WriteIndentedLine("ReadOnlySpan data = new byte[] {"); + IncreaseIndentation(); + WriteIndentation(); - WriteValueAsBytes(Unsafe.As(ref value), 4); + WriteValueAsBytes(Unsafe.As(ref value), 4); - WriteLine(','); - WriteIndentation(); + WriteLine(','); + WriteIndentation(); - WriteValueAsBytes(Unsafe.As(ref Unsafe.AddByteOffset(ref value, (nint)4)), 2); + WriteValueAsBytes(Unsafe.As(ref Unsafe.AddByteOffset(ref value, (nint)4)), 2); - WriteLine(','); - WriteIndentation(); + WriteLine(','); + WriteIndentation(); - WriteValueAsBytes(Unsafe.As(ref Unsafe.AddByteOffset(ref value, (nint)6)), 2); + WriteValueAsBytes(Unsafe.As(ref Unsafe.AddByteOffset(ref value, (nint)6)), 2); - for (var i = 8; i < 16; i++) - { - WriteLine(','); - WriteIndentation(); + for (var i = 8; i < 16; i++) + { + WriteLine(','); + WriteIndentation(); - WriteValueAsBytes(Unsafe.As(ref Unsafe.AddByteOffset(ref value, (nint)i)), 1); - } + WriteValueAsBytes(Unsafe.As(ref Unsafe.AddByteOffset(ref value, (nint)i)), 1); + } - WriteNewline(); - DecreaseIndentation(); - WriteIndentedLine("};"); + WriteNewline(); + DecreaseIndentation(); + WriteIndentedLine("};"); - NeedsNewline = true; + NeedsNewline = true; - WriteIndentedLine("Debug.Assert(data.Length == Unsafe.SizeOf());"); - WriteIndentedLine("return ref Unsafe.As(ref MemoryMarshal.GetReference(data));"); + WriteIndentedLine("Debug.Assert(data.Length == Unsafe.SizeOf());"); + WriteIndentedLine("return ref Unsafe.As(ref MemoryMarshal.GetReference(data));"); - WriteBlockEnd(); - WriteBlockEnd(); - } - else - { - var valueString = value.ToString("X").ToUpperInvariant().Replace("{", "").Replace("}", "").Replace('X', 'x').Replace(",", ", "); - WriteIid(name, valueString); - } + WriteBlockEnd(); + WriteBlockEnd(); } - - public void WriteIid(string name, string value) + else { - AddUsingDirective("System"); - WriteIndented("public static readonly Guid "); - Write(name); - Write(" = new Guid("); - Write(value); - Write(")"); - WriteSemicolon(); - WriteNewline(); + var valueString = value.ToString("X").ToUpperInvariant().Replace("{", "").Replace("}", "").Replace('X', 'x').Replace(",", ", "); + WriteIid(name, valueString); } + } - public void EmitUsingDirective(string directive) => AddUsingDirective(directive); + public void WriteIid(string name, string value) + { + AddUsingDirective("System"); + WriteIndented("public static readonly Guid "); + Write(name); + Write(" = new Guid("); + Write(value); + Write(")"); + WriteSemicolon(); + WriteNewline(); } + + public void EmitUsingDirective(string directive) => AddUsingDirective(directive); } diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs index 6a1a48ec..892481d2 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs @@ -6,989 +6,988 @@ using ClangSharp.Abstractions; using ClangSharp.Interop; -namespace ClangSharp.CSharp +namespace ClangSharp.CSharp; + +internal partial class CSharpOutputBuilder : IOutputBuilder { - internal partial class CSharpOutputBuilder : IOutputBuilder - { - public void BeginInnerValue() => Write('('); - public void EndInnerValue() => Write(')'); + public void BeginInnerValue() => Write('('); + public void EndInnerValue() => Write(')'); + + public void BeginInnerCast() => Write('('); + public void WriteCastType(string targetTypeName) => Write(targetTypeName); + public void EndInnerCast() => Write(')'); - public void BeginInnerCast() => Write('('); - public void WriteCastType(string targetTypeName) => Write(targetTypeName); - public void EndInnerCast() => Write(')'); + public void BeginUnchecked() + { + Debug.Assert(!IsUncheckedContext); + Write("unchecked"); + IsUncheckedContext = true; + } + public void EndUnchecked() + { + Debug.Assert(IsUncheckedContext); + IsUncheckedContext = false; + } - public void BeginUnchecked() + public void BeginValue(in ValueDesc desc) + { + if (_config.GenerateDocIncludes && (desc.Kind == ValueKind.Enumerator)) { - Debug.Assert(!IsUncheckedContext); - Write("unchecked"); - IsUncheckedContext = true; + WriteIndented("/// "); } - public void EndUnchecked() + + if (desc.NativeTypeName is not null) { - Debug.Assert(IsUncheckedContext); - IsUncheckedContext = false; + AddNativeTypeNameAttribute(desc.NativeTypeName); } - public void BeginValue(in ValueDesc desc) + if (desc.Location is { } location) { - if (_config.GenerateDocIncludes && (desc.Kind == ValueKind.Enumerator)) - { - WriteIndented("/// "); - } - - if (desc.NativeTypeName is not null) - { - AddNativeTypeNameAttribute(desc.NativeTypeName); - } - - if (desc.Location is { } location) - { - WriteSourceLocation(location, false); - } + WriteSourceLocation(location, false); + } - desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); + desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - var isProperty = false; - var isExpressionBody = false; + var isProperty = false; + var isExpressionBody = false; - if (desc.Kind == ValueKind.String) - { - isExpressionBody = true; - } - else if (desc.IsConstant) + if (desc.Kind == ValueKind.String) + { + isExpressionBody = true; + } + else if (desc.IsConstant) + { + if (_config.GenerateUnmanagedConstants && (desc.Kind != ValueKind.Enumerator)) { - if (_config.GenerateUnmanagedConstants && (desc.Kind != ValueKind.Enumerator)) + if (desc.IsCopy) { - if (desc.IsCopy) - { - isExpressionBody = true; - } - else if (desc.Kind == ValueKind.Unmanaged) - { - isProperty = true; - } + isExpressionBody = true; + } + else if (desc.Kind == ValueKind.Unmanaged) + { + isProperty = true; } } + } - WriteIndentation(); + WriteIndentation(); - if (desc.Kind == ValueKind.Primitive) - { - Write(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); + if (desc.Kind == ValueKind.Primitive) + { + Write(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); - if (desc.IsConstant) + if (desc.IsConstant) + { + if (desc.IsCopy) { - if (desc.IsCopy) - { - Write(" static "); + Write(" static "); - if (!_config.GenerateUnmanagedConstants) - { - Write("readonly "); - } - } - else + if (!_config.GenerateUnmanagedConstants) { - Write(" const "); + Write("readonly "); } } else { - Write(" static "); + Write(" const "); } - - Write(desc.TypeName); - Write(' '); } - else if (desc.Kind == ValueKind.Unmanaged) + else { - Write(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); Write(" static "); + } - if (_config.GenerateUnmanagedConstants && desc.IsConstant) - { - if (desc.IsArray) - { - Write("ReadOnlySpan<"); - } - else - { - Write("ref readonly "); - } - - Write(desc.TypeName); + Write(desc.TypeName); + Write(' '); + } + else if (desc.Kind == ValueKind.Unmanaged) + { + Write(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); + Write(" static "); - if (desc.IsArray) - { - Write('>'); - } + if (_config.GenerateUnmanagedConstants && desc.IsConstant) + { + if (desc.IsArray) + { + Write("ReadOnlySpan<"); } else { - if (desc.IsConstant) - { - Write("readonly "); - } - Write(desc.TypeName); + Write("ref readonly "); } - Write(' '); - } - else if (desc.Kind == ValueKind.String) - { - Write(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); - Write(" static "); + Write(desc.TypeName); - if (desc.TypeName is "byte[]" or "uint[]") + if (desc.IsArray) { - if (desc.IsConstant) - { - Write("readonly "); - } - isExpressionBody = false; + Write('>'); } - - Write(desc.TypeName); - Write(' '); } - else if (desc.Kind == ValueKind.GuidMember) + else { - Write("static "); + if (desc.IsConstant) + { + Write("readonly "); + } Write(desc.TypeName); - Write(' '); - isExpressionBody = true; } - Write(desc.EscapedName); + Write(' '); + } + else if (desc.Kind == ValueKind.String) + { + Write(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); + Write(" static "); - if (desc.HasInitializer) + if (desc.TypeName is "byte[]" or "uint[]") { - if (isExpressionBody) - { - Write(" => "); - } - else if (isProperty) - { - WriteNewline(); - WriteBlockStart(); - BeginGetter(desc.IsConstant && _config.GenerateAggressiveInlining); - } - else + if (desc.IsConstant) { - Write(" = "); + Write("readonly "); } + isExpressionBody = false; } - } - - public void WriteConstantValue(long value) => Write(value); - public void WriteConstantValue(ulong value) => Write(value); - public void EndValue(in ValueDesc desc) + Write(desc.TypeName); + Write(' '); + } + else if (desc.Kind == ValueKind.GuidMember) { - switch (desc.Kind) - { - case ValueKind.Primitive: - { - WriteLine(';'); - break; - } - - case ValueKind.Enumerator: - { - WriteLine(','); - - if (_config.GenerateDocIncludes) - { - NeedsNewline = true; - } - break; - } - - case ValueKind.Unmanaged: - { - if (desc.IsConstant) - { - if (_config.GenerateUnmanagedConstants && !desc.IsCopy) - { - EndGetter(); - WriteBlockEnd(); - } - else - { - WriteLine(';'); - } - } - break; - } - - case ValueKind.String: - { - WriteLine(';'); - break; - } - - case ValueKind.GuidMember: - { - WriteLine(';'); - NeedsNewline = true; - break; - } - } + Write("static "); + Write(desc.TypeName); + Write(' '); + isExpressionBody = true; } - public void BeginEnum(in EnumDesc desc) - { - if (_config.GenerateDocIncludes) - { - WriteIndented("/// "); - } + Write(desc.EscapedName); - if (desc.NativeType is not null) + if (desc.HasInitializer) + { + if (isExpressionBody) { - AddNativeTypeNameAttribute(desc.NativeType); + Write(" => "); } - - if (desc.Location is {} location) + else if (isProperty) { - WriteSourceLocation(location, false); + WriteNewline(); + WriteBlockStart(); + BeginGetter(desc.IsConstant && _config.GenerateAggressiveInlining); } - - desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - - WriteIndented(GetAccessSpecifierString(desc.AccessSpecifier, desc.IsNested)); - Write(" enum "); - Write(desc.EscapedName); - - if (!desc.TypeName.Equals("int")) + else { - Write(" : "); - Write(desc.TypeName); + Write(" = "); } - - NeedsNewline = true; - WriteBlockStart(); } + } - public void EndEnum(in EnumDesc desc) => WriteBlockEnd(); + public void WriteConstantValue(long value) => Write(value); + public void WriteConstantValue(ulong value) => Write(value); - public void BeginField(in FieldDesc desc) + public void EndValue(in ValueDesc desc) + { + switch (desc.Kind) { - if (_config.GenerateDocIncludes && !string.IsNullOrWhiteSpace(desc.ParentName)) + case ValueKind.Primitive: { - WriteIndented("/// "); + WriteLine(';'); + break; } - if (desc.Offset is not null) + case ValueKind.Enumerator: { - WriteIndentedLine($"[FieldOffset({desc.Offset})]"); - } + WriteLine(','); - if (desc.NativeTypeName is not null) - { - AddNativeTypeNameAttribute(desc.NativeTypeName); + if (_config.GenerateDocIncludes) + { + NeedsNewline = true; + } + break; } - if (desc.Location is { } location) + case ValueKind.Unmanaged: { - WriteSourceLocation(location, false); + if (desc.IsConstant) + { + if (_config.GenerateUnmanagedConstants && !desc.IsCopy) + { + EndGetter(); + WriteBlockEnd(); + } + else + { + WriteLine(';'); + } + } + break; } - desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - - if (desc.NeedsUnscopedRef) + case ValueKind.String: { - WriteCustomAttribute("UnscopedRef"); + WriteLine(';'); + break; } - WriteIndented(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); - Write(' '); - - if (desc.NeedsNewKeyword) + case ValueKind.GuidMember: { - Write("new "); + WriteLine(';'); + NeedsNewline = true; + break; } } + } - public void WriteFixedCountField(string typeName, string escapedName, string fixedName, string count) + public void BeginEnum(in EnumDesc desc) + { + if (_config.GenerateDocIncludes) { - if (PInvokeGenerator.IsSupportedFixedSizedBufferType(typeName)) - { - Write("fixed "); - Write(typeName); - Write(' '); - Write(escapedName); - Write('['); - Write(count); - Write(']'); - } - else - { - Write(fixedName); - Write(' '); - Write(escapedName); - } + WriteIndented("/// "); } - public void WriteRegularField(string typeName, string escapedName) + if (desc.NativeType is not null) { - Write(typeName); - Write(' '); - Write(escapedName); + AddNativeTypeNameAttribute(desc.NativeType); } - public void EndField(in FieldDesc desc) + if (desc.Location is {} location) { - if (!desc.HasBody) - { - WriteSemicolon(); - WriteNewline(); - NeedsNewline = true; - } + WriteSourceLocation(location, false); } - public void BeginFunctionOrDelegate(in FunctionOrDelegateDesc desc, ref bool isMethodClassUnsafe) - { - if (_config.GenerateDocIncludes && !string.IsNullOrEmpty(desc.ParentName)) - { - if (desc.IsInherited) - { - WriteIndented("/// "); - } - else - { - WriteIndented("/// "); - } - } - - if (desc.IsVirtual) - { - Debug.Assert(!desc.HasFnPtrCodeGen); - - AddUsingDirective("System.Runtime.InteropServices"); - WriteIndented("[UnmanagedFunctionPointer"); - - if (desc.CallingConvention != CallingConvention.Winapi) - { - Write("(CallingConvention."); - Write(desc.CallingConvention); - Write(')'); - } - - WriteLine(']'); - } - else if (desc.IsDllImport && !desc.IsManualImport) - { - AddUsingDirective("System.Runtime.InteropServices"); + desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - WriteIndented("[DllImport("); + WriteIndented(GetAccessSpecifierString(desc.AccessSpecifier, desc.IsNested)); + Write(" enum "); + Write(desc.EscapedName); - Write('"'); - Write(desc.LibraryPath); - Write('"'); + if (!desc.TypeName.Equals("int")) + { + Write(" : "); + Write(desc.TypeName); + } - Write(", "); + NeedsNewline = true; + WriteBlockStart(); + } - if (desc.CallingConvention != CallingConvention.Winapi) - { - Write("CallingConvention = CallingConvention."); - Write(desc.CallingConvention); - Write(", "); - } + public void EndEnum(in EnumDesc desc) => WriteBlockEnd(); - if (desc.EntryPoint != desc.EscapedName) - { - Write("EntryPoint = \""); - Write(desc.EntryPoint); - Write("\", "); - } - - Write("ExactSpelling = true"); + public void BeginField(in FieldDesc desc) + { + if (_config.GenerateDocIncludes && !string.IsNullOrWhiteSpace(desc.ParentName)) + { + WriteIndented("/// "); + } - if (desc.SetLastError && !_config.GenerateSetsLastSystemErrorAttribute) - { - Write(", SetLastError = true"); - } + if (desc.Offset is not null) + { + WriteIndentedLine($"[FieldOffset({desc.Offset})]"); + } - WriteLine(")]"); - } + if (desc.NativeTypeName is not null) + { + AddNativeTypeNameAttribute(desc.NativeTypeName); + } - if (desc.Location is {} location) - { - WriteSourceLocation(location, false); - } + if (desc.Location is { } location) + { + WriteSourceLocation(location, false); + } - if (desc.SetLastError && _config.GenerateSetsLastSystemErrorAttribute) - { - WriteIndentedLine("[SetsLastSystemError]"); - } + desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - if (desc.IsAggressivelyInlined) - { - AddUsingDirective("System.Runtime.CompilerServices"); - WriteIndentedLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]"); - } + if (desc.NeedsUnscopedRef) + { + WriteCustomAttribute("UnscopedRef"); + } - var vtblIndex = desc.VtblIndex ?? -1; + WriteIndented(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); + Write(' '); - if (vtblIndex != -1) - { - AddVtblIndexAttribute(vtblIndex); - } + if (desc.NeedsNewKeyword) + { + Write("new "); + } + } - if ((desc.NativeTypeName is not null) && !desc.IsManualImport) - { - AddNativeTypeNameAttribute(desc.NativeTypeName, attributePrefix: "return: "); - } + public void WriteFixedCountField(string typeName, string escapedName, string fixedName, string count) + { + if (PInvokeGenerator.IsSupportedFixedSizedBufferType(typeName)) + { + Write("fixed "); + Write(typeName); + Write(' '); + Write(escapedName); + Write('['); + Write(count); + Write(']'); + } + else + { + Write(fixedName); + Write(' '); + Write(escapedName); + } + } - desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); + public void WriteRegularField(string typeName, string escapedName) + { + Write(typeName); + Write(' '); + Write(escapedName); + } - if (desc.NeedsUnscopedRef) - { - WriteCustomAttribute("UnscopedRef"); - } + public void EndField(in FieldDesc desc) + { + if (!desc.HasBody) + { + WriteSemicolon(); + WriteNewline(); + NeedsNewline = true; + } + } - if (_isInMarkerInterface) + public void BeginFunctionOrDelegate(in FunctionOrDelegateDesc desc, ref bool isMethodClassUnsafe) + { + if (_config.GenerateDocIncludes && !string.IsNullOrEmpty(desc.ParentName)) + { + if (desc.IsInherited) { - WriteIndentation(); + WriteIndented("/// "); } else { - WriteIndented(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); - Write(' '); + WriteIndented("/// "); } + } - if (!desc.IsMemberFunction) - { - if (desc.IsVirtual) - { - if (desc.IsUnsafe && !desc.IsCxxRecordCtxUnsafe) - { - Write("unsafe "); - } - Write("delegate "); - } - else if ((desc.IsStatic ?? (desc.IsDllImport || !desc.IsCxx)) && !desc.IsManualImport) - { - Write("static "); + if (desc.IsVirtual) + { + Debug.Assert(!desc.HasFnPtrCodeGen); - if (desc.IsDllImport) - { - Write("extern "); - } - } - } + AddUsingDirective("System.Runtime.InteropServices"); + WriteIndented("[UnmanagedFunctionPointer"); - if (!desc.IsVirtual) + if (desc.CallingConvention != CallingConvention.Winapi) { - if (desc.NeedsNewKeyword) - { - Write("new "); - } - - if (desc.IsUnsafe) - { - if (!desc.IsCtxCxxRecord) - { - isMethodClassUnsafe = true; - } - else if (!desc.IsCxxRecordCtxUnsafe) - { - Write("unsafe "); - } - } + Write("(CallingConvention."); + Write(desc.CallingConvention); + Write(')'); } - if (!desc.IsCxxConstructor && !desc.IsManualImport) - { - Write(desc.ReturnType); - Write(' '); - } + WriteLine(']'); } - - private void WriteSourceLocation(CXSourceLocation location, bool inline) + else if (desc.IsDllImport && !desc.IsManualImport) { - if (!_writeSourceLocation) - { - return; - } + AddUsingDirective("System.Runtime.InteropServices"); - if (!inline) - { - WriteIndentation(); - } + WriteIndented("[DllImport("); + + Write('"'); + Write(desc.LibraryPath); + Write('"'); - Write("[SourceLocation(\""); - location.GetFileLocation(out var file, out var line, out var column, out _); - Write(PInvokeGenerator.EscapeString(file.Name.ToString())); - Write("\", "); - Write(line); Write(", "); - Write(column); - Write(")]"); - if (!inline) - { - WriteNewline(); - } - else + if (desc.CallingConvention != CallingConvention.Winapi) { - Write(' '); + Write("CallingConvention = CallingConvention."); + Write(desc.CallingConvention); + Write(", "); } - } - public void BeginFunctionInnerPrototype(in FunctionOrDelegateDesc desc) - { - if (desc.IsManualImport) + if (desc.EntryPoint != desc.EscapedName) { - Write("delegate* unmanaged"); + Write("EntryPoint = \""); + Write(desc.EntryPoint); + Write("\", "); + } - if (desc.CallingConvention != CallingConvention.Winapi) - { - Write('['); - Write(desc.CallingConvention); - Write(']'); - } + Write("ExactSpelling = true"); - Write('<'); - } - else + if (desc.SetLastError && !_config.GenerateSetsLastSystemErrorAttribute) { - Write(desc.EscapedName); - Write('('); + Write(", SetLastError = true"); } + + WriteLine(")]"); } - public void BeginParameter(in ParameterDesc info) + if (desc.Location is {} location) { - if (info.IsForManualImport) - { - Write(info.Type); - } - else - { - if (info.NativeTypeName is not null) - { - AddNativeTypeNameAttribute(info.NativeTypeName, prefix: "", postfix: " "); - } + WriteSourceLocation(location, false); + } - if (info.CppAttributes is not null) - { - AddCppAttributes(info.CppAttributes, prefix: "", postfix: " "); - } + if (desc.SetLastError && _config.GenerateSetsLastSystemErrorAttribute) + { + WriteIndentedLine("[SetsLastSystemError]"); + } - if (info.Location is { } location) - { - WriteSourceLocation(location, true); - } + if (desc.IsAggressivelyInlined) + { + AddUsingDirective("System.Runtime.CompilerServices"); + WriteIndentedLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]"); + } - _customAttrIsForParameter = true; - info.WriteCustomAttrs?.Invoke(info.CustomAttrGeneratorData); - _customAttrIsForParameter = false; + var vtblIndex = desc.VtblIndex ?? -1; - Write(info.Type); - if (info.Name.Length > 0) - { - Write(' '); - Write(info.Name); - } - } + if (vtblIndex != -1) + { + AddVtblIndexAttribute(vtblIndex); } - public void BeginParameterDefault() => Write(" = "); - - public void EndParameterDefault() + if ((desc.NativeTypeName is not null) && !desc.IsManualImport) { - // nop, used only by XML + AddNativeTypeNameAttribute(desc.NativeTypeName, attributePrefix: "return: "); } - public void EndParameter(in ParameterDesc info) + desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); + + if (desc.NeedsUnscopedRef) { - // nop, used only by XML + WriteCustomAttribute("UnscopedRef"); } - public void WriteParameterSeparator() + if (_isInMarkerInterface) + { + WriteIndentation(); + } + else { - Write(','); + WriteIndented(GetAccessSpecifierString(desc.AccessSpecifier, isNested: true)); Write(' '); } - public void EndFunctionInnerPrototype(in FunctionOrDelegateDesc desc) + if (!desc.IsMemberFunction) { - if (desc.IsManualImport) + if (desc.IsVirtual) { - Write(desc.ReturnType); - Write('>'); + if (desc.IsUnsafe && !desc.IsCxxRecordCtxUnsafe) + { + Write("unsafe "); + } + Write("delegate "); } - else + else if ((desc.IsStatic ?? (desc.IsDllImport || !desc.IsCxx)) && !desc.IsManualImport) { - Write(')'); + Write("static "); + + if (desc.IsDllImport) + { + Write("extern "); + } } } - public void BeginConstructorInitializer(string memberRefName, string memberInitName) + if (!desc.IsVirtual) { - WriteIndentation(); - if (memberRefName.Equals(memberInitName)) + if (desc.NeedsNewKeyword) { - Write("this"); - Write('.'); + Write("new "); } - Write(memberRefName); - Write(' '); - Write('='); - Write(' '); - } - - public void EndConstructorInitializer() - { - WriteSemicolon(); - WriteNewline(); + if (desc.IsUnsafe) + { + if (!desc.IsCtxCxxRecord) + { + isMethodClassUnsafe = true; + } + else if (!desc.IsCxxRecordCtxUnsafe) + { + Write("unsafe "); + } + } } - public void BeginBody(bool isExpressionBody = false) + if (!desc.IsCxxConstructor && !desc.IsManualImport) { - if (isExpressionBody) - { - Write(" => "); - } - else - { - NeedsNewline = true; - WriteBlockStart(); - } + Write(desc.ReturnType); + Write(' '); } + } - public void BeginConstructorInitializers() + private void WriteSourceLocation(CXSourceLocation location, bool inline) + { + if (!_writeSourceLocation) { - // nop, method only exists for consistency and/or future use + return; } - public void EndConstructorInitializers() + if (!inline) { - // nop, method only exists for consistency and/or future use + WriteIndentation(); } - public void BeginInnerFunctionBody() => WriteIndentation(); + Write("[SourceLocation(\""); + location.GetFileLocation(out var file, out var line, out var column, out _); + Write(PInvokeGenerator.EscapeString(file.Name.ToString())); + Write("\", "); + Write(line); + Write(", "); + Write(column); + Write(")]"); - public void EndInnerFunctionBody() + if (!inline) { - // nop, used only by XML + WriteNewline(); } - - public void EndBody(bool isExpressionBody = false) + else { - WriteSemicolonIfNeeded(); - WriteNewlineIfNeeded(); - if (!isExpressionBody) - { - WriteBlockEnd(); - } + Write(' '); } + } - public void EndFunctionOrDelegate(in FunctionOrDelegateDesc desc) + public void BeginFunctionInnerPrototype(in FunctionOrDelegateDesc desc) + { + if (desc.IsManualImport) { - if (desc.IsManualImport) - { - Write(' '); - Write(desc.EscapedName); - } + Write("delegate* unmanaged"); - if (!desc.HasBody || desc.IsVirtual) + if (desc.CallingConvention != CallingConvention.Winapi) { - WriteSemicolon(); - WriteNewline(); + Write('['); + Write(desc.CallingConvention); + Write(']'); } - NeedsNewline = true; + Write('<'); + } + else + { + Write(desc.EscapedName); + Write('('); } + } - public void BeginStruct(in StructDesc desc) + public void BeginParameter(in ParameterDesc info) + { + if (info.IsForManualImport) + { + Write(info.Type); + } + else { - if (_config.GenerateDocIncludes) + if (info.NativeTypeName is not null) { - WriteIndented("/// "); + AddNativeTypeNameAttribute(info.NativeTypeName, prefix: "", postfix: " "); } - if (desc.LayoutAttribute is not null) + if (info.CppAttributes is not null) { - AddUsingDirective("System.Runtime.InteropServices"); - WriteIndented("[StructLayout(LayoutKind."); - Write(desc.LayoutAttribute.Value); - - if (desc.LayoutAttribute.Pack != 0) - { - Write(", Pack = "); - Write(desc.LayoutAttribute.Pack); - } - - WriteLine(")]"); + AddCppAttributes(info.CppAttributes, prefix: "", postfix: " "); } - if (desc.Uuid is not null) + if (info.Location is { } location) { - AddUsingDirective("System.Runtime.InteropServices"); - - WriteIndented("[Guid(\""); - Write(desc.Uuid.Value.ToString("D", CultureInfo.InvariantCulture).ToUpperInvariant()); - WriteLine("\")]"); + WriteSourceLocation(location, true); } - if (desc.NativeType is not null) - { - AddNativeTypeNameAttribute(desc.NativeType); - } + _customAttrIsForParameter = true; + info.WriteCustomAttrs?.Invoke(info.CustomAttrGeneratorData); + _customAttrIsForParameter = false; - if (desc.NativeInheritance is not null) + Write(info.Type); + if (info.Name.Length > 0) { - AddNativeInheritanceAttribute(desc.NativeInheritance); + Write(' '); + Write(info.Name); } + } + } - if (desc.Location is {} location) - { - WriteSourceLocation(location, false); - } + public void BeginParameterDefault() => Write(" = "); - desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); + public void EndParameterDefault() + { + // nop, used only by XML + } - WriteIndented(GetAccessSpecifierString(desc.AccessSpecifier, desc.IsNested)); - Write(' '); + public void EndParameter(in ParameterDesc info) + { + // nop, used only by XML + } - if (desc.IsUnsafe) - { - Write("unsafe "); - } + public void WriteParameterSeparator() + { + Write(','); + Write(' '); + } - Write("partial struct "); - Write(desc.EscapedName); + public void EndFunctionInnerPrototype(in FunctionOrDelegateDesc desc) + { + if (desc.IsManualImport) + { + Write(desc.ReturnType); + Write('>'); + } + else + { + Write(')'); + } + } - if (_config.GenerateMarkerInterfaces) - { - if (desc.HasVtbl) - { - Write(" : "); - Write(desc.EscapedName); - Write(".Interface"); - } + public void BeginConstructorInitializer(string memberRefName, string memberInitName) + { + WriteIndentation(); + if (memberRefName.Equals(memberInitName)) + { + Write("this"); + Write('.'); + } - if ((desc.Uuid is not null) && _config.GenerateGuidMember && _config.GeneratePreviewCode) - { - Write(desc.HasVtbl ? ", " : " : "); - Write("INativeGuid"); - } - } + Write(memberRefName); + Write(' '); + Write('='); + Write(' '); + } - WriteNewline(); + public void EndConstructorInitializer() + { + WriteSemicolon(); + WriteNewline(); + } + + public void BeginBody(bool isExpressionBody = false) + { + if (isExpressionBody) + { + Write(" => "); + } + else + { + NeedsNewline = true; WriteBlockStart(); } + } - public void BeginMarkerInterface(string[] baseTypeNames) - { - WriteIndented("public interface Interface"); + public void BeginConstructorInitializers() + { + // nop, method only exists for consistency and/or future use + } - if (baseTypeNames is not null) - { - Write(" : "); - Write(baseTypeNames[0]); - Write(".Interface"); + public void EndConstructorInitializers() + { + // nop, method only exists for consistency and/or future use + } - for (var i = 1; i < baseTypeNames.Length; i++) - { - Write(", "); - Write(baseTypeNames[i]); - Write(".Interface"); - } - } + public void BeginInnerFunctionBody() => WriteIndentation(); + + public void EndInnerFunctionBody() + { + // nop, used only by XML + } + + public void EndBody(bool isExpressionBody = false) + { + WriteSemicolonIfNeeded(); + WriteNewlineIfNeeded(); + if (!isExpressionBody) + { + WriteBlockEnd(); + } + } + + public void EndFunctionOrDelegate(in FunctionOrDelegateDesc desc) + { + if (desc.IsManualImport) + { + Write(' '); + Write(desc.EscapedName); + } + if (!desc.HasBody || desc.IsVirtual) + { + WriteSemicolon(); WriteNewline(); - WriteBlockStart(); - _isInMarkerInterface = true; } - public void BeginExplicitVtbl() + NeedsNewline = true; + } + + public void BeginStruct(in StructDesc desc) + { + if (_config.GenerateDocIncludes) { - WriteIndented("public partial struct Vtbl"); + WriteIndented("/// "); + } - if (_config.GenerateMarkerInterfaces && !_config.ExcludeFnptrCodegen) - { - WriteLine(""); - IncreaseIndentation(); - WriteIndentedLine("where TSelf : unmanaged, Interface"); - DecreaseIndentation(); - } - else + if (desc.LayoutAttribute is not null) + { + AddUsingDirective("System.Runtime.InteropServices"); + WriteIndented("[StructLayout(LayoutKind."); + Write(desc.LayoutAttribute.Value); + + if (desc.LayoutAttribute.Pack != 0) { - WriteNewline(); + Write(", Pack = "); + Write(desc.LayoutAttribute.Pack); } - WriteBlockStart(); + WriteLine(")]"); } - public void EmitCompatibleCodeSupport() => AddUsingDirective("System.Runtime.CompilerServices"); - - public void EmitFnPtrSupport() + if (desc.Uuid is not null) { - AddUsingDirective("System"); AddUsingDirective("System.Runtime.InteropServices"); + + WriteIndented("[Guid(\""); + Write(desc.Uuid.Value.ToString("D", CultureInfo.InvariantCulture).ToUpperInvariant()); + WriteLine("\")]"); } - public void EmitSystemSupport() => AddUsingDirective("System"); + if (desc.NativeType is not null) + { + AddNativeTypeNameAttribute(desc.NativeType); + } - public void EndStruct(in StructDesc desc) => WriteBlockEnd(); + if (desc.NativeInheritance is not null) + { + AddNativeInheritanceAttribute(desc.NativeInheritance); + } - public void EndMarkerInterface() + if (desc.Location is {} location) { - _isInMarkerInterface = false; - WriteBlockEnd(); + WriteSourceLocation(location, false); } - public void EndExplicitVtbl() => WriteBlockEnd(); + desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - public CSharpOutputBuilder BeginCSharpCode() => - // just write directly to this buffer - this; + WriteIndented(GetAccessSpecifierString(desc.AccessSpecifier, desc.IsNested)); + Write(' '); - public void EndCSharpCode(CSharpOutputBuilder output) + if (desc.IsUnsafe) { - // nop, used only by XML + Write("unsafe "); } - public void BeginGetter(bool aggressivelyInlined) + Write("partial struct "); + Write(desc.EscapedName); + + if (_config.GenerateMarkerInterfaces) { - if (aggressivelyInlined) + if (desc.HasVtbl) { - AddUsingDirective("System.Runtime.CompilerServices"); - WriteIndentedLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]"); + Write(" : "); + Write(desc.EscapedName); + Write(".Interface"); } - WriteIndentedLine("get"); - WriteBlockStart(); + if ((desc.Uuid is not null) && _config.GenerateGuidMember && _config.GeneratePreviewCode) + { + Write(desc.HasVtbl ? ", " : " : "); + Write("INativeGuid"); + } } - public void EndGetter() => WriteBlockEnd(); + WriteNewline(); + WriteBlockStart(); + } + + public void BeginMarkerInterface(string[] baseTypeNames) + { + WriteIndented("public interface Interface"); - public void BeginSetter(bool aggressivelyInlined) + if (baseTypeNames is not null) { - WriteNewline(); - if (aggressivelyInlined) + Write(" : "); + Write(baseTypeNames[0]); + Write(".Interface"); + + for (var i = 1; i < baseTypeNames.Length; i++) { - AddUsingDirective("System.Runtime.CompilerServices"); - WriteIndentedLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]"); + Write(", "); + Write(baseTypeNames[i]); + Write(".Interface"); } - - WriteIndentedLine("set"); - WriteBlockStart(); } - public void EndSetter() + WriteNewline(); + WriteBlockStart(); + _isInMarkerInterface = true; + } + + public void BeginExplicitVtbl() + { + WriteIndented("public partial struct Vtbl"); + + if (_config.GenerateMarkerInterfaces && !_config.ExcludeFnptrCodegen) { - WriteBlockEnd(); - NeedsNewline = false; + WriteLine(""); + IncreaseIndentation(); + WriteIndentedLine("where TSelf : unmanaged, Interface"); + DecreaseIndentation(); } - - public void BeginIndexer(AccessSpecifier accessSpecifier, bool isUnsafe, bool needsUnscopedRef) + else { - NeedsNewline = true; + WriteNewline(); + } - if (needsUnscopedRef) - { - WriteCustomAttribute("UnscopedRef"); - } + WriteBlockStart(); + } - WriteIndented(GetAccessSpecifierString(accessSpecifier, isNested: true)); - Write(' '); - if (isUnsafe) - { - Write("unsafe "); - } + public void EmitCompatibleCodeSupport() => AddUsingDirective("System.Runtime.CompilerServices"); + + public void EmitFnPtrSupport() + { + AddUsingDirective("System"); + AddUsingDirective("System.Runtime.InteropServices"); + } + + public void EmitSystemSupport() => AddUsingDirective("System"); + + public void EndStruct(in StructDesc desc) => WriteBlockEnd(); + + public void EndMarkerInterface() + { + _isInMarkerInterface = false; + WriteBlockEnd(); + } + + public void EndExplicitVtbl() => WriteBlockEnd(); + + public CSharpOutputBuilder BeginCSharpCode() => + // just write directly to this buffer + this; + + public void EndCSharpCode(CSharpOutputBuilder output) + { + // nop, used only by XML + } + + public void BeginGetter(bool aggressivelyInlined) + { + if (aggressivelyInlined) + { + AddUsingDirective("System.Runtime.CompilerServices"); + WriteIndentedLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]"); } - public void WriteIndexer(string typeName) + WriteIndentedLine("get"); + WriteBlockStart(); + } + + public void EndGetter() => WriteBlockEnd(); + + public void BeginSetter(bool aggressivelyInlined) + { + WriteNewline(); + if (aggressivelyInlined) { - Write(typeName); - Write(" this"); + AddUsingDirective("System.Runtime.CompilerServices"); + WriteIndentedLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]"); } - public void BeginIndexerParameters() => Write('['); + WriteIndentedLine("set"); + WriteBlockStart(); + } - public void EndIndexerParameters() => Write(']'); + public void EndSetter() + { + WriteBlockEnd(); + NeedsNewline = false; + } - public void EndIndexer() => NeedsNewline = true; + public void BeginIndexer(AccessSpecifier accessSpecifier, bool isUnsafe, bool needsUnscopedRef) + { + NeedsNewline = true; - public void BeginDereference() => Write('&'); + if (needsUnscopedRef) + { + WriteCustomAttribute("UnscopedRef"); + } - public void EndDereference() + WriteIndented(GetAccessSpecifierString(accessSpecifier, isNested: true)); + Write(' '); + if (isUnsafe) { - // nop, used only by XML + Write("unsafe "); } + } + + public void WriteIndexer(string typeName) + { + Write(typeName); + Write(" this"); + } + + public void BeginIndexerParameters() => Write('['); + + public void EndIndexerParameters() => Write(']'); + + public void EndIndexer() => NeedsNewline = true; + + public void BeginDereference() => Write('&'); + + public void EndDereference() + { + // nop, used only by XML + } - private string GetAccessSpecifierString(AccessSpecifier accessSpecifier, bool isNested) + private string GetAccessSpecifierString(AccessSpecifier accessSpecifier, bool isNested) + { + switch (accessSpecifier) { - switch (accessSpecifier) + case AccessSpecifier.Private: { - case AccessSpecifier.Private: - { - // Non-nested members can only be public or internal - // and C# defaults to internal when no specifier is given - - if (!isNested) - { - accessSpecifier = AccessSpecifier.Internal; - } - break; - } + // Non-nested members can only be public or internal + // and C# defaults to internal when no specifier is given - case AccessSpecifier.PrivateProtected: + if (!isNested) { - // We only generate structs, enums, or static members so protected is invalid - // fallback to internal to match the non-external visibility of private protected - accessSpecifier = AccessSpecifier.Internal; - break; } + break; + } - case AccessSpecifier.Protected: - case AccessSpecifier.ProtectedInternal: - { - // We only generate structs, enums, or static members so protected is invalid - // fallback to internal to match the external visibility of protected and protected internal + case AccessSpecifier.PrivateProtected: + { + // We only generate structs, enums, or static members so protected is invalid + // fallback to internal to match the non-external visibility of private protected - accessSpecifier = AccessSpecifier.Public; - break; - } + accessSpecifier = AccessSpecifier.Internal; + break; } - return accessSpecifier.AsString(); + case AccessSpecifier.Protected: + case AccessSpecifier.ProtectedInternal: + { + // We only generate structs, enums, or static members so protected is invalid + // fallback to internal to match the external visibility of protected and protected internal + + accessSpecifier = AccessSpecifier.Public; + break; + } } + + return accessSpecifier.AsString(); } } diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.cs index de0badaf..7f2b9d28 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.cs @@ -5,363 +5,362 @@ using System.Diagnostics; using System.Text; -namespace ClangSharp.CSharp +namespace ClangSharp.CSharp; + +internal sealed partial class CSharpOutputBuilder { - internal sealed partial class CSharpOutputBuilder + public const string DefaultIndentationString = " "; + + private readonly string _name; + private readonly PInvokeGeneratorConfiguration _config; + private readonly List _contents; + private readonly StringBuilder _currentLine; + private readonly SortedSet _usingDirectives; + private readonly SortedSet _staticUsingDirectives; + private readonly string _indentationString; + private readonly bool _isTestOutput; + + private int _indentationLevel; + private bool _isInMarkerInterface; + private readonly MarkerMode _markerMode; + private readonly bool _writeSourceLocation; + + public CSharpOutputBuilder(string name, PInvokeGeneratorConfiguration config, string indentationString = DefaultIndentationString, + bool isTestOutput = false, MarkerMode markerMode = MarkerMode.None, + bool writeSourceLocation = false) { - public const string DefaultIndentationString = " "; - - private readonly string _name; - private readonly PInvokeGeneratorConfiguration _config; - private readonly List _contents; - private readonly StringBuilder _currentLine; - private readonly SortedSet _usingDirectives; - private readonly SortedSet _staticUsingDirectives; - private readonly string _indentationString; - private readonly bool _isTestOutput; - - private int _indentationLevel; - private bool _isInMarkerInterface; - private readonly MarkerMode _markerMode; - private readonly bool _writeSourceLocation; - - public CSharpOutputBuilder(string name, PInvokeGeneratorConfiguration config, string indentationString = DefaultIndentationString, - bool isTestOutput = false, MarkerMode markerMode = MarkerMode.None, - bool writeSourceLocation = false) - { - _name = name; - _config = config; - _contents = new List(); - _currentLine = new StringBuilder(); - _usingDirectives = new SortedSet(); - _staticUsingDirectives = new SortedSet(); - _indentationString = indentationString; - _isTestOutput = isTestOutput; - _markerMode = markerMode; - _writeSourceLocation = writeSourceLocation; - } + _name = name; + _config = config; + _contents = new List(); + _currentLine = new StringBuilder(); + _usingDirectives = new SortedSet(); + _staticUsingDirectives = new SortedSet(); + _indentationString = indentationString; + _isTestOutput = isTestOutput; + _markerMode = markerMode; + _writeSourceLocation = writeSourceLocation; + } + + public IEnumerable Contents => _contents; + + public bool HasPendingLine => _currentLine.Length > 0; + + public string IndentationString => _indentationString; - public IEnumerable Contents => _contents; + public bool IsUncheckedContext { get; private set; } - public bool HasPendingLine => _currentLine.Length > 0; + public bool IsTestOutput => _isTestOutput; - public string IndentationString => _indentationString; + public string Name => _name; - public bool IsUncheckedContext { get; private set; } + public string Extension { get; } = ".cs"; - public bool IsTestOutput => _isTestOutput; + public bool NeedsNewline { get; set; } + + public bool NeedsSemicolon { get; set; } + + public IEnumerable StaticUsingDirectives => _staticUsingDirectives; + + public IEnumerable UsingDirectives => _usingDirectives; + + public void AddUsingDirective(string namespaceName) => _ = namespaceName.StartsWith("static ") ? _staticUsingDirectives.Add(namespaceName) : _usingDirectives.Add(namespaceName); + + public void DecreaseIndentation() + { + Debug.Assert(_indentationLevel > 0); + _indentationLevel--; + } - public string Name => _name; + public void IncreaseIndentation() => _indentationLevel++; - public string Extension { get; } = ".cs"; + public void WriteBlockStart() + { + WriteIndentedLine('{'); + IncreaseIndentation(); + } - public bool NeedsNewline { get; set; } + public void WriteBlockEnd() + { + // We don't need a newline if immediately closing the scope + NeedsNewline = false; - public bool NeedsSemicolon { get; set; } + // We don't need a semicolon if immediately closing the scope + NeedsSemicolon = false; - public IEnumerable StaticUsingDirectives => _staticUsingDirectives; + DecreaseIndentation(); + WriteIndentedLine('}'); + } - public IEnumerable UsingDirectives => _usingDirectives; + public void Write(T value) => _ = _currentLine.Append(value); - public void AddUsingDirective(string namespaceName) => _ = namespaceName.StartsWith("static ") ? _staticUsingDirectives.Add(namespaceName) : _usingDirectives.Add(namespaceName); + public void WriteIndentation() + { + WriteNewlineIfNeeded(); - public void DecreaseIndentation() + for (var i = 0; i < _indentationLevel; i++) { - Debug.Assert(_indentationLevel > 0); - _indentationLevel--; + _ = _currentLine.Append(_indentationString); } + } + + public void WriteIndented(T value) + { + WriteIndentation(); + Write(value); + } - public void IncreaseIndentation() => _indentationLevel++; + public void WriteIndentedLine(T value) + { + WriteIndentation(); + WriteLine(value); + } + + public void WriteLine(T value) + { + Write(value); + WriteNewline(); + } - public void WriteBlockStart() + public void WriteNewline() + { + _contents.Add(_currentLine.ToString()); + _ = _currentLine.Clear(); + NeedsNewline = false; + } + + public void WriteNewlineIfNeeded() + { + if (NeedsNewline) { - WriteIndentedLine('{'); - IncreaseIndentation(); + WriteNewline(); } + } - public void WriteBlockEnd() + public void WritePendingLine() + { + if (HasPendingLine) { - // We don't need a newline if immediately closing the scope - NeedsNewline = false; + WriteNewline(); + } + } - // We don't need a semicolon if immediately closing the scope - NeedsSemicolon = false; + public void WriteSemicolon() + { + Write(';'); + NeedsSemicolon = false; + NeedsNewline = true; + } - DecreaseIndentation(); - WriteIndentedLine('}'); + public void WriteSemicolonIfNeeded() + { + if (NeedsSemicolon) + { + WriteSemicolon(); } + } - public void Write(T value) => _ = _currentLine.Append(value); + public void WriteValueAsBytes(ulong value, int sizeInChars) + { + Write("0x"); + Write(((byte)value).ToString("X2")); - public void WriteIndentation() + for (var i = 1; i < sizeInChars; i++) { - WriteNewlineIfNeeded(); + Write(", "); + value >>= 8; - for (var i = 0; i < _indentationLevel; i++) - { - _ = _currentLine.Append(_indentationString); - } + Write("0x"); + Write(((byte)value).ToString("X2")); } + } - public void WriteIndented(T value) + public void BeginMarker(string kind, params KeyValuePair[] attributes) + { + if (_markerMode != MarkerMode.Xml) { - WriteIndentation(); - Write(value); + return; } - public void WriteIndentedLine(T value) + Write("/*M*/<"); + Write(kind); + foreach (var kvp in attributes) { - WriteIndentation(); - WriteLine(value); + Write(' '); + Write(kvp.Key); + Write('='); + Write('"'); + Write(kvp.Value); + Write('"'); } - public void WriteLine(T value) + Write("/*M*/>"); + } + + public void EndMarker(string kind) + { + if (_markerMode != MarkerMode.Xml) { - Write(value); - WriteNewline(); + return; } - public void WriteNewline() + Write("/*M*/"); + } + + private void AddCppAttributes(IEnumerable attrs, string prefix = null, string postfix = null) + { + var attributeList = string.Join("^", attrs); + if (string.IsNullOrWhiteSpace(attributeList)) { - _contents.Add(_currentLine.ToString()); - _ = _currentLine.Clear(); - NeedsNewline = false; + return; } - public void WriteNewlineIfNeeded() + if (prefix is null) { - if (NeedsNewline) - { - WriteNewline(); - } + WriteIndentation(); } - - public void WritePendingLine() + else { - if (HasPendingLine) - { - WriteNewline(); - } + WriteNewlineIfNeeded(); + Write(prefix); } - public void WriteSemicolon() + Write("[CppAttributeList(\""); + Write(attributeList); + Write("\")]"); + + if (postfix is null) { - Write(';'); - NeedsSemicolon = false; NeedsNewline = true; } + else + { + Write(postfix); + } + } - public void WriteSemicolonIfNeeded() + private void AddNativeInheritanceAttribute(string inheritedFromName, string prefix = null, string postfix = null, string attributePrefix = null) + { + if (prefix is null) { - if (NeedsSemicolon) - { - WriteSemicolon(); - } + WriteIndentation(); } + else + { + WriteNewlineIfNeeded(); + Write(prefix); + } + + Write('['); - public void WriteValueAsBytes(ulong value, int sizeInChars) + if (attributePrefix != null) { - Write("0x"); - Write(((byte)value).ToString("X2")); + Write(attributePrefix); + } - for (var i = 1; i < sizeInChars; i++) - { - Write(", "); - value >>= 8; + Write("NativeInheritance"); + Write('('); + Write('"'); + Write(PInvokeGenerator.EscapeString(inheritedFromName)); + Write('"'); + Write(')'); + Write(']'); - Write("0x"); - Write(((byte)value).ToString("X2")); - } + if (postfix is null) + { + NeedsNewline = true; + } + else + { + Write(postfix); } + } - public void BeginMarker(string kind, params KeyValuePair[] attributes) + private void AddVtblIndexAttribute(long vtblIndex, string prefix = null, string postfix = null, string attributePrefix = null) + { + if (prefix is null) { - if (_markerMode != MarkerMode.Xml) - { - return; - } - - Write("/*M*/<"); - Write(kind); - foreach (var kvp in attributes) - { - Write(' '); - Write(kvp.Key); - Write('='); - Write('"'); - Write(kvp.Value); - Write('"'); - } - - Write("/*M*/>"); + WriteIndentation(); + } + else + { + WriteNewlineIfNeeded(); + Write(prefix); } - public void EndMarker(string kind) + Write('['); + + if (attributePrefix != null) { - if (_markerMode != MarkerMode.Xml) - { - return; - } - - Write("/*M*/"); + Write(attributePrefix); } - private void AddCppAttributes(IEnumerable attrs, string prefix = null, string postfix = null) + Write("VtblIndex"); + Write('('); + Write(vtblIndex); + Write(')'); + Write(']'); + + if (postfix is null) + { + NeedsNewline = true; + } + else { - var attributeList = string.Join("^", attrs); - if (string.IsNullOrWhiteSpace(attributeList)) - { - return; - } - - if (prefix is null) - { - WriteIndentation(); - } - else - { - WriteNewlineIfNeeded(); - Write(prefix); - } - - Write("[CppAttributeList(\""); - Write(attributeList); - Write("\")]"); - - if (postfix is null) - { - NeedsNewline = true; - } - else - { - Write(postfix); - } + Write(postfix); } + } - private void AddNativeInheritanceAttribute(string inheritedFromName, string prefix = null, string postfix = null, string attributePrefix = null) + private void AddNativeTypeNameAttribute(string nativeTypeName, string prefix = null, string postfix = null, string attributePrefix = null) + { + if (string.IsNullOrWhiteSpace(nativeTypeName)) { - if (prefix is null) - { - WriteIndentation(); - } - else - { - WriteNewlineIfNeeded(); - Write(prefix); - } - - Write('['); - - if (attributePrefix != null) - { - Write(attributePrefix); - } - - Write("NativeInheritance"); - Write('('); - Write('"'); - Write(PInvokeGenerator.EscapeString(inheritedFromName)); - Write('"'); - Write(')'); - Write(']'); - - if (postfix is null) - { - NeedsNewline = true; - } - else - { - Write(postfix); - } + return; } - private void AddVtblIndexAttribute(long vtblIndex, string prefix = null, string postfix = null, string attributePrefix = null) + if (prefix is null) { - if (prefix is null) - { - WriteIndentation(); - } - else - { - WriteNewlineIfNeeded(); - Write(prefix); - } - - Write('['); - - if (attributePrefix != null) - { - Write(attributePrefix); - } - - Write("VtblIndex"); - Write('('); - Write(vtblIndex); - Write(')'); - Write(']'); - - if (postfix is null) - { - NeedsNewline = true; - } - else - { - Write(postfix); - } + WriteIndentation(); } + else + { + WriteNewlineIfNeeded(); + Write(prefix); + } + + Write('['); - private void AddNativeTypeNameAttribute(string nativeTypeName, string prefix = null, string postfix = null, string attributePrefix = null) + if (attributePrefix != null) { - if (string.IsNullOrWhiteSpace(nativeTypeName)) - { - return; - } - - if (prefix is null) - { - WriteIndentation(); - } - else - { - WriteNewlineIfNeeded(); - Write(prefix); - } - - Write('['); - - if (attributePrefix != null) - { - Write(attributePrefix); - } - - Write("NativeTypeName(\""); - Write(PInvokeGenerator.EscapeString(nativeTypeName)); - Write("\")]"); - - if (postfix is null) - { - NeedsNewline = true; - } - else - { - Write(postfix); - } + Write(attributePrefix); } - public override string ToString() + Write("NativeTypeName(\""); + Write(PInvokeGenerator.EscapeString(nativeTypeName)); + Write("\")]"); + + if (postfix is null) { - var result = new StringBuilder(); + NeedsNewline = true; + } + else + { + Write(postfix); + } + } - foreach (var line in _contents) - { - _ = result.Append(line); - _ = result.Append('\n'); - } + public override string ToString() + { + var result = new StringBuilder(); - _ = result.Append(_currentLine); - return result.ToString(); + foreach (var line in _contents) + { + _ = result.Append(line); + _ = result.Append('\n'); } + + _ = result.Append(_currentLine); + return result.ToString(); } } diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/MarkerMode.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/MarkerMode.cs index 112fe5cf..fb12e07d 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/MarkerMode.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/MarkerMode.cs @@ -1,11 +1,10 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp.CSharp +namespace ClangSharp.CSharp; + +internal enum MarkerMode { - internal enum MarkerMode - { - None, - Xml - // TODO Future prospect: Add an option to output the markers as C# comments? - } + None, + Xml + // TODO Future prospect: Add an option to output the markers as C# comments? } diff --git a/sources/ClangSharp.PInvokeGenerator/Diagnostic.cs b/sources/ClangSharp.PInvokeGenerator/Diagnostic.cs index 9cb15c32..8f2cae50 100644 --- a/sources/ClangSharp.PInvokeGenerator/Diagnostic.cs +++ b/sources/ClangSharp.PInvokeGenerator/Diagnostic.cs @@ -3,49 +3,48 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class Diagnostic : IEquatable { - public sealed class Diagnostic : IEquatable - { - private readonly DiagnosticLevel _level; - private readonly string _message; - private readonly string _location; + private readonly DiagnosticLevel _level; + private readonly string _message; + private readonly string _location; - public Diagnostic(DiagnosticLevel level, string message) : this(level, message, "") - { - } + public Diagnostic(DiagnosticLevel level, string message) : this(level, message, "") + { + } - public Diagnostic(DiagnosticLevel level, string message, CXSourceLocation location) : this(level, message, location.ToString().Replace('\\', '/')) - { - } + public Diagnostic(DiagnosticLevel level, string message, CXSourceLocation location) : this(level, message, location.ToString().Replace('\\', '/')) + { + } - public Diagnostic(DiagnosticLevel level, string message, string location) + public Diagnostic(DiagnosticLevel level, string message, string location) + { + if (string.IsNullOrWhiteSpace(message)) { - if (string.IsNullOrWhiteSpace(message)) - { - throw new ArgumentNullException(nameof(message)); - } - - _level = level; - _message = message; - _location = location; + throw new ArgumentNullException(nameof(message)); } - public DiagnosticLevel Level => _level; + _level = level; + _message = message; + _location = location; + } - public string Location => _location; + public DiagnosticLevel Level => _level; - public string Message => _message; + public string Location => _location; - public override bool Equals(object obj) => (obj is Diagnostic other) && Equals(other); + public string Message => _message; - public bool Equals(Diagnostic other) - { - return (_level == other.Level) - && (_location == other.Location) - && (_message == other.Message); - } + public override bool Equals(object obj) => (obj is Diagnostic other) && Equals(other); - public override string ToString() => string.IsNullOrWhiteSpace(_location) ? $"{_level}: {_message}" : $"{_level} ({_location}): {_message}"; + public bool Equals(Diagnostic other) + { + return (_level == other.Level) + && (_location == other.Location) + && (_message == other.Message); } + + public override string ToString() => string.IsNullOrWhiteSpace(_location) ? $"{_level}: {_message}" : $"{_level} ({_location}): {_message}"; } diff --git a/sources/ClangSharp.PInvokeGenerator/DiagnosticLevel.cs b/sources/ClangSharp.PInvokeGenerator/DiagnosticLevel.cs index 51f577bf..e0062003 100644 --- a/sources/ClangSharp.PInvokeGenerator/DiagnosticLevel.cs +++ b/sources/ClangSharp.PInvokeGenerator/DiagnosticLevel.cs @@ -1,11 +1,10 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp +namespace ClangSharp; + +public enum DiagnosticLevel { - public enum DiagnosticLevel - { - Info = 0, - Warning = 1, - Error = 2 - } + Info = 0, + Warning = 1, + Error = 2 } diff --git a/sources/ClangSharp.PInvokeGenerator/Extensions/IReadOnlyListExtensions.cs b/sources/ClangSharp.PInvokeGenerator/Extensions/IReadOnlyListExtensions.cs index 1e720b2e..aebc7374 100644 --- a/sources/ClangSharp.PInvokeGenerator/Extensions/IReadOnlyListExtensions.cs +++ b/sources/ClangSharp.PInvokeGenerator/Extensions/IReadOnlyListExtensions.cs @@ -2,23 +2,22 @@ using System.Collections.Generic; -namespace ClangSharp +namespace ClangSharp; + +internal static class IReadOnlyListExtensions { - internal static class IReadOnlyListExtensions + public static int IndexOf(this IReadOnlyList self, T value) { - public static int IndexOf(this IReadOnlyList self, T value) - { - var comparer = EqualityComparer.Default; + var comparer = EqualityComparer.Default; - for (var i = 0; i < self.Count; i++) + for (var i = 0; i < self.Count; i++) + { + if (comparer.Equals(self[i], value)) { - if (comparer.Equals(self[i], value)) - { - return i; - } + return i; } - - return -1; } + + return -1; } } diff --git a/sources/ClangSharp.PInvokeGenerator/Extensions/StringExtensions.cs b/sources/ClangSharp.PInvokeGenerator/Extensions/StringExtensions.cs index 3c011000..18ce4b6d 100644 --- a/sources/ClangSharp.PInvokeGenerator/Extensions/StringExtensions.cs +++ b/sources/ClangSharp.PInvokeGenerator/Extensions/StringExtensions.cs @@ -4,34 +4,33 @@ using System.Runtime.InteropServices; using ClangSharp.Abstractions; -namespace ClangSharp +namespace ClangSharp; + +internal static class StringExtensions { - internal static class StringExtensions - { - public static string Unquote(this string str) - => str.StartsWith("\"") && str.EndsWith("\"") && !str.EndsWith("\\\"") - ? str[1..^1] - : str; + public static string Unquote(this string str) + => str.StartsWith("\"") && str.EndsWith("\"") && !str.EndsWith("\\\"") + ? str[1..^1] + : str; - public static string AsString(this AccessSpecifier value) => value switch - { - AccessSpecifier.Public => "public", - AccessSpecifier.Protected => "protected", - AccessSpecifier.ProtectedInternal => "protected internal", - AccessSpecifier.Internal => "internal", - AccessSpecifier.PrivateProtected => "private protected", - AccessSpecifier.Private => "private", - _ => "public" - }; + public static string AsString(this AccessSpecifier value) => value switch + { + AccessSpecifier.Public => "public", + AccessSpecifier.Protected => "protected", + AccessSpecifier.ProtectedInternal => "protected internal", + AccessSpecifier.Internal => "internal", + AccessSpecifier.PrivateProtected => "private protected", + AccessSpecifier.Private => "private", + _ => "public" + }; - public static string AsString(this CallingConvention value, bool isForFnPtr) => value switch - { - CallingConvention.Winapi => "Winapi", - CallingConvention.Cdecl => "Cdecl", - CallingConvention.StdCall => isForFnPtr ? "Stdcall" : "StdCall", - CallingConvention.ThisCall => isForFnPtr ? "Thiscall" : "ThisCall", - CallingConvention.FastCall => isForFnPtr ? "Fastcall" : "FastCall", - _ => throw new ArgumentOutOfRangeException(nameof(value), value, null) - }; - } + public static string AsString(this CallingConvention value, bool isForFnPtr) => value switch + { + CallingConvention.Winapi => "Winapi", + CallingConvention.Cdecl => "Cdecl", + CallingConvention.StdCall => isForFnPtr ? "Stdcall" : "StdCall", + CallingConvention.ThisCall => isForFnPtr ? "Thiscall" : "ThisCall", + CallingConvention.FastCall => isForFnPtr ? "Fastcall" : "FastCall", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, null) + }; } diff --git a/sources/ClangSharp.PInvokeGenerator/FunctionOrDelegateFlags.cs b/sources/ClangSharp.PInvokeGenerator/FunctionOrDelegateFlags.cs index 617e33f1..1dabadcd 100644 --- a/sources/ClangSharp.PInvokeGenerator/FunctionOrDelegateFlags.cs +++ b/sources/ClangSharp.PInvokeGenerator/FunctionOrDelegateFlags.cs @@ -1,25 +1,24 @@ using System; -namespace ClangSharp +namespace ClangSharp; + +[Flags] +public enum FunctionOrDelegateFlags { - [Flags] - public enum FunctionOrDelegateFlags - { - IsVirtual = 1 << 0, - IsDllImport = 1 << 1, - HasFnPtrCodeGen = 1 << 2, - IsAggressivelyInlined = 1 << 3, - SetLastError = 1 << 4, - IsCxx = 1 << 5, - NeedsNewKeyword = 1 << 6, - IsUnsafe = 1 << 7, - IsCtxCxxRecord = 1 << 8, - IsCxxRecordCtxUnsafe = 1 << 9, - IsMemberFunction = 1 << 10, - IsStatic = 1 << 11, - IsNotStatic = 1 << 12, - NeedsReturnFixup = 1 << 13, - IsCxxConstructor = 1 << 14, - IsManualImport = 1 << 15, - } + IsVirtual = 1 << 0, + IsDllImport = 1 << 1, + HasFnPtrCodeGen = 1 << 2, + IsAggressivelyInlined = 1 << 3, + SetLastError = 1 << 4, + IsCxx = 1 << 5, + NeedsNewKeyword = 1 << 6, + IsUnsafe = 1 << 7, + IsCtxCxxRecord = 1 << 8, + IsCxxRecordCtxUnsafe = 1 << 9, + IsMemberFunction = 1 << 10, + IsStatic = 1 << 11, + IsNotStatic = 1 << 12, + NeedsReturnFixup = 1 << 13, + IsCxxConstructor = 1 << 14, + IsManualImport = 1 << 15, } diff --git a/sources/ClangSharp.PInvokeGenerator/OutputBuilderFactory.cs b/sources/ClangSharp.PInvokeGenerator/OutputBuilderFactory.cs index c114d66e..f77ad08b 100644 --- a/sources/ClangSharp.PInvokeGenerator/OutputBuilderFactory.cs +++ b/sources/ClangSharp.PInvokeGenerator/OutputBuilderFactory.cs @@ -6,72 +6,71 @@ using ClangSharp.CSharp; using ClangSharp.XML; -namespace ClangSharp +namespace ClangSharp; + +internal sealed class OutputBuilderFactory { - internal sealed class OutputBuilderFactory - { - private readonly PInvokeGeneratorConfiguration _config; - private readonly bool _writeSourceLocation; - private readonly Dictionary _outputBuilders; + private readonly PInvokeGeneratorConfiguration _config; + private readonly bool _writeSourceLocation; + private readonly Dictionary _outputBuilders; - public OutputBuilderFactory(PInvokeGeneratorConfiguration config) - { - _config = config; - _writeSourceLocation = config.GenerateSourceLocationAttribute; - _outputBuilders = new Dictionary(); - } + public OutputBuilderFactory(PInvokeGeneratorConfiguration config) + { + _config = config; + _writeSourceLocation = config.GenerateSourceLocationAttribute; + _outputBuilders = new Dictionary(); + } - public IEnumerable OutputBuilders => _outputBuilders.Values; + public IEnumerable OutputBuilders => _outputBuilders.Values; - public void Clear() => _outputBuilders.Clear(); + public void Clear() => _outputBuilders.Clear(); - public IOutputBuilder Create(string name) + public IOutputBuilder Create(string name) + { + if (string.IsNullOrWhiteSpace(name)) { - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentNullException(nameof(name)); - } - - var outputBuilder = _config.OutputMode switch - { - PInvokeGeneratorOutputMode.CSharp => (IOutputBuilder) new CSharpOutputBuilder(name, _config, writeSourceLocation: _writeSourceLocation), - PInvokeGeneratorOutputMode.Xml => new XmlOutputBuilder(name, _config), - _ => throw new InvalidOperationException() - }; - - _outputBuilders.Add(name, outputBuilder); - return outputBuilder; + throw new ArgumentNullException(nameof(name)); } - public CSharpOutputBuilder CreateTests(string name) + var outputBuilder = _config.OutputMode switch { - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentNullException(nameof(name)); - } + PInvokeGeneratorOutputMode.CSharp => (IOutputBuilder) new CSharpOutputBuilder(name, _config, writeSourceLocation: _writeSourceLocation), + PInvokeGeneratorOutputMode.Xml => new XmlOutputBuilder(name, _config), + _ => throw new InvalidOperationException() + }; - var outputBuilder = new CSharpOutputBuilder(name, _config, isTestOutput: true, writeSourceLocation: _writeSourceLocation); + _outputBuilders.Add(name, outputBuilder); + return outputBuilder; + } - _outputBuilders.Add(name, outputBuilder); - return outputBuilder; + public CSharpOutputBuilder CreateTests(string name) + { + if (string.IsNullOrWhiteSpace(name)) + { + throw new ArgumentNullException(nameof(name)); } - public IOutputBuilder GetOutputBuilder(string name) => string.IsNullOrWhiteSpace(name) ? throw new ArgumentNullException(nameof(name)) : _outputBuilders[name]; + var outputBuilder = new CSharpOutputBuilder(name, _config, isTestOutput: true, writeSourceLocation: _writeSourceLocation); - public CSharpOutputBuilder GetTestOutputBuilder(string name) - { - return string.IsNullOrWhiteSpace(name) - ? throw new ArgumentNullException(nameof(name)) - : _outputBuilders[name] is CSharpOutputBuilder csharpOutputBuilder && csharpOutputBuilder.IsTestOutput - ? csharpOutputBuilder - : throw new ArgumentException("A test output builder was not found with the given name", nameof(name)); - } + _outputBuilders.Add(name, outputBuilder); + return outputBuilder; + } - public bool TryGetOutputBuilder(string name, out IOutputBuilder outputBuilder) - { - return string.IsNullOrWhiteSpace(name) - ? throw new ArgumentNullException(nameof(name)) - : _outputBuilders.TryGetValue(name, out outputBuilder); - } + public IOutputBuilder GetOutputBuilder(string name) => string.IsNullOrWhiteSpace(name) ? throw new ArgumentNullException(nameof(name)) : _outputBuilders[name]; + + public CSharpOutputBuilder GetTestOutputBuilder(string name) + { + return string.IsNullOrWhiteSpace(name) + ? throw new ArgumentNullException(nameof(name)) + : _outputBuilders[name] is CSharpOutputBuilder csharpOutputBuilder && csharpOutputBuilder.IsTestOutput + ? csharpOutputBuilder + : throw new ArgumentException("A test output builder was not found with the given name", nameof(name)); + } + + public bool TryGetOutputBuilder(string name, out IOutputBuilder outputBuilder) + { + return string.IsNullOrWhiteSpace(name) + ? throw new ArgumentNullException(nameof(name)) + : _outputBuilders.TryGetValue(name, out outputBuilder); } } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitAttr.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitAttr.cs index 01f29fe8..f9cae309 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitAttr.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitAttr.cs @@ -1,12 +1,11 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp +namespace ClangSharp; + +public partial class PInvokeGenerator { - public partial class PInvokeGenerator + private static void VisitAttr(Attr attr) { - private static void VisitAttr(Attr attr) - { - // We don't consider most attributes particularly important and so we do nothing - } + // We don't consider most attributes particularly important and so we do nothing } } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs index b66e0ab4..e871fd01 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs @@ -11,3870 +11,3869 @@ using ClangSharp.CSharp; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public partial class PInvokeGenerator { - public partial class PInvokeGenerator - { - private void VisitClassTemplateDecl(ClassTemplateDecl classTemplateDecl) => Visit(classTemplateDecl.TemplatedDecl); + private void VisitClassTemplateDecl(ClassTemplateDecl classTemplateDecl) => Visit(classTemplateDecl.TemplatedDecl); - private void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl classTemplateSpecializationDecl) => AddDiagnostic(DiagnosticLevel.Warning, $"Class template specializations are not supported: '{GetCursorQualifiedName(classTemplateSpecializationDecl)}'. Generated bindings may be incomplete.", classTemplateSpecializationDecl); + private void VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl classTemplateSpecializationDecl) => AddDiagnostic(DiagnosticLevel.Warning, $"Class template specializations are not supported: '{GetCursorQualifiedName(classTemplateSpecializationDecl)}'. Generated bindings may be incomplete.", classTemplateSpecializationDecl); - private void VisitDecl(Decl decl) + private void VisitDecl(Decl decl) + { + if (IsExcluded(decl)) { - if (IsExcluded(decl)) + if (decl.Kind == CX_DeclKind.CX_DeclKind_Typedef) { - if (decl.Kind == CX_DeclKind.CX_DeclKind_Typedef) - { - VisitTypedefDecl((TypedefDecl)decl, onlyHandleRemappings: true); - } - return; + VisitTypedefDecl((TypedefDecl)decl, onlyHandleRemappings: true); } + return; + } - switch (decl.Kind) + switch (decl.Kind) + { + case CX_DeclKind.CX_DeclKind_AccessSpec: { - case CX_DeclKind.CX_DeclKind_AccessSpec: - { - // Access specifications are also exposed as a queryable property - // on the declarations they impact, so we don't need to do anything - break; - } - - // case CX_DeclKind.CX_DeclKind_Block: - // case CX_DeclKind.CX_DeclKind_Captured: - // case CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization: - - case CX_DeclKind.CX_DeclKind_Empty: - { - // Nothing to generate for empty declarations - break; - } - - // case CX_DeclKind.CX_DeclKind_Export: - // case CX_DeclKind.CX_DeclKind_ExternCContext: - // case CX_DeclKind.CX_DeclKind_FileScopeAsm: - - case CX_DeclKind.CX_DeclKind_Friend: - { - // Nothing to generate for friend declarations - break; - } - - // case CX_DeclKind.CX_DeclKind_FriendTemplate: - // case CX_DeclKind.CX_DeclKind_Import: - - case CX_DeclKind.CX_DeclKind_LinkageSpec: - { - VisitLinkageSpecDecl((LinkageSpecDecl)decl); - break; - } - - case CX_DeclKind.CX_DeclKind_Label: - { - VisitLabelDecl((LabelDecl)decl); - break; - } - - case CX_DeclKind.CX_DeclKind_Namespace: - { - VisitNamespaceDecl((NamespaceDecl)decl); - break; - } - - // case CX_DeclKind.CX_DeclKind_NamespaceAlias: - // case CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias: - // case CX_DeclKind.CX_DeclKind_ObjCCategory: - // case CX_DeclKind.CX_DeclKind_ObjCCategoryImpl: - // case CX_DeclKind.CX_DeclKind_ObjCImplementation: - // case CX_DeclKind.CX_DeclKind_ObjCInterface: - // case CX_DeclKind.CX_DeclKind_ObjCProtocol: - // case CX_DeclKind.CX_DeclKind_ObjCMethod: - // case CX_DeclKind.CX_DeclKind_ObjCProperty: - // case CX_DeclKind.CX_DeclKind_BuiltinTemplate: - // case CX_DeclKind.CX_DeclKind_Concept: + // Access specifications are also exposed as a queryable property + // on the declarations they impact, so we don't need to do anything + break; + } - case CX_DeclKind.CX_DeclKind_ClassTemplate: - { - VisitClassTemplateDecl((ClassTemplateDecl)decl); - break; - } + // case CX_DeclKind.CX_DeclKind_Block: + // case CX_DeclKind.CX_DeclKind_Captured: + // case CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization: - case CX_DeclKind.CX_DeclKind_FunctionTemplate: - { - VisitFunctionTemplateDecl((FunctionTemplateDecl)decl); - break; - } + case CX_DeclKind.CX_DeclKind_Empty: + { + // Nothing to generate for empty declarations + break; + } - // case CX_DeclKind.CX_DeclKind_TypeAliasTemplate: - // case CX_DeclKind.CX_DeclKind_VarTemplate: - // case CX_DeclKind.CX_DeclKind_TemplateTemplateParm: + // case CX_DeclKind.CX_DeclKind_Export: + // case CX_DeclKind.CX_DeclKind_ExternCContext: + // case CX_DeclKind.CX_DeclKind_FileScopeAsm: - case CX_DeclKind.CX_DeclKind_Enum: - { - VisitEnumDecl((EnumDecl)decl); - break; - } + case CX_DeclKind.CX_DeclKind_Friend: + { + // Nothing to generate for friend declarations + break; + } - case CX_DeclKind.CX_DeclKind_Record: - case CX_DeclKind.CX_DeclKind_CXXRecord: - { - VisitRecordDecl((RecordDecl)decl); - break; - } + // case CX_DeclKind.CX_DeclKind_FriendTemplate: + // case CX_DeclKind.CX_DeclKind_Import: - case CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization: - { - VisitClassTemplateSpecializationDecl((ClassTemplateSpecializationDecl)decl); - break; - } + case CX_DeclKind.CX_DeclKind_LinkageSpec: + { + VisitLinkageSpecDecl((LinkageSpecDecl)decl); + break; + } - // case CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization: - // case CX_DeclKind.CX_DeclKind_TemplateTypeParm: - // case CX_DeclKind.CX_DeclKind_ObjCTypeParam: + case CX_DeclKind.CX_DeclKind_Label: + { + VisitLabelDecl((LabelDecl)decl); + break; + } - case CX_DeclKind.CX_DeclKind_TypeAlias: - { - VisitTypeAliasDecl((TypeAliasDecl)decl); - break; - } + case CX_DeclKind.CX_DeclKind_Namespace: + { + VisitNamespaceDecl((NamespaceDecl)decl); + break; + } - case CX_DeclKind.CX_DeclKind_Typedef: - { - VisitTypedefDecl((TypedefDecl)decl, onlyHandleRemappings: false); - break; - } + // case CX_DeclKind.CX_DeclKind_NamespaceAlias: + // case CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias: + // case CX_DeclKind.CX_DeclKind_ObjCCategory: + // case CX_DeclKind.CX_DeclKind_ObjCCategoryImpl: + // case CX_DeclKind.CX_DeclKind_ObjCImplementation: + // case CX_DeclKind.CX_DeclKind_ObjCInterface: + // case CX_DeclKind.CX_DeclKind_ObjCProtocol: + // case CX_DeclKind.CX_DeclKind_ObjCMethod: + // case CX_DeclKind.CX_DeclKind_ObjCProperty: + // case CX_DeclKind.CX_DeclKind_BuiltinTemplate: + // case CX_DeclKind.CX_DeclKind_Concept: - // case CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename: + case CX_DeclKind.CX_DeclKind_ClassTemplate: + { + VisitClassTemplateDecl((ClassTemplateDecl)decl); + break; + } - case CX_DeclKind.CX_DeclKind_Using: - { - // Using declarations only introduce existing members into - // the current scope. There isn't an easy way to translate - // this to C#, so we will ignore them for now. - break; - } + case CX_DeclKind.CX_DeclKind_FunctionTemplate: + { + VisitFunctionTemplateDecl((FunctionTemplateDecl)decl); + break; + } - // case CX_DeclKind.CX_DeclKind_UsingDirective: - // case CX_DeclKind.CX_DeclKind_UsingPack: + // case CX_DeclKind.CX_DeclKind_TypeAliasTemplate: + // case CX_DeclKind.CX_DeclKind_VarTemplate: + // case CX_DeclKind.CX_DeclKind_TemplateTemplateParm: - case CX_DeclKind.CX_DeclKind_UsingShadow: - { - VisitUsingShadowDecl((UsingShadowDecl)decl); - break; - } + case CX_DeclKind.CX_DeclKind_Enum: + { + VisitEnumDecl((EnumDecl)decl); + break; + } - // case CX_DeclKind.CX_DeclKind_ConstructorUsingShadow: - // case CX_DeclKind.CX_DeclKind_Binding: + case CX_DeclKind.CX_DeclKind_Record: + case CX_DeclKind.CX_DeclKind_CXXRecord: + { + VisitRecordDecl((RecordDecl)decl); + break; + } - case CX_DeclKind.CX_DeclKind_Field: - { - VisitFieldDecl((FieldDecl)decl); - break; - } + case CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization: + { + VisitClassTemplateSpecializationDecl((ClassTemplateSpecializationDecl)decl); + break; + } - // case CX_DeclKind.CX_DeclKind_ObjCAtDefsField: - // case CX_DeclKind.CX_DeclKind_ObjCIvar: + // case CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization: + // case CX_DeclKind.CX_DeclKind_TemplateTypeParm: + // case CX_DeclKind.CX_DeclKind_ObjCTypeParam: - case CX_DeclKind.CX_DeclKind_Function: - case CX_DeclKind.CX_DeclKind_CXXMethod: - case CX_DeclKind.CX_DeclKind_CXXConstructor: - case CX_DeclKind.CX_DeclKind_CXXDestructor: - case CX_DeclKind.CX_DeclKind_CXXConversion: - { - VisitFunctionDecl((FunctionDecl)decl); - break; - } + case CX_DeclKind.CX_DeclKind_TypeAlias: + { + VisitTypeAliasDecl((TypeAliasDecl)decl); + break; + } - // case CX_DeclKind.CX_DeclKind_CXXDeductionGuide: - // case CX_DeclKind.CX_DeclKind_MSProperty: - // case CX_DeclKind.CX_DeclKind_NonTypeTemplateParm: + case CX_DeclKind.CX_DeclKind_Typedef: + { + VisitTypedefDecl((TypedefDecl)decl, onlyHandleRemappings: false); + break; + } - case CX_DeclKind.CX_DeclKind_Var: - { - VisitVarDecl((VarDecl)decl); - break; - } + // case CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename: - // case CX_DeclKind.CX_DeclKind_Decomposition: - // case CX_DeclKind.CX_DeclKind_ImplicitParam: - // case CX_DeclKind.CX_DeclKind_OMPCapturedExpr: + case CX_DeclKind.CX_DeclKind_Using: + { + // Using declarations only introduce existing members into + // the current scope. There isn't an easy way to translate + // this to C#, so we will ignore them for now. + break; + } - case CX_DeclKind.CX_DeclKind_ParmVar: - { - VisitParmVarDecl((ParmVarDecl)decl); - break; - } + // case CX_DeclKind.CX_DeclKind_UsingDirective: + // case CX_DeclKind.CX_DeclKind_UsingPack: - // case CX_DeclKind.CX_DeclKind_VarTemplateSpecialization: - // case CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization: + case CX_DeclKind.CX_DeclKind_UsingShadow: + { + VisitUsingShadowDecl((UsingShadowDecl)decl); + break; + } - case CX_DeclKind.CX_DeclKind_EnumConstant: - { - VisitEnumConstantDecl((EnumConstantDecl)decl); - break; - } + // case CX_DeclKind.CX_DeclKind_ConstructorUsingShadow: + // case CX_DeclKind.CX_DeclKind_Binding: - case CX_DeclKind.CX_DeclKind_IndirectField: - { - VisitIndirectFieldDecl((IndirectFieldDecl)decl); - break; - } + case CX_DeclKind.CX_DeclKind_Field: + { + VisitFieldDecl((FieldDecl)decl); + break; + } - // case CX_DeclKind.CX_DeclKind_OMPDeclareMapper: - // case CX_DeclKind.CX_DeclKind_OMPDeclareReduction: - // case CX_DeclKind.CX_DeclKind_UnresolvedUsingValue: - // case CX_DeclKind.CX_DeclKind_OMPAllocate: - // case CX_DeclKind.CX_DeclKind_OMPRequires: - // case CX_DeclKind.CX_DeclKind_OMPThreadPrivate: - // case CX_DeclKind.CX_DeclKind_ObjCPropertyImpl: + // case CX_DeclKind.CX_DeclKind_ObjCAtDefsField: + // case CX_DeclKind.CX_DeclKind_ObjCIvar: - case CX_DeclKind.CX_DeclKind_PragmaComment: - { - // Pragma comments can't be easily modeled in C# - // We'll ignore them for now. - break; - } + case CX_DeclKind.CX_DeclKind_Function: + case CX_DeclKind.CX_DeclKind_CXXMethod: + case CX_DeclKind.CX_DeclKind_CXXConstructor: + case CX_DeclKind.CX_DeclKind_CXXDestructor: + case CX_DeclKind.CX_DeclKind_CXXConversion: + { + VisitFunctionDecl((FunctionDecl)decl); + break; + } - // case CX_DeclKind.CX_DeclKind_PragmaDetectMismatch: + // case CX_DeclKind.CX_DeclKind_CXXDeductionGuide: + // case CX_DeclKind.CX_DeclKind_MSProperty: + // case CX_DeclKind.CX_DeclKind_NonTypeTemplateParm: - case CX_DeclKind.CX_DeclKind_StaticAssert: - { - // Static asserts can't be easily modeled in C# - // We'll ignore them for now. - break; - } + case CX_DeclKind.CX_DeclKind_Var: + { + VisitVarDecl((VarDecl)decl); + break; + } - case CX_DeclKind.CX_DeclKind_TranslationUnit: - { - VisitTranslationUnitDecl((TranslationUnitDecl)decl); - break; - } + // case CX_DeclKind.CX_DeclKind_Decomposition: + // case CX_DeclKind.CX_DeclKind_ImplicitParam: + // case CX_DeclKind.CX_DeclKind_OMPCapturedExpr: - default: - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported declaration: '{decl.DeclKindName}'. Generated bindings may be incomplete.", decl); - break; - } + case CX_DeclKind.CX_DeclKind_ParmVar: + { + VisitParmVarDecl((ParmVarDecl)decl); + break; } - } - private void VisitEnumConstantDecl(EnumConstantDecl enumConstantDecl) - { - var accessSpecifier = AccessSpecifier.None; - var name = GetRemappedCursorName(enumConstantDecl); - var escapedName = EscapeName(name); - var typeName = GetTargetTypeName(enumConstantDecl, out _); - var isAnonymousEnum = false; - var parentName = ""; + // case CX_DeclKind.CX_DeclKind_VarTemplateSpecialization: + // case CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization: - if (enumConstantDecl.DeclContext is EnumDecl enumDecl) + case CX_DeclKind.CX_DeclKind_EnumConstant: { - parentName = GetRemappedCursorName(enumDecl); - - if (parentName.StartsWith("__AnonymousEnum_")) - { - parentName = ""; - isAnonymousEnum = true; - accessSpecifier = GetAccessSpecifier(enumDecl, matchStar: true); - } + VisitEnumConstantDecl((EnumConstantDecl)decl); + break; } - if (string.IsNullOrEmpty(parentName)) + case CX_DeclKind.CX_DeclKind_IndirectField: { - parentName = _outputBuilder.Name; + VisitIndirectFieldDecl((IndirectFieldDecl)decl); + break; } - var kind = isAnonymousEnum ? ValueKind.Primitive : ValueKind.Enumerator; - var flags = ValueFlags.Constant; + // case CX_DeclKind.CX_DeclKind_OMPDeclareMapper: + // case CX_DeclKind.CX_DeclKind_OMPDeclareReduction: + // case CX_DeclKind.CX_DeclKind_UnresolvedUsingValue: + // case CX_DeclKind.CX_DeclKind_OMPAllocate: + // case CX_DeclKind.CX_DeclKind_OMPRequires: + // case CX_DeclKind.CX_DeclKind_OMPThreadPrivate: + // case CX_DeclKind.CX_DeclKind_ObjCPropertyImpl: - if ((enumConstantDecl.InitExpr is not null) || isAnonymousEnum) + case CX_DeclKind.CX_DeclKind_PragmaComment: { - flags |= ValueFlags.Initializer; + // Pragma comments can't be easily modeled in C# + // We'll ignore them for now. + break; } - var desc = new ValueDesc { - AccessSpecifier = accessSpecifier, - TypeName = typeName, - EscapedName = escapedName, - NativeTypeName = null, - ParentName = parentName, - Kind = kind, - Flags = flags, - Location = enumConstantDecl.Location, - WriteCustomAttrs = static context => { - (var enumConstantDecl, var generator) = ((EnumConstantDecl, PInvokeGenerator))context; - - generator.WithAttributes(enumConstantDecl); - generator.WithUsings(enumConstantDecl); - }, - CustomAttrGeneratorData = (enumConstantDecl, this), - }; - - _outputBuilder.BeginValue(in desc); + // case CX_DeclKind.CX_DeclKind_PragmaDetectMismatch: - if (enumConstantDecl.InitExpr != null) + case CX_DeclKind.CX_DeclKind_StaticAssert: { - Visit(enumConstantDecl.InitExpr); + // Static asserts can't be easily modeled in C# + // We'll ignore them for now. + break; } - else if (isAnonymousEnum) + + case CX_DeclKind.CX_DeclKind_TranslationUnit: { - if (IsUnsigned(typeName)) - { - _outputBuilder.WriteConstantValue(enumConstantDecl.UnsignedInitVal); - } - else - { - _outputBuilder.WriteConstantValue(enumConstantDecl.InitVal); - } + VisitTranslationUnitDecl((TranslationUnitDecl)decl); + break; } - _outputBuilder.EndValue(in desc); + default: + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported declaration: '{decl.DeclKindName}'. Generated bindings may be incomplete.", decl); + break; + } } + } - private void VisitEnumDecl(EnumDecl enumDecl) + private void VisitEnumConstantDecl(EnumConstantDecl enumConstantDecl) + { + var accessSpecifier = AccessSpecifier.None; + var name = GetRemappedCursorName(enumConstantDecl); + var escapedName = EscapeName(name); + var typeName = GetTargetTypeName(enumConstantDecl, out _); + var isAnonymousEnum = false; + var parentName = ""; + + if (enumConstantDecl.DeclContext is EnumDecl enumDecl) { - var accessSpecifier = GetAccessSpecifier(enumDecl, matchStar: true); - var name = GetRemappedCursorName(enumDecl); - var escapedName = EscapeName(name); - var isAnonymousEnum = false; + parentName = GetRemappedCursorName(enumDecl); - if (name.StartsWith("__AnonymousEnum_")) + if (parentName.StartsWith("__AnonymousEnum_")) { + parentName = ""; isAnonymousEnum = true; - - if (!TryGetClass(name, out var className, disallowPrefixMatch: true)) - { - className = _config.DefaultClass; - _ = _topLevelClassNames.Add(className); - _ = _topLevelClassNames.Add($"{className}Tests"); - AddDiagnostic(DiagnosticLevel.Info, $"Found anonymous enum: {name}. Mapping values as constants in: {className}", enumDecl); - } - - name = className; + accessSpecifier = GetAccessSpecifier(enumDecl, matchStar: true); } + } - StartUsingOutputBuilder(name); - { - EnumDesc desc = default; - - if (!isAnonymousEnum) - { - var typeName = GetRemappedTypeName(enumDecl, context: null, enumDecl.IntegerType, out var nativeTypeName); - - desc = new EnumDesc() - { - AccessSpecifier = accessSpecifier, - TypeName = typeName, - EscapedName = escapedName, - NativeType = nativeTypeName, - Location = enumDecl.Location, - IsNested = enumDecl.DeclContext is TagDecl, - WriteCustomAttrs = static context => { - (var enumDecl, var generator) = ((EnumDecl, PInvokeGenerator))context; - - generator.WithAttributes(enumDecl); - generator.WithUsings(enumDecl); - }, - CustomAttrGeneratorData = (enumDecl, this), - }; - - _outputBuilder.BeginEnum(in desc); - } + if (string.IsNullOrEmpty(parentName)) + { + parentName = _outputBuilder.Name; + } - Visit(enumDecl.Enumerators); - Visit(enumDecl.Decls, excludedCursors: enumDecl.Enumerators); + var kind = isAnonymousEnum ? ValueKind.Primitive : ValueKind.Enumerator; + var flags = ValueFlags.Constant; - if (!isAnonymousEnum) - { - _outputBuilder.EndEnum(in desc); - } - } - StopUsingOutputBuilder(); + if ((enumConstantDecl.InitExpr is not null) || isAnonymousEnum) + { + flags |= ValueFlags.Initializer; } - private void VisitFieldDecl(FieldDecl fieldDecl) + var desc = new ValueDesc { + AccessSpecifier = accessSpecifier, + TypeName = typeName, + EscapedName = escapedName, + NativeTypeName = null, + ParentName = parentName, + Kind = kind, + Flags = flags, + Location = enumConstantDecl.Location, + WriteCustomAttrs = static context => { + (var enumConstantDecl, var generator) = ((EnumConstantDecl, PInvokeGenerator))context; + + generator.WithAttributes(enumConstantDecl); + generator.WithUsings(enumConstantDecl); + }, + CustomAttrGeneratorData = (enumConstantDecl, this), + }; + + _outputBuilder.BeginValue(in desc); + + if (enumConstantDecl.InitExpr != null) + { + Visit(enumConstantDecl.InitExpr); + } + else if (isAnonymousEnum) { - if (fieldDecl.IsBitField) + if (IsUnsigned(typeName)) { - return; + _outputBuilder.WriteConstantValue(enumConstantDecl.UnsignedInitVal); } - - var accessSpecifier = GetAccessSpecifier(fieldDecl, matchStar: false); - var name = GetRemappedCursorName(fieldDecl); - var escapedName = EscapeName(name); - - var type = fieldDecl.Type; - var typeName = GetRemappedTypeName(fieldDecl, context: null, type, out var nativeTypeName); - - if (typeName == "bool") + else { - // bool is not blittable, so we shouldn't use it for structs that may be in P/Invoke signatures - typeName = "byte"; - nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? "bool" : nativeTypeName; + _outputBuilder.WriteConstantValue(enumConstantDecl.InitVal); } + } - if (_config.GenerateCompatibleCode && typeName.StartsWith("bool*")) - { - // bool* is not blittable in compat mode, so we shouldn't use it for structs that may be in P/Invoke signatures - typeName = typeName.Replace("bool*", "byte*"); - nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? typeName.Replace("byte*", "bool *") : nativeTypeName; - } + _outputBuilder.EndValue(in desc); + } + + private void VisitEnumDecl(EnumDecl enumDecl) + { + var accessSpecifier = GetAccessSpecifier(enumDecl, matchStar: true); + var name = GetRemappedCursorName(enumDecl); + var escapedName = EscapeName(name); + var isAnonymousEnum = false; + + if (name.StartsWith("__AnonymousEnum_")) + { + isAnonymousEnum = true; - int? offset = null; - if (fieldDecl.Parent.IsUnion) + if (!TryGetClass(name, out var className, disallowPrefixMatch: true)) { - offset = 0; + className = _config.DefaultClass; + _ = _topLevelClassNames.Add(className); + _ = _topLevelClassNames.Add($"{className}Tests"); + AddDiagnostic(DiagnosticLevel.Info, $"Found anonymous enum: {name}. Mapping values as constants in: {className}", enumDecl); } - var desc = new FieldDesc { - AccessSpecifier = accessSpecifier, - NativeTypeName = nativeTypeName, - EscapedName = escapedName, - ParentName = GetRemappedCursorName(fieldDecl.Parent), - Offset = offset, - NeedsNewKeyword = NeedsNewKeyword(name), - Location = fieldDecl.Location, - WriteCustomAttrs = static context => { - (var fieldDecl, var generator) = ((FieldDecl, PInvokeGenerator))context; - - generator.WithAttributes(fieldDecl); - generator.WithUsings(fieldDecl); - }, - CustomAttrGeneratorData = (fieldDecl, this), - }; + name = className; + } - _outputBuilder.BeginField(in desc); + StartUsingOutputBuilder(name); + { + EnumDesc desc = default; - if (type.CanonicalType is ConstantArrayType or IncompleteArrayType) + if (!isAnonymousEnum) { - var arrayType = (ArrayType)type.CanonicalType; + var typeName = GetRemappedTypeName(enumDecl, context: null, enumDecl.IntegerType, out var nativeTypeName); - var count = Math.Max((arrayType as ConstantArrayType)?.Size ?? 0, 1).ToString(); - var elementType = arrayType.ElementType; - while (elementType.CanonicalType is ConstantArrayType or IncompleteArrayType) + desc = new EnumDesc() { - var subArrayType = (ArrayType)elementType.CanonicalType; - count += " * "; - count += Math.Max((subArrayType as ConstantArrayType)?.Size ?? 0, 1).ToString(); - elementType = subArrayType.ElementType; - } + AccessSpecifier = accessSpecifier, + TypeName = typeName, + EscapedName = escapedName, + NativeType = nativeTypeName, + Location = enumDecl.Location, + IsNested = enumDecl.DeclContext is TagDecl, + WriteCustomAttrs = static context => { + (var enumDecl, var generator) = ((EnumDecl, PInvokeGenerator))context; + + generator.WithAttributes(enumDecl); + generator.WithUsings(enumDecl); + }, + CustomAttrGeneratorData = (enumDecl, this), + }; - _outputBuilder.WriteFixedCountField(typeName, escapedName, GetArtificialFixedSizedBufferName(fieldDecl), count); + _outputBuilder.BeginEnum(in desc); } - else + + Visit(enumDecl.Enumerators); + Visit(enumDecl.Decls, excludedCursors: enumDecl.Enumerators); + + if (!isAnonymousEnum) { - _outputBuilder.WriteRegularField(typeName, escapedName); + _outputBuilder.EndEnum(in desc); } - - _outputBuilder.EndField(in desc); } + StopUsingOutputBuilder(); + } - private void VisitFunctionDecl(FunctionDecl functionDecl) + private void VisitFieldDecl(FieldDecl fieldDecl) + { + if (fieldDecl.IsBitField) { - if (!functionDecl.IsUserProvided) - { - // We shouldn't process injected functions - return; - } + return; + } - if (IsExcluded(functionDecl)) - { - return; - } + var accessSpecifier = GetAccessSpecifier(fieldDecl, matchStar: false); + var name = GetRemappedCursorName(fieldDecl); + var escapedName = EscapeName(name); - var name = GetRemappedCursorName(functionDecl); + var type = fieldDecl.Type; + var typeName = GetRemappedTypeName(fieldDecl, context: null, type, out var nativeTypeName); - var cxxMethodDecl = functionDecl as CXXMethodDecl; - var isCxxMethodDecl = cxxMethodDecl is not null; + if (typeName == "bool") + { + // bool is not blittable, so we shouldn't use it for structs that may be in P/Invoke signatures + typeName = "byte"; + nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? "bool" : nativeTypeName; + } - if (isCxxMethodDecl && (cxxMethodDecl is CXXConstructorDecl)) - { - name = GetRemappedCursorName(cxxMethodDecl.Parent); - } + if (_config.GenerateCompatibleCode && typeName.StartsWith("bool*")) + { + // bool* is not blittable in compat mode, so we shouldn't use it for structs that may be in P/Invoke signatures + typeName = typeName.Replace("bool*", "byte*"); + nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? typeName.Replace("byte*", "bool *") : nativeTypeName; + } - var isManualImport = _config.WithManualImports.Contains(name); + int? offset = null; + if (fieldDecl.Parent.IsUnion) + { + offset = 0; + } - var className = name; - var parentName = ""; + var desc = new FieldDesc { + AccessSpecifier = accessSpecifier, + NativeTypeName = nativeTypeName, + EscapedName = escapedName, + ParentName = GetRemappedCursorName(fieldDecl.Parent), + Offset = offset, + NeedsNewKeyword = NeedsNewKeyword(name), + Location = fieldDecl.Location, + WriteCustomAttrs = static context => { + (var fieldDecl, var generator) = ((FieldDecl, PInvokeGenerator))context; + + generator.WithAttributes(fieldDecl); + generator.WithUsings(fieldDecl); + }, + CustomAttrGeneratorData = (fieldDecl, this), + }; + + _outputBuilder.BeginField(in desc); + + if (type.CanonicalType is ConstantArrayType or IncompleteArrayType) + { + var arrayType = (ArrayType)type.CanonicalType; - if (functionDecl.DeclContext is not CXXRecordDecl cxxRecordDecl) - { - cxxRecordDecl = null; - className = GetClass(name); - parentName = className; - StartUsingOutputBuilder(className); - } - else if ((Cursor)functionDecl.LexicalDeclContext != cxxRecordDecl) + var count = Math.Max((arrayType as ConstantArrayType)?.Size ?? 0, 1).ToString(); + var elementType = arrayType.ElementType; + while (elementType.CanonicalType is ConstantArrayType or IncompleteArrayType) { - // We shouldn't reprocess C++ functions outside the declaration - return; + var subArrayType = (ArrayType)elementType.CanonicalType; + count += " * "; + count += Math.Max((subArrayType as ConstantArrayType)?.Size ?? 0, 1).ToString(); + elementType = subArrayType.ElementType; } - var accessSpecifier = GetAccessSpecifier(functionDecl, matchStar: false); - - var body = functionDecl.Body; - var hasBody = body is not null; + _outputBuilder.WriteFixedCountField(typeName, escapedName, GetArtificialFixedSizedBufferName(fieldDecl), count); + } + else + { + _outputBuilder.WriteRegularField(typeName, escapedName); + } - var isVirtual = isCxxMethodDecl && cxxMethodDecl.IsVirtual; - var escapedName = isVirtual ? PrefixAndStripName(name, GetOverloadIndex(cxxMethodDecl)) : EscapeAndStripName(name); + _outputBuilder.EndField(in desc); + } - var returnType = functionDecl.ReturnType; - var returnTypeName = GetRemappedTypeName(functionDecl, cxxRecordDecl, returnType, out var nativeTypeName); + private void VisitFunctionDecl(FunctionDecl functionDecl) + { + if (!functionDecl.IsUserProvided) + { + // We shouldn't process injected functions + return; + } - if (isManualImport && !_config.WithClasses.ContainsKey(name)) - { - var firstParameter = functionDecl.Parameters.FirstOrDefault(); - var firstParameterTypeName = (firstParameter is not null) ? GetTargetTypeName(firstParameter, out var _) : "void"; - AddDiagnostic(DiagnosticLevel.Warning, $"Found manual import for {name} with no class remapping. First Parameter Type: {firstParameterTypeName}; Return Type: {returnTypeName}", functionDecl); - } + if (IsExcluded(functionDecl)) + { + return; + } - if (isVirtual || !hasBody) - { - if (returnTypeName == "bool") - { - // bool is not blittable, so we shouldn't use it for P/Invoke signatures - returnTypeName = "byte"; - nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? "bool" : nativeTypeName; - } + var name = GetRemappedCursorName(functionDecl); - if (_config.GenerateCompatibleCode && returnTypeName.StartsWith("bool*")) - { - // bool* is not blittable in compat mode, so we shouldn't use it for P/Invoke signatures - returnTypeName = returnTypeName.Replace("bool*", "byte*"); - nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? returnTypeName.Replace("byte*", "bool *") : nativeTypeName; - } - } + var cxxMethodDecl = functionDecl as CXXMethodDecl; + var isCxxMethodDecl = cxxMethodDecl is not null; - var type = functionDecl.Type; - var callingConventionName = GetCallingConvention(functionDecl, cxxRecordDecl, type); + if (isCxxMethodDecl && (cxxMethodDecl is CXXConstructorDecl)) + { + name = GetRemappedCursorName(cxxMethodDecl.Parent); + } - var isDllImport = !hasBody && !isVirtual; - var entryPoint = ""; + var isManualImport = _config.WithManualImports.Contains(name); - if (isDllImport) - { - entryPoint = functionDecl.IsExternC ? GetCursorName(functionDecl) : functionDecl.Handle.Mangling.CString; - } + var className = name; + var parentName = ""; - var needsReturnFixup = isCxxMethodDecl && NeedsReturnFixup(cxxMethodDecl); + if (functionDecl.DeclContext is not CXXRecordDecl cxxRecordDecl) + { + cxxRecordDecl = null; + className = GetClass(name); + parentName = className; + StartUsingOutputBuilder(className); + } + else if ((Cursor)functionDecl.LexicalDeclContext != cxxRecordDecl) + { + // We shouldn't reprocess C++ functions outside the declaration + return; + } - var desc = new FunctionOrDelegateDesc { - AccessSpecifier = accessSpecifier, - NativeTypeName = nativeTypeName, - EscapedName = escapedName, - ParentName = parentName, - EntryPoint = entryPoint, - CallingConvention = callingConventionName, - LibraryPath = isDllImport ? GetLibraryPath(name).Unquote() : null, - IsVirtual = isVirtual, - IsDllImport = isDllImport, - IsManualImport = isManualImport, - HasFnPtrCodeGen = !_config.ExcludeFnptrCodegen, - SetLastError = GetSetLastError(functionDecl), - IsCxx = isCxxMethodDecl, - IsStatic = isDllImport || !isCxxMethodDecl || cxxMethodDecl.IsStatic, - NeedsNewKeyword = NeedsNewKeyword(escapedName, functionDecl.Parameters), - IsUnsafe = IsUnsafe(functionDecl), - IsCtxCxxRecord = cxxRecordDecl is not null, - IsCxxRecordCtxUnsafe = cxxRecordDecl is not null && IsUnsafe(cxxRecordDecl), - NeedsReturnFixup = needsReturnFixup, - ReturnType = needsReturnFixup ? $"{returnTypeName}*" : returnTypeName, - IsCxxConstructor = functionDecl is CXXConstructorDecl, - Location = functionDecl.Location, - HasBody = hasBody, - WriteCustomAttrs = static context => { - (var functionDecl, var outputBuilder, var generator) = ((FunctionDecl, IOutputBuilder, PInvokeGenerator))context; + var accessSpecifier = GetAccessSpecifier(functionDecl, matchStar: false); - generator.WithAttributes(functionDecl); - generator.WithUsings(functionDecl); + var body = functionDecl.Body; + var hasBody = body is not null; - if (generator.HasSuppressGCTransition(functionDecl)) - { - outputBuilder.WriteCustomAttribute("SuppressGCTransition"); - } - }, - CustomAttrGeneratorData = (functionDecl, _outputBuilder, this), - }; + var isVirtual = isCxxMethodDecl && cxxMethodDecl.IsVirtual; + var escapedName = isVirtual ? PrefixAndStripName(name, GetOverloadIndex(cxxMethodDecl)) : EscapeAndStripName(name); - _ = _topLevelClassIsUnsafe.TryGetValue(className, out var isUnsafe); - _outputBuilder.BeginFunctionOrDelegate(in desc, ref isUnsafe); - _topLevelClassIsUnsafe[className] = isUnsafe; + var returnType = functionDecl.ReturnType; + var returnTypeName = GetRemappedTypeName(functionDecl, cxxRecordDecl, returnType, out var nativeTypeName); - _outputBuilder.BeginFunctionInnerPrototype(in desc); + if (isManualImport && !_config.WithClasses.ContainsKey(name)) + { + var firstParameter = functionDecl.Parameters.FirstOrDefault(); + var firstParameterTypeName = (firstParameter is not null) ? GetTargetTypeName(firstParameter, out var _) : "void"; + AddDiagnostic(DiagnosticLevel.Warning, $"Found manual import for {name} with no class remapping. First Parameter Type: {firstParameterTypeName}; Return Type: {returnTypeName}", functionDecl); + } - var needsThis = isVirtual || (isCxxMethodDecl && !hasBody && cxxMethodDecl.IsInstance); + if (isVirtual || !hasBody) + { + if (returnTypeName == "bool") + { + // bool is not blittable, so we shouldn't use it for P/Invoke signatures + returnTypeName = "byte"; + nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? "bool" : nativeTypeName; + } - if (needsThis) + if (_config.GenerateCompatibleCode && returnTypeName.StartsWith("bool*")) { - Debug.Assert(cxxRecordDecl != null); + // bool* is not blittable in compat mode, so we shouldn't use it for P/Invoke signatures + returnTypeName = returnTypeName.Replace("bool*", "byte*"); + nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? returnTypeName.Replace("byte*", "bool *") : nativeTypeName; + } + } - if (!IsPrevContextDecl(out var thisCursor, out _)) - { - thisCursor = cxxRecordDecl; - } + var type = functionDecl.Type; + var callingConventionName = GetCallingConvention(functionDecl, cxxRecordDecl, type); - var cxxRecordDeclName = GetRemappedCursorName(thisCursor); - var cxxRecordEscapedName = EscapeName(cxxRecordDeclName); - var parameterDesc = new ParameterDesc { - Name = "pThis", - Type = $"{cxxRecordEscapedName}*", - }; + var isDllImport = !hasBody && !isVirtual; + var entryPoint = ""; - _outputBuilder.BeginParameter(in parameterDesc); - _outputBuilder.EndParameter(in parameterDesc); + if (isDllImport) + { + entryPoint = functionDecl.IsExternC ? GetCursorName(functionDecl) : functionDecl.Handle.Mangling.CString; + } - if (needsReturnFixup) - { - _outputBuilder.WriteParameterSeparator(); - parameterDesc = new() - { - Name = "_result", - Type = $"{returnTypeName}*" - }; - _outputBuilder.BeginParameter(in parameterDesc); - _outputBuilder.EndParameter(in parameterDesc); - } + var needsReturnFixup = isCxxMethodDecl && NeedsReturnFixup(cxxMethodDecl); + + var desc = new FunctionOrDelegateDesc { + AccessSpecifier = accessSpecifier, + NativeTypeName = nativeTypeName, + EscapedName = escapedName, + ParentName = parentName, + EntryPoint = entryPoint, + CallingConvention = callingConventionName, + LibraryPath = isDllImport ? GetLibraryPath(name).Unquote() : null, + IsVirtual = isVirtual, + IsDllImport = isDllImport, + IsManualImport = isManualImport, + HasFnPtrCodeGen = !_config.ExcludeFnptrCodegen, + SetLastError = GetSetLastError(functionDecl), + IsCxx = isCxxMethodDecl, + IsStatic = isDllImport || !isCxxMethodDecl || cxxMethodDecl.IsStatic, + NeedsNewKeyword = NeedsNewKeyword(escapedName, functionDecl.Parameters), + IsUnsafe = IsUnsafe(functionDecl), + IsCtxCxxRecord = cxxRecordDecl is not null, + IsCxxRecordCtxUnsafe = cxxRecordDecl is not null && IsUnsafe(cxxRecordDecl), + NeedsReturnFixup = needsReturnFixup, + ReturnType = needsReturnFixup ? $"{returnTypeName}*" : returnTypeName, + IsCxxConstructor = functionDecl is CXXConstructorDecl, + Location = functionDecl.Location, + HasBody = hasBody, + WriteCustomAttrs = static context => { + (var functionDecl, var outputBuilder, var generator) = ((FunctionDecl, IOutputBuilder, PInvokeGenerator))context; + + generator.WithAttributes(functionDecl); + generator.WithUsings(functionDecl); + + if (generator.HasSuppressGCTransition(functionDecl)) + { + outputBuilder.WriteCustomAttribute("SuppressGCTransition"); + } + }, + CustomAttrGeneratorData = (functionDecl, _outputBuilder, this), + }; + + _ = _topLevelClassIsUnsafe.TryGetValue(className, out var isUnsafe); + _outputBuilder.BeginFunctionOrDelegate(in desc, ref isUnsafe); + _topLevelClassIsUnsafe[className] = isUnsafe; + + _outputBuilder.BeginFunctionInnerPrototype(in desc); + + var needsThis = isVirtual || (isCxxMethodDecl && !hasBody && cxxMethodDecl.IsInstance); + + if (needsThis) + { + Debug.Assert(cxxRecordDecl != null); - if (functionDecl.Parameters.Any()) - { - _outputBuilder.WriteParameterSeparator(); - } + if (!IsPrevContextDecl(out var thisCursor, out _)) + { + thisCursor = cxxRecordDecl; } - Visit(functionDecl.Parameters); + var cxxRecordDeclName = GetRemappedCursorName(thisCursor); + var cxxRecordEscapedName = EscapeName(cxxRecordDeclName); + var parameterDesc = new ParameterDesc { + Name = "pThis", + Type = $"{cxxRecordEscapedName}*", + }; + + _outputBuilder.BeginParameter(in parameterDesc); + _outputBuilder.EndParameter(in parameterDesc); - if (functionDecl.IsVariadic) + if (needsReturnFixup) { - if (needsThis || functionDecl.Parameters.Any()) + _outputBuilder.WriteParameterSeparator(); + parameterDesc = new() { - _outputBuilder.WriteParameterSeparator(); - } - var parameterDesc = new ParameterDesc - { - Name = "", - Type = "__arglist" + Name = "_result", + Type = $"{returnTypeName}*" }; _outputBuilder.BeginParameter(in parameterDesc); _outputBuilder.EndParameter(in parameterDesc); } - _outputBuilder.EndFunctionInnerPrototype(in desc); + if (functionDecl.Parameters.Any()) + { + _outputBuilder.WriteParameterSeparator(); + } + } - if (hasBody && !isVirtual) + Visit(functionDecl.Parameters); + + if (functionDecl.IsVariadic) + { + if (needsThis || functionDecl.Parameters.Any()) { - _outputBuilder.BeginBody(); + _outputBuilder.WriteParameterSeparator(); + } + var parameterDesc = new ParameterDesc + { + Name = "", + Type = "__arglist" + }; + _outputBuilder.BeginParameter(in parameterDesc); + _outputBuilder.EndParameter(in parameterDesc); + } + + _outputBuilder.EndFunctionInnerPrototype(in desc); + + if (hasBody && !isVirtual) + { + _outputBuilder.BeginBody(); + + if ((_cxxRecordDeclContext is not null) && (_cxxRecordDeclContext != cxxRecordDecl) && HasField(cxxRecordDecl)) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.WriteIndentation(); - if ((_cxxRecordDeclContext is not null) && (_cxxRecordDeclContext != cxxRecordDecl) && HasField(cxxRecordDecl)) + if (returnType.CanonicalType.Kind != CXTypeKind.CXType_Void) { - var outputBuilder = StartCSharpCode(); - outputBuilder.WriteIndentation(); + outputBuilder.Write("return "); + } - if (returnType.CanonicalType.Kind != CXTypeKind.CXType_Void) - { - outputBuilder.Write("return "); - } + var cxxBaseSpecifier = _cxxRecordDeclContext.Bases.Where((baseSpecifier) => baseSpecifier.Referenced == cxxMethodDecl.Parent).SingleOrDefault(); - var cxxBaseSpecifier = _cxxRecordDeclContext.Bases.Where((baseSpecifier) => baseSpecifier.Referenced == cxxMethodDecl.Parent).SingleOrDefault(); + if (cxxBaseSpecifier != null) + { + var baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); + baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); + outputBuilder.Write(baseFieldName); + } + else + { + outputBuilder.Write("Base"); + } + + outputBuilder.Write('.'); + outputBuilder.Write(name); + outputBuilder.Write('('); - if (cxxBaseSpecifier != null) - { - var baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); - baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); - outputBuilder.Write(baseFieldName); - } - else - { - outputBuilder.Write("Base"); - } - - outputBuilder.Write('.'); - outputBuilder.Write(name); - outputBuilder.Write('('); + var parameters = functionDecl.Parameters; - var parameters = functionDecl.Parameters; + if (parameters.Count != 0) + { + var parameter = parameters[0]; + var parameterName = GetRemappedCursorName(parameter); + outputBuilder.Write(EscapeName(parameterName)); - if (parameters.Count != 0) + for (var i = 1; i < parameters.Count; i++) { - var parameter = parameters[0]; - var parameterName = GetRemappedCursorName(parameter); - outputBuilder.Write(EscapeName(parameterName)); + parameter = parameters[i]; + parameterName = GetRemappedCursorName(parameter); - for (var i = 1; i < parameters.Count; i++) - { - parameter = parameters[i]; - parameterName = GetRemappedCursorName(parameter); - - outputBuilder.Write(", "); - outputBuilder.Write(EscapeName(parameterName)); - } + outputBuilder.Write(", "); + outputBuilder.Write(EscapeName(parameterName)); } + } - if (functionDecl.IsVariadic) + if (functionDecl.IsVariadic) + { + if (parameters.Count != 0) { - if (parameters.Count != 0) - { - outputBuilder.Write(", "); - } - outputBuilder.Write("__arglist"); + outputBuilder.Write(", "); } + outputBuilder.Write("__arglist"); + } - outputBuilder.Write(')'); + outputBuilder.Write(')'); - outputBuilder.NeedsSemicolon = true; - outputBuilder.NeedsNewline = true; + outputBuilder.NeedsSemicolon = true; + outputBuilder.NeedsNewline = true; - StopCSharpCode(); - } - else - { - var firstCtorInitializer = functionDecl.Parameters.Any() ? (functionDecl.CursorChildren.IndexOf(functionDecl.Parameters.Last()) + 1) : 0; - var lastCtorInitializer = (functionDecl.Body != null) ? functionDecl.CursorChildren.IndexOf(functionDecl.Body) : functionDecl.CursorChildren.Count; + StopCSharpCode(); + } + else + { + var firstCtorInitializer = functionDecl.Parameters.Any() ? (functionDecl.CursorChildren.IndexOf(functionDecl.Parameters.Last()) + 1) : 0; + var lastCtorInitializer = (functionDecl.Body != null) ? functionDecl.CursorChildren.IndexOf(functionDecl.Body) : functionDecl.CursorChildren.Count; - if (functionDecl is CXXConstructorDecl cxxConstructorDecl) - { - VisitCtorInitializers(cxxConstructorDecl, firstCtorInitializer, lastCtorInitializer); - } + if (functionDecl is CXXConstructorDecl cxxConstructorDecl) + { + VisitCtorInitializers(cxxConstructorDecl, firstCtorInitializer, lastCtorInitializer); + } - if (body is CompoundStmt compoundStmt) - { - var currentContext = _context.AddLast((compoundStmt, null)); + if (body is CompoundStmt compoundStmt) + { + var currentContext = _context.AddLast((compoundStmt, null)); - _outputBuilder.BeginConstructorInitializers(); - VisitStmts(compoundStmt.Body); - _outputBuilder.EndConstructorInitializers(); + _outputBuilder.BeginConstructorInitializers(); + VisitStmts(compoundStmt.Body); + _outputBuilder.EndConstructorInitializers(); - Debug.Assert(_context.Last == currentContext); - _context.RemoveLast(); - } - else - { - _outputBuilder.BeginInnerFunctionBody(); - Visit(body); - _outputBuilder.EndInnerFunctionBody(); - } + Debug.Assert(_context.Last == currentContext); + _context.RemoveLast(); + } + else + { + _outputBuilder.BeginInnerFunctionBody(); + Visit(body); + _outputBuilder.EndInnerFunctionBody(); } - - _outputBuilder.EndBody(); } - _outputBuilder.EndFunctionOrDelegate(in desc); + _outputBuilder.EndBody(); + } - Visit(functionDecl.Decls, excludedCursors: functionDecl.Parameters); + _outputBuilder.EndFunctionOrDelegate(in desc); - if (cxxRecordDecl is null) - { - StopUsingOutputBuilder(); - } + Visit(functionDecl.Decls, excludedCursors: functionDecl.Parameters); + + if (cxxRecordDecl is null) + { + StopUsingOutputBuilder(); + } - void VisitCtorInitializers(CXXConstructorDecl cxxConstructorDecl, int firstCtorInitializer, int lastCtorInitializer) + void VisitCtorInitializers(CXXConstructorDecl cxxConstructorDecl, int firstCtorInitializer, int lastCtorInitializer) + { + for (var i = firstCtorInitializer; i < lastCtorInitializer; i++) { - for (var i = firstCtorInitializer; i < lastCtorInitializer; i++) + if (cxxConstructorDecl.CursorChildren[i] is Attr) { - if (cxxConstructorDecl.CursorChildren[i] is Attr) - { - continue; - } + continue; + } - var memberRef = (Ref)cxxConstructorDecl.CursorChildren[i]; - var memberInit = (Stmt)cxxConstructorDecl.CursorChildren[++i]; + var memberRef = (Ref)cxxConstructorDecl.CursorChildren[i]; + var memberInit = (Stmt)cxxConstructorDecl.CursorChildren[++i]; - if (memberInit is ImplicitValueInitExpr) - { - continue; - } + if (memberInit is ImplicitValueInitExpr) + { + continue; + } - var memberRefName = GetRemappedCursorName(memberRef.Referenced); - var memberInitName = memberInit.Spelling; + var memberRefName = GetRemappedCursorName(memberRef.Referenced); + var memberInitName = memberInit.Spelling; - if (memberInit is CastExpr {SubExprAsWritten: DeclRefExpr declRefExpr}) - { - memberInitName = GetRemappedCursorName(declRefExpr.Decl); - } + if (memberInit is CastExpr {SubExprAsWritten: DeclRefExpr declRefExpr}) + { + memberInitName = GetRemappedCursorName(declRefExpr.Decl); + } - _outputBuilder.BeginConstructorInitializer(memberRefName, memberInitName); + _outputBuilder.BeginConstructorInitializer(memberRefName, memberInitName); - var memberRefTypeName = GetRemappedTypeName(memberRef, context: null, memberRef.Type, out var memberRefNativeTypeName); + var memberRefTypeName = GetRemappedTypeName(memberRef, context: null, memberRef.Type, out var memberRefNativeTypeName); - UncheckStmt(memberRefTypeName, memberInit); + UncheckStmt(memberRefTypeName, memberInit); - _outputBuilder.EndConstructorInitializer(); - } + _outputBuilder.EndConstructorInitializer(); } } + } - private void VisitFunctionTemplateDecl(FunctionTemplateDecl functionTemplateDecl) => Visit(functionTemplateDecl.TemplatedDecl); + private void VisitFunctionTemplateDecl(FunctionTemplateDecl functionTemplateDecl) => Visit(functionTemplateDecl.TemplatedDecl); - private void VisitIndirectFieldDecl(IndirectFieldDecl indirectFieldDecl) + private void VisitIndirectFieldDecl(IndirectFieldDecl indirectFieldDecl) + { + if (_config.ExcludeAnonymousFieldHelpers) { - if (_config.ExcludeAnonymousFieldHelpers) - { - return; - } + return; + } - if (IsPrevContextDecl(out var prevContext, out _) && prevContext.IsAnonymousStructOrUnion) - { - // We shouldn't process indirect fields where the prev context is an anonymous record decl - return; - } + if (IsPrevContextDecl(out var prevContext, out _) && prevContext.IsAnonymousStructOrUnion) + { + // We shouldn't process indirect fields where the prev context is an anonymous record decl + return; + } + + var fieldDecl = indirectFieldDecl.AnonField; + var anonymousRecordDecl = fieldDecl.Parent; - var fieldDecl = indirectFieldDecl.AnonField; - var anonymousRecordDecl = fieldDecl.Parent; + var rootRecordDecl = anonymousRecordDecl; - var rootRecordDecl = anonymousRecordDecl; + var contextNameParts = new Stack(); + var contextTypeParts = new Stack(); - var contextNameParts = new Stack(); - var contextTypeParts = new Stack(); + while (rootRecordDecl.IsAnonymousStructOrUnion && (rootRecordDecl.Parent is RecordDecl parentRecordDecl)) + { + var contextNamePart = GetRemappedCursorName(rootRecordDecl); - while (rootRecordDecl.IsAnonymousStructOrUnion && (rootRecordDecl.Parent is RecordDecl parentRecordDecl)) + if (contextNamePart.StartsWith("_")) { - var contextNamePart = GetRemappedCursorName(rootRecordDecl); + var suffixLength = 0; - if (contextNamePart.StartsWith("_")) + if (contextNamePart.EndsWith("_e__Union")) { - var suffixLength = 0; - - if (contextNamePart.EndsWith("_e__Union")) - { - suffixLength = 10; - } - else if (contextNamePart.EndsWith("_e__Struct")) - { - suffixLength = 11; - } + suffixLength = 10; + } + else if (contextNamePart.EndsWith("_e__Struct")) + { + suffixLength = 11; + } - if (suffixLength != 0) - { - contextNamePart = contextNamePart.Substring(1, contextNamePart.Length - suffixLength); - } + if (suffixLength != 0) + { + contextNamePart = contextNamePart.Substring(1, contextNamePart.Length - suffixLength); } + } - contextNameParts.Push(EscapeName(contextNamePart)); + contextNameParts.Push(EscapeName(contextNamePart)); - contextTypeParts.Push(GetRemappedTypeName(rootRecordDecl, context: null, rootRecordDecl.TypeForDecl, out _)); + contextTypeParts.Push(GetRemappedTypeName(rootRecordDecl, context: null, rootRecordDecl.TypeForDecl, out _)); - rootRecordDecl = parentRecordDecl; - } + rootRecordDecl = parentRecordDecl; + } - var contextNameBuilder = new StringBuilder(contextNameParts.Pop()); - var contextTypeBuilder = new StringBuilder(contextTypeParts.Pop()); + var contextNameBuilder = new StringBuilder(contextNameParts.Pop()); + var contextTypeBuilder = new StringBuilder(contextTypeParts.Pop()); - while (contextNameParts.Count != 0) - { - _ = contextNameBuilder.Append('.'); - _ = contextNameBuilder.Append(contextNameParts.Pop()); + while (contextNameParts.Count != 0) + { + _ = contextNameBuilder.Append('.'); + _ = contextNameBuilder.Append(contextNameParts.Pop()); - _ = contextTypeBuilder.Append('.'); - _ = contextTypeBuilder.Append(contextTypeParts.Pop()); - } + _ = contextTypeBuilder.Append('.'); + _ = contextTypeBuilder.Append(contextTypeParts.Pop()); + } - var contextName = contextNameBuilder.ToString(); - var contextType = contextTypeBuilder.ToString(); + var contextName = contextNameBuilder.ToString(); + var contextType = contextTypeBuilder.ToString(); - var type = fieldDecl.Type; + var type = fieldDecl.Type; - var accessSpecifier = GetAccessSpecifier(anonymousRecordDecl, matchStar: true); + var accessSpecifier = GetAccessSpecifier(anonymousRecordDecl, matchStar: true); - var typeName = GetRemappedTypeName(fieldDecl, context: null, type, out _); - var name = GetRemappedCursorName(fieldDecl); - var escapedName = EscapeName(name); + var typeName = GetRemappedTypeName(fieldDecl, context: null, type, out _); + var name = GetRemappedCursorName(fieldDecl); + var escapedName = EscapeName(name); - var rootRecordDeclName = GetRemappedCursorName(rootRecordDecl); + var rootRecordDeclName = GetRemappedCursorName(rootRecordDecl); - if (_config.ExcludedNames.Contains($"{rootRecordDeclName}.{name}") || _config.ExcludedNames.Contains($"{rootRecordDeclName}::{name}")) - { - return; - } + if (_config.ExcludedNames.Contains($"{rootRecordDeclName}.{name}") || _config.ExcludedNames.Contains($"{rootRecordDeclName}::{name}")) + { + return; + } - var desc = new FieldDesc { - AccessSpecifier = accessSpecifier, - NativeTypeName = null, - EscapedName = escapedName, - ParentName = GetRemappedCursorName(fieldDecl.Parent), - Offset = null, - NeedsNewKeyword = false, - NeedsUnscopedRef = _config.GeneratePreviewCode && !fieldDecl.IsBitField, - Location = fieldDecl.Location, - HasBody = true, - WriteCustomAttrs = static context => { - (var fieldDecl, var generator) = ((FieldDecl, PInvokeGenerator))context; + var desc = new FieldDesc { + AccessSpecifier = accessSpecifier, + NativeTypeName = null, + EscapedName = escapedName, + ParentName = GetRemappedCursorName(fieldDecl.Parent), + Offset = null, + NeedsNewKeyword = false, + NeedsUnscopedRef = _config.GeneratePreviewCode && !fieldDecl.IsBitField, + Location = fieldDecl.Location, + HasBody = true, + WriteCustomAttrs = static context => { + (var fieldDecl, var generator) = ((FieldDecl, PInvokeGenerator))context; + + generator.WithAttributes(fieldDecl); + generator.WithUsings(fieldDecl); + }, + CustomAttrGeneratorData = (fieldDecl, this), + }; + + _outputBuilder.WriteDivider(true); + _outputBuilder.BeginField(in desc); + + var isFixedSizedBuffer = type.CanonicalType is ConstantArrayType or IncompleteArrayType; + var generateCompatibleCode = _config.GenerateCompatibleCode; + var typeString = string.Empty; + + if (!fieldDecl.IsBitField && (!isFixedSizedBuffer || generateCompatibleCode)) + { + typeString = "ref "; + } - generator.WithAttributes(fieldDecl); - generator.WithUsings(fieldDecl); - }, - CustomAttrGeneratorData = (fieldDecl, this), - }; + if (type.CanonicalType is RecordType recordType) + { + var recordDecl = recordType.Decl; - _outputBuilder.WriteDivider(true); - _outputBuilder.BeginField(in desc); + while ((recordDecl.DeclContext is RecordDecl parentRecordDecl) && (parentRecordDecl != rootRecordDecl)) + { + var parentRecordDeclName = GetRemappedCursorName(parentRecordDecl); + var escapedParentRecordDeclName = EscapeName(parentRecordDeclName); - var isFixedSizedBuffer = type.CanonicalType is ConstantArrayType or IncompleteArrayType; - var generateCompatibleCode = _config.GenerateCompatibleCode; - var typeString = string.Empty; + typeString += escapedParentRecordDeclName + '.'; - if (!fieldDecl.IsBitField && (!isFixedSizedBuffer || generateCompatibleCode)) - { - typeString = "ref "; + recordDecl = parentRecordDecl; } + } - if (type.CanonicalType is RecordType recordType) + var isSupportedFixedSizedBufferType = isFixedSizedBuffer && IsSupportedFixedSizedBufferType(typeName); + + if (isFixedSizedBuffer) + { + if (!generateCompatibleCode) + { + _outputBuilder.EmitSystemSupport(); + typeString += "Span<"; + } + else if (!isSupportedFixedSizedBufferType) { - var recordDecl = recordType.Decl; + typeString += contextType + '.'; + typeName = GetArtificialFixedSizedBufferName(fieldDecl); + } + } - while ((recordDecl.DeclContext is RecordDecl parentRecordDecl) && (parentRecordDecl != rootRecordDecl)) - { - var parentRecordDeclName = GetRemappedCursorName(parentRecordDecl); - var escapedParentRecordDeclName = EscapeName(parentRecordDeclName); + typeString += typeName; + if (isFixedSizedBuffer && !generateCompatibleCode) + { + typeString += '>'; + } - typeString += escapedParentRecordDeclName + '.'; + _outputBuilder.WriteRegularField(typeString, escapedName); - recordDecl = parentRecordDecl; - } - } + var isIndirectPointerField = ((type.CanonicalType is PointerType) || (type.CanonicalType is ReferenceType)) && (typeName != "IntPtr") && (typeName != "UIntPtr"); - var isSupportedFixedSizedBufferType = isFixedSizedBuffer && IsSupportedFixedSizedBufferType(typeName); + _outputBuilder.BeginBody(); + _outputBuilder.BeginGetter(_config.GenerateAggressiveInlining); + var code = _outputBuilder.BeginCSharpCode(); - if (isFixedSizedBuffer) - { - if (!generateCompatibleCode) - { - _outputBuilder.EmitSystemSupport(); - typeString += "Span<"; - } - else if (!isSupportedFixedSizedBufferType) - { - typeString += contextType + '.'; - typeName = GetArtificialFixedSizedBufferName(fieldDecl); - } - } + if (fieldDecl.IsBitField) + { + code.WriteIndented("return "); + code.Write(contextName); + code.Write('.'); + code.Write(escapedName); + code.WriteSemicolon(); + code.WriteNewline(); + _outputBuilder.EndCSharpCode(code); + + _outputBuilder.EndGetter(); + + _outputBuilder.BeginSetter(_config.GenerateAggressiveInlining); + + code = _outputBuilder.BeginCSharpCode(); + code.WriteIndented(contextName); + code.Write('.'); + code.Write(escapedName); + code.Write(" = value"); + code.WriteSemicolon(); + code.WriteNewline(); + _outputBuilder.EndCSharpCode(code); + + _outputBuilder.EndSetter(); + } + else if (generateCompatibleCode) + { + code.WriteIndented("fixed ("); + code.Write(contextType); + code.Write("* pField = &"); + code.Write(contextName); + code.WriteLine(')'); + code.WriteBlockStart(); + code.WriteIndented("return ref pField->"); + code.Write(escapedName); - typeString += typeName; - if (isFixedSizedBuffer && !generateCompatibleCode) + if (isSupportedFixedSizedBufferType) { - typeString += '>'; + code.Write("[0]"); } - _outputBuilder.WriteRegularField(typeString, escapedName); - - var isIndirectPointerField = ((type.CanonicalType is PointerType) || (type.CanonicalType is ReferenceType)) && (typeName != "IntPtr") && (typeName != "UIntPtr"); + code.WriteSemicolon(); + code.WriteNewline(); + code.WriteBlockEnd(); + _outputBuilder.EndCSharpCode(code); - _outputBuilder.BeginBody(); - _outputBuilder.BeginGetter(_config.GenerateAggressiveInlining); - var code = _outputBuilder.BeginCSharpCode(); + _outputBuilder.EndGetter(); + } + else + { + code.WriteIndented("return "); - if (fieldDecl.IsBitField) + if (desc.NeedsUnscopedRef && !isFixedSizedBuffer) { - code.WriteIndented("return "); + code.Write("ref "); code.Write(contextName); code.Write('.'); code.Write(escapedName); - code.WriteSemicolon(); - code.WriteNewline(); - _outputBuilder.EndCSharpCode(code); - - _outputBuilder.EndGetter(); - - _outputBuilder.BeginSetter(_config.GenerateAggressiveInlining); - - code = _outputBuilder.BeginCSharpCode(); - code.WriteIndented(contextName); - code.Write('.'); - code.Write(escapedName); - code.Write(" = value"); - code.WriteSemicolon(); - code.WriteNewline(); - _outputBuilder.EndCSharpCode(code); - - _outputBuilder.EndSetter(); } - else if (generateCompatibleCode) + else { - code.WriteIndented("fixed ("); - code.Write(contextType); - code.Write("* pField = &"); - code.Write(contextName); - code.WriteLine(')'); - code.WriteBlockStart(); - code.WriteIndented("return ref pField->"); - code.Write(escapedName); - - if (isSupportedFixedSizedBufferType) + if (!isFixedSizedBuffer) { - code.Write("[0]"); + code.AddUsingDirective("System.Runtime.InteropServices"); + code.Write("ref MemoryMarshal.GetReference("); } - code.WriteSemicolon(); - code.WriteNewline(); - code.WriteBlockEnd(); - _outputBuilder.EndCSharpCode(code); - - _outputBuilder.EndGetter(); - } - else - { - code.WriteIndented("return "); + if (!isFixedSizedBuffer || isSupportedFixedSizedBufferType) + { + code.Write("MemoryMarshal.CreateSpan(ref "); + } - if (desc.NeedsUnscopedRef && !isFixedSizedBuffer) + if (isIndirectPointerField) + { + code.Write("this"); + } + else { - code.Write("ref "); code.Write(contextName); code.Write('.'); code.Write(escapedName); } - else - { - if (!isFixedSizedBuffer) - { - code.AddUsingDirective("System.Runtime.InteropServices"); - code.Write("ref MemoryMarshal.GetReference("); - } - - if (!isFixedSizedBuffer || isSupportedFixedSizedBufferType) - { - code.Write("MemoryMarshal.CreateSpan(ref "); - } - - if (isIndirectPointerField) - { - code.Write("this"); - } - else - { - code.Write(contextName); - code.Write('.'); - code.Write(escapedName); - } - if (isFixedSizedBuffer) + if (isFixedSizedBuffer) + { + if (isSupportedFixedSizedBufferType) { - if (isSupportedFixedSizedBufferType) - { - code.Write("[0], "); - code.Write(Math.Max((type.CanonicalType as ConstantArrayType)?.Size ?? 0, 1)); - } - else - { - code.Write(".AsSpan("); - } + code.Write("[0], "); + code.Write(Math.Max((type.CanonicalType as ConstantArrayType)?.Size ?? 0, 1)); } else { - code.Write(", 1)"); - } - - code.Write(')'); - - if (isIndirectPointerField) - { - code.Write('.'); - code.Write(contextName); - code.Write('.'); - code.Write(escapedName); + code.Write(".AsSpan("); } } + else + { + code.Write(", 1)"); + } - code.WriteSemicolon(); - code.WriteNewline(); - _outputBuilder.EndCSharpCode(code); + code.Write(')'); - _outputBuilder.EndGetter(); + if (isIndirectPointerField) + { + code.Write('.'); + code.Write(contextName); + code.Write('.'); + code.Write(escapedName); + } } - _outputBuilder.EndBody(); - _outputBuilder.EndField(in desc); - _outputBuilder.WriteDivider(); + code.WriteSemicolon(); + code.WriteNewline(); + _outputBuilder.EndCSharpCode(code); + + _outputBuilder.EndGetter(); } - private static void VisitLabelDecl(LabelDecl labelDecl) + _outputBuilder.EndBody(); + _outputBuilder.EndField(in desc); + _outputBuilder.WriteDivider(); + } + + private static void VisitLabelDecl(LabelDecl labelDecl) + { + // This should have already been handled as a statement + } + + private void VisitLinkageSpecDecl(LinkageSpecDecl linkageSpecDecl) + { + Visit(linkageSpecDecl.Decls); + Visit(linkageSpecDecl.CursorChildren, linkageSpecDecl.Decls); + } + + private void VisitNamespaceDecl(NamespaceDecl namespaceDecl) + { + // We don't currently include the namespace name anywhere in the + // generated bindings. We might want to in the future... + + Visit(namespaceDecl.Decls); + Visit(namespaceDecl.CursorChildren, namespaceDecl.Decls); + } + + private void VisitParmVarDecl(ParmVarDecl parmVarDecl) + { + if (IsExcluded(parmVarDecl)) { - // This should have already been handled as a statement + return; } - private void VisitLinkageSpecDecl(LinkageSpecDecl linkageSpecDecl) + if (IsPrevContextDecl(out var functionDecl, out _)) { - Visit(linkageSpecDecl.Decls); - Visit(linkageSpecDecl.CursorChildren, linkageSpecDecl.Decls); + ForFunctionDecl(parmVarDecl, functionDecl); } - - private void VisitNamespaceDecl(NamespaceDecl namespaceDecl) + else if (IsPrevContextDecl(out var typedefDecl, out _)) { - // We don't currently include the namespace name anywhere in the - // generated bindings. We might want to in the future... - - Visit(namespaceDecl.Decls); - Visit(namespaceDecl.CursorChildren, namespaceDecl.Decls); + ForTypedefDecl(parmVarDecl, typedefDecl); } - - private void VisitParmVarDecl(ParmVarDecl parmVarDecl) + else { - if (IsExcluded(parmVarDecl)) - { - return; - } + _ = IsPrevContextDecl(out var previousContext, out _); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported parameter variable declaration parent: '{previousContext.CursorKindSpelling}'. Generated bindings may be incomplete.", previousContext); + } - if (IsPrevContextDecl(out var functionDecl, out _)) - { - ForFunctionDecl(parmVarDecl, functionDecl); - } - else if (IsPrevContextDecl(out var typedefDecl, out _)) - { - ForTypedefDecl(parmVarDecl, typedefDecl); - } - else - { - _ = IsPrevContextDecl(out var previousContext, out _); - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported parameter variable declaration parent: '{previousContext.CursorKindSpelling}'. Generated bindings may be incomplete.", previousContext); - } + void ForFunctionDecl(ParmVarDecl parmVarDecl, FunctionDecl functionDecl) + { + var type = parmVarDecl.Type; + var typeName = GetTargetTypeName(parmVarDecl, out var nativeTypeName); - void ForFunctionDecl(ParmVarDecl parmVarDecl, FunctionDecl functionDecl) - { - var type = parmVarDecl.Type; - var typeName = GetTargetTypeName(parmVarDecl, out var nativeTypeName); + var name = GetRemappedCursorName(parmVarDecl); + var escapedName = EscapeName(name); - var name = GetRemappedCursorName(parmVarDecl); - var escapedName = EscapeName(name); + var functionName = GetRemappedCursorName(functionDecl); + var isForManualImport = _config.WithManualImports.Contains(functionName); - var functionName = GetRemappedCursorName(functionDecl); - var isForManualImport = _config.WithManualImports.Contains(functionName); + var parameters = functionDecl.Parameters; + var index = parameters.IndexOf(parmVarDecl); + var lastIndex = parameters.Count - 1; - var parameters = functionDecl.Parameters; - var index = parameters.IndexOf(parmVarDecl); - var lastIndex = parameters.Count - 1; + if (name.Equals("param")) + { + escapedName += index; + } - if (name.Equals("param")) - { - escapedName += index; - } + var desc = new ParameterDesc { + Name = escapedName, + Type = typeName, + NativeTypeName = nativeTypeName, + CppAttributes = _config.GenerateCppAttributes + ? parmVarDecl.Attrs.Select(x => EscapeString(x.Spelling)) + : null, + Location = parmVarDecl.Location, + WriteCustomAttrs = static context => { + (var parmVarDecl, var generator, var csharpOutputBuilder, var defaultArg) = ((ParmVarDecl, PInvokeGenerator, CSharp.CSharpOutputBuilder, Expr))context; - var desc = new ParameterDesc { - Name = escapedName, - Type = typeName, - NativeTypeName = nativeTypeName, - CppAttributes = _config.GenerateCppAttributes - ? parmVarDecl.Attrs.Select(x => EscapeString(x.Spelling)) - : null, - Location = parmVarDecl.Location, - WriteCustomAttrs = static context => { - (var parmVarDecl, var generator, var csharpOutputBuilder, var defaultArg) = ((ParmVarDecl, PInvokeGenerator, CSharp.CSharpOutputBuilder, Expr))context; + generator.WithAttributes(parmVarDecl); + generator.WithUsings(parmVarDecl); - generator.WithAttributes(parmVarDecl); - generator.WithUsings(parmVarDecl); + if (defaultArg is not null) + { + csharpOutputBuilder.WriteCustomAttribute("Optional, DefaultParameterValue(", () => { + generator.Visit(defaultArg); + csharpOutputBuilder.Write(')'); + }); + } + else + { + csharpOutputBuilder?.WriteCustomAttribute("Optional", null); + } + }, + CustomAttrGeneratorData = (parmVarDecl, this, null as CSharp.CSharpOutputBuilder, null as Expr), + IsForManualImport = isForManualImport + }; - if (defaultArg is not null) - { - csharpOutputBuilder.WriteCustomAttribute("Optional, DefaultParameterValue(", () => { - generator.Visit(defaultArg); - csharpOutputBuilder.Write(')'); - }); - } - else if (csharpOutputBuilder is not null) - { - csharpOutputBuilder.WriteCustomAttribute("Optional", null); - } - }, - CustomAttrGeneratorData = (parmVarDecl, this, null as CSharp.CSharpOutputBuilder, null as Expr), - IsForManualImport = isForManualImport - }; + var handledDefaultArg = false; + var isExprDefaultValue = false; - var handledDefaultArg = false; - var isExprDefaultValue = false; + if (parmVarDecl.HasDefaultArg) + { + isExprDefaultValue = IsDefaultValue(parmVarDecl.DefaultArg); - if (parmVarDecl.HasDefaultArg) + if ((_outputBuilder is CSharp.CSharpOutputBuilder csharpOutputBuilder) && (_config.WithTransparentStructs.ContainsKey(typeName) || parameters.Skip(index).Any((parmVarDecl) => { + var type = parmVarDecl.Type; + var typeName = GetTargetTypeName(parmVarDecl, out var nativeTypeName); + return _config.WithTransparentStructs.ContainsKey(typeName); + }))) { - isExprDefaultValue = IsDefaultValue(parmVarDecl.DefaultArg); - - if ((_outputBuilder is CSharp.CSharpOutputBuilder csharpOutputBuilder) && (_config.WithTransparentStructs.ContainsKey(typeName) || parameters.Skip(index).Any((parmVarDecl) => { - var type = parmVarDecl.Type; - var typeName = GetTargetTypeName(parmVarDecl, out var nativeTypeName); - return _config.WithTransparentStructs.ContainsKey(typeName); - }))) - { - desc.CustomAttrGeneratorData = (parmVarDecl, this, csharpOutputBuilder, isExprDefaultValue ? null : parmVarDecl.DefaultArg); - handledDefaultArg = true; - } + desc.CustomAttrGeneratorData = (parmVarDecl, this, csharpOutputBuilder, isExprDefaultValue ? null : parmVarDecl.DefaultArg); + handledDefaultArg = true; } + } - _outputBuilder.BeginParameter(in desc); - - if (parmVarDecl.HasDefaultArg && !handledDefaultArg) - { - _outputBuilder.BeginParameterDefault(); + _outputBuilder.BeginParameter(in desc); - var defaultArg = parmVarDecl.DefaultArg; + if (parmVarDecl.HasDefaultArg && !handledDefaultArg) + { + _outputBuilder.BeginParameterDefault(); - if (parmVarDecl.Type.CanonicalType.IsPointerType && (defaultArg.Handle.Evaluate.Kind == CXEvalResultKind.CXEval_UnExposed)) - { - if (!isExprDefaultValue) - { - AddDiagnostic(DiagnosticLevel.Info, $"Unsupported default parameter: '{name}'. Generated bindings may be incomplete.", defaultArg); - } + var defaultArg = parmVarDecl.DefaultArg; - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("null"); - StopCSharpCode(); - } - else + if (parmVarDecl.Type.CanonicalType.IsPointerType && (defaultArg.Handle.Evaluate.Kind == CXEvalResultKind.CXEval_UnExposed)) + { + if (!isExprDefaultValue) { - Visit(parmVarDecl.DefaultArg); + AddDiagnostic(DiagnosticLevel.Info, $"Unsupported default parameter: '{name}'. Generated bindings may be incomplete.", defaultArg); } - _outputBuilder.EndParameterDefault(); + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("null"); + StopCSharpCode(); } - - _outputBuilder.EndParameter(in desc); - - if ((index != lastIndex) || isForManualImport) + else { - _outputBuilder.WriteParameterSeparator(); + Visit(parmVarDecl.DefaultArg); } + + _outputBuilder.EndParameterDefault(); } - void ForTypedefDecl(ParmVarDecl parmVarDecl, TypedefDecl typedefDecl) - { - var type = parmVarDecl.Type; - var typeName = GetTargetTypeName(parmVarDecl, out var nativeTypeName); + _outputBuilder.EndParameter(in desc); - var name = GetRemappedCursorName(parmVarDecl); - var escapedName = EscapeName(name); + if ((index != lastIndex) || isForManualImport) + { + _outputBuilder.WriteParameterSeparator(); + } + } - var parameters = typedefDecl.CursorChildren.OfType().ToList(); - var index = parameters.IndexOf(parmVarDecl); - var lastIndex = parameters.Count - 1; + void ForTypedefDecl(ParmVarDecl parmVarDecl, TypedefDecl typedefDecl) + { + var type = parmVarDecl.Type; + var typeName = GetTargetTypeName(parmVarDecl, out var nativeTypeName); - if (name.Equals("param")) - { - escapedName += index; - } + var name = GetRemappedCursorName(parmVarDecl); + var escapedName = EscapeName(name); - var desc = new ParameterDesc - { - Name = escapedName, - Type = typeName, - NativeTypeName = nativeTypeName, - CppAttributes = _config.GenerateCppAttributes - ? parmVarDecl.Attrs.Select(x => EscapeString(x.Spelling)) - : null, - Location = parmVarDecl.Location, - WriteCustomAttrs = static context => { - (var parmVarDecl, var generator) = ((ParmVarDecl, PInvokeGenerator))context; + var parameters = typedefDecl.CursorChildren.OfType().ToList(); + var index = parameters.IndexOf(parmVarDecl); + var lastIndex = parameters.Count - 1; - generator.WithAttributes(parmVarDecl); - generator.WithUsings(parmVarDecl); - }, - CustomAttrGeneratorData = (parmVarDecl, this), - }; + if (name.Equals("param")) + { + escapedName += index; + } - _outputBuilder.BeginParameter(in desc); + var desc = new ParameterDesc + { + Name = escapedName, + Type = typeName, + NativeTypeName = nativeTypeName, + CppAttributes = _config.GenerateCppAttributes + ? parmVarDecl.Attrs.Select(x => EscapeString(x.Spelling)) + : null, + Location = parmVarDecl.Location, + WriteCustomAttrs = static context => { + (var parmVarDecl, var generator) = ((ParmVarDecl, PInvokeGenerator))context; - if (parmVarDecl.HasDefaultArg) - { - _outputBuilder.BeginParameterDefault(); - Visit(parmVarDecl.DefaultArg); - _outputBuilder.EndParameterDefault(); - } + generator.WithAttributes(parmVarDecl); + generator.WithUsings(parmVarDecl); + }, + CustomAttrGeneratorData = (parmVarDecl, this), + }; - _outputBuilder.EndParameter(in desc); + _outputBuilder.BeginParameter(in desc); - if (index != lastIndex) - { - _outputBuilder.WriteParameterSeparator(); - } + if (parmVarDecl.HasDefaultArg) + { + _outputBuilder.BeginParameterDefault(); + Visit(parmVarDecl.DefaultArg); + _outputBuilder.EndParameterDefault(); } - bool IsDefaultValue(Expr defaultArg) + _outputBuilder.EndParameter(in desc); + + if (index != lastIndex) { - return IsStmtAsWritten(defaultArg, out _, removeParens: true) || - (IsStmtAsWritten(defaultArg, out var castExpr, removeParens: true) && (castExpr.CastKind == CX_CastKind.CX_CK_NullToPointer)) || - (IsStmtAsWritten(defaultArg, out var integerLiteral, removeParens: true) && (integerLiteral.Value == 0)); + _outputBuilder.WriteParameterSeparator(); } } - private void VisitRecordDecl(RecordDecl recordDecl) + bool IsDefaultValue(Expr defaultArg) { - if (recordDecl.IsInjectedClassName) - { - // We shouldn't process injected records - return; - } + return IsStmtAsWritten(defaultArg, out _, removeParens: true) || + (IsStmtAsWritten(defaultArg, out var castExpr, removeParens: true) && (castExpr.CastKind == CX_CastKind.CX_CK_NullToPointer)) || + (IsStmtAsWritten(defaultArg, out var integerLiteral, removeParens: true) && (integerLiteral.Value == 0)); + } + } - var nativeName = GetCursorName(recordDecl); - var name = GetRemappedCursorName(recordDecl); - var escapedName = EscapeName(name); + private void VisitRecordDecl(RecordDecl recordDecl) + { + if (recordDecl.IsInjectedClassName) + { + // We shouldn't process injected records + return; + } - StartUsingOutputBuilder(name, includeTestOutput: true); - { - var cxxRecordDecl = recordDecl as CXXRecordDecl; - _cxxRecordDeclContext = cxxRecordDecl; + var nativeName = GetCursorName(recordDecl); + var name = GetRemappedCursorName(recordDecl); + var escapedName = EscapeName(name); - var hasVtbl = false; - var hasBaseVtbl = false; + StartUsingOutputBuilder(name, includeTestOutput: true); + { + var cxxRecordDecl = recordDecl as CXXRecordDecl; + _cxxRecordDeclContext = cxxRecordDecl; - if (cxxRecordDecl != null) - { - hasVtbl = HasVtbl(cxxRecordDecl, out hasBaseVtbl); - } + var hasVtbl = false; + var hasBaseVtbl = false; - var alignment = Math.Max(recordDecl.TypeForDecl.Handle.AlignOf, 1); - var maxAlignm = recordDecl.Fields.Any() ? recordDecl.Fields.Max((fieldDecl) => Math.Max(fieldDecl.Type.Handle.AlignOf, 1)) : alignment; + if (cxxRecordDecl != null) + { + hasVtbl = HasVtbl(cxxRecordDecl, out hasBaseVtbl); + } - var isTopLevelStruct = _config.WithTypes.TryGetValue(name, out var withType) && (withType == "struct"); - var generateTestsClass = _testOutputBuilder != null && !recordDecl.IsAnonymousStructOrUnion && recordDecl.DeclContext is not RecordDecl; + var alignment = Math.Max(recordDecl.TypeForDecl.Handle.AlignOf, 1); + var maxAlignm = recordDecl.Fields.Any() ? recordDecl.Fields.Max((fieldDecl) => Math.Max(fieldDecl.Type.Handle.AlignOf, 1)) : alignment; - if (generateTestsClass && !isTopLevelStruct) - { - _testOutputBuilder.WriteIndented("/// Provides validation of the struct."); + var isTopLevelStruct = _config.WithTypes.TryGetValue(name, out var withType) && (withType == "struct"); + var generateTestsClass = _testOutputBuilder != null && !recordDecl.IsAnonymousStructOrUnion && recordDecl.DeclContext is not RecordDecl; - WithAttributes(recordDecl, onlySupportedOSPlatform: true, isTestOutput: true); + if (generateTestsClass && !isTopLevelStruct) + { + _testOutputBuilder.WriteIndented("/// Provides validation of the struct."); - _testOutputBuilder.WriteIndented("public static unsafe partial class "); - _testOutputBuilder.Write(escapedName); - _testOutputBuilder.WriteLine("Tests"); - _testOutputBuilder.WriteBlockStart(); - } + WithAttributes(recordDecl, onlySupportedOSPlatform: true, isTestOutput: true); - var nullableUuid = (Guid?)null; - var uuidName = ""; + _testOutputBuilder.WriteIndented("public static unsafe partial class "); + _testOutputBuilder.Write(escapedName); + _testOutputBuilder.WriteLine("Tests"); + _testOutputBuilder.WriteBlockStart(); + } - if (TryGetUuid(recordDecl, out var uuid)) - { - nullableUuid = uuid; - uuidName = GetRemappedName($"IID_{nativeName}", recordDecl, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true); + var nullableUuid = (Guid?)null; + var uuidName = ""; - _uuidsToGenerate.Add(uuidName, uuid); + if (TryGetUuid(recordDecl, out var uuid)) + { + nullableUuid = uuid; + uuidName = GetRemappedName($"IID_{nativeName}", recordDecl, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true); - if (_testOutputBuilder != null) - { - var className = GetClass(uuidName); + _uuidsToGenerate.Add(uuidName, uuid); - _testOutputBuilder.AddUsingDirective("System"); - _testOutputBuilder.AddUsingDirective($"static {GetNamespace(className)}.{className}"); + if (_testOutputBuilder != null) + { + var className = GetClass(uuidName); - _testOutputBuilder.WriteIndented("/// Validates that the of the struct is correct."); + _testOutputBuilder.AddUsingDirective("System"); + _testOutputBuilder.AddUsingDirective($"static {GetNamespace(className)}.{className}"); - WithTestAttribute(); + _testOutputBuilder.WriteIndented("/// Validates that the of the struct is correct."); - _testOutputBuilder.WriteIndentedLine("public static void GuidOfTest()"); - _testOutputBuilder.WriteBlockStart(); + WithTestAttribute(); - if (_config.GenerateTestsNUnit) - { - _testOutputBuilder.WriteIndented("Assert.That"); - } - else if (_config.GenerateTestsXUnit) - { - _testOutputBuilder.WriteIndented("Assert.Equal"); - } + _testOutputBuilder.WriteIndentedLine("public static void GuidOfTest()"); + _testOutputBuilder.WriteBlockStart(); - _testOutputBuilder.Write("(typeof("); - _testOutputBuilder.Write(escapedName); - _testOutputBuilder.Write(").GUID, "); + if (_config.GenerateTestsNUnit) + { + _testOutputBuilder.WriteIndented("Assert.That"); + } + else if (_config.GenerateTestsXUnit) + { + _testOutputBuilder.WriteIndented("Assert.Equal"); + } - if (_config.GenerateTestsNUnit) - { - _testOutputBuilder.Write("Is.EqualTo("); - } + _testOutputBuilder.Write("(typeof("); + _testOutputBuilder.Write(escapedName); + _testOutputBuilder.Write(").GUID, "); - _testOutputBuilder.Write(uuidName); + if (_config.GenerateTestsNUnit) + { + _testOutputBuilder.Write("Is.EqualTo("); + } - if (_config.GenerateTestsNUnit) - { - _testOutputBuilder.Write(')'); - } + _testOutputBuilder.Write(uuidName); + if (_config.GenerateTestsNUnit) + { _testOutputBuilder.Write(')'); - _testOutputBuilder.WriteSemicolon(); - _testOutputBuilder.WriteNewline(); - _testOutputBuilder.WriteBlockEnd(); - _testOutputBuilder.NeedsNewline = true; } + + _testOutputBuilder.Write(')'); + _testOutputBuilder.WriteSemicolon(); + _testOutputBuilder.WriteNewline(); + _testOutputBuilder.WriteBlockEnd(); + _testOutputBuilder.NeedsNewline = true; } + } - var hasGuidMember = _config.GenerateGuidMember && !string.IsNullOrWhiteSpace(uuidName); + var hasGuidMember = _config.GenerateGuidMember && !string.IsNullOrWhiteSpace(uuidName); - var layoutKind = recordDecl.IsUnion - ? LayoutKind.Explicit - : LayoutKind.Sequential; + var layoutKind = recordDecl.IsUnion + ? LayoutKind.Explicit + : LayoutKind.Sequential; - long alignment32 = -1; - long alignment64 = -1; + long alignment32 = -1; + long alignment64 = -1; - GetTypeSize(recordDecl, recordDecl.TypeForDecl, ref alignment32, ref alignment64, out var size32, out var size64); + GetTypeSize(recordDecl, recordDecl.TypeForDecl, ref alignment32, ref alignment64, out var size32, out var size64); - string[] baseTypeNames = null; + string[] baseTypeNames = null; - string nativeNameWithExtras = null, nativeInheritance = null; - if ((cxxRecordDecl != null) && cxxRecordDecl.Bases.Any()) - { - var nativeTypeNameBuilder = new StringBuilder(); - var baseTypeNamesBuilder = new List(); + string nativeNameWithExtras = null, nativeInheritance = null; + if ((cxxRecordDecl != null) && cxxRecordDecl.Bases.Any()) + { + var nativeTypeNameBuilder = new StringBuilder(); + var baseTypeNamesBuilder = new List(); + + _ = nativeTypeNameBuilder.Append(recordDecl.IsUnion ? "union " : "struct "); + _ = nativeTypeNameBuilder.Append(nativeName); + _ = nativeTypeNameBuilder.Append(" : "); + + var baseName = GetRemappedCursorName(cxxRecordDecl.Bases[0].Referenced, out var nativeBaseName, skipUsing: !_config.GenerateMarkerInterfaces); - _ = nativeTypeNameBuilder.Append(recordDecl.IsUnion ? "union " : "struct "); - _ = nativeTypeNameBuilder.Append(nativeName); - _ = nativeTypeNameBuilder.Append(" : "); + baseTypeNamesBuilder.Add(baseName); + _ = nativeTypeNameBuilder.Append(nativeBaseName); - var baseName = GetRemappedCursorName(cxxRecordDecl.Bases[0].Referenced, out var nativeBaseName, skipUsing: !_config.GenerateMarkerInterfaces); + for (var i = 1; i < cxxRecordDecl.Bases.Count; i++) + { + _ = nativeTypeNameBuilder.Append(", "); + baseName = GetRemappedCursorName(cxxRecordDecl.Bases[i].Referenced, out nativeBaseName, skipUsing: !_config.GenerateMarkerInterfaces); baseTypeNamesBuilder.Add(baseName); _ = nativeTypeNameBuilder.Append(nativeBaseName); + } - for (var i = 1; i < cxxRecordDecl.Bases.Count; i++) - { - _ = nativeTypeNameBuilder.Append(", "); - baseName = GetRemappedCursorName(cxxRecordDecl.Bases[i].Referenced, out nativeBaseName, skipUsing: !_config.GenerateMarkerInterfaces); + nativeNameWithExtras = nativeTypeNameBuilder.ToString(); + nativeInheritance = GetCursorName(cxxRecordDecl.Bases.Last().Referenced); + baseTypeNames = baseTypeNamesBuilder.ToArray(); + } - baseTypeNamesBuilder.Add(baseName); - _ = nativeTypeNameBuilder.Append(nativeBaseName); - } + var desc = new StructDesc { + AccessSpecifier = GetAccessSpecifier(recordDecl, matchStar: true), + EscapedName = escapedName, + IsUnsafe = IsUnsafe(recordDecl) || hasGuidMember, + HasVtbl = hasVtbl || hasBaseVtbl, + IsUnion = recordDecl.IsUnion, + Layout = new() { + Alignment32 = alignment32, + Alignment64 = alignment64, + Size32 = size32, + Size64 = size64, + Pack = alignment < maxAlignm ? alignment : 0, + MaxFieldAlignment = maxAlignm, + Kind = layoutKind + }, + Uuid = nullableUuid, + NativeType = nativeNameWithExtras, + NativeInheritance = _config.GenerateNativeInheritanceAttribute ? nativeInheritance : null, + Location = recordDecl.Location, + IsNested = recordDecl.DeclContext is TagDecl, + WriteCustomAttrs = static context => { + (var recordDecl, var generator) = ((RecordDecl, PInvokeGenerator))context; - nativeNameWithExtras = nativeTypeNameBuilder.ToString(); - nativeInheritance = GetCursorName(cxxRecordDecl.Bases.Last().Referenced); - baseTypeNames = baseTypeNamesBuilder.ToArray(); + generator.WithAttributes(recordDecl); + generator.WithUsings(recordDecl); + }, + CustomAttrGeneratorData = (recordDecl, this), + }; + + if (!isTopLevelStruct) + { + _outputBuilder.BeginStruct(in desc); + } + else + { + if (!_topLevelClassAttributes.TryGetValue(name, out var withAttributes)) + { + withAttributes = new List(); } - var desc = new StructDesc { - AccessSpecifier = GetAccessSpecifier(recordDecl, matchStar: true), - EscapedName = escapedName, - IsUnsafe = IsUnsafe(recordDecl) || hasGuidMember, - HasVtbl = hasVtbl || hasBaseVtbl, - IsUnion = recordDecl.IsUnion, - Layout = new() { - Alignment32 = alignment32, - Alignment64 = alignment64, - Size32 = size32, - Size64 = size64, - Pack = alignment < maxAlignm ? alignment : 0, - MaxFieldAlignment = maxAlignm, - Kind = layoutKind - }, - Uuid = nullableUuid, - NativeType = nativeNameWithExtras, - NativeInheritance = _config.GenerateNativeInheritanceAttribute ? nativeInheritance : null, - Location = recordDecl.Location, - IsNested = recordDecl.DeclContext is TagDecl, - WriteCustomAttrs = static context => { - (var recordDecl, var generator) = ((RecordDecl, PInvokeGenerator))context; + if (!_topLevelClassUsings.TryGetValue(name, out var withUsings)) + { + withUsings = new HashSet(); + } - generator.WithAttributes(recordDecl); - generator.WithUsings(recordDecl); - }, - CustomAttrGeneratorData = (recordDecl, this), - }; + if (desc.LayoutAttribute is not null) + { + withAttributes.Add($"StructLayout(LayoutKind.{desc.LayoutAttribute.Value}{((desc.LayoutAttribute.Pack != 0) ? $", Pack = {desc.LayoutAttribute.Pack}" : "")})"); + _ = withUsings.Add("System.Runtime.InteropServices"); + } - if (!isTopLevelStruct) + if (desc.Uuid is not null) { - _outputBuilder.BeginStruct(in desc); + withAttributes.Add($"Guid(\"{nullableUuid.Value.ToString("D", CultureInfo.InvariantCulture).ToUpperInvariant()}\")"); + _ = withUsings.Add("System.Runtime.InteropServices"); } - else + + if (desc.NativeType is not null) { - if (!_topLevelClassAttributes.TryGetValue(name, out var withAttributes)) - { - withAttributes = new List(); - } - - if (!_topLevelClassUsings.TryGetValue(name, out var withUsings)) - { - withUsings = new HashSet(); - } - - if (desc.LayoutAttribute is not null) - { - withAttributes.Add($"StructLayout(LayoutKind.{desc.LayoutAttribute.Value}{((desc.LayoutAttribute.Pack != 0) ? $", Pack = {desc.LayoutAttribute.Pack}" : "")})"); - _ = withUsings.Add("System.Runtime.InteropServices"); - } - - if (desc.Uuid is not null) - { - withAttributes.Add($"Guid(\"{nullableUuid.Value.ToString("D", CultureInfo.InvariantCulture).ToUpperInvariant()}\")"); - _ = withUsings.Add("System.Runtime.InteropServices"); - } - - if (desc.NativeType is not null) - { - withAttributes.Add($"NativeTypeName(\"{EscapeString(desc.NativeType)}\")"); - _ = withUsings.Add(GetNamespace("NativeTypeNameAttribute")); - } - - if (_config.GenerateNativeInheritanceAttribute && (desc.NativeInheritance is not null)) - { - withAttributes.Add($"NativeInheritance(\"{desc.NativeInheritance}\")"); - _ = withUsings.Add(GetNamespace("NativeInheritanceAttribute")); - } + withAttributes.Add($"NativeTypeName(\"{EscapeString(desc.NativeType)}\")"); + _ = withUsings.Add(GetNamespace("NativeTypeNameAttribute")); + } - if (_config.GenerateSourceLocationAttribute && (desc.Location is not null)) - { - desc.Location.Value.GetFileLocation(out var file, out var line, out var column, out _); - withAttributes.Add($"SourceLocation(\"{EscapeString(file.Name.ToString())}\", {line}, {column})"); - _ = withUsings.Add(GetNamespace("SourceLocationAttribute")); - } + if (_config.GenerateNativeInheritanceAttribute && (desc.NativeInheritance is not null)) + { + withAttributes.Add($"NativeInheritance(\"{desc.NativeInheritance}\")"); + _ = withUsings.Add(GetNamespace("NativeInheritanceAttribute")); + } - if (withAttributes.Count != 0) - { - _topLevelClassAttributes[name] = withAttributes; - } + if (_config.GenerateSourceLocationAttribute && (desc.Location is not null)) + { + desc.Location.Value.GetFileLocation(out var file, out var line, out var column, out _); + withAttributes.Add($"SourceLocation(\"{EscapeString(file.Name.ToString())}\", {line}, {column})"); + _ = withUsings.Add(GetNamespace("SourceLocationAttribute")); + } - if (withUsings.Count != 0) - { - _topLevelClassUsings[name] = withUsings; - } + if (withAttributes.Count != 0) + { + _topLevelClassAttributes[name] = withAttributes; + } - if (desc.IsUnsafe) - { - _topLevelClassIsUnsafe[name] = true; - } + if (withUsings.Count != 0) + { + _topLevelClassUsings[name] = withUsings; + } - if (hasGuidMember) - { - _topLevelClassHasGuidMember[name] = true; - } + if (desc.IsUnsafe) + { + _topLevelClassIsUnsafe[name] = true; } if (hasGuidMember) { - var valueDesc = new ValueDesc { - AccessSpecifier = AccessSpecifier.None, - TypeName = "Guid*", - EscapedName = "INativeGuid.NativeGuid", - ParentName = name, - Kind = ValueKind.GuidMember, - Flags = ValueFlags.Initializer, - }; + _topLevelClassHasGuidMember[name] = true; + } + } - var uuidClassName = GetClass(uuidName); + if (hasGuidMember) + { + var valueDesc = new ValueDesc { + AccessSpecifier = AccessSpecifier.None, + TypeName = "Guid*", + EscapedName = "INativeGuid.NativeGuid", + ParentName = name, + Kind = ValueKind.GuidMember, + Flags = ValueFlags.Initializer, + }; - _outputBuilder.EmitUsingDirective("System"); - _outputBuilder.EmitUsingDirective("System.Runtime.CompilerServices"); + var uuidClassName = GetClass(uuidName); - _outputBuilder.EmitUsingDirective($"static {GetNamespace(uuidClassName)}.{uuidClassName}"); - _outputBuilder.BeginValue(in valueDesc); + _outputBuilder.EmitUsingDirective("System"); + _outputBuilder.EmitUsingDirective("System.Runtime.CompilerServices"); - var code = _outputBuilder.BeginCSharpCode(); - code.Write("(Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in "); - code.Write(uuidName); - code.Write("))"); - _outputBuilder.EndCSharpCode(code); + _outputBuilder.EmitUsingDirective($"static {GetNamespace(uuidClassName)}.{uuidClassName}"); + _outputBuilder.BeginValue(in valueDesc); - _outputBuilder.EndValue(in valueDesc); - } + var code = _outputBuilder.BeginCSharpCode(); + code.Write("(Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in "); + code.Write(uuidName); + code.Write("))"); + _outputBuilder.EndCSharpCode(code); - if (hasVtbl || (hasBaseVtbl && !HasBaseField(cxxRecordDecl))) - { - var fieldDesc = new FieldDesc { - AccessSpecifier = AccessSpecifier.Public, - NativeTypeName = null, - EscapedName = "lpVtbl", - Offset = null, - NeedsNewKeyword = false, - }; + _outputBuilder.EndValue(in valueDesc); + } - _outputBuilder.BeginField(in fieldDesc); + if (hasVtbl || (hasBaseVtbl && !HasBaseField(cxxRecordDecl))) + { + var fieldDesc = new FieldDesc { + AccessSpecifier = AccessSpecifier.Public, + NativeTypeName = null, + EscapedName = "lpVtbl", + Offset = null, + NeedsNewKeyword = false, + }; - if (_config.GenerateExplicitVtbls) + _outputBuilder.BeginField(in fieldDesc); + + if (_config.GenerateExplicitVtbls) + { + if (_config.GenerateMarkerInterfaces && !_config.GenerateCompatibleCode) { - if (_config.GenerateMarkerInterfaces && !_config.GenerateCompatibleCode) - { - _outputBuilder.WriteRegularField($"Vtbl<{nativeName}>*", "lpVtbl"); - } - else - { - _outputBuilder.WriteRegularField("Vtbl*", "lpVtbl"); - } + _outputBuilder.WriteRegularField($"Vtbl<{nativeName}>*", "lpVtbl"); } else { - _outputBuilder.WriteRegularField("void**", "lpVtbl"); + _outputBuilder.WriteRegularField("Vtbl*", "lpVtbl"); } - - _outputBuilder.EndField(in fieldDesc); } - - if (cxxRecordDecl != null) + else { - for (var index = 0; index < cxxRecordDecl.Bases.Count; index++) - { - var cxxBaseSpecifier = cxxRecordDecl.Bases[index]; - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - - if (HasField(baseCxxRecordDecl)) - { - var parent = GetRemappedCursorName(baseCxxRecordDecl); - var baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); - baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); - - var fieldDesc = new FieldDesc { - AccessSpecifier = GetAccessSpecifier(baseCxxRecordDecl, matchStar: true), - NativeTypeName = null, - EscapedName = baseFieldName, - Offset = null, - NeedsNewKeyword = false, - InheritedFrom = parent, - Location = cxxBaseSpecifier.Location, - }; - - _outputBuilder.BeginField(in fieldDesc); - _outputBuilder.WriteRegularField(parent, baseFieldName); - _outputBuilder.EndField(in fieldDesc); - } - } + _outputBuilder.WriteRegularField("void**", "lpVtbl"); } - if (generateTestsClass) + _outputBuilder.EndField(in fieldDesc); + } + + if (cxxRecordDecl != null) + { + for (var index = 0; index < cxxRecordDecl.Bases.Count; index++) { - _testOutputBuilder.WriteIndented("/// Validates that the struct is blittable."); + var cxxBaseSpecifier = cxxRecordDecl.Bases[index]; + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - WithTestAttribute(); + if (HasField(baseCxxRecordDecl)) + { + var parent = GetRemappedCursorName(baseCxxRecordDecl); + var baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); + baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); - _testOutputBuilder.WriteIndentedLine("public static void IsBlittableTest()"); - _testOutputBuilder.WriteBlockStart(); + var fieldDesc = new FieldDesc { + AccessSpecifier = GetAccessSpecifier(baseCxxRecordDecl, matchStar: true), + NativeTypeName = null, + EscapedName = baseFieldName, + Offset = null, + NeedsNewKeyword = false, + InheritedFrom = parent, + Location = cxxBaseSpecifier.Location, + }; - WithTestAssertEqual($"sizeof({escapedName})", $"Marshal.SizeOf<{escapedName}>()"); + _outputBuilder.BeginField(in fieldDesc); + _outputBuilder.WriteRegularField(parent, baseFieldName); + _outputBuilder.EndField(in fieldDesc); + } + } + } - _testOutputBuilder.WriteBlockEnd(); - _testOutputBuilder.NeedsNewline = true; + if (generateTestsClass) + { + _testOutputBuilder.WriteIndented("/// Validates that the struct is blittable."); - _testOutputBuilder.WriteIndented("/// Validates that the struct has the right ."); + WithTestAttribute(); - WithTestAttribute(); + _testOutputBuilder.WriteIndentedLine("public static void IsBlittableTest()"); + _testOutputBuilder.WriteBlockStart(); - _testOutputBuilder.WriteIndented("public static void IsLayout"); + WithTestAssertEqual($"sizeof({escapedName})", $"Marshal.SizeOf<{escapedName}>()"); - if (recordDecl.IsUnion) - { - _testOutputBuilder.Write("Explicit"); - } - else - { - _testOutputBuilder.Write("Sequential"); - } + _testOutputBuilder.WriteBlockEnd(); + _testOutputBuilder.NeedsNewline = true; - _testOutputBuilder.WriteLine("Test()"); - _testOutputBuilder.WriteBlockStart(); + _testOutputBuilder.WriteIndented("/// Validates that the struct has the right ."); - WithTestAssertTrue($"typeof({escapedName}).Is{(recordDecl.IsUnion ? "ExplicitLayout" : "LayoutSequential")}"); + WithTestAttribute(); - _testOutputBuilder.WriteBlockEnd(); - _testOutputBuilder.NeedsNewline = true; + _testOutputBuilder.WriteIndented("public static void IsLayout"); - if ((size32 == 0 || size64 == 0) && !TryGetUuid(recordDecl, out _)) - { - AddDiagnostic(DiagnosticLevel.Info, $"{escapedName} has a size of 0", recordDecl); - } + if (recordDecl.IsUnion) + { + _testOutputBuilder.Write("Explicit"); + } + else + { + _testOutputBuilder.Write("Sequential"); + } - _testOutputBuilder.WriteIndented("/// Validates that the struct has the correct size."); + _testOutputBuilder.WriteLine("Test()"); + _testOutputBuilder.WriteBlockStart(); - WithTestAttribute(); + WithTestAssertTrue($"typeof({escapedName}).Is{(recordDecl.IsUnion ? "ExplicitLayout" : "LayoutSequential")}"); - _testOutputBuilder.WriteIndentedLine("public static void SizeOfTest()"); - _testOutputBuilder.WriteBlockStart(); + _testOutputBuilder.WriteBlockEnd(); + _testOutputBuilder.NeedsNewline = true; - if (size32 != size64) - { - _testOutputBuilder.AddUsingDirective("System"); + if ((size32 == 0 || size64 == 0) && !TryGetUuid(recordDecl, out _)) + { + AddDiagnostic(DiagnosticLevel.Info, $"{escapedName} has a size of 0", recordDecl); + } - _testOutputBuilder.WriteIndentedLine("if (Environment.Is64BitProcess)"); - _testOutputBuilder.WriteBlockStart(); + _testOutputBuilder.WriteIndented("/// Validates that the struct has the correct size."); - WithTestAssertEqual($"{Math.Max(size64, 1)}", $"sizeof({escapedName})"); + WithTestAttribute(); - _testOutputBuilder.WriteBlockEnd(); - _testOutputBuilder.WriteIndentedLine("else"); - _testOutputBuilder.WriteBlockStart(); - } + _testOutputBuilder.WriteIndentedLine("public static void SizeOfTest()"); + _testOutputBuilder.WriteBlockStart(); - WithTestAssertEqual($"{Math.Max(size32, 1)}", $"sizeof({escapedName})"); + if (size32 != size64) + { + _testOutputBuilder.AddUsingDirective("System"); - if (size32 != size64) - { - _testOutputBuilder.WriteBlockEnd(); - } + _testOutputBuilder.WriteIndentedLine("if (Environment.Is64BitProcess)"); + _testOutputBuilder.WriteBlockStart(); + + WithTestAssertEqual($"{Math.Max(size64, 1)}", $"sizeof({escapedName})"); _testOutputBuilder.WriteBlockEnd(); + _testOutputBuilder.WriteIndentedLine("else"); + _testOutputBuilder.WriteBlockStart(); } - var bitfieldTypes = GetBitfieldCount(recordDecl); - var bitfieldIndex = (bitfieldTypes.Length == 1) ? -1 : 0; + WithTestAssertEqual($"{Math.Max(size32, 1)}", $"sizeof({escapedName})"); - var bitfieldPreviousSize = 0L; - var bitfieldRemainingBits = 0L; - - foreach (var fieldDecl in recordDecl.Fields) + if (size32 != size64) { - if (fieldDecl.IsBitField) - { - VisitBitfieldDecl(fieldDecl, bitfieldTypes, recordDecl, contextName: "", ref bitfieldIndex, ref bitfieldPreviousSize, ref bitfieldRemainingBits); - } - else - { - bitfieldPreviousSize = 0; - bitfieldRemainingBits = 0; - } - - Visit(fieldDecl); - _outputBuilder.WriteDivider(); + _testOutputBuilder.WriteBlockEnd(); } - Visit(recordDecl.IndirectFields); + _testOutputBuilder.WriteBlockEnd(); + } - if (cxxRecordDecl != null) - { - foreach (var cxxConstructorDecl in cxxRecordDecl.Ctors) - { - Visit(cxxConstructorDecl); - _outputBuilder.WriteDivider(); - } + var bitfieldTypes = GetBitfieldCount(recordDecl); + var bitfieldIndex = (bitfieldTypes.Length == 1) ? -1 : 0; - if (cxxRecordDecl.HasUserDeclaredDestructor && !cxxRecordDecl.Destructor.IsVirtual) - { - Visit(cxxRecordDecl.Destructor); - _outputBuilder.WriteDivider(); - } + var bitfieldPreviousSize = 0L; + var bitfieldRemainingBits = 0L; - if (hasVtbl || hasBaseVtbl) - { - OutputDelegateSignatures(cxxRecordDecl, cxxRecordDecl); - } + foreach (var fieldDecl in recordDecl.Fields) + { + if (fieldDecl.IsBitField) + { + VisitBitfieldDecl(fieldDecl, bitfieldTypes, recordDecl, contextName: "", ref bitfieldIndex, ref bitfieldPreviousSize, ref bitfieldRemainingBits); + } + else + { + bitfieldPreviousSize = 0; + bitfieldRemainingBits = 0; } - var excludedCursors = recordDecl.Fields.AsEnumerable().Concat(recordDecl.IndirectFields); + Visit(fieldDecl); + _outputBuilder.WriteDivider(); + } + + Visit(recordDecl.IndirectFields); - if (cxxRecordDecl != null) + if (cxxRecordDecl != null) + { + foreach (var cxxConstructorDecl in cxxRecordDecl.Ctors) { - OutputMethods(cxxRecordDecl, cxxRecordDecl); - excludedCursors = excludedCursors.Concat(cxxRecordDecl.Methods); + Visit(cxxConstructorDecl); + _outputBuilder.WriteDivider(); } - Visit(recordDecl.Decls, excludedCursors); - - foreach (var array in recordDecl.Fields.Where((field) => field.Type.CanonicalType is ConstantArrayType or IncompleteArrayType)) + if (cxxRecordDecl.HasUserDeclaredDestructor && !cxxRecordDecl.Destructor.IsVirtual) { - VisitConstantOrIncompleteArrayFieldDecl(recordDecl, array); + Visit(cxxRecordDecl.Destructor); + _outputBuilder.WriteDivider(); } if (hasVtbl || hasBaseVtbl) { - if (!_config.GenerateCompatibleCode) - { - _outputBuilder.EmitCompatibleCodeSupport(); - } - - if (_config.ExcludeFnptrCodegen) - { - _outputBuilder.EmitFnPtrSupport(); - } + OutputDelegateSignatures(cxxRecordDecl, cxxRecordDecl); + } + } - OutputVtblHelperMethods(cxxRecordDecl, cxxRecordDecl); + var excludedCursors = recordDecl.Fields.AsEnumerable().Concat(recordDecl.IndirectFields); - if (_config.GenerateMarkerInterfaces) - { - if (_outputBuilder is CSharp.CSharpOutputBuilder csharpOutputBuilder) - { - csharpOutputBuilder.NeedsNewline = true; - } + if (cxxRecordDecl != null) + { + OutputMethods(cxxRecordDecl, cxxRecordDecl); + excludedCursors = excludedCursors.Concat(cxxRecordDecl.Methods); + } - _outputBuilder.BeginMarkerInterface(baseTypeNames); - OutputMarkerInterfaces(cxxRecordDecl, cxxRecordDecl); - _outputBuilder.EndMarkerInterface(); - } + Visit(recordDecl.Decls, excludedCursors); - if (_config.GenerateExplicitVtbls || _config.GenerateTrimmableVtbls) - { - if (_outputBuilder is CSharp.CSharpOutputBuilder csharpOutputBuilder) - { - csharpOutputBuilder.NeedsNewline = true; - } + foreach (var array in recordDecl.Fields.Where((field) => field.Type.CanonicalType is ConstantArrayType or IncompleteArrayType)) + { + VisitConstantOrIncompleteArrayFieldDecl(recordDecl, array); + } - _outputBuilder.BeginExplicitVtbl(); - OutputVtblEntries(cxxRecordDecl, cxxRecordDecl); - _outputBuilder.EndExplicitVtbl(); - } + if (hasVtbl || hasBaseVtbl) + { + if (!_config.GenerateCompatibleCode) + { + _outputBuilder.EmitCompatibleCodeSupport(); } - if (!isTopLevelStruct) + if (_config.ExcludeFnptrCodegen) { - _outputBuilder.EndStruct(in desc); + _outputBuilder.EmitFnPtrSupport(); + } - if (generateTestsClass) + OutputVtblHelperMethods(cxxRecordDecl, cxxRecordDecl); + + if (_config.GenerateMarkerInterfaces) + { + if (_outputBuilder is CSharp.CSharpOutputBuilder csharpOutputBuilder) { - _testOutputBuilder.WriteBlockEnd(); + csharpOutputBuilder.NeedsNewline = true; } + + _outputBuilder.BeginMarkerInterface(baseTypeNames); + OutputMarkerInterfaces(cxxRecordDecl, cxxRecordDecl); + _outputBuilder.EndMarkerInterface(); } - _cxxRecordDeclContext = null; + if (_config.GenerateExplicitVtbls || _config.GenerateTrimmableVtbls) + { + if (_outputBuilder is CSharp.CSharpOutputBuilder csharpOutputBuilder) + { + csharpOutputBuilder.NeedsNewline = true; + } + + _outputBuilder.BeginExplicitVtbl(); + OutputVtblEntries(cxxRecordDecl, cxxRecordDecl); + _outputBuilder.EndExplicitVtbl(); + } } - StopUsingOutputBuilder(); - string FixupNameForMultipleHits(CXXMethodDecl cxxMethodDecl) + if (!isTopLevelStruct) { - var remappedName = GetRemappedCursorName(cxxMethodDecl); - var overloadIndex = GetOverloadIndex(cxxMethodDecl); + _outputBuilder.EndStruct(in desc); - if (overloadIndex != 0) + if (generateTestsClass) { - remappedName = $"{remappedName}{overloadIndex}"; + _testOutputBuilder.WriteBlockEnd(); } - return remappedName; } - void OutputDelegateSignatures(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) + _cxxRecordDeclContext = null; + } + StopUsingOutputBuilder(); + + string FixupNameForMultipleHits(CXXMethodDecl cxxMethodDecl) + { + var remappedName = GetRemappedCursorName(cxxMethodDecl); + var overloadIndex = GetOverloadIndex(cxxMethodDecl); + + if (overloadIndex != 0) { - if (!_config.ExcludeFnptrCodegen) - { - return; - } + remappedName = $"{remappedName}{overloadIndex}"; + } + return remappedName; + } - foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) - { - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - OutputDelegateSignatures(rootCxxRecordDecl, baseCxxRecordDecl); - } + void OutputDelegateSignatures(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) + { + if (!_config.ExcludeFnptrCodegen) + { + return; + } - var cxxMethodDecls = cxxRecordDecl.Methods; + foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) + { + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); + OutputDelegateSignatures(rootCxxRecordDecl, baseCxxRecordDecl); + } - if (cxxMethodDecls.Count != 0) + var cxxMethodDecls = cxxRecordDecl.Methods; + + if (cxxMethodDecls.Count != 0) + { + foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) { - foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) + if (!cxxMethodDecl.IsVirtual) { - if (!cxxMethodDecl.IsVirtual) - { - continue; - } + continue; + } - if (IsExcluded(cxxMethodDecl, out var isExcludedByConflictingDefinition)) - { - continue; - } + if (IsExcluded(cxxMethodDecl, out var isExcludedByConflictingDefinition)) + { + continue; + } - _outputBuilder.WriteDivider(); + _outputBuilder.WriteDivider(); - var remappedName = FixupNameForMultipleHits(cxxMethodDecl); - Debug.Assert(CurrentContext.Cursor == rootCxxRecordDecl); - Visit(cxxMethodDecl); - } + var remappedName = FixupNameForMultipleHits(cxxMethodDecl); + Debug.Assert(CurrentContext.Cursor == rootCxxRecordDecl); + Visit(cxxMethodDecl); } } + } - void OutputMethods(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) + void OutputMethods(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) + { + foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) { - foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) - { - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - OutputMethods(rootCxxRecordDecl, baseCxxRecordDecl); - } + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); + OutputMethods(rootCxxRecordDecl, baseCxxRecordDecl); + } - var cxxMethodDecls = cxxRecordDecl.Methods; + var cxxMethodDecls = cxxRecordDecl.Methods; - if (cxxMethodDecls.Count != 0) + if (cxxMethodDecls.Count != 0) + { + foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) { - foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) + if (cxxMethodDecl.IsVirtual) { - if (cxxMethodDecl.IsVirtual) - { - continue; - } - - if (cxxMethodDecl is CXXConstructorDecl or CXXDestructorDecl) - { - continue; - } + continue; + } - Debug.Assert(CurrentContext.Cursor == rootCxxRecordDecl); - Visit(cxxMethodDecl); - _outputBuilder.WriteDivider(); + if (cxxMethodDecl is CXXConstructorDecl or CXXDestructorDecl) + { + continue; } + + Debug.Assert(CurrentContext.Cursor == rootCxxRecordDecl); + Visit(cxxMethodDecl); + _outputBuilder.WriteDivider(); } } + } - void OutputMarkerInterface(CXXRecordDecl cxxRecordDecl, CXXMethodDecl cxxMethodDecl) + void OutputMarkerInterface(CXXRecordDecl cxxRecordDecl, CXXMethodDecl cxxMethodDecl) + { + if (!cxxMethodDecl.IsVirtual) { - if (!cxxMethodDecl.IsVirtual) - { - return; - } - - if (IsExcluded(cxxMethodDecl, out var isExcludedByConflictingDefinition)) - { - return; - } - - if (_config.GenerateTrimmableVtbls && cxxMethodDecl.Parameters.Any((parmVarDecl) => (parmVarDecl.Type.CanonicalType is PointerType pointerType) && (pointerType.PointeeType is FunctionType))) - { - // This breaks trimming right now - return; - } + return; + } - var currentContext = _context.AddLast((cxxMethodDecl, null)); + if (IsExcluded(cxxMethodDecl, out var isExcludedByConflictingDefinition)) + { + return; + } - var returnType = cxxMethodDecl.ReturnType; - var returnTypeName = GetRemappedTypeName(cxxMethodDecl, cxxRecordDecl, returnType, out var nativeTypeName); + if (_config.GenerateTrimmableVtbls && cxxMethodDecl.Parameters.Any((parmVarDecl) => (parmVarDecl.Type.CanonicalType is PointerType pointerType) && (pointerType.PointeeType is FunctionType))) + { + // This breaks trimming right now + return; + } - var remappedName = FixupNameForMultipleHits(cxxMethodDecl); - var name = GetRemappedCursorName(cxxMethodDecl); - var needsReturnFixup = false; - var needsCastToTransparentStruct = false; + var currentContext = _context.AddLast((cxxMethodDecl, null)); - if (returnType.Kind != CXTypeKind.CXType_Void) - { - needsReturnFixup = NeedsReturnFixup(cxxMethodDecl); - needsCastToTransparentStruct = _config.WithTransparentStructs.TryGetValue(returnTypeName, out var transparentStruct) && IsTransparentStructHandle(transparentStruct.Kind); - } + var returnType = cxxMethodDecl.ReturnType; + var returnTypeName = GetRemappedTypeName(cxxMethodDecl, cxxRecordDecl, returnType, out var nativeTypeName); - var desc = new FunctionOrDelegateDesc { - AccessSpecifier = AccessSpecifier.Public, - EscapedName = EscapeAndStripName(name), - IsMemberFunction = true, - NativeTypeName = nativeTypeName, - HasFnPtrCodeGen = !_config.ExcludeFnptrCodegen, - IsCtxCxxRecord = true, - IsCxxRecordCtxUnsafe = IsUnsafe(cxxRecordDecl), - IsUnsafe = true, - NeedsReturnFixup = needsReturnFixup, - ReturnType = returnTypeName, - VtblIndex = _config.GenerateVtblIndexAttribute ? cxxMethodDecl.VtblIndex : -1, - Location = cxxMethodDecl.Location, - WriteCustomAttrs = static context => { - (var cxxMethodDecl, var generator) = ((CXXMethodDecl, PInvokeGenerator))context; + var remappedName = FixupNameForMultipleHits(cxxMethodDecl); + var name = GetRemappedCursorName(cxxMethodDecl); + var needsReturnFixup = false; + var needsCastToTransparentStruct = false; - generator.WithAttributes(cxxMethodDecl); - generator.WithUsings(cxxMethodDecl); - }, - CustomAttrGeneratorData = (cxxMethodDecl, this), - }; + if (returnType.Kind != CXTypeKind.CXType_Void) + { + needsReturnFixup = NeedsReturnFixup(cxxMethodDecl); + needsCastToTransparentStruct = _config.WithTransparentStructs.TryGetValue(returnTypeName, out var transparentStruct) && IsTransparentStructHandle(transparentStruct.Kind); + } - var isUnsafe = true; - _outputBuilder.BeginFunctionOrDelegate(in desc, ref isUnsafe); + var desc = new FunctionOrDelegateDesc { + AccessSpecifier = AccessSpecifier.Public, + EscapedName = EscapeAndStripName(name), + IsMemberFunction = true, + NativeTypeName = nativeTypeName, + HasFnPtrCodeGen = !_config.ExcludeFnptrCodegen, + IsCtxCxxRecord = true, + IsCxxRecordCtxUnsafe = IsUnsafe(cxxRecordDecl), + IsUnsafe = true, + NeedsReturnFixup = needsReturnFixup, + ReturnType = returnTypeName, + VtblIndex = _config.GenerateVtblIndexAttribute ? cxxMethodDecl.VtblIndex : -1, + Location = cxxMethodDecl.Location, + WriteCustomAttrs = static context => { + (var cxxMethodDecl, var generator) = ((CXXMethodDecl, PInvokeGenerator))context; - _outputBuilder.BeginFunctionInnerPrototype(in desc); + generator.WithAttributes(cxxMethodDecl); + generator.WithUsings(cxxMethodDecl); + }, + CustomAttrGeneratorData = (cxxMethodDecl, this), + }; - Visit(cxxMethodDecl.Parameters); + var isUnsafe = true; + _outputBuilder.BeginFunctionOrDelegate(in desc, ref isUnsafe); - _outputBuilder.EndFunctionInnerPrototype(in desc); - _outputBuilder.EndFunctionOrDelegate(in desc); + _outputBuilder.BeginFunctionInnerPrototype(in desc); - Debug.Assert(_context.Last == currentContext); - _context.RemoveLast(); - } + Visit(cxxMethodDecl.Parameters); - void OutputMarkerInterfaces(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) - { - // Don't process the base types because that's exposed via inheritance instead - var cxxMethodDecls = cxxRecordDecl.Methods; + _outputBuilder.EndFunctionInnerPrototype(in desc); + _outputBuilder.EndFunctionOrDelegate(in desc); - if (cxxMethodDecls.Count != 0) + Debug.Assert(_context.Last == currentContext); + _context.RemoveLast(); + } + + void OutputMarkerInterfaces(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) + { + // Don't process the base types because that's exposed via inheritance instead + var cxxMethodDecls = cxxRecordDecl.Methods; + + if (cxxMethodDecls.Count != 0) + { + foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) { - foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) - { - OutputMarkerInterface(rootCxxRecordDecl, cxxMethodDecl); - } + OutputMarkerInterface(rootCxxRecordDecl, cxxMethodDecl); } } + } - void OutputVtblEntries(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) + void OutputVtblEntries(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) + { + foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) { - foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) - { - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - OutputVtblEntries(rootCxxRecordDecl, baseCxxRecordDecl); - } + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); + OutputVtblEntries(rootCxxRecordDecl, baseCxxRecordDecl); + } - var cxxMethodDecls = cxxRecordDecl.Methods; + var cxxMethodDecls = cxxRecordDecl.Methods; - if (cxxMethodDecls.Count != 0) + if (cxxMethodDecls.Count != 0) + { + foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) { - foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) - { - OutputVtblEntry(rootCxxRecordDecl, cxxMethodDecl); - } + OutputVtblEntry(rootCxxRecordDecl, cxxMethodDecl); } } + } - void OutputVtblEntry(CXXRecordDecl cxxRecordDecl, CXXMethodDecl cxxMethodDecl) + void OutputVtblEntry(CXXRecordDecl cxxRecordDecl, CXXMethodDecl cxxMethodDecl) + { + if (!cxxMethodDecl.IsVirtual) { - if (!cxxMethodDecl.IsVirtual) - { - return; - } + return; + } - if (IsExcluded(cxxMethodDecl, out var isExcludedByConflictingDefinition)) - { - return; - } + if (IsExcluded(cxxMethodDecl, out var isExcludedByConflictingDefinition)) + { + return; + } - var cxxMethodDeclTypeName = GetRemappedTypeName(cxxMethodDecl, cxxRecordDecl, cxxMethodDecl.Type, out var nativeTypeName, skipUsing: false, ignoreTransparentStructsWhereRequired: true); + var cxxMethodDeclTypeName = GetRemappedTypeName(cxxMethodDecl, cxxRecordDecl, cxxMethodDecl.Type, out var nativeTypeName, skipUsing: false, ignoreTransparentStructsWhereRequired: true); - if (_config.GenerateMarkerInterfaces && !_config.ExcludeFnptrCodegen) - { - var cxxRecordDeclName = GetRemappedCursorName(cxxRecordDecl); - cxxMethodDeclTypeName = cxxMethodDeclTypeName.Replace($"<{cxxRecordDeclName}*,", " { - (var cxxMethodDecl, var generator) = ((CXXMethodDecl, PInvokeGenerator))context; + var desc = new FieldDesc + { + AccessSpecifier = AccessSpecifier.Public, + NativeTypeName = nativeTypeName, + EscapedName = escapedName, + Offset = null, + NeedsNewKeyword = NeedsNewKeyword(remappedName), + Location = cxxMethodDecl.Location, + WriteCustomAttrs = static context => { + (var cxxMethodDecl, var generator) = ((CXXMethodDecl, PInvokeGenerator))context; - generator.WithAttributes(cxxMethodDecl); - generator.WithUsings(cxxMethodDecl); - }, - CustomAttrGeneratorData = (cxxMethodDecl, this), - }; + generator.WithAttributes(cxxMethodDecl); + generator.WithUsings(cxxMethodDecl); + }, + CustomAttrGeneratorData = (cxxMethodDecl, this), + }; + + _outputBuilder.BeginField(in desc); + _outputBuilder.WriteRegularField(cxxMethodDeclTypeName, escapedName); + _outputBuilder.EndField(in desc); - _outputBuilder.BeginField(in desc); - _outputBuilder.WriteRegularField(cxxMethodDeclTypeName, escapedName); - _outputBuilder.EndField(in desc); + _outputBuilder.WriteDivider(); + } - _outputBuilder.WriteDivider(); + void OutputVtblHelperMethod(CXXRecordDecl cxxRecordDecl, CXXMethodDecl cxxMethodDecl) + { + if (!cxxMethodDecl.IsVirtual) + { + return; } - void OutputVtblHelperMethod(CXXRecordDecl cxxRecordDecl, CXXMethodDecl cxxMethodDecl) + if (IsExcluded(cxxMethodDecl, out var isExcludedByConflictingDefinition)) { - if (!cxxMethodDecl.IsVirtual) - { - return; - } + return; + } - if (IsExcluded(cxxMethodDecl, out var isExcludedByConflictingDefinition)) - { - return; - } + var currentContext = _context.AddLast((cxxMethodDecl, null)); - var currentContext = _context.AddLast((cxxMethodDecl, null)); + var returnType = cxxMethodDecl.ReturnType; + var returnTypeName = GetRemappedTypeName(cxxMethodDecl, cxxRecordDecl, returnType, out var nativeTypeName); - var returnType = cxxMethodDecl.ReturnType; - var returnTypeName = GetRemappedTypeName(cxxMethodDecl, cxxRecordDecl, returnType, out var nativeTypeName); + var remappedName = FixupNameForMultipleHits(cxxMethodDecl); + var name = GetRemappedCursorName(cxxMethodDecl); + var needsReturnFixup = false; + var needsCastToTransparentStruct = false; + var cxxRecordDeclName = GetRemappedCursorName(cxxRecordDecl); + var parentName = cxxRecordDeclName; + var isInherited = false; - var remappedName = FixupNameForMultipleHits(cxxMethodDecl); - var name = GetRemappedCursorName(cxxMethodDecl); - var needsReturnFixup = false; - var needsCastToTransparentStruct = false; - var cxxRecordDeclName = GetRemappedCursorName(cxxRecordDecl); - var parentName = cxxRecordDeclName; - var isInherited = false; + if (cxxMethodDecl.Parent != cxxRecordDecl) + { + parentName = GetRemappedCursorName(cxxMethodDecl.Parent); + isInherited = true; + } - if (cxxMethodDecl.Parent != cxxRecordDecl) - { - parentName = GetRemappedCursorName(cxxMethodDecl.Parent); - isInherited = true; - } + if (returnType.Kind != CXTypeKind.CXType_Void) + { + needsReturnFixup = NeedsReturnFixup(cxxMethodDecl); + needsCastToTransparentStruct = _config.WithTransparentStructs.TryGetValue(returnTypeName, out var transparentStruct) && IsTransparentStructHandle(transparentStruct.Kind); + } - if (returnType.Kind != CXTypeKind.CXType_Void) - { - needsReturnFixup = NeedsReturnFixup(cxxMethodDecl); - needsCastToTransparentStruct = _config.WithTransparentStructs.TryGetValue(returnTypeName, out var transparentStruct) && IsTransparentStructHandle(transparentStruct.Kind); - } + var desc = new FunctionOrDelegateDesc { + AccessSpecifier = AccessSpecifier.Public, + IsAggressivelyInlined = _config.GenerateAggressiveInlining, + EscapedName = EscapeAndStripName(name), + ParentName = parentName, + IsMemberFunction = true, + IsInherited = isInherited, + NativeTypeName = nativeTypeName, + NeedsNewKeyword = NeedsNewKeyword(name, cxxMethodDecl.Parameters), + HasFnPtrCodeGen = !_config.ExcludeFnptrCodegen, + IsCtxCxxRecord = true, + IsCxxRecordCtxUnsafe = IsUnsafe(cxxRecordDecl), + IsUnsafe = true, + NeedsReturnFixup = needsReturnFixup, + ReturnType = returnTypeName, + VtblIndex = _config.GenerateVtblIndexAttribute ? cxxMethodDecl.VtblIndex : -1, + Location = cxxMethodDecl.Location, + HasBody = true, + WriteCustomAttrs = static context => { + (var cxxMethodDecl, var generator) = ((CXXMethodDecl, PInvokeGenerator))context; - var desc = new FunctionOrDelegateDesc { - AccessSpecifier = AccessSpecifier.Public, - IsAggressivelyInlined = _config.GenerateAggressiveInlining, - EscapedName = EscapeAndStripName(name), - ParentName = parentName, - IsMemberFunction = true, - IsInherited = isInherited, - NativeTypeName = nativeTypeName, - NeedsNewKeyword = NeedsNewKeyword(name, cxxMethodDecl.Parameters), - HasFnPtrCodeGen = !_config.ExcludeFnptrCodegen, - IsCtxCxxRecord = true, - IsCxxRecordCtxUnsafe = IsUnsafe(cxxRecordDecl), - IsUnsafe = true, - NeedsReturnFixup = needsReturnFixup, - ReturnType = returnTypeName, - VtblIndex = _config.GenerateVtblIndexAttribute ? cxxMethodDecl.VtblIndex : -1, - Location = cxxMethodDecl.Location, - HasBody = true, - WriteCustomAttrs = static context => { - (var cxxMethodDecl, var generator) = ((CXXMethodDecl, PInvokeGenerator))context; + generator.WithAttributes(cxxMethodDecl); + generator.WithUsings(cxxMethodDecl); + }, + CustomAttrGeneratorData = (cxxMethodDecl, this), + }; - generator.WithAttributes(cxxMethodDecl); - generator.WithUsings(cxxMethodDecl); - }, - CustomAttrGeneratorData = (cxxMethodDecl, this), - }; + var isUnsafe = true; + _outputBuilder.BeginFunctionOrDelegate(in desc, ref isUnsafe); - var isUnsafe = true; - _outputBuilder.BeginFunctionOrDelegate(in desc, ref isUnsafe); + _outputBuilder.BeginFunctionInnerPrototype(in desc); - _outputBuilder.BeginFunctionInnerPrototype(in desc); + Visit(cxxMethodDecl.Parameters); - Visit(cxxMethodDecl.Parameters); + _outputBuilder.EndFunctionInnerPrototype(in desc); + _outputBuilder.BeginBody(); - _outputBuilder.EndFunctionInnerPrototype(in desc); - _outputBuilder.BeginBody(); + var escapedCXXRecordDeclName = EscapeName(cxxRecordDeclName); - var escapedCXXRecordDeclName = EscapeName(cxxRecordDeclName); + _outputBuilder.BeginInnerFunctionBody(); + var body = _outputBuilder.BeginCSharpCode(); - _outputBuilder.BeginInnerFunctionBody(); - var body = _outputBuilder.BeginCSharpCode(); + if (_config.GenerateCompatibleCode) + { + body.Write("fixed ("); + body.Write(escapedCXXRecordDeclName); + body.WriteLine("* pThis = &this)"); + body.WriteBlockStart(); + body.WriteIndentation(); + } - if (_config.GenerateCompatibleCode) - { - body.Write("fixed ("); - body.Write(escapedCXXRecordDeclName); - body.WriteLine("* pThis = &this)"); - body.WriteBlockStart(); - body.WriteIndentation(); - } + if (needsReturnFixup) + { + body.BeginMarker("fixup", new KeyValuePair("type", "*result")); + body.Write(returnTypeName); + body.EndMarker("fixup"); + body.Write(" result"); + body.WriteSemicolon(); + body.WriteNewline(); + body.WriteIndentation(); + } - if (needsReturnFixup) - { - body.BeginMarker("fixup", new KeyValuePair("type", "*result")); - body.Write(returnTypeName); - body.EndMarker("fixup"); - body.Write(" result"); - body.WriteSemicolon(); - body.WriteNewline(); - body.WriteIndentation(); - } + if (returnType.Kind != CXTypeKind.CXType_Void) + { + body.Write("return "); + } - if (returnType.Kind != CXTypeKind.CXType_Void) - { - body.Write("return "); - } + if (needsCastToTransparentStruct) + { + body.Write("(("); + body.Write(returnTypeName); + body.Write(")("); + } - if (needsCastToTransparentStruct) - { - body.Write("(("); - body.Write(returnTypeName); - body.Write(")("); - } + if (needsReturnFixup) + { + body.Write('*'); + } - if (needsReturnFixup) - { - body.Write('*'); - } + if (_config.ExcludeFnptrCodegen) + { + body.Write("Marshal.GetDelegateForFunctionPointer<"); + body.BeginMarker("delegate"); + body.Write(PrefixAndStripName(name, GetOverloadIndex(cxxMethodDecl))); + body.EndMarker("delegate"); + body.Write(">("); + } - if (_config.ExcludeFnptrCodegen) - { - body.Write("Marshal.GetDelegateForFunctionPointer<"); - body.BeginMarker("delegate"); - body.Write(PrefixAndStripName(name, GetOverloadIndex(cxxMethodDecl))); - body.EndMarker("delegate"); - body.Write(">("); - } + if (_config.GenerateExplicitVtbls) + { + body.Write("lpVtbl->"); + body.BeginMarker("vtbl", new KeyValuePair("explicit", true)); + body.Write(EscapeAndStripName(remappedName)); + body.EndMarker("vtbl"); + } + else + { + var cxxMethodDeclTypeName = GetRemappedTypeName(cxxMethodDecl, cxxRecordDecl, cxxMethodDecl.Type, out _, skipUsing: false, ignoreTransparentStructsWhereRequired: true); - if (_config.GenerateExplicitVtbls) - { - body.Write("lpVtbl->"); - body.BeginMarker("vtbl", new KeyValuePair("explicit", true)); - body.Write(EscapeAndStripName(remappedName)); - body.EndMarker("vtbl"); - } - else + if (!_config.ExcludeFnptrCodegen) { - var cxxMethodDeclTypeName = GetRemappedTypeName(cxxMethodDecl, cxxRecordDecl, cxxMethodDecl.Type, out _, skipUsing: false, ignoreTransparentStructsWhereRequired: true); - - if (!_config.ExcludeFnptrCodegen) - { - body.Write('('); - } - body.Write('('); - body.Write(cxxMethodDeclTypeName); - body.Write(")(lpVtbl["); - body.BeginMarker("vtbl", new KeyValuePair("explicit", false)); - body.Write(cxxMethodDecl.VtblIndex); - body.EndMarker("vtbl"); - body.Write("])"); - - if (!_config.ExcludeFnptrCodegen) - { - body.Write(')'); - } } - if (_config.ExcludeFnptrCodegen) + body.Write('('); + body.Write(cxxMethodDeclTypeName); + body.Write(")(lpVtbl["); + body.BeginMarker("vtbl", new KeyValuePair("explicit", false)); + body.Write(cxxMethodDecl.VtblIndex); + body.EndMarker("vtbl"); + body.Write("])"); + + if (!_config.ExcludeFnptrCodegen) { body.Write(')'); } + } + + if (_config.ExcludeFnptrCodegen) + { + body.Write(')'); + } + + body.Write('('); + body.BeginMarker("param", new KeyValuePair("special", "thisPtr")); + if (_config.GenerateCompatibleCode) + { + body.Write("pThis"); + } + else + { body.Write('('); + body.Write(escapedCXXRecordDeclName); + body.Write("*)Unsafe.AsPointer(ref this)"); + } + body.EndMarker("param"); - body.BeginMarker("param", new KeyValuePair("special", "thisPtr")); - if (_config.GenerateCompatibleCode) - { - body.Write("pThis"); - } - else - { - body.Write('('); - body.Write(escapedCXXRecordDeclName); - body.Write("*)Unsafe.AsPointer(ref this)"); - } + if (needsReturnFixup) + { + body.BeginMarker("param", new KeyValuePair("special", "retFixup")); + body.Write(", &result"); body.EndMarker("param"); + } + + var parmVarDecls = cxxMethodDecl.Parameters; - if (needsReturnFixup) + for (var index = 0; index < parmVarDecls.Count; index++) + { + body.Write(", "); + + var parmVarDeclName = GetRemappedCursorName(parmVarDecls[index]); + var escapedParmVarDeclName = EscapeName(parmVarDeclName); + if (parmVarDeclName.Equals("param")) { - body.BeginMarker("param", new KeyValuePair("special", "retFixup")); - body.Write(", &result"); - body.EndMarker("param"); + escapedParmVarDeclName += index; } - var parmVarDecls = cxxMethodDecl.Parameters; + body.BeginMarker("param", new KeyValuePair("name", escapedParmVarDeclName)); + body.Write(escapedParmVarDeclName); + body.EndMarker("param"); + } - for (var index = 0; index < parmVarDecls.Count; index++) - { - body.Write(", "); + body.Write(')'); - var parmVarDeclName = GetRemappedCursorName(parmVarDecls[index]); - var escapedParmVarDeclName = EscapeName(parmVarDeclName); - if (parmVarDeclName.Equals("param")) - { - escapedParmVarDeclName += index; - } + if (returnTypeName == "bool") + { + body.Write(" != 0"); + } - body.BeginMarker("param", new KeyValuePair("name", escapedParmVarDeclName)); - body.Write(escapedParmVarDeclName); - body.EndMarker("param"); - } + if (needsCastToTransparentStruct) + { + body.Write("))"); + } - body.Write(')'); + body.WriteSemicolon(); + body.WriteNewline(); - if (returnTypeName == "bool") - { - body.Write(" != 0"); - } + if (_config.GenerateCompatibleCode) + { + body.WriteBlockEnd(); + } - if (needsCastToTransparentStruct) - { - body.Write("))"); - } + _outputBuilder.EndCSharpCode(body); + _outputBuilder.EndInnerFunctionBody(); + _outputBuilder.EndBody(); + _outputBuilder.EndFunctionOrDelegate(in desc); - body.WriteSemicolon(); - body.WriteNewline(); + Debug.Assert(_context.Last == currentContext); + _context.RemoveLast(); + } + + void OutputVtblHelperMethods(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) + { + foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) + { + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); + OutputVtblHelperMethods(rootCxxRecordDecl, baseCxxRecordDecl); + } - if (_config.GenerateCompatibleCode) + var cxxMethodDecls = cxxRecordDecl.Methods; + + if (cxxMethodDecls.Count != 0) + { + foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) { - body.WriteBlockEnd(); + _outputBuilder.WriteDivider(); + OutputVtblHelperMethod(rootCxxRecordDecl, cxxMethodDecl); } + } + } - _outputBuilder.EndCSharpCode(body); - _outputBuilder.EndInnerFunctionBody(); - _outputBuilder.EndBody(); - _outputBuilder.EndFunctionOrDelegate(in desc); + void VisitBitfieldDecl(FieldDecl fieldDecl, Type[] types, RecordDecl recordDecl, string contextName, ref int index, ref long previousSize, ref long remainingBits) + { + Debug.Assert(fieldDecl.IsBitField); - Debug.Assert(_context.Last == currentContext); - _context.RemoveLast(); + var type = fieldDecl.Type; + var typeName = GetRemappedTypeName(fieldDecl, context: null, type, out var nativeTypeName); + + if (string.IsNullOrWhiteSpace(nativeTypeName)) + { + nativeTypeName = typeName; } - void OutputVtblHelperMethods(CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl) + nativeTypeName += $" : {fieldDecl.BitWidthValue}"; + + var currentSize = fieldDecl.Type.Handle.SizeOf; + + var bitfieldName = "_bitfield"; + + Type typeBacking; + string typeNameBacking; + + if ((!_config.GenerateUnixTypes && (currentSize != previousSize)) || (fieldDecl.BitWidthValue > remainingBits)) { - foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) + if (index >= 0) { - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - OutputVtblHelperMethods(rootCxxRecordDecl, baseCxxRecordDecl); + index++; + bitfieldName += index.ToString(); } - var cxxMethodDecls = cxxRecordDecl.Methods; + remainingBits = currentSize * 8; + previousSize = 0; + + typeBacking = (index > 0) ? types[index - 1] : types[0]; + typeNameBacking = GetRemappedTypeName(fieldDecl, context: null, typeBacking, out _); - if (cxxMethodDecls.Count != 0) + if (fieldDecl.Parent == recordDecl) { - foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) - { - _outputBuilder.WriteDivider(); - OutputVtblHelperMethod(rootCxxRecordDecl, cxxMethodDecl); - } + var fieldDesc = new FieldDesc { + AccessSpecifier = AccessSpecifier.Public, + NativeTypeName = null, + EscapedName = bitfieldName, + Offset = fieldDecl.Parent.IsUnion ? 0 : null, + NeedsNewKeyword = false, + Location = fieldDecl.Location, + }; + _outputBuilder.BeginField(in fieldDesc); + _outputBuilder.WriteRegularField(typeNameBacking, bitfieldName); + _outputBuilder.EndField(in fieldDesc); } } - - void VisitBitfieldDecl(FieldDecl fieldDecl, Type[] types, RecordDecl recordDecl, string contextName, ref int index, ref long previousSize, ref long remainingBits) + else { - Debug.Assert(fieldDecl.IsBitField); + currentSize = Math.Max(previousSize, currentSize); - var type = fieldDecl.Type; - var typeName = GetRemappedTypeName(fieldDecl, context: null, type, out var nativeTypeName); + if (_config.GenerateUnixTypes && (currentSize > previousSize)) + { + remainingBits += (currentSize - previousSize) * 8; + } - if (string.IsNullOrWhiteSpace(nativeTypeName)) + if (index >= 0) { - nativeTypeName = typeName; + bitfieldName += index.ToString(); } - nativeTypeName += $" : {fieldDecl.BitWidthValue}"; + typeBacking = (index > 0) ? types[index - 1] : types[0]; + typeNameBacking = GetRemappedTypeName(fieldDecl, context: null, typeBacking, out _); + } - var currentSize = fieldDecl.Type.Handle.SizeOf; + var bitfieldOffset = (currentSize * 8) - remainingBits; - var bitfieldName = "_bitfield"; + var bitwidthHexStringBacking = ((1 << fieldDecl.BitWidthValue) - 1).ToString("X"); + var canonicalTypeBacking = typeBacking.CanonicalType; - Type typeBacking; - string typeNameBacking; - - if ((!_config.GenerateUnixTypes && (currentSize != previousSize)) || (fieldDecl.BitWidthValue > remainingBits)) + switch (canonicalTypeBacking.Kind) + { + case CXTypeKind.CXType_Char_U: + case CXTypeKind.CXType_UChar: + case CXTypeKind.CXType_UShort: + case CXTypeKind.CXType_UInt: { - if (index >= 0) - { - index++; - bitfieldName += index.ToString(); - } - - remainingBits = currentSize * 8; - previousSize = 0; - - typeBacking = (index > 0) ? types[index - 1] : types[0]; - typeNameBacking = GetRemappedTypeName(fieldDecl, context: null, typeBacking, out _); - - if (fieldDecl.Parent == recordDecl) - { - var fieldDesc = new FieldDesc { - AccessSpecifier = AccessSpecifier.Public, - NativeTypeName = null, - EscapedName = bitfieldName, - Offset = fieldDecl.Parent.IsUnion ? 0 : null, - NeedsNewKeyword = false, - Location = fieldDecl.Location, - }; - _outputBuilder.BeginField(in fieldDesc); - _outputBuilder.WriteRegularField(typeNameBacking, bitfieldName); - _outputBuilder.EndField(in fieldDesc); - } + bitwidthHexStringBacking += "u"; + break; } - else - { - currentSize = Math.Max(previousSize, currentSize); - - if (_config.GenerateUnixTypes && (currentSize > previousSize)) - { - remainingBits += (currentSize - previousSize) * 8; - } - if (index >= 0) + case CXTypeKind.CXType_ULong: + { + if (_config.GenerateUnixTypes) { - bitfieldName += index.ToString(); + goto default; } - typeBacking = (index > 0) ? types[index - 1] : types[0]; - typeNameBacking = GetRemappedTypeName(fieldDecl, context: null, typeBacking, out _); + goto case CXTypeKind.CXType_UInt; } - var bitfieldOffset = (currentSize * 8) - remainingBits; - - var bitwidthHexStringBacking = ((1 << fieldDecl.BitWidthValue) - 1).ToString("X"); - var canonicalTypeBacking = typeBacking.CanonicalType; - - switch (canonicalTypeBacking.Kind) + case CXTypeKind.CXType_ULongLong: { - case CXTypeKind.CXType_Char_U: - case CXTypeKind.CXType_UChar: - case CXTypeKind.CXType_UShort: - case CXTypeKind.CXType_UInt: - { - bitwidthHexStringBacking += "u"; - break; - } - - case CXTypeKind.CXType_ULong: + if (typeNameBacking == "nuint") { - if (_config.GenerateUnixTypes) - { - goto default; - } - goto case CXTypeKind.CXType_UInt; } - case CXTypeKind.CXType_ULongLong: - { - if (typeNameBacking == "nuint") - { - goto case CXTypeKind.CXType_UInt; - } + bitwidthHexStringBacking += "UL"; + break; + } - bitwidthHexStringBacking += "UL"; - break; - } + case CXTypeKind.CXType_Char_S: + case CXTypeKind.CXType_SChar: + case CXTypeKind.CXType_Short: + case CXTypeKind.CXType_Int: + { + break; + } - case CXTypeKind.CXType_Char_S: - case CXTypeKind.CXType_SChar: - case CXTypeKind.CXType_Short: - case CXTypeKind.CXType_Int: + case CXTypeKind.CXType_Long: + { + if (_config.GenerateUnixTypes) { - break; + goto default; } - case CXTypeKind.CXType_Long: - { - if (_config.GenerateUnixTypes) - { - goto default; - } + goto case CXTypeKind.CXType_Int; + } + case CXTypeKind.CXType_LongLong: + { + if (typeNameBacking == "nint") + { goto case CXTypeKind.CXType_Int; } - case CXTypeKind.CXType_LongLong: - { - if (typeNameBacking == "nint") - { - goto case CXTypeKind.CXType_Int; - } - - bitwidthHexStringBacking += "L"; - break; - } + bitwidthHexStringBacking += "L"; + break; + } - default: - { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported bitfield type: '{canonicalTypeBacking.TypeClassSpelling}'. Generated bindings may be incomplete.", fieldDecl); - break; - } + default: + { + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported bitfield type: '{canonicalTypeBacking.TypeClassSpelling}'. Generated bindings may be incomplete.", fieldDecl); + break; } + } + + var bitwidthHexString = ((1 << fieldDecl.BitWidthValue) - 1).ToString("X"); - var bitwidthHexString = ((1 << fieldDecl.BitWidthValue) - 1).ToString("X"); + var canonicalType = type.CanonicalType; - var canonicalType = type.CanonicalType; + if (canonicalType is EnumType enumType) + { + canonicalType = enumType.Decl.IntegerType.CanonicalType; + } - if (canonicalType is EnumType enumType) + switch (canonicalType.Kind) + { + case CXTypeKind.CXType_Char_U: + case CXTypeKind.CXType_UChar: + case CXTypeKind.CXType_UShort: + case CXTypeKind.CXType_UInt: { - canonicalType = enumType.Decl.IntegerType.CanonicalType; + bitwidthHexString += "u"; + break; } - switch (canonicalType.Kind) + case CXTypeKind.CXType_ULong: { - case CXTypeKind.CXType_Char_U: - case CXTypeKind.CXType_UChar: - case CXTypeKind.CXType_UShort: - case CXTypeKind.CXType_UInt: + if (_config.GenerateUnixTypes) { - bitwidthHexString += "u"; - break; + goto default; } - case CXTypeKind.CXType_ULong: - { - if (_config.GenerateUnixTypes) - { - goto default; - } + goto case CXTypeKind.CXType_UInt; + } + case CXTypeKind.CXType_ULongLong: + { + if (typeNameBacking == "nuint") + { goto case CXTypeKind.CXType_UInt; } - case CXTypeKind.CXType_ULongLong: - { - if (typeNameBacking == "nuint") - { - goto case CXTypeKind.CXType_UInt; - } + bitwidthHexString += "UL"; + break; + } - bitwidthHexString += "UL"; - break; - } + case CXTypeKind.CXType_Char_S: + case CXTypeKind.CXType_SChar: + case CXTypeKind.CXType_Short: + case CXTypeKind.CXType_Int: + { + break; + } - case CXTypeKind.CXType_Char_S: - case CXTypeKind.CXType_SChar: - case CXTypeKind.CXType_Short: - case CXTypeKind.CXType_Int: + case CXTypeKind.CXType_Long: + { + if (_config.GenerateUnixTypes) { - break; + goto default; } - case CXTypeKind.CXType_Long: - { - if (_config.GenerateUnixTypes) - { - goto default; - } - - goto case CXTypeKind.CXType_Int; - } + goto case CXTypeKind.CXType_Int; + } - case CXTypeKind.CXType_LongLong: + case CXTypeKind.CXType_LongLong: + { + if (typeNameBacking == "nint") { - if (typeNameBacking == "nint") - { - goto case CXTypeKind.CXType_Int; - } - - bitwidthHexString += "L"; - break; + goto case CXTypeKind.CXType_Int; } - default: - { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported bitfield type: '{canonicalType.TypeClassSpelling}'. Generated bindings may be incomplete.", fieldDecl); - break; - } + bitwidthHexString += "L"; + break; } - canonicalType = type.CanonicalType; + default: + { + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported bitfield type: '{canonicalType.TypeClassSpelling}'. Generated bindings may be incomplete.", fieldDecl); + break; + } + } - var accessSpecifier = GetAccessSpecifier(fieldDecl, matchStar: false); - var name = GetRemappedCursorName(fieldDecl); - var escapedName = EscapeName(name); + canonicalType = type.CanonicalType; - var desc = new FieldDesc { - AccessSpecifier = accessSpecifier, - NativeTypeName = nativeTypeName, - EscapedName = escapedName, - ParentName = GetRemappedCursorName(fieldDecl.Parent), - Offset = null, - NeedsNewKeyword = false, - Location = fieldDecl.Location, - HasBody = true, - WriteCustomAttrs = static context => { - (var fieldDecl, var generator) = ((FieldDecl, PInvokeGenerator))context; + var accessSpecifier = GetAccessSpecifier(fieldDecl, matchStar: false); + var name = GetRemappedCursorName(fieldDecl); + var escapedName = EscapeName(name); - generator.WithAttributes(fieldDecl); - generator.WithUsings(fieldDecl); - }, - CustomAttrGeneratorData = (fieldDecl, this), - }; + var desc = new FieldDesc { + AccessSpecifier = accessSpecifier, + NativeTypeName = nativeTypeName, + EscapedName = escapedName, + ParentName = GetRemappedCursorName(fieldDecl.Parent), + Offset = null, + NeedsNewKeyword = false, + Location = fieldDecl.Location, + HasBody = true, + WriteCustomAttrs = static context => { + (var fieldDecl, var generator) = ((FieldDecl, PInvokeGenerator))context; - _outputBuilder.WriteDivider(); - _outputBuilder.BeginField(in desc); - _outputBuilder.WriteRegularField(typeName, escapedName); - _outputBuilder.BeginBody(); - _outputBuilder.BeginGetter(_config.GenerateAggressiveInlining); - var code = _outputBuilder.BeginCSharpCode(); + generator.WithAttributes(fieldDecl); + generator.WithUsings(fieldDecl); + }, + CustomAttrGeneratorData = (fieldDecl, this), + }; - code.WriteIndented("return "); + _outputBuilder.WriteDivider(); + _outputBuilder.BeginField(in desc); + _outputBuilder.WriteRegularField(typeName, escapedName); + _outputBuilder.BeginBody(); + _outputBuilder.BeginGetter(_config.GenerateAggressiveInlining); + var code = _outputBuilder.BeginCSharpCode(); - var recordDeclName = GetCursorName(recordDecl); + code.WriteIndented("return "); - var isRemappedToSelf = _config.RemappedNames.TryGetValue(typeName, out var remappedTypeName) && typeName.Equals(remappedTypeName); - var needsCast = (currentSize < 4) || (canonicalTypeBacking != canonicalType) || isRemappedToSelf; + var recordDeclName = GetCursorName(recordDecl); - if (needsCast) - { - code.Write('('); - code.BeginMarker("typeName"); - code.Write(typeName); - code.EndMarker("typeName"); - code.Write(")("); - } + var isRemappedToSelf = _config.RemappedNames.TryGetValue(typeName, out var remappedTypeName) && typeName.Equals(remappedTypeName); + var needsCast = (currentSize < 4) || (canonicalTypeBacking != canonicalType) || isRemappedToSelf; - if (bitfieldOffset != 0) - { - code.Write('('); - } + if (needsCast) + { + code.Write('('); + code.BeginMarker("typeName"); + code.Write(typeName); + code.EndMarker("typeName"); + code.Write(")("); + } - if (!string.IsNullOrWhiteSpace(contextName)) - { - code.BeginMarker("contextName"); - code.Write(contextName); - code.EndMarker("contextName"); - code.Write('.'); - } + if (bitfieldOffset != 0) + { + code.Write('('); + } - code.BeginMarker("bitfieldName"); - code.Write(bitfieldName); - code.EndMarker("bitfieldName"); + if (!string.IsNullOrWhiteSpace(contextName)) + { + code.BeginMarker("contextName"); + code.Write(contextName); + code.EndMarker("contextName"); + code.Write('.'); + } - if (bitfieldOffset != 0) - { - code.Write(" >> "); - code.BeginMarker("bitfieldOffset"); - code.Write(bitfieldOffset); - code.EndMarker("bitfieldOffset"); - code.Write(')'); - } + code.BeginMarker("bitfieldName"); + code.Write(bitfieldName); + code.EndMarker("bitfieldName"); - code.Write(" & 0x"); - code.BeginMarker("bitwidthHexStringBacking"); - code.Write(bitwidthHexStringBacking); - code.EndMarker("bitwidthHexStringBacking"); + if (bitfieldOffset != 0) + { + code.Write(" >> "); + code.BeginMarker("bitfieldOffset"); + code.Write(bitfieldOffset); + code.EndMarker("bitfieldOffset"); + code.Write(')'); + } - if (needsCast) - { - code.Write(')'); - } + code.Write(" & 0x"); + code.BeginMarker("bitwidthHexStringBacking"); + code.Write(bitwidthHexStringBacking); + code.EndMarker("bitwidthHexStringBacking"); - code.WriteSemicolon(); - code.WriteNewline(); - _outputBuilder.EndCSharpCode(code); - _outputBuilder.EndGetter(); + if (needsCast) + { + code.Write(')'); + } - _outputBuilder.BeginSetter(_config.GenerateAggressiveInlining); - code = _outputBuilder.BeginCSharpCode(); - code.WriteIndentation(); + code.WriteSemicolon(); + code.WriteNewline(); + _outputBuilder.EndCSharpCode(code); + _outputBuilder.EndGetter(); - if (!string.IsNullOrWhiteSpace(contextName)) - { - code.BeginMarker("contextName"); - code.Write(contextName); - code.EndMarker("contextName"); - code.Write('.'); - } + _outputBuilder.BeginSetter(_config.GenerateAggressiveInlining); + code = _outputBuilder.BeginCSharpCode(); + code.WriteIndentation(); - code.BeginMarker("bitfieldName"); - code.Write(bitfieldName); - code.EndMarker("bitfieldName"); + if (!string.IsNullOrWhiteSpace(contextName)) + { + code.BeginMarker("contextName"); + code.Write(contextName); + code.EndMarker("contextName"); + code.Write('.'); + } - code.Write(" = "); + code.BeginMarker("bitfieldName"); + code.Write(bitfieldName); + code.EndMarker("bitfieldName"); - if (currentSize < 4) - { - code.Write('('); - code.BeginMarker("typeNameBacking"); - code.Write(typeNameBacking); - code.EndMarker("typeNameBacking"); - code.Write(")("); - } + code.Write(" = "); + if (currentSize < 4) + { code.Write('('); + code.BeginMarker("typeNameBacking"); + code.Write(typeNameBacking); + code.EndMarker("typeNameBacking"); + code.Write(")("); + } - if (!string.IsNullOrWhiteSpace(contextName)) - { - code.Write(contextName); - code.Write('.'); - } + code.Write('('); - code.Write(bitfieldName); + if (!string.IsNullOrWhiteSpace(contextName)) + { + code.Write(contextName); + code.Write('.'); + } - code.Write(" & ~"); + code.Write(bitfieldName); - if (bitfieldOffset != 0) - { - code.Write('('); - } + code.Write(" & ~"); - code.Write("0x"); - code.BeginMarker("bitwidthHexStringBacking"); - code.Write(bitwidthHexStringBacking); - code.EndMarker("bitwidthHexStringBacking"); + if (bitfieldOffset != 0) + { + code.Write('('); + } - if (bitfieldOffset != 0) - { - code.Write(" << "); - code.BeginMarker("bitfieldOffset"); - code.Write(bitfieldOffset); - code.EndMarker("bitfieldOffset"); - code.Write(')'); - } + code.Write("0x"); + code.BeginMarker("bitwidthHexStringBacking"); + code.Write(bitwidthHexStringBacking); + code.EndMarker("bitwidthHexStringBacking"); - code.Write(") | "); + if (bitfieldOffset != 0) + { + code.Write(" << "); + code.BeginMarker("bitfieldOffset"); + code.Write(bitfieldOffset); + code.EndMarker("bitfieldOffset"); + code.Write(')'); + } - if ((canonicalTypeBacking != canonicalType) && (canonicalType is not EnumType)) - { - code.Write('('); - code.Write(typeNameBacking); - code.Write(')'); - } + code.Write(") | "); + if ((canonicalTypeBacking != canonicalType) && (canonicalType is not EnumType)) + { code.Write('('); + code.Write(typeNameBacking); + code.Write(')'); + } - if (bitfieldOffset != 0) - { - code.Write('('); - } - - if ((canonicalType is EnumType) || isRemappedToSelf) - { - code.Write('('); - code.Write(typeNameBacking); - code.Write(")(value)"); - } - else - { - code.Write("value"); - } + code.Write('('); - code.Write(" & 0x"); - code.BeginMarker("bitwidthHexString"); - code.Write(bitwidthHexString); - code.EndMarker("bitwidthHexString"); + if (bitfieldOffset != 0) + { + code.Write('('); + } - if (bitfieldOffset != 0) - { - code.Write(") << "); - code.Write(bitfieldOffset); - } + if ((canonicalType is EnumType) || isRemappedToSelf) + { + code.Write('('); + code.Write(typeNameBacking); + code.Write(")(value)"); + } + else + { + code.Write("value"); + } - code.Write(')'); + code.Write(" & 0x"); + code.BeginMarker("bitwidthHexString"); + code.Write(bitwidthHexString); + code.EndMarker("bitwidthHexString"); - if (currentSize < 4) - { - code.Write(')'); - } + if (bitfieldOffset != 0) + { + code.Write(") << "); + code.Write(bitfieldOffset); + } - code.WriteSemicolon(); - code.WriteNewline(); - _outputBuilder.EndCSharpCode(code); - _outputBuilder.EndSetter(); - _outputBuilder.EndBody(); - _outputBuilder.EndField(in desc); - _outputBuilder.WriteDivider(); + code.Write(')'); - remainingBits -= fieldDecl.BitWidthValue; - previousSize = Math.Max(previousSize, currentSize); + if (currentSize < 4) + { + code.Write(')'); } - void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl constantOrIncompleteArray) - { - Debug.Assert(constantOrIncompleteArray.Type.CanonicalType is ConstantArrayType or IncompleteArrayType); + code.WriteSemicolon(); + code.WriteNewline(); + _outputBuilder.EndCSharpCode(code); + _outputBuilder.EndSetter(); + _outputBuilder.EndBody(); + _outputBuilder.EndField(in desc); + _outputBuilder.WriteDivider(); - var outputBuilder = _outputBuilder; - var arrayType = (ArrayType)constantOrIncompleteArray.Type.CanonicalType; - var arrayTypeName = GetRemappedTypeName(constantOrIncompleteArray, context: null, constantOrIncompleteArray.Type, out _); + remainingBits -= fieldDecl.BitWidthValue; + previousSize = Math.Max(previousSize, currentSize); + } - if (IsSupportedFixedSizedBufferType(arrayTypeName)) - { - return; - } + void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl constantOrIncompleteArray) + { + Debug.Assert(constantOrIncompleteArray.Type.CanonicalType is ConstantArrayType or IncompleteArrayType); - _outputBuilder.WriteDivider(); + var outputBuilder = _outputBuilder; + var arrayType = (ArrayType)constantOrIncompleteArray.Type.CanonicalType; + var arrayTypeName = GetRemappedTypeName(constantOrIncompleteArray, context: null, constantOrIncompleteArray.Type, out _); - var alignment = Math.Max(recordDecl.TypeForDecl.Handle.AlignOf, 1); - var maxAlignm = recordDecl.Fields.Any() ? recordDecl.Fields.Max((fieldDecl) => Math.Max(fieldDecl.Type.Handle.AlignOf, 1)) : alignment; + if (IsSupportedFixedSizedBufferType(arrayTypeName)) + { + return; + } - var accessSpecifier = GetAccessSpecifier(constantOrIncompleteArray, matchStar: false); - var canonicalElementType = arrayType.ElementType.CanonicalType; - var isUnsafeElementType = - ((canonicalElementType is PointerType) || (canonicalElementType is ReferenceType)) && - (arrayTypeName != "IntPtr") && (arrayTypeName != "UIntPtr"); + _outputBuilder.WriteDivider(); - var name = GetArtificialFixedSizedBufferName(constantOrIncompleteArray); - var escapedName = EscapeName(name); + var alignment = Math.Max(recordDecl.TypeForDecl.Handle.AlignOf, 1); + var maxAlignm = recordDecl.Fields.Any() ? recordDecl.Fields.Max((fieldDecl) => Math.Max(fieldDecl.Type.Handle.AlignOf, 1)) : alignment; - var arraySize = Math.Max((arrayType as ConstantArrayType)?.Size ?? 0, 1); - var totalSize = arraySize; - var sizePerDimension = new List<(long index, long size)>() {(0, arraySize) }; + var accessSpecifier = GetAccessSpecifier(constantOrIncompleteArray, matchStar: false); + var canonicalElementType = arrayType.ElementType.CanonicalType; + var isUnsafeElementType = + ((canonicalElementType is PointerType) || (canonicalElementType is ReferenceType)) && + (arrayTypeName != "IntPtr") && (arrayTypeName != "UIntPtr"); - var elementType = arrayType.ElementType; + var name = GetArtificialFixedSizedBufferName(constantOrIncompleteArray); + var escapedName = EscapeName(name); - while (elementType.CanonicalType is ConstantArrayType or IncompleteArrayType) - { - var subArrayType = (ArrayType)elementType.CanonicalType; + var arraySize = Math.Max((arrayType as ConstantArrayType)?.Size ?? 0, 1); + var totalSize = arraySize; + var sizePerDimension = new List<(long index, long size)>() {(0, arraySize) }; - var subArraySize = Math.Max((subArrayType as ConstantArrayType)?.Size ?? 0, 1); - totalSize *= subArraySize; - sizePerDimension.Add((0, subArraySize)); + var elementType = arrayType.ElementType; - elementType = subArrayType.ElementType; - } + while (elementType.CanonicalType is ConstantArrayType or IncompleteArrayType) + { + var subArrayType = (ArrayType)elementType.CanonicalType; - long alignment32 = -1; - long alignment64 = -1; + var subArraySize = Math.Max((subArrayType as ConstantArrayType)?.Size ?? 0, 1); + totalSize *= subArraySize; + sizePerDimension.Add((0, subArraySize)); - GetTypeSize(constantOrIncompleteArray, constantOrIncompleteArray.Type, ref alignment32, ref alignment64, out var size32, out var size64); + elementType = subArrayType.ElementType; + } - if ((size32 == 0 || size64 == 0) && _testOutputBuilder != null) - { - AddDiagnostic(DiagnosticLevel.Info, $"{escapedName} (constant array field) has a size of 0", constantOrIncompleteArray); - } + long alignment32 = -1; + long alignment64 = -1; - var desc = new StructDesc { - AccessSpecifier = accessSpecifier, - EscapedName = escapedName, - IsUnsafe = isUnsafeElementType, - Layout = new() { - Alignment32 = alignment32, - Alignment64 = alignment64, - Size32 = size32, - Size64 = size64, - Pack = alignment < maxAlignm ? alignment : 0, - MaxFieldAlignment = maxAlignm, - Kind = LayoutKind.Sequential - }, - Location = constantOrIncompleteArray.Location, - IsNested = true, - WriteCustomAttrs = static context => { - (var fieldDecl, var generator) = ((FieldDecl, PInvokeGenerator))context; + GetTypeSize(constantOrIncompleteArray, constantOrIncompleteArray.Type, ref alignment32, ref alignment64, out var size32, out var size64); - generator.WithAttributes(fieldDecl); - generator.WithUsings(fieldDecl); - }, - CustomAttrGeneratorData = (constantOrIncompleteArray, this), - }; + if ((size32 == 0 || size64 == 0) && _testOutputBuilder != null) + { + AddDiagnostic(DiagnosticLevel.Info, $"{escapedName} (constant array field) has a size of 0", constantOrIncompleteArray); + } - _outputBuilder.BeginStruct(in desc); + var desc = new StructDesc { + AccessSpecifier = accessSpecifier, + EscapedName = escapedName, + IsUnsafe = isUnsafeElementType, + Layout = new() { + Alignment32 = alignment32, + Alignment64 = alignment64, + Size32 = size32, + Size64 = size64, + Pack = alignment < maxAlignm ? alignment : 0, + MaxFieldAlignment = maxAlignm, + Kind = LayoutKind.Sequential + }, + Location = constantOrIncompleteArray.Location, + IsNested = true, + WriteCustomAttrs = static context => { + (var fieldDecl, var generator) = ((FieldDecl, PInvokeGenerator))context; - var firstFieldName = ""; + generator.WithAttributes(fieldDecl); + generator.WithUsings(fieldDecl); + }, + CustomAttrGeneratorData = (constantOrIncompleteArray, this), + }; - for (long i = 0; i < totalSize; i++) - { - var dimension = sizePerDimension[0]; - var firstDimension = dimension.index++; - var fieldName = "e" + firstDimension; - sizePerDimension[0] = dimension; + _outputBuilder.BeginStruct(in desc); - var separateStride = false; - for (var d = 1; d < sizePerDimension.Count; d++) - { - dimension = sizePerDimension[d]; - fieldName += "_" + dimension.index; - sizePerDimension[d] = dimension; + var firstFieldName = ""; - var previousDimension = sizePerDimension[d - 1]; + for (long i = 0; i < totalSize; i++) + { + var dimension = sizePerDimension[0]; + var firstDimension = dimension.index++; + var fieldName = "e" + firstDimension; + sizePerDimension[0] = dimension; - if (previousDimension.index == previousDimension.size) - { - previousDimension.index = 0; - dimension.index++; - sizePerDimension[d - 1] = previousDimension; - separateStride = true; - } + var separateStride = false; + for (var d = 1; d < sizePerDimension.Count; d++) + { + dimension = sizePerDimension[d]; + fieldName += "_" + dimension.index; + sizePerDimension[d] = dimension; - sizePerDimension[d] = dimension; - } + var previousDimension = sizePerDimension[d - 1]; - if (firstFieldName == "") + if (previousDimension.index == previousDimension.size) { - firstFieldName = fieldName; + previousDimension.index = 0; + dimension.index++; + sizePerDimension[d - 1] = previousDimension; + separateStride = true; } - var fieldDesc = new FieldDesc { - AccessSpecifier = accessSpecifier, - NativeTypeName = null, - EscapedName = fieldName, - Offset = null, - NeedsNewKeyword = false, - Location = constantOrIncompleteArray.Location, - }; + sizePerDimension[d] = dimension; + } - _outputBuilder.BeginField(in fieldDesc); - _outputBuilder.WriteRegularField(arrayTypeName, fieldName); - _outputBuilder.EndField(in fieldDesc); - if (!separateStride) - { - _outputBuilder.SuppressDivider(); - } + if (firstFieldName == "") + { + firstFieldName = fieldName; } - var generateCompatibleCode = _config.GenerateCompatibleCode; + var fieldDesc = new FieldDesc { + AccessSpecifier = accessSpecifier, + NativeTypeName = null, + EscapedName = fieldName, + Offset = null, + NeedsNewKeyword = false, + Location = constantOrIncompleteArray.Location, + }; - if (generateCompatibleCode || isUnsafeElementType) + _outputBuilder.BeginField(in fieldDesc); + _outputBuilder.WriteRegularField(arrayTypeName, fieldName); + _outputBuilder.EndField(in fieldDesc); + if (!separateStride) { - _outputBuilder.BeginIndexer(AccessSpecifier.Public, isUnsafe: generateCompatibleCode && !isUnsafeElementType, needsUnscopedRef: false); - _outputBuilder.WriteIndexer($"ref {arrayTypeName}"); - _outputBuilder.BeginIndexerParameters(); - var param = new ParameterDesc { - Name = "index", - Type = "int", - }; - _outputBuilder.BeginParameter(in param); - _outputBuilder.EndParameter(in param); - _outputBuilder.EndIndexerParameters(); - _outputBuilder.BeginBody(); - - _outputBuilder.BeginGetter(_config.GenerateAggressiveInlining); - var code = _outputBuilder.BeginCSharpCode(); - - code.WriteIndented("fixed ("); - code.Write(arrayTypeName); - code.Write("* pThis = &"); - code.Write(firstFieldName); - code.WriteLine(')'); - code.WriteBlockStart(); - code.WriteIndented("return ref pThis[index]"); - code.WriteSemicolon(); - code.WriteNewline(); - code.WriteBlockEnd(); - _outputBuilder.EndCSharpCode(code); - - _outputBuilder.EndGetter(); - _outputBuilder.EndBody(); - _outputBuilder.EndIndexer(); + _outputBuilder.SuppressDivider(); } - else - { - _outputBuilder.BeginIndexer(AccessSpecifier.Public, isUnsafe: false, needsUnscopedRef: _config.GeneratePreviewCode); - _outputBuilder.WriteIndexer($"ref {arrayTypeName}"); - _outputBuilder.BeginIndexerParameters(); - var param = new ParameterDesc { - Name = "index", - Type = "int", - }; - _outputBuilder.BeginParameter(in param); - _outputBuilder.EndParameter(in param); - _outputBuilder.EndIndexerParameters(); - _outputBuilder.BeginBody(); + } - _outputBuilder.BeginGetter(_config.GenerateAggressiveInlining); - var code = _outputBuilder.BeginCSharpCode(); - code.AddUsingDirective("System"); - code.AddUsingDirective("System.Runtime.InteropServices"); + var generateCompatibleCode = _config.GenerateCompatibleCode; - code.WriteIndented("return ref AsSpan("); + if (generateCompatibleCode || isUnsafeElementType) + { + _outputBuilder.BeginIndexer(AccessSpecifier.Public, isUnsafe: generateCompatibleCode && !isUnsafeElementType, needsUnscopedRef: false); + _outputBuilder.WriteIndexer($"ref {arrayTypeName}"); + _outputBuilder.BeginIndexerParameters(); + var param = new ParameterDesc { + Name = "index", + Type = "int", + }; + _outputBuilder.BeginParameter(in param); + _outputBuilder.EndParameter(in param); + _outputBuilder.EndIndexerParameters(); + _outputBuilder.BeginBody(); - if (arraySize == 1) - { - code.Write("int.MaxValue"); - } + _outputBuilder.BeginGetter(_config.GenerateAggressiveInlining); + var code = _outputBuilder.BeginCSharpCode(); - code.Write(")[index]"); - code.WriteSemicolon(); - code.WriteNewline(); - _outputBuilder.EndCSharpCode(code); + code.WriteIndented("fixed ("); + code.Write(arrayTypeName); + code.Write("* pThis = &"); + code.Write(firstFieldName); + code.WriteLine(')'); + code.WriteBlockStart(); + code.WriteIndented("return ref pThis[index]"); + code.WriteSemicolon(); + code.WriteNewline(); + code.WriteBlockEnd(); + _outputBuilder.EndCSharpCode(code); - _outputBuilder.EndGetter(); - _outputBuilder.EndBody(); - _outputBuilder.EndIndexer(); + _outputBuilder.EndGetter(); + _outputBuilder.EndBody(); + _outputBuilder.EndIndexer(); + } + else + { + _outputBuilder.BeginIndexer(AccessSpecifier.Public, isUnsafe: false, needsUnscopedRef: _config.GeneratePreviewCode); + _outputBuilder.WriteIndexer($"ref {arrayTypeName}"); + _outputBuilder.BeginIndexerParameters(); + var param = new ParameterDesc { + Name = "index", + Type = "int", + }; + _outputBuilder.BeginParameter(in param); + _outputBuilder.EndParameter(in param); + _outputBuilder.EndIndexerParameters(); + _outputBuilder.BeginBody(); - var function = new FunctionOrDelegateDesc { - AccessSpecifier = AccessSpecifier.Public, - EscapedName = "AsSpan", - IsAggressivelyInlined = _config.GenerateAggressiveInlining, - IsStatic = false, - IsMemberFunction = true, - ReturnType = $"Span<{arrayTypeName}>", - Location = constantOrIncompleteArray.Location, - HasBody = true, - NeedsUnscopedRef = _config.GeneratePreviewCode, - }; + _outputBuilder.BeginGetter(_config.GenerateAggressiveInlining); + var code = _outputBuilder.BeginCSharpCode(); + code.AddUsingDirective("System"); + code.AddUsingDirective("System.Runtime.InteropServices"); - var isUnsafe = false; - _outputBuilder.BeginFunctionOrDelegate(in function, ref isUnsafe); + code.WriteIndented("return ref AsSpan("); - _outputBuilder.BeginFunctionInnerPrototype(in function); + if (arraySize == 1) + { + code.Write("int.MaxValue"); + } - if (arraySize == 1) - { - param = new ParameterDesc { - Name = "length", - Type = "int", - }; + code.Write(")[index]"); + code.WriteSemicolon(); + code.WriteNewline(); + _outputBuilder.EndCSharpCode(code); - _outputBuilder.BeginParameter(in param); - _outputBuilder.EndParameter(in param); - } + _outputBuilder.EndGetter(); + _outputBuilder.EndBody(); + _outputBuilder.EndIndexer(); - _outputBuilder.EndFunctionInnerPrototype(in function); - _outputBuilder.BeginBody(true); - code = _outputBuilder.BeginCSharpCode(); + var function = new FunctionOrDelegateDesc { + AccessSpecifier = AccessSpecifier.Public, + EscapedName = "AsSpan", + IsAggressivelyInlined = _config.GenerateAggressiveInlining, + IsStatic = false, + IsMemberFunction = true, + ReturnType = $"Span<{arrayTypeName}>", + Location = constantOrIncompleteArray.Location, + HasBody = true, + NeedsUnscopedRef = _config.GeneratePreviewCode, + }; - code.Write("MemoryMarshal.CreateSpan(ref "); - code.Write(firstFieldName); - code.Write(", "); + var isUnsafe = false; + _outputBuilder.BeginFunctionOrDelegate(in function, ref isUnsafe); - if (arraySize == 1) - { - code.Write("length"); - } - else - { - code.Write(totalSize); - } + _outputBuilder.BeginFunctionInnerPrototype(in function); + + if (arraySize == 1) + { + param = new ParameterDesc { + Name = "length", + Type = "int", + }; - code.Write(')'); - code.WriteSemicolon(); - _outputBuilder.EndBody(true); - _outputBuilder.EndCSharpCode(code); - _outputBuilder.EndFunctionOrDelegate(in function); + _outputBuilder.BeginParameter(in param); + _outputBuilder.EndParameter(in param); } - _outputBuilder.EndStruct(in desc); + _outputBuilder.EndFunctionInnerPrototype(in function); + _outputBuilder.BeginBody(true); + code = _outputBuilder.BeginCSharpCode(); + + code.Write("MemoryMarshal.CreateSpan(ref "); + code.Write(firstFieldName); + code.Write(", "); + + if (arraySize == 1) + { + code.Write("length"); + } + else + { + code.Write(totalSize); + } + + code.Write(')'); + code.WriteSemicolon(); + _outputBuilder.EndBody(true); + _outputBuilder.EndCSharpCode(code); + _outputBuilder.EndFunctionOrDelegate(in function); } + + _outputBuilder.EndStruct(in desc); } + } + + private void VisitTranslationUnitDecl(TranslationUnitDecl translationUnitDecl) + { + Visit(translationUnitDecl.Decls); + Visit(translationUnitDecl.CursorChildren, translationUnitDecl.Decls); + } - private void VisitTranslationUnitDecl(TranslationUnitDecl translationUnitDecl) - { - Visit(translationUnitDecl.Decls); - Visit(translationUnitDecl.CursorChildren, translationUnitDecl.Decls); - } + private void VisitTypeAliasDecl(TypeAliasDecl typeAliasDecl) + { + // Nothing to generate for type alias declarations + } - private void VisitTypeAliasDecl(TypeAliasDecl typeAliasDecl) - { - // Nothing to generate for type alias declarations - } + private void VisitTypedefDecl(TypedefDecl typedefDecl, bool onlyHandleRemappings) + { + ForUnderlyingType(typedefDecl, typedefDecl.UnderlyingType, onlyHandleRemappings); - private void VisitTypedefDecl(TypedefDecl typedefDecl, bool onlyHandleRemappings) + void ForFunctionProtoType(TypedefDecl typedefDecl, FunctionProtoType functionProtoType, Type parentType, bool onlyHandleRemappings) { - ForUnderlyingType(typedefDecl, typedefDecl.UnderlyingType, onlyHandleRemappings); - - void ForFunctionProtoType(TypedefDecl typedefDecl, FunctionProtoType functionProtoType, Type parentType, bool onlyHandleRemappings) + if (!_config.ExcludeFnptrCodegen || onlyHandleRemappings) { - if (!_config.ExcludeFnptrCodegen || onlyHandleRemappings) - { - return; - } + return; + } - var name = GetRemappedCursorName(typedefDecl); - var escapedName = EscapeName(name); + var name = GetRemappedCursorName(typedefDecl); + var escapedName = EscapeName(name); - var callingConventionName = GetCallingConvention(typedefDecl, context: null, typedefDecl.TypeForDecl); + var callingConventionName = GetCallingConvention(typedefDecl, context: null, typedefDecl.TypeForDecl); - var returnType = functionProtoType.ReturnType; - var returnTypeName = GetRemappedTypeName(typedefDecl, context: null, returnType, out var nativeTypeName); + var returnType = functionProtoType.ReturnType; + var returnTypeName = GetRemappedTypeName(typedefDecl, context: null, returnType, out var nativeTypeName); - StartUsingOutputBuilder(name); - { - var desc = new FunctionOrDelegateDesc { - AccessSpecifier = GetAccessSpecifier(typedefDecl, matchStar: true), - CallingConvention = callingConventionName, - EscapedName = escapedName, - IsVirtual = true, // such that it outputs as a delegate - IsUnsafe = IsUnsafe(typedefDecl, functionProtoType), - NativeTypeName = nativeTypeName, - ReturnType = returnTypeName, - Location = typedefDecl.Location, - HasBody = true, - WriteCustomAttrs = static context => { - (var typedefDecl, var generator) = ((TypedefDecl, PInvokeGenerator))context; + StartUsingOutputBuilder(name); + { + var desc = new FunctionOrDelegateDesc { + AccessSpecifier = GetAccessSpecifier(typedefDecl, matchStar: true), + CallingConvention = callingConventionName, + EscapedName = escapedName, + IsVirtual = true, // such that it outputs as a delegate + IsUnsafe = IsUnsafe(typedefDecl, functionProtoType), + NativeTypeName = nativeTypeName, + ReturnType = returnTypeName, + Location = typedefDecl.Location, + HasBody = true, + WriteCustomAttrs = static context => { + (var typedefDecl, var generator) = ((TypedefDecl, PInvokeGenerator))context; - generator.WithAttributes(typedefDecl); - generator.WithUsings(typedefDecl); - }, - CustomAttrGeneratorData = (typedefDecl, this), - }; + generator.WithAttributes(typedefDecl); + generator.WithUsings(typedefDecl); + }, + CustomAttrGeneratorData = (typedefDecl, this), + }; - var isUnsafe = desc.IsUnsafe; - _outputBuilder.BeginFunctionOrDelegate(in desc, ref isUnsafe); + var isUnsafe = desc.IsUnsafe; + _outputBuilder.BeginFunctionOrDelegate(in desc, ref isUnsafe); - _outputBuilder.BeginFunctionInnerPrototype(in desc); + _outputBuilder.BeginFunctionInnerPrototype(in desc); - Visit(typedefDecl.CursorChildren.OfType()); + Visit(typedefDecl.CursorChildren.OfType()); - _outputBuilder.EndFunctionInnerPrototype(in desc); - _outputBuilder.EndFunctionOrDelegate(in desc); - } - StopUsingOutputBuilder(); + _outputBuilder.EndFunctionInnerPrototype(in desc); + _outputBuilder.EndFunctionOrDelegate(in desc); } + StopUsingOutputBuilder(); + } - void ForPointeeType(TypedefDecl typedefDecl, Type parentType, Type pointeeType, bool onlyHandleRemappings) + void ForPointeeType(TypedefDecl typedefDecl, Type parentType, Type pointeeType, bool onlyHandleRemappings) + { + if (pointeeType is AttributedType attributedType) { - if (pointeeType is AttributedType attributedType) - { - ForPointeeType(typedefDecl, attributedType, attributedType.ModifiedType, onlyHandleRemappings); - } - else if (pointeeType is ElaboratedType elaboratedType) - { - ForPointeeType(typedefDecl, elaboratedType, elaboratedType.NamedType, onlyHandleRemappings); - } - else if (pointeeType is FunctionProtoType functionProtoType) - { - ForFunctionProtoType(typedefDecl, functionProtoType, parentType, onlyHandleRemappings); - } - else if (pointeeType is PointerType pointerType) - { - ForPointeeType(typedefDecl, pointerType, pointerType.PointeeType, onlyHandleRemappings); - } - else if (pointeeType is TypedefType typedefType) - { - ForPointeeType(typedefDecl, typedefType, typedefType.Decl.UnderlyingType, onlyHandleRemappings); - } - else if (pointeeType is not ConstantArrayType and not IncompleteArrayType and not BuiltinType and not TagType and not TemplateTypeParmType) - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported pointee type: '{pointeeType.TypeClassSpelling}'. Generating bindings may be incomplete.", typedefDecl); - } + ForPointeeType(typedefDecl, attributedType, attributedType.ModifiedType, onlyHandleRemappings); + } + else if (pointeeType is ElaboratedType elaboratedType) + { + ForPointeeType(typedefDecl, elaboratedType, elaboratedType.NamedType, onlyHandleRemappings); + } + else if (pointeeType is FunctionProtoType functionProtoType) + { + ForFunctionProtoType(typedefDecl, functionProtoType, parentType, onlyHandleRemappings); + } + else if (pointeeType is PointerType pointerType) + { + ForPointeeType(typedefDecl, pointerType, pointerType.PointeeType, onlyHandleRemappings); + } + else if (pointeeType is TypedefType typedefType) + { + ForPointeeType(typedefDecl, typedefType, typedefType.Decl.UnderlyingType, onlyHandleRemappings); + } + else if (pointeeType is not ConstantArrayType and not IncompleteArrayType and not BuiltinType and not TagType and not TemplateTypeParmType) + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported pointee type: '{pointeeType.TypeClassSpelling}'. Generating bindings may be incomplete.", typedefDecl); } + } - void ForUnderlyingType(TypedefDecl typedefDecl, Type underlyingType, bool onlyHandleRemappings) + void ForUnderlyingType(TypedefDecl typedefDecl, Type underlyingType, bool onlyHandleRemappings) + { + if (underlyingType is ArrayType arrayType) { - if (underlyingType is ArrayType arrayType) - { - // Nothing to do for array types - } - else if (underlyingType is AttributedType attributedType) - { - ForUnderlyingType(typedefDecl, attributedType.ModifiedType, onlyHandleRemappings); - } - else if (underlyingType is BuiltinType builtinType) - { - // Nothing to do for builtin types - } - else if (underlyingType is DecltypeType decltypeType) - { - ForUnderlyingType(typedefDecl, decltypeType.UnderlyingType, onlyHandleRemappings); - } - else if (underlyingType is DependentNameType dependentNameType) - { - // Nothing to do for dependent name types - } - else if (underlyingType is ElaboratedType elaboratedType) - { - ForUnderlyingType(typedefDecl, elaboratedType.NamedType, onlyHandleRemappings); - } - else if (underlyingType is FunctionProtoType functionProtoType) - { - ForFunctionProtoType(typedefDecl, functionProtoType, parentType: null, onlyHandleRemappings); - } - else if (underlyingType is PointerType pointerType) - { - ForPointeeType(typedefDecl, parentType: null, pointerType.PointeeType, onlyHandleRemappings); - } - else if (underlyingType is ReferenceType referenceType) - { - ForPointeeType(typedefDecl, parentType: null, referenceType.PointeeType, onlyHandleRemappings); - } - else if (underlyingType is TagType underlyingTagType) - { - var underlyingName = GetCursorName(underlyingTagType.AsTagDecl); - var typedefName = GetCursorName(typedefDecl); + // Nothing to do for array types + } + else if (underlyingType is AttributedType attributedType) + { + ForUnderlyingType(typedefDecl, attributedType.ModifiedType, onlyHandleRemappings); + } + else if (underlyingType is BuiltinType builtinType) + { + // Nothing to do for builtin types + } + else if (underlyingType is DecltypeType decltypeType) + { + ForUnderlyingType(typedefDecl, decltypeType.UnderlyingType, onlyHandleRemappings); + } + else if (underlyingType is DependentNameType dependentNameType) + { + // Nothing to do for dependent name types + } + else if (underlyingType is ElaboratedType elaboratedType) + { + ForUnderlyingType(typedefDecl, elaboratedType.NamedType, onlyHandleRemappings); + } + else if (underlyingType is FunctionProtoType functionProtoType) + { + ForFunctionProtoType(typedefDecl, functionProtoType, parentType: null, onlyHandleRemappings); + } + else if (underlyingType is PointerType pointerType) + { + ForPointeeType(typedefDecl, parentType: null, pointerType.PointeeType, onlyHandleRemappings); + } + else if (underlyingType is ReferenceType referenceType) + { + ForPointeeType(typedefDecl, parentType: null, referenceType.PointeeType, onlyHandleRemappings); + } + else if (underlyingType is TagType underlyingTagType) + { + var underlyingName = GetCursorName(underlyingTagType.AsTagDecl); + var typedefName = GetCursorName(typedefDecl); - if (underlyingName != typedefName) + if (underlyingName != typedefName) + { + if (!_allValidNameRemappings.TryGetValue(underlyingName, out var allRemappings)) { - if (!_allValidNameRemappings.TryGetValue(underlyingName, out var allRemappings)) - { - allRemappings = new HashSet(); - _allValidNameRemappings[underlyingName] = allRemappings; - } - _ = allRemappings.Add(typedefName); + allRemappings = new HashSet(); + _allValidNameRemappings[underlyingName] = allRemappings; + } + _ = allRemappings.Add(typedefName); - if (!onlyHandleRemappings) + if (!onlyHandleRemappings) + { + if (!_traversedValidNameRemappings.TryGetValue(underlyingName, out var traversedRemappings)) { - if (!_traversedValidNameRemappings.TryGetValue(underlyingName, out var traversedRemappings)) - { - traversedRemappings = new HashSet(); - _traversedValidNameRemappings[underlyingName] = traversedRemappings; - } - _ = traversedRemappings.Add(typedefName); + traversedRemappings = new HashSet(); + _traversedValidNameRemappings[underlyingName] = traversedRemappings; } + _ = traversedRemappings.Add(typedefName); } } - else if (underlyingType is TemplateSpecializationType templateSpecializationType) - { - if (templateSpecializationType.IsTypeAlias) - { - ForUnderlyingType(typedefDecl, templateSpecializationType.AliasedType, onlyHandleRemappings); - } - else - { - // Nothing to do for non-aliased template specialization types - } - } - else if (underlyingType is TemplateTypeParmType templateTypeParmType) - { - // Nothing to do for template type parameter types - } - else if (underlyingType is TypedefType typedefType) + } + else if (underlyingType is TemplateSpecializationType templateSpecializationType) + { + if (templateSpecializationType.IsTypeAlias) { - ForUnderlyingType(typedefDecl, typedefType.Decl.UnderlyingType, onlyHandleRemappings); + ForUnderlyingType(typedefDecl, templateSpecializationType.AliasedType, onlyHandleRemappings); } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported underlying type: '{underlyingType.TypeClassSpelling}'. Generating bindings may be incomplete.", typedefDecl); + // Nothing to do for non-aliased template specialization types } - - return; } - - string GetUndecoratedName(Type type) + else if (underlyingType is TemplateTypeParmType templateTypeParmType) + { + // Nothing to do for template type parameter types + } + else if (underlyingType is TypedefType typedefType) + { + ForUnderlyingType(typedefDecl, typedefType.Decl.UnderlyingType, onlyHandleRemappings); + } + else { - return type is AttributedType attributedType - ? GetUndecoratedName(attributedType.ModifiedType) - : type is ElaboratedType elaboratedType ? GetUndecoratedName(elaboratedType.NamedType) : type.AsString; + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported underlying type: '{underlyingType.TypeClassSpelling}'. Generating bindings may be incomplete.", typedefDecl); } + + return; } - private static void VisitUsingShadowDecl(UsingShadowDecl usingShadowDecl) + string GetUndecoratedName(Type type) { - // Nothing to handle for binding generation + return type is AttributedType attributedType + ? GetUndecoratedName(attributedType.ModifiedType) + : type is ElaboratedType elaboratedType ? GetUndecoratedName(elaboratedType.NamedType) : type.AsString; } + } + + private static void VisitUsingShadowDecl(UsingShadowDecl usingShadowDecl) + { + // Nothing to handle for binding generation + } - private void VisitVarDecl(VarDecl varDecl) + private void VisitVarDecl(VarDecl varDecl) + { + if (IsPrevContextStmt(out var declStmt, out _)) + { + ForDeclStmt(varDecl, declStmt); + } + else if (IsPrevContextDecl(out _, out _) || IsPrevContextDecl(out _, out _) || IsPrevContextDecl(out _, out _) || IsPrevContextDecl(out _, out _)) { - if (IsPrevContextStmt(out var declStmt, out _)) + if (!varDecl.HasInit) { - ForDeclStmt(varDecl, declStmt); + // Nothing to do if a top level const declaration doesn't have an initializer + return; } - else if (IsPrevContextDecl(out _, out _) || IsPrevContextDecl(out _, out _) || IsPrevContextDecl(out _, out _) || IsPrevContextDecl(out _, out _)) - { - if (!varDecl.HasInit) - { - // Nothing to do if a top level const declaration doesn't have an initializer - return; - } - var type = varDecl.Type; - var isMacroDefinitionRecord = false; + var type = varDecl.Type; + var isMacroDefinitionRecord = false; - var nativeName = GetCursorName(varDecl); - if (nativeName.StartsWith("ClangSharpMacro_" + "")) - { - type = varDecl.Init.Type; - nativeName = nativeName["ClangSharpMacro_".Length..]; - isMacroDefinitionRecord = true; - } + var nativeName = GetCursorName(varDecl); + if (nativeName.StartsWith("ClangSharpMacro_" + "")) + { + type = varDecl.Init.Type; + nativeName = nativeName["ClangSharpMacro_".Length..]; + isMacroDefinitionRecord = true; + } - var accessSpecifier = GetAccessSpecifier(varDecl, matchStar: false); - var name = GetRemappedName(nativeName, varDecl, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true); - var escapedName = EscapeName(name); + var accessSpecifier = GetAccessSpecifier(varDecl, matchStar: false); + var name = GetRemappedName(nativeName, varDecl, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true); + var escapedName = EscapeName(name); - if (isMacroDefinitionRecord) + if (isMacroDefinitionRecord) + { + if (IsStmtAsWritten(varDecl.Init, out var declRefExpr, removeParens: true)) { - if (IsStmtAsWritten(varDecl.Init, out var declRefExpr, removeParens: true)) + if ((declRefExpr.Decl is NamedDecl namedDecl) && (name == GetCursorName(namedDecl))) { - if ((declRefExpr.Decl is NamedDecl namedDecl) && (name == GetCursorName(namedDecl))) - { - return; - } + return; } } + } - var openedOutputBuilder = false; - var className = GetClass(name); + var openedOutputBuilder = false; + var className = GetClass(name); - if (_outputBuilder is null) - { - openedOutputBuilder = true; + if (_outputBuilder is null) + { + openedOutputBuilder = true; - if (IsUnsafe(varDecl, type) && (!varDecl.HasInit || !IsStmtAsWritten(varDecl.Init, out _, removeParens: true))) - { - _topLevelClassIsUnsafe[className] = true; - } + if (IsUnsafe(varDecl, type) && (!varDecl.HasInit || !IsStmtAsWritten(varDecl.Init, out _, removeParens: true))) + { + _topLevelClassIsUnsafe[className] = true; } + } - var typeName = GetTargetTypeName(varDecl, out var nativeTypeName); + var typeName = GetTargetTypeName(varDecl, out var nativeTypeName); - if (isMacroDefinitionRecord) - { - var nativeTypeNameBuilder = new StringBuilder("#define"); + if (isMacroDefinitionRecord) + { + var nativeTypeNameBuilder = new StringBuilder("#define"); - _ = nativeTypeNameBuilder.Append(' '); - _ = nativeTypeNameBuilder.Append(nativeName); - _ = nativeTypeNameBuilder.Append(' '); + _ = nativeTypeNameBuilder.Append(' '); + _ = nativeTypeNameBuilder.Append(nativeName); + _ = nativeTypeNameBuilder.Append(' '); - var macroValue = GetSourceRangeContents(varDecl.TranslationUnit.Handle, varDecl.Init.Extent); - _ = nativeTypeNameBuilder.Append(macroValue); + var macroValue = GetSourceRangeContents(varDecl.TranslationUnit.Handle, varDecl.Init.Extent); + _ = nativeTypeNameBuilder.Append(macroValue); - nativeTypeName = nativeTypeNameBuilder.ToString(); - } + nativeTypeName = nativeTypeNameBuilder.ToString(); + } - var kind = ValueKind.Unknown; - var flags = ValueFlags.None; + var kind = ValueKind.Unknown; + var flags = ValueFlags.None; - if (varDecl.HasInit) - { - flags |= ValueFlags.Initializer; - } + if (varDecl.HasInit) + { + flags |= ValueFlags.Initializer; + } - if (type.IsLocalConstQualified || isMacroDefinitionRecord || (type is ConstantArrayType or IncompleteArrayType)) - { - flags |= ValueFlags.Constant; - } + if (type.IsLocalConstQualified || isMacroDefinitionRecord || (type is ConstantArrayType or IncompleteArrayType)) + { + flags |= ValueFlags.Constant; + } - if (IsStmtAsWritten(varDecl.Init, out var stringLiteral, removeParens: true)) - { - kind = ValueKind.String; + if (IsStmtAsWritten(varDecl.Init, out var stringLiteral, removeParens: true)) + { + kind = ValueKind.String; - switch (stringLiteral.Kind) + switch (stringLiteral.Kind) + { + case CX_CharacterKind.CX_CLK_Ascii: + case CX_CharacterKind.CX_CLK_UTF8: { - case CX_CharacterKind.CX_CLK_Ascii: - case CX_CharacterKind.CX_CLK_UTF8: - { - if (flags.HasFlag(ValueFlags.Constant)) - { - typeName = "ReadOnlySpan"; - } - else - { - typeName = "byte[]"; - } - break; - } - - case CX_CharacterKind.CX_CLK_Wide: + if (flags.HasFlag(ValueFlags.Constant)) { - if (_config.GenerateUnixTypes) - { - goto case CX_CharacterKind.CX_CLK_UTF32; - } - else - { - goto case CX_CharacterKind.CX_CLK_UTF16; - } + typeName = "ReadOnlySpan"; } - - case CX_CharacterKind.CX_CLK_UTF16: + else { - kind = ValueKind.Primitive; - typeName = "string"; - break; + typeName = "byte[]"; } + break; + } - case CX_CharacterKind.CX_CLK_UTF32: + case CX_CharacterKind.CX_CLK_Wide: + { + if (_config.GenerateUnixTypes) { - if (_config.GeneratePreviewCode && flags.HasFlag(ValueFlags.Constant)) - { - typeName = "ReadOnlySpan"; - } - else - { - typeName = "uint[]"; - } - break; + goto case CX_CharacterKind.CX_CLK_UTF32; } - - default: + else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported string literal kind: '{stringLiteral.Kind}'. Generated bindings may be incomplete.", stringLiteral); - break; + goto case CX_CharacterKind.CX_CLK_UTF16; } } - } - else if (IsPrimitiveValue(type)) - { - kind = ValueKind.Primitive; - if (flags.HasFlag(ValueFlags.Constant) && !IsConstant(typeName, varDecl.Init)) - { - flags |= ValueFlags.Copy; - } - else if (_config.WithTransparentStructs.TryGetValue(typeName, out var transparentStruct)) + case CX_CharacterKind.CX_CLK_UTF16: { - typeName = transparentStruct.Name; + kind = ValueKind.Primitive; + typeName = "string"; + break; } - } - else if ((varDecl.StorageClass == CX_StorageClass.CX_SC_Static) || openedOutputBuilder) - { - kind = ValueKind.Unmanaged; - if (varDecl.HasInit) + case CX_CharacterKind.CX_CLK_UTF32: { - if ((varDecl.Init is CXXConstructExpr cxxConstructExpr) && cxxConstructExpr.Constructor.IsCopyConstructor) + if (_config.GeneratePreviewCode && flags.HasFlag(ValueFlags.Constant)) + { + typeName = "ReadOnlySpan"; + } + else { - if (cxxConstructExpr.Args[0] is CXXUuidofExpr) - { - // It's easiest just to let _uuidsToGenerate handle it - return; - } - flags |= ValueFlags.Copy; + typeName = "uint[]"; } + break; } - if (type is ArrayType arrayType) + default: { - flags |= ValueFlags.Array; - - if (!_config.GenerateUnmanagedConstants) - { - do - { - typeName += "[]"; - arrayType = arrayType.ElementType as ArrayType; - } - while (arrayType is not null); - } + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported string literal kind: '{stringLiteral.Kind}'. Generated bindings may be incomplete.", stringLiteral); + break; } } + } + else if (IsPrimitiveValue(type)) + { + kind = ValueKind.Primitive; - if (typeName == "Guid") + if (flags.HasFlag(ValueFlags.Constant) && !IsConstant(typeName, varDecl.Init)) { - _ = _generatedUuids.Add(name); + flags |= ValueFlags.Copy; } - - var desc = new ValueDesc { - AccessSpecifier = accessSpecifier, - TypeName = typeName, - EscapedName = escapedName, - NativeTypeName = nativeTypeName, - Kind = kind, - Flags = flags, - Location = varDecl.Location, - WriteCustomAttrs = static context => { - (var varDecl, var generator) = ((VarDecl, PInvokeGenerator))context; - - generator.WithAttributes(varDecl); - generator.WithUsings(varDecl); - }, - CustomAttrGeneratorData = (varDecl, this), - }; - - if (openedOutputBuilder) + else if (_config.WithTransparentStructs.TryGetValue(typeName, out var transparentStruct)) { - StartUsingOutputBuilder(className); - - if ((kind == ValueKind.String) && typeName.StartsWith("ReadOnlySpan<")) - { - _outputBuilder.EmitSystemSupport(); - } + typeName = transparentStruct.Name; } - - _outputBuilder.BeginValue(in desc); - _context.Last.Value = (_context.Last.Value.Cursor, desc); + } + else if ((varDecl.StorageClass == CX_StorageClass.CX_SC_Static) || openedOutputBuilder) + { + kind = ValueKind.Unmanaged; if (varDecl.HasInit) { - var dereference = (type.CanonicalType is PointerType pointerType) && - (pointerType.PointeeType.CanonicalType is FunctionType) && - isMacroDefinitionRecord; - - if (dereference) + if ((varDecl.Init is CXXConstructExpr cxxConstructExpr) && cxxConstructExpr.Constructor.IsCopyConstructor) { - _outputBuilder.BeginDereference(); + if (cxxConstructExpr.Args[0] is CXXUuidofExpr) + { + // It's easiest just to let _uuidsToGenerate handle it + return; + } + flags |= ValueFlags.Copy; } + } - Visit(varDecl.Init); + if (type is ArrayType arrayType) + { + flags |= ValueFlags.Array; - if (dereference) + if (!_config.GenerateUnmanagedConstants) { - _outputBuilder.EndDereference(); + do + { + typeName += "[]"; + arrayType = arrayType.ElementType as ArrayType; + } + while (arrayType is not null); } } - - _outputBuilder.EndValue(in desc); - - if (openedOutputBuilder) - { - StopUsingOutputBuilder(); - } - else - { - _outputBuilder.WriteDivider(); - } - } - else if (IsPrevContextDecl(out _, out _)) - { - // This should be handled in the function body as part of a DeclStmt } - else + + if (typeName == "Guid") { - _ = IsPrevContextDecl(out var previousContext, out _); - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported variable declaration parent: '{previousContext.CursorKindSpelling}'. Generated bindings may be incomplete.", previousContext); + _ = _generatedUuids.Add(name); } - void ForDeclStmt(VarDecl varDecl, DeclStmt declStmt) + var desc = new ValueDesc { + AccessSpecifier = accessSpecifier, + TypeName = typeName, + EscapedName = escapedName, + NativeTypeName = nativeTypeName, + Kind = kind, + Flags = flags, + Location = varDecl.Location, + WriteCustomAttrs = static context => { + (var varDecl, var generator) = ((VarDecl, PInvokeGenerator))context; + + generator.WithAttributes(varDecl); + generator.WithUsings(varDecl); + }, + CustomAttrGeneratorData = (varDecl, this), + }; + + if (openedOutputBuilder) { - var outputBuilder = StartCSharpCode(); - var name = GetRemappedCursorName(varDecl); - var escapedName = EscapeName(name); + StartUsingOutputBuilder(className); - if (varDecl == declStmt.Decls.First()) + if ((kind == ValueKind.String) && typeName.StartsWith("ReadOnlySpan<")) { - var type = varDecl.Type; - var typeName = GetRemappedTypeName(varDecl, context: null, type, out _); + _outputBuilder.EmitSystemSupport(); + } + } - outputBuilder.Write(typeName); + _outputBuilder.BeginValue(in desc); + _context.Last.Value = (_context.Last.Value.Cursor, desc); - if (type is ArrayType) - { - outputBuilder.Write("[]"); - } + if (varDecl.HasInit) + { + var dereference = (type.CanonicalType is PointerType pointerType) && + (pointerType.PointeeType.CanonicalType is FunctionType) && + isMacroDefinitionRecord; - outputBuilder.Write(' '); + if (dereference) + { + _outputBuilder.BeginDereference(); } - outputBuilder.Write(escapedName); + Visit(varDecl.Init); - if (varDecl.HasInit) + if (dereference) { - outputBuilder.Write(" = "); - Visit(varDecl.Init); + _outputBuilder.EndDereference(); } + } - StopCSharpCode(); + _outputBuilder.EndValue(in desc); + + if (openedOutputBuilder) + { + StopUsingOutputBuilder(); + } + else + { + _outputBuilder.WriteDivider(); } } + else if (IsPrevContextDecl(out _, out _)) + { + // This should be handled in the function body as part of a DeclStmt + } + else + { + _ = IsPrevContextDecl(out var previousContext, out _); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported variable declaration parent: '{previousContext.CursorKindSpelling}'. Generated bindings may be incomplete.", previousContext); + } - private bool IsConstant(string targetTypeName, Expr initExpr) + void ForDeclStmt(VarDecl varDecl, DeclStmt declStmt) { - if (initExpr.Type.CanonicalType.IsPointerType && (targetTypeName != "string")) - { - return false; - } + var outputBuilder = StartCSharpCode(); + var name = GetRemappedCursorName(varDecl); + var escapedName = EscapeName(name); - switch (initExpr.StmtClass) + if (varDecl == declStmt.Decls.First()) { - // case CX_StmtClass.CX_StmtClass_BinaryConditionalOperator: + var type = varDecl.Type; + var typeName = GetRemappedTypeName(varDecl, context: null, type, out _); + + outputBuilder.Write(typeName); - case CX_StmtClass.CX_StmtClass_ConditionalOperator: + if (type is ArrayType) { - var conditionalOperator = (ConditionalOperator)initExpr; - return IsConstant(targetTypeName, conditionalOperator.Cond) && IsConstant(targetTypeName, conditionalOperator.LHS) && IsConstant(targetTypeName, conditionalOperator.RHS); + outputBuilder.Write("[]"); } - // case CX_StmtClass.CX_StmtClass_AddrLabelExpr: - // case CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr: - // case CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr: + outputBuilder.Write(' '); + } - case CX_StmtClass.CX_StmtClass_ArraySubscriptExpr: - { - return false; - } + outputBuilder.Write(escapedName); - // case CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr: - // case CX_StmtClass.CX_StmtClass_AsTypeExpr: - // case CX_StmtClass.CX_StmtClass_AtomicExpr: + if (varDecl.HasInit) + { + outputBuilder.Write(" = "); + Visit(varDecl.Init); + } - case CX_StmtClass.CX_StmtClass_BinaryOperator: - { - var binaryOperator = (BinaryOperator)initExpr; - return IsConstant(targetTypeName, binaryOperator.LHS) && IsConstant(targetTypeName, binaryOperator.RHS); - } + StopCSharpCode(); + } + } - // case CX_StmtClass.CX_StmtClass_CompoundAssignOperator: - // case CX_StmtClass.CX_StmtClass_BlockExpr: - // case CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr: + private bool IsConstant(string targetTypeName, Expr initExpr) + { + if (initExpr.Type.CanonicalType.IsPointerType && (targetTypeName != "string")) + { + return false; + } - case CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr: - { - return true; - } + switch (initExpr.StmtClass) + { + // case CX_StmtClass.CX_StmtClass_BinaryConditionalOperator: - case CX_StmtClass.CX_StmtClass_CXXConstructExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_ConditionalOperator: + { + var conditionalOperator = (ConditionalOperator)initExpr; + return IsConstant(targetTypeName, conditionalOperator.Cond) && IsConstant(targetTypeName, conditionalOperator.LHS) && IsConstant(targetTypeName, conditionalOperator.RHS); + } - // case CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr: - // case CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr: + // case CX_StmtClass.CX_StmtClass_AddrLabelExpr: + // case CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr: + // case CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr: - case CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_ArraySubscriptExpr: + { + return false; + } - // case CX_StmtClass.CX_StmtClass_CXXDeleteExpr: + // case CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr: + // case CX_StmtClass.CX_StmtClass_AsTypeExpr: + // case CX_StmtClass.CX_StmtClass_AtomicExpr: - case CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_BinaryOperator: + { + var binaryOperator = (BinaryOperator)initExpr; + return IsConstant(targetTypeName, binaryOperator.LHS) && IsConstant(targetTypeName, binaryOperator.RHS); + } - // case CX_StmtClass.CX_StmtClass_CXXFoldExpr: - // case CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr: + // case CX_StmtClass.CX_StmtClass_CompoundAssignOperator: + // case CX_StmtClass.CX_StmtClass_BlockExpr: + // case CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr: - case CX_StmtClass.CX_StmtClass_CXXNewExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr: + { + return true; + } - // case CX_StmtClass.CX_StmtClass_CXXNoexceptExpr: + case CX_StmtClass.CX_StmtClass_CXXConstructExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr: - { - return true; - } + // case CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr: + // case CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr: - // case CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr: - // case CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator: - // case CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr: - // case CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr: + case CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_CXXThisExpr: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_CXXDeleteExpr: - // case CX_StmtClass.CX_StmtClass_CXXThrowExpr: - // case CX_StmtClass.CX_StmtClass_CXXTypeidExpr: - // case CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr: + case CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_CXXUuidofExpr: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_CXXFoldExpr: + // case CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr: - case CX_StmtClass.CX_StmtClass_CallExpr: - { - var callExpr = (CallExpr)initExpr; + case CX_StmtClass.CX_StmtClass_CXXNewExpr: + { + return false; + } - if (callExpr.DirectCallee.IsInlined) - { - var evaluateResult = callExpr.Handle.Evaluate; + // case CX_StmtClass.CX_StmtClass_CXXNoexceptExpr: - switch (evaluateResult.Kind) - { - case CXEvalResultKind.CXEval_Int: - { - return true; - } - - case CXEvalResultKind.CXEval_Float: - { - return true; - } - } - } + case CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr: + { + return true; + } - return false; - } + // case CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr: + // case CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator: + // case CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr: + // case CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr: + + case CX_StmtClass.CX_StmtClass_CXXThisExpr: + { + return false; + } + + // case CX_StmtClass.CX_StmtClass_CXXThrowExpr: + // case CX_StmtClass.CX_StmtClass_CXXTypeidExpr: + // case CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr: + + case CX_StmtClass.CX_StmtClass_CXXUuidofExpr: + { + return false; + } - // case CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr: - // case CX_StmtClass.CX_StmtClass_CXXMemberCallExpr: + case CX_StmtClass.CX_StmtClass_CallExpr: + { + var callExpr = (CallExpr)initExpr; - case CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr: + if (callExpr.DirectCallee.IsInlined) { - var cxxOperatorCall = (CXXOperatorCallExpr)initExpr; + var evaluateResult = callExpr.Handle.Evaluate; - if (cxxOperatorCall.CalleeDecl is FunctionDecl functionDecl) + switch (evaluateResult.Kind) { - var functionDeclName = GetCursorName(functionDecl); + case CXEvalResultKind.CXEval_Int: + { + return true; + } - if (IsEnumOperator(functionDecl, functionDeclName)) + case CXEvalResultKind.CXEval_Float: { return true; } } - - return false; } - // case CX_StmtClass.CX_StmtClass_UserDefinedLiteral: - // case CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr: + return false; + } - case CX_StmtClass.CX_StmtClass_CStyleCastExpr: - case CX_StmtClass.CX_StmtClass_CXXStaticCastExpr: - case CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr: - { - var cxxFunctionalCastExpr = (ExplicitCastExpr)initExpr; - return IsConstant(targetTypeName, cxxFunctionalCastExpr.SubExprAsWritten); - } + // case CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr: + // case CX_StmtClass.CX_StmtClass_CXXMemberCallExpr: - // case CX_StmtClass.CX_StmtClass_CXXConstCastExpr: - // case CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr: - // case CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr: - // case CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr: + case CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr: + { + var cxxOperatorCall = (CXXOperatorCallExpr)initExpr; - case CX_StmtClass.CX_StmtClass_ImplicitCastExpr: + if (cxxOperatorCall.CalleeDecl is FunctionDecl functionDecl) { - var implicitCastExpr = (ImplicitCastExpr)initExpr; - return IsConstant(targetTypeName, implicitCastExpr.SubExprAsWritten); - } + var functionDeclName = GetCursorName(functionDecl); - case CX_StmtClass.CX_StmtClass_CharacterLiteral: - { - return true; + if (IsEnumOperator(functionDecl, functionDeclName)) + { + return true; + } } - // case CX_StmtClass.CX_StmtClass_ChooseExpr: - // case CX_StmtClass.CX_StmtClass_CompoundLiteralExpr: - // case CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr: - // case CX_StmtClass.CX_StmtClass_ConvertVectorExpr: - // case CX_StmtClass.CX_StmtClass_CoawaitExpr: - // case CX_StmtClass.CX_StmtClass_CoyieldExpr: + return false; + } - case CX_StmtClass.CX_StmtClass_DeclRefExpr: - { - var declRefExpr = (DeclRefExpr)initExpr; - return (declRefExpr.Decl is EnumConstantDecl) || - ((declRefExpr.Decl is VarDecl varDecl) && varDecl.HasInit && IsConstant(targetTypeName, varDecl.Init)); - } + // case CX_StmtClass.CX_StmtClass_UserDefinedLiteral: + // case CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr: - // case CX_StmtClass.CX_StmtClass_DependentCoawaitExpr: - // case CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr: - // case CX_StmtClass.CX_StmtClass_DesignatedInitExpr: - // case CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr: - // case CX_StmtClass.CX_StmtClass_ExpressionTraitExpr: - // case CX_StmtClass.CX_StmtClass_ExtVectorElementExpr: - // case CX_StmtClass.CX_StmtClass_FixedPointLiteral: + case CX_StmtClass.CX_StmtClass_CStyleCastExpr: + case CX_StmtClass.CX_StmtClass_CXXStaticCastExpr: + case CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr: + { + var cxxFunctionalCastExpr = (ExplicitCastExpr)initExpr; + return IsConstant(targetTypeName, cxxFunctionalCastExpr.SubExprAsWritten); + } - case CX_StmtClass.CX_StmtClass_FloatingLiteral: - { - return true; - } + // case CX_StmtClass.CX_StmtClass_CXXConstCastExpr: + // case CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr: + // case CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr: + // case CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr: - // case CX_StmtClass.CX_StmtClass_ConstantExpr: + case CX_StmtClass.CX_StmtClass_ImplicitCastExpr: + { + var implicitCastExpr = (ImplicitCastExpr)initExpr; + return IsConstant(targetTypeName, implicitCastExpr.SubExprAsWritten); + } - case CX_StmtClass.CX_StmtClass_ExprWithCleanups: - { - var exprWithCleanups = (ExprWithCleanups)initExpr; - return IsConstant(targetTypeName, exprWithCleanups.SubExpr); - } + case CX_StmtClass.CX_StmtClass_CharacterLiteral: + { + return true; + } - // case CX_StmtClass.CX_StmtClass_FunctionParmPackExpr: - // case CX_StmtClass.CX_StmtClass_GNUNullExpr: - // case CX_StmtClass.CX_StmtClass_GenericSelectionExpr: - // case CX_StmtClass.CX_StmtClass_ImaginaryLiteral: - // case CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr: + // case CX_StmtClass.CX_StmtClass_ChooseExpr: + // case CX_StmtClass.CX_StmtClass_CompoundLiteralExpr: + // case CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr: + // case CX_StmtClass.CX_StmtClass_ConvertVectorExpr: + // case CX_StmtClass.CX_StmtClass_CoawaitExpr: + // case CX_StmtClass.CX_StmtClass_CoyieldExpr: - case CX_StmtClass.CX_StmtClass_InitListExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_DeclRefExpr: + { + var declRefExpr = (DeclRefExpr)initExpr; + return (declRefExpr.Decl is EnumConstantDecl) || + ((declRefExpr.Decl is VarDecl varDecl) && varDecl.HasInit && IsConstant(targetTypeName, varDecl.Init)); + } - case CX_StmtClass.CX_StmtClass_IntegerLiteral: - { - return true; - } + // case CX_StmtClass.CX_StmtClass_DependentCoawaitExpr: + // case CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr: + // case CX_StmtClass.CX_StmtClass_DesignatedInitExpr: + // case CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr: + // case CX_StmtClass.CX_StmtClass_ExpressionTraitExpr: + // case CX_StmtClass.CX_StmtClass_ExtVectorElementExpr: + // case CX_StmtClass.CX_StmtClass_FixedPointLiteral: - case CX_StmtClass.CX_StmtClass_LambdaExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_FloatingLiteral: + { + return true; + } - // case CX_StmtClass.CX_StmtClass_MSPropertyRefExpr: - // case CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr: - // case CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr: + // case CX_StmtClass.CX_StmtClass_ConstantExpr: - case CX_StmtClass.CX_StmtClass_MemberExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_ExprWithCleanups: + { + var exprWithCleanups = (ExprWithCleanups)initExpr; + return IsConstant(targetTypeName, exprWithCleanups.SubExpr); + } - // case CX_StmtClass.CX_StmtClass_NoInitExpr: - // case CX_StmtClass.CX_StmtClass_OMPArraySectionExpr: - // case CX_StmtClass.CX_StmtClass_ObjCArrayLiteral: - // case CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr: - // case CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr: - // case CX_StmtClass.CX_StmtClass_ObjCBoxedExpr: - // case CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral: - // case CX_StmtClass.CX_StmtClass_ObjCEncodeExpr: - // case CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr: - // case CX_StmtClass.CX_StmtClass_ObjCIsaExpr: - // case CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr: - // case CX_StmtClass.CX_StmtClass_ObjCMessageExpr: - // case CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr: - // case CX_StmtClass.CX_StmtClass_ObjCProtocolExpr: - // case CX_StmtClass.CX_StmtClass_ObjCSelectorExpr: - // case CX_StmtClass.CX_StmtClass_ObjCStringLiteral: - // case CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr: - - case CX_StmtClass.CX_StmtClass_OffsetOfExpr: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_FunctionParmPackExpr: + // case CX_StmtClass.CX_StmtClass_GNUNullExpr: + // case CX_StmtClass.CX_StmtClass_GenericSelectionExpr: + // case CX_StmtClass.CX_StmtClass_ImaginaryLiteral: + // case CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr: - // case CX_StmtClass.CX_StmtClass_OpaqueValueExpr: - // case CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr: - // case CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr: - // case CX_StmtClass.CX_StmtClass_PackExpansionExpr: + case CX_StmtClass.CX_StmtClass_InitListExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_ParenExpr: - { - var parenExpr = (ParenExpr)initExpr; - return IsConstant(targetTypeName, parenExpr.SubExpr); - } + case CX_StmtClass.CX_StmtClass_IntegerLiteral: + { + return true; + } - case CX_StmtClass.CX_StmtClass_ParenListExpr: - { - var parenListExpr = (ParenListExpr)initExpr; + case CX_StmtClass.CX_StmtClass_LambdaExpr: + { + return false; + } - foreach (var expr in parenListExpr.Exprs) - { - if (IsConstant(targetTypeName, expr)) - { - return true; - } - } + // case CX_StmtClass.CX_StmtClass_MSPropertyRefExpr: + // case CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr: + // case CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr: - return false; - } + case CX_StmtClass.CX_StmtClass_MemberExpr: + { + return false; + } - // case CX_StmtClass.CX_StmtClass_PredefinedExpr: - // case CX_StmtClass.CX_StmtClass_PseudoObjectExpr: - // case CX_StmtClass.CX_StmtClass_RequiresExpr: - // case CX_StmtClass.CX_StmtClass_ShuffleVectorExpr: - // case CX_StmtClass.CX_StmtClass_SizeOfPackExpr: - // case CX_StmtClass.CX_StmtClass_SourceLocExpr: - // case CX_StmtClass.CX_StmtClass_StmtExpr: + // case CX_StmtClass.CX_StmtClass_NoInitExpr: + // case CX_StmtClass.CX_StmtClass_OMPArraySectionExpr: + // case CX_StmtClass.CX_StmtClass_ObjCArrayLiteral: + // case CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr: + // case CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr: + // case CX_StmtClass.CX_StmtClass_ObjCBoxedExpr: + // case CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral: + // case CX_StmtClass.CX_StmtClass_ObjCEncodeExpr: + // case CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr: + // case CX_StmtClass.CX_StmtClass_ObjCIsaExpr: + // case CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr: + // case CX_StmtClass.CX_StmtClass_ObjCMessageExpr: + // case CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr: + // case CX_StmtClass.CX_StmtClass_ObjCProtocolExpr: + // case CX_StmtClass.CX_StmtClass_ObjCSelectorExpr: + // case CX_StmtClass.CX_StmtClass_ObjCStringLiteral: + // case CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr: + + case CX_StmtClass.CX_StmtClass_OffsetOfExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_StringLiteral: - { - return true; - } + // case CX_StmtClass.CX_StmtClass_OpaqueValueExpr: + // case CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr: + // case CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr: + // case CX_StmtClass.CX_StmtClass_PackExpansionExpr: + + case CX_StmtClass.CX_StmtClass_ParenExpr: + { + var parenExpr = (ParenExpr)initExpr; + return IsConstant(targetTypeName, parenExpr.SubExpr); + } - case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr: + case CX_StmtClass.CX_StmtClass_ParenListExpr: + { + var parenListExpr = (ParenListExpr)initExpr; + + foreach (var expr in parenListExpr.Exprs) { - return false; + if (IsConstant(targetTypeName, expr)) + { + return true; + } } - // case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr: - // case CX_StmtClass.CX_StmtClass_TypeTraitExpr: - // case CX_StmtClass.CX_StmtClass_TypoExpr: + return false; + } + + // case CX_StmtClass.CX_StmtClass_PredefinedExpr: + // case CX_StmtClass.CX_StmtClass_PseudoObjectExpr: + // case CX_StmtClass.CX_StmtClass_RequiresExpr: + // case CX_StmtClass.CX_StmtClass_ShuffleVectorExpr: + // case CX_StmtClass.CX_StmtClass_SizeOfPackExpr: + // case CX_StmtClass.CX_StmtClass_SourceLocExpr: + // case CX_StmtClass.CX_StmtClass_StmtExpr: - case CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr: - { - var unaryExprOrTypeTraitExpr = (UnaryExprOrTypeTraitExpr)initExpr; - var argumentType = unaryExprOrTypeTraitExpr.TypeOfArgument; + case CX_StmtClass.CX_StmtClass_StringLiteral: + { + return true; + } + case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr: + { + return false; + } - long alignment32 = -1; - long alignment64 = -1; + // case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr: + // case CX_StmtClass.CX_StmtClass_TypeTraitExpr: + // case CX_StmtClass.CX_StmtClass_TypoExpr: - GetTypeSize(unaryExprOrTypeTraitExpr, argumentType, ref alignment32, ref alignment64, out var size32, out var size64); + case CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr: + { + var unaryExprOrTypeTraitExpr = (UnaryExprOrTypeTraitExpr)initExpr; + var argumentType = unaryExprOrTypeTraitExpr.TypeOfArgument; - switch (unaryExprOrTypeTraitExpr.Kind) - { - case CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf: - { - return size32 == size64; - } - case CX_UnaryExprOrTypeTrait.CX_UETT_AlignOf: - case CX_UnaryExprOrTypeTrait.CX_UETT_PreferredAlignOf: - { - return alignment32 == alignment64; - } + long alignment32 = -1; + long alignment64 = -1; - default: - { - return false; - } - } - } + GetTypeSize(unaryExprOrTypeTraitExpr, argumentType, ref alignment32, ref alignment64, out var size32, out var size64); - case CX_StmtClass.CX_StmtClass_UnaryOperator: + switch (unaryExprOrTypeTraitExpr.Kind) { - var unaryOperator = (UnaryOperator)initExpr; - - if (!IsConstant(targetTypeName, unaryOperator.SubExpr)) + case CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf: { - return false; + return size32 == size64; } - if (unaryOperator.Opcode != CX_UnaryOperatorKind.CX_UO_Minus) + case CX_UnaryExprOrTypeTrait.CX_UETT_AlignOf: + case CX_UnaryExprOrTypeTrait.CX_UETT_PreferredAlignOf: { - return true; + return alignment32 == alignment64; } - return targetTypeName is not "IntPtr" and not "nint" and not "nuint" and not "UIntPtr"; + default: + { + return false; + } } + } - // case CX_StmtClass.CX_StmtClass_VAArgExpr: + case CX_StmtClass.CX_StmtClass_UnaryOperator: + { + var unaryOperator = (UnaryOperator)initExpr; - default: + if (!IsConstant(targetTypeName, unaryOperator.SubExpr)) { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported statement class: '{initExpr.StmtClassName}'. Generated bindings may not be constant.", initExpr); return false; } - } - } - private bool IsPrimitiveValue(Type type) - { - if (type is AttributedType attributedType) - { - return IsPrimitiveValue(attributedType.ModifiedType); - } - else if (type is AutoType autoType) - { - return IsPrimitiveValue(autoType.CanonicalType); - } - else if (type is BuiltinType) - { - switch (type.Kind) + if (unaryOperator.Opcode != CX_UnaryOperatorKind.CX_UO_Minus) { - case CXTypeKind.CXType_Bool: - case CXTypeKind.CXType_Char_U: - case CXTypeKind.CXType_UChar: - case CXTypeKind.CXType_Char16: - case CXTypeKind.CXType_UShort: - case CXTypeKind.CXType_UInt: - case CXTypeKind.CXType_ULong: - case CXTypeKind.CXType_ULongLong: - case CXTypeKind.CXType_Char_S: - case CXTypeKind.CXType_SChar: - case CXTypeKind.CXType_WChar: - case CXTypeKind.CXType_Short: - case CXTypeKind.CXType_Int: - case CXTypeKind.CXType_Long: - case CXTypeKind.CXType_LongLong: - case CXTypeKind.CXType_Float: - case CXTypeKind.CXType_Double: - { - return true; - } + return true; } + + return targetTypeName is not "IntPtr" and not "nint" and not "nuint" and not "UIntPtr"; } - else if (type is ElaboratedType elaboratedType) - { - return IsPrimitiveValue(elaboratedType.NamedType); - } - else if (type is EnumType enumType) - { - return IsPrimitiveValue(enumType.Decl.IntegerType); - } - else if (type is TypedefType typedefType) + + // case CX_StmtClass.CX_StmtClass_VAArgExpr: + + default: { - return IsPrimitiveValue(typedefType.Decl.UnderlyingType); + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported statement class: '{initExpr.StmtClassName}'. Generated bindings may not be constant.", initExpr); + return false; } + } + } - return type.IsPointerType; + private bool IsPrimitiveValue(Type type) + { + if (type is AttributedType attributedType) + { + return IsPrimitiveValue(attributedType.ModifiedType); + } + else if (type is AutoType autoType) + { + return IsPrimitiveValue(autoType.CanonicalType); + } + else if (type is BuiltinType) + { + switch (type.Kind) + { + case CXTypeKind.CXType_Bool: + case CXTypeKind.CXType_Char_U: + case CXTypeKind.CXType_UChar: + case CXTypeKind.CXType_Char16: + case CXTypeKind.CXType_UShort: + case CXTypeKind.CXType_UInt: + case CXTypeKind.CXType_ULong: + case CXTypeKind.CXType_ULongLong: + case CXTypeKind.CXType_Char_S: + case CXTypeKind.CXType_SChar: + case CXTypeKind.CXType_WChar: + case CXTypeKind.CXType_Short: + case CXTypeKind.CXType_Int: + case CXTypeKind.CXType_Long: + case CXTypeKind.CXType_LongLong: + case CXTypeKind.CXType_Float: + case CXTypeKind.CXType_Double: + { + return true; + } + } + } + else if (type is ElaboratedType elaboratedType) + { + return IsPrimitiveValue(elaboratedType.NamedType); + } + else if (type is EnumType enumType) + { + return IsPrimitiveValue(enumType.Decl.IntegerType); + } + else if (type is TypedefType typedefType) + { + return IsPrimitiveValue(typedefType.Decl.UnderlyingType); } + + return type.IsPointerType; } } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitPreprocessedEntity.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitPreprocessedEntity.cs index fe5fbd28..c79329c6 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitPreprocessedEntity.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitPreprocessedEntity.cs @@ -2,91 +2,90 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public partial class PInvokeGenerator { - public partial class PInvokeGenerator + private unsafe void VisitMacroDefinitionRecord(MacroDefinitionRecord macroDefinitionRecord) { - private unsafe void VisitMacroDefinitionRecord(MacroDefinitionRecord macroDefinitionRecord) + if (IsExcluded(macroDefinitionRecord)) { - if (IsExcluded(macroDefinitionRecord)) - { - return; - } + return; + } - if (macroDefinitionRecord.IsFunctionLike) - { - AddDiagnostic(DiagnosticLevel.Warning, $"Function like macro definition records are not supported: '{macroDefinitionRecord.Name}'. Generated bindings may be incomplete.", macroDefinitionRecord); - return; - } + if (macroDefinitionRecord.IsFunctionLike) + { + AddDiagnostic(DiagnosticLevel.Warning, $"Function like macro definition records are not supported: '{macroDefinitionRecord.Name}'. Generated bindings may be incomplete.", macroDefinitionRecord); + return; + } - var translationUnitHandle = macroDefinitionRecord.TranslationUnit.Handle; - var tokens = translationUnitHandle.Tokenize(macroDefinitionRecord.Extent).ToArray(); + var translationUnitHandle = macroDefinitionRecord.TranslationUnit.Handle; + var tokens = translationUnitHandle.Tokenize(macroDefinitionRecord.Extent).ToArray(); - if ((tokens[0].Kind == CXTokenKind.CXToken_Identifier) && (tokens[0].GetSpelling(translationUnitHandle).CString == macroDefinitionRecord.Spelling)) + if ((tokens[0].Kind == CXTokenKind.CXToken_Identifier) && (tokens[0].GetSpelling(translationUnitHandle).CString == macroDefinitionRecord.Spelling)) + { + if (tokens.Length == 1) { - if (tokens.Length == 1) - { - // Nothing to do for simple macro definitions with no value - return; - } + // Nothing to do for simple macro definitions with no value + return; + } - var macroName = $"ClangSharpMacro_{macroDefinitionRecord.Spelling}"; + var macroName = $"ClangSharpMacro_{macroDefinitionRecord.Spelling}"; - _ = _fileContentsBuilder.Append('\n'); - _ = _fileContentsBuilder.Append($"const auto {macroName} = "); + _ = _fileContentsBuilder.Append('\n'); + _ = _fileContentsBuilder.Append($"const auto {macroName} = "); - var sourceRangeEnd = tokens[^1].GetExtent(translationUnitHandle).End; - var sourceRangeStart = tokens[1].GetLocation(translationUnitHandle); + var sourceRangeEnd = tokens[^1].GetExtent(translationUnitHandle).End; + var sourceRangeStart = tokens[1].GetLocation(translationUnitHandle); - var sourceRange = CXSourceRange.Create(sourceRangeStart, sourceRangeEnd); + var sourceRange = CXSourceRange.Create(sourceRangeStart, sourceRangeEnd); - var macroValue = GetSourceRangeContents(translationUnitHandle, sourceRange); - _ = _fileContentsBuilder.Append(macroValue); + var macroValue = GetSourceRangeContents(translationUnitHandle, sourceRange); + _ = _fileContentsBuilder.Append(macroValue); - _ = _fileContentsBuilder.Append(';'); - _ = _fileContentsBuilder.Append('\n'); - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported macro definition record: {macroDefinitionRecord.Name}. Generated bindings may be incomplete.", macroDefinitionRecord); - } + _ = _fileContentsBuilder.Append(';'); + _ = _fileContentsBuilder.Append('\n'); + } + else + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported macro definition record: {macroDefinitionRecord.Name}. Generated bindings may be incomplete.", macroDefinitionRecord); } + } - private void VisitPreprocessingDirective(PreprocessingDirective preprocessingDirective) + private void VisitPreprocessingDirective(PreprocessingDirective preprocessingDirective) + { + if (preprocessingDirective is InclusionDirective) { - if (preprocessingDirective is InclusionDirective) - { - // Not currently handling inclusion directives - } - else if (preprocessingDirective is MacroDefinitionRecord macroDefinitionRecord) - { - VisitMacroDefinitionRecord(macroDefinitionRecord); - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported preprocessing directive: '{preprocessingDirective.CursorKind}'. Generated bindings may be incomplete.", preprocessingDirective); - } + // Not currently handling inclusion directives + } + else if (preprocessingDirective is MacroDefinitionRecord macroDefinitionRecord) + { + VisitMacroDefinitionRecord(macroDefinitionRecord); + } + else + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported preprocessing directive: '{preprocessingDirective.CursorKind}'. Generated bindings may be incomplete.", preprocessingDirective); } + } - private void VisitPreprocessedEntity(PreprocessedEntity preprocessedEntity) + private void VisitPreprocessedEntity(PreprocessedEntity preprocessedEntity) + { + if (!_config.GenerateMacroBindings) { - if (!_config.GenerateMacroBindings) - { - return; - } + return; + } - if (preprocessedEntity is MacroExpansion) - { - // Not currently handling macro expansions - } - else if (preprocessedEntity is PreprocessingDirective preprocessingDirective) - { - VisitPreprocessingDirective(preprocessingDirective); - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported preprocessed entity: '{preprocessedEntity.CursorKind}'. Generated bindings may be incomplete.", preprocessedEntity); - } + if (preprocessedEntity is MacroExpansion) + { + // Not currently handling macro expansions + } + else if (preprocessedEntity is PreprocessingDirective preprocessingDirective) + { + VisitPreprocessingDirective(preprocessingDirective); + } + else + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported preprocessed entity: '{preprocessedEntity.CursorKind}'. Generated bindings may be incomplete.", preprocessedEntity); } } } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitRef.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitRef.cs index a2b6925e..ed9cb36d 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitRef.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitRef.cs @@ -1,14 +1,13 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp +namespace ClangSharp; + +public partial class PInvokeGenerator { - public partial class PInvokeGenerator + private void VisitRef(Ref @ref) { - private void VisitRef(Ref @ref) - { - var name = GetRemappedCursorName(@ref.Referenced); - StartCSharpCode().Write(name); - StopCSharpCode(); - } + var name = GetRemappedCursorName(@ref.Referenced); + StartCSharpCode().Write(name); + StopCSharpCode(); } } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs index 06923702..ae57bdcb 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs @@ -10,1537 +10,1598 @@ using ClangSharp.Abstractions; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public partial class PInvokeGenerator { - public partial class PInvokeGenerator + private void VisitArraySubscriptExpr(ArraySubscriptExpr arraySubscriptExpr) { - private void VisitArraySubscriptExpr(ArraySubscriptExpr arraySubscriptExpr) - { - var outputBuilder = StartCSharpCode(); - Visit(arraySubscriptExpr.Base); - outputBuilder.Write('['); - Visit(arraySubscriptExpr.Idx); - outputBuilder.Write(']'); - StopCSharpCode(); - } + var outputBuilder = StartCSharpCode(); + Visit(arraySubscriptExpr.Base); + outputBuilder.Write('['); + Visit(arraySubscriptExpr.Idx); + outputBuilder.Write(']'); + StopCSharpCode(); + } - private void VisitBinaryOperator(BinaryOperator binaryOperator) - { - var outputBuilder = StartCSharpCode(); - Visit(binaryOperator.LHS); - outputBuilder.Write(' '); - outputBuilder.Write(binaryOperator.OpcodeStr); - outputBuilder.Write(' '); - Visit(binaryOperator.RHS); - StopCSharpCode(); - } + private void VisitBinaryOperator(BinaryOperator binaryOperator) + { + var outputBuilder = StartCSharpCode(); + Visit(binaryOperator.LHS); + outputBuilder.Write(' '); + outputBuilder.Write(binaryOperator.OpcodeStr); + outputBuilder.Write(' '); + Visit(binaryOperator.RHS); + StopCSharpCode(); + } + + private void VisitBreakStmt(BreakStmt breakStmt) + { + StartCSharpCode().Write("break"); + StopCSharpCode(); + } - private void VisitBreakStmt(BreakStmt breakStmt) + private void VisitBody(Stmt stmt) + { + var outputBuilder = StartCSharpCode(); + if (stmt is CompoundStmt) { - StartCSharpCode().Write("break"); - StopCSharpCode(); + Visit(stmt); } - - private void VisitBody(Stmt stmt) + else { - var outputBuilder = StartCSharpCode(); - if (stmt is CompoundStmt) - { - Visit(stmt); - } - else - { - outputBuilder.WriteBlockStart(); - outputBuilder.WriteIndentation(); - outputBuilder.NeedsSemicolon = true; - outputBuilder.NeedsNewline = true; - - Visit(stmt); + outputBuilder.WriteBlockStart(); + outputBuilder.WriteIndentation(); + outputBuilder.NeedsSemicolon = true; + outputBuilder.NeedsNewline = true; - outputBuilder.WriteSemicolonIfNeeded(); - outputBuilder.WriteNewlineIfNeeded(); - outputBuilder.WriteBlockEnd(); - } + Visit(stmt); - StopCSharpCode(); + outputBuilder.WriteSemicolonIfNeeded(); + outputBuilder.WriteNewlineIfNeeded(); + outputBuilder.WriteBlockEnd(); } - private void VisitCallExpr(CallExpr callExpr) + StopCSharpCode(); + } + + private void VisitCallExpr(CallExpr callExpr) + { + var outputBuilder = StartCSharpCode(); + var calleeDecl = callExpr.CalleeDecl; + + if ((callExpr.DirectCallee is not null) && callExpr.DirectCallee.IsInlined) { - var outputBuilder = StartCSharpCode(); - var calleeDecl = callExpr.CalleeDecl; + var evalResult = callExpr.Handle.Evaluate; + var canonicalType = callExpr.Type.CanonicalType; - if ((callExpr.DirectCallee is not null) && callExpr.DirectCallee.IsInlined) + switch (evalResult.Kind) { - var evalResult = callExpr.Handle.Evaluate; - var canonicalType = callExpr.Type.CanonicalType; - - switch (evalResult.Kind) + case CXEvalResultKind.CXEval_Int: { - case CXEvalResultKind.CXEval_Int: + if (canonicalType.Handle.IsUnsigned) { - if (canonicalType.Handle.IsUnsigned) - { - outputBuilder.Write(evalResult.AsUnsigned); - } - else - { - outputBuilder.Write(evalResult.AsLongLong); - } - - StopCSharpCode(); - return; + outputBuilder.Write(evalResult.AsUnsigned); } - - case CXEvalResultKind.CXEval_Float: + else { - if (canonicalType.Kind == CXTypeKind.CXType_Float) - { - outputBuilder.Write((float)evalResult.AsDouble); - } - else - { - outputBuilder.Write(evalResult.AsDouble); - } - - StopCSharpCode(); - return; + outputBuilder.Write(evalResult.AsLongLong); } - case CXEvalResultKind.CXEval_StrLiteral: - { - AddDiagnostic(DiagnosticLevel.Info, "Possible string constant"); - break; - } + StopCSharpCode(); + return; } - } - var isUnusedValue = false; + case CXEvalResultKind.CXEval_Float: + { + if (canonicalType.Kind == CXTypeKind.CXType_Float) + { + outputBuilder.Write((float)evalResult.AsDouble); + } + else + { + outputBuilder.Write(evalResult.AsDouble); + } - if (callExpr.Type.CanonicalType.Kind != CXTypeKind.CXType_Void) - { - isUnusedValue = IsPrevContextStmt(out _, out _) - || IsPrevContextStmt(out _, out _); + StopCSharpCode(); + return; + } - if ((calleeDecl is FunctionDecl functionDecl) && (functionDecl.Name is "memcpy" or "memset")) + case CXEvalResultKind.CXEval_StrLiteral: { - isUnusedValue = false; + AddDiagnostic(DiagnosticLevel.Info, "Possible string constant"); + break; } } + } - if (isUnusedValue) - { - outputBuilder.Write("_ = "); - } + var isUnusedValue = false; - if (calleeDecl is null) - { - Visit(callExpr.Callee); - VisitArgs(callExpr); - } - else if (calleeDecl is FieldDecl) + if (callExpr.Type.CanonicalType.Kind != CXTypeKind.CXType_Void) + { + isUnusedValue = IsPrevContextStmt(out _, out _) + || IsPrevContextStmt(out _, out _); + + if ((calleeDecl is FunctionDecl functionDecl) && (functionDecl.Name is "memcpy" or "memset")) { - Visit(callExpr.Callee); - VisitArgs(callExpr); + isUnusedValue = false; } - else if (calleeDecl is FunctionDecl functionDecl) + } + + if (isUnusedValue) + { + outputBuilder.Write("_ = "); + } + + if (calleeDecl is null) + { + Visit(callExpr.Callee); + VisitArgs(callExpr); + } + else if (calleeDecl is FieldDecl) + { + Visit(callExpr.Callee); + VisitArgs(callExpr); + } + else if (calleeDecl is FunctionDecl functionDecl) + { + switch (functionDecl.Name) { - switch (functionDecl.Name) + case "memcpy": { - case "memcpy": - { - outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); - outputBuilder.Write("Unsafe.CopyBlockUnaligned"); - VisitArgs(callExpr); - break; - } + outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); + outputBuilder.Write("Unsafe.CopyBlockUnaligned"); + VisitArgs(callExpr); + break; + } - case "memset": - { - NamedDecl namedDecl = null; + case "memset": + { + NamedDecl namedDecl = null; - if (callExpr.NumArgs == 3) + if (callExpr.NumArgs == 3) + { + if (IsStmtAsWritten(callExpr.Args[1], out var integerLiteralExpr, removeParens: true) && (integerLiteralExpr.Value == 0) && + IsStmtAsWritten(callExpr.Args[2], out var unaryExprOrTypeTraitExpr, removeParens: true) && (unaryExprOrTypeTraitExpr.Kind == CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf)) { - if (IsStmtAsWritten(callExpr.Args[1], out var integerLiteralExpr, removeParens: true) && (integerLiteralExpr.Value == 0) && - IsStmtAsWritten(callExpr.Args[2], out var unaryExprOrTypeTraitExpr, removeParens: true) && (unaryExprOrTypeTraitExpr.Kind == CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf)) - { - var typeOfArgument = unaryExprOrTypeTraitExpr.TypeOfArgument.CanonicalType; - var expr = callExpr.Args[0]; + var typeOfArgument = unaryExprOrTypeTraitExpr.TypeOfArgument.CanonicalType; + var expr = callExpr.Args[0]; - if (IsStmtAsWritten(expr, out var unaryOperator, removeParens: true) && (unaryOperator.Opcode == CX_UnaryOperatorKind.CX_UO_AddrOf)) - { - expr = unaryOperator.SubExpr; - } - - if (IsStmtAsWritten(expr, out var declRefExpr, removeParens: true) && (typeOfArgument == declRefExpr.Type.CanonicalType)) - { - namedDecl = declRefExpr.Decl; - } - else if (IsStmtAsWritten(expr, out var memberExpr, removeParens: true) && (typeOfArgument == memberExpr.Type.CanonicalType)) - { - namedDecl = memberExpr.MemberDecl; - } + if (IsStmtAsWritten(expr, out var unaryOperator, removeParens: true) && (unaryOperator.Opcode == CX_UnaryOperatorKind.CX_UO_AddrOf)) + { + expr = unaryOperator.SubExpr; } - if (namedDecl is not null) + if (IsStmtAsWritten(expr, out var declRefExpr, removeParens: true) && (typeOfArgument == declRefExpr.Type.CanonicalType)) { - outputBuilder.Write(GetRemappedCursorName(namedDecl)); - outputBuilder.Write(" = default"); - break; + namedDecl = declRefExpr.Decl; + } + else if (IsStmtAsWritten(expr, out var memberExpr, removeParens: true) && (typeOfArgument == memberExpr.Type.CanonicalType)) + { + namedDecl = memberExpr.MemberDecl; } } - outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); - outputBuilder.Write("Unsafe.InitBlockUnaligned"); - VisitArgs(callExpr); - break; - } - - case "wcslen": - { - if (_config.GenerateCompatibleCode) + if (namedDecl is not null) { - goto default; + outputBuilder.Write(GetRemappedCursorName(namedDecl)); + outputBuilder.Write(" = default"); + break; } - - outputBuilder.AddUsingDirective("System.Runtime.InteropServices"); - outputBuilder.Write("MemoryMarshal.CreateReadOnlySpanFromNullTerminated"); - - VisitArgs(callExpr); - outputBuilder.Write(".Length"); - break; } - default: + outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); + outputBuilder.Write("Unsafe.InitBlockUnaligned"); + VisitArgs(callExpr); + break; + } + + case "wcslen": + { + if (_config.GenerateCompatibleCode) { - Visit(callExpr.Callee); - VisitArgs(callExpr); - break; + goto default; } + + outputBuilder.AddUsingDirective("System.Runtime.InteropServices"); + outputBuilder.Write("MemoryMarshal.CreateReadOnlySpanFromNullTerminated"); + + VisitArgs(callExpr); + outputBuilder.Write(".Length"); + break; + } + + default: + { + Visit(callExpr.Callee); + VisitArgs(callExpr); + break; } } - else if (calleeDecl is ParmVarDecl) - { - Visit(callExpr.Callee); - VisitArgs(callExpr); - } - else if (calleeDecl is VarDecl) - { - Visit(callExpr.Callee); - VisitArgs(callExpr); - } - else + } + else if (calleeDecl is ParmVarDecl) + { + Visit(callExpr.Callee); + VisitArgs(callExpr); + } + else if (calleeDecl is VarDecl) + { + Visit(callExpr.Callee); + VisitArgs(callExpr); + } + else + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported callee declaration: '{calleeDecl?.DeclKindName}'. Generated bindings may be incomplete.", calleeDecl); + } + + void VisitArgs(CallExpr callExpr) + { + var callExprType = (callExpr.Callee is MemberExpr memberExpr) + ? memberExpr.MemberDecl.Type.CanonicalType + : callExpr.Callee.Type.CanonicalType; + + if (callExprType is PointerType pointerType) { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported callee declaration: '{calleeDecl?.DeclKindName}'. Generated bindings may be incomplete.", calleeDecl); + callExprType = pointerType.PointeeType.CanonicalType; } - void VisitArgs(CallExpr callExpr) + outputBuilder.Write('('); + + var args = callExpr.Args; + var needsComma = false; + + for (var i = 0; i < args.Count; i++) { - var callExprType = (callExpr.Callee is MemberExpr memberExpr) - ? memberExpr.MemberDecl.Type.CanonicalType - : callExpr.Callee.Type.CanonicalType; + var arg = args[i]; - if (callExprType is PointerType pointerType) + if (needsComma && (arg is not CXXDefaultArgExpr)) { - callExprType = pointerType.PointeeType.CanonicalType; + outputBuilder.Write(", "); } - outputBuilder.Write('('); - - var args = callExpr.Args; - var needsComma = false; - - for (var i = 0; i < args.Count; i++) + if (callExprType is FunctionProtoType functionProtoType) { - var arg = args[i]; - - if (needsComma && (arg is not CXXDefaultArgExpr)) - { - outputBuilder.Write(", "); - } + var paramType = functionProtoType.ParamTypes[i].CanonicalType; - if (callExprType is FunctionProtoType functionProtoType) + if (paramType is ReferenceType) { - var paramType = functionProtoType.ParamTypes[i].CanonicalType; - - if (paramType is ReferenceType) + if (IsStmtAsWritten(arg, out var unaryOperator, removeParens: true) && (unaryOperator.Opcode == CX_UnaryOperatorKind.CX_UO_Deref)) { - if (IsStmtAsWritten(arg, out var unaryOperator, removeParens: true) && (unaryOperator.Opcode == CX_UnaryOperatorKind.CX_UO_Deref)) - { - arg = unaryOperator.SubExpr; - } - else if (IsStmtAsWritten(arg, out var declRefExpr, removeParens: true)) - { - if (declRefExpr.Decl.Type.CanonicalType is not ReferenceType and not PointerType) - { - outputBuilder.Write('&'); - } - } - else if (arg.Type.CanonicalType is not ReferenceType and not PointerType) + arg = unaryOperator.SubExpr; + } + else if (IsStmtAsWritten(arg, out var declRefExpr, removeParens: true)) + { + if (declRefExpr.Decl.Type.CanonicalType is not ReferenceType and not PointerType) { outputBuilder.Write('&'); } } + else if (arg.Type.CanonicalType is not ReferenceType and not PointerType) + { + outputBuilder.Write('&'); + } } + } - Visit(arg); + Visit(arg); - if (arg is not CXXDefaultArgExpr) - { - needsComma = true; - } + if (arg is not CXXDefaultArgExpr) + { + needsComma = true; } - - outputBuilder.Write(')'); } - StopCSharpCode(); + outputBuilder.Write(')'); } - private void VisitCaseStmt(CaseStmt caseStmt) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("case "); - Visit(caseStmt.LHS); - outputBuilder.WriteLine(':'); + StopCSharpCode(); + } - if (caseStmt.SubStmt is SwitchCase) - { - outputBuilder.WriteIndentation(); - Visit(caseStmt.SubStmt); - } - else - { - VisitBody(caseStmt.SubStmt); - } + private void VisitCaseStmt(CaseStmt caseStmt) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("case "); + Visit(caseStmt.LHS); + outputBuilder.WriteLine(':'); - StopCSharpCode(); + if (caseStmt.SubStmt is SwitchCase) + { + outputBuilder.WriteIndentation(); + Visit(caseStmt.SubStmt); + } + else + { + VisitBody(caseStmt.SubStmt); } - private void VisitCharacterLiteral(CharacterLiteral characterLiteral) + StopCSharpCode(); + } + + private void VisitCharacterLiteral(CharacterLiteral characterLiteral) + { + var outputBuilder = StartCSharpCode(); + switch (characterLiteral.Kind) { - var outputBuilder = StartCSharpCode(); - switch (characterLiteral.Kind) + case CX_CharacterKind.CX_CLK_Ascii: + case CX_CharacterKind.CX_CLK_UTF8: { - case CX_CharacterKind.CX_CLK_Ascii: - case CX_CharacterKind.CX_CLK_UTF8: + if (characterLiteral.Value > ushort.MaxValue) { - if (characterLiteral.Value > ushort.MaxValue) + outputBuilder.Write("0x"); + outputBuilder.Write(characterLiteral.Value.ToString("X8")); + } + else if (characterLiteral.Value > byte.MaxValue) + { + outputBuilder.Write("0x"); + outputBuilder.Write(characterLiteral.Value.ToString("X4")); + } + else + { + var castType = ""; + var targetTypeName = ""; + var targetTypeNumBits = 0; + + if (IsPrevContextStmt(out var implicitCastExpr, out _)) { - outputBuilder.Write("0x"); - outputBuilder.Write(characterLiteral.Value.ToString("X8")); + // C# characters are effectively `ushort` while C defaults to "char" which is + // most typically `sbyte`. Due to this we need to insert a correct implicit + // cast to ensure things are correctly handled here. + + var targetType = implicitCastExpr.Type; + targetTypeName = GetRemappedTypeName(implicitCastExpr, context: null, targetType, out _, skipUsing: true); + targetTypeNumBits = targetType.Handle.NumBits; } - else if (characterLiteral.Value > byte.MaxValue) + else if (PreviousContext.Cursor is VarDecl varDecl) { - outputBuilder.Write("0x"); - outputBuilder.Write(characterLiteral.Value.ToString("X4")); + var targetType = varDecl.Type; + targetTypeName = GetRemappedTypeName(varDecl, context: null, targetType, out _, skipUsing: true); + targetTypeNumBits = targetType.Handle.NumBits; } - else - { - var castType = ""; - var targetTypeName = ""; - var targetTypeNumBits = 0; - - if (IsPrevContextStmt(out var implicitCastExpr, out _)) - { - // C# characters are effectively `ushort` while C defaults to "char" which is - // most typically `sbyte`. Due to this we need to insert a correct implicit - // cast to ensure things are correctly handled here. - var targetType = implicitCastExpr.Type; - targetTypeName = GetRemappedTypeName(implicitCastExpr, context: null, targetType, out _, skipUsing: true); - targetTypeNumBits = targetType.Handle.NumBits; - } - else if (PreviousContext.Cursor is VarDecl varDecl) + if (targetTypeName != "") + { + if (!IsUnsigned(targetTypeName)) { - var targetType = varDecl.Type; - targetTypeName = GetRemappedTypeName(varDecl, context: null, targetType, out _, skipUsing: true); - targetTypeNumBits = targetType.Handle.NumBits; + castType = "sbyte"; } - - if (targetTypeName != "") + else if (targetTypeNumBits < 16) { - if (!IsUnsigned(targetTypeName)) - { - castType = "sbyte"; - } - else if (targetTypeNumBits < 16) - { - castType = "byte"; - } - - outputBuilder.Write('('); - outputBuilder.Write(castType); - outputBuilder.Write(")("); + castType = "byte"; } - outputBuilder.Write('\''); - outputBuilder.Write(EscapeCharacter((char)characterLiteral.Value)); - outputBuilder.Write('\''); - - if (castType != "") - { - outputBuilder.Write(')'); - } + outputBuilder.Write('('); + outputBuilder.Write(castType); + outputBuilder.Write(")("); } - break; - } - case CX_CharacterKind.CX_CLK_Wide: - { - if (_config.GenerateUnixTypes) + outputBuilder.Write('\''); + outputBuilder.Write(EscapeCharacter((char)characterLiteral.Value)); + outputBuilder.Write('\''); + + if (castType != "") { - goto default; + outputBuilder.Write(')'); } - - goto case CX_CharacterKind.CX_CLK_UTF16; } + break; + } - case CX_CharacterKind.CX_CLK_UTF16: + case CX_CharacterKind.CX_CLK_Wide: + { + if (_config.GenerateUnixTypes) { - if (characterLiteral.Value > ushort.MaxValue) - { - outputBuilder.Write("0x"); - outputBuilder.Write(characterLiteral.Value.ToString("X8")); - } - else - { - outputBuilder.Write('\''); - outputBuilder.Write(EscapeCharacter((char)characterLiteral.Value)); - outputBuilder.Write('\''); - } - break; + goto default; } - case CX_CharacterKind.CX_CLK_UTF32: + goto case CX_CharacterKind.CX_CLK_UTF16; + } + + case CX_CharacterKind.CX_CLK_UTF16: + { + if (characterLiteral.Value > ushort.MaxValue) { outputBuilder.Write("0x"); outputBuilder.Write(characterLiteral.Value.ToString("X8")); - break; } - - default: + else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported character literal kind: '{characterLiteral.Kind}'. Generated bindings may be incomplete.", characterLiteral); - break; + outputBuilder.Write('\''); + outputBuilder.Write(EscapeCharacter((char)characterLiteral.Value)); + outputBuilder.Write('\''); } + break; + } + + case CX_CharacterKind.CX_CLK_UTF32: + { + outputBuilder.Write("0x"); + outputBuilder.Write(characterLiteral.Value.ToString("X8")); + break; } - StopCSharpCode(); + default: + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported character literal kind: '{characterLiteral.Kind}'. Generated bindings may be incomplete.", characterLiteral); + break; + } } - private void VisitCompoundStmt(CompoundStmt compoundStmt) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.WriteBlockStart(); + StopCSharpCode(); + } - VisitStmts(compoundStmt.Body); + private void VisitCompoundStmt(CompoundStmt compoundStmt) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.WriteBlockStart(); - outputBuilder.WriteSemicolonIfNeeded(); - outputBuilder.WriteNewlineIfNeeded(); - outputBuilder.WriteBlockEnd(); - StopCSharpCode(); - } + VisitStmts(compoundStmt.Body); - private void VisitConditionalOperator(ConditionalOperator conditionalOperator) - { - var outputBuilder = StartCSharpCode(); - Visit(conditionalOperator.Cond); - outputBuilder.Write(" ? "); - Visit(conditionalOperator.TrueExpr); - outputBuilder.Write(" : "); - Visit(conditionalOperator.FalseExpr); - StopCSharpCode(); - } + outputBuilder.WriteSemicolonIfNeeded(); + outputBuilder.WriteNewlineIfNeeded(); + outputBuilder.WriteBlockEnd(); + StopCSharpCode(); + } - private void VisitContinueStmt(ContinueStmt continueStmt) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("continue"); - StopCSharpCode(); - } + private void VisitConditionalOperator(ConditionalOperator conditionalOperator) + { + var outputBuilder = StartCSharpCode(); + Visit(conditionalOperator.Cond); + outputBuilder.Write(" ? "); + Visit(conditionalOperator.TrueExpr); + outputBuilder.Write(" : "); + Visit(conditionalOperator.FalseExpr); + StopCSharpCode(); + } - private void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr cxxBoolLiteralExpr) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write(cxxBoolLiteralExpr.ValueString); - StopCSharpCode(); - } + private void VisitContinueStmt(ContinueStmt continueStmt) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("continue"); + StopCSharpCode(); + } - private void VisitCXXConstCastExpr(CXXConstCastExpr cxxConstCastExpr) => - // C# doesn't have a concept of const pointers so - // ignore rather than adding a cast from T* to T* + private void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr cxxBoolLiteralExpr) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write(cxxBoolLiteralExpr.ValueString); + StopCSharpCode(); + } - Visit(cxxConstCastExpr.SubExprAsWritten); + private void VisitCXXConstCastExpr(CXXConstCastExpr cxxConstCastExpr) => + // C# doesn't have a concept of const pointers so + // ignore rather than adding a cast from T* to T* - private void VisitCXXConstructExpr(CXXConstructExpr cxxConstructExpr) - { - var outputBuilder = StartCSharpCode(); - var isCopyOrMoveConstructor = cxxConstructExpr.Constructor is { IsCopyConstructor: true } or { IsMoveConstructor: true }; - var isUnmanagedConstant = false; + Visit(cxxConstCastExpr.SubExprAsWritten); - if (IsPrevContextDecl(out _, out var userData)) - { - isUnmanagedConstant = (userData is ValueDesc valueDesc) && (valueDesc.Kind == ValueKind.Unmanaged) && valueDesc.IsConstant && valueDesc.IsCopy; - } + private void VisitCXXConstructExpr(CXXConstructExpr cxxConstructExpr) + { + var outputBuilder = StartCSharpCode(); + var isCopyOrMoveConstructor = cxxConstructExpr.Constructor is { IsCopyConstructor: true } or { IsMoveConstructor: true }; + var isUnmanagedConstant = false; - if (!isCopyOrMoveConstructor) - { - outputBuilder.Write("new "); + if (IsPrevContextDecl(out _, out var userData)) + { + isUnmanagedConstant = (userData is ValueDesc valueDesc) && (valueDesc.Kind == ValueKind.Unmanaged) && valueDesc.IsConstant && valueDesc.IsCopy; + } - var constructorName = GetRemappedCursorName(cxxConstructExpr.Constructor); + if (!isCopyOrMoveConstructor) + { + outputBuilder.Write("new "); - outputBuilder.Write(constructorName); - outputBuilder.Write('('); - } + var constructorName = GetRemappedCursorName(cxxConstructExpr.Constructor); + + outputBuilder.Write(constructorName); + outputBuilder.Write('('); + } - var args = cxxConstructExpr.Args; + var args = cxxConstructExpr.Args; - if (args.Count != 0) + if (args.Count != 0) + { + if (isUnmanagedConstant) { - if (isUnmanagedConstant) - { - outputBuilder.Write("ref "); - } - Visit(args[0]); - - for (var i = 1; i < args.Count; i++) - { - outputBuilder.Write(", "); - Visit(args[i]); - } + outputBuilder.Write("ref "); } + Visit(args[0]); - if (!isCopyOrMoveConstructor) + for (var i = 1; i < args.Count; i++) { - outputBuilder.Write(')'); + outputBuilder.Write(", "); + Visit(args[i]); } - - StopCSharpCode(); } - private static void VisitCXXDefaultArgExpr(CXXDefaultArgExpr cxxDefaultArgExpr) + if (!isCopyOrMoveConstructor) { - // Nothing to handle as these just represent optional parameters that - // aren't properly defined + outputBuilder.Write(')'); } - private void VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr cxxDependentScopeMemberExpr) - { - var outputBuilder = StartCSharpCode(); - if (!cxxDependentScopeMemberExpr.IsImplicitAccess) - { - Visit(cxxDependentScopeMemberExpr.Base); + StopCSharpCode(); + } - var type = cxxDependentScopeMemberExpr.Base is CXXThisExpr - ? null - : cxxDependentScopeMemberExpr.Base is DeclRefExpr declRefExpr - ? declRefExpr.Decl.Type.CanonicalType - : cxxDependentScopeMemberExpr.Base.Type.CanonicalType; + private static void VisitCXXDefaultArgExpr(CXXDefaultArgExpr cxxDefaultArgExpr) + { + // Nothing to handle as these just represent optional parameters that + // aren't properly defined + } - if (type is not null and (PointerType or ReferenceType)) - { - outputBuilder.Write("->"); - } - else - { - outputBuilder.Write('.'); - } - } + private void VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr cxxDependentScopeMemberExpr) + { + var outputBuilder = StartCSharpCode(); + if (!cxxDependentScopeMemberExpr.IsImplicitAccess) + { + Visit(cxxDependentScopeMemberExpr.Base); - outputBuilder.Write(GetRemappedName(cxxDependentScopeMemberExpr.MemberName, cxxDependentScopeMemberExpr, tryRemapOperatorName: false, out _, skipUsing: true)); - StopCSharpCode(); - } + var type = cxxDependentScopeMemberExpr.Base is CXXThisExpr + ? null + : cxxDependentScopeMemberExpr.Base is DeclRefExpr declRefExpr + ? declRefExpr.Decl.Type.CanonicalType + : cxxDependentScopeMemberExpr.Base.Type.CanonicalType; - private void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr cxxFunctionalCastExpr) - { - if (cxxFunctionalCastExpr.SubExpr is CXXConstructExpr cxxConstructExpr) + if (type is not null and (PointerType or ReferenceType)) { - Visit(cxxConstructExpr); + outputBuilder.Write("->"); } else { - VisitExplicitCastExpr(cxxFunctionalCastExpr); + outputBuilder.Write('.'); } } - private void VisitCXXNewExpr(CXXNewExpr cxxNewExpr) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("cxx_new<"); + outputBuilder.Write(GetRemappedName(cxxDependentScopeMemberExpr.MemberName, cxxDependentScopeMemberExpr, tryRemapOperatorName: false, out _, skipUsing: true)); + StopCSharpCode(); + } + private void VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr cxxFunctionalCastExpr) + { + if (cxxFunctionalCastExpr.SubExpr is CXXConstructExpr cxxConstructExpr) + { + Visit(cxxConstructExpr); + } + else + { + VisitExplicitCastExpr(cxxFunctionalCastExpr); + } + } - var allocatedTypeName = GetRemappedTypeName(cxxNewExpr, null, cxxNewExpr.AllocatedType, out _); - outputBuilder.Write(allocatedTypeName); + private void VisitCXXNewExpr(CXXNewExpr cxxNewExpr) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("cxx_new<"); - outputBuilder.Write(">(sizeof("); - outputBuilder.Write(allocatedTypeName); - outputBuilder.Write("))"); - if (cxxNewExpr.ConstructExpr is not null) - { - outputBuilder.WriteSemicolon(); - outputBuilder.WriteNewline(); + var allocatedTypeName = GetRemappedTypeName(cxxNewExpr, null, cxxNewExpr.AllocatedType, out _); + outputBuilder.Write(allocatedTypeName); - outputBuilder.WriteIndented(" = "); - VisitCXXConstructExpr(cxxNewExpr.ConstructExpr); - } - StopCSharpCode(); - } + outputBuilder.Write(">(sizeof("); + outputBuilder.Write(allocatedTypeName); + outputBuilder.Write("))"); - private void VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr cxxNullPtrLiteralExpr) + if (cxxNewExpr.ConstructExpr is not null) { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("null"); - StopCSharpCode(); + outputBuilder.WriteSemicolon(); + outputBuilder.WriteNewline(); + + outputBuilder.WriteIndented(" = "); + VisitCXXConstructExpr(cxxNewExpr.ConstructExpr); } + StopCSharpCode(); + } + + private void VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr cxxNullPtrLiteralExpr) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("null"); + StopCSharpCode(); + } + + private void VisitCXXOperatorCallExpr(CXXOperatorCallExpr cxxOperatorCallExpr) + { + var outputBuilder = StartCSharpCode(); + var calleeDecl = cxxOperatorCallExpr.CalleeDecl; - private void VisitCXXOperatorCallExpr(CXXOperatorCallExpr cxxOperatorCallExpr) + if (calleeDecl is FunctionDecl functionDecl) { - var outputBuilder = StartCSharpCode(); - var calleeDecl = cxxOperatorCallExpr.CalleeDecl; + var functionDeclName = GetCursorName(functionDecl); + var args = cxxOperatorCallExpr.Args; - if (calleeDecl is FunctionDecl functionDecl) + if (functionDecl.DeclContext is CXXRecordDecl) { - var functionDeclName = GetCursorName(functionDecl); - var args = cxxOperatorCallExpr.Args; - - if (functionDecl.DeclContext is CXXRecordDecl) - { - Visit(cxxOperatorCallExpr.Args[0]); - outputBuilder.Write('.'); - } + Visit(cxxOperatorCallExpr.Args[0]); + outputBuilder.Write('.'); + } - if (IsEnumOperator(functionDecl, functionDeclName)) + if (IsEnumOperator(functionDecl, functionDeclName)) + { + switch (functionDeclName) { - switch (functionDeclName) + case "operator|": + case "operator|=": + case "operator&": + case "operator&=": + case "operator^": + case "operator^=": { - case "operator|": - case "operator|=": - case "operator&": - case "operator&=": - case "operator^": - case "operator^=": - { - Visit(args[0]); - outputBuilder.Write(' '); - outputBuilder.Write(functionDeclName[8..]); - outputBuilder.Write(' '); - Visit(args[1]); - StopCSharpCode(); - return; - } + Visit(args[0]); + outputBuilder.Write(' '); + outputBuilder.Write(functionDeclName[8..]); + outputBuilder.Write(' '); + Visit(args[1]); + StopCSharpCode(); + return; + } - case "operator~": - { - outputBuilder.Write(functionDeclName[8..]); - Visit(args[0]); - StopCSharpCode(); - return; - } + case "operator~": + { + outputBuilder.Write(functionDeclName[8..]); + Visit(args[0]); + StopCSharpCode(); + return; + } - default: - { - break; - } + default: + { + break; } } + } - var name = GetRemappedCursorName(functionDecl); - outputBuilder.Write(name); + var name = GetRemappedCursorName(functionDecl); + outputBuilder.Write(name); - outputBuilder.Write('('); - var firstIndex = (functionDecl.DeclContext is CXXRecordDecl) ? 1 : 0; + outputBuilder.Write('('); + var firstIndex = (functionDecl.DeclContext is CXXRecordDecl) ? 1 : 0; - if (args.Count > firstIndex) - { - Visit(args[firstIndex]); + if (args.Count > firstIndex) + { + Visit(args[firstIndex]); - for (var i = firstIndex + 1; i < args.Count; i++) - { - outputBuilder.Write(", "); - Visit(args[i]); - } + for (var i = firstIndex + 1; i < args.Count; i++) + { + outputBuilder.Write(", "); + Visit(args[i]); } - - outputBuilder.Write(')'); - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported callee declaration: '{calleeDecl.DeclKindName}'. Generated bindings may be incomplete.", calleeDecl); } - StopCSharpCode(); + outputBuilder.Write(')'); } - - private static void VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr cxxPseudoDestructorExpr) + else { - // Nothing to generate for pseudo destructors + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported callee declaration: '{calleeDecl.DeclKindName}'. Generated bindings may be incomplete.", calleeDecl); } - private void VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr cxxTemporaryObjectExpr) => VisitCXXConstructExpr(cxxTemporaryObjectExpr); + StopCSharpCode(); + } - private void VisitCXXThisExpr(CXXThisExpr cxxThisExpr) - { - StartCSharpCode().Write("this"); - StopCSharpCode(); - } + private static void VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr cxxPseudoDestructorExpr) + { + // Nothing to generate for pseudo destructors + } - private void VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr cxxUnresolvedConstructExpr) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("new "); + private void VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr cxxTemporaryObjectExpr) => VisitCXXConstructExpr(cxxTemporaryObjectExpr); - var constructorName = GetRemappedTypeName(cxxUnresolvedConstructExpr, null, cxxUnresolvedConstructExpr.TypeAsWritten, out _); - outputBuilder.Write(constructorName); + private void VisitCXXThisExpr(CXXThisExpr cxxThisExpr) + { + StartCSharpCode().Write("this"); + StopCSharpCode(); + } - outputBuilder.Write('('); - var args = cxxUnresolvedConstructExpr.Args; + private void VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr cxxUnresolvedConstructExpr) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("new "); - if (args.Count != 0) - { - Visit(args[0]); + var constructorName = GetRemappedTypeName(cxxUnresolvedConstructExpr, null, cxxUnresolvedConstructExpr.TypeAsWritten, out _); + outputBuilder.Write(constructorName); - for (var i = 1; i < args.Count; i++) - { - outputBuilder.Write(", "); - Visit(args[i]); - } - } + outputBuilder.Write('('); + var args = cxxUnresolvedConstructExpr.Args; - outputBuilder.Write(')'); - StopCSharpCode(); + if (args.Count != 0) + { + Visit(args[0]); + + for (var i = 1; i < args.Count; i++) + { + outputBuilder.Write(", "); + Visit(args[i]); + } } - private void VisitCXXUuidofExpr(CXXUuidofExpr cxxUuidofExpr) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("typeof("); + outputBuilder.Write(')'); + StopCSharpCode(); + } - var type = cxxUuidofExpr.IsTypeOperand ? cxxUuidofExpr.TypeOperand : cxxUuidofExpr.ExprOperand.Type; - var typeName = GetRemappedTypeName(cxxUuidofExpr, context: null, type, out _); - outputBuilder.Write(typeName); + private void VisitCXXUuidofExpr(CXXUuidofExpr cxxUuidofExpr) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("typeof("); - outputBuilder.Write(").GUID"); + var type = cxxUuidofExpr.IsTypeOperand ? cxxUuidofExpr.TypeOperand : cxxUuidofExpr.ExprOperand.Type; + var typeName = GetRemappedTypeName(cxxUuidofExpr, context: null, type, out _); + outputBuilder.Write(typeName); - StopCSharpCode(); - } + outputBuilder.Write(").GUID"); - private void VisitDeclRefExpr(DeclRefExpr declRefExpr) - { - var outputBuilder = StartCSharpCode(); + StopCSharpCode(); + } + + private void VisitDeclRefExpr(DeclRefExpr declRefExpr) + { + var outputBuilder = StartCSharpCode(); - var name = GetRemappedCursorName(declRefExpr.Decl, out _, skipUsing: true); - var escapedName = EscapeName(name); + var name = GetRemappedCursorName(declRefExpr.Decl, out _, skipUsing: true); + var escapedName = EscapeName(name); - if (declRefExpr.Decl is EnumConstantDecl enumConstantDecl) + if (declRefExpr.Decl is EnumConstantDecl enumConstantDecl) + { + if ((declRefExpr.DeclContext != enumConstantDecl.DeclContext) && (enumConstantDecl.DeclContext is NamedDecl namedDecl)) { - if ((declRefExpr.DeclContext != enumConstantDecl.DeclContext) && (enumConstantDecl.DeclContext is NamedDecl namedDecl)) - { - var enumName = GetRemappedCursorName(namedDecl, out _, skipUsing: true); + var enumName = GetRemappedCursorName(namedDecl, out _, skipUsing: true); - if (!_config.DontUseUsingStaticsForEnums) + if (!_config.DontUseUsingStaticsForEnums) + { + if (enumName.StartsWith("__AnonymousEnum_")) { - if (enumName.StartsWith("__AnonymousEnum_")) - { - var className = GetClass(enumName); + var className = GetClass(enumName); - if ((outputBuilder.Name != className) && (namedDecl.Parent is not TagDecl)) - { - outputBuilder.AddUsingDirective($"static {GetNamespace(enumName, namedDecl)}.{className}"); - } - } - else + if ((outputBuilder.Name != className) && (namedDecl.Parent is not TagDecl)) { - outputBuilder.AddUsingDirective($"static {GetNamespace(enumName, namedDecl)}.{enumName}"); + outputBuilder.AddUsingDirective($"static {GetNamespace(enumName, namedDecl)}.{className}"); } } else { - outputBuilder.Write(enumName); - outputBuilder.Write("."); - } - } - } - else - { - if (TryGetClass(name, out var className)) - { - if (TryGetNamespace(className, out var namespaceName) && ((_currentNamespace != namespaceName) || (_currentClass != className))) - { - outputBuilder.AddUsingDirective($"static {namespaceName}.{className}"); + outputBuilder.AddUsingDirective($"static {GetNamespace(enumName, namedDecl)}.{enumName}"); } } - else if (TryGetNamespace(name, out var namespaceName) && (_currentNamespace != namespaceName)) - { - outputBuilder.AddUsingDirective(namespaceName); - } - - if (declRefExpr.Decl is FunctionDecl) + else { - escapedName = EscapeAndStripName(name); + outputBuilder.Write(enumName); + outputBuilder.Write("."); } } - - outputBuilder.Write(escapedName); - - StopCSharpCode(); } - - private void VisitDeclStmt(DeclStmt declStmt) + else { - var outputBuilder = StartCSharpCode(); - if (declStmt.IsSingleDecl) - { - Visit(declStmt.SingleDecl); - } - else + if (TryGetClass(name, out var className)) { - Visit(declStmt.Decls.First()); - - foreach (var decl in declStmt.Decls.Skip(1)) + if (TryGetNamespace(className, out var namespaceName) && ((_currentNamespace != namespaceName) || (_currentClass != className))) { - outputBuilder.Write(", "); - Visit(decl); + outputBuilder.AddUsingDirective($"static {namespaceName}.{className}"); } } + else if (TryGetNamespace(name, out var namespaceName) && (_currentNamespace != namespaceName)) + { + outputBuilder.AddUsingDirective(namespaceName); + } - StopCSharpCode(); + if (declRefExpr.Decl is FunctionDecl) + { + escapedName = EscapeAndStripName(name); + } } - private void VisitDefaultStmt(DefaultStmt defaultStmt) + outputBuilder.Write(escapedName); + + StopCSharpCode(); + } + + private void VisitDeclStmt(DeclStmt declStmt) + { + var outputBuilder = StartCSharpCode(); + if (declStmt.IsSingleDecl) { - var outputBuilder = StartCSharpCode(); - outputBuilder.WriteLine("default:"); + Visit(declStmt.SingleDecl); + } + else + { + Visit(declStmt.Decls.First()); - if (defaultStmt.SubStmt is SwitchCase) - { - outputBuilder.WriteIndentation(); - Visit(defaultStmt.SubStmt); - } - else + foreach (var decl in declStmt.Decls.Skip(1)) { - VisitBody(defaultStmt.SubStmt); + outputBuilder.Write(", "); + Visit(decl); } - - StopCSharpCode(); } - private void VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr dependentScopeDeclRefExpr) - { - var outputBuilder = StartCSharpCode(); + StopCSharpCode(); + } - var name = GetRemappedName(dependentScopeDeclRefExpr.DeclName, dependentScopeDeclRefExpr, tryRemapOperatorName: true, out _, skipUsing: true); - outputBuilder.Write(EscapeName(name)); + private void VisitDefaultStmt(DefaultStmt defaultStmt) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.WriteLine("default:"); - StopCSharpCode(); + if (defaultStmt.SubStmt is SwitchCase) + { + outputBuilder.WriteIndentation(); + Visit(defaultStmt.SubStmt); } - - private void VisitDoStmt(DoStmt doStmt) + else { - var outputBuilder = StartCSharpCode(); - outputBuilder.WriteLine("do"); + VisitBody(defaultStmt.SubStmt); + } - VisitBody(doStmt.Body); + StopCSharpCode(); + } - outputBuilder.WriteIndented("while ("); + private void VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr dependentScopeDeclRefExpr) + { + var outputBuilder = StartCSharpCode(); - Visit(doStmt.Cond); + var name = GetRemappedName(dependentScopeDeclRefExpr.DeclName, dependentScopeDeclRefExpr, tryRemapOperatorName: true, out _, skipUsing: true); + outputBuilder.Write(EscapeName(name)); - outputBuilder.Write(')'); - outputBuilder.WriteSemicolon(); - outputBuilder.WriteNewline(); + StopCSharpCode(); + } - outputBuilder.NeedsNewline = true; + private void VisitDoStmt(DoStmt doStmt) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.WriteLine("do"); - StopCSharpCode(); - } + VisitBody(doStmt.Body); - private void VisitExplicitCastExpr(ExplicitCastExpr explicitCastExpr) - { - var outputBuilder = StartCSharpCode(); + outputBuilder.WriteIndented("while ("); - if (IsPrevContextDecl(out _, out _) && explicitCastExpr.Type is EnumType enumType) - { - outputBuilder.Write('('); - var enumUnderlyingTypeName = GetRemappedTypeName(explicitCastExpr, context: null, enumType.Decl.IntegerType, out _); - outputBuilder.Write(enumUnderlyingTypeName); - outputBuilder.Write(')'); - } + Visit(doStmt.Cond); - var type = explicitCastExpr.Type; - var typeName = GetRemappedTypeName(explicitCastExpr, context: null, type, out _); + outputBuilder.Write(')'); + outputBuilder.WriteSemicolon(); + outputBuilder.WriteNewline(); - if (IsPrevContextDecl(out var varDecl, out _)) - { - var cursorName = GetCursorName(varDecl); + outputBuilder.NeedsNewline = true; - if (cursorName.StartsWith("ClangSharpMacro_") && _config.WithTransparentStructs.TryGetValue(typeName, out var transparentStruct)) - { - if (!IsPrimitiveValue(type) || IsConstant(typeName, varDecl.Init)) - { - typeName = transparentStruct.Name; - } - } - } + StopCSharpCode(); + } - if (typeName == "IntPtr") - { - typeName = "nint"; - } - else if (typeName == "UIntPtr") - { - typeName = "nuint"; - } + private void VisitExplicitCastExpr(ExplicitCastExpr explicitCastExpr) + { + var outputBuilder = StartCSharpCode(); + if (IsPrevContextDecl(out _, out _) && explicitCastExpr.Type is EnumType enumType) + { outputBuilder.Write('('); - outputBuilder.Write(typeName); + var enumUnderlyingTypeName = GetRemappedTypeName(explicitCastExpr, context: null, enumType.Decl.IntegerType, out _); + outputBuilder.Write(enumUnderlyingTypeName); outputBuilder.Write(')'); - - ParenthesizeStmt(explicitCastExpr.SubExprAsWritten); - - StopCSharpCode(); } - private void VisitExprWithCleanups(ExprWithCleanups exprWithCleanups) - { - Visit(exprWithCleanups.SubExpr); - Visit(exprWithCleanups.Objects); - } + var type = explicitCastExpr.Type; + var typeName = GetRemappedTypeName(explicitCastExpr, context: null, type, out _); - private void VisitFloatingLiteral(FloatingLiteral floatingLiteral) + if (IsPrevContextDecl(out var varDecl, out _)) { - var outputBuilder = StartCSharpCode(); - if (floatingLiteral.ValueString.EndsWith(".f")) - { - outputBuilder.Write(floatingLiteral.ValueString[0..^1]); - outputBuilder.Write("0f"); - } - else - { - outputBuilder.Write(floatingLiteral.ValueString); + var cursorName = GetCursorName(varDecl); - if (floatingLiteral.ValueString.EndsWith(".")) + if (cursorName.StartsWith("ClangSharpMacro_") && _config.WithTransparentStructs.TryGetValue(typeName, out var transparentStruct)) + { + if (!IsPrimitiveValue(type) || IsConstant(typeName, varDecl.Init)) { - outputBuilder.Write('0'); + typeName = transparentStruct.Name; } } - - StopCSharpCode(); } - private void VisitForStmt(ForStmt forStmt) + if (typeName == "IntPtr") { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("for ("); + typeName = "nint"; + } + else if (typeName == "UIntPtr") + { + typeName = "nuint"; + } - if (forStmt.ConditionVariableDeclStmt != null) - { - Visit(forStmt.ConditionVariableDeclStmt); - } - else if (forStmt.Init != null) - { - Visit(forStmt.Init); - } + outputBuilder.Write('('); + outputBuilder.Write(typeName); + outputBuilder.Write(')'); - outputBuilder.WriteSemicolon(); + ParenthesizeStmt(explicitCastExpr.SubExprAsWritten); - if (forStmt.Cond != null) - { - outputBuilder.Write(' '); - Visit(forStmt.Cond); - } + StopCSharpCode(); + } - outputBuilder.WriteSemicolon(); + private void VisitExprWithCleanups(ExprWithCleanups exprWithCleanups) + { + Visit(exprWithCleanups.SubExpr); + Visit(exprWithCleanups.Objects); + } - if (forStmt.Inc != null) - { - outputBuilder.Write(' '); - Visit(forStmt.Inc); + private void VisitFloatingLiteral(FloatingLiteral floatingLiteral) + { + var outputBuilder = StartCSharpCode(); + if (floatingLiteral.ValueString.EndsWith(".f")) + { + outputBuilder.Write(floatingLiteral.ValueString[0..^1]); + outputBuilder.Write("0f"); + } + else + { + outputBuilder.Write(floatingLiteral.ValueString); + + if (floatingLiteral.ValueString.EndsWith(".")) + { + outputBuilder.Write('0'); } + } + + StopCSharpCode(); + } + + private void VisitForStmt(ForStmt forStmt) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("for ("); + + if (forStmt.ConditionVariableDeclStmt != null) + { + Visit(forStmt.ConditionVariableDeclStmt); + } + else if (forStmt.Init != null) + { + Visit(forStmt.Init); + } - outputBuilder.WriteLine(')'); + outputBuilder.WriteSemicolon(); - VisitBody(forStmt.Body); - StopCSharpCode(); + if (forStmt.Cond != null) + { + outputBuilder.Write(' '); + Visit(forStmt.Cond); } - private void VisitGotoStmt(GotoStmt gotoStmt) + outputBuilder.WriteSemicolon(); + + if (forStmt.Inc != null) { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("goto "); - outputBuilder.Write(gotoStmt.Label.Name); - StopCSharpCode(); + outputBuilder.Write(' '); + Visit(forStmt.Inc); } - private void VisitIfStmt(IfStmt ifStmt) + outputBuilder.WriteLine(')'); + + VisitBody(forStmt.Body); + StopCSharpCode(); + } + + private void VisitGotoStmt(GotoStmt gotoStmt) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("goto "); + outputBuilder.Write(gotoStmt.Label.Name); + StopCSharpCode(); + } + + private void VisitIfStmt(IfStmt ifStmt) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write("if ("); + + Visit(ifStmt.Cond); + + outputBuilder.WriteLine(')'); + + VisitBody(ifStmt.Then); + + if (ifStmt.Else != null) { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write("if ("); + outputBuilder.WriteIndented("else"); - Visit(ifStmt.Cond); + if (ifStmt.Else is IfStmt) + { + outputBuilder.Write(' '); + Visit(ifStmt.Else); + } + else + { + outputBuilder.WriteNewline(); + VisitBody(ifStmt.Else); + } + } - outputBuilder.WriteLine(')'); + StopCSharpCode(); + } - VisitBody(ifStmt.Then); + private void VisitImplicitCastExpr(ImplicitCastExpr implicitCastExpr) + { + var outputBuilder = StartCSharpCode(); + var subExpr = implicitCastExpr.SubExprAsWritten; - if (ifStmt.Else != null) + switch (implicitCastExpr.CastKind) + { + case CX_CastKind.CX_CK_NullToPointer: { - outputBuilder.WriteIndented("else"); + outputBuilder.Write("null"); + break; + } - if (ifStmt.Else is IfStmt) + case CX_CastKind.CX_CK_PointerToBoolean: + { + if ((subExpr is UnaryOperator unaryOperator) && (unaryOperator.Opcode == CX_UnaryOperatorKind.CX_UO_LNot)) { - outputBuilder.Write(' '); - Visit(ifStmt.Else); + Visit(subExpr); } else { - outputBuilder.WriteNewline(); - VisitBody(ifStmt.Else); + ParenthesizeStmt(subExpr); + outputBuilder.Write(" != null"); } + break; } - StopCSharpCode(); - } - - private void VisitImplicitCastExpr(ImplicitCastExpr implicitCastExpr) - { - var outputBuilder = StartCSharpCode(); - var subExpr = implicitCastExpr.SubExprAsWritten; - - switch (implicitCastExpr.CastKind) + case CX_CastKind.CX_CK_IntegralCast: { - case CX_CastKind.CX_CK_NullToPointer: + if (subExpr.Type.CanonicalType.Kind == CXTypeKind.CXType_Bool) { - outputBuilder.Write("null"); - break; + goto case CX_CastKind.CX_CK_BooleanToSignedIntegral; } - - case CX_CastKind.CX_CK_PointerToBoolean: + else { - if ((subExpr is UnaryOperator unaryOperator) && (unaryOperator.Opcode == CX_UnaryOperatorKind.CX_UO_LNot)) - { - Visit(subExpr); - } - else - { - ParenthesizeStmt(subExpr); - outputBuilder.Write(" != null"); - } - break; + goto default; } + } - case CX_CastKind.CX_CK_IntegralCast: + case CX_CastKind.CX_CK_IntegralToBoolean: + { + if ((subExpr is UnaryOperator unaryOperator) && (unaryOperator.Opcode == CX_UnaryOperatorKind.CX_UO_LNot)) { - if (subExpr.Type.CanonicalType.Kind == CXTypeKind.CXType_Bool) - { - goto case CX_CastKind.CX_CK_BooleanToSignedIntegral; - } - else - { - goto default; - } + Visit(subExpr); } - - case CX_CastKind.CX_CK_IntegralToBoolean: + else { - if ((subExpr is UnaryOperator unaryOperator) && (unaryOperator.Opcode == CX_UnaryOperatorKind.CX_UO_LNot)) - { - Visit(subExpr); - } - else - { - ParenthesizeStmt(subExpr); - outputBuilder.Write(" != 0"); - } - break; + ParenthesizeStmt(subExpr); + outputBuilder.Write(" != 0"); } + break; + } + + case CX_CastKind.CX_CK_BooleanToSignedIntegral: + { + var needsCast = implicitCastExpr.Type.Handle.SizeOf < 4; - case CX_CastKind.CX_CK_BooleanToSignedIntegral: + if (needsCast) { - var needsCast = implicitCastExpr.Type.Handle.SizeOf < 4; + outputBuilder.Write("(byte)("); + } - if (needsCast) - { - outputBuilder.Write("(byte)("); - } + ParenthesizeStmt(subExpr); + outputBuilder.Write(" ? 1 : 0"); - ParenthesizeStmt(subExpr); - outputBuilder.Write(" ? 1 : 0"); + if (needsCast) + { + outputBuilder.Write(')'); + } - if (needsCast) - { - outputBuilder.Write(')'); - } + break; + } - break; + default: + { + if (IsStmtAsWritten(subExpr, out var declRefExpr, removeParens: true) && (declRefExpr.Decl is EnumConstantDecl enumConstantDecl)) + { + ForEnumConstantDecl(implicitCastExpr, enumConstantDecl); } - - default: + else { - if (IsStmtAsWritten(subExpr, out var declRefExpr, removeParens: true) && (declRefExpr.Decl is EnumConstantDecl enumConstantDecl)) - { - ForEnumConstantDecl(implicitCastExpr, enumConstantDecl); - } - else - { - VisitStmt(subExpr); - } - break; + VisitStmt(subExpr); } + break; } + } + + void ForEnumConstantDecl(ImplicitCastExpr implicitCastExpr, EnumConstantDecl enumConstantDecl) + { + var subExpr = implicitCastExpr.SubExprAsWritten; - void ForEnumConstantDecl(ImplicitCastExpr implicitCastExpr, EnumConstantDecl enumConstantDecl) + if (IsPrevContextStmt(out var binaryOperator, out _) && ((binaryOperator.Opcode == CX_BinaryOperatorKind.CX_BO_EQ) || (binaryOperator.Opcode == CX_BinaryOperatorKind.CX_BO_NE))) { - var subExpr = implicitCastExpr.SubExprAsWritten; + Visit(subExpr); + subExpr = null; + } + else if (IsPrevContextStmt(out _, out _)) + { + var previousContext = _context.Last.Previous; - if (IsPrevContextStmt(out var binaryOperator, out _) && ((binaryOperator.Opcode == CX_BinaryOperatorKind.CX_BO_EQ) || (binaryOperator.Opcode == CX_BinaryOperatorKind.CX_BO_NE))) + do { - Visit(subExpr); - subExpr = null; + previousContext = previousContext.Previous; } - else if (IsPrevContextStmt(out _, out _)) - { - var previousContext = _context.Last.Previous; - - do - { - previousContext = previousContext.Previous; - } - while (previousContext.Value.Cursor is ParenExpr or ImplicitCastExpr or CaseStmt or CompoundStmt); + while (previousContext.Value.Cursor is ParenExpr or ImplicitCastExpr or CaseStmt or CompoundStmt); - var value = previousContext.Value; + var value = previousContext.Value; - if ((value.Cursor is SwitchStmt switchStmt) && (switchStmt.Cond.IgnoreImplicit.Type.CanonicalType is EnumType)) - { - Visit(subExpr); - subExpr = null; - } - } - else if (IsPrevContextDecl(out _, out _)) + if ((value.Cursor is SwitchStmt switchStmt) && (switchStmt.Cond.IgnoreImplicit.Type.CanonicalType is EnumType)) { Visit(subExpr); subExpr = null; } + } + else if (IsPrevContextDecl(out _, out _)) + { + Visit(subExpr); + subExpr = null; + } - if (subExpr is not null) - { - var type = implicitCastExpr.Type; + if (subExpr is not null) + { + var type = implicitCastExpr.Type; - var typeName = GetRemappedTypeName(implicitCastExpr, context: null, type, out _); + var typeName = GetRemappedTypeName(implicitCastExpr, context: null, type, out _); - outputBuilder.Write('('); - outputBuilder.Write(typeName); - outputBuilder.Write(')'); + outputBuilder.Write('('); + outputBuilder.Write(typeName); + outputBuilder.Write(')'); - ParenthesizeStmt(subExpr); - } + ParenthesizeStmt(subExpr); } - - StopCSharpCode(); } - private void VisitImplicitValueInitExpr(ImplicitValueInitExpr implicitValueInitExpr) - { - StartCSharpCode().Write("default"); - StopCSharpCode(); - } + StopCSharpCode(); + } + + private void VisitImplicitValueInitExpr(ImplicitValueInitExpr implicitValueInitExpr) + { + StartCSharpCode().Write("default"); + StopCSharpCode(); + } - private void VisitInitListExpr(InitListExpr initListExpr) + private void VisitInitListExpr(InitListExpr initListExpr) + { + var outputBuilder = StartCSharpCode(); + ForType(initListExpr, initListExpr.Type); + StopCSharpCode(); + + long CalculateRootSize(InitListExpr initListExpr, ArrayType arrayType, bool isUnmanagedConstant) { - var outputBuilder = StartCSharpCode(); - ForType(initListExpr, initListExpr.Type); - StopCSharpCode(); + long rootSize = -1; - long CalculateRootSize(InitListExpr initListExpr, ArrayType arrayType, bool isUnmanagedConstant) + do { - long rootSize = -1; - - do + if (!isUnmanagedConstant) { - if (!isUnmanagedConstant) - { - outputBuilder.Write('['); - } - long size = -1; + outputBuilder.Write('['); + } + long size = -1; - if (arrayType is ConstantArrayType or IncompleteArrayType) - { - size = Math.Max((arrayType as ConstantArrayType)?.Size ?? 0, 1); - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported array type kind: '{initListExpr.Type.KindSpelling}'. Generated bindings may be incomplete.", initListExpr); - } + if (arrayType is ConstantArrayType or IncompleteArrayType) + { + size = Math.Max((arrayType as ConstantArrayType)?.Size ?? 0, 1); + } + else + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported array type kind: '{initListExpr.Type.KindSpelling}'. Generated bindings may be incomplete.", initListExpr); + } - if (rootSize == -1) + if (rootSize == -1) + { + if (size != -1) { - if (size != -1) - { - rootSize = size; + rootSize = size; - if (!isUnmanagedConstant) - { - outputBuilder.Write(size); - } - } - else + if (!isUnmanagedConstant) { - rootSize = 0; + outputBuilder.Write(size); } } - - if (!isUnmanagedConstant) + else { - outputBuilder.Write(']'); + rootSize = 0; } - arrayType = arrayType.ElementType as ArrayType; } - while (arrayType is not null); - return rootSize; + if (!isUnmanagedConstant) + { + outputBuilder.Write(']'); + } + arrayType = arrayType.ElementType as ArrayType; } + while (arrayType is not null); - void ForArrayType(InitListExpr initListExpr, ArrayType arrayType) - { - var type = initListExpr.Type; - var typeName = GetRemappedTypeName(initListExpr, context: null, type, out _); - var isUnmanagedConstant = false; - var escapedName = ""; + return rootSize; + } - if (IsPrevContextDecl(out _, out var userData)) - { - if (userData is ValueDesc valueDesc) - { - escapedName = valueDesc.EscapedName; - isUnmanagedConstant = (valueDesc.Kind == ValueKind.Unmanaged) && valueDesc.IsConstant; - } - } + void ForArrayType(InitListExpr initListExpr, ArrayType arrayType) + { + var type = initListExpr.Type; + var typeName = GetRemappedTypeName(initListExpr, context: null, type, out _); + var isUnmanagedConstant = false; + var escapedName = ""; - if (_config.GenerateUnmanagedConstants && isUnmanagedConstant && (_testStmtOutputBuilder is null)) + if (IsPrevContextDecl(out _, out var userData)) + { + if (userData is ValueDesc valueDesc) { - HandleUnmanagedConstant(initListExpr, arrayType, typeName, escapedName); + escapedName = valueDesc.EscapedName; + isUnmanagedConstant = (valueDesc.Kind == ValueKind.Unmanaged) && valueDesc.IsConstant; } - else - { - outputBuilder.Write("new "); - outputBuilder.Write(typeName); + } - var rootSize = CalculateRootSize(initListExpr, arrayType, isUnmanagedConstant: false); + if (_config.GenerateUnmanagedConstants && isUnmanagedConstant && (_testStmtOutputBuilder is null)) + { + HandleUnmanagedConstant(initListExpr, arrayType, typeName, escapedName); + } + else + { + outputBuilder.Write("new "); + outputBuilder.Write(typeName); - outputBuilder.WriteNewline(); - outputBuilder.WriteBlockStart(); + var rootSize = CalculateRootSize(initListExpr, arrayType, isUnmanagedConstant: false); - for (var i = 0; i < initListExpr.Inits.Count; i++) - { - outputBuilder.WriteIndentation(); - Visit(initListExpr.Inits[i]); - outputBuilder.WriteLine(','); - } + outputBuilder.WriteNewline(); + outputBuilder.WriteBlockStart(); - for (var i = initListExpr.Inits.Count; i < rootSize; i++) - { - outputBuilder.WriteIndentedLine("default,"); - } + for (var i = 0; i < initListExpr.Inits.Count; i++) + { + outputBuilder.WriteIndentation(); + Visit(initListExpr.Inits[i]); + outputBuilder.WriteLine(','); + } - outputBuilder.DecreaseIndentation(); - outputBuilder.WriteIndented('}'); - outputBuilder.NeedsSemicolon = true; + for (var i = initListExpr.Inits.Count; i < rootSize; i++) + { + outputBuilder.WriteIndentedLine("default,"); } + + outputBuilder.DecreaseIndentation(); + outputBuilder.WriteIndented('}'); + outputBuilder.NeedsSemicolon = true; } + } + + void ForBuiltinType(InitListExpr initListExpr, BuiltinType builtinType) + { + var inits = initListExpr.Inits; - void ForBuiltinType(InitListExpr initListExpr, BuiltinType builtinType) + if (inits.Count == 1) { - var inits = initListExpr.Inits; + Visit(inits[0]); + } + else + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported init list expression count for builtin type: '{inits.Count}'. Generated bindings may be incomplete.", initListExpr); + } - if (inits.Count == 1) - { - Visit(inits[0]); - } - else + outputBuilder.NeedsSemicolon = true; + } + + void ForRecordType(InitListExpr initListExpr, RecordType recordType) + { + var type = initListExpr.Type; + var typeName = GetRemappedTypeName(initListExpr, context: null, type, out _); + var isUnmanagedConstant = false; + var escapedName = ""; + + if (IsPrevContextDecl(out _, out var userData)) + { + if (userData is ValueDesc valueDesc) { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported init list expression count for builtin type: '{inits.Count}'. Generated bindings may be incomplete.", initListExpr); + escapedName = valueDesc.EscapedName; + isUnmanagedConstant = (valueDesc.Kind == ValueKind.Unmanaged) && valueDesc.IsConstant; } - - outputBuilder.NeedsSemicolon = true; } - void ForRecordType(InitListExpr initListExpr, RecordType recordType) + if (_config.GenerateUnmanagedConstants && isUnmanagedConstant && (_testStmtOutputBuilder is null)) { - var type = initListExpr.Type; - var typeName = GetRemappedTypeName(initListExpr, context: null, type, out _); - var isUnmanagedConstant = false; - var escapedName = ""; + HandleUnmanagedConstant(initListExpr, recordType, typeName, escapedName); + } + else + { + outputBuilder.Write("new "); + outputBuilder.Write(typeName); - if (IsPrevContextDecl(out _, out var userData)) + if (typeName == "Guid") { - if (userData is ValueDesc valueDesc) + outputBuilder.Write('('); + + Visit(initListExpr.Inits[0]); + + outputBuilder.Write(", "); + Visit(initListExpr.Inits[1]); + + outputBuilder.Write(", "); + Visit(initListExpr.Inits[2]); + + initListExpr = (InitListExpr)initListExpr.Inits[3]; + + for (var i = 0; i < initListExpr.Inits.Count; i++) { - escapedName = valueDesc.EscapedName; - isUnmanagedConstant = (valueDesc.Kind == ValueKind.Unmanaged) && valueDesc.IsConstant; + outputBuilder.Write(", "); + Visit(initListExpr.Inits[i]); } - } - if (_config.GenerateUnmanagedConstants && isUnmanagedConstant && (_testStmtOutputBuilder is null)) - { - HandleUnmanagedConstant(initListExpr, recordType, typeName, escapedName); + outputBuilder.Write(')'); } else { - outputBuilder.Write("new "); - outputBuilder.Write(typeName); + outputBuilder.WriteNewline(); + outputBuilder.WriteBlockStart(); - if (typeName == "Guid") - { - outputBuilder.Write('('); + var decl = recordType.Decl; - Visit(initListExpr.Inits[0]); - - outputBuilder.Write(", "); - Visit(initListExpr.Inits[1]); - - outputBuilder.Write(", "); - Visit(initListExpr.Inits[2]); - - initListExpr = (InitListExpr)initListExpr.Inits[3]; + for (var i = 0; i < initListExpr.Inits.Count; i++) + { + var init = initListExpr.Inits[i]; - for (var i = 0; i < initListExpr.Inits.Count; i++) + if (init is ImplicitValueInitExpr) { - outputBuilder.Write(", "); - Visit(initListExpr.Inits[i]); + continue; } - outputBuilder.Write(')'); - } - else - { - outputBuilder.WriteNewline(); - outputBuilder.WriteBlockStart(); + var fieldName = GetRemappedCursorName(decl.Fields[i]); - var decl = recordType.Decl; + outputBuilder.WriteIndented(fieldName); + outputBuilder.Write(" = "); + Visit(init); + outputBuilder.WriteLine(','); + } - for (var i = 0; i < initListExpr.Inits.Count; i++) - { - var init = initListExpr.Inits[i]; + outputBuilder.DecreaseIndentation(); + outputBuilder.WriteIndented('}'); + outputBuilder.NeedsSemicolon = true; + } + } + } - if (init is ImplicitValueInitExpr) - { - continue; - } + void ForPointerType(InitListExpr initListExpr, PointerType pointerType) + { + var inits = initListExpr.Inits; - var fieldName = GetRemappedCursorName(decl.Fields[i]); + if (inits.Count == 1) + { + Visit(inits[0]); + } + else + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported init list expression count for pointer type: '{inits.Count}'. Generated bindings may be incomplete.", initListExpr); + } - outputBuilder.WriteIndented(fieldName); - outputBuilder.Write(" = "); - Visit(init); - outputBuilder.WriteLine(','); - } + outputBuilder.NeedsSemicolon = true; + } - outputBuilder.DecreaseIndentation(); - outputBuilder.WriteIndented('}'); - outputBuilder.NeedsSemicolon = true; - } - } + void ForType(InitListExpr initListExpr, Type type) + { + if (type is ArrayType arrayType) + { + ForArrayType(initListExpr, arrayType); } - - void ForPointerType(InitListExpr initListExpr, PointerType pointerType) + else if (type is BuiltinType builtinType) + { + ForBuiltinType(initListExpr, builtinType); + } + else if (type is ElaboratedType elaboratedType) + { + ForType(initListExpr, elaboratedType.NamedType); + } + else if (type is PointerType pointerType) + { + ForPointerType(initListExpr, pointerType); + } + else if (type is RecordType recordType) + { + ForRecordType(initListExpr, recordType); + } + else if (type is TypedefType typedefType) + { + ForType(initListExpr, typedefType.Decl.UnderlyingType); + } + else { - var inits = initListExpr.Inits; + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported init list expression type: '{type.TypeClassSpelling}'. Generated bindings may be incomplete.", initListExpr); + } + } - if (inits.Count == 1) - { - Visit(inits[0]); - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported init list expression count for pointer type: '{inits.Count}'. Generated bindings may be incomplete.", initListExpr); - } + void HandleInitListExpr(InitListExpr initListExpr) + { + var inits = initListExpr.Inits; - outputBuilder.NeedsSemicolon = true; + if (initListExpr.NumInits > 0) + { + HandleInitStmt(inits[0]); } - void ForType(InitListExpr initListExpr, Type type) + for (var i = 1; i < inits.Count; i++) { - if (type is ArrayType arrayType) - { - ForArrayType(initListExpr, arrayType); - } - else if (type is BuiltinType builtinType) - { - ForBuiltinType(initListExpr, builtinType); - } - else if (type is ElaboratedType elaboratedType) - { - ForType(initListExpr, elaboratedType.NamedType); - } - else if (type is PointerType pointerType) - { - ForPointerType(initListExpr, pointerType); - } - else if (type is RecordType recordType) - { - ForRecordType(initListExpr, recordType); - } - else if (type is TypedefType typedefType) - { - ForType(initListExpr, typedefType.Decl.UnderlyingType); - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported init list expression type: '{type.TypeClassSpelling}'. Generated bindings may be incomplete.", initListExpr); - } + outputBuilder.WriteLine(','); + HandleInitStmt(inits[i]); } + } - void HandleInitListExpr(InitListExpr initListExpr) + void HandleInitStmt(Stmt init) + { + if (init is InitListExpr nestedInitListExpr) { - var inits = initListExpr.Inits; - - if (initListExpr.NumInits > 0) - { - HandleInitStmt(inits[0]); - } - - for (var i = 1; i < inits.Count; i++) - { - outputBuilder.WriteLine(','); - HandleInitStmt(inits[i]); - } + HandleInitListExpr(nestedInitListExpr); } - - void HandleInitStmt(Stmt init) + else { - if (init is InitListExpr nestedInitListExpr) - { - HandleInitListExpr(nestedInitListExpr); - } - else - { - outputBuilder.WriteIndentation(); + outputBuilder.WriteIndentation(); - var evaluation = init.Handle.Evaluate; + var evaluation = init.Handle.Evaluate; - switch (evaluation.Kind) + switch (evaluation.Kind) + { + case CXEvalResultKind.CXEval_Int: { - case CXEvalResultKind.CXEval_Int: - { - var sizeInChars = ((Expr)init).Type.Handle.SizeOf; - outputBuilder.WriteValueAsBytes(evaluation.AsUnsigned, (int)sizeInChars); - break; - } - - case CXEvalResultKind.CXEval_Float: - { - var sizeInChars = ((Expr)init).Type.Handle.SizeOf; + var sizeInChars = ((Expr)init).Type.Handle.SizeOf; + outputBuilder.WriteValueAsBytes(evaluation.AsUnsigned, (int)sizeInChars); + break; + } - if (sizeInChars == 4) - { - var value = (float)evaluation.AsDouble; - outputBuilder.WriteValueAsBytes(Unsafe.As(ref value), (int)sizeInChars); - } - else if (sizeInChars == 8) - { - var value = evaluation.AsDouble; - outputBuilder.WriteValueAsBytes(Unsafe.As(ref value), (int)sizeInChars); - } - else - { - goto default; - } + case CXEvalResultKind.CXEval_Float: + { + var sizeInChars = ((Expr)init).Type.Handle.SizeOf; - break; + if (sizeInChars == 4) + { + var value = (float)evaluation.AsDouble; + outputBuilder.WriteValueAsBytes(Unsafe.As(ref value), (int)sizeInChars); } - - case CXEvalResultKind.CXEval_StrLiteral: + else if (sizeInChars == 8) { - outputBuilder.Write('"'); - outputBuilder.Write(evaluation.AsStr); - outputBuilder.Write('"'); - break; + var value = evaluation.AsDouble; + outputBuilder.WriteValueAsBytes(Unsafe.As(ref value), (int)sizeInChars); } - - default: + else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported evaluation kind: '{evaluation.Kind}'. Generated bindings may be incomplete.", init); - break; + goto default; } + + break; + } + + case CXEvalResultKind.CXEval_StrLiteral: + { + outputBuilder.Write('"'); + outputBuilder.Write(evaluation.AsStr); + outputBuilder.Write('"'); + break; + } + + default: + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported evaluation kind: '{evaluation.Kind}'. Generated bindings may be incomplete.", init); + break; } } } + } - void HandleUnmanagedConstant(InitListExpr initListExpr, Type type, string typeName, string escapedName) - { - outputBuilder.AddUsingDirective("System"); - outputBuilder.AddUsingDirective("System.Diagnostics"); - outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); - outputBuilder.AddUsingDirective("System.Runtime.InteropServices"); + void HandleUnmanagedConstant(InitListExpr initListExpr, Type type, string typeName, string escapedName) + { + outputBuilder.AddUsingDirective("System"); + outputBuilder.AddUsingDirective("System.Diagnostics"); + outputBuilder.AddUsingDirective("System.Runtime.CompilerServices"); + outputBuilder.AddUsingDirective("System.Runtime.InteropServices"); - outputBuilder.WriteIndentedLine("ReadOnlySpan data = new byte[] {"); - outputBuilder.IncreaseIndentation(); + outputBuilder.WriteIndentedLine("ReadOnlySpan data = new byte[] {"); + outputBuilder.IncreaseIndentation(); - HandleInitListExpr(initListExpr); + HandleInitListExpr(initListExpr); - outputBuilder.WriteNewline(); - outputBuilder.DecreaseIndentation(); - outputBuilder.WriteIndentedLine("};"); + outputBuilder.WriteNewline(); + outputBuilder.DecreaseIndentation(); + outputBuilder.WriteIndentedLine("};"); - outputBuilder.NeedsNewline = true; - long rootSize = -1; + outputBuilder.NeedsNewline = true; + long rootSize = -1; - if (type is ArrayType arrayType) - { - rootSize = CalculateRootSize(initListExpr, arrayType, isUnmanagedConstant: true); + if (type is ArrayType arrayType) + { + rootSize = CalculateRootSize(initListExpr, arrayType, isUnmanagedConstant: true); - outputBuilder.WriteIndented("Debug.Assert(data.Length == (Unsafe.SizeOf<"); - outputBuilder.Write(typeName); - outputBuilder.Write(">() * "); - outputBuilder.Write(rootSize); - outputBuilder.WriteLine("));"); + outputBuilder.WriteIndented("Debug.Assert(data.Length == (Unsafe.SizeOf<"); + outputBuilder.Write(typeName); + outputBuilder.Write(">() * "); + outputBuilder.Write(rootSize); + outputBuilder.WriteLine("));"); - outputBuilder.WriteIndented("return MemoryMarshal.CreateReadOnlySpan<"); - outputBuilder.Write(typeName); - outputBuilder.Write(">("); - } - else - { - outputBuilder.WriteIndented("Debug.Assert(data.Length == Unsafe.SizeOf<"); - outputBuilder.Write(typeName); - outputBuilder.WriteLine(">());"); + outputBuilder.WriteIndented("return MemoryMarshal.CreateReadOnlySpan<"); + outputBuilder.Write(typeName); + outputBuilder.Write(">("); + } + else + { + outputBuilder.WriteIndented("Debug.Assert(data.Length == Unsafe.SizeOf<"); + outputBuilder.Write(typeName); + outputBuilder.WriteLine(">());"); - outputBuilder.WriteIndented("return "); - } + outputBuilder.WriteIndented("return "); + } - outputBuilder.Write("ref Unsafe.As(ref MemoryMarshal.GetReference(data))"); + outputBuilder.Write("ref Unsafe.As(ref MemoryMarshal.GetReference(data))"); - if (rootSize != -1) - { - outputBuilder.Write(", "); - outputBuilder.Write(rootSize); - outputBuilder.Write(")"); - } - outputBuilder.WriteLine(';'); + if (rootSize != -1) + { + outputBuilder.Write(", "); + outputBuilder.Write(rootSize); + outputBuilder.Write(")"); + } + outputBuilder.WriteLine(';'); - StartUsingOutputBuilder(_outputBuilder.Name, includeTestOutput: true); + StartUsingOutputBuilder(_outputBuilder.Name, includeTestOutput: true); - if (_testOutputBuilder != null) + if (_testOutputBuilder != null) + { + _testOutputBuilder.AddUsingDirective("System"); + _testOutputBuilder.AddUsingDirective($"static {GetNamespace(_outputBuilder.Name)}.{_outputBuilder.Name}"); + + _testOutputBuilder.WriteIndented("/// Validates that the value of the property is correct."); + + WithTestAttribute(); + + _testOutputBuilder.WriteIndented("public static void "); + _testOutputBuilder.Write(escapedName); + _testOutputBuilder.WriteLine("Test()"); + _testOutputBuilder.WriteBlockStart(); + + if (typeName == "Guid") { - _testOutputBuilder.AddUsingDirective("System"); - _testOutputBuilder.AddUsingDirective($"static {GetNamespace(_outputBuilder.Name)}.{_outputBuilder.Name}"); + if (_config.GenerateTestsNUnit) + { + _testOutputBuilder.WriteIndented("Assert.That"); + } + else if (_config.GenerateTestsXUnit) + { + _testOutputBuilder.WriteIndented("Assert.Equal"); + } - _testOutputBuilder.WriteIndented("/// Validates that the value of the property is correct."); + _testOutputBuilder.Write(", "); - WithTestAttribute(); + if (_config.GenerateTestsNUnit) + { + _testOutputBuilder.Write("Is.EqualTo("); + } - _testOutputBuilder.WriteIndented("public static void "); - _testOutputBuilder.Write(escapedName); - _testOutputBuilder.WriteLine("Test()"); - _testOutputBuilder.WriteBlockStart(); + _testOutputBuilder.Write("new Guid("); + + var tmp = _outputBuilder; + _outputBuilder = _testOutputBuilder; + { + Visit(initListExpr.Inits[0]); + + _testOutputBuilder.Write(", "); + Visit(initListExpr.Inits[1]); + + _testOutputBuilder.Write(", "); + Visit(initListExpr.Inits[2]); + + initListExpr = (InitListExpr)initListExpr.Inits[3]; + + for (var i = 0; i < initListExpr.Inits.Count; i++) + { + _testOutputBuilder.Write(", "); + Visit(initListExpr.Inits[i]); + } + } + _outputBuilder = tmp; + + _testOutputBuilder.Write(")"); + + if (_config.GenerateTestsNUnit) + { + _testOutputBuilder.Write(')'); + } + + _testOutputBuilder.Write(')'); + _testOutputBuilder.WriteSemicolon(); + _testOutputBuilder.WriteNewline(); + } + else if (type is RecordType recordType) + { + var decl = recordType.Decl; - if (typeName == "Guid") + for (var i = 0; i < initListExpr.Inits.Count; i++) { + var init = initListExpr.Inits[i]; + var fieldName = GetRemappedCursorName(decl.Fields[i]); + if (_config.GenerateTestsNUnit) { _testOutputBuilder.WriteIndented("Assert.That"); @@ -1552,6 +1613,8 @@ void HandleUnmanagedConstant(InitListExpr initListExpr, Type type, string typeNa _testOutputBuilder.Write('('); _testOutputBuilder.Write(escapedName); + _testOutputBuilder.Write('.'); + _testOutputBuilder.Write(fieldName); _testOutputBuilder.Write(", "); if (_config.GenerateTestsNUnit) @@ -1559,31 +1622,13 @@ void HandleUnmanagedConstant(InitListExpr initListExpr, Type type, string typeNa _testOutputBuilder.Write("Is.EqualTo("); } - _testOutputBuilder.Write("new Guid("); - var tmp = _outputBuilder; _outputBuilder = _testOutputBuilder; { - Visit(initListExpr.Inits[0]); - - _testOutputBuilder.Write(", "); - Visit(initListExpr.Inits[1]); - - _testOutputBuilder.Write(", "); - Visit(initListExpr.Inits[2]); - - initListExpr = (InitListExpr)initListExpr.Inits[3]; - - for (var i = 0; i < initListExpr.Inits.Count; i++) - { - _testOutputBuilder.Write(", "); - Visit(initListExpr.Inits[i]); - } + Visit(init); } _outputBuilder = tmp; - _testOutputBuilder.Write(")"); - if (_config.GenerateTestsNUnit) { _testOutputBuilder.Write(')'); @@ -1593,1269 +1638,1223 @@ void HandleUnmanagedConstant(InitListExpr initListExpr, Type type, string typeNa _testOutputBuilder.WriteSemicolon(); _testOutputBuilder.WriteNewline(); } - else if (type is RecordType recordType) - { - var decl = recordType.Decl; - - for (var i = 0; i < initListExpr.Inits.Count; i++) - { - var init = initListExpr.Inits[i]; - var fieldName = GetRemappedCursorName(decl.Fields[i]); - - if (_config.GenerateTestsNUnit) - { - _testOutputBuilder.WriteIndented("Assert.That"); - } - else if (_config.GenerateTestsXUnit) - { - _testOutputBuilder.WriteIndented("Assert.Equal"); - } - - _testOutputBuilder.Write('('); - _testOutputBuilder.Write(escapedName); - _testOutputBuilder.Write('.'); - _testOutputBuilder.Write(fieldName); - _testOutputBuilder.Write(", "); - - if (_config.GenerateTestsNUnit) - { - _testOutputBuilder.Write("Is.EqualTo("); - } - - var tmp = _outputBuilder; - _outputBuilder = _testOutputBuilder; - { - Visit(init); - } - _outputBuilder = tmp; - - if (_config.GenerateTestsNUnit) - { - _testOutputBuilder.Write(')'); - } - - _testOutputBuilder.Write(')'); - _testOutputBuilder.WriteSemicolon(); - _testOutputBuilder.WriteNewline(); - } - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported type kind: '{type.Kind}'. Generated bindings may be incomplete.", initListExpr); - } - - _testOutputBuilder.WriteBlockEnd(); - _testOutputBuilder.NeedsNewline = true; + } + else + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported type kind: '{type.Kind}'. Generated bindings may be incomplete.", initListExpr); } - StopUsingOutputBuilder(); + _testOutputBuilder.WriteBlockEnd(); + _testOutputBuilder.NeedsNewline = true; } + + StopUsingOutputBuilder(); } + } - private void VisitIntegerLiteral(IntegerLiteral integerLiteral) - { - var valueString = integerLiteral.ValueString; + private void VisitIntegerLiteral(IntegerLiteral integerLiteral) + { + var valueString = integerLiteral.ValueString; - if (valueString.EndsWith("l", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^1]; - } - else if (valueString.EndsWith("ui8", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^3]; - } - else if (valueString.EndsWith("i8", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^2]; - } - else if (valueString.EndsWith("ui16", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^4]; - } - else if (valueString.EndsWith("i16", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^3]; - } - else if (valueString.EndsWith("i32", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^3]; - } - else if (valueString.EndsWith("i64", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^3] + "L"; - } - - if (valueString.EndsWith("ul", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^2] + "UL"; - } - else if (valueString.EndsWith("l", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^1] + "L"; - } - else if (valueString.EndsWith("u", StringComparison.OrdinalIgnoreCase)) - { - valueString = valueString[0..^1] + "U"; - } - - var outputBuilder = StartCSharpCode(); - outputBuilder.Write(valueString); - StopCSharpCode(); + if (valueString.EndsWith("l", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^1]; + } + else if (valueString.EndsWith("ui8", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^3]; + } + else if (valueString.EndsWith("i8", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^2]; + } + else if (valueString.EndsWith("ui16", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^4]; + } + else if (valueString.EndsWith("i16", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^3]; + } + else if (valueString.EndsWith("i32", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^3]; + } + else if (valueString.EndsWith("i64", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^3] + "L"; } - private void VisitLabelStmt(LabelStmt labelStmt) + if (valueString.EndsWith("ul", StringComparison.OrdinalIgnoreCase)) { - var outputBuilder = StartCSharpCode(); + valueString = valueString[0..^2] + "UL"; + } + else if (valueString.EndsWith("l", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^1] + "L"; + } + else if (valueString.EndsWith("u", StringComparison.OrdinalIgnoreCase)) + { + valueString = valueString[0..^1] + "U"; + } + + var outputBuilder = StartCSharpCode(); + outputBuilder.Write(valueString); + StopCSharpCode(); + } - outputBuilder.Write(labelStmt.Decl.Name); - outputBuilder.WriteLine(':'); + private void VisitLabelStmt(LabelStmt labelStmt) + { + var outputBuilder = StartCSharpCode(); - outputBuilder.WriteIndentation(); - Visit(labelStmt.SubStmt); - StopCSharpCode(); - } + outputBuilder.Write(labelStmt.Decl.Name); + outputBuilder.WriteLine(':'); - private void VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr materializeTemporaryExpr) => Visit(materializeTemporaryExpr.SubExpr); + outputBuilder.WriteIndentation(); + Visit(labelStmt.SubStmt); + StopCSharpCode(); + } - private void VisitMemberExpr(MemberExpr memberExpr) - { - var outputBuilder = StartCSharpCode(); - var baseFieldName = ""; + private void VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr materializeTemporaryExpr) => Visit(materializeTemporaryExpr.SubExpr); - if ((memberExpr.Base is ImplicitCastExpr implicitCastExpr) && (implicitCastExpr.CastKind is CX_CastKind.CX_CK_DerivedToBase or CX_CastKind.CX_CK_DerivedToBaseMemberPointer or CX_CastKind.CX_CK_UncheckedDerivedToBase)) + private void VisitMemberExpr(MemberExpr memberExpr) + { + var outputBuilder = StartCSharpCode(); + var baseFieldName = ""; + + if ((memberExpr.Base is ImplicitCastExpr implicitCastExpr) && (implicitCastExpr.CastKind is CX_CastKind.CX_CK_DerivedToBase or CX_CastKind.CX_CK_DerivedToBaseMemberPointer or CX_CastKind.CX_CK_UncheckedDerivedToBase)) + { + if (memberExpr.MemberDecl is CXXMethodDecl cxxMethodDecl) { - if (memberExpr.MemberDecl is CXXMethodDecl cxxMethodDecl) + if ((_cxxRecordDeclContext is not null) && (_cxxRecordDeclContext != cxxMethodDecl.Parent) && HasField(cxxMethodDecl.Parent)) { - if ((_cxxRecordDeclContext is not null) && (_cxxRecordDeclContext != cxxMethodDecl.Parent) && HasField(cxxMethodDecl.Parent)) - { - var cxxBaseSpecifier = _cxxRecordDeclContext.Bases.Where((baseSpecifier) => baseSpecifier.Referenced == cxxMethodDecl.Parent).SingleOrDefault(); + var cxxBaseSpecifier = _cxxRecordDeclContext.Bases.Where((baseSpecifier) => baseSpecifier.Referenced == cxxMethodDecl.Parent).SingleOrDefault(); - if (cxxBaseSpecifier is not null) - { - baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); - baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); - } - } - } - else if (memberExpr.MemberDecl is FieldDecl fieldDecl) - { - if ((_cxxRecordDeclContext is not null) && (_cxxRecordDeclContext != fieldDecl.Parent)) + if (cxxBaseSpecifier is not null) { - var cxxBaseSpecifier = _cxxRecordDeclContext.Bases.Where((baseSpecifier) => baseSpecifier.Referenced == fieldDecl.Parent).SingleOrDefault(); - - if (cxxBaseSpecifier is not null) - { - baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); - baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); - } + baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); + baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); } } } - - if (!memberExpr.IsImplicitAccess || !string.IsNullOrWhiteSpace(baseFieldName)) + else if (memberExpr.MemberDecl is FieldDecl fieldDecl) { - var memberExprBase = memberExpr.Base.IgnoreImplicit; - - if (!string.IsNullOrWhiteSpace(baseFieldName)) + if ((_cxxRecordDeclContext is not null) && (_cxxRecordDeclContext != fieldDecl.Parent)) { - outputBuilder.Write(baseFieldName); - } - else - { - Visit(memberExprBase); - } + var cxxBaseSpecifier = _cxxRecordDeclContext.Bases.Where((baseSpecifier) => baseSpecifier.Referenced == fieldDecl.Parent).SingleOrDefault(); - var type = null as Type; - - if (!IsStmtAsWritten(memberExprBase, out _, removeParens: true)) - { - if (memberExprBase is DeclRefExpr declRefExpr) + if (cxxBaseSpecifier is not null) { - type = declRefExpr.Decl.Type.CanonicalType; - } - else - { - type = memberExpr.Base.Type.CanonicalType; + baseFieldName = GetAnonymousName(cxxBaseSpecifier, "Base"); + baseFieldName = GetRemappedName(baseFieldName, cxxBaseSpecifier, tryRemapOperatorName: true, out var wasRemapped, skipUsing: true); } } + } + } + + if (!memberExpr.IsImplicitAccess || !string.IsNullOrWhiteSpace(baseFieldName)) + { + var memberExprBase = memberExpr.Base.IgnoreImplicit; + + if (!string.IsNullOrWhiteSpace(baseFieldName)) + { + outputBuilder.Write(baseFieldName); + } + else + { + Visit(memberExprBase); + } + + var type = null as Type; - if (type is not null and (PointerType or ReferenceType)) + if (!IsStmtAsWritten(memberExprBase, out _, removeParens: true)) + { + if (memberExprBase is DeclRefExpr declRefExpr) { - outputBuilder.Write("->"); + type = declRefExpr.Decl.Type.CanonicalType; } else { - outputBuilder.Write('.'); + type = memberExpr.Base.Type.CanonicalType; } } - outputBuilder.Write(GetRemappedCursorName(memberExpr.MemberDecl)); - StopCSharpCode(); + if (type is not null and (PointerType or ReferenceType)) + { + outputBuilder.Write("->"); + } + else + { + outputBuilder.Write('.'); + } } - private static void VisitNullStmt(NullStmt nullStmt) - { - // null statements are empty by definition, so nothing to do - } + outputBuilder.Write(GetRemappedCursorName(memberExpr.MemberDecl)); + StopCSharpCode(); + } - private void VisitPackExpansionExpr(PackExpansionExpr packExpansionExpr) => Visit(packExpansionExpr.Pattern); + private static void VisitNullStmt(NullStmt nullStmt) + { + // null statements are empty by definition, so nothing to do + } - private void VisitParenExpr(ParenExpr parenExpr) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write('('); - Visit(parenExpr.SubExpr); - outputBuilder.Write(')'); - StopCSharpCode(); - } + private void VisitPackExpansionExpr(PackExpansionExpr packExpansionExpr) => Visit(packExpansionExpr.Pattern); - private void VisitParenListExpr(ParenListExpr parenListExpr) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write('('); + private void VisitParenExpr(ParenExpr parenExpr) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write('('); + Visit(parenExpr.SubExpr); + outputBuilder.Write(')'); + StopCSharpCode(); + } - var needsComma = false; + private void VisitParenListExpr(ParenListExpr parenListExpr) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write('('); - foreach (var expr in parenListExpr.Exprs) - { - if (needsComma) - { - outputBuilder.Write(", "); - } + var needsComma = false; - Visit(expr); - needsComma = true; + foreach (var expr in parenListExpr.Exprs) + { + if (needsComma) + { + outputBuilder.Write(", "); } - outputBuilder.Write(')'); - StopCSharpCode(); + Visit(expr); + needsComma = true; } - private void VisitReturnStmt(ReturnStmt returnStmt) + outputBuilder.Write(')'); + StopCSharpCode(); + } + + private void VisitReturnStmt(ReturnStmt returnStmt) + { + var outputBuilder = StartCSharpCode(); + if (IsPrevContextDecl(out var functionDecl, out _) && (functionDecl.ReturnType.CanonicalType.Kind != CXTypeKind.CXType_Void)) { - var outputBuilder = StartCSharpCode(); - if (IsPrevContextDecl(out var functionDecl, out _) && (functionDecl.ReturnType.CanonicalType.Kind != CXTypeKind.CXType_Void)) + outputBuilder.Write("return"); + + if (returnStmt.RetValue != null) { - outputBuilder.Write("return"); + outputBuilder.Write(' '); - if (returnStmt.RetValue != null) + if (functionDecl.ReturnType.CanonicalType is not ReferenceType and not PointerType) { - outputBuilder.Write(' '); - - if (functionDecl.ReturnType.CanonicalType is not ReferenceType and not PointerType) + if (returnStmt.RetValue.Type.CanonicalType is ReferenceType) { - if (returnStmt.RetValue.Type.CanonicalType is ReferenceType) - { - outputBuilder.Write('*'); - } + outputBuilder.Write('*'); } - - Visit(returnStmt.RetValue); } - } - else if (returnStmt.RetValue != null) - { + Visit(returnStmt.RetValue); } - else - { - outputBuilder.Write("return"); - } - - StopCSharpCode(); } + else if (returnStmt.RetValue != null) + { + Visit(returnStmt.RetValue); + } + else + { + outputBuilder.Write("return"); + } + + StopCSharpCode(); + } - private void VisitStmt(Stmt stmt) + private void VisitStmt(Stmt stmt) + { + switch (stmt.StmtClass) { - switch (stmt.StmtClass) + // case CX_StmtClass.CX_StmtClass_GCCAsmStmt: + // case CX_StmtClass.CX_StmtClass_MSAsmStmt: + + case CX_StmtClass.CX_StmtClass_BreakStmt: { - // case CX_StmtClass.CX_StmtClass_GCCAsmStmt: - // case CX_StmtClass.CX_StmtClass_MSAsmStmt: + VisitBreakStmt((BreakStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_BreakStmt: - { - VisitBreakStmt((BreakStmt)stmt); - break; - } + // case CX_StmtClass.CX_StmtClass_CXXCatchStmt: + // case CX_StmtClass.CX_StmtClass_CXXForRangeStmt: + // case CX_StmtClass.CX_StmtClass_CXXTryStmt: + // case CX_StmtClass.CX_StmtClass_CapturedStmt: - // case CX_StmtClass.CX_StmtClass_CXXCatchStmt: - // case CX_StmtClass.CX_StmtClass_CXXForRangeStmt: - // case CX_StmtClass.CX_StmtClass_CXXTryStmt: - // case CX_StmtClass.CX_StmtClass_CapturedStmt: + case CX_StmtClass.CX_StmtClass_CompoundStmt: + { + VisitCompoundStmt((CompoundStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CompoundStmt: - { - VisitCompoundStmt((CompoundStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_ContinueStmt: + { + VisitContinueStmt((ContinueStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_ContinueStmt: - { - VisitContinueStmt((ContinueStmt)stmt); - break; - } + // case CX_StmtClass.CX_StmtClass_CoreturnStmt: + // case CX_StmtClass.CX_StmtClass_CoroutineBodyStmt: - // case CX_StmtClass.CX_StmtClass_CoreturnStmt: - // case CX_StmtClass.CX_StmtClass_CoroutineBodyStmt: + case CX_StmtClass.CX_StmtClass_DeclStmt: + { + VisitDeclStmt((DeclStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_DeclStmt: - { - VisitDeclStmt((DeclStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_DoStmt: + { + VisitDoStmt((DoStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_DoStmt: - { - VisitDoStmt((DoStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_ForStmt: + { + VisitForStmt((ForStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_ForStmt: - { - VisitForStmt((ForStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_GotoStmt: + { + VisitGotoStmt((GotoStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_GotoStmt: - { - VisitGotoStmt((GotoStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_IfStmt: + { + VisitIfStmt((IfStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_IfStmt: - { - VisitIfStmt((IfStmt)stmt); - break; - } + // case CX_StmtClass.CX_StmtClass_IndirectGotoStmt: + // case CX_StmtClass.CX_StmtClass_MSDependentExistsStmt: - // case CX_StmtClass.CX_StmtClass_IndirectGotoStmt: - // case CX_StmtClass.CX_StmtClass_MSDependentExistsStmt: + case CX_StmtClass.CX_StmtClass_NullStmt: + { + VisitNullStmt((NullStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_NullStmt: - { - VisitNullStmt((NullStmt)stmt); - break; - } + // case CX_StmtClass.CX_StmtClass_OMPAtomicDirective: + // case CX_StmtClass.CX_StmtClass_OMPBarrierDirective: + // case CX_StmtClass.CX_StmtClass_OMPCancelDirective: + // case CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective: + // case CX_StmtClass.CX_StmtClass_OMPCriticalDirective: + // case CX_StmtClass.CX_StmtClass_OMPFlushDirective: + // case CX_StmtClass.CX_StmtClass_OMPDistributeDirective: + // case CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective: + // case CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPForDirective: + // case CX_StmtClass.CX_StmtClass_OMPForSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPParallelForDirective: + // case CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective: + // case CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective: + // case CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective: + // case CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective: + // case CX_StmtClass.CX_StmtClass_OMPMasterDirective: + // case CX_StmtClass.CX_StmtClass_OMPOrderedDirective: + // case CX_StmtClass.CX_StmtClass_OMPParallelDirective: + // case CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective: + // case CX_StmtClass.CX_StmtClass_OMPSectionDirective: + // case CX_StmtClass.CX_StmtClass_OMPSectionsDirective: + // case CX_StmtClass.CX_StmtClass_OMPSingleDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetDataDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective: + // case CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective: + // case CX_StmtClass.CX_StmtClass_OMPTaskDirective: + // case CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective: + // case CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective: + // case CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective: + // case CX_StmtClass.CX_StmtClass_OMPTeamsDirective: + // case CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt: + // case CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt: + // case CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt: + // case CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt: + // case CX_StmtClass.CX_StmtClass_ObjCAtTryStmt: + // case CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt: + // case CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt: - // case CX_StmtClass.CX_StmtClass_OMPAtomicDirective: - // case CX_StmtClass.CX_StmtClass_OMPBarrierDirective: - // case CX_StmtClass.CX_StmtClass_OMPCancelDirective: - // case CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective: - // case CX_StmtClass.CX_StmtClass_OMPCriticalDirective: - // case CX_StmtClass.CX_StmtClass_OMPFlushDirective: - // case CX_StmtClass.CX_StmtClass_OMPDistributeDirective: - // case CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective: - // case CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPForDirective: - // case CX_StmtClass.CX_StmtClass_OMPForSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPParallelForDirective: - // case CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective: - // case CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective: - // case CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective: - // case CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective: - // case CX_StmtClass.CX_StmtClass_OMPMasterDirective: - // case CX_StmtClass.CX_StmtClass_OMPOrderedDirective: - // case CX_StmtClass.CX_StmtClass_OMPParallelDirective: - // case CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective: - // case CX_StmtClass.CX_StmtClass_OMPSectionDirective: - // case CX_StmtClass.CX_StmtClass_OMPSectionsDirective: - // case CX_StmtClass.CX_StmtClass_OMPSingleDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetDataDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective: - // case CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective: - // case CX_StmtClass.CX_StmtClass_OMPTaskDirective: - // case CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective: - // case CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective: - // case CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective: - // case CX_StmtClass.CX_StmtClass_OMPTeamsDirective: - // case CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt: - // case CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt: - // case CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt: - // case CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt: - // case CX_StmtClass.CX_StmtClass_ObjCAtTryStmt: - // case CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt: - // case CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt: - - case CX_StmtClass.CX_StmtClass_ReturnStmt: - { - VisitReturnStmt((ReturnStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_ReturnStmt: + { + VisitReturnStmt((ReturnStmt)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_SEHExceptStmt: - // case CX_StmtClass.CX_StmtClass_SEHFinallyStmt: - // case CX_StmtClass.CX_StmtClass_SEHLeaveStmt: - // case CX_StmtClass.CX_StmtClass_SEHTryStmt: + // case CX_StmtClass.CX_StmtClass_SEHExceptStmt: + // case CX_StmtClass.CX_StmtClass_SEHFinallyStmt: + // case CX_StmtClass.CX_StmtClass_SEHLeaveStmt: + // case CX_StmtClass.CX_StmtClass_SEHTryStmt: - case CX_StmtClass.CX_StmtClass_CaseStmt: - { - VisitCaseStmt((CaseStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CaseStmt: + { + VisitCaseStmt((CaseStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_DefaultStmt: - { - VisitDefaultStmt((DefaultStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_DefaultStmt: + { + VisitDefaultStmt((DefaultStmt)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_SwitchStmt: - { - VisitSwitchStmt((SwitchStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_SwitchStmt: + { + VisitSwitchStmt((SwitchStmt)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_AttributedStmt: - // case CX_StmtClass.CX_StmtClass_BinaryConditionalOperator: + // case CX_StmtClass.CX_StmtClass_AttributedStmt: + // case CX_StmtClass.CX_StmtClass_BinaryConditionalOperator: - case CX_StmtClass.CX_StmtClass_ConditionalOperator: - { - VisitConditionalOperator((ConditionalOperator)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_ConditionalOperator: + { + VisitConditionalOperator((ConditionalOperator)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_AddrLabelExpr: - // case CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr: - // case CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr: + // case CX_StmtClass.CX_StmtClass_AddrLabelExpr: + // case CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr: + // case CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr: - case CX_StmtClass.CX_StmtClass_ArraySubscriptExpr: - { - VisitArraySubscriptExpr((ArraySubscriptExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_ArraySubscriptExpr: + { + VisitArraySubscriptExpr((ArraySubscriptExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr: - // case CX_StmtClass.CX_StmtClass_AsTypeExpr: - // case CX_StmtClass.CX_StmtClass_AtomicExpr: + // case CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr: + // case CX_StmtClass.CX_StmtClass_AsTypeExpr: + // case CX_StmtClass.CX_StmtClass_AtomicExpr: - case CX_StmtClass.CX_StmtClass_BinaryOperator: - case CX_StmtClass.CX_StmtClass_CompoundAssignOperator: - { - VisitBinaryOperator((BinaryOperator)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_BinaryOperator: + case CX_StmtClass.CX_StmtClass_CompoundAssignOperator: + { + VisitBinaryOperator((BinaryOperator)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_BlockExpr: - // case CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr: + // case CX_StmtClass.CX_StmtClass_BlockExpr: + // case CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr: - case CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr: - { - VisitCXXBoolLiteralExpr((CXXBoolLiteralExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr: + { + VisitCXXBoolLiteralExpr((CXXBoolLiteralExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CXXConstructExpr: - { - VisitCXXConstructExpr((CXXConstructExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXConstructExpr: + { + VisitCXXConstructExpr((CXXConstructExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr: - { - VisitCXXTemporaryObjectExpr((CXXTemporaryObjectExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr: + { + VisitCXXTemporaryObjectExpr((CXXTemporaryObjectExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr: - { - VisitCXXDefaultArgExpr((CXXDefaultArgExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr: + { + VisitCXXDefaultArgExpr((CXXDefaultArgExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr: - // case CX_StmtClass.CX_StmtClass_CXXDeleteExpr: + // case CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr: + // case CX_StmtClass.CX_StmtClass_CXXDeleteExpr: - case CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr: - { - VisitCXXDependentScopeMemberExpr((CXXDependentScopeMemberExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr: + { + VisitCXXDependentScopeMemberExpr((CXXDependentScopeMemberExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_CXXFoldExpr: - // case CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr: + // case CX_StmtClass.CX_StmtClass_CXXFoldExpr: + // case CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr: - case CX_StmtClass.CX_StmtClass_CXXNewExpr: - { - VisitCXXNewExpr((CXXNewExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXNewExpr: + { + VisitCXXNewExpr((CXXNewExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_CXXNoexceptExpr: + // case CX_StmtClass.CX_StmtClass_CXXNoexceptExpr: - case CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr: - { - VisitCXXNullPtrLiteralExpr((CXXNullPtrLiteralExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr: + { + VisitCXXNullPtrLiteralExpr((CXXNullPtrLiteralExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr: - { - VisitCXXPseudoDestructorExpr((CXXPseudoDestructorExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr: + { + VisitCXXPseudoDestructorExpr((CXXPseudoDestructorExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr: - // case CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr: + // case CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr: + // case CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr: - case CX_StmtClass.CX_StmtClass_CXXThisExpr: - { - VisitCXXThisExpr((CXXThisExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXThisExpr: + { + VisitCXXThisExpr((CXXThisExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_CXXThrowExpr: - // case CX_StmtClass.CX_StmtClass_CXXTypeidExpr: + // case CX_StmtClass.CX_StmtClass_CXXThrowExpr: + // case CX_StmtClass.CX_StmtClass_CXXTypeidExpr: - case CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr: - { - VisitCXXUnresolvedConstructExpr((CXXUnresolvedConstructExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr: + { + VisitCXXUnresolvedConstructExpr((CXXUnresolvedConstructExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CXXUuidofExpr: - { - VisitCXXUuidofExpr((CXXUuidofExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXUuidofExpr: + { + VisitCXXUuidofExpr((CXXUuidofExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CallExpr: - case CX_StmtClass.CX_StmtClass_CXXMemberCallExpr: - { - VisitCallExpr((CallExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CallExpr: + case CX_StmtClass.CX_StmtClass_CXXMemberCallExpr: + { + VisitCallExpr((CallExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr: + // case CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr: - case CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr: - { - VisitCXXOperatorCallExpr((CXXOperatorCallExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr: + { + VisitCXXOperatorCallExpr((CXXOperatorCallExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_UserDefinedLiteral: - // case CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr: + // case CX_StmtClass.CX_StmtClass_UserDefinedLiteral: + // case CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr: - case CX_StmtClass.CX_StmtClass_CStyleCastExpr: - case CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr: - case CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr: - case CX_StmtClass.CX_StmtClass_CXXStaticCastExpr: - { - VisitExplicitCastExpr((ExplicitCastExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CStyleCastExpr: + case CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr: + case CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr: + case CX_StmtClass.CX_StmtClass_CXXStaticCastExpr: + { + VisitExplicitCastExpr((ExplicitCastExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr: - { - VisitCXXFunctionalCastExpr((CXXFunctionalCastExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr: + { + VisitCXXFunctionalCastExpr((CXXFunctionalCastExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CXXConstCastExpr: - { - VisitCXXConstCastExpr((CXXConstCastExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CXXConstCastExpr: + { + VisitCXXConstCastExpr((CXXConstCastExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr: + // case CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr: - case CX_StmtClass.CX_StmtClass_ImplicitCastExpr: - { - VisitImplicitCastExpr((ImplicitCastExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_ImplicitCastExpr: + { + VisitImplicitCastExpr((ImplicitCastExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_CharacterLiteral: - { - VisitCharacterLiteral((CharacterLiteral)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_CharacterLiteral: + { + VisitCharacterLiteral((CharacterLiteral)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_ChooseExpr: - // case CX_StmtClass.CX_StmtClass_CompoundLiteralExpr: - // case CX_StmtClass.CX_StmtClass_ConvertVectorExpr: - // case CX_StmtClass.CX_StmtClass_CoawaitExpr: - // case CX_StmtClass.CX_StmtClass_CoyieldExpr: + // case CX_StmtClass.CX_StmtClass_ChooseExpr: + // case CX_StmtClass.CX_StmtClass_CompoundLiteralExpr: + // case CX_StmtClass.CX_StmtClass_ConvertVectorExpr: + // case CX_StmtClass.CX_StmtClass_CoawaitExpr: + // case CX_StmtClass.CX_StmtClass_CoyieldExpr: - case CX_StmtClass.CX_StmtClass_DeclRefExpr: - { - VisitDeclRefExpr((DeclRefExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_DeclRefExpr: + { + VisitDeclRefExpr((DeclRefExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_DependentCoawaitExpr: + // case CX_StmtClass.CX_StmtClass_DependentCoawaitExpr: - case CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr: - { - VisitDependentScopeDeclRefExpr((DependentScopeDeclRefExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr: + { + VisitDependentScopeDeclRefExpr((DependentScopeDeclRefExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_DesignatedInitExpr: - // case CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr: - // case CX_StmtClass.CX_StmtClass_ExpressionTraitExpr: - // case CX_StmtClass.CX_StmtClass_ExtVectorElementExpr: - // case CX_StmtClass.CX_StmtClass_FixedPointLiteral: + // case CX_StmtClass.CX_StmtClass_DesignatedInitExpr: + // case CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr: + // case CX_StmtClass.CX_StmtClass_ExpressionTraitExpr: + // case CX_StmtClass.CX_StmtClass_ExtVectorElementExpr: + // case CX_StmtClass.CX_StmtClass_FixedPointLiteral: - case CX_StmtClass.CX_StmtClass_FloatingLiteral: - { - VisitFloatingLiteral((FloatingLiteral)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_FloatingLiteral: + { + VisitFloatingLiteral((FloatingLiteral)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_ConstantExpr: + // case CX_StmtClass.CX_StmtClass_ConstantExpr: - case CX_StmtClass.CX_StmtClass_ExprWithCleanups: - { - VisitExprWithCleanups((ExprWithCleanups)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_ExprWithCleanups: + { + VisitExprWithCleanups((ExprWithCleanups)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_FunctionParmPackExpr: - // case CX_StmtClass.CX_StmtClass_GNUNullExpr: - // case CX_StmtClass.CX_StmtClass_GenericSelectionExpr: - // case CX_StmtClass.CX_StmtClass_ImaginaryLiteral: + // case CX_StmtClass.CX_StmtClass_FunctionParmPackExpr: + // case CX_StmtClass.CX_StmtClass_GNUNullExpr: + // case CX_StmtClass.CX_StmtClass_GenericSelectionExpr: + // case CX_StmtClass.CX_StmtClass_ImaginaryLiteral: - case CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr: - { - VisitImplicitValueInitExpr((ImplicitValueInitExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr: + { + VisitImplicitValueInitExpr((ImplicitValueInitExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_InitListExpr: - { - VisitInitListExpr((InitListExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_InitListExpr: + { + VisitInitListExpr((InitListExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_IntegerLiteral: - { - VisitIntegerLiteral((IntegerLiteral)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_IntegerLiteral: + { + VisitIntegerLiteral((IntegerLiteral)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_LambdaExpr: - // case CX_StmtClass.CX_StmtClass_MSPropertyRefExpr: - // case CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr: + // case CX_StmtClass.CX_StmtClass_LambdaExpr: + // case CX_StmtClass.CX_StmtClass_MSPropertyRefExpr: + // case CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr: - case CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr: - { - VisitMaterializeTemporaryExpr((MaterializeTemporaryExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr: + { + VisitMaterializeTemporaryExpr((MaterializeTemporaryExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_MemberExpr: - { - VisitMemberExpr((MemberExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_MemberExpr: + { + VisitMemberExpr((MemberExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_NoInitExpr: - // case CX_StmtClass.CX_StmtClass_OMPArraySectionExpr: - // case CX_StmtClass.CX_StmtClass_ObjCArrayLiteral: - // case CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr: - // case CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr: - // case CX_StmtClass.CX_StmtClass_ObjCBoxedExpr: - // case CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral: - // case CX_StmtClass.CX_StmtClass_ObjCEncodeExpr: - // case CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr: - // case CX_StmtClass.CX_StmtClass_ObjCIsaExpr: - // case CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr: - // case CX_StmtClass.CX_StmtClass_ObjCMessageExpr: - // case CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr: - // case CX_StmtClass.CX_StmtClass_ObjCProtocolExpr: - // case CX_StmtClass.CX_StmtClass_ObjCSelectorExpr: - // case CX_StmtClass.CX_StmtClass_ObjCStringLiteral: - // case CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr: - - case CX_StmtClass.CX_StmtClass_OffsetOfExpr: - { - VisitOffsetOfExpr((OffsetOfExpr)stmt); - break; - } + // case CX_StmtClass.CX_StmtClass_NoInitExpr: + // case CX_StmtClass.CX_StmtClass_OMPArraySectionExpr: + // case CX_StmtClass.CX_StmtClass_ObjCArrayLiteral: + // case CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr: + // case CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr: + // case CX_StmtClass.CX_StmtClass_ObjCBoxedExpr: + // case CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral: + // case CX_StmtClass.CX_StmtClass_ObjCEncodeExpr: + // case CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr: + // case CX_StmtClass.CX_StmtClass_ObjCIsaExpr: + // case CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr: + // case CX_StmtClass.CX_StmtClass_ObjCMessageExpr: + // case CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr: + // case CX_StmtClass.CX_StmtClass_ObjCProtocolExpr: + // case CX_StmtClass.CX_StmtClass_ObjCSelectorExpr: + // case CX_StmtClass.CX_StmtClass_ObjCStringLiteral: + // case CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr: - // case CX_StmtClass.CX_StmtClass_OpaqueValueExpr: + case CX_StmtClass.CX_StmtClass_OffsetOfExpr: + { + VisitOffsetOfExpr((OffsetOfExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr: - { - VisitUnresolvedLookupExpr((UnresolvedLookupExpr)stmt); - break; - } + // case CX_StmtClass.CX_StmtClass_OpaqueValueExpr: - case CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr: - { - VisitUnresolvedMemberExpr((UnresolvedMemberExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr: + { + VisitUnresolvedLookupExpr((UnresolvedLookupExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_PackExpansionExpr: - { - VisitPackExpansionExpr((PackExpansionExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr: + { + VisitUnresolvedMemberExpr((UnresolvedMemberExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_ParenExpr: - { - VisitParenExpr((ParenExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_PackExpansionExpr: + { + VisitPackExpansionExpr((PackExpansionExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_ParenListExpr: - { - VisitParenListExpr((ParenListExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_ParenExpr: + { + VisitParenExpr((ParenExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_PredefinedExpr: - // case CX_StmtClass.CX_StmtClass_PseudoObjectExpr: - // case CX_StmtClass.CX_StmtClass_ShuffleVectorExpr: - // case CX_StmtClass.CX_StmtClass_SizeOfPackExpr: - // case CX_StmtClass.CX_StmtClass_SourceLocExpr: - // case CX_StmtClass.CX_StmtClass_StmtExpr: + case CX_StmtClass.CX_StmtClass_ParenListExpr: + { + VisitParenListExpr((ParenListExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_StringLiteral: - { - VisitStringLiteral((StringLiteral)stmt); - break; - } + // case CX_StmtClass.CX_StmtClass_PredefinedExpr: + // case CX_StmtClass.CX_StmtClass_PseudoObjectExpr: + // case CX_StmtClass.CX_StmtClass_ShuffleVectorExpr: + // case CX_StmtClass.CX_StmtClass_SizeOfPackExpr: + // case CX_StmtClass.CX_StmtClass_SourceLocExpr: + // case CX_StmtClass.CX_StmtClass_StmtExpr: - case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr: - { - VisitSubstNonTypeTemplateParmExpr((SubstNonTypeTemplateParmExpr)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_StringLiteral: + { + VisitStringLiteral((StringLiteral)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr: - // case CX_StmtClass.CX_StmtClass_TypeTraitExpr: - // case CX_StmtClass.CX_StmtClass_TypoExpr: + case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr: + { + VisitSubstNonTypeTemplateParmExpr((SubstNonTypeTemplateParmExpr)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr: - { - VisitUnaryExprOrTypeTraitExpr((UnaryExprOrTypeTraitExpr)stmt); - break; - } + // case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr: + // case CX_StmtClass.CX_StmtClass_TypeTraitExpr: + // case CX_StmtClass.CX_StmtClass_TypoExpr: - case CX_StmtClass.CX_StmtClass_UnaryOperator: - { - VisitUnaryOperator((UnaryOperator)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr: + { + VisitUnaryExprOrTypeTraitExpr((UnaryExprOrTypeTraitExpr)stmt); + break; + } - // case CX_StmtClass.CX_StmtClass_VAArgExpr: + case CX_StmtClass.CX_StmtClass_UnaryOperator: + { + VisitUnaryOperator((UnaryOperator)stmt); + break; + } - case CX_StmtClass.CX_StmtClass_LabelStmt: - { - VisitLabelStmt((LabelStmt)stmt); - break; - } + // case CX_StmtClass.CX_StmtClass_VAArgExpr: - case CX_StmtClass.CX_StmtClass_WhileStmt: - { - VisitWhileStmt((WhileStmt)stmt); - break; - } + case CX_StmtClass.CX_StmtClass_LabelStmt: + { + VisitLabelStmt((LabelStmt)stmt); + break; + } - default: - { - var context = string.Empty; + case CX_StmtClass.CX_StmtClass_WhileStmt: + { + VisitWhileStmt((WhileStmt)stmt); + break; + } - if (IsPrevContextDecl(out var namedDecl, out _)) - { - context = $" in {GetCursorQualifiedName(namedDecl)}"; - } + default: + { + var context = string.Empty; - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported statement: '{stmt.StmtClassName}'{context}. Generated bindings may be incomplete.", stmt); - break; + if (IsPrevContextDecl(out var namedDecl, out _)) + { + context = $" in {GetCursorQualifiedName(namedDecl)}"; } + + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported statement: '{stmt.StmtClassName}'{context}. Generated bindings may be incomplete.", stmt); + break; } } + } + + private void VisitStmts(IReadOnlyList stmts) + { + var outputBuilder = StartCSharpCode(); + var lastIndex = stmts.Count - 1; + var previousStmt = null as Stmt; - private void VisitStmts(IReadOnlyList stmts) + for (var i = 0; i < lastIndex; i++) { - var outputBuilder = StartCSharpCode(); - var lastIndex = stmts.Count - 1; - var previousStmt = null as Stmt; + var stmt = stmts[i]; - for (var i = 0; i < lastIndex; i++) + if ((previousStmt is DeclStmt) && (stmt is not DeclStmt)) { - var stmt = stmts[i]; - - if ((previousStmt is DeclStmt) && (stmt is not DeclStmt)) - { - outputBuilder.NeedsNewline = true; - } - - outputBuilder.WriteIndentation(); - outputBuilder.NeedsSemicolon = true; outputBuilder.NeedsNewline = true; + } - Visit(stmts[i]); + outputBuilder.WriteIndentation(); + outputBuilder.NeedsSemicolon = true; + outputBuilder.NeedsNewline = true; - outputBuilder.WriteSemicolonIfNeeded(); - outputBuilder.WriteNewline(); + Visit(stmts[i]); - previousStmt = stmt; - } + outputBuilder.WriteSemicolonIfNeeded(); + outputBuilder.WriteNewline(); - if (lastIndex != -1) - { - var stmt = stmts[lastIndex]; + previousStmt = stmt; + } - if ((previousStmt is DeclStmt) && (stmt is not DeclStmt)) - { - outputBuilder.NeedsNewline = true; - } + if (lastIndex != -1) + { + var stmt = stmts[lastIndex]; - outputBuilder.WriteIndentation(); - outputBuilder.NeedsSemicolon = true; + if ((previousStmt is DeclStmt) && (stmt is not DeclStmt)) + { outputBuilder.NeedsNewline = true; + } - Visit(stmt); + outputBuilder.WriteIndentation(); + outputBuilder.NeedsSemicolon = true; + outputBuilder.NeedsNewline = true; - outputBuilder.WriteSemicolonIfNeeded(); - outputBuilder.WriteNewlineIfNeeded(); - } + Visit(stmt); - StopCSharpCode(); + outputBuilder.WriteSemicolonIfNeeded(); + outputBuilder.WriteNewlineIfNeeded(); } - private void VisitStringLiteral(StringLiteral stringLiteral) + StopCSharpCode(); + } + + private void VisitStringLiteral(StringLiteral stringLiteral) + { + var outputBuilder = StartCSharpCode(); + switch (stringLiteral.Kind) { - var outputBuilder = StartCSharpCode(); - switch (stringLiteral.Kind) + case CX_CharacterKind.CX_CLK_Ascii: + case CX_CharacterKind.CX_CLK_UTF8: { - case CX_CharacterKind.CX_CLK_Ascii: - case CX_CharacterKind.CX_CLK_UTF8: + if (Config.GeneratePreviewCode) { - if (Config.GeneratePreviewCode) - { - outputBuilder.Write('"'); - outputBuilder.Write(EscapeString(stringLiteral.String)); - outputBuilder.Write('"'); - outputBuilder.Write("u8"); + outputBuilder.Write('"'); + outputBuilder.Write(EscapeString(stringLiteral.String)); + outputBuilder.Write('"'); + outputBuilder.Write("u8"); - if (IsPrevContextDecl(out _, out var userData)) + if (IsPrevContextDecl(out _, out var userData)) + { + if (userData is ValueDesc valueDesc) { - if (userData is ValueDesc valueDesc) + if ((valueDesc.Kind == ValueKind.String) && (valueDesc.TypeName == "byte[]")) { - if ((valueDesc.Kind == ValueKind.String) && (valueDesc.TypeName == "byte[]")) - { - outputBuilder.Write(".ToArray()"); - } + outputBuilder.Write(".ToArray()"); } } } - else - { - outputBuilder.Write("new byte[] { "); - - var bytes = Encoding.UTF8.GetBytes(stringLiteral.String); - - foreach (var b in bytes) - { - outputBuilder.Write("0x"); - outputBuilder.Write(b.ToString("X2")); - outputBuilder.Write(", "); - } - - outputBuilder.Write("0x00 }"); - } - break; } - - case CX_CharacterKind.CX_CLK_Wide: + else { - if (_config.GenerateUnixTypes) - { - goto case CX_CharacterKind.CX_CLK_UTF32; - } - else + outputBuilder.Write("new byte[] { "); + + var bytes = Encoding.UTF8.GetBytes(stringLiteral.String); + + foreach (var b in bytes) { - goto case CX_CharacterKind.CX_CLK_UTF16; + outputBuilder.Write("0x"); + outputBuilder.Write(b.ToString("X2")); + outputBuilder.Write(", "); } + + outputBuilder.Write("0x00 }"); } + break; + } - case CX_CharacterKind.CX_CLK_UTF16: + case CX_CharacterKind.CX_CLK_Wide: + { + if (_config.GenerateUnixTypes) { - outputBuilder.Write('"'); - outputBuilder.Write(EscapeString(stringLiteral.String)); - outputBuilder.Write('"'); - break; + goto case CX_CharacterKind.CX_CLK_UTF32; } - - case CX_CharacterKind.CX_CLK_UTF32: + else { - outputBuilder.Write("new uint[] { "); + goto case CX_CharacterKind.CX_CLK_UTF16; + } + } - var bytes = Encoding.UTF32.GetBytes(stringLiteral.String); - var codepoints = MemoryMarshal.Cast(bytes); + case CX_CharacterKind.CX_CLK_UTF16: + { + outputBuilder.Write('"'); + outputBuilder.Write(EscapeString(stringLiteral.String)); + outputBuilder.Write('"'); + break; + } - foreach (var codepoint in codepoints) - { - outputBuilder.Write("0x"); - outputBuilder.Write(codepoint.ToString("X8")); - outputBuilder.Write(", "); - } + case CX_CharacterKind.CX_CLK_UTF32: + { + outputBuilder.Write("new uint[] { "); - outputBuilder.Write("0x00000000 }"); - break; - } + var bytes = Encoding.UTF32.GetBytes(stringLiteral.String); + var codepoints = MemoryMarshal.Cast(bytes); - default: + foreach (var codepoint in codepoints) { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported string literal kind: '{stringLiteral.Kind}'. Generated bindings may be incomplete.", stringLiteral); - break; + outputBuilder.Write("0x"); + outputBuilder.Write(codepoint.ToString("X8")); + outputBuilder.Write(", "); } + + outputBuilder.Write("0x00000000 }"); + break; } - StopCSharpCode(); + default: + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported string literal kind: '{stringLiteral.Kind}'. Generated bindings may be incomplete.", stringLiteral); + break; + } } - private void VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr substNonTypeTemplateParmExpr) => Visit(substNonTypeTemplateParmExpr.Replacement); + StopCSharpCode(); + } + + private void VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr substNonTypeTemplateParmExpr) => Visit(substNonTypeTemplateParmExpr.Replacement); - private void VisitSwitchStmt(SwitchStmt switchStmt) - { - var outputBuilder = StartCSharpCode(); + private void VisitSwitchStmt(SwitchStmt switchStmt) + { + var outputBuilder = StartCSharpCode(); - outputBuilder.Write("switch ("); - Visit(switchStmt.Cond); - outputBuilder.WriteLine(')'); + outputBuilder.Write("switch ("); + Visit(switchStmt.Cond); + outputBuilder.WriteLine(')'); - VisitBody(switchStmt.Body); - StopCSharpCode(); - } + VisitBody(switchStmt.Body); + StopCSharpCode(); + } - private void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr unaryExprOrTypeTraitExpr) - { - var outputBuilder = StartCSharpCode(); - var argumentType = unaryExprOrTypeTraitExpr.TypeOfArgument; + private void VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr unaryExprOrTypeTraitExpr) + { + var outputBuilder = StartCSharpCode(); + var argumentType = unaryExprOrTypeTraitExpr.TypeOfArgument; - long alignment32 = -1; - long alignment64 = -1; + long alignment32 = -1; + long alignment64 = -1; - GetTypeSize(unaryExprOrTypeTraitExpr, argumentType, ref alignment32, ref alignment64, out var size32, out var size64); + GetTypeSize(unaryExprOrTypeTraitExpr, argumentType, ref alignment32, ref alignment64, out var size32, out var size64); - switch (unaryExprOrTypeTraitExpr.Kind) + switch (unaryExprOrTypeTraitExpr.Kind) + { + case CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf: { - case CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf: + if ((size32 == size64) && IsPrevContextDecl(out _, out _)) { - if ((size32 == size64) && IsPrevContextDecl(out _, out _)) + outputBuilder.Write(size32); + } + else + { + if (_topLevelClassNames.Contains(_outputBuilder.Name)) { - outputBuilder.Write(size32); + _topLevelClassIsUnsafe[_outputBuilder.Name] = true; } - else - { - if (_topLevelClassNames.Contains(_outputBuilder.Name)) - { - _topLevelClassIsUnsafe[_outputBuilder.Name] = true; - } - - var parentType = null as Type; - var parentTypeIsVariableSized = false; - if (IsPrevContextStmt(out var callExpr, out _)) - { - var args = callExpr.Args; - var index = -1; - - for (var i = 0; i < args.Count; i++) - { - var arg = args[i]; - - if (IsStmtAsWritten(arg, unaryExprOrTypeTraitExpr, removeParens: true)) - { - index = i; - break; - } - } + var parentType = null as Type; + var parentTypeIsVariableSized = false; - if (index == -1) - { - AddDiagnostic(DiagnosticLevel.Error, $"Failed to locate index of '{unaryExprOrTypeTraitExpr}' in call expression. Generated bindings may be incomplete.", callExpr); - } - - var calleeDecl = callExpr.CalleeDecl; + if (IsPrevContextStmt(out var callExpr, out _)) + { + var args = callExpr.Args; + var index = -1; - if (calleeDecl is null) - { - parentType = callExpr.Callee.Type.CanonicalType; - } - else if (calleeDecl is FunctionDecl functionDecl) - { - switch (functionDecl.Name) - { - case "memcpy": - { - parentTypeIsVariableSized = true; - break; - } - - case "memset": - { - parentTypeIsVariableSized = true; - break; - } - } + for (var i = 0; i < args.Count; i++) + { + var arg = args[i]; - parentType = functionDecl.Parameters[index].Type.CanonicalType; - } - else + if (IsStmtAsWritten(arg, unaryExprOrTypeTraitExpr, removeParens: true)) { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported callee declaration: '{calleeDecl?.DeclKindName}'. Generated bindings may be incomplete.", calleeDecl); + index = i; + break; } } - else if (IsPrevContextStmt(out var expr, out _)) - { - parentType = expr.Type.CanonicalType; - } - else if (IsPrevContextDecl(out var typeDecl, out _)) - { - parentType = typeDecl.TypeForDecl.CanonicalType; - } - else if (IsPrevContextDecl(out var valueDecl, out _)) + + if (index == -1) { - parentType = valueDecl.Type.CanonicalType; + AddDiagnostic(DiagnosticLevel.Error, $"Failed to locate index of '{unaryExprOrTypeTraitExpr}' in call expression. Generated bindings may be incomplete.", callExpr); } - var needsCast = false; - var typeName = GetRemappedTypeName(unaryExprOrTypeTraitExpr, context: null, argumentType, out _); + var calleeDecl = callExpr.CalleeDecl; - if (parentType != null) + if (calleeDecl is null) + { + parentType = callExpr.Callee.Type.CanonicalType; + } + else if (calleeDecl is FunctionDecl functionDecl) { - if ((parentType.Handle.SizeOf == 8) && IsPrevContextDecl(out var varDecl, out _)) + switch (functionDecl.Name) { - var cursorName = GetCursorName(varDecl); + case "memcpy": + { + parentTypeIsVariableSized = true; + break; + } - if (cursorName.StartsWith("ClangSharpMacro_")) + case "memset": { - cursorName = cursorName["ClangSharpMacro_".Length..]; - parentTypeIsVariableSized |= _config.WithTypes.TryGetValue(cursorName, out var remappedTypeName) && ((remappedTypeName == "int") || (remappedTypeName == "uint")); + parentTypeIsVariableSized = true; + break; } } - needsCast = parentType.Kind == CXTypeKind.CXType_UInt; - needsCast |= parentType.Kind == CXTypeKind.CXType_ULong; - needsCast &= !IsSupportedFixedSizedBufferType(typeName); - needsCast &= argumentType.CanonicalType.Kind != CXTypeKind.CXType_Enum; - needsCast |= parentTypeIsVariableSized; + parentType = functionDecl.Parameters[index].Type.CanonicalType; } - - if (needsCast) + else { - outputBuilder.Write("(uint)("); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported callee declaration: '{calleeDecl?.DeclKindName}'. Generated bindings may be incomplete.", calleeDecl); } + } + else if (IsPrevContextStmt(out var expr, out _)) + { + parentType = expr.Type.CanonicalType; + } + else if (IsPrevContextDecl(out var typeDecl, out _)) + { + parentType = typeDecl.TypeForDecl.CanonicalType; + } + else if (IsPrevContextDecl(out var valueDecl, out _)) + { + parentType = valueDecl.Type.CanonicalType; + } - outputBuilder.Write("sizeof("); - outputBuilder.Write(typeName); - outputBuilder.Write(')'); + var needsCast = false; + var typeName = GetRemappedTypeName(unaryExprOrTypeTraitExpr, context: null, argumentType, out _); - if (needsCast) + if (parentType != null) + { + if ((parentType.Handle.SizeOf == 8) && IsPrevContextDecl(out var varDecl, out _)) { - outputBuilder.Write(')'); + var cursorName = GetCursorName(varDecl); + + if (cursorName.StartsWith("ClangSharpMacro_")) + { + cursorName = cursorName["ClangSharpMacro_".Length..]; + parentTypeIsVariableSized |= _config.WithTypes.TryGetValue(cursorName, out var remappedTypeName) && ((remappedTypeName == "int") || (remappedTypeName == "uint")); + } } + + needsCast = parentType.Kind == CXTypeKind.CXType_UInt; + needsCast |= parentType.Kind == CXTypeKind.CXType_ULong; + needsCast &= !IsSupportedFixedSizedBufferType(typeName); + needsCast &= argumentType.CanonicalType.Kind != CXTypeKind.CXType_Enum; + needsCast |= parentTypeIsVariableSized; } - break; - } - case CX_UnaryExprOrTypeTrait.CX_UETT_AlignOf: - case CX_UnaryExprOrTypeTrait.CX_UETT_PreferredAlignOf: - { - if (alignment32 == alignment64) + if (needsCast) { - outputBuilder.Write(alignment32); + outputBuilder.Write("(uint)("); } - else + + outputBuilder.Write("sizeof("); + outputBuilder.Write(typeName); + outputBuilder.Write(')'); + + if (needsCast) { - outputBuilder.Write("Environment.Is64BitProcess ? "); - outputBuilder.Write(alignment64); - outputBuilder.Write(" : "); - outputBuilder.Write(alignment32); + outputBuilder.Write(')'); } - - break; } + break; + } - default: + case CX_UnaryExprOrTypeTrait.CX_UETT_AlignOf: + case CX_UnaryExprOrTypeTrait.CX_UETT_PreferredAlignOf: + { + if (alignment32 == alignment64) { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported unary or type trait expression: '{unaryExprOrTypeTraitExpr.StmtClassName}'. Generated bindings may be incomplete.", unaryExprOrTypeTraitExpr); - break; + outputBuilder.Write(alignment32); + } + else + { + outputBuilder.Write("Environment.Is64BitProcess ? "); + outputBuilder.Write(alignment64); + outputBuilder.Write(" : "); + outputBuilder.Write(alignment32); } + + break; } - StopCSharpCode(); + default: + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported unary or type trait expression: '{unaryExprOrTypeTraitExpr.StmtClassName}'. Generated bindings may be incomplete.", unaryExprOrTypeTraitExpr); + break; + } } - private void VisitUnaryOperator(UnaryOperator unaryOperator) + StopCSharpCode(); + } + + private void VisitUnaryOperator(UnaryOperator unaryOperator) + { + var outputBuilder = StartCSharpCode(); + switch (unaryOperator.Opcode) { - var outputBuilder = StartCSharpCode(); - switch (unaryOperator.Opcode) + case CX_UnaryOperatorKind.CX_UO_PostInc: + case CX_UnaryOperatorKind.CX_UO_PostDec: { - case CX_UnaryOperatorKind.CX_UO_PostInc: - case CX_UnaryOperatorKind.CX_UO_PostDec: - { - Visit(unaryOperator.SubExpr); - outputBuilder.Write(unaryOperator.OpcodeStr); - break; - } + Visit(unaryOperator.SubExpr); + outputBuilder.Write(unaryOperator.OpcodeStr); + break; + } - case CX_UnaryOperatorKind.CX_UO_PreInc: - case CX_UnaryOperatorKind.CX_UO_PreDec: - case CX_UnaryOperatorKind.CX_UO_Deref: - case CX_UnaryOperatorKind.CX_UO_Plus: - case CX_UnaryOperatorKind.CX_UO_Minus: - case CX_UnaryOperatorKind.CX_UO_Not: - { - outputBuilder.Write(unaryOperator.OpcodeStr); - Visit(unaryOperator.SubExpr); - break; - } + case CX_UnaryOperatorKind.CX_UO_PreInc: + case CX_UnaryOperatorKind.CX_UO_PreDec: + case CX_UnaryOperatorKind.CX_UO_Deref: + case CX_UnaryOperatorKind.CX_UO_Plus: + case CX_UnaryOperatorKind.CX_UO_Minus: + case CX_UnaryOperatorKind.CX_UO_Not: + { + outputBuilder.Write(unaryOperator.OpcodeStr); + Visit(unaryOperator.SubExpr); + break; + } + + case CX_UnaryOperatorKind.CX_UO_LNot: + { + var subExpr = GetExprAsWritten(unaryOperator.SubExpr, removeParens: true); + var canonicalType = subExpr.Type.CanonicalType; - case CX_UnaryOperatorKind.CX_UO_LNot: + if (canonicalType.IsIntegerType && (canonicalType.Kind != CXTypeKind.CXType_Bool)) { - var subExpr = GetExprAsWritten(unaryOperator.SubExpr, removeParens: true); - var canonicalType = subExpr.Type.CanonicalType; + var needsParens = IsStmtAsWritten(subExpr, out _); - if (canonicalType.IsIntegerType && (canonicalType.Kind != CXTypeKind.CXType_Bool)) + if (needsParens) { - var needsParens = IsStmtAsWritten(subExpr, out _); - - if (needsParens) - { - outputBuilder.Write('('); - } - Visit(subExpr); - - if (needsParens) - { - outputBuilder.Write(')'); - } - outputBuilder.Write(" == 0"); + outputBuilder.Write('('); } - else if (canonicalType is PointerType or ReferenceType) - { - var needsParens = !IsPrevContextStmt(out _, out _, preserveParen: true) && - !IsPrevContextStmt(out _, out _, preserveParen: true); - - if (needsParens) - { - outputBuilder.Write('('); - } - - Visit(subExpr); - outputBuilder.Write(" == null"); + Visit(subExpr); - if (needsParens) - { - outputBuilder.Write(')'); - } - } - else + if (needsParens) { - outputBuilder.Write(unaryOperator.OpcodeStr); - Visit(unaryOperator.SubExpr); + outputBuilder.Write(')'); } - break; + outputBuilder.Write(" == 0"); } - - case CX_UnaryOperatorKind.CX_UO_AddrOf: + else if (canonicalType is PointerType or ReferenceType) { - if ((unaryOperator.SubExpr is DeclRefExpr declRefExpr) && (declRefExpr.Decl.Type is LValueReferenceType)) + var needsParens = !IsPrevContextStmt(out _, out _, preserveParen: true) && + !IsPrevContextStmt(out _, out _, preserveParen: true); + + if (needsParens) { - Visit(unaryOperator.SubExpr); + outputBuilder.Write('('); } - else + + Visit(subExpr); + outputBuilder.Write(" == null"); + + if (needsParens) { - outputBuilder.Write(unaryOperator.OpcodeStr); - Visit(unaryOperator.SubExpr); + outputBuilder.Write(')'); } - break; } + else + { + outputBuilder.Write(unaryOperator.OpcodeStr); + Visit(unaryOperator.SubExpr); + } + break; + } - default: + case CX_UnaryOperatorKind.CX_UO_AddrOf: + { + if ((unaryOperator.SubExpr is DeclRefExpr declRefExpr) && (declRefExpr.Decl.Type is LValueReferenceType)) { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported unary operator opcode: '{unaryOperator.OpcodeStr}'. Generated bindings may be incomplete.", unaryOperator); - break; + Visit(unaryOperator.SubExpr); + } + else + { + outputBuilder.Write(unaryOperator.OpcodeStr); + Visit(unaryOperator.SubExpr); } + break; } - StopCSharpCode(); + default: + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported unary operator opcode: '{unaryOperator.OpcodeStr}'. Generated bindings may be incomplete.", unaryOperator); + break; + } } - private void VisitOffsetOfExpr(OffsetOfExpr offsetOfExpr) - { - var outputBuilder = StartCSharpCode(); + StopCSharpCode(); + } - outputBuilder.AddUsingDirective("System.Runtime.InteropServices"); - outputBuilder.Write("Marshal.OffsetOf<"); - outputBuilder.Write(GetRemappedTypeName(offsetOfExpr, context: null, offsetOfExpr.TypeSourceInfoType, out var _)); - outputBuilder.Write(">(\""); - Visit(offsetOfExpr.Referenced ?? offsetOfExpr.CursorChildren[1]); - outputBuilder.Write("\")"); + private void VisitOffsetOfExpr(OffsetOfExpr offsetOfExpr) + { + var outputBuilder = StartCSharpCode(); - StopCSharpCode(); - } + outputBuilder.AddUsingDirective("System.Runtime.InteropServices"); + outputBuilder.Write("Marshal.OffsetOf<"); + outputBuilder.Write(GetRemappedTypeName(offsetOfExpr, context: null, offsetOfExpr.TypeSourceInfoType, out var _)); + outputBuilder.Write(">(\""); + Visit(offsetOfExpr.Referenced ?? offsetOfExpr.CursorChildren[1]); + outputBuilder.Write("\")"); - private void VisitUnresolvedLookupExpr(UnresolvedLookupExpr unresolvedLookupExpr) - { - var outputBuilder = StartCSharpCode(); - outputBuilder.Write(GetRemappedName(unresolvedLookupExpr.Name, unresolvedLookupExpr, tryRemapOperatorName: false, out _, skipUsing: true)); - StopCSharpCode(); - } + StopCSharpCode(); + } - private void VisitUnresolvedMemberExpr(UnresolvedMemberExpr unresolvedMemberExpr) + private void VisitUnresolvedLookupExpr(UnresolvedLookupExpr unresolvedLookupExpr) + { + var outputBuilder = StartCSharpCode(); + outputBuilder.Write(GetRemappedName(unresolvedLookupExpr.Name, unresolvedLookupExpr, tryRemapOperatorName: false, out _, skipUsing: true)); + StopCSharpCode(); + } + + private void VisitUnresolvedMemberExpr(UnresolvedMemberExpr unresolvedMemberExpr) + { + var outputBuilder = StartCSharpCode(); + if (!unresolvedMemberExpr.IsImplicitAccess) { - var outputBuilder = StartCSharpCode(); - if (!unresolvedMemberExpr.IsImplicitAccess) - { - Visit(unresolvedMemberExpr.Base); + Visit(unresolvedMemberExpr.Base); - var type = unresolvedMemberExpr.Base is CXXThisExpr - ? null - : unresolvedMemberExpr.Base is DeclRefExpr declRefExpr ? declRefExpr.Decl.Type.CanonicalType : unresolvedMemberExpr.Base.Type.CanonicalType; + var type = unresolvedMemberExpr.Base is CXXThisExpr + ? null + : unresolvedMemberExpr.Base is DeclRefExpr declRefExpr ? declRefExpr.Decl.Type.CanonicalType : unresolvedMemberExpr.Base.Type.CanonicalType; - if (type is not null and (PointerType or ReferenceType)) - { - outputBuilder.Write("->"); - } - else - { - outputBuilder.Write('.'); - } + if (type is not null and (PointerType or ReferenceType)) + { + outputBuilder.Write("->"); + } + else + { + outputBuilder.Write('.'); } - - outputBuilder.Write(GetRemappedName(unresolvedMemberExpr.MemberName, unresolvedMemberExpr, tryRemapOperatorName: true, out _, skipUsing: true)); - StopCSharpCode(); } - private void VisitWhileStmt(WhileStmt whileStmt) - { - var outputBuilder = StartCSharpCode(); + outputBuilder.Write(GetRemappedName(unresolvedMemberExpr.MemberName, unresolvedMemberExpr, tryRemapOperatorName: true, out _, skipUsing: true)); + StopCSharpCode(); + } + + private void VisitWhileStmt(WhileStmt whileStmt) + { + var outputBuilder = StartCSharpCode(); - outputBuilder.Write("while ("); + outputBuilder.Write("while ("); - Visit(whileStmt.Cond); + Visit(whileStmt.Cond); - outputBuilder.WriteLine(')'); + outputBuilder.WriteLine(')'); - VisitBody(whileStmt.Body); + VisitBody(whileStmt.Body); - StopCSharpCode(); - } + StopCSharpCode(); } } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index 3cc2039d..23fa78a6 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -14,385 +14,601 @@ using ClangSharp.Interop; using ClangSharp.XML; -namespace ClangSharp +namespace ClangSharp; + +public sealed partial class PInvokeGenerator : IDisposable { - public sealed partial class PInvokeGenerator : IDisposable + private const int DefaultStreamWriterBufferSize = 1024; + private static readonly Encoding s_defaultStreamWriterEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); + private static readonly Regex s_needsSystemSupportRegex = new Regex(@"\b(?:Guid|IntPtr|UIntPtr)\b", RegexOptions.Compiled); + + private const string ExpectedClangVersion = "version 14.0"; + private const string ExpectedClangSharpVersion = "version 14.0"; + + private readonly CXIndex _index; + private readonly OutputBuilderFactory _outputBuilderFactory; + private readonly Func _outputStreamFactory; + private readonly StringBuilder _fileContentsBuilder; + private readonly HashSet _visitedFiles; + private readonly List _diagnostics; + private readonly LinkedList<(Cursor Cursor, object UserData)> _context; + private readonly Dictionary _uuidsToGenerate; + private readonly HashSet _generatedUuids; + private readonly PInvokeGeneratorConfiguration _config; + private readonly Dictionary _cursorNames; + private readonly Dictionary<(NamedDecl namedDecl, bool truncateForFunctionParameters), string> _cursorQualifiedNames; + private readonly Dictionary<(Cursor cursor, Cursor context, Type type), (string typeName, string nativeTypeName)> _typeNames; + private readonly Dictionary> _allValidNameRemappings; + private readonly Dictionary> _traversedValidNameRemappings; + private readonly Dictionary _overloadIndices; + private readonly Dictionary _isExcluded; + private readonly Dictionary _topLevelClassHasGuidMember; + private readonly Dictionary _topLevelClassIsUnsafe; + private readonly Dictionary> _topLevelClassUsings; + private readonly Dictionary> _topLevelClassAttributes; + private readonly HashSet _topLevelClassNames; + private readonly HashSet _usedRemappings; + + private string _filePath; + private string[] _clangCommandLineArgs; + private CXTranslationUnit_Flags _translationFlags; + private string _currentClass; + private string _currentNamespace; + + private IOutputBuilder _outputBuilder; + private CSharpOutputBuilder _testOutputBuilder; + private CSharpOutputBuilder _stmtOutputBuilder; + private CSharpOutputBuilder _testStmtOutputBuilder; + private int _stmtOutputBuilderUsers; + private int _testStmtOutputBuilderUsers; + private int _outputBuilderUsers; + private CXXRecordDecl _cxxRecordDeclContext; + private bool _disposed; + + public PInvokeGenerator(PInvokeGeneratorConfiguration config, Func outputStreamFactory = null) { - private const int DefaultStreamWriterBufferSize = 1024; - private static readonly Encoding s_defaultStreamWriterEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true); - private static readonly Regex s_needsSystemSupportRegex = new Regex(@"\b(?:Guid|IntPtr|UIntPtr)\b", RegexOptions.Compiled); - - private const string ExpectedClangVersion = "version 14.0"; - private const string ExpectedClangSharpVersion = "version 14.0"; - - private readonly CXIndex _index; - private readonly OutputBuilderFactory _outputBuilderFactory; - private readonly Func _outputStreamFactory; - private readonly StringBuilder _fileContentsBuilder; - private readonly HashSet _visitedFiles; - private readonly List _diagnostics; - private readonly LinkedList<(Cursor Cursor, object UserData)> _context; - private readonly Dictionary _uuidsToGenerate; - private readonly HashSet _generatedUuids; - private readonly PInvokeGeneratorConfiguration _config; - private readonly Dictionary _cursorNames; - private readonly Dictionary<(NamedDecl namedDecl, bool truncateForFunctionParameters), string> _cursorQualifiedNames; - private readonly Dictionary<(Cursor cursor, Cursor context, Type type), (string typeName, string nativeTypeName)> _typeNames; - private readonly Dictionary> _allValidNameRemappings; - private readonly Dictionary> _traversedValidNameRemappings; - private readonly Dictionary _overloadIndices; - private readonly Dictionary _isExcluded; - private readonly Dictionary _topLevelClassHasGuidMember; - private readonly Dictionary _topLevelClassIsUnsafe; - private readonly Dictionary> _topLevelClassUsings; - private readonly Dictionary> _topLevelClassAttributes; - private readonly HashSet _topLevelClassNames; - private readonly HashSet _usedRemappings; - - private string _filePath; - private string[] _clangCommandLineArgs; - private CXTranslationUnit_Flags _translationFlags; - private string _currentClass; - private string _currentNamespace; + if (config is null) + { + throw new ArgumentNullException(nameof(config)); + } - private IOutputBuilder _outputBuilder; - private CSharpOutputBuilder _testOutputBuilder; - private CSharpOutputBuilder _stmtOutputBuilder; - private CSharpOutputBuilder _testStmtOutputBuilder; - private int _stmtOutputBuilderUsers; - private int _testStmtOutputBuilderUsers; - private int _outputBuilderUsers; - private CXXRecordDecl _cxxRecordDeclContext; - private bool _disposed; + var clangVersion = clang.getClangVersion().ToString(); - public PInvokeGenerator(PInvokeGeneratorConfiguration config, Func outputStreamFactory = null) + if (!clangVersion.Contains(ExpectedClangVersion)) { - if (config is null) - { - throw new ArgumentNullException(nameof(config)); - } - - var clangVersion = clang.getClangVersion().ToString(); + throw new InvalidOperationException($"Invalid libClang version. Returned string '{clangVersion}' does not contain '{ExpectedClangVersion}'"); + } - if (!clangVersion.Contains(ExpectedClangVersion)) - { - throw new InvalidOperationException($"Invalid libClang version. Returned string '{clangVersion}' does not contain '{ExpectedClangVersion}'"); - } + var clangSharpVersion = clangsharp.getVersion().ToString(); - var clangSharpVersion = clangsharp.getVersion().ToString(); + if (!clangSharpVersion.Contains(ExpectedClangSharpVersion)) + { + throw new InvalidOperationException($"Invalid libClang version. Returned string '{clangSharpVersion}' does not contain '{ExpectedClangSharpVersion}'"); + } - if (!clangSharpVersion.Contains(ExpectedClangSharpVersion)) - { - throw new InvalidOperationException($"Invalid libClang version. Returned string '{clangSharpVersion}' does not contain '{ExpectedClangSharpVersion}'"); - } + _index = CXIndex.Create(); + _outputBuilderFactory = new OutputBuilderFactory(config); + _outputStreamFactory = outputStreamFactory ?? ((path) => { + var directoryPath = Path.GetDirectoryName(path); + _ = Directory.CreateDirectory(directoryPath); + return new FileStream(path, FileMode.Create); + }); + _fileContentsBuilder = new StringBuilder(); + _visitedFiles = new HashSet(); + _diagnostics = new List(); + _context = new LinkedList<(Cursor, object)>(); + _config = config; + _uuidsToGenerate = new Dictionary(); + _generatedUuids = new HashSet(); + _cursorNames = new Dictionary(); + _cursorQualifiedNames = new Dictionary<(NamedDecl, bool), string>(); + _typeNames = new Dictionary<(Cursor, Cursor, Type), (string, string)>(); + _allValidNameRemappings = new Dictionary>() { + ["intptr_t"] = new HashSet() { "IntPtr", "nint" }, + ["ptrdiff_t"] = new HashSet() { "IntPtr", "nint" }, + ["size_t"] = new HashSet() { "UIntPtr", "nuint" }, + ["uintptr_t"] = new HashSet() { "UIntPtr", "nuint" }, + ["_GUID"] = new HashSet() { "Guid" }, + }; + _traversedValidNameRemappings = new Dictionary>(); + _overloadIndices = new Dictionary(); + _isExcluded = new Dictionary(); + _topLevelClassHasGuidMember = new Dictionary(); + _topLevelClassIsUnsafe = new Dictionary(); + _topLevelClassNames = new HashSet(); + _topLevelClassAttributes = new Dictionary>(); + _topLevelClassUsings = new Dictionary>(); + _usedRemappings = new HashSet(); + } - _index = CXIndex.Create(); - _outputBuilderFactory = new OutputBuilderFactory(config); - _outputStreamFactory = outputStreamFactory ?? ((path) => { - var directoryPath = Path.GetDirectoryName(path); - _ = Directory.CreateDirectory(directoryPath); - return new FileStream(path, FileMode.Create); - }); - _fileContentsBuilder = new StringBuilder(); - _visitedFiles = new HashSet(); - _diagnostics = new List(); - _context = new LinkedList<(Cursor, object)>(); - _config = config; - _uuidsToGenerate = new Dictionary(); - _generatedUuids = new HashSet(); - _cursorNames = new Dictionary(); - _cursorQualifiedNames = new Dictionary<(NamedDecl, bool), string>(); - _typeNames = new Dictionary<(Cursor, Cursor, Type), (string, string)>(); - _allValidNameRemappings = new Dictionary>() { - ["intptr_t"] = new HashSet() { "IntPtr", "nint" }, - ["ptrdiff_t"] = new HashSet() { "IntPtr", "nint" }, - ["size_t"] = new HashSet() { "UIntPtr", "nuint" }, - ["uintptr_t"] = new HashSet() { "UIntPtr", "nuint" }, - ["_GUID"] = new HashSet() { "Guid" }, - }; - _traversedValidNameRemappings = new Dictionary>(); - _overloadIndices = new Dictionary(); - _isExcluded = new Dictionary(); - _topLevelClassHasGuidMember = new Dictionary(); - _topLevelClassIsUnsafe = new Dictionary(); - _topLevelClassNames = new HashSet(); - _topLevelClassAttributes = new Dictionary>(); - _topLevelClassUsings = new Dictionary>(); - _usedRemappings = new HashSet(); - } + ~PInvokeGenerator() + { + Dispose(isDisposing: false); + } - ~PInvokeGenerator() - { - Dispose(isDisposing: false); - } + public PInvokeGeneratorConfiguration Config => _config; - public PInvokeGeneratorConfiguration Config => _config; + public (Cursor Cursor, object UserData) CurrentContext => _context.Last.Value; - public (Cursor Cursor, object UserData) CurrentContext => _context.Last.Value; + public IReadOnlyList Diagnostics => _diagnostics; - public IReadOnlyList Diagnostics => _diagnostics; + public string FilePath => _filePath; - public string FilePath => _filePath; + public CXIndex IndexHandle => _index; - public CXIndex IndexHandle => _index; + public (Cursor Cursor, object UserData) PreviousContext => _context.Last.Previous.Value; - public (Cursor Cursor, object UserData) PreviousContext => _context.Last.Previous.Value; + public void Close() + { + Stream stream = null; + var methodClassOutputBuilders = new Dictionary(); + var methodClassTestOutputBuilders = new Dictionary(); + var emitNamespaceDeclaration = true; + var leaveStreamOpen = false; - public void Close() + foreach (var foundUuid in _uuidsToGenerate) { - Stream stream = null; - var methodClassOutputBuilders = new Dictionary(); - var methodClassTestOutputBuilders = new Dictionary(); - var emitNamespaceDeclaration = true; - var leaveStreamOpen = false; + var iidName = foundUuid.Key; - foreach (var foundUuid in _uuidsToGenerate) + if (_generatedUuids.Contains(iidName) || _config.ExcludedNames.Contains(iidName)) { - var iidName = foundUuid.Key; - - if (_generatedUuids.Contains(iidName) || _config.ExcludedNames.Contains(iidName)) - { - continue; - } - - StartUsingOutputBuilder(GetClass(iidName)); - _outputBuilder.WriteIid(iidName, foundUuid.Value); - StopUsingOutputBuilder(); + continue; } - if (!_config.GenerateMultipleFiles) - { - var outputPath = _config.OutputLocation; - stream = _outputStreamFactory(outputPath); - leaveStreamOpen = true; + StartUsingOutputBuilder(GetClass(iidName)); + _outputBuilder.WriteIid(iidName, foundUuid.Value); + StopUsingOutputBuilder(); + } + + if (!_config.GenerateMultipleFiles) + { + var outputPath = _config.OutputLocation; + stream = _outputStreamFactory(outputPath); + leaveStreamOpen = true; - var usingDirectives = Enumerable.Empty(); - var staticUsingDirectives = Enumerable.Empty(); - var hasAnyContents = false; + var usingDirectives = Enumerable.Empty(); + var staticUsingDirectives = Enumerable.Empty(); + var hasAnyContents = false; - foreach (var outputBuilder in _outputBuilderFactory.OutputBuilders) + foreach (var outputBuilder in _outputBuilderFactory.OutputBuilders) + { + if (outputBuilder is CSharpOutputBuilder csharpOutputBuilder) { - if (outputBuilder is CSharpOutputBuilder csharpOutputBuilder) - { - usingDirectives = usingDirectives.Concat(csharpOutputBuilder.UsingDirectives); - staticUsingDirectives = staticUsingDirectives.Concat(csharpOutputBuilder.StaticUsingDirectives); - hasAnyContents = csharpOutputBuilder.Contents.Any(); - } - else if (outputBuilder is XmlOutputBuilder xmlOutputBuilder) - { - hasAnyContents = xmlOutputBuilder.Contents.Any(); - } + usingDirectives = usingDirectives.Concat(csharpOutputBuilder.UsingDirectives); + staticUsingDirectives = staticUsingDirectives.Concat(csharpOutputBuilder.StaticUsingDirectives); + hasAnyContents = csharpOutputBuilder.Contents.Any(); + } + else if (outputBuilder is XmlOutputBuilder xmlOutputBuilder) + { + hasAnyContents = xmlOutputBuilder.Contents.Any(); } + } + + usingDirectives = usingDirectives.Distinct() + .OrderBy((usingDirective) => usingDirective); - usingDirectives = usingDirectives.Distinct() - .OrderBy((usingDirective) => usingDirective); + staticUsingDirectives = staticUsingDirectives.Distinct() + .OrderBy((staticUsingDirective) => staticUsingDirective); - staticUsingDirectives = staticUsingDirectives.Distinct() - .OrderBy((staticUsingDirective) => staticUsingDirective); + usingDirectives = usingDirectives.Concat(staticUsingDirectives); - usingDirectives = usingDirectives.Concat(staticUsingDirectives); + if (hasAnyContents) + { + using var sw = new StreamWriter(stream, s_defaultStreamWriterEncoding, DefaultStreamWriterBufferSize, leaveStreamOpen); + sw.NewLine = "\n"; - if (hasAnyContents) + if (_config.OutputMode == PInvokeGeneratorOutputMode.CSharp) { - using var sw = new StreamWriter(stream, s_defaultStreamWriterEncoding, DefaultStreamWriterBufferSize, leaveStreamOpen); - sw.NewLine = "\n"; + if (_config.HeaderText != string.Empty) + { + sw.WriteLine(_config.HeaderText); + } - if (_config.OutputMode == PInvokeGeneratorOutputMode.CSharp) + if (usingDirectives.Any()) { - if (_config.HeaderText != string.Empty) + foreach (var usingDirective in usingDirectives) { - sw.WriteLine(_config.HeaderText); + sw.Write("using "); + sw.Write(usingDirective); + sw.WriteLine(';'); } - if (usingDirectives.Any()) - { - foreach (var usingDirective in usingDirectives) - { - sw.Write("using "); - sw.Write(usingDirective); - sw.WriteLine(';'); - } - - sw.WriteLine(); - } + sw.WriteLine(); } - else if (_config.OutputMode == PInvokeGeneratorOutputMode.Xml) + } + else if (_config.OutputMode == PInvokeGeneratorOutputMode.Xml) + { + sw.WriteLine(""); + sw.WriteLine(""); + + if (_config.HeaderText != string.Empty) { - sw.WriteLine(""); - sw.WriteLine(""); + sw.WriteLine(" "); if (_config.HeaderText != string.Empty) { - sw.WriteLine(" "); - - if (_config.HeaderText != string.Empty) + foreach (var ln in _config.HeaderText.Split('\n')) { - foreach (var ln in _config.HeaderText.Split('\n')) - { - sw.Write(" "); - sw.WriteLine(ln); - } + sw.Write(" "); + sw.WriteLine(ln); } - - sw.WriteLine(" "); } + + sw.WriteLine(" "); } } } + } - foreach (var outputBuilder in _outputBuilderFactory.OutputBuilders) - { - var outputPath = outputBuilder.IsTestOutput ? _config.TestOutputLocation : _config.OutputLocation; - var isMethodClass = _topLevelClassNames.Contains(outputBuilder.Name); + foreach (var outputBuilder in _outputBuilderFactory.OutputBuilders) + { + var outputPath = outputBuilder.IsTestOutput ? _config.TestOutputLocation : _config.OutputLocation; + var isMethodClass = _topLevelClassNames.Contains(outputBuilder.Name); - if (_config.GenerateMultipleFiles) + if (_config.GenerateMultipleFiles) + { + outputPath = Path.Combine(outputPath, $"{outputBuilder.Name}{outputBuilder.Extension}"); + stream = _outputStreamFactory(outputPath); + emitNamespaceDeclaration = true; + } + else if (isMethodClass) + { + if (outputBuilder.IsTestOutput) { - outputPath = Path.Combine(outputPath, $"{outputBuilder.Name}{outputBuilder.Extension}"); - stream = _outputStreamFactory(outputPath); - emitNamespaceDeclaration = true; + methodClassTestOutputBuilders.Add(outputBuilder.Name, outputBuilder); } - else if (isMethodClass) + else { - if (outputBuilder.IsTestOutput) - { - methodClassTestOutputBuilders.Add(outputBuilder.Name, outputBuilder); - } - else - { - methodClassOutputBuilders.Add(outputBuilder.Name, outputBuilder); - } - continue; + methodClassOutputBuilders.Add(outputBuilder.Name, outputBuilder); } + continue; + } + + CloseOutputBuilder(stream, outputBuilder, isMethodClass, leaveStreamOpen, emitNamespaceDeclaration); + emitNamespaceDeclaration = false; + } + + if (_config.GenerateHelperTypes && (_config.OutputMode == PInvokeGeneratorOutputMode.CSharp)) + { + _ = Directory.CreateDirectory(_config.OutputLocation); + + GenerateNativeInheritanceAttribute(this); + GenerateNativeTypeNameAttribute(this); + GenerateSetsLastSystemErrorAttribute(this); + GenerateVtblIndexAttribute(this); + GenerateTransparentStructs(this); + } + + if (leaveStreamOpen && _outputBuilderFactory.OutputBuilders.Any()) + { + foreach (var entry in methodClassOutputBuilders) + { + var hasGuidMember = _config.GenerateGuidMember && _config.GeneratePreviewCode; + hasGuidMember &= _uuidsToGenerate.ContainsKey(entry.Value.Name) || _generatedUuids.Contains(entry.Value.Name); - CloseOutputBuilder(stream, outputBuilder, isMethodClass, leaveStreamOpen, emitNamespaceDeclaration); - emitNamespaceDeclaration = false; + CloseOutputBuilder(stream, entry.Value, isMethodClass: true, leaveStreamOpen, emitNamespaceDeclaration); } - if (_config.GenerateHelperTypes && (_config.OutputMode == PInvokeGeneratorOutputMode.CSharp)) + foreach (var entry in methodClassTestOutputBuilders) { - _ = Directory.CreateDirectory(_config.OutputLocation); + CloseOutputBuilder(stream, entry.Value, isMethodClass: true, leaveStreamOpen, emitNamespaceDeclaration); + } + + using var sw = new StreamWriter(stream, s_defaultStreamWriterEncoding, DefaultStreamWriterBufferSize, leaveStreamOpen); + sw.NewLine = "\n"; - GenerateNativeInheritanceAttribute(this); - GenerateNativeTypeNameAttribute(this); - GenerateSetsLastSystemErrorAttribute(this); - GenerateVtblIndexAttribute(this); - GenerateTransparentStructs(this); + if (_config.OutputMode == PInvokeGeneratorOutputMode.CSharp) + { + sw.WriteLine('}'); } + else if (_config.OutputMode == PInvokeGeneratorOutputMode.Xml) + { + sw.WriteLine(" "); + sw.WriteLine(""); + } + } + + _context.Clear(); + _diagnostics.Clear(); + _ = _fileContentsBuilder.Clear(); + _generatedUuids.Clear(); + _outputBuilderFactory.Clear(); + _uuidsToGenerate.Clear(); + _visitedFiles.Clear(); - if (leaveStreamOpen && _outputBuilderFactory.OutputBuilders.Any()) + static void GenerateNativeInheritanceAttribute(PInvokeGenerator generator) + { + var config = generator.Config; + var outputPath = Path.Combine(config.OutputLocation, "NativeInheritanceAttribute.cs"); + + using var sw = new StreamWriter(outputPath); + sw.NewLine = "\n"; + + if (config.HeaderText != string.Empty) { - foreach (var entry in methodClassOutputBuilders) - { - var hasGuidMember = _config.GenerateGuidMember && _config.GeneratePreviewCode; - hasGuidMember &= _uuidsToGenerate.ContainsKey(entry.Value.Name) || _generatedUuids.Contains(entry.Value.Name); + sw.WriteLine(config.HeaderText); + } - CloseOutputBuilder(stream, entry.Value, isMethodClass: true, leaveStreamOpen, emitNamespaceDeclaration); - } + var indentString = " "; - foreach (var entry in methodClassTestOutputBuilders) - { - CloseOutputBuilder(stream, entry.Value, isMethodClass: true, leaveStreamOpen, emitNamespaceDeclaration); - } + sw.WriteLine("using System;"); + sw.WriteLine("using System.Diagnostics;"); + sw.WriteLine(); - using var sw = new StreamWriter(stream, s_defaultStreamWriterEncoding, DefaultStreamWriterBufferSize, leaveStreamOpen); - sw.NewLine = "\n"; + sw.Write("namespace "); + sw.Write(generator.GetNamespace("NativeInheritanceAttribute")); - if (_config.OutputMode == PInvokeGeneratorOutputMode.CSharp) - { - sw.WriteLine('}'); - } - else if (_config.OutputMode == PInvokeGeneratorOutputMode.Xml) - { - sw.WriteLine(" "); - sw.WriteLine(""); - } + if (generator.Config.GenerateFileScopedNamespaces) + { + sw.WriteLine(';'); + sw.WriteLine(); + indentString = ""; + } + else + { + sw.WriteLine(); + sw.WriteLine('{'); + } + + sw.Write(indentString); + sw.WriteLine("/// Defines the base type of a struct as it was in the native signature."); + sw.Write(indentString); + sw.WriteLine("[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]"); + sw.Write(indentString); + sw.WriteLine("[Conditional(\"DEBUG\")]"); + sw.Write(indentString); + sw.WriteLine("internal sealed partial class NativeInheritanceAttribute : Attribute"); + sw.Write(indentString); + sw.WriteLine('{'); + sw.Write(indentString); + sw.WriteLine(" private readonly string _name;"); + sw.WriteLine(); + sw.Write(indentString); + sw.WriteLine(" /// Initializes a new instance of the class."); + sw.Write(indentString); + sw.WriteLine(" /// The name of the base type that was inherited from in the native signature."); + sw.Write(indentString); + sw.WriteLine(" public NativeInheritanceAttribute(string name)"); + sw.Write(indentString); + sw.WriteLine(" {"); + sw.Write(indentString); + sw.WriteLine(" _name = name;"); + sw.Write(indentString); + sw.WriteLine(" }"); + sw.WriteLine(); + sw.Write(indentString); + sw.WriteLine(" /// Gets the name of the base type that was inherited from in the native signature."); + sw.Write(indentString); + sw.WriteLine(" public string Name => _name;"); + sw.Write(indentString); + sw.WriteLine('}'); + + if (!generator.Config.GenerateFileScopedNamespaces) + { + sw.WriteLine('}'); } + } + + static void GenerateNativeTypeNameAttribute(PInvokeGenerator generator) + { + var config = generator.Config; + var outputPath = Path.Combine(config.OutputLocation, "NativeTypeNameAttribute.cs"); - _context.Clear(); - _diagnostics.Clear(); - _ = _fileContentsBuilder.Clear(); - _generatedUuids.Clear(); - _outputBuilderFactory.Clear(); - _uuidsToGenerate.Clear(); - _visitedFiles.Clear(); + using var sw = new StreamWriter(outputPath); + sw.NewLine = "\n"; - static void GenerateNativeInheritanceAttribute(PInvokeGenerator generator) + if (config.HeaderText != string.Empty) { - var config = generator.Config; - var outputPath = Path.Combine(config.OutputLocation, "NativeInheritanceAttribute.cs"); + sw.WriteLine(config.HeaderText); + } - using var sw = new StreamWriter(outputPath); - sw.NewLine = "\n"; + var indentString = " "; - if (config.HeaderText != string.Empty) - { - sw.WriteLine(config.HeaderText); - } + sw.WriteLine("using System;"); + sw.WriteLine("using System.Diagnostics;"); + sw.WriteLine(); - var indentString = " "; + sw.Write("namespace "); + sw.Write(generator.GetNamespace("NativeTypeNameAttribute")); - sw.WriteLine("using System;"); - sw.WriteLine("using System.Diagnostics;"); + if (generator.Config.GenerateFileScopedNamespaces) + { + sw.WriteLine(';'); + sw.WriteLine(); + indentString = ""; + } + else + { sw.WriteLine(); + sw.WriteLine('{'); + } - sw.Write("namespace "); - sw.Write(generator.GetNamespace("NativeInheritanceAttribute")); + sw.Write(indentString); + sw.WriteLine("/// Defines the type of a member as it was used in the native signature."); + sw.Write(indentString); + sw.WriteLine("[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)]"); + sw.Write(indentString); + sw.WriteLine("[Conditional(\"DEBUG\")]"); + sw.Write(indentString); + sw.WriteLine("internal sealed partial class NativeTypeNameAttribute : Attribute"); + sw.Write(indentString); + sw.WriteLine('{'); + sw.Write(indentString); + sw.WriteLine(" private readonly string _name;"); + sw.WriteLine(); + sw.Write(indentString); + sw.WriteLine(" /// Initializes a new instance of the class."); + sw.Write(indentString); + sw.WriteLine(" /// The name of the type that was used in the native signature."); + sw.Write(indentString); + sw.WriteLine(" public NativeTypeNameAttribute(string name)"); + sw.Write(indentString); + sw.WriteLine(" {"); + sw.Write(indentString); + sw.WriteLine(" _name = name;"); + sw.Write(indentString); + sw.WriteLine(" }"); + sw.WriteLine(); + sw.Write(indentString); + sw.WriteLine(" /// Gets the name of the type that was used in the native signature."); + sw.Write(indentString); + sw.WriteLine(" public string Name => _name;"); + sw.Write(indentString); + sw.WriteLine('}'); + + if (!generator.Config.GenerateFileScopedNamespaces) + { + sw.WriteLine('}'); + } + } - if (generator.Config.GenerateFileScopedNamespaces) - { - sw.WriteLine(';'); - sw.WriteLine(); - indentString = ""; - } - else - { - sw.WriteLine(); - sw.WriteLine('{'); - } + static void GenerateSetsLastSystemErrorAttribute(PInvokeGenerator generator) + { + var config = generator.Config; + var outputPath = Path.Combine(config.OutputLocation, "SetsLastSystemErrorAttribute.cs"); - sw.Write(indentString); - sw.WriteLine("/// Defines the base type of a struct as it was in the native signature."); - sw.Write(indentString); - sw.WriteLine("[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]"); - sw.Write(indentString); - sw.WriteLine("[Conditional(\"DEBUG\")]"); - sw.Write(indentString); - sw.WriteLine("internal sealed partial class NativeInheritanceAttribute : Attribute"); - sw.Write(indentString); - sw.WriteLine('{'); - sw.Write(indentString); - sw.WriteLine(" private readonly string _name;"); + using var sw = new StreamWriter(outputPath); + sw.NewLine = "\n"; + + if (config.HeaderText != string.Empty) + { + sw.WriteLine(config.HeaderText); + } + + var indentString = " "; + + sw.WriteLine("using System;"); + sw.WriteLine("using System.Diagnostics;"); + sw.WriteLine("using System.Runtime.InteropServices;"); + sw.WriteLine(); + + sw.Write("namespace "); + sw.Write(generator.GetNamespace("SetsLastSystemErrorAttribute")); + + if (generator.Config.GenerateFileScopedNamespaces) + { + sw.WriteLine(';'); sw.WriteLine(); - sw.Write(indentString); - sw.WriteLine(" /// Initializes a new instance of the class."); - sw.Write(indentString); - sw.WriteLine(" /// The name of the base type that was inherited from in the native signature."); - sw.Write(indentString); - sw.WriteLine(" public NativeInheritanceAttribute(string name)"); - sw.Write(indentString); - sw.WriteLine(" {"); - sw.Write(indentString); - sw.WriteLine(" _name = name;"); - sw.Write(indentString); - sw.WriteLine(" }"); + indentString = ""; + } + else + { sw.WriteLine(); - sw.Write(indentString); - sw.WriteLine(" /// Gets the name of the base type that was inherited from in the native signature."); - sw.Write(indentString); - sw.WriteLine(" public string Name => _name;"); - sw.Write(indentString); + sw.WriteLine('{'); + } + + sw.Write(indentString); + sw.WriteLine("/// Specifies that the given method sets the last system error and it can be retrieved via ."); + sw.Write(indentString); + sw.WriteLine("[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]"); + sw.Write(indentString); + sw.WriteLine("[Conditional(\"DEBUG\")]"); + sw.Write(indentString); + sw.WriteLine("internal sealed partial class SetsLastSystemErrorAttribute : Attribute"); + sw.Write(indentString); + sw.WriteLine('{'); + sw.Write(indentString); + sw.WriteLine(" /// Initializes a new instance of the class."); + sw.Write(indentString); + sw.WriteLine(" public SetsLastSystemErrorAttribute()"); + sw.Write(indentString); + sw.WriteLine(" {"); + sw.Write(indentString); + sw.WriteLine(" }"); + sw.Write(indentString); + sw.WriteLine('}'); + + if (!generator.Config.GenerateFileScopedNamespaces) + { sw.WriteLine('}'); + } + } - if (!generator.Config.GenerateFileScopedNamespaces) - { - sw.WriteLine('}'); - } + static void GenerateVtblIndexAttribute(PInvokeGenerator generator) + { + var config = generator.Config; + var outputPath = Path.Combine(config.OutputLocation, "VtblIndexAttribute.cs"); + + using var sw = new StreamWriter(outputPath); + sw.NewLine = "\n"; + + if (config.HeaderText != string.Empty) + { + sw.WriteLine(config.HeaderText); + } + + var indentString = " "; + + sw.WriteLine("using System;"); + sw.WriteLine("using System.Diagnostics;"); + sw.WriteLine(); + + sw.Write("namespace "); + sw.Write(generator.GetNamespace("VtblIndexAttribute")); + + if (generator.Config.GenerateFileScopedNamespaces) + { + sw.WriteLine(';'); + sw.WriteLine(); + indentString = ""; + } + else + { + sw.WriteLine(); + sw.WriteLine('{'); + } + + sw.Write(indentString); + sw.WriteLine("/// Defines the vtbl index of a method as it was in the native signature."); + sw.Write(indentString); + sw.WriteLine("[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]"); + sw.Write(indentString); + sw.WriteLine("[Conditional(\"DEBUG\")]"); + sw.Write(indentString); + sw.WriteLine("internal sealed partial class VtblIndexAttribute : Attribute"); + sw.Write(indentString); + sw.WriteLine('{'); + sw.Write(indentString); + sw.WriteLine(" private readonly uint _index;"); + sw.WriteLine(); + sw.Write(indentString); + sw.WriteLine(" /// Initializes a new instance of the class."); + sw.Write(indentString); + sw.WriteLine(" /// The vtbl index of a method as it was in the native signature."); + sw.Write(indentString); + sw.WriteLine(" public VtblIndexAttribute(uint index)"); + sw.Write(indentString); + sw.WriteLine(" {"); + sw.Write(indentString); + sw.WriteLine(" _index = index;"); + sw.Write(indentString); + sw.WriteLine(" }"); + sw.WriteLine(); + sw.Write(indentString); + sw.WriteLine(" /// Gets the vtbl index of a method as it was in the native signature."); + sw.Write(indentString); + sw.WriteLine(" public uint Index => _index;"); + sw.Write(indentString); + sw.WriteLine('}'); + + if (!generator.Config.GenerateFileScopedNamespaces) + { + sw.WriteLine('}'); } + } - static void GenerateNativeTypeNameAttribute(PInvokeGenerator generator) + static void GenerateTransparentStructs(PInvokeGenerator generator) + { + var config = generator.Config; + + foreach (var transparentStruct in config.WithTransparentStructs) { - var config = generator.Config; - var outputPath = Path.Combine(config.OutputLocation, "NativeTypeNameAttribute.cs"); + var name = transparentStruct.Key; + var type = transparentStruct.Value.Name; + var kind = transparentStruct.Value.Kind; + + var isTypePointer = type.Contains('*'); + var outputPath = Path.Combine(config.OutputLocation, $"{name}.cs"); using var sw = new StreamWriter(outputPath); sw.NewLine = "\n"; @@ -403,13 +619,26 @@ static void GenerateNativeTypeNameAttribute(PInvokeGenerator generator) } var indentString = " "; + var targetNamespace = generator.GetNamespace(name); sw.WriteLine("using System;"); - sw.WriteLine("using System.Diagnostics;"); + + if (kind == PInvokeGeneratorTransparentStructKind.HandleWin32) + { + var handleNamespace = generator.GetNamespace("HANDLE"); + + if (targetNamespace != handleNamespace) + { + sw.Write("using "); + sw.Write(handleNamespace); + sw.WriteLine(';'); + } + } + sw.WriteLine(); sw.Write("namespace "); - sw.Write(generator.GetNamespace("NativeTypeNameAttribute")); + sw.Write(targetNamespace); if (generator.Config.GenerateFileScopedNamespaces) { @@ -424,3079 +653,2725 @@ static void GenerateNativeTypeNameAttribute(PInvokeGenerator generator) } sw.Write(indentString); - sw.WriteLine("/// Defines the type of a member as it was used in the native signature."); - sw.Write(indentString); - sw.WriteLine("[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)]"); - sw.Write(indentString); - sw.WriteLine("[Conditional(\"DEBUG\")]"); - sw.Write(indentString); - sw.WriteLine("internal sealed partial class NativeTypeNameAttribute : Attribute"); + sw.Write("public readonly "); + + if (isTypePointer || IsTransparentStructHexBased(kind)) + { + sw.Write("unsafe "); + } + + sw.Write("partial struct "); + sw.Write(name); + sw.Write(" : IComparable, IComparable<"); + sw.Write(name); + sw.Write(">, IEquatable<"); + sw.Write(name); + sw.WriteLine(">, IFormattable"); + sw.Write(indentString); sw.WriteLine('{'); + sw.Write(indentString); - sw.WriteLine(" private readonly string _name;"); + sw.Write(" public readonly "); + sw.Write(type); + sw.WriteLine(" Value;"); sw.WriteLine(); + + // All transparent structs be created directly from the underlying type + sw.Write(indentString); - sw.WriteLine(" /// Initializes a new instance of the class."); - sw.Write(indentString); - sw.WriteLine(" /// The name of the type that was used in the native signature."); - sw.Write(indentString); - sw.WriteLine(" public NativeTypeNameAttribute(string name)"); + sw.Write(" public "); + sw.Write(name); + sw.Write('('); + sw.Write(type); + sw.WriteLine(" value)"); sw.Write(indentString); sw.WriteLine(" {"); sw.Write(indentString); - sw.WriteLine(" _name = name;"); + sw.WriteLine(" Value = value;"); sw.Write(indentString); sw.WriteLine(" }"); sw.WriteLine(); - sw.Write(indentString); - sw.WriteLine(" /// Gets the name of the type that was used in the native signature."); - sw.Write(indentString); - sw.WriteLine(" public string Name => _name;"); - sw.Write(indentString); - sw.WriteLine('}'); - if (!generator.Config.GenerateFileScopedNamespaces) + if (IsTransparentStructHandle(kind) || (kind == PInvokeGeneratorTransparentStructKind.HandleVulkan)) { - sw.WriteLine('}'); - } - } + // Handle like transparent structs define a NULL member - static void GenerateSetsLastSystemErrorAttribute(PInvokeGenerator generator) - { - var config = generator.Config; - var outputPath = Path.Combine(config.OutputLocation, "SetsLastSystemErrorAttribute.cs"); - - using var sw = new StreamWriter(outputPath); - sw.NewLine = "\n"; + if (kind == PInvokeGeneratorTransparentStructKind.HandleWin32) + { + sw.Write(indentString); + sw.Write(" public static "); + sw.Write(name); + sw.Write(" INVALID_VALUE => new "); + sw.Write(name); - if (config.HeaderText != string.Empty) - { - sw.WriteLine(config.HeaderText); - } + if (isTypePointer) + { + sw.Write("(("); + sw.Write(type); + sw.WriteLine(")(-1));"); + } + else + { + sw.WriteLine("(-1);"); + } - var indentString = " "; + sw.WriteLine(); + } - sw.WriteLine("using System;"); - sw.WriteLine("using System.Diagnostics;"); - sw.WriteLine("using System.Runtime.InteropServices;"); - sw.WriteLine(); + sw.Write(indentString); + sw.Write(" public static "); + sw.Write(name); + sw.Write(" NULL => new "); + sw.Write(name); - sw.Write("namespace "); - sw.Write(generator.GetNamespace("SetsLastSystemErrorAttribute")); + if (isTypePointer) + { + sw.WriteLine("(null);"); + } + else + { + sw.WriteLine("(0);"); + } - if (generator.Config.GenerateFileScopedNamespaces) - { - sw.WriteLine(';'); - sw.WriteLine(); - indentString = ""; - } - else - { sw.WriteLine(); - sw.WriteLine('{'); } - - sw.Write(indentString); - sw.WriteLine("/// Specifies that the given method sets the last system error and it can be retrieved via ."); - sw.Write(indentString); - sw.WriteLine("[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]"); - sw.Write(indentString); - sw.WriteLine("[Conditional(\"DEBUG\")]"); - sw.Write(indentString); - sw.WriteLine("internal sealed partial class SetsLastSystemErrorAttribute : Attribute"); - sw.Write(indentString); - sw.WriteLine('{'); - sw.Write(indentString); - sw.WriteLine(" /// Initializes a new instance of the class."); - sw.Write(indentString); - sw.WriteLine(" public SetsLastSystemErrorAttribute()"); - sw.Write(indentString); - sw.WriteLine(" {"); - sw.Write(indentString); - sw.WriteLine(" }"); - sw.Write(indentString); - sw.WriteLine('}'); - - if (!generator.Config.GenerateFileScopedNamespaces) + else if (IsTransparentStructBoolean(kind)) { - sw.WriteLine('}'); - } - } + // Boolean like transparent structs define FALSE and TRUE members - static void GenerateVtblIndexAttribute(PInvokeGenerator generator) - { - var config = generator.Config; - var outputPath = Path.Combine(config.OutputLocation, "VtblIndexAttribute.cs"); - - using var sw = new StreamWriter(outputPath); - sw.NewLine = "\n"; + sw.Write(indentString); + sw.Write(" public static "); + sw.Write(name); + sw.Write(" FALSE => new "); + sw.Write(name); + sw.WriteLine("(0);"); + sw.WriteLine(); - if (config.HeaderText != string.Empty) - { - sw.WriteLine(config.HeaderText); + sw.Write(indentString); + sw.Write(" public static "); + sw.Write(name); + sw.Write(" TRUE => new "); + sw.Write(name); + sw.WriteLine("(1);"); + sw.WriteLine(); } - var indentString = " "; + // All transparent structs support equality and relational comparisons with themselves - sw.WriteLine("using System;"); - sw.WriteLine("using System.Diagnostics;"); + sw.Write(indentString); + sw.Write(" public static bool operator ==("); + sw.Write(name); + sw.Write(" left, "); + sw.Write(name); + sw.WriteLine(" right) => left.Value == right.Value;"); sw.WriteLine(); - sw.Write("namespace "); - sw.Write(generator.GetNamespace("VtblIndexAttribute")); - - if (generator.Config.GenerateFileScopedNamespaces) - { - sw.WriteLine(';'); - sw.WriteLine(); - indentString = ""; - } - else - { - sw.WriteLine(); - sw.WriteLine('{'); - } - - sw.Write(indentString); - sw.WriteLine("/// Defines the vtbl index of a method as it was in the native signature."); - sw.Write(indentString); - sw.WriteLine("[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]"); sw.Write(indentString); - sw.WriteLine("[Conditional(\"DEBUG\")]"); - sw.Write(indentString); - sw.WriteLine("internal sealed partial class VtblIndexAttribute : Attribute"); - sw.Write(indentString); - sw.WriteLine('{'); - sw.Write(indentString); - sw.WriteLine(" private readonly uint _index;"); + sw.Write(" public static bool operator !=("); + sw.Write(name); + sw.Write(" left, "); + sw.Write(name); + sw.WriteLine(" right) => left.Value != right.Value;"); sw.WriteLine(); + sw.Write(indentString); - sw.WriteLine(" /// Initializes a new instance of the class."); - sw.Write(indentString); - sw.WriteLine(" /// The vtbl index of a method as it was in the native signature."); - sw.Write(indentString); - sw.WriteLine(" public VtblIndexAttribute(uint index)"); - sw.Write(indentString); - sw.WriteLine(" {"); - sw.Write(indentString); - sw.WriteLine(" _index = index;"); - sw.Write(indentString); - sw.WriteLine(" }"); + sw.Write(" public static bool operator <("); + sw.Write(name); + sw.Write(" left, "); + sw.Write(name); + sw.WriteLine(" right) => left.Value < right.Value;"); sw.WriteLine(); + sw.Write(indentString); - sw.WriteLine(" /// Gets the vtbl index of a method as it was in the native signature."); - sw.Write(indentString); - sw.WriteLine(" public uint Index => _index;"); - sw.Write(indentString); - sw.WriteLine('}'); + sw.Write(" public static bool operator <=("); + sw.Write(name); + sw.Write(" left, "); + sw.Write(name); + sw.WriteLine(" right) => left.Value <= right.Value;"); + sw.WriteLine(); - if (!generator.Config.GenerateFileScopedNamespaces) - { - sw.WriteLine('}'); - } - } + sw.Write(indentString); + sw.Write(" public static bool operator >("); + sw.Write(name); + sw.Write(" left, "); + sw.Write(name); + sw.WriteLine(" right) => left.Value > right.Value;"); + sw.WriteLine(); - static void GenerateTransparentStructs(PInvokeGenerator generator) - { - var config = generator.Config; + sw.Write(indentString); + sw.Write(" public static bool operator >=("); + sw.Write(name); + sw.Write(" left, "); + sw.Write(name); + sw.WriteLine(" right) => left.Value >= right.Value;"); + sw.WriteLine(); - foreach (var transparentStruct in config.WithTransparentStructs) + if (IsTransparentStructHandle(kind)) { - var name = transparentStruct.Key; - var type = transparentStruct.Value.Name; - var kind = transparentStruct.Value.Kind; - - var isTypePointer = type.Contains('*'); - var outputPath = Path.Combine(config.OutputLocation, $"{name}.cs"); + // Handle like transparent structs can be cast to/from void* - using var sw = new StreamWriter(outputPath); - sw.NewLine = "\n"; + sw.Write(indentString); + sw.Write(" public static explicit operator "); + sw.Write(name); + sw.Write("(void* value) => new "); + sw.Write(name); - if (config.HeaderText != string.Empty) + if (type == "void*") { - sw.WriteLine(config.HeaderText); + sw.WriteLine("(value);"); } - - var indentString = " "; - var targetNamespace = generator.GetNamespace(name); - - sw.WriteLine("using System;"); - - if (kind == PInvokeGeneratorTransparentStructKind.HandleWin32) + else { - var handleNamespace = generator.GetNamespace("HANDLE"); - - if (targetNamespace != handleNamespace) + if (!IsUnsigned(type)) { - sw.Write("using "); - sw.Write(handleNamespace); - sw.WriteLine(';'); + sw.Write("unchecked"); } - } - sw.WriteLine(); - - sw.Write("namespace "); - sw.Write(targetNamespace); - - if (generator.Config.GenerateFileScopedNamespaces) - { - sw.WriteLine(';'); - sw.WriteLine(); - indentString = ""; - } - else - { - sw.WriteLine(); - sw.WriteLine('{'); - } - - sw.Write(indentString); - sw.Write("public readonly "); - - if (isTypePointer || IsTransparentStructHexBased(kind)) - { - sw.Write("unsafe "); + sw.Write("(("); + sw.Write(type); + sw.WriteLine(")(value));"); } - - sw.Write("partial struct "); - sw.Write(name); - sw.Write(" : IComparable, IComparable<"); - sw.Write(name); - sw.Write(">, IEquatable<"); - sw.Write(name); - sw.WriteLine(">, IFormattable"); - - sw.Write(indentString); - sw.WriteLine('{'); - - sw.Write(indentString); - sw.Write(" public readonly "); - sw.Write(type); - sw.WriteLine(" Value;"); sw.WriteLine(); - // All transparent structs be created directly from the underlying type - sw.Write(indentString); - sw.Write(" public "); + sw.Write(" public static implicit operator void*("); sw.Write(name); - sw.Write('('); - sw.Write(type); - sw.WriteLine(" value)"); - sw.Write(indentString); - sw.WriteLine(" {"); - sw.Write(indentString); - sw.WriteLine(" Value = value;"); - sw.Write(indentString); - sw.WriteLine(" }"); - sw.WriteLine(); - if (IsTransparentStructHandle(kind) || (kind == PInvokeGeneratorTransparentStructKind.HandleVulkan)) + if (isTypePointer) + { + sw.WriteLine(" value) => value.Value;"); + } + else { - // Handle like transparent structs define a NULL member + var isUnchecked = !IsUnsigned(type); + sw.Write(" value) => "); - if (kind == PInvokeGeneratorTransparentStructKind.HandleWin32) + if (isUnchecked) { - sw.Write(indentString); - sw.Write(" public static "); - sw.Write(name); - sw.Write(" INVALID_VALUE => new "); - sw.Write(name); - - if (isTypePointer) - { - sw.Write("(("); - sw.Write(type); - sw.WriteLine(")(-1));"); - } - else - { - sw.WriteLine("(-1);"); - } - - sw.WriteLine(); + sw.Write("unchecked("); } + sw.Write("(void*)(value.Value)"); - sw.Write(indentString); - sw.Write(" public static "); - sw.Write(name); - sw.Write(" NULL => new "); - sw.Write(name); - - if (isTypePointer) - { - sw.WriteLine("(null);"); - } - else + if (isUnchecked) { - sw.WriteLine("(0);"); + sw.Write(")"); } - sw.WriteLine(); } - else if (IsTransparentStructBoolean(kind)) + + sw.WriteLine(); + + if ((kind == PInvokeGeneratorTransparentStructKind.HandleWin32) && (name != "HANDLE")) { - // Boolean like transparent structs define FALSE and TRUE members + // Win32 handle like transparent structs can also be cast to/from HANDLE sw.Write(indentString); - sw.Write(" public static "); + sw.Write(" public static explicit operator "); sw.Write(name); - sw.Write(" FALSE => new "); + sw.Write("(HANDLE value) => new "); sw.Write(name); - sw.WriteLine("(0);"); + sw.WriteLine("(value);"); sw.WriteLine(); sw.Write(indentString); - sw.Write(" public static "); + sw.Write(" public static implicit operator HANDLE("); sw.Write(name); - sw.Write(" TRUE => new "); - sw.Write(name); - sw.WriteLine("(1);"); + sw.WriteLine(" value) => new HANDLE(value.Value);"); sw.WriteLine(); } - - // All transparent structs support equality and relational comparisons with themselves + } + else if (IsTransparentStructBoolean(kind)) + { + // Boolean like transparent structs define conversion to/from bool + // and support for usage in bool like scenarios. sw.Write(indentString); - sw.Write(" public static bool operator ==("); + sw.Write(" public static implicit operator bool("); sw.Write(name); - sw.Write(" left, "); - sw.Write(name); - sw.WriteLine(" right) => left.Value == right.Value;"); + sw.WriteLine(" value) => value.Value != 0;"); sw.WriteLine(); sw.Write(indentString); - sw.Write(" public static bool operator !=("); + sw.Write(" public static implicit operator "); sw.Write(name); - sw.Write(" left, "); + sw.Write("(bool value) => new "); sw.Write(name); - sw.WriteLine(" right) => left.Value != right.Value;"); - sw.WriteLine(); - sw.Write(indentString); - sw.Write(" public static bool operator <("); - sw.Write(name); - sw.Write(" left, "); - sw.Write(name); - sw.WriteLine(" right) => left.Value < right.Value;"); - sw.WriteLine(); + if (type == "int") + { + sw.WriteLine("(value ? 1 : 0);"); + } + else if (type == "uint") + { + sw.WriteLine("(value ? 1u : 0u);"); + } + else + { + sw.Write("(("); + sw.Write(type); + sw.WriteLine(")(value ? 1u : 0u);"); + } - sw.Write(indentString); - sw.Write(" public static bool operator <=("); - sw.Write(name); - sw.Write(" left, "); - sw.Write(name); - sw.WriteLine(" right) => left.Value <= right.Value;"); sw.WriteLine(); sw.Write(indentString); - sw.Write(" public static bool operator >("); - sw.Write(name); - sw.Write(" left, "); + sw.Write(" public static bool operator false("); sw.Write(name); - sw.WriteLine(" right) => left.Value > right.Value;"); + sw.WriteLine(" value) => value.Value == 0;"); sw.WriteLine(); sw.Write(indentString); - sw.Write(" public static bool operator >=("); + sw.Write(" public static bool operator true("); sw.Write(name); - sw.Write(" left, "); - sw.Write(name); - sw.WriteLine(" right) => left.Value >= right.Value;"); + sw.WriteLine(" value) => value.Value != 0;"); sw.WriteLine(); + } - if (IsTransparentStructHandle(kind)) - { - // Handle like transparent structs can be cast to/from void* + // All transparent structs define casts to/from the various integer types - sw.Write(indentString); - sw.Write(" public static explicit operator "); - sw.Write(name); - sw.Write("(void* value) => new "); - sw.Write(name); + OutputConversions(sw, indentString, name, type, kind, "byte"); + OutputConversions(sw, indentString, name, type, kind, "short"); + OutputConversions(sw, indentString, name, type, kind, "int"); + OutputConversions(sw, indentString, name, type, kind, "long"); + OutputConversions(sw, indentString, name, type, kind, "nint"); + OutputConversions(sw, indentString, name, type, kind, "sbyte"); + OutputConversions(sw, indentString, name, type, kind, "ushort"); + OutputConversions(sw, indentString, name, type, kind, "uint"); + OutputConversions(sw, indentString, name, type, kind, "ulong"); + OutputConversions(sw, indentString, name, type, kind, "nuint"); - if (type == "void*") - { - sw.WriteLine("(value);"); - } - else - { - if (!IsUnsigned(type)) - { - sw.Write("unchecked"); - } + // All transparent structs override CompareTo, Equals, GetHashCode, and ToString - sw.Write("(("); - sw.Write(type); - sw.WriteLine(")(value));"); - } - sw.WriteLine(); - - sw.Write(indentString); - sw.Write(" public static implicit operator void*("); - sw.Write(name); - - if (isTypePointer) - { - sw.WriteLine(" value) => value.Value;"); - } - else - { - var isUnchecked = !IsUnsigned(type); - sw.Write(" value) => "); - - if (isUnchecked) - { - sw.Write("unchecked("); - } - sw.Write("(void*)(value.Value)"); + sw.Write(indentString); + sw.WriteLine(" public int CompareTo(object? obj)"); + sw.Write(indentString); + sw.WriteLine(" {"); + sw.Write(indentString); + sw.Write(" if (obj is "); + sw.Write(name); + sw.WriteLine(" other)"); + sw.Write(indentString); + sw.WriteLine(" {"); + sw.Write(indentString); + sw.WriteLine(" return CompareTo(other);"); + sw.Write(indentString); + sw.WriteLine(" }"); + sw.WriteLine(); + sw.Write(indentString); + sw.Write(" return (obj is null) ? 1 : throw new ArgumentException(\"obj is not an instance of "); + sw.Write(name); + sw.WriteLine(".\");"); + sw.Write(indentString); + sw.WriteLine(" }"); + sw.WriteLine(); - if (isUnchecked) - { - sw.Write(")"); - } - sw.WriteLine(); - } + sw.Write(indentString); + sw.Write(" public int CompareTo("); + sw.Write(name); - sw.WriteLine(); + if (isTypePointer) + { + sw.WriteLine(" other) => ((nuint)(Value)).CompareTo((nuint)(other.Value));"); + } + else + { + sw.WriteLine(" other) => Value.CompareTo(other.Value);"); + } - if ((kind == PInvokeGeneratorTransparentStructKind.HandleWin32) && (name != "HANDLE")) - { - // Win32 handle like transparent structs can also be cast to/from HANDLE - - sw.Write(indentString); - sw.Write(" public static explicit operator "); - sw.Write(name); - sw.Write("(HANDLE value) => new "); - sw.Write(name); - sw.WriteLine("(value);"); - sw.WriteLine(); - - sw.Write(indentString); - sw.Write(" public static implicit operator HANDLE("); - sw.Write(name); - sw.WriteLine(" value) => new HANDLE(value.Value);"); - sw.WriteLine(); - } - } - else if (IsTransparentStructBoolean(kind)) - { - // Boolean like transparent structs define conversion to/from bool - // and support for usage in bool like scenarios. + sw.WriteLine(); - sw.Write(indentString); - sw.Write(" public static implicit operator bool("); - sw.Write(name); - sw.WriteLine(" value) => value.Value != 0;"); - sw.WriteLine(); + sw.Write(indentString); + sw.Write(" public override bool Equals(object? obj) => (obj is "); + sw.Write(name); + sw.WriteLine(" other) && Equals(other);"); + sw.WriteLine(); - sw.Write(indentString); - sw.Write(" public static implicit operator "); - sw.Write(name); - sw.Write("(bool value) => new "); - sw.Write(name); + sw.Write(indentString); + sw.Write(" public bool Equals("); + sw.Write(name); - if (type == "int") - { - sw.WriteLine("(value ? 1 : 0);"); - } - else if (type == "uint") - { - sw.WriteLine("(value ? 1u : 0u);"); - } - else - { - sw.Write("(("); - sw.Write(type); - sw.WriteLine(")(value ? 1u : 0u);"); - } + if (isTypePointer) + { + sw.WriteLine(" other) => ((nuint)(Value)).Equals((nuint)(other.Value));"); + } + else + { + sw.WriteLine(" other) => Value.Equals(other.Value);"); + } - sw.WriteLine(); + sw.WriteLine(); - sw.Write(indentString); - sw.Write(" public static bool operator false("); - sw.Write(name); - sw.WriteLine(" value) => value.Value == 0;"); - sw.WriteLine(); + sw.Write(indentString); + sw.Write(" public override int GetHashCode() => "); - sw.Write(indentString); - sw.Write(" public static bool operator true("); - sw.Write(name); - sw.WriteLine(" value) => value.Value != 0;"); - sw.WriteLine(); - } + if (isTypePointer) + { + sw.Write("((nuint)(Value))"); + } + else + { + sw.Write("Value"); + } - // All transparent structs define casts to/from the various integer types + sw.WriteLine(".GetHashCode();"); + sw.WriteLine(); - OutputConversions(sw, indentString, name, type, kind, "byte"); - OutputConversions(sw, indentString, name, type, kind, "short"); - OutputConversions(sw, indentString, name, type, kind, "int"); - OutputConversions(sw, indentString, name, type, kind, "long"); - OutputConversions(sw, indentString, name, type, kind, "nint"); - OutputConversions(sw, indentString, name, type, kind, "sbyte"); - OutputConversions(sw, indentString, name, type, kind, "ushort"); - OutputConversions(sw, indentString, name, type, kind, "uint"); - OutputConversions(sw, indentString, name, type, kind, "ulong"); - OutputConversions(sw, indentString, name, type, kind, "nuint"); + sw.Write(indentString); + sw.Write(" public override string ToString() => "); - // All transparent structs override CompareTo, Equals, GetHashCode, and ToString + if (isTypePointer) + { + sw.Write("((nuint)(Value))"); + } + else + { + sw.Write("Value"); + } - sw.Write(indentString); - sw.WriteLine(" public int CompareTo(object? obj)"); - sw.Write(indentString); - sw.WriteLine(" {"); - sw.Write(indentString); - sw.Write(" if (obj is "); - sw.Write(name); - sw.WriteLine(" other)"); - sw.Write(indentString); - sw.WriteLine(" {"); - sw.Write(indentString); - sw.WriteLine(" return CompareTo(other);"); - sw.Write(indentString); - sw.WriteLine(" }"); - sw.WriteLine(); - sw.Write(indentString); - sw.Write(" return (obj is null) ? 1 : throw new ArgumentException(\"obj is not an instance of "); - sw.Write(name); - sw.WriteLine(".\");"); - sw.Write(indentString); - sw.WriteLine(" }"); - sw.WriteLine(); + sw.Write(".ToString("); - sw.Write(indentString); - sw.Write(" public int CompareTo("); - sw.Write(name); + if (IsTransparentStructHexBased(kind)) + { + var (typeSrcSize, typeDstSize, typeSign) = GetSizeAndSignOf(type); - if (isTypePointer) + if (typeSrcSize != typeDstSize) { - sw.WriteLine(" other) => ((nuint)(Value)).CompareTo((nuint)(other.Value));"); + sw.Write("(sizeof(nint) == 4) ? \"X8\" : \"X16\""); } else { - sw.WriteLine(" other) => Value.CompareTo(other.Value);"); + sw.Write('"'); + sw.Write('X'); + sw.Write(typeSrcSize * 2); + sw.Write('"'); } + } - sw.WriteLine(); + sw.WriteLine(");"); + sw.WriteLine(); - sw.Write(indentString); - sw.Write(" public override bool Equals(object? obj) => (obj is "); - sw.Write(name); - sw.WriteLine(" other) && Equals(other);"); - sw.WriteLine(); + sw.Write(indentString); + sw.Write(" public string ToString(string? format, IFormatProvider? formatProvider) => "); - sw.Write(indentString); - sw.Write(" public bool Equals("); - sw.Write(name); + if (isTypePointer) + { + sw.Write("((nuint)(Value))"); + } + else + { + sw.Write("Value"); + } - if (isTypePointer) - { - sw.WriteLine(" other) => ((nuint)(Value)).Equals((nuint)(other.Value));"); - } - else - { - sw.WriteLine(" other) => Value.Equals(other.Value);"); - } + sw.WriteLine(".ToString(format, formatProvider);"); - sw.WriteLine(); + sw.Write(indentString); + sw.WriteLine('}'); - sw.Write(indentString); - sw.Write(" public override int GetHashCode() => "); + if (!generator.Config.GenerateFileScopedNamespaces) + { + sw.WriteLine('}'); + } + } - if (isTypePointer) - { - sw.Write("((nuint)(Value))"); - } - else - { - sw.Write("Value"); - } + static (int srcSize, int dstSize, int sign) GetSizeAndSignOf(string type) + { + if (type.Contains('*')) + { + return (8, 4, +1); + } - sw.WriteLine(".GetHashCode();"); - sw.WriteLine(); + return type switch { + "sbyte" => (1, 1, -1), + "byte" => (1, 1, +1), + "short" => (2, 2, -1), + "ushort" => (2, 2, +1), + "int" => (4, 4, -1), + "uint" => (4, 4, +1), + "nint" => (8, 4, -1), + "nuint" => (8, 4, +1), + "long" => (8, 8, -1), + "ulong" => (8, 8, +1), + _ => (0, 0, 0), + }; + } - sw.Write(indentString); - sw.Write(" public override string ToString() => "); + static void OutputConversions(StreamWriter sw, string indentString, string name, string type, PInvokeGeneratorTransparentStructKind kind, string target) + { + var (typeSrcSize, typeDstSize, typeSign) = GetSizeAndSignOf(type); + var (targetSrcSize, targetDstSize, targetSign) = GetSizeAndSignOf(target); - if (isTypePointer) - { - sw.Write("((nuint)(Value))"); - } - else - { - sw.Write("Value"); - } + var isTypePointer = type.Contains('*'); + var isPointerToNativeCast = (isTypePointer && target == "nint") || (isTypePointer && target == "nuint"); - sw.Write(".ToString("); + // public static castFromKind operator name(target value) => new name((type)(value)); - if (IsTransparentStructHexBased(kind)) - { - var (typeSrcSize, typeDstSize, typeSign) = GetSizeAndSignOf(type); + var castFromKind = "implicit"; + var areEquivalentTypeAndTarget = (type == target) || isPointerToNativeCast + || ((type == "nint") && (target == "int")) || ((type == "nuint") && (target == "uint")) + || ((type == "long") && (target == "nint")) || ((type == "ulong") && (target == "nuint")); - if (typeSrcSize != typeDstSize) - { - sw.Write("(sizeof(nint) == 4) ? \"X8\" : \"X16\""); - } - else - { - sw.Write('"'); - sw.Write('X'); - sw.Write(typeSrcSize * 2); - sw.Write('"'); - } - } + if (((typeDstSize <= targetSrcSize) && !areEquivalentTypeAndTarget) || ((targetSign == -1) && (typeSign == +1)) || IsTransparentStructHandle(kind)) + { + castFromKind = "explicit"; + } - sw.WriteLine(");"); - sw.WriteLine(); + sw.Write(indentString); + sw.Write(" public static "); + sw.Write(castFromKind); + sw.Write(" operator "); + sw.Write(name); + sw.Write('('); + sw.Write(target); + sw.Write(" value) => new "); + sw.Write(name); + sw.Write('('); + + if ((castFromKind == "explicit") || isPointerToNativeCast) + { + sw.Write("unchecked(("); + sw.Write(type); + sw.Write(")("); + } - sw.Write(indentString); - sw.Write(" public string ToString(string? format, IFormatProvider? formatProvider) => "); + sw.Write("value"); - if (isTypePointer) - { - sw.Write("((nuint)(Value))"); - } - else - { - sw.Write("Value"); - } + if ((castFromKind == "explicit") || isPointerToNativeCast) + { + sw.Write("))"); + } - sw.WriteLine(".ToString(format, formatProvider);"); + sw.WriteLine(");"); + sw.WriteLine(); - sw.Write(indentString); - sw.WriteLine('}'); + // public static castToKind operator target(name value) => ((target)(value.Value)); - if (!generator.Config.GenerateFileScopedNamespaces) - { - sw.WriteLine('}'); - } - } + var castToKind = "implicit"; + areEquivalentTypeAndTarget = (type == target) || isPointerToNativeCast + || ((type == "int") && (target == "nint")) || ((type == "uint") && (target == "nuint")) + || ((type == "nint") && (target == "long")) || ((type == "nuint") && (target == "ulong")); - static (int srcSize, int dstSize, int sign) GetSizeAndSignOf(string type) + if (((targetDstSize <= typeSrcSize) && !areEquivalentTypeAndTarget) || ((typeSign == -1) && (targetSign == +1))) { - if (type.Contains('*')) - { - return (8, 4, +1); - } - - return type switch { - "sbyte" => (1, 1, -1), - "byte" => (1, 1, +1), - "short" => (2, 2, -1), - "ushort" => (2, 2, +1), - "int" => (4, 4, -1), - "uint" => (4, 4, +1), - "nint" => (8, 4, -1), - "nuint" => (8, 4, +1), - "long" => (8, 8, -1), - "ulong" => (8, 8, +1), - _ => (0, 0, 0), - }; + castToKind = "explicit"; } - static void OutputConversions(StreamWriter sw, string indentString, string name, string type, PInvokeGeneratorTransparentStructKind kind, string target) - { - var (typeSrcSize, typeDstSize, typeSign) = GetSizeAndSignOf(type); - var (targetSrcSize, targetDstSize, targetSign) = GetSizeAndSignOf(target); - - var isTypePointer = type.Contains('*'); - var isPointerToNativeCast = (isTypePointer && target == "nint") || (isTypePointer && target == "nuint"); + sw.Write(indentString); + sw.Write(" public static "); + sw.Write(castToKind); + sw.Write(" operator "); + sw.Write(target); + sw.Write('('); + sw.Write(name); + sw.Write(" value) => "); - // public static castFromKind operator name(target value) => new name((type)(value)); + if ((castToKind == "explicit") || isPointerToNativeCast) + { + sw.Write('('); + sw.Write(target); + sw.Write(")("); + } - var castFromKind = "implicit"; - var areEquivalentTypeAndTarget = (type == target) || isPointerToNativeCast - || ((type == "nint") && (target == "int")) || ((type == "nuint") && (target == "uint")) - || ((type == "long") && (target == "nint")) || ((type == "ulong") && (target == "nuint")); + sw.Write("value.Value"); - if (((typeDstSize <= targetSrcSize) && !areEquivalentTypeAndTarget) || ((targetSign == -1) && (typeSign == +1)) || IsTransparentStructHandle(kind)) - { - castFromKind = "explicit"; - } + if ((castToKind == "explicit") || isPointerToNativeCast) + { + sw.Write(')'); + } - sw.Write(indentString); - sw.Write(" public static "); - sw.Write(castFromKind); - sw.Write(" operator "); - sw.Write(name); - sw.Write('('); - sw.Write(target); - sw.Write(" value) => new "); - sw.Write(name); - sw.Write('('); + sw.WriteLine(';'); + sw.WriteLine(); + } + } + } - if ((castFromKind == "explicit") || isPointerToNativeCast) - { - sw.Write("unchecked(("); - sw.Write(type); - sw.Write(")("); - } + public void Dispose() + { + Dispose(isDisposing: true); + GC.SuppressFinalize(this); + } - sw.Write("value"); + public void GenerateBindings(TranslationUnit translationUnit, string filePath, string[] clangCommandLineArgs, CXTranslationUnit_Flags translationFlags) + { + Debug.Assert(_outputBuilder is null); - if ((castFromKind == "explicit") || isPointerToNativeCast) - { - sw.Write("))"); - } + _filePath = filePath; + _clangCommandLineArgs = clangCommandLineArgs; + _translationFlags = translationFlags; - sw.WriteLine(");"); - sw.WriteLine(); + if (translationUnit.Handle.NumDiagnostics != 0) + { + var errorDiagnostics = new StringBuilder(); + errorDiagnostics.AppendLine($"The provided {nameof(CXTranslationUnit)} has the following diagnostics which prevent its use:"); + var invalidTranslationUnitHandle = false; - // public static castToKind operator target(name value) => ((target)(value.Value)); + for (uint i = 0; i < translationUnit.Handle.NumDiagnostics; ++i) + { + using var diagnostic = translationUnit.Handle.GetDiagnostic(i); - var castToKind = "implicit"; - areEquivalentTypeAndTarget = (type == target) || isPointerToNativeCast - || ((type == "int") && (target == "nint")) || ((type == "uint") && (target == "nuint")) - || ((type == "nint") && (target == "long")) || ((type == "nuint") && (target == "ulong")); + if (diagnostic.Severity is CXDiagnosticSeverity.CXDiagnostic_Error or CXDiagnosticSeverity.CXDiagnostic_Fatal) + { + invalidTranslationUnitHandle = true; + errorDiagnostics.Append(' ', 4); + errorDiagnostics.AppendLine(diagnostic.Format(CXDiagnostic.DefaultDisplayOptions).ToString()); + } + } - if (((targetDstSize <= typeSrcSize) && !areEquivalentTypeAndTarget) || ((typeSign == -1) && (targetSign == +1))) - { - castToKind = "explicit"; - } + if (invalidTranslationUnitHandle) + { + throw new ArgumentOutOfRangeException(nameof(translationUnit), errorDiagnostics.ToString()); + } + } - sw.Write(indentString); - sw.Write(" public static "); - sw.Write(castToKind); - sw.Write(" operator "); - sw.Write(target); - sw.Write('('); - sw.Write(name); - sw.Write(" value) => "); + try + { + if (_config.GenerateMacroBindings) + { + var translationUnitHandle = translationUnit.Handle; - if ((castToKind == "explicit") || isPointerToNativeCast) - { - sw.Write('('); - sw.Write(target); - sw.Write(")("); - } + var file = translationUnitHandle.GetFile(_filePath); + var fileContents = translationUnitHandle.GetFileContents(file, out var size); - sw.Write("value.Value"); +#if NETCOREAPP + _fileContentsBuilder.Append(Encoding.UTF8.GetString(fileContents)); +#else + _fileContentsBuilder.Append(Encoding.UTF8.GetString(fileContents.ToArray())); +#endif - if ((castToKind == "explicit") || isPointerToNativeCast) + foreach (var cursor in translationUnit.TranslationUnitDecl.CursorChildren) + { + if (cursor is PreprocessedEntity preprocessedEntity) { - sw.Write(')'); + VisitPreprocessedEntity(preprocessedEntity); } - - sw.WriteLine(';'); - sw.WriteLine(); } - } - } - public void Dispose() - { - Dispose(isDisposing: true); - GC.SuppressFinalize(this); - } + var unsavedFileContents = _fileContentsBuilder.ToString(); + _fileContentsBuilder.Clear(); - public void GenerateBindings(TranslationUnit translationUnit, string filePath, string[] clangCommandLineArgs, CXTranslationUnit_Flags translationFlags) - { - Debug.Assert(_outputBuilder is null); + using var unsavedFile = CXUnsavedFile.Create(_filePath, unsavedFileContents); + var unsavedFiles = new CXUnsavedFile[] { unsavedFile }; - _filePath = filePath; - _clangCommandLineArgs = clangCommandLineArgs; - _translationFlags = translationFlags; + translationFlags = _translationFlags & ~CXTranslationUnit_Flags.CXTranslationUnit_DetailedPreprocessingRecord; + var handle = CXTranslationUnit.Parse(IndexHandle, _filePath, _clangCommandLineArgs, unsavedFiles, translationFlags); - if (translationUnit.Handle.NumDiagnostics != 0) + using var nestedTranslationUnit = TranslationUnit.GetOrCreate(handle); + Visit(nestedTranslationUnit.TranslationUnitDecl); + } + else { - var errorDiagnostics = new StringBuilder(); - errorDiagnostics.AppendLine($"The provided {nameof(CXTranslationUnit)} has the following diagnostics which prevent its use:"); - var invalidTranslationUnitHandle = false; + Visit(translationUnit.TranslationUnitDecl); + } - for (uint i = 0; i < translationUnit.Handle.NumDiagnostics; ++i) + if (_config.LogPotentialTypedefRemappings) + { + foreach (var kvp in _traversedValidNameRemappings) { - using var diagnostic = translationUnit.Handle.GetDiagnostic(i); + var name = kvp.Key; + var remappings = kvp.Value; - if (diagnostic.Severity is CXDiagnosticSeverity.CXDiagnostic_Error or CXDiagnosticSeverity.CXDiagnostic_Fatal) + if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) { - invalidTranslationUnitHandle = true; - errorDiagnostics.Append(' ', 4); - errorDiagnostics.AppendLine(diagnostic.Format(CXDiagnostic.DefaultDisplayOptions).ToString()); + AddDiagnostic(DiagnosticLevel.Info, $"Potential missing remapping '{name}'. {GetFoundRemappingString(name, remappings)}"); } } - if (invalidTranslationUnitHandle) + foreach (var kvp in _allValidNameRemappings) { - throw new ArgumentOutOfRangeException(nameof(translationUnit), errorDiagnostics.ToString()); + var name = kvp.Key; + var remappings = kvp.Value; + + if (_config.RemappedNames.TryGetValue(name, out var remappedName) && !remappings.Contains(remappedName) && (name != remappedName) && !_config.ForceRemappedNames.Contains(name)) + { + AddDiagnostic(DiagnosticLevel.Info, $"Potential invalid remapping '{name}={remappedName}'. {GetFoundRemappingString(name, remappings)}"); + } } - } - try - { - if (_config.GenerateMacroBindings) + foreach (var name in _usedRemappings) { - var translationUnitHandle = translationUnit.Handle; - - var file = translationUnitHandle.GetFile(_filePath); - var fileContents = translationUnitHandle.GetFileContents(file, out var size); + var remappedName = _config.RemappedNames[name]; -#if NETCOREAPP - _fileContentsBuilder.Append(Encoding.UTF8.GetString(fileContents)); -#else - _fileContentsBuilder.Append(Encoding.UTF8.GetString(fileContents.ToArray())); -#endif - - foreach (var cursor in translationUnit.TranslationUnitDecl.CursorChildren) + if (!_allValidNameRemappings.ContainsKey(name) && (name != remappedName) && !_config.ForceRemappedNames.Contains(name)) { - if (cursor is PreprocessedEntity preprocessedEntity) - { - VisitPreprocessedEntity(preprocessedEntity); - } + AddDiagnostic(DiagnosticLevel.Info, $"Potential invalid remapping '{name}={remappedName}'. No remappings were found."); } - - var unsavedFileContents = _fileContentsBuilder.ToString(); - _fileContentsBuilder.Clear(); - - using var unsavedFile = CXUnsavedFile.Create(_filePath, unsavedFileContents); - var unsavedFiles = new CXUnsavedFile[] { unsavedFile }; - - translationFlags = _translationFlags & ~CXTranslationUnit_Flags.CXTranslationUnit_DetailedPreprocessingRecord; - var handle = CXTranslationUnit.Parse(IndexHandle, _filePath, _clangCommandLineArgs, unsavedFiles, translationFlags); - - using var nestedTranslationUnit = TranslationUnit.GetOrCreate(handle); - Visit(nestedTranslationUnit.TranslationUnitDecl); - } - else - { - Visit(translationUnit.TranslationUnitDecl); } - if (_config.LogPotentialTypedefRemappings) + static string GetFoundRemappingString(string name, HashSet remappings) { - foreach (var kvp in _traversedValidNameRemappings) - { - var name = kvp.Key; - var remappings = kvp.Value; + var recommendedRemapping = ""; - if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) - { - AddDiagnostic(DiagnosticLevel.Info, $"Potential missing remapping '{name}'. {GetFoundRemappingString(name, remappings)}"); - } + if (remappings.Count == 1) + { + recommendedRemapping = remappings.Single(); } - foreach (var kvp in _allValidNameRemappings) + if ((recommendedRemapping == "") && name.StartsWith("_")) { - var name = kvp.Key; - var remappings = kvp.Value; + var remapping = name[1..]; - if (_config.RemappedNames.TryGetValue(name, out var remappedName) && !remappings.Contains(remappedName) && (name != remappedName) && !_config.ForceRemappedNames.Contains(name)) + if (remappings.Contains(remapping)) { - AddDiagnostic(DiagnosticLevel.Info, $"Potential invalid remapping '{name}={remappedName}'. {GetFoundRemappingString(name, remappings)}"); + recommendedRemapping = remapping; } } - foreach (var name in _usedRemappings) + if ((recommendedRemapping == "") && name.StartsWith("tag")) { - var remappedName = _config.RemappedNames[name]; + var remapping = name[3..]; - if (!_allValidNameRemappings.ContainsKey(name) && (name != remappedName) && !_config.ForceRemappedNames.Contains(name)) + if (remappings.Contains(remapping)) { - AddDiagnostic(DiagnosticLevel.Info, $"Potential invalid remapping '{name}={remappedName}'. No remappings were found."); + recommendedRemapping = remapping; } } - static string GetFoundRemappingString(string name, HashSet remappings) + if ((recommendedRemapping == "") && name.EndsWith("_")) { - var recommendedRemapping = ""; + var remapping = name[0..^1]; - if (remappings.Count == 1) + if (remappings.Contains(remapping)) { - recommendedRemapping = remappings.Single(); + recommendedRemapping = remapping; } + } - if ((recommendedRemapping == "") && name.StartsWith("_")) - { - var remapping = name[1..]; - - if (remappings.Contains(remapping)) - { - recommendedRemapping = remapping; - } - } + if ((recommendedRemapping == "") && name.EndsWith("tag")) + { + var remapping = name[0..^3]; - if ((recommendedRemapping == "") && name.StartsWith("tag")) + if (remappings.Contains(remapping)) { - var remapping = name[3..]; - - if (remappings.Contains(remapping)) - { - recommendedRemapping = remapping; - } + recommendedRemapping = remapping; } + } - if ((recommendedRemapping == "") && name.EndsWith("_")) - { - var remapping = name[0..^1]; - - if (remappings.Contains(remapping)) - { - recommendedRemapping = remapping; - } - } + if (recommendedRemapping == "") + { + var remapping = name.ToUpperInvariant(); - if ((recommendedRemapping == "") && name.EndsWith("tag")) + if (remappings.Contains(remapping)) { - var remapping = name[0..^3]; - - if (remappings.Contains(remapping)) - { - recommendedRemapping = remapping; - } + recommendedRemapping = remapping; } + } - if (recommendedRemapping == "") - { - var remapping = name.ToUpperInvariant(); - - if (remappings.Contains(remapping)) - { - recommendedRemapping = remapping; - } - } + var result = ""; + var remainingRemappings = (IEnumerable)remappings; + var remainingString = "Found"; - var result = ""; - var remainingRemappings = (IEnumerable)remappings; - var remainingString = "Found"; + if (recommendedRemapping != "") + { + result += $"Recommended remapping: '{name}={recommendedRemapping}'."; - if (recommendedRemapping != "") + if (remappings.Count == 1) { - result += $"Recommended remapping: '{name}={recommendedRemapping}'."; - - if (remappings.Count == 1) - { - remainingRemappings = Array.Empty(); - } - else - { - result += ' '; - remainingRemappings = remappings.Except(new string[] { recommendedRemapping }); - remainingString = "Other"; - } + remainingRemappings = Array.Empty(); } - - if (remainingRemappings.Any()) + else { - result += $"{remainingString} typedefs: {string.Join("; ", remainingRemappings)}"; + result += ' '; + remainingRemappings = remappings.Except(new string[] { recommendedRemapping }); + remainingString = "Other"; } + } - return result; + if (remainingRemappings.Any()) + { + result += $"{remainingString} typedefs: {string.Join("; ", remainingRemappings)}"; } + + return result; } } - catch (Exception e) - { - var diagnostic = new Diagnostic(DiagnosticLevel.Error, e.ToString()); - _diagnostics.Add(diagnostic); - } - - GC.KeepAlive(translationUnit); } - - private void AddDiagnostic(DiagnosticLevel level, string message) + catch (Exception e) { - var diagnostic = new Diagnostic(level, message); - - if (_diagnostics.Contains(diagnostic)) - { - return; - } - + var diagnostic = new Diagnostic(DiagnosticLevel.Error, e.ToString()); _diagnostics.Add(diagnostic); } - private void AddDiagnostic(DiagnosticLevel level, string message, Cursor cursor) + GC.KeepAlive(translationUnit); + } + + private void AddDiagnostic(DiagnosticLevel level, string message) + { + var diagnostic = new Diagnostic(level, message); + + if (_diagnostics.Contains(diagnostic)) { - var diagnostic = new Diagnostic(level, message, (cursor?.Location).GetValueOrDefault()); + return; + } - if (_diagnostics.Contains(diagnostic)) - { - return; - } + _diagnostics.Add(diagnostic); + } - _diagnostics.Add(diagnostic); + private void AddDiagnostic(DiagnosticLevel level, string message, Cursor cursor) + { + var diagnostic = new Diagnostic(level, message, (cursor?.Location).GetValueOrDefault()); + + if (_diagnostics.Contains(diagnostic)) + { + return; } - private void CloseOutputBuilder(Stream stream, IOutputBuilder outputBuilder, bool isMethodClass, bool leaveStreamOpen, bool emitNamespaceDeclaration) + _diagnostics.Add(diagnostic); + } + + private void CloseOutputBuilder(Stream stream, IOutputBuilder outputBuilder, bool isMethodClass, bool leaveStreamOpen, bool emitNamespaceDeclaration) + { + if (stream is null) { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } + throw new ArgumentNullException(nameof(stream)); + } - if (outputBuilder is null) - { - throw new ArgumentNullException(nameof(outputBuilder)); - } + if (outputBuilder is null) + { + throw new ArgumentNullException(nameof(outputBuilder)); + } - using var sw = new StreamWriter(stream, s_defaultStreamWriterEncoding, DefaultStreamWriterBufferSize, leaveStreamOpen); - sw.NewLine = "\n"; + using var sw = new StreamWriter(stream, s_defaultStreamWriterEncoding, DefaultStreamWriterBufferSize, leaveStreamOpen); + sw.NewLine = "\n"; - if (_config.GenerateMultipleFiles) + if (_config.GenerateMultipleFiles) + { + if (outputBuilder is CSharpOutputBuilder csharpOutputBuilder) { - if (outputBuilder is CSharpOutputBuilder csharpOutputBuilder) + if (_config.HeaderText != string.Empty) { - if (_config.HeaderText != string.Empty) - { - sw.WriteLine(_config.HeaderText); - } + sw.WriteLine(_config.HeaderText); + } - if (isMethodClass) - { - var nonTestName = outputBuilder.IsTestOutput ? outputBuilder.Name[0..^5] : outputBuilder.Name; + if (isMethodClass) + { + var nonTestName = outputBuilder.IsTestOutput ? outputBuilder.Name[0..^5] : outputBuilder.Name; - if (_topLevelClassUsings.TryGetValue(nonTestName, out var withUsings)) + if (_topLevelClassUsings.TryGetValue(nonTestName, out var withUsings)) + { + foreach (var withUsing in withUsings) { - foreach (var withUsing in withUsings) - { - csharpOutputBuilder.AddUsingDirective(withUsing); - } + csharpOutputBuilder.AddUsingDirective(withUsing); } } + } - var usingDirectives = csharpOutputBuilder.UsingDirectives.Concat(csharpOutputBuilder.StaticUsingDirectives); + var usingDirectives = csharpOutputBuilder.UsingDirectives.Concat(csharpOutputBuilder.StaticUsingDirectives); - if (usingDirectives.Any()) + if (usingDirectives.Any()) + { + foreach (var usingDirective in usingDirectives) { - foreach (var usingDirective in usingDirectives) - { - sw.Write("using "); - sw.Write(usingDirective); - sw.WriteLine(';'); - } - - sw.WriteLine(); + sw.Write("using "); + sw.Write(usingDirective); + sw.WriteLine(';'); } + + sw.WriteLine(); } - else if ((outputBuilder is XmlOutputBuilder xmlOutputBuilder) && xmlOutputBuilder.Contents.Any()) + } + else if ((outputBuilder is XmlOutputBuilder xmlOutputBuilder) && xmlOutputBuilder.Contents.Any()) + { + sw.WriteLine(""); + sw.WriteLine(""); + + if (_config.HeaderText != string.Empty) { - sw.WriteLine(""); - sw.WriteLine(""); + sw.WriteLine(" "); - if (_config.HeaderText != string.Empty) + foreach (var ln in _config.HeaderText.Split('\n')) { - sw.WriteLine(" "); - - foreach (var ln in _config.HeaderText.Split('\n')) - { - sw.Write(" "); - sw.WriteLine(ln); - } - - sw.WriteLine(" "); + sw.Write(" "); + sw.WriteLine(ln); } + + sw.WriteLine(" "); } } + } - if (outputBuilder is CSharpOutputBuilder csOutputBuilder) - { - ForCSharp(csOutputBuilder); - } - else if (outputBuilder is XmlOutputBuilder xmlOutputBuilder) - { - ForXml(xmlOutputBuilder); - } + if (outputBuilder is CSharpOutputBuilder csOutputBuilder) + { + ForCSharp(csOutputBuilder); + } + else if (outputBuilder is XmlOutputBuilder xmlOutputBuilder) + { + ForXml(xmlOutputBuilder); + } - void ForCSharp(CSharpOutputBuilder csharpOutputBuilder) + void ForCSharp(CSharpOutputBuilder csharpOutputBuilder) + { + var indentationString = csharpOutputBuilder.IndentationString; + var nonTestName = outputBuilder.IsTestOutput ? outputBuilder.Name[0..^5] : outputBuilder.Name; + + if (emitNamespaceDeclaration) { - var indentationString = csharpOutputBuilder.IndentationString; - var nonTestName = outputBuilder.IsTestOutput ? outputBuilder.Name[0..^5] : outputBuilder.Name; + sw.Write("namespace "); + sw.Write(GetNamespace(nonTestName)); - if (emitNamespaceDeclaration) + if (csharpOutputBuilder.IsTestOutput) { - sw.Write("namespace "); - sw.Write(GetNamespace(nonTestName)); - - if (csharpOutputBuilder.IsTestOutput) - { - sw.Write(".UnitTests"); - } + sw.Write(".UnitTests"); + } - if (Config.GenerateFileScopedNamespaces) - { - sw.WriteLine(';'); - sw.WriteLine(); - indentationString = ""; - } - else - { - sw.WriteLine(); - sw.WriteLine('{'); - } + if (Config.GenerateFileScopedNamespaces) + { + sw.WriteLine(';'); + sw.WriteLine(); + indentationString = ""; } else { sw.WriteLine(); + sw.WriteLine('{'); } + } + else + { + sw.WriteLine(); + } - if (isMethodClass) - { - var isTopLevelStruct = _config.WithTypes.TryGetValue(nonTestName, out var withType) && (withType == "struct"); - - if (outputBuilder.IsTestOutput) - { - sw.Write(indentationString); - sw.Write("/// Provides validation of the "); - - if (isTopLevelStruct) - { - sw.Write("struct"); - } - else - { - sw.Write("class"); - } - - sw.WriteLine("."); - } - - if (_topLevelClassAttributes.TryGetValue(nonTestName, out var withAttributes)) - { - if (withAttributes.Any()) - { - foreach (var attribute in withAttributes) - { - if (outputBuilder.IsTestOutput && !attribute.StartsWith("SupportedOSPlatform(")) - { - continue; - } - - sw.Write(indentationString); - sw.Write('['); - sw.Write(attribute); - sw.WriteLine(']'); - } - } - } + if (isMethodClass) + { + var isTopLevelStruct = _config.WithTypes.TryGetValue(nonTestName, out var withType) && (withType == "struct"); + if (outputBuilder.IsTestOutput) + { sw.Write(indentationString); - sw.Write(GetMethodClassAccessSpecifier(outputBuilder.Name).AsString()); - sw.Write(' '); - - if (outputBuilder.IsTestOutput || !isTopLevelStruct) - { - sw.Write("static "); - } - - if ((_topLevelClassIsUnsafe.TryGetValue(nonTestName, out var isUnsafe) && isUnsafe) || (outputBuilder.IsTestOutput && isTopLevelStruct)) - { - sw.Write("unsafe "); - } + sw.Write("/// Provides validation of the "); - sw.Write("partial "); - - if (!outputBuilder.IsTestOutput && isTopLevelStruct) + if (isTopLevelStruct) { - sw.Write("struct "); + sw.Write("struct"); } else { - sw.Write("class "); - } - - sw.Write(outputBuilder.Name); - - if (_topLevelClassHasGuidMember.TryGetValue(outputBuilder.Name, out var hasGuidMember) && hasGuidMember) - { - sw.Write(" : INativeGuid"); - } - - sw.WriteLine(); - sw.Write(indentationString); - sw.Write('{'); - - if ((!outputBuilder.IsTestOutput && !isTopLevelStruct) || !string.IsNullOrEmpty(csharpOutputBuilder.Contents.First())) - { - sw.WriteLine(); + sw.Write("class"); } - indentationString += csharpOutputBuilder.IndentationString; + sw.WriteLine("."); } - foreach (var line in csharpOutputBuilder.Contents) + if (_topLevelClassAttributes.TryGetValue(nonTestName, out var withAttributes)) { - if (string.IsNullOrWhiteSpace(line)) - { - sw.WriteLine(); - } - else + if (withAttributes.Any()) { - sw.Write(indentationString); - sw.WriteLine(line); + foreach (var attribute in withAttributes) + { + if (outputBuilder.IsTestOutput && !attribute.StartsWith("SupportedOSPlatform(")) + { + continue; + } + + sw.Write(indentationString); + sw.Write('['); + sw.Write(attribute); + sw.WriteLine(']'); + } } } - if (isMethodClass) - { - indentationString = indentationString[..^csharpOutputBuilder.IndentationString.Length]; + sw.Write(indentationString); + sw.Write(GetMethodClassAccessSpecifier(outputBuilder.Name).AsString()); + sw.Write(' '); - sw.Write(indentationString); - sw.WriteLine('}'); + if (outputBuilder.IsTestOutput || !isTopLevelStruct) + { + sw.Write("static "); } - if (_config.GenerateMultipleFiles && !Config.GenerateFileScopedNamespaces) + if ((_topLevelClassIsUnsafe.TryGetValue(nonTestName, out var isUnsafe) && isUnsafe) || (outputBuilder.IsTestOutput && isTopLevelStruct)) { - sw.WriteLine('}'); + sw.Write("unsafe "); } - } - void ForXml(XmlOutputBuilder xmlOutputBuilder) - { - const string Indent = " "; - var indentationString = Indent; + sw.Write("partial "); - if (emitNamespaceDeclaration) + if (!outputBuilder.IsTestOutput && isTopLevelStruct) { - sw.Write(indentationString); - sw.Write(""); + sw.Write("struct "); } - - indentationString += Indent; - - if (isMethodClass) + else { - sw.Write(indentationString); - sw.Write("'); - indentationString += Indent; + if (_topLevelClassHasGuidMember.TryGetValue(outputBuilder.Name, out var hasGuidMember) && hasGuidMember) + { + sw.Write(" : INativeGuid"); } - foreach (var line in xmlOutputBuilder.Contents) + sw.WriteLine(); + sw.Write(indentationString); + sw.Write('{'); + + if ((!outputBuilder.IsTestOutput && !isTopLevelStruct) || !string.IsNullOrEmpty(csharpOutputBuilder.Contents.First())) { - if (string.IsNullOrWhiteSpace(line)) - { - sw.WriteLine(); - } - else - { - sw.Write(indentationString); - sw.WriteLine(line); - } + sw.WriteLine(); } - if (isMethodClass) + indentationString += csharpOutputBuilder.IndentationString; + } + + foreach (var line in csharpOutputBuilder.Contents) + { + if (string.IsNullOrWhiteSpace(line)) { - indentationString = indentationString[..^Indent.Length]; - sw.Write(indentationString); - sw.WriteLine(""); + sw.WriteLine(); } - - if (_config.GenerateMultipleFiles) + else { - indentationString = indentationString[..^Indent.Length]; sw.Write(indentationString); - sw.WriteLine(""); - sw.WriteLine(""); + sw.WriteLine(line); } } - } - private void Dispose(bool isDisposing) - { - Debug.Assert(_outputBuilder is null); - - if (_disposed) + if (isMethodClass) { - return; - } - _disposed = true; - - if (isDisposing) - { - Close(); - } - _index.Dispose(); - } - - private static string EscapeName(string name) - { - switch (name) - { - case "abstract": - case "as": - case "base": - case "bool": - case "break": - case "byte": - case "case": - case "catch": - case "char": - case "checked": - case "class": - case "const": - case "continue": - case "decimal": - case "default": - case "delegate": - case "do": - case "double": - case "else": - case "enum": - case "event": - case "explicit": - case "extern": - case "false": - case "finally": - case "fixed": - case "float": - case "for": - case "foreach": - case "goto": - case "if": - case "implicit": - case "in": - case "int": - case "interface": - case "internal": - case "is": - case "lock": - case "long": - case "namespace": - case "new": - case "null": - case "object": - case "operator": - case "out": - case "override": - case "params": - case "private": - case "protected": - case "public": - case "readonly": - case "ref": - case "return": - case "sbyte": - case "sealed": - case "short": - case "sizeof": - case "stackalloc": - case "static": - case "string": - case "struct": - case "switch": - case "this": - case "throw": - case "true": - case "try": - case "typeof": - case "uint": - case "ulong": - case "unchecked": - case "unsafe": - case "ushort": - case "using": - case "using static": - case "virtual": - case "void": - case "volatile": - case "while": - { - return $"@{name}"; - } + indentationString = indentationString[..^csharpOutputBuilder.IndentationString.Length]; - default: - { - return name; - } + sw.Write(indentationString); + sw.WriteLine('}'); } - } - private string EscapeAndStripName(string name) - { - if (name.StartsWith(_config.MethodPrefixToStrip)) + if (_config.GenerateMultipleFiles && !Config.GenerateFileScopedNamespaces) { - name = name[_config.MethodPrefixToStrip.Length..]; + sw.WriteLine('}'); } - - return EscapeName(name); } - internal static string EscapeCharacter(char value) => value switch { - '\0' => "\\0", - '\\' => "\\\\", - '\r' => "\\r", - '\n' => "\\n", - '\t' => "\\t", - '\'' => "\\'", - _ => value.ToString(), - }; - - internal static string EscapeString(string value) => value.Replace("\0", "\\0") - .Replace("\\", "\\\\") - .Replace("\r", "\\r") - .Replace("\n", "\\n") - .Replace("\t", "\\t") - .Replace("\"", "\\\""); - - private AccessSpecifier GetAccessSpecifier(NamedDecl namedDecl, bool matchStar) + void ForXml(XmlOutputBuilder xmlOutputBuilder) { - if (!TryGetRemappedValue(namedDecl, _config.WithAccessSpecifiers, out var accessSpecifier, matchStar) || (accessSpecifier == AccessSpecifier.None)) - { - switch (namedDecl.Access) - { - case CX_CXXAccessSpecifier.CX_CXXInvalidAccessSpecifier: - { - // Top level declarations will have an invalid access specifier - accessSpecifier = AccessSpecifier.Public; - break; - } + const string Indent = " "; + var indentationString = Indent; - case CX_CXXAccessSpecifier.CX_CXXPublic: - { - accessSpecifier = AccessSpecifier.Public; - break; - } + if (emitNamespaceDeclaration) + { + sw.Write(indentationString); + sw.Write(""); + } - case CX_CXXAccessSpecifier.CX_CXXProtected: - { - accessSpecifier = AccessSpecifier.Protected; - break; - } + indentationString += Indent; - case CX_CXXAccessSpecifier.CX_CXXPrivate: - { - accessSpecifier = AccessSpecifier.Private; - break; - } + if (isMethodClass) + { + sw.Write(indentationString); + sw.Write("'); + indentationString += Indent; + } - private AccessSpecifier GetMethodClassAccessSpecifier(string name) - { - var accessMap = _config.WithAccessSpecifiers; + foreach (var line in xmlOutputBuilder.Contents) + { + if (string.IsNullOrWhiteSpace(line)) + { + sw.WriteLine(); + } + else + { + sw.Write(indentationString); + sw.WriteLine(line); + } + } - if (accessMap.TryGetValue(name, out var accessSpecifier)) + if (isMethodClass) { - return accessSpecifier; + indentationString = indentationString[..^Indent.Length]; + sw.Write(indentationString); + sw.WriteLine(""); } - if (accessMap.TryGetValue("*", out accessSpecifier)) + if (_config.GenerateMultipleFiles) { - return accessSpecifier; + indentationString = indentationString[..^Indent.Length]; + sw.Write(indentationString); + sw.WriteLine(""); + sw.WriteLine(""); } + } + } - return AccessSpecifier.None; + private void Dispose(bool isDisposing) + { + Debug.Assert(_outputBuilder is null); + + if (_disposed) + { + return; } + _disposed = true; - private static string GetAnonymousName(Cursor cursor, string kind) + if (isDisposing) { - cursor.Location.GetFileLocation(out var file, out var line, out var column, out _); - var fileName = Path.GetFileNameWithoutExtension(file.Name.ToString()); - return $"__Anonymous{kind}_{fileName}_L{line}_C{column}"; + Close(); } + _index.Dispose(); + } - private string GetArtificialFixedSizedBufferName(FieldDecl fieldDecl) + private static string EscapeName(string name) + { + switch (name) { - var name = GetRemappedCursorName(fieldDecl); - return $"_{name}_e__FixedBuffer"; + case "abstract": + case "as": + case "base": + case "bool": + case "break": + case "byte": + case "case": + case "catch": + case "char": + case "checked": + case "class": + case "const": + case "continue": + case "decimal": + case "default": + case "delegate": + case "do": + case "double": + case "else": + case "enum": + case "event": + case "explicit": + case "extern": + case "false": + case "finally": + case "fixed": + case "float": + case "for": + case "foreach": + case "goto": + case "if": + case "implicit": + case "in": + case "int": + case "interface": + case "internal": + case "is": + case "lock": + case "long": + case "namespace": + case "new": + case "null": + case "object": + case "operator": + case "out": + case "override": + case "params": + case "private": + case "protected": + case "public": + case "readonly": + case "ref": + case "return": + case "sbyte": + case "sealed": + case "short": + case "sizeof": + case "stackalloc": + case "static": + case "string": + case "struct": + case "switch": + case "this": + case "throw": + case "true": + case "try": + case "typeof": + case "uint": + case "ulong": + case "unchecked": + case "unsafe": + case "ushort": + case "using": + case "using static": + case "virtual": + case "void": + case "volatile": + case "while": + { + return $"@{name}"; + } + + default: + { + return name; + } } + } - private Type[] GetBitfieldCount(RecordDecl recordDecl) + private string EscapeAndStripName(string name) + { + if (name.StartsWith(_config.MethodPrefixToStrip)) { - var types = new List(recordDecl.Fields.Count); + name = name[_config.MethodPrefixToStrip.Length..]; + } - var count = 0; - var previousSize = 0L; - var remainingBits = 0L; + return EscapeName(name); + } - foreach (var fieldDecl in recordDecl.Fields) + internal static string EscapeCharacter(char value) => value switch { + '\0' => "\\0", + '\\' => "\\\\", + '\r' => "\\r", + '\n' => "\\n", + '\t' => "\\t", + '\'' => "\\'", + _ => value.ToString(), + }; + + internal static string EscapeString(string value) => value.Replace("\0", "\\0") + .Replace("\\", "\\\\") + .Replace("\r", "\\r") + .Replace("\n", "\\n") + .Replace("\t", "\\t") + .Replace("\"", "\\\""); + + private AccessSpecifier GetAccessSpecifier(NamedDecl namedDecl, bool matchStar) + { + if (!TryGetRemappedValue(namedDecl, _config.WithAccessSpecifiers, out var accessSpecifier, matchStar) || (accessSpecifier == AccessSpecifier.None)) + { + switch (namedDecl.Access) { - if (!fieldDecl.IsBitField) + case CX_CXXAccessSpecifier.CX_CXXInvalidAccessSpecifier: { - previousSize = 0; - remainingBits = 0; - continue; + // Top level declarations will have an invalid access specifier + accessSpecifier = AccessSpecifier.Public; + break; } - var currentSize = fieldDecl.Type.Handle.SizeOf; - - if ((!_config.GenerateUnixTypes && (currentSize != previousSize)) || (fieldDecl.BitWidthValue > remainingBits)) + case CX_CXXAccessSpecifier.CX_CXXPublic: { - count++; - remainingBits = currentSize * 8; - previousSize = 0; - - var type = fieldDecl.Type; - - if (type.CanonicalType is EnumType enumType) - { - type = enumType.Decl.IntegerType; - } - - types.Add(type); + accessSpecifier = AccessSpecifier.Public; + break; } - else if (_config.GenerateUnixTypes && (currentSize > previousSize)) - { - remainingBits += (currentSize - previousSize) * 8; - - var type = fieldDecl.Type; - - if (type.CanonicalType is EnumType enumType) - { - type = enumType.Decl.IntegerType; - } - types[^1] = type; + case CX_CXXAccessSpecifier.CX_CXXProtected: + { + accessSpecifier = AccessSpecifier.Protected; + break; } - remainingBits -= fieldDecl.BitWidthValue; - previousSize = Math.Max(previousSize, currentSize); - } - - return types.ToArray(); - } - - private CallingConvention GetCallingConvention(Cursor cursor, Cursor context, Type type) - { - if (cursor is FunctionDecl functionDecl) - { - if (functionDecl.IsVariadic) + case CX_CXXAccessSpecifier.CX_CXXPrivate: { - return CallingConvention.Cdecl; + accessSpecifier = AccessSpecifier.Private; + break; } - } - if (cursor is NamedDecl namedDecl) - { - if (TryGetRemappedValue(namedDecl, _config.WithCallConvs, out var callConv, matchStar: true)) + default: { - if (Enum.TryParse(callConv, true, out var remappedCallingConvention)) - { - return remappedCallingConvention; - } - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported manually-specified calling convention: '{callConv}'. Determining convention from cursor.", cursor); + accessSpecifier = AccessSpecifier.Internal; + AddDiagnostic(DiagnosticLevel.Warning, $"Unknown access specifier: '{namedDecl.Access}'. Falling back to '{accessSpecifier}'.", namedDecl); + break; } } + } - var wasRemapped = false; - return GetCallingConvention(cursor, context, type, ref wasRemapped); + return accessSpecifier; + } + + private AccessSpecifier GetMethodClassAccessSpecifier(string name) + { + var accessMap = _config.WithAccessSpecifiers; + + if (accessMap.TryGetValue(name, out var accessSpecifier)) + { + return accessSpecifier; } - private CallingConvention GetCallingConvention(Cursor cursor, Cursor context, Type type, ref bool wasRemapped) + if (accessMap.TryGetValue("*", out accessSpecifier)) { - var remappedName = GetRemappedTypeName(cursor, context, type, out _, ignoreTransparentStructsWhereRequired: false, skipUsing: true); + return accessSpecifier; + } - if (_config.WithCallConvs.TryGetValue(remappedName, out var callConv) || _config.WithCallConvs.TryGetValue("*", out callConv)) - { - if (Enum.TryParse(callConv, true, out var remappedCallingConvention)) - { - wasRemapped = true; - return remappedCallingConvention; - } - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported manually-specified calling convention: '{callConv}'. Determining convention from cursor.", cursor); - } + return AccessSpecifier.None; + } - if (type is AttributedType attributedType) - { - var callingConvention = GetCallingConvention(cursor, context, attributedType.ModifiedType, ref wasRemapped); + private static string GetAnonymousName(Cursor cursor, string kind) + { + cursor.Location.GetFileLocation(out var file, out var line, out var column, out _); + var fileName = Path.GetFileNameWithoutExtension(file.Name.ToString()); + return $"__Anonymous{kind}_{fileName}_L{line}_C{column}"; + } - if (wasRemapped) - { - return callingConvention; - } + private string GetArtificialFixedSizedBufferName(FieldDecl fieldDecl) + { + var name = GetRemappedCursorName(fieldDecl); + return $"_{name}_e__FixedBuffer"; + } - switch (attributedType.AttrKind) - { - case CX_AttrKind.CX_AttrKind_MSABI: - case CX_AttrKind.CX_AttrKind_SysVABI: - { - return CallingConvention.Winapi; - } + private Type[] GetBitfieldCount(RecordDecl recordDecl) + { + var types = new List(recordDecl.Fields.Count); - case CX_AttrKind.CX_AttrKind_CDecl: - { - return CallingConvention.Cdecl; - } + var count = 0; + var previousSize = 0L; + var remainingBits = 0L; - case CX_AttrKind.CX_AttrKind_FastCall: - { - return CallingConvention.FastCall; - } + foreach (var fieldDecl in recordDecl.Fields) + { + if (!fieldDecl.IsBitField) + { + previousSize = 0; + remainingBits = 0; + continue; + } - case CX_AttrKind.CX_AttrKind_StdCall: - { - return CallingConvention.StdCall; - } + var currentSize = fieldDecl.Type.Handle.SizeOf; - case CX_AttrKind.CX_AttrKind_ThisCall: - { - return CallingConvention.ThisCall; - } + if ((!_config.GenerateUnixTypes && (currentSize != previousSize)) || (fieldDecl.BitWidthValue > remainingBits)) + { + count++; + remainingBits = currentSize * 8; + previousSize = 0; - case CX_AttrKind.CX_AttrKind_AArch64VectorPcs: - case CX_AttrKind.CX_AttrKind_Pcs: - case CX_AttrKind.CX_AttrKind_PreserveAll: - case CX_AttrKind.CX_AttrKind_PreserveMost: - case CX_AttrKind.CX_AttrKind_RegCall: - case CX_AttrKind.CX_AttrKind_VectorCall: - { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported calling convention: '{attributedType.AttrKind}'.", cursor); - return callingConvention; - } + var type = fieldDecl.Type; - default: - { - return callingConvention; - } + if (type.CanonicalType is EnumType enumType) + { + type = enumType.Decl.IntegerType; } + + types.Add(type); } - else if (type is FunctionType functionType) + else if (_config.GenerateUnixTypes && (currentSize > previousSize)) { - var callingConv = functionType.CallConv; + remainingBits += (currentSize - previousSize) * 8; - switch (callingConv) - { - case CXCallingConv.CXCallingConv_C: - { - if ((cursor is CXXMethodDecl cxxMethodDecl) && cxxMethodDecl.IsInstance) - { - return CallingConvention.ThisCall; - } - return CallingConvention.Cdecl; - } + var type = fieldDecl.Type; - case CXCallingConv.CXCallingConv_X86StdCall: - { - return CallingConvention.StdCall; - } + if (type.CanonicalType is EnumType enumType) + { + type = enumType.Decl.IntegerType; + } - case CXCallingConv.CXCallingConv_X86FastCall: - { - return CallingConvention.FastCall; - } + types[^1] = type; + } - case CXCallingConv.CXCallingConv_X86ThisCall: - { - return CallingConvention.ThisCall; - } + remainingBits -= fieldDecl.BitWidthValue; + previousSize = Math.Max(previousSize, currentSize); + } - case CXCallingConv.CXCallingConv_Win64: - { - return CallingConvention.Winapi; - } + return types.ToArray(); + } - default: - { - const CallingConvention Name = CallingConvention.Winapi; - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported calling convention: '{callingConv}'. Falling back to '{Name}'.", cursor); - return Name; - } - } - } - else if (type is PointerType pointerType) - { - return GetCallingConvention(cursor, context, pointerType.PointeeType, ref wasRemapped); - } - else if (type is TypedefType typedefType) - { - return GetCallingConvention(cursor, context, typedefType.Decl.UnderlyingType, ref wasRemapped); - } - else + private CallingConvention GetCallingConvention(Cursor cursor, Cursor context, Type type) + { + if (cursor is FunctionDecl functionDecl) + { + if (functionDecl.IsVariadic) { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported type: '{type.TypeClass}'. Falling back to canonical type.", cursor); - return GetCallingConvention(cursor, context, type.CanonicalType, ref wasRemapped); + return CallingConvention.Cdecl; } } - private string GetCursorName(NamedDecl namedDecl) + if (cursor is NamedDecl namedDecl) { - if (!_cursorNames.TryGetValue(namedDecl, out var name)) + if (TryGetRemappedValue(namedDecl, _config.WithCallConvs, out var callConv, matchStar: true)) { - name = namedDecl.Name.Replace('\\', '/'); - - if (namedDecl is CXXConstructorDecl cxxConstructorDecl) - { - name = GetCursorName(cxxConstructorDecl.Parent); - } - else if (namedDecl is CXXDestructorDecl) - { - name = "Dispose"; - } - else if (string.IsNullOrWhiteSpace(name)) + if (Enum.TryParse(callConv, true, out var remappedCallingConvention)) { - if (namedDecl is TypeDecl typeDecl) - { - name = (typeDecl is TagDecl tagDecl) && tagDecl.Handle.IsAnonymous - ? GetAnonymousName(tagDecl, tagDecl.TypeForDecl.KindSpelling) - : GetTypeName(namedDecl, context: null, typeDecl.TypeForDecl, ignoreTransparentStructsWhereRequired: false, out _); - } - else if (namedDecl is ParmVarDecl) - { - name = "param"; - } - else if (namedDecl is FieldDecl fieldDecl) - { - name = GetAnonymousName(fieldDecl, fieldDecl.CursorKindSpelling); - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported anonymous named declaration: '{namedDecl.DeclKindName}'.", namedDecl); - } + return remappedCallingConvention; } - - _cursorNames[namedDecl] = name; + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported manually-specified calling convention: '{callConv}'. Determining convention from cursor.", cursor); } + } + + var wasRemapped = false; + return GetCallingConvention(cursor, context, type, ref wasRemapped); + } + + private CallingConvention GetCallingConvention(Cursor cursor, Cursor context, Type type, ref bool wasRemapped) + { + var remappedName = GetRemappedTypeName(cursor, context, type, out _, ignoreTransparentStructsWhereRequired: false, skipUsing: true); - Debug.Assert(!string.IsNullOrWhiteSpace(name)); - return name; + if (_config.WithCallConvs.TryGetValue(remappedName, out var callConv) || _config.WithCallConvs.TryGetValue("*", out callConv)) + { + if (Enum.TryParse(callConv, true, out var remappedCallingConvention)) + { + wasRemapped = true; + return remappedCallingConvention; + } + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported manually-specified calling convention: '{callConv}'. Determining convention from cursor.", cursor); } - private string GetCursorQualifiedName(NamedDecl namedDecl, bool truncateParameters = false) + if (type is AttributedType attributedType) { - if (!_cursorQualifiedNames.TryGetValue((namedDecl, truncateParameters), out var qualifiedName)) + var callingConvention = GetCallingConvention(cursor, context, attributedType.ModifiedType, ref wasRemapped); + + if (wasRemapped) { - var parts = new Stack(); - Decl decl = namedDecl; + return callingConvention; + } - do + switch (attributedType.AttrKind) + { + case CX_AttrKind.CX_AttrKind_MSABI: + case CX_AttrKind.CX_AttrKind_SysVABI: { - if (decl is NamedDecl parentNamedDecl) - { - parts.Push(parentNamedDecl); - } - - decl = (decl.DeclContext is null) && (decl is CXXMethodDecl cxxMethodDecl) - ? cxxMethodDecl.ThisObjectType.AsCXXRecordDecl - : (Decl)decl.DeclContext; + return CallingConvention.Winapi; } - while (decl != null); - var qualifiedNameBuilder = new StringBuilder(); - - var part = parts.Pop(); - - while (parts.Count != 0) + case CX_AttrKind.CX_AttrKind_CDecl: { - AppendNamedDecl(part, GetCursorName(part), qualifiedNameBuilder); - _ = qualifiedNameBuilder.Append("::"); - part = parts.Pop(); + return CallingConvention.Cdecl; } - AppendNamedDecl(part, GetCursorName(part), qualifiedNameBuilder); - - qualifiedName = qualifiedNameBuilder.ToString(); - _cursorQualifiedNames[(namedDecl, truncateParameters)] = qualifiedName; - } - - Debug.Assert(!string.IsNullOrWhiteSpace(qualifiedName)); - return qualifiedName; - - void AppendFunctionParameters(CXType functionType, StringBuilder qualifiedName) - { - if (truncateParameters) + case CX_AttrKind.CX_AttrKind_FastCall: { - return; + return CallingConvention.FastCall; } - _ = qualifiedName.Append('('); - - if (functionType.NumArgTypes != 0) + case CX_AttrKind.CX_AttrKind_StdCall: { - _ = qualifiedName.Append(functionType.GetArgType(0).Spelling); - - for (uint i = 1; i < functionType.NumArgTypes; i++) - { - _ = qualifiedName.Append(','); - _ = qualifiedName.Append(' '); - _ = qualifiedName.Append(functionType.GetArgType(i).Spelling); - } + return CallingConvention.StdCall; } - _ = qualifiedName.Append(')'); - _ = qualifiedName.Append(':'); - - _ = qualifiedName.Append(functionType.ResultType.Spelling); - - if (functionType.ExceptionSpecificationType == CXCursor_ExceptionSpecificationKind.CXCursor_ExceptionSpecificationKind_NoThrow) + case CX_AttrKind.CX_AttrKind_ThisCall: { - _ = qualifiedName.Append(' '); - _ = qualifiedName.Append("nothrow"); + return CallingConvention.ThisCall; } - } - - void AppendNamedDecl(NamedDecl namedDecl, string name, StringBuilder qualifiedName) - { - _ = qualifiedName.Append(name); - if (namedDecl is FunctionDecl functionDecl) + case CX_AttrKind.CX_AttrKind_AArch64VectorPcs: + case CX_AttrKind.CX_AttrKind_Pcs: + case CX_AttrKind.CX_AttrKind_PreserveAll: + case CX_AttrKind.CX_AttrKind_PreserveMost: + case CX_AttrKind.CX_AttrKind_RegCall: + case CX_AttrKind.CX_AttrKind_VectorCall: { - AppendFunctionParameters(functionDecl.Type.Handle, qualifiedName); + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported calling convention: '{attributedType.AttrKind}'.", cursor); + return callingConvention; } - else if (namedDecl is TemplateDecl templateDecl) - { - AppendTemplateParameters(templateDecl, qualifiedName); - if (namedDecl is FunctionTemplateDecl functionTemplateDecl) - { - AppendFunctionParameters(functionTemplateDecl.Handle.Type, qualifiedName); - } - } - else if (namedDecl is ClassTemplateSpecializationDecl classTemplateSpecializationDecl) + default: { - AppendTemplateArguments(classTemplateSpecializationDecl, qualifiedName); + return callingConvention; } } + } + else if (type is FunctionType functionType) + { + var callingConv = functionType.CallConv; - void AppendTemplateArgument(TemplateArgument templateArgument, Decl parentDecl, StringBuilder qualifiedName) + switch (callingConv) { - switch (templateArgument.Kind) + case CXCallingConv.CXCallingConv_C: { - case CXTemplateArgumentKind.CXTemplateArgumentKind_Type: + if ((cursor is CXXMethodDecl cxxMethodDecl) && cxxMethodDecl.IsInstance) { - _ = qualifiedName.Append(templateArgument.AsType.AsString); - break; + return CallingConvention.ThisCall; } + return CallingConvention.Cdecl; + } - case CXTemplateArgumentKind.CXTemplateArgumentKind_Integral: - { - _ = qualifiedName.Append(templateArgument.AsIntegral); - break; - } + case CXCallingConv.CXCallingConv_X86StdCall: + { + return CallingConvention.StdCall; + } - default: - { - _ = qualifiedName.Append('?'); - break; - } + case CXCallingConv.CXCallingConv_X86FastCall: + { + return CallingConvention.FastCall; } - } - void AppendTemplateArguments(ClassTemplateSpecializationDecl classTemplateSpecializationDecl, StringBuilder qualifiedName) - { - if (truncateParameters) + case CXCallingConv.CXCallingConv_X86ThisCall: { - return; + return CallingConvention.ThisCall; } - _ = qualifiedName.Append('<'); - - var templateArgs = classTemplateSpecializationDecl.TemplateArgs; - - if (templateArgs.Any()) - { - AppendTemplateArgument(templateArgs[0], classTemplateSpecializationDecl, qualifiedName); - - for (var i = 1; i < templateArgs.Count; i++) - { - _ = qualifiedName.Append(','); - _ = qualifiedName.Append(' '); - AppendTemplateArgument(templateArgs[i], classTemplateSpecializationDecl, qualifiedName); - } - } - - _ = qualifiedName.Append('>'); - } - - void AppendTemplateParameters(TemplateDecl templateDecl, StringBuilder qualifiedName) - { - if (truncateParameters) + case CXCallingConv.CXCallingConv_Win64: { - return; + return CallingConvention.Winapi; } - _ = qualifiedName.Append('<'); - - var templateParameters = templateDecl.TemplateParameters; - - if (templateParameters.Any()) + default: { - _ = qualifiedName.Append(templateParameters[0].Name); - - for (var i = 1; i < templateParameters.Count; i++) - { - _ = qualifiedName.Append(','); - _ = qualifiedName.Append(' '); - _ = qualifiedName.Append(templateParameters[i].Name); - } + const CallingConvention Name = CallingConvention.Winapi; + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported calling convention: '{callingConv}'. Falling back to '{Name}'.", cursor); + return Name; } - - _ = qualifiedName.Append('>'); } } - - private static Expr GetExprAsWritten(Expr expr, bool removeParens) + else if (type is PointerType pointerType) { - do - { - if (expr is ImplicitCastExpr implicitCastExpr) - { - expr = implicitCastExpr.SubExprAsWritten; - } - else if (removeParens && (expr is ParenExpr parenExpr)) - { - expr = parenExpr.SubExpr; - } - else - { - return expr; - } - } - while (true); + return GetCallingConvention(cursor, context, pointerType.PointeeType, ref wasRemapped); + } + else if (type is TypedefType typedefType) + { + return GetCallingConvention(cursor, context, typedefType.Decl.UnderlyingType, ref wasRemapped); + } + else + { + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported type: '{type.TypeClass}'. Falling back to canonical type.", cursor); + return GetCallingConvention(cursor, context, type.CanonicalType, ref wasRemapped); } + } - private uint GetOverloadIndex(CXXMethodDecl cxxMethodDeclToMatch) + private string GetCursorName(NamedDecl namedDecl) + { + if (!_cursorNames.TryGetValue(namedDecl, out var name)) { - if (!_overloadIndices.TryGetValue(cxxMethodDeclToMatch, out var index)) + name = namedDecl.Name.Replace('\\', '/'); + + if (namedDecl is CXXConstructorDecl cxxConstructorDecl) { - index = GetOverloadIndex(cxxMethodDeclToMatch, cxxMethodDeclToMatch.Parent, baseIndex: 0); - _overloadIndices.Add(cxxMethodDeclToMatch, index); + name = GetCursorName(cxxConstructorDecl.Parent); } - return index; - - uint GetOverloadIndex(CXXMethodDecl cxxMethodDeclToMatch, CXXRecordDecl cxxRecordDecl, uint baseIndex) + else if (namedDecl is CXXDestructorDecl) { - var index = baseIndex; - - foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) - { - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - index = GetOverloadIndex(cxxMethodDeclToMatch, baseCxxRecordDecl, index); - } - - foreach (var cxxMethodDecl in cxxRecordDecl.Methods.OrderBy((cxxmd) => cxxmd.VtblIndex)) - { - if (IsExcluded(cxxMethodDecl)) - { - continue; - } - else if (cxxMethodDecl == cxxMethodDeclToMatch) - { - break; - } - else if (cxxMethodDecl.Name == cxxMethodDeclToMatch.Name) - { - index++; - } - } - - return index; + name = "Dispose"; } - } - - private static CXXRecordDecl GetRecordDecl(CXXBaseSpecifier cxxBaseSpecifier) - { - var baseType = cxxBaseSpecifier.Type; - - while (baseType is not RecordType) + else if (string.IsNullOrWhiteSpace(name)) { - if (baseType is AttributedType attributedType) + if (namedDecl is TypeDecl typeDecl) { - baseType = attributedType.ModifiedType; + name = (typeDecl is TagDecl tagDecl) && tagDecl.Handle.IsAnonymous + ? GetAnonymousName(tagDecl, tagDecl.TypeForDecl.KindSpelling) + : GetTypeName(namedDecl, context: null, typeDecl.TypeForDecl, ignoreTransparentStructsWhereRequired: false, out _); } - else if (baseType is ElaboratedType elaboratedType) + else if (namedDecl is ParmVarDecl) { - baseType = elaboratedType.CanonicalType; + name = "param"; } - else if (baseType is TemplateSpecializationType templateSpecializationType) + else if (namedDecl is FieldDecl fieldDecl) { - baseType = templateSpecializationType.CanonicalType; - } - else if (baseType is TypedefType typedefType) - { - baseType = typedefType.Decl.UnderlyingType; + name = GetAnonymousName(fieldDecl, fieldDecl.CursorKindSpelling); } else { - break; + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported anonymous named declaration: '{namedDecl.DeclKindName}'.", namedDecl); } } - var baseRecordType = (RecordType)baseType; - return (CXXRecordDecl)baseRecordType.Decl; + _cursorNames[namedDecl] = name; } - private string GetRemappedCursorName(NamedDecl namedDecl) - { - return GetRemappedCursorName(namedDecl, out _, skipUsing: false); - } + Debug.Assert(!string.IsNullOrWhiteSpace(name)); + return name; + } - private string GetRemappedCursorName(NamedDecl namedDecl, out string nativeTypeName, bool skipUsing) + private string GetCursorQualifiedName(NamedDecl namedDecl, bool truncateParameters = false) + { + if (!_cursorQualifiedNames.TryGetValue((namedDecl, truncateParameters), out var qualifiedName)) { - nativeTypeName = GetCursorName(namedDecl); - - var name = GetCursorQualifiedName(namedDecl); - var remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out var wasRemapped, skipUsing); + var parts = new Stack(); + Decl decl = namedDecl; - if (wasRemapped) + do { - return remappedName; - } - - name = name.Replace("::", "."); - remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out wasRemapped, skipUsing); + if (decl is NamedDecl parentNamedDecl) + { + parts.Push(parentNamedDecl); + } - if (wasRemapped) - { - return remappedName; + decl = (decl.DeclContext is null) && (decl is CXXMethodDecl cxxMethodDecl) + ? cxxMethodDecl.ThisObjectType.AsCXXRecordDecl + : (Decl)decl.DeclContext; } + while (decl != null); + var qualifiedNameBuilder = new StringBuilder(); - name = GetCursorQualifiedName(namedDecl, truncateParameters: true); - remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out wasRemapped, skipUsing); + var part = parts.Pop(); - if (wasRemapped) + while (parts.Count != 0) { - return remappedName; + AppendNamedDecl(part, GetCursorName(part), qualifiedNameBuilder); + _ = qualifiedNameBuilder.Append("::"); + part = parts.Pop(); } - name = name.Replace("::", "."); - remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out wasRemapped, skipUsing); + AppendNamedDecl(part, GetCursorName(part), qualifiedNameBuilder); - if (wasRemapped) - { - return remappedName; - } + qualifiedName = qualifiedNameBuilder.ToString(); + _cursorQualifiedNames[(namedDecl, truncateParameters)] = qualifiedName; + } - name = nativeTypeName; - remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out wasRemapped, skipUsing); + Debug.Assert(!string.IsNullOrWhiteSpace(qualifiedName)); + return qualifiedName; - if (wasRemapped) + void AppendFunctionParameters(CXType functionType, StringBuilder qualifiedName) + { + if (truncateParameters) { - return remappedName; + return; } - if (namedDecl is CXXConstructorDecl cxxConstructorDecl) - { - remappedName = GetRemappedCursorName(cxxConstructorDecl.Parent); - } - else if (namedDecl is FieldDecl fieldDecl) + _ = qualifiedName.Append('('); + + if (functionType.NumArgTypes != 0) { - if (name.StartsWith("__AnonymousFieldDecl_")) - { - remappedName = "Anonymous"; + _ = qualifiedName.Append(functionType.GetArgType(0).Spelling); - if (fieldDecl.Parent.AnonymousFields.Count > 1) - { - var index = fieldDecl.Parent.AnonymousFields.IndexOf(fieldDecl) + 1; - remappedName += index.ToString(); - } + for (uint i = 1; i < functionType.NumArgTypes; i++) + { + _ = qualifiedName.Append(','); + _ = qualifiedName.Append(' '); + _ = qualifiedName.Append(functionType.GetArgType(i).Spelling); } } - else if ((namedDecl is RecordDecl recordDecl) && name.StartsWith("__AnonymousRecord_")) - { - if (recordDecl.Parent is RecordDecl parentRecordDecl) - { - remappedName = "_Anonymous"; - var matchingField = parentRecordDecl.Fields.Where((fieldDecl) => fieldDecl.Type.CanonicalType == recordDecl.TypeForDecl.CanonicalType).FirstOrDefault(); + _ = qualifiedName.Append(')'); + _ = qualifiedName.Append(':'); - if (matchingField != null) - { - remappedName = "_"; - remappedName += GetRemappedCursorName(matchingField); - } - else if (parentRecordDecl.AnonymousRecords.Count > 1) - { - var index = parentRecordDecl.AnonymousRecords.IndexOf(recordDecl) + 1; - remappedName += index.ToString(); - } + _ = qualifiedName.Append(functionType.ResultType.Spelling); - remappedName += $"_e__{(recordDecl.IsUnion ? "Union" : "Struct")}"; - } + if (functionType.ExceptionSpecificationType == CXCursor_ExceptionSpecificationKind.CXCursor_ExceptionSpecificationKind_NoThrow) + { + _ = qualifiedName.Append(' '); + _ = qualifiedName.Append("nothrow"); } - - return remappedName; } - private string GetRemappedName(string name, Cursor cursor, bool tryRemapOperatorName, out bool wasRemapped, bool skipUsing = false) + void AppendNamedDecl(NamedDecl namedDecl, string name, StringBuilder qualifiedName) { - return GetRemappedName(name, cursor, tryRemapOperatorName, out wasRemapped, skipUsing, skipUsingIfNotRemapped: skipUsing); - } + _ = qualifiedName.Append(name); - private string GetRemappedName(string name, Cursor cursor, bool tryRemapOperatorName, out bool wasRemapped, bool skipUsing, bool skipUsingIfNotRemapped) - { - if (_config.RemappedNames.TryGetValue(name, out var remappedName)) + if (namedDecl is FunctionDecl functionDecl) { - wasRemapped = true; - _ = _usedRemappings.Add(name); - return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsing); + AppendFunctionParameters(functionDecl.Type.Handle, qualifiedName); } - - if (name.StartsWith("const ")) + else if (namedDecl is TemplateDecl templateDecl) { - var tmpName = name[6..]; + AppendTemplateParameters(templateDecl, qualifiedName); - if (_config.RemappedNames.TryGetValue(tmpName, out remappedName)) + if (namedDecl is FunctionTemplateDecl functionTemplateDecl) { - - wasRemapped = true; - _ = _usedRemappings.Add(tmpName); - return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsing); + AppendFunctionParameters(functionTemplateDecl.Handle.Type, qualifiedName); } } - - remappedName = name; - - if ((cursor is FunctionDecl functionDecl) && tryRemapOperatorName && TryRemapOperatorName(ref remappedName, functionDecl)) + else if (namedDecl is ClassTemplateSpecializationDecl classTemplateSpecializationDecl) { - wasRemapped = true; - // We don't track remapped operators in _usedRemappings - return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsing); + AppendTemplateArguments(classTemplateSpecializationDecl, qualifiedName); } + } - if ((cursor is CXXBaseSpecifier cxxBaseSpecifier) && remappedName.StartsWith("__AnonymousBase_")) + void AppendTemplateArgument(TemplateArgument templateArgument, Decl parentDecl, StringBuilder qualifiedName) + { + switch (templateArgument.Kind) { - remappedName = "Base"; - - if (_cxxRecordDeclContext.Bases.Count > 1) + case CXTemplateArgumentKind.CXTemplateArgumentKind_Type: { - var index = _cxxRecordDeclContext.Bases.IndexOf(cxxBaseSpecifier) + 1; - remappedName += index.ToString(); + _ = qualifiedName.Append(templateArgument.AsType.AsString); + break; } - wasRemapped = true; - return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsing); - } - - wasRemapped = false; - return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsingIfNotRemapped); - - string AddUsingDirectiveIfNeeded(IOutputBuilder outputBuilder, string remappedName, bool skipUsing) - { - if (!skipUsing) + case CXTemplateArgumentKind.CXTemplateArgumentKind_Integral: { - if (s_needsSystemSupportRegex.IsMatch(remappedName)) - { - outputBuilder?.EmitSystemSupport(); - } - - var namespaceName = GetNamespace(remappedName); - var needsUsing = false; - - if (_currentNamespace is not null) - { - if (!_currentNamespace.StartsWith(namespaceName)) - { - needsUsing = true; - } - else if ((_currentNamespace.Length > namespaceName.Length) && (_currentNamespace[namespaceName.Length] != '.')) - { - needsUsing = true; - } - } - - if (needsUsing) - { - outputBuilder?.EmitUsingDirective(namespaceName); - } + _ = qualifiedName.Append(templateArgument.AsIntegral); + break; } - return remappedName; + default: + { + _ = qualifiedName.Append('?'); + break; + } } } - private string GetRemappedTypeName(Cursor cursor, Cursor context, Type type, out string nativeTypeName, bool skipUsing = false, bool ignoreTransparentStructsWhereRequired = false) + void AppendTemplateArguments(ClassTemplateSpecializationDecl classTemplateSpecializationDecl, StringBuilder qualifiedName) { - var name = GetTypeName(cursor, context, type, ignoreTransparentStructsWhereRequired, out nativeTypeName); - - var nameToCheck = nativeTypeName; - var remappedName = GetRemappedName(nameToCheck, cursor, tryRemapOperatorName: false, out var wasRemapped, skipUsing, skipUsingIfNotRemapped: true); - - if (wasRemapped) + if (truncateParameters) { - return remappedName; + return; } - nameToCheck = nameToCheck.Replace("::", "."); - remappedName = GetRemappedName(nameToCheck, cursor, tryRemapOperatorName: false, out wasRemapped, skipUsing, skipUsingIfNotRemapped: true); + _ = qualifiedName.Append('<'); - if (wasRemapped) - { - return remappedName; - } - - nameToCheck = name; - remappedName = GetRemappedName(nameToCheck, cursor, tryRemapOperatorName: false, out wasRemapped, skipUsing); + var templateArgs = classTemplateSpecializationDecl.TemplateArgs; - if (!wasRemapped) + if (templateArgs.Any()) { - var canonicalType = type.CanonicalType; + AppendTemplateArgument(templateArgs[0], classTemplateSpecializationDecl, qualifiedName); - if (canonicalType is ConstantArrayType or IncompleteArrayType) - { - var arrayType = (ArrayType)canonicalType; - - if (arrayType.ElementType is RecordType) - { - canonicalType = arrayType.ElementType; - } - } - else if ((canonicalType is IncompleteArrayType incompleteArrayType) && (incompleteArrayType.ElementType is RecordType)) + for (var i = 1; i < templateArgs.Count; i++) { - canonicalType = incompleteArrayType.ElementType; + _ = qualifiedName.Append(','); + _ = qualifiedName.Append(' '); + AppendTemplateArgument(templateArgs[i], classTemplateSpecializationDecl, qualifiedName); } + } - if ((canonicalType is RecordType recordType) && remappedName.StartsWith("__AnonymousRecord_")) - { - var recordDecl = recordType.Decl; - remappedName = "_Anonymous"; - - if (recordDecl.Parent is RecordDecl parentRecordDecl) - { - var matchingField = parentRecordDecl.Fields.Where((fieldDecl) => fieldDecl.Type.CanonicalType == recordType).FirstOrDefault(); - - if (matchingField != null) - { - remappedName = "_"; - remappedName += GetRemappedCursorName(matchingField); - } - else - { - var index = 0; + _ = qualifiedName.Append('>'); + } - if (parentRecordDecl.AnonymousRecords.Count > 1) - { - index = parentRecordDecl.AnonymousRecords.IndexOf(cursor) + 1; - } + void AppendTemplateParameters(TemplateDecl templateDecl, StringBuilder qualifiedName) + { + if (truncateParameters) + { + return; + } - while (parentRecordDecl.IsAnonymousStructOrUnion && (parentRecordDecl.IsUnion == recordType.Decl.IsUnion)) - { - index += 1; + _ = qualifiedName.Append('<'); - if (parentRecordDecl.Parent is RecordDecl parentRecordDeclParent) - { - if (parentRecordDeclParent.AnonymousRecords.Count > 0) - { - index += parentRecordDeclParent.AnonymousRecords.Count - 1; - } - parentRecordDecl = parentRecordDeclParent; - } - } + var templateParameters = templateDecl.TemplateParameters; - if (index != 0) - { - remappedName += index.ToString(); - } - } - } + if (templateParameters.Any()) + { + _ = qualifiedName.Append(templateParameters[0].Name); - remappedName += $"_e__{(recordDecl.IsUnion ? "Union" : "Struct")}"; - } - else if ((canonicalType is EnumType enumType) && remappedName.StartsWith("__AnonymousEnum_")) + for (var i = 1; i < templateParameters.Count; i++) { - remappedName = GetRemappedTypeName(enumType.Decl, context: null, enumType.Decl.IntegerType, out _, skipUsing); + _ = qualifiedName.Append(','); + _ = qualifiedName.Append(' '); + _ = qualifiedName.Append(templateParameters[i].Name); } - else if (cursor is EnumDecl enumDecl) - { - var enumDeclName = GetRemappedCursorName(enumDecl); + } - if (enumDecl.Enumerators.Any((enumConstantDecl) => IsForceDwordOrForceUInt(enumDeclName, enumConstantDecl))) - { - remappedName = "uint"; - } + _ = qualifiedName.Append('>'); + } + } - WithType(enumDecl, ref remappedName, ref nativeTypeName); - } + private static Expr GetExprAsWritten(Expr expr, bool removeParens) + { + do + { + if (expr is ImplicitCastExpr implicitCastExpr) + { + expr = implicitCastExpr.SubExprAsWritten; } - - if (IsNativeTypeNameEquivalent(nativeTypeName, remappedName)) + else if (removeParens && (expr is ParenExpr parenExpr)) { - nativeTypeName = string.Empty; + expr = parenExpr.SubExpr; } - return remappedName; - - bool IsForceDwordOrForceUInt(string enumDeclName, EnumConstantDecl enumConstantDecl) + else { - var enumConstantDeclName = GetRemappedCursorName(enumConstantDecl); - return (enumConstantDeclName == $"{enumDeclName}_FORCE_DWORD") || (enumConstantDeclName == $"{enumDeclName}_FORCE_UINT"); + return expr; } } + while (true); + } - private static string GetSourceRangeContents(CXTranslationUnit translationUnit, CXSourceRange sourceRange) + private uint GetOverloadIndex(CXXMethodDecl cxxMethodDeclToMatch) + { + if (!_overloadIndices.TryGetValue(cxxMethodDeclToMatch, out var index)) { - sourceRange.Start.GetFileLocation(out var startFile, out var startLine, out var startColumn, out var startOffset); - sourceRange.End.GetFileLocation(out var endFile, out var endLine, out var endColumn, out var endOffset); - - if (startFile != endFile) - { - return string.Empty; - } - - var fileContents = translationUnit.GetFileContents(startFile, out var fileSize); - fileContents = fileContents.Slice(unchecked((int)startOffset), unchecked((int)(endOffset - startOffset))); - -#if NETCOREAPP - return Encoding.UTF8.GetString(fileContents); -#else - return Encoding.UTF8.GetString(fileContents.ToArray()); -#endif + index = GetOverloadIndex(cxxMethodDeclToMatch, cxxMethodDeclToMatch.Parent, baseIndex: 0); + _overloadIndices.Add(cxxMethodDeclToMatch, index); } + return index; - private string GetTargetTypeName(Cursor cursor, out string nativeTypeName) + uint GetOverloadIndex(CXXMethodDecl cxxMethodDeclToMatch, CXXRecordDecl cxxRecordDecl, uint baseIndex) { - var targetTypeName = ""; - nativeTypeName = ""; + var index = baseIndex; + + foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) + { + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); + index = GetOverloadIndex(cxxMethodDeclToMatch, baseCxxRecordDecl, index); + } - if (cursor is Decl decl) + foreach (var cxxMethodDecl in cxxRecordDecl.Methods.OrderBy((cxxmd) => cxxmd.VtblIndex)) { - if (decl is EnumConstantDecl enumConstantDecl) + if (IsExcluded(cxxMethodDecl)) { - if (enumConstantDecl.DeclContext is EnumDecl enumDecl) - { - targetTypeName = GetRemappedTypeName(enumDecl, context: null, enumDecl.IntegerType, out nativeTypeName); - } - else - { - targetTypeName = GetRemappedTypeName(enumConstantDecl, context: null, enumConstantDecl.Type, out nativeTypeName); - } + continue; } - else if (decl is TypeDecl previousTypeDecl) + else if (cxxMethodDecl == cxxMethodDeclToMatch) { - targetTypeName = GetRemappedTypeName(previousTypeDecl, context: null, previousTypeDecl.TypeForDecl, out nativeTypeName); + break; } - else if (decl is VarDecl varDecl) + else if (cxxMethodDecl.Name == cxxMethodDeclToMatch.Name) { - if (varDecl is ParmVarDecl parmVarDecl) - { - targetTypeName = GetRemappedTypeName(parmVarDecl, context: null, parmVarDecl.Type, out nativeTypeName); - - if ((parmVarDecl.ParentFunctionOrMethod is FunctionDecl functionDecl) && ((functionDecl is CXXMethodDecl { IsVirtual: true }) || (functionDecl.Body is null)) && (targetTypeName == "bool")) - { - // bool is not blittable, so we shouldn't use it for P/Invoke signatures - targetTypeName = "byte"; - nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? "bool" : nativeTypeName; - } - } - else - { - var type = varDecl.Type; - var cursorName = GetCursorName(varDecl); - - if (cursorName.StartsWith("ClangSharpMacro_")) - { - cursorName = cursorName["ClangSharpMacro_".Length..]; - - if (_config.WithTypes.TryGetValue(cursorName, out targetTypeName)) - { - return targetTypeName; - } - - type = varDecl.Init.Type; - } - - targetTypeName = GetRemappedTypeName(varDecl, context: null, type, out nativeTypeName); - } + index++; } - - } - else if ((cursor is Expr expr) && (expr is not MemberExpr)) - { - targetTypeName = GetRemappedTypeName(expr, context: null, expr.Type, out nativeTypeName); } - return targetTypeName; + return index; } + } - private string GetTypeName(Cursor cursor, Cursor context, Type type, bool ignoreTransparentStructsWhereRequired, out string nativeTypeName) - => GetTypeName(cursor, context, type, type, ignoreTransparentStructsWhereRequired, out nativeTypeName); + private static CXXRecordDecl GetRecordDecl(CXXBaseSpecifier cxxBaseSpecifier) + { + var baseType = cxxBaseSpecifier.Type; - private string GetTypeName(Cursor cursor, Cursor context, Type rootType, Type type, bool ignoreTransparentStructsWhereRequired, out string nativeTypeName) + while (baseType is not RecordType) { - if (!_typeNames.TryGetValue((cursor, context, type), out var result)) + if (baseType is AttributedType attributedType) { - result.typeName = type.AsString.Replace('\\', '/'); - - if (result.typeName.Contains("unnamed struct at")) - { - result.typeName = result.typeName.Replace("unnamed struct at", "anonymous struct at"); - } - - if (result.typeName.Contains("unnamed union at")) - { - result.typeName = result.typeName.Replace("unnamed union at", "anonymous union at"); - } - - result.nativeTypeName = result.typeName; - - if (type is ArrayType arrayType) - { - result.typeName = GetRemappedTypeName(cursor, context, arrayType.ElementType, out _, skipUsing: true, ignoreTransparentStructsWhereRequired); + baseType = attributedType.ModifiedType; + } + else if (baseType is ElaboratedType elaboratedType) + { + baseType = elaboratedType.CanonicalType; + } + else if (baseType is TemplateSpecializationType templateSpecializationType) + { + baseType = templateSpecializationType.CanonicalType; + } + else if (baseType is TypedefType typedefType) + { + baseType = typedefType.Decl.UnderlyingType; + } + else + { + break; + } + } - if (cursor is FunctionDecl or ParmVarDecl) - { - result.typeName += '*'; - } + var baseRecordType = (RecordType)baseType; + return (CXXRecordDecl)baseRecordType.Decl; + } + + private string GetRemappedCursorName(NamedDecl namedDecl) + { + return GetRemappedCursorName(namedDecl, out _, skipUsing: false); + } + + private string GetRemappedCursorName(NamedDecl namedDecl, out string nativeTypeName, bool skipUsing) + { + nativeTypeName = GetCursorName(namedDecl); + + var name = GetCursorQualifiedName(namedDecl); + var remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out var wasRemapped, skipUsing); + + if (wasRemapped) + { + return remappedName; + } + + name = name.Replace("::", "."); + remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out wasRemapped, skipUsing); + + if (wasRemapped) + { + return remappedName; + } + + + name = GetCursorQualifiedName(namedDecl, truncateParameters: true); + remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out wasRemapped, skipUsing); + + if (wasRemapped) + { + return remappedName; + } + + name = name.Replace("::", "."); + remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out wasRemapped, skipUsing); + + if (wasRemapped) + { + return remappedName; + } + + name = nativeTypeName; + remappedName = GetRemappedName(name, namedDecl, tryRemapOperatorName: true, out wasRemapped, skipUsing); + + if (wasRemapped) + { + return remappedName; + } + + if (namedDecl is CXXConstructorDecl cxxConstructorDecl) + { + remappedName = GetRemappedCursorName(cxxConstructorDecl.Parent); + } + else if (namedDecl is FieldDecl fieldDecl) + { + if (name.StartsWith("__AnonymousFieldDecl_")) + { + remappedName = "Anonymous"; + + if (fieldDecl.Parent.AnonymousFields.Count > 1) + { + var index = fieldDecl.Parent.AnonymousFields.IndexOf(fieldDecl) + 1; + remappedName += index.ToString(); } - else if (type is AttributedType attributedType) + } + } + else if ((namedDecl is RecordDecl recordDecl) && name.StartsWith("__AnonymousRecord_")) + { + if (recordDecl.Parent is RecordDecl parentRecordDecl) + { + remappedName = "_Anonymous"; + + var matchingField = parentRecordDecl.Fields.Where((fieldDecl) => fieldDecl.Type.CanonicalType == recordDecl.TypeForDecl.CanonicalType).FirstOrDefault(); + + if (matchingField != null) { - result.typeName = GetTypeName(cursor, context, rootType, attributedType.ModifiedType, ignoreTransparentStructsWhereRequired, out _); + remappedName = "_"; + remappedName += GetRemappedCursorName(matchingField); } - else if (type is BuiltinType) + else if (parentRecordDecl.AnonymousRecords.Count > 1) { - switch (type.Kind) - { - case CXTypeKind.CXType_Void: - { - result.typeName = (cursor is null) ? "Void" : "void"; - break; - } + var index = parentRecordDecl.AnonymousRecords.IndexOf(recordDecl) + 1; + remappedName += index.ToString(); + } - case CXTypeKind.CXType_Bool: - { - result.typeName = (cursor is null) ? "Boolean" : "bool"; - break; - } + remappedName += $"_e__{(recordDecl.IsUnion ? "Union" : "Struct")}"; + } + } - case CXTypeKind.CXType_Char_U: - case CXTypeKind.CXType_UChar: - { - result.typeName = (cursor is null) ? "Byte" : "byte"; - break; - } + return remappedName; + } - case CXTypeKind.CXType_Char16: - case CXTypeKind.CXType_UShort: - { - result.typeName = (cursor is null) ? "UInt16" : "ushort"; - break; - } + private string GetRemappedName(string name, Cursor cursor, bool tryRemapOperatorName, out bool wasRemapped, bool skipUsing = false) + { + return GetRemappedName(name, cursor, tryRemapOperatorName, out wasRemapped, skipUsing, skipUsingIfNotRemapped: skipUsing); + } - case CXTypeKind.CXType_UInt: - { - result.typeName = (cursor is null) ? "UInt32" : "uint"; - break; - } + private string GetRemappedName(string name, Cursor cursor, bool tryRemapOperatorName, out bool wasRemapped, bool skipUsing, bool skipUsingIfNotRemapped) + { + if (_config.RemappedNames.TryGetValue(name, out var remappedName)) + { + wasRemapped = true; + _ = _usedRemappings.Add(name); + return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsing); + } - case CXTypeKind.CXType_ULong: - { - if (_config.GenerateUnixTypes) - { - result.typeName = _config.ExcludeNIntCodegen ? "UIntPtr" : "nuint"; - } - else - { - goto case CXTypeKind.CXType_UInt; - } - break; - } + if (name.StartsWith("const ")) + { + var tmpName = name[6..]; - case CXTypeKind.CXType_ULongLong: - { - result.typeName = (cursor is null) ? "UInt64" : "ulong"; - break; - } + if (_config.RemappedNames.TryGetValue(tmpName, out remappedName)) + { - case CXTypeKind.CXType_Char_S: - case CXTypeKind.CXType_SChar: - { - result.typeName = (cursor is null) ? "SByte" : "sbyte"; - break; - } + wasRemapped = true; + _ = _usedRemappings.Add(tmpName); + return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsing); + } + } - case CXTypeKind.CXType_WChar: - { - if (_config.GenerateUnixTypes) - { - goto case CXTypeKind.CXType_UInt; - } - else - { - goto case CXTypeKind.CXType_UShort; - } - } + remappedName = name; - case CXTypeKind.CXType_Short: - { - result.typeName = (cursor is null) ? "Int16" : "short"; - break; - } + if ((cursor is FunctionDecl functionDecl) && tryRemapOperatorName && TryRemapOperatorName(ref remappedName, functionDecl)) + { + wasRemapped = true; + // We don't track remapped operators in _usedRemappings + return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsing); + } - case CXTypeKind.CXType_Int: - { - result.typeName = (cursor is null) ? "Int32" : "int"; - break; - } + if ((cursor is CXXBaseSpecifier cxxBaseSpecifier) && remappedName.StartsWith("__AnonymousBase_")) + { + remappedName = "Base"; - case CXTypeKind.CXType_Long: - { - if (_config.GenerateUnixTypes) - { - result.typeName = _config.ExcludeNIntCodegen ? "IntPtr" : "nint"; - } - else - { - goto case CXTypeKind.CXType_Int; - } - break; - } + if (_cxxRecordDeclContext.Bases.Count > 1) + { + var index = _cxxRecordDeclContext.Bases.IndexOf(cxxBaseSpecifier) + 1; + remappedName += index.ToString(); + } - case CXTypeKind.CXType_LongLong: - { - result.typeName = (cursor is null) ? "Int64" : "long"; - break; - } + wasRemapped = true; + return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsing); + } - case CXTypeKind.CXType_Float: - { - result.typeName = (cursor is null) ? "Single" : "float"; - break; - } + wasRemapped = false; + return AddUsingDirectiveIfNeeded(_outputBuilder, remappedName, skipUsingIfNotRemapped); - case CXTypeKind.CXType_Double: - { - result.typeName = (cursor is null) ? "Double" : "double"; - break; - } + string AddUsingDirectiveIfNeeded(IOutputBuilder outputBuilder, string remappedName, bool skipUsing) + { + if (!skipUsing) + { + if (s_needsSystemSupportRegex.IsMatch(remappedName)) + { + outputBuilder?.EmitSystemSupport(); + } - case CXTypeKind.CXType_NullPtr: - { - result.typeName = "null"; - break; - } + var namespaceName = GetNamespace(remappedName); + var needsUsing = false; - default: - { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported builtin type: '{type.KindSpelling}'. Falling back '{result.typeName}'.", cursor); - break; - } + if (_currentNamespace is not null) + { + if (!_currentNamespace.StartsWith(namespaceName)) + { + needsUsing = true; + } + else if ((_currentNamespace.Length > namespaceName.Length) && (_currentNamespace[namespaceName.Length] != '.')) + { + needsUsing = true; } } - else if (type is DeducedType deducedType) + + if (needsUsing) { - result.typeName = GetTypeName(cursor, context, rootType, deducedType.CanonicalType, ignoreTransparentStructsWhereRequired, out _); + outputBuilder?.EmitUsingDirective(namespaceName); } - else if (type is DependentNameType dependentNameType) + } + + return remappedName; + } + } + + private string GetRemappedTypeName(Cursor cursor, Cursor context, Type type, out string nativeTypeName, bool skipUsing = false, bool ignoreTransparentStructsWhereRequired = false) + { + var name = GetTypeName(cursor, context, type, ignoreTransparentStructsWhereRequired, out nativeTypeName); + + var nameToCheck = nativeTypeName; + var remappedName = GetRemappedName(nameToCheck, cursor, tryRemapOperatorName: false, out var wasRemapped, skipUsing, skipUsingIfNotRemapped: true); + + if (wasRemapped) + { + return remappedName; + } + + nameToCheck = nameToCheck.Replace("::", "."); + remappedName = GetRemappedName(nameToCheck, cursor, tryRemapOperatorName: false, out wasRemapped, skipUsing, skipUsingIfNotRemapped: true); + + if (wasRemapped) + { + return remappedName; + } + + nameToCheck = name; + remappedName = GetRemappedName(nameToCheck, cursor, tryRemapOperatorName: false, out wasRemapped, skipUsing); + + if (!wasRemapped) + { + var canonicalType = type.CanonicalType; + + if (canonicalType is ConstantArrayType or IncompleteArrayType) + { + var arrayType = (ArrayType)canonicalType; + + if (arrayType.ElementType is RecordType) + { + canonicalType = arrayType.ElementType; + } + } + else if ((canonicalType is IncompleteArrayType incompleteArrayType) && (incompleteArrayType.ElementType is RecordType)) + { + canonicalType = incompleteArrayType.ElementType; + } + + if ((canonicalType is RecordType recordType) && remappedName.StartsWith("__AnonymousRecord_")) + { + var recordDecl = recordType.Decl; + remappedName = "_Anonymous"; + + if (recordDecl.Parent is RecordDecl parentRecordDecl) { - if (dependentNameType.IsSugared) + var matchingField = parentRecordDecl.Fields.Where((fieldDecl) => fieldDecl.Type.CanonicalType == recordType).FirstOrDefault(); + + if (matchingField != null) { - result.typeName = GetTypeName(cursor, context, rootType, dependentNameType.Desugar, ignoreTransparentStructsWhereRequired, out _); + remappedName = "_"; + remappedName += GetRemappedCursorName(matchingField); } else { - // The default name should be correct + var index = 0; + + if (parentRecordDecl.AnonymousRecords.Count > 1) + { + index = parentRecordDecl.AnonymousRecords.IndexOf(cursor) + 1; + } + + while (parentRecordDecl.IsAnonymousStructOrUnion && (parentRecordDecl.IsUnion == recordType.Decl.IsUnion)) + { + index += 1; + + if (parentRecordDecl.Parent is RecordDecl parentRecordDeclParent) + { + if (parentRecordDeclParent.AnonymousRecords.Count > 0) + { + index += parentRecordDeclParent.AnonymousRecords.Count - 1; + } + parentRecordDecl = parentRecordDeclParent; + } + } + + if (index != 0) + { + remappedName += index.ToString(); + } } } - else if (type is ElaboratedType elaboratedType) - { - result.typeName = GetTypeName(cursor, context, rootType, elaboratedType.NamedType, ignoreTransparentStructsWhereRequired, out _); - } - else if (type is FunctionType functionType) + + remappedName += $"_e__{(recordDecl.IsUnion ? "Union" : "Struct")}"; + } + else if ((canonicalType is EnumType enumType) && remappedName.StartsWith("__AnonymousEnum_")) + { + remappedName = GetRemappedTypeName(enumType.Decl, context: null, enumType.Decl.IntegerType, out _, skipUsing); + } + else if (cursor is EnumDecl enumDecl) + { + var enumDeclName = GetRemappedCursorName(enumDecl); + + if (enumDecl.Enumerators.Any((enumConstantDecl) => IsForceDwordOrForceUInt(enumDeclName, enumConstantDecl))) { - result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, functionType, ignoreTransparentStructsWhereRequired, out _); + remappedName = "uint"; } - else if (type is InjectedClassNameType injectedClassNameType) + + WithType(enumDecl, ref remappedName, ref nativeTypeName); + } + } + + if (IsNativeTypeNameEquivalent(nativeTypeName, remappedName)) + { + nativeTypeName = string.Empty; + } + return remappedName; + + bool IsForceDwordOrForceUInt(string enumDeclName, EnumConstantDecl enumConstantDecl) + { + var enumConstantDeclName = GetRemappedCursorName(enumConstantDecl); + return (enumConstantDeclName == $"{enumDeclName}_FORCE_DWORD") || (enumConstantDeclName == $"{enumDeclName}_FORCE_UINT"); + } + } + + private static string GetSourceRangeContents(CXTranslationUnit translationUnit, CXSourceRange sourceRange) + { + sourceRange.Start.GetFileLocation(out var startFile, out var startLine, out var startColumn, out var startOffset); + sourceRange.End.GetFileLocation(out var endFile, out var endLine, out var endColumn, out var endOffset); + + if (startFile != endFile) + { + return string.Empty; + } + + var fileContents = translationUnit.GetFileContents(startFile, out var fileSize); + fileContents = fileContents.Slice(unchecked((int)startOffset), unchecked((int)(endOffset - startOffset))); + +#if NETCOREAPP + return Encoding.UTF8.GetString(fileContents); +#else + return Encoding.UTF8.GetString(fileContents.ToArray()); +#endif + } + + private string GetTargetTypeName(Cursor cursor, out string nativeTypeName) + { + var targetTypeName = ""; + nativeTypeName = ""; + + if (cursor is Decl decl) + { + if (decl is EnumConstantDecl enumConstantDecl) + { + if (enumConstantDecl.DeclContext is EnumDecl enumDecl) { - result.typeName = GetTypeName(cursor, context, rootType, injectedClassNameType.InjectedTST, ignoreTransparentStructsWhereRequired, out _); + targetTypeName = GetRemappedTypeName(enumDecl, context: null, enumDecl.IntegerType, out nativeTypeName); } - else if (type is PackExpansionType packExpansionType) + else { - result.typeName = GetTypeName(cursor, context, rootType, packExpansionType.Pattern, ignoreTransparentStructsWhereRequired, out _); + targetTypeName = GetRemappedTypeName(enumConstantDecl, context: null, enumConstantDecl.Type, out nativeTypeName); } - else if (type is PointerType pointerType) + } + else if (decl is TypeDecl previousTypeDecl) + { + targetTypeName = GetRemappedTypeName(previousTypeDecl, context: null, previousTypeDecl.TypeForDecl, out nativeTypeName); + } + else if (decl is VarDecl varDecl) + { + if (varDecl is ParmVarDecl parmVarDecl) { - result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, pointerType.PointeeType, ignoreTransparentStructsWhereRequired, out _); + targetTypeName = GetRemappedTypeName(parmVarDecl, context: null, parmVarDecl.Type, out nativeTypeName); + + if ((parmVarDecl.ParentFunctionOrMethod is FunctionDecl functionDecl) && ((functionDecl is CXXMethodDecl { IsVirtual: true }) || (functionDecl.Body is null)) && (targetTypeName == "bool")) + { + // bool is not blittable, so we shouldn't use it for P/Invoke signatures + targetTypeName = "byte"; + nativeTypeName = string.IsNullOrWhiteSpace(nativeTypeName) ? "bool" : nativeTypeName; + } } - else if (type is ReferenceType referenceType) + else { - result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, referenceType.PointeeType, ignoreTransparentStructsWhereRequired, out _); + var type = varDecl.Type; + var cursorName = GetCursorName(varDecl); + + if (cursorName.StartsWith("ClangSharpMacro_")) + { + cursorName = cursorName["ClangSharpMacro_".Length..]; + + if (_config.WithTypes.TryGetValue(cursorName, out targetTypeName)) + { + return targetTypeName; + } + + type = varDecl.Init.Type; + } + + targetTypeName = GetRemappedTypeName(varDecl, context: null, type, out nativeTypeName); } - else if (type is SubstTemplateTypeParmType substTemplateTypeParmType) + } + + } + else if ((cursor is Expr expr) && (expr is not MemberExpr)) + { + targetTypeName = GetRemappedTypeName(expr, context: null, expr.Type, out nativeTypeName); + } + + return targetTypeName; + } + + private string GetTypeName(Cursor cursor, Cursor context, Type type, bool ignoreTransparentStructsWhereRequired, out string nativeTypeName) + => GetTypeName(cursor, context, type, type, ignoreTransparentStructsWhereRequired, out nativeTypeName); + + private string GetTypeName(Cursor cursor, Cursor context, Type rootType, Type type, bool ignoreTransparentStructsWhereRequired, out string nativeTypeName) + { + if (!_typeNames.TryGetValue((cursor, context, type), out var result)) + { + result.typeName = type.AsString.Replace('\\', '/'); + + if (result.typeName.Contains("unnamed struct at")) + { + result.typeName = result.typeName.Replace("unnamed struct at", "anonymous struct at"); + } + + if (result.typeName.Contains("unnamed union at")) + { + result.typeName = result.typeName.Replace("unnamed union at", "anonymous union at"); + } + + result.nativeTypeName = result.typeName; + + if (type is ArrayType arrayType) + { + result.typeName = GetRemappedTypeName(cursor, context, arrayType.ElementType, out _, skipUsing: true, ignoreTransparentStructsWhereRequired); + + if (cursor is FunctionDecl or ParmVarDecl) { - result.typeName = GetTypeName(cursor, context, rootType, substTemplateTypeParmType.ReplacementType, ignoreTransparentStructsWhereRequired, out _); + result.typeName += '*'; } - else if (type is TagType tagType) + } + else if (type is AttributedType attributedType) + { + result.typeName = GetTypeName(cursor, context, rootType, attributedType.ModifiedType, ignoreTransparentStructsWhereRequired, out _); + } + else if (type is BuiltinType) + { + switch (type.Kind) { - if (tagType.Decl.Handle.IsAnonymous) + case CXTypeKind.CXType_Void: { - result.typeName = GetAnonymousName(tagType.Decl, tagType.KindSpelling); + result.typeName = (cursor is null) ? "Void" : "void"; + break; } - else if (tagType.Handle.IsConstQualified) + + case CXTypeKind.CXType_Bool: { - result.typeName = GetTypeName(cursor, context, rootType, tagType.Decl.TypeForDecl, ignoreTransparentStructsWhereRequired, out _); + result.typeName = (cursor is null) ? "Boolean" : "bool"; + break; } - else - { - // The default name should be correct for C++, but C may have a prefix we need to strip - if (result.typeName.StartsWith("enum ")) - { - result.typeName = result.typeName[5..]; - } - else if (result.typeName.StartsWith("struct ")) - { - result.typeName = result.typeName[7..]; - } + case CXTypeKind.CXType_Char_U: + case CXTypeKind.CXType_UChar: + { + result.typeName = (cursor is null) ? "Byte" : "byte"; + break; } - if (result.typeName.Contains("::")) + case CXTypeKind.CXType_Char16: + case CXTypeKind.CXType_UShort: { - result.typeName = result.typeName.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries).Last(); - result.typeName = GetRemappedName(result.typeName, cursor, tryRemapOperatorName: false, out _, skipUsing: true); + result.typeName = (cursor is null) ? "UInt16" : "ushort"; + break; } - } - else if (type is TemplateSpecializationType templateSpecializationType) - { - var nameBuilder = new StringBuilder(); - - var templateTypeDecl = templateSpecializationType.CanonicalType is RecordType recordType - ? recordType.Decl - : (NamedDecl)templateSpecializationType.TemplateName.AsTemplateDecl; - var templateTypeDeclName = GetRemappedCursorName(templateTypeDecl, out _, skipUsing: true); - var isStdAtomic = false; - - if (templateTypeDeclName == "atomic") + case CXTypeKind.CXType_UInt: { - isStdAtomic = (templateTypeDecl.Parent is NamespaceDecl namespaceDecl) && namespaceDecl.IsStdNamespace; + result.typeName = (cursor is null) ? "UInt32" : "uint"; + break; } - if (!isStdAtomic) + case CXTypeKind.CXType_ULong: { - _ = nameBuilder.Append(templateTypeDeclName); - _ = nameBuilder.Append('<'); + if (_config.GenerateUnixTypes) + { + result.typeName = _config.ExcludeNIntCodegen ? "UIntPtr" : "nuint"; + } + else + { + goto case CXTypeKind.CXType_UInt; + } + break; } - else + + case CXTypeKind.CXType_ULongLong: { - _ = nameBuilder.Append("volatile "); + result.typeName = (cursor is null) ? "UInt64" : "ulong"; + break; } - var shouldWritePrecedingComma = false; + case CXTypeKind.CXType_Char_S: + case CXTypeKind.CXType_SChar: + { + result.typeName = (cursor is null) ? "SByte" : "sbyte"; + break; + } - foreach (var arg in templateSpecializationType.Args) + case CXTypeKind.CXType_WChar: { - if (shouldWritePrecedingComma) + if (_config.GenerateUnixTypes) { - _ = nameBuilder.Append(','); - _ = nameBuilder.Append(' '); + goto case CXTypeKind.CXType_UInt; } - - var typeName = ""; - - switch (arg.Kind) + else { - case CXTemplateArgumentKind.CXTemplateArgumentKind_Type: - { - typeName = GetRemappedTypeName(cursor, context: null, arg.AsType, out var nativeAsTypeName, skipUsing: true); - break; - } - - case CXTemplateArgumentKind.CXTemplateArgumentKind_Expression: - { - var oldOutputBuilder = _outputBuilder; - _outputBuilder = new CSharpOutputBuilder("ClangSharp_TemplateSpecializationType_AsExpr", _config); - - Visit(arg.AsExpr); - typeName = _outputBuilder.ToString(); + goto case CXTypeKind.CXType_UShort; + } + } - _outputBuilder = oldOutputBuilder; - break; - } + case CXTypeKind.CXType_Short: + { + result.typeName = (cursor is null) ? "Int16" : "short"; + break; + } - default: - { - typeName = result.typeName; - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported template argument kind: '{arg.Kind}'. Falling back '{result.typeName}'.", cursor); - break; - } - } + case CXTypeKind.CXType_Int: + { + result.typeName = (cursor is null) ? "Int32" : "int"; + break; + } - if (typeName == "bool") + case CXTypeKind.CXType_Long: + { + if (_config.GenerateUnixTypes) { - // bool is not blittable, so we shouldn't use it for P/Invoke signatures - typeName = "byte"; + result.typeName = _config.ExcludeNIntCodegen ? "IntPtr" : "nint"; } - - if (typeName.EndsWith("*") || typeName.Contains("delegate*")) + else { - // Pointers are not yet supported as generic arguments; remap to IntPtr - typeName = "IntPtr"; - _outputBuilder.EmitSystemSupport(); + goto case CXTypeKind.CXType_Int; } + break; + } - _ = nameBuilder.Append(typeName); + case CXTypeKind.CXType_LongLong: + { + result.typeName = (cursor is null) ? "Int64" : "long"; + break; + } - shouldWritePrecedingComma = true; + case CXTypeKind.CXType_Float: + { + result.typeName = (cursor is null) ? "Single" : "float"; + break; } - if (!isStdAtomic) + case CXTypeKind.CXType_Double: { - _ = nameBuilder.Append('>'); + result.typeName = (cursor is null) ? "Double" : "double"; + break; } - result.typeName = nameBuilder.ToString(); - } - else if (type is TemplateTypeParmType templateTypeParmType) - { - if (templateTypeParmType.IsSugared) + case CXTypeKind.CXType_NullPtr: { - result.typeName = GetTypeName(cursor, context, rootType, templateTypeParmType.Desugar, ignoreTransparentStructsWhereRequired, out _); + result.typeName = "null"; + break; } - else + + default: { - // The default name should be correct + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported builtin type: '{type.KindSpelling}'. Falling back '{result.typeName}'.", cursor); + break; } } - else if (type is TypedefType typedefType) - { - // We check remapped names here so that types that have variable sizes - // can be treated correctly. Otherwise, they will resolve to a particular - // platform size, based on whatever parameters were passed into clang. - - var remappedName = GetRemappedName(result.typeName, cursor, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true); - result.typeName = wasRemapped ? remappedName : GetTypeName(cursor, context, rootType, typedefType.Decl.UnderlyingType, ignoreTransparentStructsWhereRequired, out _); - } - else if (type is UsingType usingType) + } + else if (type is DeducedType deducedType) + { + result.typeName = GetTypeName(cursor, context, rootType, deducedType.CanonicalType, ignoreTransparentStructsWhereRequired, out _); + } + else if (type is DependentNameType dependentNameType) + { + if (dependentNameType.IsSugared) { - result.typeName = GetTypeName(cursor, context, rootType, usingType.Desugar, ignoreTransparentStructsWhereRequired, out _); + result.typeName = GetTypeName(cursor, context, rootType, dependentNameType.Desugar, ignoreTransparentStructsWhereRequired, out _); } else { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported type: '{type.TypeClass}'. Falling back '{result.typeName}'.", cursor); - } - - Debug.Assert(!string.IsNullOrWhiteSpace(result.typeName)); - Debug.Assert(!string.IsNullOrWhiteSpace(result.nativeTypeName)); - - if (IsNativeTypeNameEquivalent(result.nativeTypeName, result.typeName)) - { - result.nativeTypeName = string.Empty; + // The default name should be correct } - - _typeNames[(cursor, context, type)] = result; } - - nativeTypeName = result.nativeTypeName; - return result.typeName; - } - - private string GetTypeNameForPointeeType(Cursor cursor, Cursor context, Type rootType, Type pointeeType, bool ignoreTransparentStructsWhereRequired, out string nativePointeeTypeName) - { - var name = pointeeType.AsString; - nativePointeeTypeName = name; - - if (pointeeType is AttributedType attributedType) + else if (type is ElaboratedType elaboratedType) + { + result.typeName = GetTypeName(cursor, context, rootType, elaboratedType.NamedType, ignoreTransparentStructsWhereRequired, out _); + } + else if (type is FunctionType functionType) + { + result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, functionType, ignoreTransparentStructsWhereRequired, out _); + } + else if (type is InjectedClassNameType injectedClassNameType) + { + result.typeName = GetTypeName(cursor, context, rootType, injectedClassNameType.InjectedTST, ignoreTransparentStructsWhereRequired, out _); + } + else if (type is PackExpansionType packExpansionType) + { + result.typeName = GetTypeName(cursor, context, rootType, packExpansionType.Pattern, ignoreTransparentStructsWhereRequired, out _); + } + else if (type is PointerType pointerType) + { + result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, pointerType.PointeeType, ignoreTransparentStructsWhereRequired, out _); + } + else if (type is ReferenceType referenceType) { - name = GetTypeNameForPointeeType(cursor, context, rootType, attributedType.ModifiedType, ignoreTransparentStructsWhereRequired, out var nativeModifiedTypeName); + result.typeName = GetTypeNameForPointeeType(cursor, context, rootType, referenceType.PointeeType, ignoreTransparentStructsWhereRequired, out _); } - else if (pointeeType is ElaboratedType elaboratedType) + else if (type is SubstTemplateTypeParmType substTemplateTypeParmType) { - name = GetTypeNameForPointeeType(cursor, context, rootType, elaboratedType.NamedType, ignoreTransparentStructsWhereRequired, out var nativeNamedTypeName); + result.typeName = GetTypeName(cursor, context, rootType, substTemplateTypeParmType.ReplacementType, ignoreTransparentStructsWhereRequired, out _); } - else if (pointeeType is FunctionType functionType) + else if (type is TagType tagType) { - if (!_config.ExcludeFnptrCodegen && (functionType is FunctionProtoType functionProtoType)) + if (tagType.Decl.Handle.IsAnonymous) { - _config.ExcludeFnptrCodegen = true; - var callConv = GetCallingConvention(cursor, context, rootType); - _config.ExcludeFnptrCodegen = false; - - var needsReturnFixup = false; - var returnTypeName = GetRemappedTypeName(cursor, context: null, functionType.ReturnType, out _, skipUsing: true); + result.typeName = GetAnonymousName(tagType.Decl, tagType.KindSpelling); + } + else if (tagType.Handle.IsConstQualified) + { + result.typeName = GetTypeName(cursor, context, rootType, tagType.Decl.TypeForDecl, ignoreTransparentStructsWhereRequired, out _); + } + else + { + // The default name should be correct for C++, but C may have a prefix we need to strip - if (returnTypeName == "bool") + if (result.typeName.StartsWith("enum ")) { - // bool is not blittable, so we shouldn't use it for P/Invoke signatures - returnTypeName = "byte"; + result.typeName = result.typeName[5..]; } + else if (result.typeName.StartsWith("struct ")) + { + result.typeName = result.typeName[7..]; + } + } - var nameBuilder = new StringBuilder(); - _ = nameBuilder.Append("delegate"); - _ = nameBuilder.Append('*'); - - var isMacroDefinitionRecord = (cursor is VarDecl varDecl) && GetCursorName(varDecl).StartsWith("ClangSharpMacro_"); + if (result.typeName.Contains("::")) + { + result.typeName = result.typeName.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries).Last(); + result.typeName = GetRemappedName(result.typeName, cursor, tryRemapOperatorName: false, out _, skipUsing: true); + } + } + else if (type is TemplateSpecializationType templateSpecializationType) + { + var nameBuilder = new StringBuilder(); - if (!isMacroDefinitionRecord) - { - _ = nameBuilder.Append(" unmanaged"); - var hasSuppressGCTransition = HasSuppressGCTransition(cursor); + var templateTypeDecl = templateSpecializationType.CanonicalType is RecordType recordType + ? recordType.Decl + : (NamedDecl)templateSpecializationType.TemplateName.AsTemplateDecl; - if (callConv != CallingConvention.Winapi) - { - _ = nameBuilder.Append('['); - _ = nameBuilder.Append(callConv.AsString(true)); + var templateTypeDeclName = GetRemappedCursorName(templateTypeDecl, out _, skipUsing: true); + var isStdAtomic = false; - if (hasSuppressGCTransition) - { - _ = nameBuilder.Append(", SuppressGCTransition"); - } - _ = nameBuilder.Append(']'); - } - else if (hasSuppressGCTransition) - { - _ = nameBuilder.Append("[SuppressGCTransition]"); - } - } + if (templateTypeDeclName == "atomic") + { + isStdAtomic = (templateTypeDecl.Parent is NamespaceDecl namespaceDecl) && namespaceDecl.IsStdNamespace; + } + if (!isStdAtomic) + { + _ = nameBuilder.Append(templateTypeDeclName); _ = nameBuilder.Append('<'); + } + else + { + _ = nameBuilder.Append("volatile "); + } - if ((cursor is CXXMethodDecl cxxMethodDecl) && (context is CXXRecordDecl cxxRecordDecl)) - { - var cxxRecordDeclName = GetRemappedCursorName(cxxRecordDecl); - needsReturnFixup = cxxMethodDecl.IsVirtual && NeedsReturnFixup(cxxMethodDecl); + var shouldWritePrecedingComma = false; - _ = nameBuilder.Append(EscapeName(cxxRecordDeclName)); - _ = nameBuilder.Append('*'); + foreach (var arg in templateSpecializationType.Args) + { + if (shouldWritePrecedingComma) + { _ = nameBuilder.Append(','); _ = nameBuilder.Append(' '); - - if (needsReturnFixup) - { - _ = nameBuilder.Append(returnTypeName); - _ = nameBuilder.Append('*'); - _ = nameBuilder.Append(','); - _ = nameBuilder.Append(' '); - } } - IEnumerable paramTypes = functionProtoType.ParamTypes; + var typeName = ""; - if (isMacroDefinitionRecord) + switch (arg.Kind) { - varDecl = (VarDecl)cursor; - - if (IsStmtAsWritten(varDecl.Init, out DeclRefExpr declRefExpr, removeParens: true) && (declRefExpr.Decl is FunctionDecl functionDecl)) + case CXTemplateArgumentKind.CXTemplateArgumentKind_Type: { - cursor = functionDecl; - paramTypes = functionDecl.Parameters.Select((param) => param.Type); - returnTypeName = GetRemappedTypeName(cursor, context: null, functionDecl.ReturnType, out _, skipUsing: true); + typeName = GetRemappedTypeName(cursor, context: null, arg.AsType, out var nativeAsTypeName, skipUsing: true); + break; } - } - - foreach (var paramType in paramTypes) - { - var typeName = GetRemappedTypeName(cursor, context: null, paramType, out _, skipUsing: true); - if (typeName == "bool") + case CXTemplateArgumentKind.CXTemplateArgumentKind_Expression: { - // bool is not blittable, so we shouldn't use it for P/Invoke signatures - typeName = "byte"; + var oldOutputBuilder = _outputBuilder; + _outputBuilder = new CSharpOutputBuilder("ClangSharp_TemplateSpecializationType_AsExpr", _config); + + Visit(arg.AsExpr); + typeName = _outputBuilder.ToString(); + + _outputBuilder = oldOutputBuilder; + break; } - _ = nameBuilder.Append(typeName); - _ = nameBuilder.Append(','); - _ = nameBuilder.Append(' '); + default: + { + typeName = result.typeName; + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported template argument kind: '{arg.Kind}'. Falling back '{result.typeName}'.", cursor); + break; + } } - if (!needsReturnFixup && ignoreTransparentStructsWhereRequired && _config.WithTransparentStructs.TryGetValue(returnTypeName, out var transparentStruct)) + if (typeName == "bool") { - _ = nameBuilder.Append(transparentStruct.Name); + // bool is not blittable, so we shouldn't use it for P/Invoke signatures + typeName = "byte"; } - else - { - _ = nameBuilder.Append(returnTypeName); - if (needsReturnFixup) - { - _ = nameBuilder.Append('*'); - } + if (typeName.EndsWith("*") || typeName.Contains("delegate*")) + { + // Pointers are not yet supported as generic arguments; remap to IntPtr + typeName = "IntPtr"; + _outputBuilder.EmitSystemSupport(); } + _ = nameBuilder.Append(typeName); + + shouldWritePrecedingComma = true; + } + + if (!isStdAtomic) + { _ = nameBuilder.Append('>'); - name = nameBuilder.ToString(); + } + + result.typeName = nameBuilder.ToString(); + } + else if (type is TemplateTypeParmType templateTypeParmType) + { + if (templateTypeParmType.IsSugared) + { + result.typeName = GetTypeName(cursor, context, rootType, templateTypeParmType.Desugar, ignoreTransparentStructsWhereRequired, out _); } else { - name = "IntPtr"; + // The default name should be correct } } - else if (pointeeType is TypedefType typedefType) + else if (type is TypedefType typedefType) { // We check remapped names here so that types that have variable sizes // can be treated correctly. Otherwise, they will resolve to a particular // platform size, based on whatever parameters were passed into clang. - var remappedName = GetRemappedName(name, cursor, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true); - - if (wasRemapped) - { - name = remappedName; - name += '*'; - } - else - { - name = GetTypeNameForPointeeType(cursor, context, rootType, typedefType.Decl.UnderlyingType, ignoreTransparentStructsWhereRequired, out var nativeUnderlyingTypeName); - } + var remappedName = GetRemappedName(result.typeName, cursor, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true); + result.typeName = wasRemapped ? remappedName : GetTypeName(cursor, context, rootType, typedefType.Decl.UnderlyingType, ignoreTransparentStructsWhereRequired, out _); + } + else if (type is UsingType usingType) + { + result.typeName = GetTypeName(cursor, context, rootType, usingType.Desugar, ignoreTransparentStructsWhereRequired, out _); } else { - // Otherwise fields that point at anonymous structs get the wrong name - name = GetRemappedTypeName(cursor, context, pointeeType, out nativePointeeTypeName, skipUsing: true); - name += '*'; + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported type: '{type.TypeClass}'. Falling back '{result.typeName}'.", cursor); } - return name; + Debug.Assert(!string.IsNullOrWhiteSpace(result.typeName)); + Debug.Assert(!string.IsNullOrWhiteSpace(result.nativeTypeName)); + + if (IsNativeTypeNameEquivalent(result.nativeTypeName, result.typeName)) + { + result.nativeTypeName = string.Empty; + } + + _typeNames[(cursor, context, type)] = result; } - private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref long alignment64, out long size32, out long size64) + nativeTypeName = result.nativeTypeName; + return result.typeName; + } + + private string GetTypeNameForPointeeType(Cursor cursor, Cursor context, Type rootType, Type pointeeType, bool ignoreTransparentStructsWhereRequired, out string nativePointeeTypeName) + { + var name = pointeeType.AsString; + nativePointeeTypeName = name; + + if (pointeeType is AttributedType attributedType) { - var has8BytePrimitiveField = false; - GetTypeSize(cursor, type, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + name = GetTypeNameForPointeeType(cursor, context, rootType, attributedType.ModifiedType, ignoreTransparentStructsWhereRequired, out var nativeModifiedTypeName); } - - private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref long alignment64, ref bool has8BytePrimitiveField, out long size32, out long size64) + else if (pointeeType is ElaboratedType elaboratedType) { - size32 = 0; - size64 = 0; - - if (type is ArrayType arrayType) + name = GetTypeNameForPointeeType(cursor, context, rootType, elaboratedType.NamedType, ignoreTransparentStructsWhereRequired, out var nativeNamedTypeName); + } + else if (pointeeType is FunctionType functionType) + { + if (!_config.ExcludeFnptrCodegen && (functionType is FunctionProtoType functionProtoType)) { - if (type is ConstantArrayType or IncompleteArrayType) + _config.ExcludeFnptrCodegen = true; + var callConv = GetCallingConvention(cursor, context, rootType); + _config.ExcludeFnptrCodegen = false; + + var needsReturnFixup = false; + var returnTypeName = GetRemappedTypeName(cursor, context: null, functionType.ReturnType, out _, skipUsing: true); + + if (returnTypeName == "bool") { - var count = Math.Max((arrayType as ConstantArrayType)?.Size ?? 0, 1); - GetTypeSize(cursor, arrayType.ElementType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out var elementSize32, out var elementSize64); + // bool is not blittable, so we shouldn't use it for P/Invoke signatures + returnTypeName = "byte"; + } - size32 = elementSize32 * Math.Max(count, 1); - size64 = elementSize64 * Math.Max(count, 1); + var nameBuilder = new StringBuilder(); + _ = nameBuilder.Append("delegate"); + _ = nameBuilder.Append('*'); - if (alignment32 == -1) + var isMacroDefinitionRecord = (cursor is VarDecl varDecl) && GetCursorName(varDecl).StartsWith("ClangSharpMacro_"); + + if (!isMacroDefinitionRecord) + { + _ = nameBuilder.Append(" unmanaged"); + var hasSuppressGCTransition = HasSuppressGCTransition(cursor); + + if (callConv != CallingConvention.Winapi) { - alignment32 = elementSize32; - } + _ = nameBuilder.Append('['); + _ = nameBuilder.Append(callConv.AsString(true)); - if (alignment64 == -1) + if (hasSuppressGCTransition) + { + _ = nameBuilder.Append(", SuppressGCTransition"); + } + _ = nameBuilder.Append(']'); + } + else if (hasSuppressGCTransition) { - alignment64 = elementSize64; + _ = nameBuilder.Append("[SuppressGCTransition]"); } } - else + + _ = nameBuilder.Append('<'); + + if ((cursor is CXXMethodDecl cxxMethodDecl) && (context is CXXRecordDecl cxxRecordDecl)) { - size32 = 4; - size64 = 8; + var cxxRecordDeclName = GetRemappedCursorName(cxxRecordDecl); + needsReturnFixup = cxxMethodDecl.IsVirtual && NeedsReturnFixup(cxxMethodDecl); - if (alignment32 == -1) - { - alignment32 = 4; - } + _ = nameBuilder.Append(EscapeName(cxxRecordDeclName)); + _ = nameBuilder.Append('*'); + _ = nameBuilder.Append(','); + _ = nameBuilder.Append(' '); - if (alignment64 == -1) + if (needsReturnFixup) { - alignment64 = 8; + _ = nameBuilder.Append(returnTypeName); + _ = nameBuilder.Append('*'); + _ = nameBuilder.Append(','); + _ = nameBuilder.Append(' '); } } - } - else if (type is AttributedType attributedType) - { - GetTypeSize(cursor, attributedType.ModifiedType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); - } - else if (type is BuiltinType) - { - switch (type.Kind) + + IEnumerable paramTypes = functionProtoType.ParamTypes; + + if (isMacroDefinitionRecord) { - case CXTypeKind.CXType_Bool: - case CXTypeKind.CXType_Char_U: - case CXTypeKind.CXType_UChar: - case CXTypeKind.CXType_Char_S: - case CXTypeKind.CXType_SChar: + varDecl = (VarDecl)cursor; + + if (IsStmtAsWritten(varDecl.Init, out DeclRefExpr declRefExpr, removeParens: true) && (declRefExpr.Decl is FunctionDecl functionDecl)) { - size32 = 1; - size64 = 1; - break; + cursor = functionDecl; + paramTypes = functionDecl.Parameters.Select((param) => param.Type); + returnTypeName = GetRemappedTypeName(cursor, context: null, functionDecl.ReturnType, out _, skipUsing: true); } + } - case CXTypeKind.CXType_UShort: - case CXTypeKind.CXType_Short: + foreach (var paramType in paramTypes) + { + var typeName = GetRemappedTypeName(cursor, context: null, paramType, out _, skipUsing: true); + + if (typeName == "bool") { - size32 = 2; - size64 = 2; - break; + // bool is not blittable, so we shouldn't use it for P/Invoke signatures + typeName = "byte"; } - case CXTypeKind.CXType_UInt: - case CXTypeKind.CXType_Int: - case CXTypeKind.CXType_Float: + _ = nameBuilder.Append(typeName); + _ = nameBuilder.Append(','); + _ = nameBuilder.Append(' '); + } + + if (!needsReturnFixup && ignoreTransparentStructsWhereRequired && _config.WithTransparentStructs.TryGetValue(returnTypeName, out var transparentStruct)) + { + _ = nameBuilder.Append(transparentStruct.Name); + } + else + { + _ = nameBuilder.Append(returnTypeName); + + if (needsReturnFixup) { - size32 = 4; - size64 = 4; - break; + _ = nameBuilder.Append('*'); } + } - case CXTypeKind.CXType_ULong: - case CXTypeKind.CXType_Long: - { - if (_config.GenerateUnixTypes) - { - size32 = 4; - size64 = 8; + _ = nameBuilder.Append('>'); + name = nameBuilder.ToString(); + } + else + { + name = "IntPtr"; + } + } + else if (pointeeType is TypedefType typedefType) + { + // We check remapped names here so that types that have variable sizes + // can be treated correctly. Otherwise, they will resolve to a particular + // platform size, based on whatever parameters were passed into clang. - if (alignment32 == -1) - { - alignment32 = 4; - } + var remappedName = GetRemappedName(name, cursor, tryRemapOperatorName: false, out var wasRemapped, skipUsing: true); - if (alignment64 == -1) - { - alignment64 = 8; - } - } - else - { - goto case CXTypeKind.CXType_UInt; - } - break; - } + if (wasRemapped) + { + name = remappedName; + name += '*'; + } + else + { + name = GetTypeNameForPointeeType(cursor, context, rootType, typedefType.Decl.UnderlyingType, ignoreTransparentStructsWhereRequired, out var nativeUnderlyingTypeName); + } + } + else + { + // Otherwise fields that point at anonymous structs get the wrong name + name = GetRemappedTypeName(cursor, context, pointeeType, out nativePointeeTypeName, skipUsing: true); + name += '*'; + } - case CXTypeKind.CXType_ULongLong: - case CXTypeKind.CXType_LongLong: - case CXTypeKind.CXType_Double: - { - size32 = 8; - size64 = 8; + return name; + } - if (alignment32 == -1) - { - alignment32 = 8; - } + private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref long alignment64, out long size32, out long size64) + { + var has8BytePrimitiveField = false; + GetTypeSize(cursor, type, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + } - if (alignment64 == -1) - { - alignment64 = 8; - } + private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref long alignment64, ref bool has8BytePrimitiveField, out long size32, out long size64) + { + size32 = 0; + size64 = 0; - has8BytePrimitiveField = true; - break; - } + if (type is ArrayType arrayType) + { + if (type is ConstantArrayType or IncompleteArrayType) + { + var count = Math.Max((arrayType as ConstantArrayType)?.Size ?? 0, 1); + GetTypeSize(cursor, arrayType.ElementType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out var elementSize32, out var elementSize64); - case CXTypeKind.CXType_WChar: - { - if (_config.GenerateUnixTypes) - { - goto case CXTypeKind.CXType_Int; - } - else - { - goto case CXTypeKind.CXType_UShort; - } - } + size32 = elementSize32 * Math.Max(count, 1); + size64 = elementSize64 * Math.Max(count, 1); + + if (alignment32 == -1) + { + alignment32 = elementSize32; + } - default: - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported builtin type: '{type.KindSpelling}.", cursor); - break; - } + if (alignment64 == -1) + { + alignment64 = elementSize64; } } - else if (type is ElaboratedType elaboratedType) - { - GetTypeSize(cursor, elaboratedType.NamedType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); - } - else if (type is EnumType enumType) - { - GetTypeSize(cursor, enumType.Decl.IntegerType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); - } - else if (type is FunctionType or PointerType or ReferenceType) + else { size32 = 4; size64 = 8; @@ -3511,174 +3386,203 @@ private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref lon alignment64 = 8; } } - else if (type is InjectedClassNameType) - { - Debug.Assert(size32 == 0); - Debug.Assert(size64 == 0); - } - else if (type is RecordType recordType) + } + else if (type is AttributedType attributedType) + { + GetTypeSize(cursor, attributedType.ModifiedType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + } + else if (type is BuiltinType) + { + switch (type.Kind) { - var recordTypeAlignOf = Math.Min(recordType.Handle.AlignOf, 8); - - if (alignment32 == -1) + case CXTypeKind.CXType_Bool: + case CXTypeKind.CXType_Char_U: + case CXTypeKind.CXType_UChar: + case CXTypeKind.CXType_Char_S: + case CXTypeKind.CXType_SChar: { - alignment32 = recordTypeAlignOf; + size32 = 1; + size64 = 1; + break; } - if (alignment64 == -1) + case CXTypeKind.CXType_UShort: + case CXTypeKind.CXType_Short: { - alignment64 = recordTypeAlignOf; + size32 = 2; + size64 = 2; + break; } - long maxFieldAlignment32 = -1; - long maxFieldAlignment64 = -1; - - long maxFieldSize32 = 0; - long maxFieldSize64 = 0; - - var anyFieldIs8BytePrimitive = false; + case CXTypeKind.CXType_UInt: + case CXTypeKind.CXType_Int: + case CXTypeKind.CXType_Float: + { + size32 = 4; + size64 = 4; + break; + } - if (recordType.Decl is CXXRecordDecl cxxRecordDecl) + case CXTypeKind.CXType_ULong: + case CXTypeKind.CXType_Long: { - if (HasVtbl(cxxRecordDecl, out _)) + if (_config.GenerateUnixTypes) { - size32 += 4; - size64 += 8; + size32 = 4; + size64 = 8; - if (alignment32 < 4) + if (alignment32 == -1) { - alignment32 = Math.Max(Math.Min(alignment32, 4), 1); + alignment32 = 4; } - if (alignment64 < 4) + if (alignment64 == -1) { - alignment64 = Math.Max(Math.Min(alignment32, 8), 1); + alignment64 = 8; } - - maxFieldSize32 = Math.Max(maxFieldSize32, 4); - maxFieldSize64 = Math.Max(maxFieldSize64, 8); - - maxFieldAlignment32 = Math.Max(maxFieldSize32, 4); - maxFieldAlignment64 = Math.Max(maxFieldSize64, 8); } else { - foreach (var baseCXXRecordDecl in cxxRecordDecl.Bases) - { - long fieldAlignment32 = -1; - long fieldAlignment64 = -1; + goto case CXTypeKind.CXType_UInt; + } + break; + } - GetTypeSize(baseCXXRecordDecl, baseCXXRecordDecl.Type, ref fieldAlignment32, ref fieldAlignment64, ref anyFieldIs8BytePrimitive, out var fieldSize32, out var fieldSize64); + case CXTypeKind.CXType_ULongLong: + case CXTypeKind.CXType_LongLong: + case CXTypeKind.CXType_Double: + { + size32 = 8; + size64 = 8; - if ((fieldAlignment32 == -1) || (alignment32 < 4)) - { - fieldAlignment32 = Math.Max(Math.Min(alignment32, fieldSize32), 1); - } + if (alignment32 == -1) + { + alignment32 = 8; + } - if ((fieldAlignment64 == -1) || (alignment64 < 4)) - { - fieldAlignment64 = Math.Max(Math.Min(alignment64, fieldSize64), 1); - } + if (alignment64 == -1) + { + alignment64 = 8; + } - if ((size32 % fieldAlignment32) != 0) - { - size32 += fieldAlignment32 - (size32 % fieldAlignment32); - } + has8BytePrimitiveField = true; + break; + } - if ((size64 % fieldAlignment64) != 0) - { - size64 += fieldAlignment64 - (size64 % fieldAlignment64); - } + case CXTypeKind.CXType_WChar: + { + if (_config.GenerateUnixTypes) + { + goto case CXTypeKind.CXType_Int; + } + else + { + goto case CXTypeKind.CXType_UShort; + } + } - size32 += fieldSize32; - size64 += fieldSize64; + default: + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported builtin type: '{type.KindSpelling}.", cursor); + break; + } + } + } + else if (type is ElaboratedType elaboratedType) + { + GetTypeSize(cursor, elaboratedType.NamedType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + } + else if (type is EnumType enumType) + { + GetTypeSize(cursor, enumType.Decl.IntegerType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + } + else if (type is FunctionType or PointerType or ReferenceType) + { + size32 = 4; + size64 = 8; - maxFieldAlignment32 = Math.Max(maxFieldAlignment32, fieldAlignment32); - maxFieldAlignment64 = Math.Max(maxFieldAlignment64, fieldAlignment64); + if (alignment32 == -1) + { + alignment32 = 4; + } - maxFieldSize32 = Math.Max(maxFieldSize32, fieldSize32); - maxFieldSize64 = Math.Max(maxFieldSize64, fieldSize64); - } - } - } + if (alignment64 == -1) + { + alignment64 = 8; + } + } + else if (type is InjectedClassNameType) + { + Debug.Assert(size32 == 0); + Debug.Assert(size64 == 0); + } + else if (type is RecordType recordType) + { + var recordTypeAlignOf = Math.Min(recordType.Handle.AlignOf, 8); - var bitfieldPreviousSize32 = 0L; - var bitfieldPreviousSize64 = 0L; - var bitfieldRemainingBits32 = 0L; - var bitfieldRemainingBits64 = 0L; + if (alignment32 == -1) + { + alignment32 = recordTypeAlignOf; + } - foreach (var fieldDecl in recordType.Decl.Fields) - { - long fieldAlignment32 = -1; - long fieldAlignment64 = -1; + if (alignment64 == -1) + { + alignment64 = recordTypeAlignOf; + } - GetTypeSize(fieldDecl, fieldDecl.Type, ref fieldAlignment32, ref fieldAlignment64, ref anyFieldIs8BytePrimitive, out var fieldSize32, out var fieldSize64); + long maxFieldAlignment32 = -1; + long maxFieldAlignment64 = -1; - var ignoreFieldSize32 = false; - var ignoreFieldSize64 = false; + long maxFieldSize32 = 0; + long maxFieldSize64 = 0; - if (fieldDecl.IsBitField) - { - if (fieldSize32 != bitfieldPreviousSize32) - { - bitfieldRemainingBits32 = fieldSize32 * 8; - bitfieldPreviousSize32 = fieldSize32; - bitfieldRemainingBits32 -= fieldDecl.BitWidthValue; - } - else if (fieldDecl.BitWidthValue > bitfieldRemainingBits32) - { - if (bitfieldRemainingBits32 != bitfieldRemainingBits64) - { - ignoreFieldSize32 = true; - } + var anyFieldIs8BytePrimitive = false; - bitfieldRemainingBits32 = fieldSize32 * 8; - bitfieldPreviousSize32 = fieldSize32; - bitfieldRemainingBits32 -= fieldDecl.BitWidthValue; - } - else - { - bitfieldPreviousSize32 = fieldSize32; - bitfieldRemainingBits32 -= fieldDecl.BitWidthValue; - ignoreFieldSize32 = true; - } + if (recordType.Decl is CXXRecordDecl cxxRecordDecl) + { + if (HasVtbl(cxxRecordDecl, out _)) + { + size32 += 4; + size64 += 8; - if ((fieldSize64 != bitfieldPreviousSize64) || (fieldDecl.BitWidthValue > bitfieldRemainingBits64)) - { - bitfieldRemainingBits64 = fieldSize64 * 8; - bitfieldPreviousSize64 = fieldSize64; - bitfieldRemainingBits64 -= fieldDecl.BitWidthValue; - } - else - { - bitfieldPreviousSize64 = fieldSize64; - bitfieldRemainingBits64 -= fieldDecl.BitWidthValue; - ignoreFieldSize64 = true; - } + if (alignment32 < 4) + { + alignment32 = Math.Max(Math.Min(alignment32, 4), 1); + } + + if (alignment64 < 4) + { + alignment64 = Math.Max(Math.Min(alignment32, 8), 1); } - if (!ignoreFieldSize32) + maxFieldSize32 = Math.Max(maxFieldSize32, 4); + maxFieldSize64 = Math.Max(maxFieldSize64, 8); + + maxFieldAlignment32 = Math.Max(maxFieldSize32, 4); + maxFieldAlignment64 = Math.Max(maxFieldSize64, 8); + } + else + { + foreach (var baseCXXRecordDecl in cxxRecordDecl.Bases) { + long fieldAlignment32 = -1; + long fieldAlignment64 = -1; + + GetTypeSize(baseCXXRecordDecl, baseCXXRecordDecl.Type, ref fieldAlignment32, ref fieldAlignment64, ref anyFieldIs8BytePrimitive, out var fieldSize32, out var fieldSize64); + if ((fieldAlignment32 == -1) || (alignment32 < 4)) { fieldAlignment32 = Math.Max(Math.Min(alignment32, fieldSize32), 1); } - if ((size32 % fieldAlignment32) != 0) + if ((fieldAlignment64 == -1) || (alignment64 < 4)) { - size32 += fieldAlignment32 - (size32 % fieldAlignment32); + fieldAlignment64 = Math.Max(Math.Min(alignment64, fieldSize64), 1); } - size32 += fieldSize32; - maxFieldAlignment32 = Math.Max(maxFieldAlignment32, fieldAlignment32); - maxFieldSize32 = Math.Max(maxFieldSize32, fieldSize32); - } - - if (!ignoreFieldSize64) - { - if ((fieldAlignment64 == -1) || (alignment64 < 4)) + if ((size32 % fieldAlignment32) != 0) { - fieldAlignment64 = Math.Max(Math.Min(alignment64, fieldSize64), 1); + size32 += fieldAlignment32 - (size32 % fieldAlignment32); } if ((size64 % fieldAlignment64) != 0) @@ -3686,1408 +3590,1426 @@ private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref lon size64 += fieldAlignment64 - (size64 % fieldAlignment64); } + size32 += fieldSize32; size64 += fieldSize64; + + maxFieldAlignment32 = Math.Max(maxFieldAlignment32, fieldAlignment32); maxFieldAlignment64 = Math.Max(maxFieldAlignment64, fieldAlignment64); + + maxFieldSize32 = Math.Max(maxFieldSize32, fieldSize32); maxFieldSize64 = Math.Max(maxFieldSize64, fieldSize64); } } + } - if ((alignment32 == 8) && !anyFieldIs8BytePrimitive) - { - alignment32 = Math.Min(alignment32, maxFieldAlignment32); - } + var bitfieldPreviousSize32 = 0L; + var bitfieldPreviousSize64 = 0L; + var bitfieldRemainingBits32 = 0L; + var bitfieldRemainingBits64 = 0L; - if ((alignment64 == 4) && !anyFieldIs8BytePrimitive) - { - alignment64 = Math.Max(alignment64, maxFieldAlignment64); - } + foreach (var fieldDecl in recordType.Decl.Fields) + { + long fieldAlignment32 = -1; + long fieldAlignment64 = -1; - if (recordType.Decl.IsUnion) - { - size32 = maxFieldSize32; - size64 = maxFieldSize64; - } + GetTypeSize(fieldDecl, fieldDecl.Type, ref fieldAlignment32, ref fieldAlignment64, ref anyFieldIs8BytePrimitive, out var fieldSize32, out var fieldSize64); - if ((size32 % alignment32) != 0) - { - size32 += alignment32 - (size32 % alignment32); - } + var ignoreFieldSize32 = false; + var ignoreFieldSize64 = false; - if ((size64 % alignment64) != 0) + if (fieldDecl.IsBitField) { - size64 += alignment64 - (size64 % alignment64); - } - - has8BytePrimitiveField |= anyFieldIs8BytePrimitive; - } - else if (type is TypedefType typedefType) - { - // We check remapped names here so that types that have variable sizes - // can be treated correctly. Otherwise, they will resolve to a particular - // platform size, based on whatever parameters were passed into clang. + if (fieldSize32 != bitfieldPreviousSize32) + { + bitfieldRemainingBits32 = fieldSize32 * 8; + bitfieldPreviousSize32 = fieldSize32; + bitfieldRemainingBits32 -= fieldDecl.BitWidthValue; + } + else if (fieldDecl.BitWidthValue > bitfieldRemainingBits32) + { + if (bitfieldRemainingBits32 != bitfieldRemainingBits64) + { + ignoreFieldSize32 = true; + } - var name = GetTypeName(cursor, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + bitfieldRemainingBits32 = fieldSize32 * 8; + bitfieldPreviousSize32 = fieldSize32; + bitfieldRemainingBits32 -= fieldDecl.BitWidthValue; + } + else + { + bitfieldPreviousSize32 = fieldSize32; + bitfieldRemainingBits32 -= fieldDecl.BitWidthValue; + ignoreFieldSize32 = true; + } - if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) - { - remappedName = name; + if ((fieldSize64 != bitfieldPreviousSize64) || (fieldDecl.BitWidthValue > bitfieldRemainingBits64)) + { + bitfieldRemainingBits64 = fieldSize64 * 8; + bitfieldPreviousSize64 = fieldSize64; + bitfieldRemainingBits64 -= fieldDecl.BitWidthValue; + } + else + { + bitfieldPreviousSize64 = fieldSize64; + bitfieldRemainingBits64 -= fieldDecl.BitWidthValue; + ignoreFieldSize64 = true; + } } - if ((remappedName == name) && _config.WithTransparentStructs.TryGetValue(remappedName, out var transparentStruct) && ((transparentStruct.Name == "long") || (transparentStruct.Name == "ulong"))) + if (!ignoreFieldSize32) { - size32 = 8; - size64 = 8; - - if (alignment32 == -1) + if ((fieldAlignment32 == -1) || (alignment32 < 4)) { - alignment32 = 8; + fieldAlignment32 = Math.Max(Math.Min(alignment32, fieldSize32), 1); } - if (alignment64 == -1) + if ((size32 % fieldAlignment32) != 0) { - alignment64 = 8; + size32 += fieldAlignment32 - (size32 % fieldAlignment32); } - has8BytePrimitiveField = true; + size32 += fieldSize32; + maxFieldAlignment32 = Math.Max(maxFieldAlignment32, fieldAlignment32); + maxFieldSize32 = Math.Max(maxFieldSize32, fieldSize32); } - else if (remappedName.Equals("IntPtr") || remappedName.Equals("nint") || remappedName.Equals("nuint") || remappedName.Equals("UIntPtr") || remappedName.EndsWith("*")) - { - size32 = 4; - size64 = 8; - if (alignment32 == -1) + if (!ignoreFieldSize64) + { + if ((fieldAlignment64 == -1) || (alignment64 < 4)) { - alignment32 = 4; + fieldAlignment64 = Math.Max(Math.Min(alignment64, fieldSize64), 1); } - if (alignment64 == -1) + if ((size64 % fieldAlignment64) != 0) { - alignment64 = 8; + size64 += fieldAlignment64 - (size64 % fieldAlignment64); } - } - else - { - GetTypeSize(cursor, typedefType.Decl.UnderlyingType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + + size64 += fieldSize64; + maxFieldAlignment64 = Math.Max(maxFieldAlignment64, fieldAlignment64); + maxFieldSize64 = Math.Max(maxFieldSize64, fieldSize64); } } - else if (type is SubstTemplateTypeParmType substTemplateTypeParmType) + + if ((alignment32 == 8) && !anyFieldIs8BytePrimitive) { - GetTypeSize(cursor, substTemplateTypeParmType.ReplacementType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + alignment32 = Math.Min(alignment32, maxFieldAlignment32); } - else if (type is TemplateSpecializationType templateSpecializationType) + + if ((alignment64 == 4) && !anyFieldIs8BytePrimitive) + { + alignment64 = Math.Max(alignment64, maxFieldAlignment64); + } + + if (recordType.Decl.IsUnion) + { + size32 = maxFieldSize32; + size64 = maxFieldSize64; + } + + if ((size32 % alignment32) != 0) + { + size32 += alignment32 - (size32 % alignment32); + } + + if ((size64 % alignment64) != 0) + { + size64 += alignment64 - (size64 % alignment64); + } + + has8BytePrimitiveField |= anyFieldIs8BytePrimitive; + } + else if (type is TypedefType typedefType) + { + // We check remapped names here so that types that have variable sizes + // can be treated correctly. Otherwise, they will resolve to a particular + // platform size, based on whatever parameters were passed into clang. + + var name = GetTypeName(cursor, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + + if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) + { + remappedName = name; + } + + if ((remappedName == name) && _config.WithTransparentStructs.TryGetValue(remappedName, out var transparentStruct) && ((transparentStruct.Name == "long") || (transparentStruct.Name == "ulong"))) { - if (templateSpecializationType.IsTypeAlias) + size32 = 8; + size64 = 8; + + if (alignment32 == -1) { - GetTypeSize(cursor, templateSpecializationType.AliasedType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + alignment32 = 8; } - else if (templateSpecializationType.IsSugared) + + if (alignment64 == -1) { - GetTypeSize(cursor, templateSpecializationType.Desugar, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + alignment64 = 8; } - else if (templateSpecializationType.TemplateName.AsTemplateDecl is TemplateDecl templateDecl) + + has8BytePrimitiveField = true; + } + else if (remappedName.Equals("IntPtr") || remappedName.Equals("nint") || remappedName.Equals("nuint") || remappedName.Equals("UIntPtr") || remappedName.EndsWith("*")) + { + size32 = 4; + size64 = 8; + + if (alignment32 == -1) { - if (templateDecl.TemplatedDecl is TypeDecl typeDecl) - { - GetTypeSize(cursor, typeDecl.TypeForDecl, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); - } - else - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported template specialization declaration kind: '{templateDecl.TemplatedDecl.DeclKindName}'.", cursor); - } + alignment32 = 4; + } + + if (alignment64 == -1) + { + alignment64 = 8; + } + } + else + { + GetTypeSize(cursor, typedefType.Decl.UnderlyingType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + } + } + else if (type is SubstTemplateTypeParmType substTemplateTypeParmType) + { + GetTypeSize(cursor, substTemplateTypeParmType.ReplacementType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + } + else if (type is TemplateSpecializationType templateSpecializationType) + { + if (templateSpecializationType.IsTypeAlias) + { + GetTypeSize(cursor, templateSpecializationType.AliasedType, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + } + else if (templateSpecializationType.IsSugared) + { + GetTypeSize(cursor, templateSpecializationType.Desugar, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); + } + else if (templateSpecializationType.TemplateName.AsTemplateDecl is TemplateDecl templateDecl) + { + if (templateDecl.TemplatedDecl is TypeDecl typeDecl) + { + GetTypeSize(cursor, typeDecl.TypeForDecl, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64); } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported template specialization type: '{templateSpecializationType}'.", cursor); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported template specialization declaration kind: '{templateDecl.TemplatedDecl.DeclKindName}'.", cursor); } } - else if (type is TemplateTypeParmType) - { - Debug.Assert(size32 == 0); - Debug.Assert(size64 == 0); - } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported type: '{type.TypeClass}'.", cursor); + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported template specialization type: '{templateSpecializationType}'.", cursor); } } + else if (type is TemplateTypeParmType) + { + Debug.Assert(size32 == 0); + Debug.Assert(size64 == 0); + } + else + { + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported type: '{type.TypeClass}'.", cursor); + } + } + + private bool HasSuppressGCTransition(Cursor cursor) + { + if (cursor is not NamedDecl namedDecl) + { + return false; + } + return HasRemapping(namedDecl, _config.WithSuppressGCTransitions); + } + + private bool HasBaseField(CXXRecordDecl cxxRecordDecl) + { + var hasBaseField = false; - private bool HasSuppressGCTransition(Cursor cursor) + foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) { - if (cursor is not NamedDecl namedDecl) + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); + + if (HasField(baseCxxRecordDecl)) { - return false; + hasBaseField = true; + break; } - return HasRemapping(namedDecl, _config.WithSuppressGCTransitions); } - private bool HasBaseField(CXXRecordDecl cxxRecordDecl) + return hasBaseField; + } + + private bool HasField(RecordDecl recordDecl) + { + var hasField = recordDecl.Fields.Any() || recordDecl.Decls.Any((decl) => (decl is RecordDecl nestedRecordDecl) && nestedRecordDecl.IsAnonymousStructOrUnion && HasField(nestedRecordDecl)); + + if (!hasField && (recordDecl is CXXRecordDecl cxxRecordDecl)) { - var hasBaseField = false; + hasField = HasBaseField(cxxRecordDecl); + } + + return hasField; + } + private bool HasUnsafeMethod(CXXRecordDecl cxxRecordDecl) + { + var hasUnsafeMethod = cxxRecordDecl.Methods.Any((method) => method.IsUserProvided && IsUnsafe(method) && !IsExcluded(method)); + + if (!hasUnsafeMethod) + { foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) { var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - if (HasField(baseCxxRecordDecl)) + if (HasUnsafeMethod(baseCxxRecordDecl)) { - hasBaseField = true; + hasUnsafeMethod = true; break; } } - - return hasBaseField; } - private bool HasField(RecordDecl recordDecl) + return hasUnsafeMethod; + } + + private bool HasVtbl(CXXRecordDecl cxxRecordDecl, out bool hasBaseVtbl) + { + var hasVtbl = cxxRecordDecl.Methods.Any((method) => method.IsVirtual && method.IsVirtual && (method.OverriddenMethods.Count == 0)); + hasBaseVtbl = false; + + if (!hasVtbl) { - var hasField = recordDecl.Fields.Any() || recordDecl.Decls.Any((decl) => (decl is RecordDecl nestedRecordDecl) && nestedRecordDecl.IsAnonymousStructOrUnion && HasField(nestedRecordDecl)); + var indirectVtblCount = 0; + + foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) + { + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - if (!hasField && (recordDecl is CXXRecordDecl cxxRecordDecl)) + if ((HasVtbl(baseCxxRecordDecl, out var baseHasBaseVtbl) || baseHasBaseVtbl) && !HasField(baseCxxRecordDecl)) + { + indirectVtblCount++; + } + } + + if (indirectVtblCount > 1) { - hasField = HasBaseField(cxxRecordDecl); + AddDiagnostic(DiagnosticLevel.Warning, "Unsupported cxx record declaration: 'multiple virtual bases'. Generated bindings may be incomplete.", cxxRecordDecl); } - return hasField; + hasBaseVtbl = indirectVtblCount != 0; } - private bool HasUnsafeMethod(CXXRecordDecl cxxRecordDecl) + return hasVtbl; + } + + private static bool IsEnumOperator(FunctionDecl functionDecl, string name) + { + if (name.StartsWith("operator") && ((functionDecl.Parameters.Count == 1) || (functionDecl.Parameters.Count == 2))) { - var hasUnsafeMethod = cxxRecordDecl.Methods.Any((method) => method.IsUserProvided && IsUnsafe(method) && !IsExcluded(method)); + var parmVarDecl1 = functionDecl.Parameters[0]; + var parmVarDecl1Type = parmVarDecl1.Type.CanonicalType; - if (!hasUnsafeMethod) + if (parmVarDecl1Type is PointerType pointerType1) { - foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) - { - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); + parmVarDecl1Type = pointerType1.PointeeType.CanonicalType; + } + else if (parmVarDecl1Type is ReferenceType referenceType1) + { + parmVarDecl1Type = referenceType1.PointeeType.CanonicalType; + } - if (HasUnsafeMethod(baseCxxRecordDecl)) - { - hasUnsafeMethod = true; - break; - } - } + if (functionDecl.Parameters.Count == 1) + { + return parmVarDecl1Type.Kind == CXTypeKind.CXType_Enum; + } + + var parmVarDecl2 = functionDecl.Parameters[1]; + var parmVarDecl2Type = parmVarDecl2.Type.CanonicalType; + + if (parmVarDecl2Type is PointerType pointerType2) + { + parmVarDecl2Type = pointerType2.PointeeType.CanonicalType; + } + else if (parmVarDecl2Type is ReferenceType referenceType2) + { + parmVarDecl2Type = referenceType2.PointeeType.CanonicalType; } - return hasUnsafeMethod; + if ((parmVarDecl1Type == parmVarDecl2Type) && (parmVarDecl2Type.Kind == CXTypeKind.CXType_Enum)) + { + return true; + } + } + return false; + } + + private bool IsExcluded(Cursor cursor) => IsExcluded(cursor, out _); + + private bool IsExcluded(Cursor cursor, out bool isExcludedByConflictingDefinition) + { + if (!_isExcluded.TryGetValue(cursor, out var isExcludedValue)) + { + isExcludedValue |= (!IsAlwaysIncluded(cursor) && (IsExcludedByConfig(cursor) || IsExcludedByFile(cursor) || IsExcludedByName(cursor, ref isExcludedValue))) ? 0b01u : 0b00u; + _isExcluded.Add(cursor, isExcludedValue); + } + isExcludedByConflictingDefinition = (isExcludedValue & 0b10) != 0; + return (isExcludedValue & 0b01) != 0; + + bool IsAlwaysIncluded(Cursor cursor) + { + return (cursor is TranslationUnitDecl) || (cursor is LinkageSpecDecl) || (cursor is NamespaceDecl) || ((cursor is VarDecl varDecl) && varDecl.Name.StartsWith("ClangSharpMacro_")); } - private bool HasVtbl(CXXRecordDecl cxxRecordDecl, out bool hasBaseVtbl) + bool IsExcludedByConfig(Cursor cursor) { - var hasVtbl = cxxRecordDecl.Methods.Any((method) => method.IsVirtual && method.IsVirtual && (method.OverriddenMethods.Count == 0)); - hasBaseVtbl = false; + return (_config.ExcludeFunctionsWithBody && (cursor is FunctionDecl functionDecl) && functionDecl.HasBody) + || (!_config.GenerateTemplateBindings && (cursor is TemplateDecl)); + } + + bool IsExcludedByFile(Cursor cursor) + { + if (_outputBuilder != null) + { + // We don't want to exclude by fileif we already have an active output builder as we + // are likely processing members of an already included type but those members may + // indirectly exist or be defined in a non-traversed file. + return false; + } + + var declLocation = cursor.Location; + declLocation.GetFileLocation(out var file, out var line, out var column, out _); - if (!hasVtbl) + if (IsIncludedFileOrLocation(cursor, file, declLocation)) { - var indirectVtblCount = 0; + return false; + } - foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) - { - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); + // It is not uncommon for some declarations to be done using macros, which are themselves + // defined in an imported header file. We want to also check if the expansion location is + // in the main file to catch these cases and ensure we still generate bindings for them. - if ((HasVtbl(baseCxxRecordDecl, out var baseHasBaseVtbl) || baseHasBaseVtbl) && !HasField(baseCxxRecordDecl)) - { - indirectVtblCount++; - } - } + declLocation.GetExpansionLocation(out var expansionFile, out var expansionLine, out var expansionColumn, out _); - if (indirectVtblCount > 1) - { - AddDiagnostic(DiagnosticLevel.Warning, "Unsupported cxx record declaration: 'multiple virtual bases'. Generated bindings may be incomplete.", cxxRecordDecl); - } + if ((expansionFile == file) && (expansionLine == line) && (expansionColumn == column) && _config.TraversalNames.Any()) + { + // clang_getLocation is a very expensive call, so exit early if the expansion file is the same + // However, if we are not explicitly specifying traversal names, its possible the expansion location + // is the same, but IsMainFile is now marked as true, in which case we can't exit early. - hasBaseVtbl = indirectVtblCount != 0; + return true; } - return hasVtbl; + var expansionLocation = cursor.TranslationUnit.Handle.GetLocation(expansionFile, expansionLine, expansionColumn); + + return !IsIncludedFileOrLocation(cursor, file, expansionLocation); } - private static bool IsEnumOperator(FunctionDecl functionDecl, string name) + bool IsExcludedByName(Cursor cursor, ref uint isExcludedValue) { - if (name.StartsWith("operator") && ((functionDecl.Parameters.Count == 1) || (functionDecl.Parameters.Count == 2))) + var isExcludedByConfigOption = false; + var qualifiedNameWithoutParameters = ""; + + string qualifiedName; + string name; + string kind; + + if (cursor is NamedDecl namedDecl) { - var parmVarDecl1 = functionDecl.Parameters[0]; - var parmVarDecl1Type = parmVarDecl1.Type.CanonicalType; + // We get the non-remapped name for the purpose of exclusion checks to ensure that users + // can remove no-definition declarations in favor of remapped anonymous declarations. - if (parmVarDecl1Type is PointerType pointerType1) - { - parmVarDecl1Type = pointerType1.PointeeType.CanonicalType; - } - else if (parmVarDecl1Type is ReferenceType referenceType1) - { - parmVarDecl1Type = referenceType1.PointeeType.CanonicalType; - } + qualifiedName = GetCursorQualifiedName(namedDecl); - if (functionDecl.Parameters.Count == 1) + if (namedDecl is FunctionDecl) { - return parmVarDecl1Type.Kind == CXTypeKind.CXType_Enum; + qualifiedNameWithoutParameters = GetCursorQualifiedName(namedDecl, truncateParameters: true); } - var parmVarDecl2 = functionDecl.Parameters[1]; - var parmVarDecl2Type = parmVarDecl2.Type.CanonicalType; + name = GetCursorName(namedDecl); + kind = $"{namedDecl.DeclKindName} declaration"; - if (parmVarDecl2Type is PointerType pointerType2) + if ((namedDecl is TagDecl tagDecl) && (tagDecl.Definition != tagDecl) && (tagDecl.Definition != null)) { - parmVarDecl2Type = pointerType2.PointeeType.CanonicalType; - } - else if (parmVarDecl2Type is ReferenceType referenceType2) - { - parmVarDecl2Type = referenceType2.PointeeType.CanonicalType; - } + // We don't want to generate bindings for anything + // that is not itself a definition and that has a + // definition that can be resolved. This ensures we + // still generate bindings for things which are used + // as opaque handles, but which aren't ever defined. - if ((parmVarDecl1Type == parmVarDecl2Type) && (parmVarDecl2Type.Kind == CXTypeKind.CXType_Enum)) - { + if (_config.LogExclusions) + { + AddDiagnostic(DiagnosticLevel.Info, $"Excluded {kind} '{qualifiedName}' by as it is not a definition."); + } return true; } } - return false; - } - - private bool IsExcluded(Cursor cursor) => IsExcluded(cursor, out _); - - private bool IsExcluded(Cursor cursor, out bool isExcludedByConflictingDefinition) - { - if (!_isExcluded.TryGetValue(cursor, out var isExcludedValue)) + else if (cursor is MacroDefinitionRecord macroDefinitionRecord) { - isExcludedValue |= (!IsAlwaysIncluded(cursor) && (IsExcludedByConfig(cursor) || IsExcludedByFile(cursor) || IsExcludedByName(cursor, ref isExcludedValue))) ? 0b01u : 0b00u; - _isExcluded.Add(cursor, isExcludedValue); + qualifiedName = macroDefinitionRecord.Name; + name = macroDefinitionRecord.Name; + kind = macroDefinitionRecord.CursorKindSpelling; + } + else + { + return false; } - isExcludedByConflictingDefinition = (isExcludedValue & 0b10) != 0; - return (isExcludedValue & 0b01) != 0; - bool IsAlwaysIncluded(Cursor cursor) + if (qualifiedName.Contains("ClangSharpMacro_")) { - return (cursor is TranslationUnitDecl) || (cursor is LinkageSpecDecl) || (cursor is NamespaceDecl) || ((cursor is VarDecl varDecl) && varDecl.Name.StartsWith("ClangSharpMacro_")); + qualifiedName = qualifiedName.Replace("ClangSharpMacro_", ""); } - bool IsExcludedByConfig(Cursor cursor) + if (name.Contains("ClangSharpMacro_")) { - return (_config.ExcludeFunctionsWithBody && (cursor is FunctionDecl functionDecl) && functionDecl.HasBody) - || (!_config.GenerateTemplateBindings && (cursor is TemplateDecl)); + name = name.Replace("ClangSharpMacro_", ""); } - bool IsExcludedByFile(Cursor cursor) + if (cursor is RecordDecl recordDecl) { - if (_outputBuilder != null) + if (_config.ExcludeEmptyRecords && IsEmptyRecord(recordDecl)) { - // We don't want to exclude by fileif we already have an active output builder as we - // are likely processing members of an already included type but those members may - // indirectly exist or be defined in a non-traversed file. - return false; + isExcludedByConfigOption = true; } - - var declLocation = cursor.Location; - declLocation.GetFileLocation(out var file, out var line, out var column, out _); - - if (IsIncludedFileOrLocation(cursor, file, declLocation)) + } + else if (cursor is FunctionDecl functionDecl) + { + if (_config.ExcludeComProxies && IsComProxy(functionDecl, name)) { - return false; + isExcludedByConfigOption = true; } - - // It is not uncommon for some declarations to be done using macros, which are themselves - // defined in an imported header file. We want to also check if the expansion location is - // in the main file to catch these cases and ensure we still generate bindings for them. - - declLocation.GetExpansionLocation(out var expansionFile, out var expansionLine, out var expansionColumn, out _); - - if ((expansionFile == file) && (expansionLine == line) && (expansionColumn == column) && _config.TraversalNames.Any()) + else if (_config.ExcludeEnumOperators && IsEnumOperator(functionDecl, name)) { - // clang_getLocation is a very expensive call, so exit early if the expansion file is the same - // However, if we are not explicitly specifying traversal names, its possible the expansion location - // is the same, but IsMainFile is now marked as true, in which case we can't exit early. - - return true; + isExcludedByConfigOption = true; + } + else if ((functionDecl is CXXMethodDecl cxxMethodDecl) && IsConflictingMethodDecl(cxxMethodDecl, cxxMethodDecl.Parent)) + { + isExcludedValue |= 0b10; } - - var expansionLocation = cursor.TranslationUnit.Handle.GetLocation(expansionFile, expansionLine, expansionColumn); - - return !IsIncludedFileOrLocation(cursor, file, expansionLocation); } - bool IsExcludedByName(Cursor cursor, ref uint isExcludedValue) - { - var isExcludedByConfigOption = false; - - string qualifiedName; - string qualifiedNameWithoutParameters = ""; - string name; - string kind; + var dottedQualifiedName = qualifiedName.Replace("::", "."); - if (cursor is NamedDecl namedDecl) + if (_config.ExcludedNames.Contains(qualifiedName) || _config.ExcludedNames.Contains(dottedQualifiedName)) + { + if (_config.LogExclusions) { - // We get the non-remapped name for the purpose of exclusion checks to ensure that users - // can remove no-definition declarations in favor of remapped anonymous declarations. + var message = $"Excluded {kind} '{qualifiedName}' by exact match"; - qualifiedName = GetCursorQualifiedName(namedDecl); - - if (namedDecl is FunctionDecl) + if (isExcludedByConfigOption) { - qualifiedNameWithoutParameters = GetCursorQualifiedName(namedDecl, truncateParameters: true); + message += "; Exclusion is unnecessary due to a config option"; } - - name = GetCursorName(namedDecl); - kind = $"{namedDecl.DeclKindName} declaration"; - - if ((namedDecl is TagDecl tagDecl) && (tagDecl.Definition != tagDecl) && (tagDecl.Definition != null)) + else if ((isExcludedValue & 0b10) != 0) { - // We don't want to generate bindings for anything - // that is not itself a definition and that has a - // definition that can be resolved. This ensures we - // still generate bindings for things which are used - // as opaque handles, but which aren't ever defined. - - if (_config.LogExclusions) - { - AddDiagnostic(DiagnosticLevel.Info, $"Excluded {kind} '{qualifiedName}' by as it is not a definition."); - } - return true; + message += "; Exclusion is unnecessary due to a conflicting definition"; } - } - else if (cursor is MacroDefinitionRecord macroDefinitionRecord) - { - qualifiedName = macroDefinitionRecord.Name; - name = macroDefinitionRecord.Name; - kind = macroDefinitionRecord.CursorKindSpelling; - } - else - { - return false; - } - if (qualifiedName.Contains("ClangSharpMacro_")) - { - qualifiedName = qualifiedName.Replace("ClangSharpMacro_", ""); + AddDiagnostic(DiagnosticLevel.Info, message); } + return true; + } - if (name.Contains("ClangSharpMacro_")) - { - name = name.Replace("ClangSharpMacro_", ""); - } + var dottedQualifiedNameWithoutParameters = qualifiedNameWithoutParameters.Replace("::", "."); - if (cursor is RecordDecl recordDecl) - { - if (_config.ExcludeEmptyRecords && IsEmptyRecord(recordDecl)) - { - isExcludedByConfigOption = true; - } - } - else if (cursor is FunctionDecl functionDecl) + if (_config.ExcludedNames.Contains(qualifiedNameWithoutParameters) || _config.ExcludedNames.Contains(dottedQualifiedNameWithoutParameters) || _config.ExcludedNames.Contains(name)) + { + if (_config.LogExclusions) { - if (_config.ExcludeComProxies && IsComProxy(functionDecl, name)) - { - isExcludedByConfigOption = true; - } - else if (_config.ExcludeEnumOperators && IsEnumOperator(functionDecl, name)) + var message = $"Excluded {kind} '{qualifiedName}' by partial match against {name}"; + + if (isExcludedByConfigOption) { - isExcludedByConfigOption = true; + message += "; Exclusion is unnecessary due to a config option"; } - else if ((functionDecl is CXXMethodDecl cxxMethodDecl) && IsConflictingMethodDecl(cxxMethodDecl, cxxMethodDecl.Parent)) + else if ((isExcludedValue & 0b10) != 0) { - isExcludedValue |= 0b10; + message += "; Exclusion is unnecessary due to a conflicting definition"; } - } - var dottedQualifiedName = qualifiedName.Replace("::", "."); + AddDiagnostic(DiagnosticLevel.Info, message); + } + return true; + } - if (_config.ExcludedNames.Contains(qualifiedName) || _config.ExcludedNames.Contains(dottedQualifiedName)) + if (isExcludedByConfigOption) + { + if (_config.LogExclusions) { - if (_config.LogExclusions) - { - var message = $"Excluded {kind} '{qualifiedName}' by exact match"; + AddDiagnostic(DiagnosticLevel.Info, $"Excluded {kind} '{qualifiedName}' by config option"); + } + return true; + } - if (isExcludedByConfigOption) - { - message += "; Exclusion is unnecessary due to a config option"; - } - else if ((isExcludedValue & 0b10) != 0) - { - message += "; Exclusion is unnecessary due to a conflicting definition"; - } + if (_config.IncludedNames.Any() && !_config.IncludedNames.Contains(qualifiedName) + && !_config.IncludedNames.Contains(dottedQualifiedName) + && !_config.IncludedNames.Contains(qualifiedNameWithoutParameters) + && !_config.IncludedNames.Contains(dottedQualifiedNameWithoutParameters) + && !_config.IncludedNames.Contains(name)) + { + if (_config.LogExclusions) + { + AddDiagnostic(DiagnosticLevel.Info, $"Excluded {kind} '{qualifiedName}' as it was not in the include list"); + } + return true; + } - AddDiagnostic(DiagnosticLevel.Info, message); - } - return true; + if ((isExcludedValue & 0b10) != 0) + { + if (_config.LogExclusions) + { + AddDiagnostic(DiagnosticLevel.Info, $"Excluded {kind} '{qualifiedName}' by conflicting definition"); } + return true; + } - var dottedQualifiedNameWithoutParameters = qualifiedNameWithoutParameters.Replace("::", "."); + return false; + } - if (_config.ExcludedNames.Contains(qualifiedNameWithoutParameters) || _config.ExcludedNames.Contains(dottedQualifiedNameWithoutParameters) || _config.ExcludedNames.Contains(name)) - { - if (_config.LogExclusions) - { - var message = $"Excluded {kind} '{qualifiedName}' by partial match against {name}"; + bool IsIncludedFileOrLocation(Cursor cursor, CXFile file, CXSourceLocation location) + { + // Use case insensitive comparison on Windows + var equalityComparer = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal; - if (isExcludedByConfigOption) - { - message += "; Exclusion is unnecessary due to a config option"; - } - else if ((isExcludedValue & 0b10) != 0) - { - message += "; Exclusion is unnecessary due to a conflicting definition"; - } + // Normalize paths to be '/' for comparison + var fileName = file.Name.ToString().Replace('\\', '/'); - AddDiagnostic(DiagnosticLevel.Info, message); - } - return true; - } + if (_visitedFiles.Add(fileName) && _config.LogVisitedFiles) + { + AddDiagnostic(DiagnosticLevel.Info, $"Visiting {fileName}"); + } - if (isExcludedByConfigOption) - { - if (_config.LogExclusions) - { - AddDiagnostic(DiagnosticLevel.Info, $"Excluded {kind} '{qualifiedName}' by config option"); - } - return true; - } + if (_config.TraversalNames.Contains(fileName, equalityComparer)) + { + return true; + } + else if (!_config.TraversalNames.Any() && location.IsFromMainFile) + { + return true; + } - if (_config.IncludedNames.Any() && !_config.IncludedNames.Contains(qualifiedName) - && !_config.IncludedNames.Contains(dottedQualifiedName) - && !_config.IncludedNames.Contains(qualifiedNameWithoutParameters) - && !_config.IncludedNames.Contains(dottedQualifiedNameWithoutParameters) - && !_config.IncludedNames.Contains(name)) - { - if (_config.LogExclusions) - { - AddDiagnostic(DiagnosticLevel.Info, $"Excluded {kind} '{qualifiedName}' as it was not in the include list"); - } - return true; - } + return false; + } - if ((isExcludedValue & 0b10) != 0) - { - if (_config.LogExclusions) - { - AddDiagnostic(DiagnosticLevel.Info, $"Excluded {kind} '{qualifiedName}' by conflicting definition"); - } - return true; - } + bool IsComProxy(FunctionDecl functionDecl, string name) + { + var parmVarDecl = null as ParmVarDecl; - return false; + if (name.EndsWith("_UserFree") || name.EndsWith("_UserFree64") || + name.EndsWith("_UserMarshal") || name.EndsWith("_UserMarshal64") || + name.EndsWith("_UserSize") || name.EndsWith("_UserSize64") || + name.EndsWith("_UserUnmarshal") || name.EndsWith("_UserUnmarshal64")) + { + parmVarDecl = functionDecl.Parameters.LastOrDefault(); + } + else if (name.EndsWith("_Proxy") || name.EndsWith("_Stub")) + { + parmVarDecl = functionDecl.Parameters.FirstOrDefault(); } - bool IsIncludedFileOrLocation(Cursor cursor, CXFile file, CXSourceLocation location) + if ((parmVarDecl != null) && (parmVarDecl.Type is PointerType pointerType)) { - // Use case insensitive comparison on Windows - var equalityComparer = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal; + var typeName = GetTypeName(parmVarDecl, context: null, pointerType.PointeeType, ignoreTransparentStructsWhereRequired: false, out var nativeTypeName); + return name.StartsWith($"{nativeTypeName}_") || name.StartsWith($"{typeName}_") || (typeName == "IRpcStubBuffer"); + } + return false; + } - // Normalize paths to be '/' for comparison - var fileName = file.Name.ToString().Replace('\\', '/'); + bool IsConflictingMethodDecl(CXXMethodDecl cxxMethodDeclToMatch, CXXRecordDecl cxxRecordDecl) + { + var cxxMethodDeclToMatchName = GetRemappedCursorName(cxxMethodDeclToMatch); + var foundCxxMethodDeclToMatch = false; - if (_visitedFiles.Add(fileName) && _config.LogVisitedFiles) - { - AddDiagnostic(DiagnosticLevel.Info, $"Visiting {fileName}"); - } + foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) + { + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - if (_config.TraversalNames.Contains(fileName, equalityComparer)) + if (ContainsConflictingMethodDecl(cxxMethodDeclToMatch, cxxRecordDecl, baseCxxRecordDecl, cxxMethodDeclToMatchName, ref foundCxxMethodDeclToMatch)) { return true; } - else if (!_config.TraversalNames.Any() && location.IsFromMainFile) + } + + return ContainsConflictingMethodDecl(cxxMethodDeclToMatch, cxxRecordDecl, cxxRecordDecl, cxxMethodDeclToMatchName, ref foundCxxMethodDeclToMatch); + + bool ContainsConflictingMethodDecl(CXXMethodDecl cxxMethodDeclToMatch, CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl, string cxxMethodDeclToMatchName, ref bool foundCxxMethodDeclToMatch) + { + var cxxMethodDecls = cxxRecordDecl.Methods; + + if (cxxMethodDecls.Count != 0) { - return true; + foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) + { + if (IsConflictingMethodDecl(cxxMethodDeclToMatch, cxxMethodDecl, rootCxxRecordDecl, cxxRecordDecl, cxxMethodDeclToMatchName, ref foundCxxMethodDeclToMatch)) + { + return true; + } + } } return false; } - bool IsComProxy(FunctionDecl functionDecl, string name) + bool IsConflictingMethodDecl(CXXMethodDecl cxxMethodDeclToMatch, CXXMethodDecl cxxMethodDecl, CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl, string cxxMethodDeclToMatchName, ref bool foundCxxMethodDeclToMatch) { - var parmVarDecl = null as ParmVarDecl; + var methodName = GetRemappedCursorName(cxxMethodDecl); - if (name.EndsWith("_UserFree") || name.EndsWith("_UserFree64") || - name.EndsWith("_UserMarshal") || name.EndsWith("_UserMarshal64") || - name.EndsWith("_UserSize") || name.EndsWith("_UserSize64") || - name.EndsWith("_UserUnmarshal") || name.EndsWith("_UserUnmarshal64")) + if (cxxMethodDeclToMatchName != methodName) { - parmVarDecl = functionDecl.Parameters.LastOrDefault(); - } - else if (name.EndsWith("_Proxy") || name.EndsWith("_Stub")) - { - parmVarDecl = functionDecl.Parameters.FirstOrDefault(); + return false; } - if ((parmVarDecl != null) && (parmVarDecl.Type is PointerType pointerType)) + if (cxxMethodDecl == cxxMethodDeclToMatch) { - var typeName = GetTypeName(parmVarDecl, context: null, pointerType.PointeeType, ignoreTransparentStructsWhereRequired: false, out var nativeTypeName); - return name.StartsWith($"{nativeTypeName}_") || name.StartsWith($"{typeName}_") || (typeName == "IRpcStubBuffer"); + foundCxxMethodDeclToMatch = true; + return false; } - return false; - } - - bool IsConflictingMethodDecl(CXXMethodDecl cxxMethodDeclToMatch, CXXRecordDecl cxxRecordDecl) - { - var cxxMethodDeclToMatchName = GetRemappedCursorName(cxxMethodDeclToMatch); - var foundCxxMethodDeclToMatch = false; - foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) + if (cxxMethodDecl.Parameters.Count != cxxMethodDeclToMatch.Parameters.Count) { - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - - if (ContainsConflictingMethodDecl(cxxMethodDeclToMatch, cxxRecordDecl, baseCxxRecordDecl, cxxMethodDeclToMatchName, ref foundCxxMethodDeclToMatch)) - { - return true; - } + return false; } - return ContainsConflictingMethodDecl(cxxMethodDeclToMatch, cxxRecordDecl, cxxRecordDecl, cxxMethodDeclToMatchName, ref foundCxxMethodDeclToMatch); + var allMatch = true; - bool ContainsConflictingMethodDecl(CXXMethodDecl cxxMethodDeclToMatch, CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl, string cxxMethodDeclToMatchName, ref bool foundCxxMethodDeclToMatch) + for (var n = 0; n < cxxMethodDeclToMatch.Parameters.Count; n++) { - var cxxMethodDecls = cxxRecordDecl.Methods; + var parameterTypeToMatch = cxxMethodDeclToMatch.Parameters[n].Type.CanonicalType; + var parameterType = cxxMethodDecl.Parameters[n].Type.CanonicalType; - if (cxxMethodDecls.Count != 0) + if (parameterType == parameterTypeToMatch) { - foreach (var cxxMethodDecl in cxxMethodDecls.OrderBy((cxxmd) => cxxmd.VtblIndex)) - { - if (IsConflictingMethodDecl(cxxMethodDeclToMatch, cxxMethodDecl, rootCxxRecordDecl, cxxRecordDecl, cxxMethodDeclToMatchName, ref foundCxxMethodDeclToMatch)) - { - return true; - } - } + continue; } - return false; - } - - bool IsConflictingMethodDecl(CXXMethodDecl cxxMethodDeclToMatch, CXXMethodDecl cxxMethodDecl, CXXRecordDecl rootCxxRecordDecl, CXXRecordDecl cxxRecordDecl, string cxxMethodDeclToMatchName, ref bool foundCxxMethodDeclToMatch) - { - var methodName = GetRemappedCursorName(cxxMethodDecl); - - if (cxxMethodDeclToMatchName != methodName) + if ((parameterTypeToMatch is PointerType pointerTypeToMatch) && + (parameterType is ReferenceType referenceType) && + (referenceType.PointeeType.CanonicalType == pointerTypeToMatch.PointeeType.CanonicalType)) { - return false; + continue; } - if (cxxMethodDecl == cxxMethodDeclToMatch) + if ((parameterTypeToMatch is ReferenceType referenceTypeToMatch) && + (parameterType is PointerType pointerType) && + (pointerType.PointeeType.CanonicalType == referenceTypeToMatch.PointeeType.CanonicalType)) { - foundCxxMethodDeclToMatch = true; - return false; + continue; } - if (cxxMethodDecl.Parameters.Count != cxxMethodDeclToMatch.Parameters.Count) - { - return false; - } + allMatch = false; + break; + } - var allMatch = true; + if (!allMatch) + { + return false; + } - for (var n = 0; n < cxxMethodDeclToMatch.Parameters.Count; n++) + if (cxxMethodDecl.IsVirtual) + { + if (cxxMethodDeclToMatch.IsVirtual) { - var parameterTypeToMatch = cxxMethodDeclToMatch.Parameters[n].Type.CanonicalType; - var parameterType = cxxMethodDecl.Parameters[n].Type.CanonicalType; - - if (parameterType == parameterTypeToMatch) - { - continue; - } - - if ((parameterTypeToMatch is PointerType pointerTypeToMatch) && - (parameterType is ReferenceType referenceType) && - (referenceType.PointeeType.CanonicalType == pointerTypeToMatch.PointeeType.CanonicalType)) - { - continue; - } - - if ((parameterTypeToMatch is ReferenceType referenceTypeToMatch) && - (parameterType is PointerType pointerType) && - (pointerType.PointeeType.CanonicalType == referenceTypeToMatch.PointeeType.CanonicalType)) + if (rootCxxRecordDecl != cxxRecordDecl) { - continue; + // The found declaration and declaration to match are both virtual + // We want to treat the one from the base declaration as non-conflicting + // So return true to report the declration to match as the conflict + return true; } - - allMatch = false; - break; - } - - if (!allMatch) - { - return false; - } - - if (cxxMethodDecl.IsVirtual) - { - if (cxxMethodDeclToMatch.IsVirtual) + else if (cxxMethodDeclToMatch.IsThisDeclarationADefinition != cxxMethodDecl.IsThisDeclarationADefinition) { - if (rootCxxRecordDecl != cxxRecordDecl) - { - // The found declaration and declaration to match are both virtual - // We want to treat the one from the base declaration as non-conflicting - // So return true to report the declration to match as the conflict - return true; - } - else if (cxxMethodDeclToMatch.IsThisDeclarationADefinition != cxxMethodDecl.IsThisDeclarationADefinition) - { - return false; - } - else - { - AddDiagnostic(DiagnosticLevel.Error, "Found conflicting method definitions for two virtual methods.", cxxMethodDeclToMatch); - } + return false; } else { - // The found declaration is virtual while the declaration to match is not - // We want to treat the virtual declaration as non-conflicting - // So return true to report the declration to match as the conflict - return true; + AddDiagnostic(DiagnosticLevel.Error, "Found conflicting method definitions for two virtual methods.", cxxMethodDeclToMatch); } } - else if (cxxMethodDeclToMatch.IsVirtual) - { - // The declaration to match is virtual while the found declaration is not - // We want to treat the virtual declaration as non-conflicting - // So treat the declaration as non-conflicting and continue searching - return false; - } else { - // Neither the declaration nor the declaration to match are virtual - // We want to pick whichever declaration appears first - // So return true or false based on if we already encounted the declaration to match - return !foundCxxMethodDeclToMatch; + // The found declaration is virtual while the declaration to match is not + // We want to treat the virtual declaration as non-conflicting + // So return true to report the declration to match as the conflict + return true; } - + } + else if (cxxMethodDeclToMatch.IsVirtual) + { + // The declaration to match is virtual while the found declaration is not + // We want to treat the virtual declaration as non-conflicting + // So treat the declaration as non-conflicting and continue searching return false; } + else + { + // Neither the declaration nor the declaration to match are virtual + // We want to pick whichever declaration appears first + // So return true or false based on if we already encounted the declaration to match + return !foundCxxMethodDeclToMatch; + } + + return false; } + } - bool IsEmptyRecord(RecordDecl recordDecl) + bool IsEmptyRecord(RecordDecl recordDecl) + { + if (recordDecl.Fields.Count != 0) { - if (recordDecl.Fields.Count != 0) + if (!GetCursorName(recordDecl).EndsWith("__") || (recordDecl.Fields.Count != 1)) { - if (!GetCursorName(recordDecl).EndsWith("__") || (recordDecl.Fields.Count != 1)) - { - return false; - } + return false; + } - var field = recordDecl.Fields.First(); + var field = recordDecl.Fields.First(); - if ((GetCursorName(field) != "unused") || (field.Type.CanonicalType.Kind != CXTypeKind.CXType_Int)) - { - return false; - } + if ((GetCursorName(field) != "unused") || (field.Type.CanonicalType.Kind != CXTypeKind.CXType_Int)) + { + return false; } + } - foreach (var decl in recordDecl.Decls) + foreach (var decl in recordDecl.Decls) + { + if ((decl is RecordDecl nestedRecordDecl) && nestedRecordDecl.IsAnonymousStructOrUnion && !IsEmptyRecord(nestedRecordDecl)) { - if ((decl is RecordDecl nestedRecordDecl) && nestedRecordDecl.IsAnonymousStructOrUnion && !IsEmptyRecord(nestedRecordDecl)) - { - return false; - } + return false; + } - if ((decl is CXXMethodDecl cxxMethodDecl) && cxxMethodDecl.IsVirtual) - { - return false; - } + if ((decl is CXXMethodDecl cxxMethodDecl) && cxxMethodDecl.IsVirtual) + { + return false; } + } - if (recordDecl is CXXRecordDecl cxxRecordDecl) + if (recordDecl is CXXRecordDecl cxxRecordDecl) + { + foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) { - foreach (var cxxBaseSpecifier in cxxRecordDecl.Bases) - { - var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); + var baseCxxRecordDecl = GetRecordDecl(cxxBaseSpecifier); - if (!IsEmptyRecord(baseCxxRecordDecl)) - { - return false; - } + if (!IsEmptyRecord(baseCxxRecordDecl)) + { + return false; } } - - return !TryGetUuid(recordDecl, out _); } + + return !TryGetUuid(recordDecl, out _); } + } - private bool IsFixedSize(Cursor cursor, Type type) + private bool IsFixedSize(Cursor cursor, Type type) + { + if (type is ArrayType) { - if (type is ArrayType) - { - return false; - } - else if (type is AttributedType attributedType) + return false; + } + else if (type is AttributedType attributedType) + { + return IsFixedSize(cursor, attributedType.ModifiedType); + } + else if (type is BuiltinType) + { + return true; + } + else if (type is ElaboratedType elaboratedType) + { + return IsFixedSize(cursor, elaboratedType.NamedType); + } + else if (type is EnumType enumType) + { + return IsFixedSize(cursor, enumType.Decl.IntegerType); + } + else if (type is FunctionType) + { + return false; + } + else if (type is PointerType) + { + return false; + } + else if (type is RecordType recordType) + { + var recordDecl = recordType.Decl; + + return recordDecl.Fields.All((fieldDecl) => IsFixedSize(fieldDecl, fieldDecl.Type)) + && (recordDecl is not CXXRecordDecl cxxRecordDecl || cxxRecordDecl.Methods.All((cxxMethodDecl) => !cxxMethodDecl.IsVirtual)); + } + else if (type is ReferenceType) + { + return false; + } + else if (type is TypedefType typedefType) + { + var name = GetTypeName(cursor, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + + if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) { - return IsFixedSize(cursor, attributedType.ModifiedType); + remappedName = name; } - else if (type is BuiltinType) + + return (remappedName != "IntPtr") + && (remappedName != "nint") + && (remappedName != "nuint") + && (remappedName != "UIntPtr") + && IsFixedSize(cursor, typedefType.Decl.UnderlyingType); + } + else + { + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported type: '{type.TypeClass}'. Assuming unfixed size.", cursor); + return false; + } + } + + private bool IsNativeTypeNameEquivalent(string nativeTypeName, string typeName) + { + if (nativeTypeName.Equals(typeName, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + if (nativeTypeName.Replace(" ", "").Equals(typeName, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + return false; + } + + private bool IsPrevContextDecl(out T cursor, out object userData) + where T : Decl + { + var previousContext = _context.Last.Previous; + + while (previousContext.Value.Cursor is not Decl) + { + previousContext = previousContext.Previous; + } + + var value = previousContext.Value; + + if (value.Cursor is T t) + { + cursor = t; + userData = value.UserData; + return true; + } + else + { + cursor = null; + userData = null; + return false; + } + } + + private bool IsPrevContextStmt(out T cursor, out object userData, bool preserveParen = false, bool preserveImplicitCast = false) + where T : Stmt + { + var previousContext = _context.Last.Previous; + + while ((!preserveParen && (previousContext.Value.Cursor is ParenExpr)) || (!preserveImplicitCast && (previousContext.Value.Cursor is ImplicitCastExpr))) + { + previousContext = previousContext.Previous; + } + + var value = previousContext.Value; + + if (value.Cursor is T t) + { + cursor = t; + userData = value.UserData; + return true; + } + else + { + cursor = null; + userData = null; + return false; + } + } + + private static bool IsStmtAsWritten(Cursor cursor, out T value, bool removeParens = false) + where T : Stmt + { + if (cursor is Expr expr) + { + cursor = GetExprAsWritten(expr, removeParens); + } + + if (cursor is T t) + { + value = t; + return true; + } + else + { + value = null; + return false; + } + } + + private static bool IsStmtAsWritten(Stmt stmt, Stmt expectedStmt, bool removeParens = false) + { + if (stmt == expectedStmt) + { + return true; + } + + if (stmt is not Expr expr) + { + return false; + } + + expr = GetExprAsWritten(expr, removeParens); + return expr == expectedStmt; + } + + internal static bool IsSupportedFixedSizedBufferType(string typeName) + { + switch (typeName) + { + case "bool": + case "byte": + case "char": + case "double": + case "float": + case "int": + case "long": + case "sbyte": + case "short": + case "ushort": + case "uint": + case "ulong": { return true; } - else if (type is ElaboratedType elaboratedType) - { - return IsFixedSize(cursor, elaboratedType.NamedType); - } - else if (type is EnumType enumType) - { - return IsFixedSize(cursor, enumType.Decl.IntegerType); - } - else if (type is FunctionType) - { - return false; - } - else if (type is PointerType) - { - return false; - } - else if (type is RecordType recordType) - { - var recordDecl = recordType.Decl; - return recordDecl.Fields.All((fieldDecl) => IsFixedSize(fieldDecl, fieldDecl.Type)) - && (recordDecl is not CXXRecordDecl cxxRecordDecl || cxxRecordDecl.Methods.All((cxxMethodDecl) => !cxxMethodDecl.IsVirtual)); - } - else if (type is ReferenceType) + default: { return false; } - else if (type is TypedefType typedefType) - { - var name = GetTypeName(cursor, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + } + } - if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) - { - remappedName = name; - } + private static bool IsTransparentStructBoolean(PInvokeGeneratorTransparentStructKind kind) + { + return kind == PInvokeGeneratorTransparentStructKind.Boolean; + } - return (remappedName != "IntPtr") - && (remappedName != "nint") - && (remappedName != "nuint") - && (remappedName != "UIntPtr") - && IsFixedSize(cursor, typedefType.Decl.UnderlyingType); - } - else - { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported type: '{type.TypeClass}'. Assuming unfixed size.", cursor); - return false; - } - } + private static bool IsTransparentStructHandle(PInvokeGeneratorTransparentStructKind kind) + { + return kind is PInvokeGeneratorTransparentStructKind.Handle + or PInvokeGeneratorTransparentStructKind.HandleWin32; + } - private bool IsNativeTypeNameEquivalent(string nativeTypeName, string typeName) + private static bool IsTransparentStructHexBased(PInvokeGeneratorTransparentStructKind kind) + { + return IsTransparentStructHandle(kind) + || (kind == PInvokeGeneratorTransparentStructKind.TypedefHex); + } + + private bool IsUnchecked(string targetTypeName, Stmt stmt) + { + if (IsPrevContextDecl(out var parentVarDecl, out _)) { - if (nativeTypeName.Equals(typeName, StringComparison.OrdinalIgnoreCase)) - { - return true; - } + var cursorName = GetCursorName(parentVarDecl); - if (nativeTypeName.Replace(" ", "").Equals(typeName, StringComparison.OrdinalIgnoreCase)) + if (cursorName.StartsWith("ClangSharpMacro_") && _config.WithTransparentStructs.TryGetValue(targetTypeName, out var transparentStruct)) { - return true; + targetTypeName = transparentStruct.Name; } - - return false; } - private bool IsPrevContextDecl(out T cursor, out object userData) - where T : Decl + switch (stmt.StmtClass) { - var previousContext = _context.Last.Previous; + // case CX_StmtClass.CX_StmtClass_BinaryConditionalOperator: - while (previousContext.Value.Cursor is not Decl) + case CX_StmtClass.CX_StmtClass_ConditionalOperator: { - previousContext = previousContext.Previous; + var conditionalOperator = (ConditionalOperator)stmt; + return IsUnchecked(targetTypeName, conditionalOperator.LHS) + || IsUnchecked(targetTypeName, conditionalOperator.RHS) + || IsUnchecked(targetTypeName, conditionalOperator.Handle.Evaluate); } - var value = previousContext.Value; + // case CX_StmtClass.CX_StmtClass_AddrLabelExpr: + // case CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr: + // case CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr: - if (value.Cursor is T t) - { - cursor = t; - userData = value.UserData; - return true; - } - else + case CX_StmtClass.CX_StmtClass_ArraySubscriptExpr: { - cursor = null; - userData = null; - return false; + var arraySubscriptExpr = (ArraySubscriptExpr)stmt; + return IsUnchecked(targetTypeName, arraySubscriptExpr.LHS) + || IsUnchecked(targetTypeName, arraySubscriptExpr.RHS); } - } - private bool IsPrevContextStmt(out T cursor, out object userData, bool preserveParen = false, bool preserveImplicitCast = false) - where T : Stmt - { - var previousContext = _context.Last.Previous; + // case CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr: + // case CX_StmtClass.CX_StmtClass_AsTypeExpr: + // case CX_StmtClass.CX_StmtClass_AtomicExpr: - while ((!preserveParen && (previousContext.Value.Cursor is ParenExpr)) || (!preserveImplicitCast && (previousContext.Value.Cursor is ImplicitCastExpr))) + case CX_StmtClass.CX_StmtClass_BinaryOperator: { - previousContext = previousContext.Previous; + var binaryOperator = (BinaryOperator)stmt; + return IsUnchecked(targetTypeName, binaryOperator.LHS) + || IsUnchecked(targetTypeName, binaryOperator.RHS) + || IsUnchecked(targetTypeName, binaryOperator.Handle.Evaluate) + || IsOverflow(binaryOperator); } - var value = previousContext.Value; + // case CX_StmtClass.CX_StmtClass_CompoundAssignOperator: + // case CX_StmtClass.CX_StmtClass_BlockExpr: + // case CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr: - if (value.Cursor is T t) + case CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr: { - cursor = t; - userData = value.UserData; - return true; + return false; } - else + + case CX_StmtClass.CX_StmtClass_CXXConstructExpr: { - cursor = null; - userData = null; return false; } - } - private static bool IsStmtAsWritten(Cursor cursor, out T value, bool removeParens = false) - where T : Stmt - { - if (cursor is Expr expr) + case CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr: { - cursor = GetExprAsWritten(expr, removeParens); + return false; } - if (cursor is T t) + case CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr: { - value = t; - return true; + return false; } - else + + case CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr: { - value = null; return false; } - } - private static bool IsStmtAsWritten(Stmt stmt, Stmt expectedStmt, bool removeParens = false) - { - if (stmt == expectedStmt) + // case CX_StmtClass.CX_StmtClass_CXXDeleteExpr: + + case CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr: { - return true; + return false; } - if (stmt is not Expr expr) + // case CX_StmtClass.CX_StmtClass_CXXFoldExpr: + // case CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr: + + case CX_StmtClass.CX_StmtClass_CXXNewExpr: { return false; } - expr = GetExprAsWritten(expr, removeParens); - return expr == expectedStmt; - } + // case CX_StmtClass.CX_StmtClass_CXXNoexceptExpr: - internal static bool IsSupportedFixedSizedBufferType(string typeName) - { - switch (typeName) + case CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr: { - case "bool": - case "byte": - case "char": - case "double": - case "float": - case "int": - case "long": - case "sbyte": - case "short": - case "ushort": - case "uint": - case "ulong": - { - return true; - } - - default: - { - return false; - } + return false; } - } - private static bool IsTransparentStructBoolean(PInvokeGeneratorTransparentStructKind kind) - { - return kind == PInvokeGeneratorTransparentStructKind.Boolean; - } + // case CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr: + // case CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator: + // case CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr: + // case CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr: - private static bool IsTransparentStructHandle(PInvokeGeneratorTransparentStructKind kind) - { - return kind is PInvokeGeneratorTransparentStructKind.Handle - or PInvokeGeneratorTransparentStructKind.HandleWin32; - } + case CX_StmtClass.CX_StmtClass_CXXThisExpr: + { + return false; + } - private static bool IsTransparentStructHexBased(PInvokeGeneratorTransparentStructKind kind) - { - return IsTransparentStructHandle(kind) - || (kind == PInvokeGeneratorTransparentStructKind.TypedefHex); - } + // case CX_StmtClass.CX_StmtClass_CXXThrowExpr: + // case CX_StmtClass.CX_StmtClass_CXXTypeidExpr: + // case CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr: - private bool IsUnchecked(string targetTypeName, Stmt stmt) - { - if (IsPrevContextDecl(out var parentVarDecl, out _)) + case CX_StmtClass.CX_StmtClass_CXXUuidofExpr: { - var cursorName = GetCursorName(parentVarDecl); - - if (cursorName.StartsWith("ClangSharpMacro_") && _config.WithTransparentStructs.TryGetValue(targetTypeName, out var transparentStruct)) - { - targetTypeName = transparentStruct.Name; - } + return false; } - switch (stmt.StmtClass) + case CX_StmtClass.CX_StmtClass_CallExpr: { - // case CX_StmtClass.CX_StmtClass_BinaryConditionalOperator: - - case CX_StmtClass.CX_StmtClass_ConditionalOperator: - { - var conditionalOperator = (ConditionalOperator)stmt; - return IsUnchecked(targetTypeName, conditionalOperator.LHS) - || IsUnchecked(targetTypeName, conditionalOperator.RHS) - || IsUnchecked(targetTypeName, conditionalOperator.Handle.Evaluate); - } - - // case CX_StmtClass.CX_StmtClass_AddrLabelExpr: - // case CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr: - // case CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr: - - case CX_StmtClass.CX_StmtClass_ArraySubscriptExpr: - { - var arraySubscriptExpr = (ArraySubscriptExpr)stmt; - return IsUnchecked(targetTypeName, arraySubscriptExpr.LHS) - || IsUnchecked(targetTypeName, arraySubscriptExpr.RHS); - } - - // case CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr: - // case CX_StmtClass.CX_StmtClass_AsTypeExpr: - // case CX_StmtClass.CX_StmtClass_AtomicExpr: - - case CX_StmtClass.CX_StmtClass_BinaryOperator: - { - var binaryOperator = (BinaryOperator)stmt; - return IsUnchecked(targetTypeName, binaryOperator.LHS) - || IsUnchecked(targetTypeName, binaryOperator.RHS) - || IsUnchecked(targetTypeName, binaryOperator.Handle.Evaluate) - || IsOverflow(binaryOperator); - } - - // case CX_StmtClass.CX_StmtClass_CompoundAssignOperator: - // case CX_StmtClass.CX_StmtClass_BlockExpr: - // case CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr: - - case CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr: - { - return false; - } - - case CX_StmtClass.CX_StmtClass_CXXConstructExpr: - { - return false; - } - - case CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr: - { - return false; - } - - case CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr: - { - return false; - } - - case CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr: - { - return false; - } - - // case CX_StmtClass.CX_StmtClass_CXXDeleteExpr: - - case CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr: - { - return false; - } - - // case CX_StmtClass.CX_StmtClass_CXXFoldExpr: - // case CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr: - - case CX_StmtClass.CX_StmtClass_CXXNewExpr: - { - return false; - } - - // case CX_StmtClass.CX_StmtClass_CXXNoexceptExpr: - - case CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr: - { - return false; - } - - // case CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr: - // case CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator: - // case CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr: - // case CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr: - - case CX_StmtClass.CX_StmtClass_CXXThisExpr: - { - return false; - } - - // case CX_StmtClass.CX_StmtClass_CXXThrowExpr: - // case CX_StmtClass.CX_StmtClass_CXXTypeidExpr: - // case CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr: - - case CX_StmtClass.CX_StmtClass_CXXUuidofExpr: - { - return false; - } + return false; + } - case CX_StmtClass.CX_StmtClass_CallExpr: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr: - // case CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr: + case CX_StmtClass.CX_StmtClass_CXXMemberCallExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_CXXMemberCallExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_UserDefinedLiteral: + // case CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr: - // case CX_StmtClass.CX_StmtClass_UserDefinedLiteral: - // case CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr: + case CX_StmtClass.CX_StmtClass_CStyleCastExpr: + case CX_StmtClass.CX_StmtClass_CXXStaticCastExpr: + case CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr: + { + var explicitCastExpr = (ExplicitCastExpr)stmt; + var explicitCastExprTypeName = GetRemappedTypeName(explicitCastExpr, context: null, explicitCastExpr.Type, out _); - case CX_StmtClass.CX_StmtClass_CStyleCastExpr: - case CX_StmtClass.CX_StmtClass_CXXStaticCastExpr: - case CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr: - { - var explicitCastExpr = (ExplicitCastExpr)stmt; - var explicitCastExprTypeName = GetRemappedTypeName(explicitCastExpr, context: null, explicitCastExpr.Type, out _); + return IsUnchecked(targetTypeName, explicitCastExpr.SubExprAsWritten) + || IsUnchecked(targetTypeName, explicitCastExpr.Handle.Evaluate) + || (IsUnsigned(targetTypeName) != IsUnsigned(explicitCastExprTypeName)); + } - return IsUnchecked(targetTypeName, explicitCastExpr.SubExprAsWritten) - || IsUnchecked(targetTypeName, explicitCastExpr.Handle.Evaluate) - || (IsUnsigned(targetTypeName) != IsUnsigned(explicitCastExprTypeName)); - } + // case CX_StmtClass.CX_StmtClass_CXXConstCastExpr: + // case CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr: - // case CX_StmtClass.CX_StmtClass_CXXConstCastExpr: - // case CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr: + case CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr: + { + var reinterpretCastExpr = (CXXReinterpretCastExpr)stmt; - case CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr: - { - var reinterpretCastExpr = (CXXReinterpretCastExpr)stmt; + return IsUnchecked(targetTypeName, reinterpretCastExpr.SubExprAsWritten) + || IsUnchecked(targetTypeName, reinterpretCastExpr.Handle.Evaluate); + } - return IsUnchecked(targetTypeName, reinterpretCastExpr.SubExprAsWritten) - || IsUnchecked(targetTypeName, reinterpretCastExpr.Handle.Evaluate); - } + // case CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr: - // case CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr: + case CX_StmtClass.CX_StmtClass_ImplicitCastExpr: + { + var implicitCastExpr = (ImplicitCastExpr)stmt; - case CX_StmtClass.CX_StmtClass_ImplicitCastExpr: - { - var implicitCastExpr = (ImplicitCastExpr)stmt; + return IsUnchecked(targetTypeName, implicitCastExpr.SubExprAsWritten) + || IsUnchecked(targetTypeName, implicitCastExpr.Handle.Evaluate); + } - return IsUnchecked(targetTypeName, implicitCastExpr.SubExprAsWritten) - || IsUnchecked(targetTypeName, implicitCastExpr.Handle.Evaluate); - } + case CX_StmtClass.CX_StmtClass_CharacterLiteral: + { + return false; + } - case CX_StmtClass.CX_StmtClass_CharacterLiteral: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_ChooseExpr: + // case CX_StmtClass.CX_StmtClass_CompoundLiteralExpr: + // case CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr: + // case CX_StmtClass.CX_StmtClass_ConvertVectorExpr: + // case CX_StmtClass.CX_StmtClass_CoawaitExpr: + // case CX_StmtClass.CX_StmtClass_CoyieldExpr: - // case CX_StmtClass.CX_StmtClass_ChooseExpr: - // case CX_StmtClass.CX_StmtClass_CompoundLiteralExpr: - // case CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr: - // case CX_StmtClass.CX_StmtClass_ConvertVectorExpr: - // case CX_StmtClass.CX_StmtClass_CoawaitExpr: - // case CX_StmtClass.CX_StmtClass_CoyieldExpr: + case CX_StmtClass.CX_StmtClass_DeclRefExpr: + { + var declRefExpr = (DeclRefExpr)stmt; + return (declRefExpr.Decl is VarDecl varDecl) && varDecl.HasInit && IsUnchecked(targetTypeName, varDecl.Init); + } - case CX_StmtClass.CX_StmtClass_DeclRefExpr: - { - var declRefExpr = (DeclRefExpr)stmt; - return (declRefExpr.Decl is VarDecl varDecl) && varDecl.HasInit && IsUnchecked(targetTypeName, varDecl.Init); - } + // case CX_StmtClass.CX_StmtClass_DependentCoawaitExpr: + // case CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr: + // case CX_StmtClass.CX_StmtClass_DesignatedInitExpr: + // case CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr: + // case CX_StmtClass.CX_StmtClass_ExpressionTraitExpr: + // case CX_StmtClass.CX_StmtClass_ExtVectorElementExpr: + // case CX_StmtClass.CX_StmtClass_FixedPointLiteral: - // case CX_StmtClass.CX_StmtClass_DependentCoawaitExpr: - // case CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr: - // case CX_StmtClass.CX_StmtClass_DesignatedInitExpr: - // case CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr: - // case CX_StmtClass.CX_StmtClass_ExpressionTraitExpr: - // case CX_StmtClass.CX_StmtClass_ExtVectorElementExpr: - // case CX_StmtClass.CX_StmtClass_FixedPointLiteral: + case CX_StmtClass.CX_StmtClass_FloatingLiteral: + { + return false; + } - case CX_StmtClass.CX_StmtClass_FloatingLiteral: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_ConstantExpr: - // case CX_StmtClass.CX_StmtClass_ConstantExpr: + case CX_StmtClass.CX_StmtClass_ExprWithCleanups: + { + var exprWithCleanups = (ExprWithCleanups)stmt; + return IsUnchecked(targetTypeName, exprWithCleanups.SubExpr); + } - case CX_StmtClass.CX_StmtClass_ExprWithCleanups: - { - var exprWithCleanups = (ExprWithCleanups)stmt; - return IsUnchecked(targetTypeName, exprWithCleanups.SubExpr); - } + // case CX_StmtClass.CX_StmtClass_FunctionParmPackExpr: + // case CX_StmtClass.CX_StmtClass_GNUNullExpr: + // case CX_StmtClass.CX_StmtClass_GenericSelectionExpr: + // case CX_StmtClass.CX_StmtClass_ImaginaryLiteral: + // case CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr: - // case CX_StmtClass.CX_StmtClass_FunctionParmPackExpr: - // case CX_StmtClass.CX_StmtClass_GNUNullExpr: - // case CX_StmtClass.CX_StmtClass_GenericSelectionExpr: - // case CX_StmtClass.CX_StmtClass_ImaginaryLiteral: - // case CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr: + case CX_StmtClass.CX_StmtClass_InitListExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_InitListExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_IntegerLiteral: + { + var integerLiteral = (IntegerLiteral)stmt; + var signedValue = integerLiteral.Value; + return IsUnchecked(targetTypeName, signedValue, integerLiteral.IsNegative, isHex: integerLiteral.ValueString.StartsWith("0x")); + } - case CX_StmtClass.CX_StmtClass_IntegerLiteral: - { - var integerLiteral = (IntegerLiteral)stmt; - var signedValue = integerLiteral.Value; - return IsUnchecked(targetTypeName, signedValue, integerLiteral.IsNegative, isHex: integerLiteral.ValueString.StartsWith("0x")); - } + case CX_StmtClass.CX_StmtClass_LambdaExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_LambdaExpr: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_MSPropertyRefExpr: + // case CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr: - // case CX_StmtClass.CX_StmtClass_MSPropertyRefExpr: - // case CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr: + case CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr: - { - return false; - } + case CX_StmtClass.CX_StmtClass_MemberExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_MemberExpr: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_NoInitExpr: + // case CX_StmtClass.CX_StmtClass_OMPArraySectionExpr: + // case CX_StmtClass.CX_StmtClass_ObjCArrayLiteral: + // case CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr: + // case CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr: + // case CX_StmtClass.CX_StmtClass_ObjCBoxedExpr: + // case CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral: + // case CX_StmtClass.CX_StmtClass_ObjCEncodeExpr: + // case CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr: + // case CX_StmtClass.CX_StmtClass_ObjCIsaExpr: + // case CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr: + // case CX_StmtClass.CX_StmtClass_ObjCMessageExpr: + // case CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr: + // case CX_StmtClass.CX_StmtClass_ObjCProtocolExpr: + // case CX_StmtClass.CX_StmtClass_ObjCSelectorExpr: + // case CX_StmtClass.CX_StmtClass_ObjCStringLiteral: + // case CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr: + + case CX_StmtClass.CX_StmtClass_OffsetOfExpr: + { + return false; + } - // case CX_StmtClass.CX_StmtClass_NoInitExpr: - // case CX_StmtClass.CX_StmtClass_OMPArraySectionExpr: - // case CX_StmtClass.CX_StmtClass_ObjCArrayLiteral: - // case CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr: - // case CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr: - // case CX_StmtClass.CX_StmtClass_ObjCBoxedExpr: - // case CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral: - // case CX_StmtClass.CX_StmtClass_ObjCEncodeExpr: - // case CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr: - // case CX_StmtClass.CX_StmtClass_ObjCIsaExpr: - // case CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr: - // case CX_StmtClass.CX_StmtClass_ObjCMessageExpr: - // case CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr: - // case CX_StmtClass.CX_StmtClass_ObjCProtocolExpr: - // case CX_StmtClass.CX_StmtClass_ObjCSelectorExpr: - // case CX_StmtClass.CX_StmtClass_ObjCStringLiteral: - // case CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr: - - case CX_StmtClass.CX_StmtClass_OffsetOfExpr: - { - return false; - } + // case CX_StmtClass.CX_StmtClass_OpaqueValueExpr: + // case CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr: + // case CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr: + // case CX_StmtClass.CX_StmtClass_PackExpansionExpr: - // case CX_StmtClass.CX_StmtClass_OpaqueValueExpr: - // case CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr: - // case CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr: - // case CX_StmtClass.CX_StmtClass_PackExpansionExpr: + case CX_StmtClass.CX_StmtClass_ParenExpr: + { + var parenExpr = (ParenExpr)stmt; + return IsUnchecked(targetTypeName, parenExpr.SubExpr) + || IsUnchecked(targetTypeName, parenExpr.Handle.Evaluate); + } - case CX_StmtClass.CX_StmtClass_ParenExpr: - { - var parenExpr = (ParenExpr)stmt; - return IsUnchecked(targetTypeName, parenExpr.SubExpr) - || IsUnchecked(targetTypeName, parenExpr.Handle.Evaluate); - } + case CX_StmtClass.CX_StmtClass_ParenListExpr: + { + var parenListExpr = (ParenListExpr)stmt; - case CX_StmtClass.CX_StmtClass_ParenListExpr: + foreach (var expr in parenListExpr.Exprs) { - var parenListExpr = (ParenListExpr)stmt; - - foreach (var expr in parenListExpr.Exprs) + if (IsUnchecked(targetTypeName, expr) || IsUnchecked(targetTypeName, expr.Handle.Evaluate)) { - if (IsUnchecked(targetTypeName, expr) || IsUnchecked(targetTypeName, expr.Handle.Evaluate)) - { - return true; - } + return true; } - - return false; } - // case CX_StmtClass.CX_StmtClass_PredefinedExpr: - // case CX_StmtClass.CX_StmtClass_PseudoObjectExpr: - // case CX_StmtClass.CX_StmtClass_RequiresExpr: - // case CX_StmtClass.CX_StmtClass_ShuffleVectorExpr: - // case CX_StmtClass.CX_StmtClass_SizeOfPackExpr: - // case CX_StmtClass.CX_StmtClass_SourceLocExpr: - // case CX_StmtClass.CX_StmtClass_StmtExpr: - - case CX_StmtClass.CX_StmtClass_StringLiteral: - { - return false; - } - - case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr: - { - return false; - } - - // case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr: - // case CX_StmtClass.CX_StmtClass_TypeTraitExpr: - // case CX_StmtClass.CX_StmtClass_TypoExpr: - - case CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr: - { - var unaryExprOrTypeTraitExpr = (UnaryExprOrTypeTraitExpr)stmt; - - var argumentType = unaryExprOrTypeTraitExpr.TypeOfArgument; - - long alignment32 = -1; - long alignment64 = -1; - - GetTypeSize(unaryExprOrTypeTraitExpr, argumentType, ref alignment32, ref alignment64, out var size32, out var size64); - - switch (unaryExprOrTypeTraitExpr.Kind) - { - case CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf: - { - switch (targetTypeName) - { - case "byte": - case "Byte": - case "ushort": - case "UInt16": - case "uint": - case "UInt32": - case "nuint": - case "sbyte": - case "SByte": - case "short": - case "Int16": - { - return (size32 != size64) || !IsPrevContextDecl(out _, out _); - } + return false; + } - case "ulong": - case "UInt64": - case "int": - case "Int32": - case "nint": - case "long": - case "Int64": - { - return false; - } + // case CX_StmtClass.CX_StmtClass_PredefinedExpr: + // case CX_StmtClass.CX_StmtClass_PseudoObjectExpr: + // case CX_StmtClass.CX_StmtClass_RequiresExpr: + // case CX_StmtClass.CX_StmtClass_ShuffleVectorExpr: + // case CX_StmtClass.CX_StmtClass_SizeOfPackExpr: + // case CX_StmtClass.CX_StmtClass_SourceLocExpr: + // case CX_StmtClass.CX_StmtClass_StmtExpr: - default: - { - return false; - } - } - } + case CX_StmtClass.CX_StmtClass_StringLiteral: + { + return false; + } - default: - { - return false; - } - } - } + case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr: + { + return false; + } - case CX_StmtClass.CX_StmtClass_UnaryOperator: - { - var unaryOperator = (UnaryOperator)stmt; + // case CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr: + // case CX_StmtClass.CX_StmtClass_TypeTraitExpr: + // case CX_StmtClass.CX_StmtClass_TypoExpr: - if (IsUnchecked(targetTypeName, unaryOperator.SubExpr)) - { - return true; - } + case CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr: + { + var unaryExprOrTypeTraitExpr = (UnaryExprOrTypeTraitExpr)stmt; - var evaluation = unaryOperator.Handle.Evaluate; + var argumentType = unaryExprOrTypeTraitExpr.TypeOfArgument; - if (IsUnchecked(targetTypeName, evaluation)) - { - return true; - } + long alignment32 = -1; + long alignment64 = -1; - var sourceTypeName = GetTypeName(stmt, context: null, unaryOperator.SubExpr.Type, ignoreTransparentStructsWhereRequired: false, out _); + GetTypeSize(unaryExprOrTypeTraitExpr, argumentType, ref alignment32, ref alignment64, out var size32, out var size64); - switch (unaryOperator.Opcode) + switch (unaryExprOrTypeTraitExpr.Kind) + { + case CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf: { - case CX_UnaryOperatorKind.CX_UO_Minus: + switch (targetTypeName) { - return IsUnsigned(targetTypeName); - } + case "byte": + case "Byte": + case "ushort": + case "UInt16": + case "uint": + case "UInt32": + case "nuint": + case "sbyte": + case "SByte": + case "short": + case "Int16": + { + return (size32 != size64) || !IsPrevContextDecl(out _, out _); + } - case CX_UnaryOperatorKind.CX_UO_Not: - { - return IsUnsigned(targetTypeName) != IsUnsigned(sourceTypeName); - } + case "ulong": + case "UInt64": + case "int": + case "Int32": + case "nint": + case "long": + case "Int64": + { + return false; + } - default: - { - return false; + default: + { + return false; + } } } - } - - // case CX_StmtClass.CX_StmtClass_VAArgExpr: - default: - { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported statement class: '{stmt.StmtClassName}'. Generated bindings may not be unchecked.", stmt); - return false; + default: + { + return false; + } } } - bool IsOverflow(BinaryOperator binaryOperator) + case CX_StmtClass.CX_StmtClass_UnaryOperator: { - var lhs = binaryOperator.LHS; - var rhs = binaryOperator.RHS; - - long lhsValue, rhsValue; + var unaryOperator = (UnaryOperator)stmt; - if (IsStmtAsWritten(lhs, out var lhsIntegerLiteral, removeParens: true)) + if (IsUnchecked(targetTypeName, unaryOperator.SubExpr)) { - lhsValue = lhsIntegerLiteral.Value; + return true; } - else - { - var lhsEvaluation = lhs.Handle.Evaluate; - if (lhsEvaluation.Kind == CXEvalResultKind.CXEval_Int) - { - lhsValue = lhsEvaluation.AsInt; - } - else - { - return false; - } - } + var evaluation = unaryOperator.Handle.Evaluate; - if (IsStmtAsWritten(rhs, out var rhsIntegerLiteral, removeParens: true)) + if (IsUnchecked(targetTypeName, evaluation)) { - rhsValue = rhsIntegerLiteral.Value; - } - else - { - var rhsEvaluation = rhs.Handle.Evaluate; - - if (rhsEvaluation.Kind == CXEvalResultKind.CXEval_Int) - { - rhsValue = rhsEvaluation.AsInt; - } - else - { - return false; - } + return true; } - var targetTypeName = GetRemappedTypeName(binaryOperator, context: null, binaryOperator.Type, out _, skipUsing: true); - var isUnsigned = IsUnsigned(targetTypeName); + var sourceTypeName = GetTypeName(stmt, context: null, unaryOperator.SubExpr.Type, ignoreTransparentStructsWhereRequired: false, out _); - switch (binaryOperator.Opcode) + switch (unaryOperator.Opcode) { - case CX_BinaryOperatorKind.CX_BO_Add: + case CX_UnaryOperatorKind.CX_UO_Minus: { - return isUnsigned - ? (ulong)lhsValue + (ulong)rhsValue < (ulong)lhsValue - : lhsValue + rhsValue < lhsValue; + return IsUnsigned(targetTypeName); } - case CX_BinaryOperatorKind.CX_BO_Sub: + case CX_UnaryOperatorKind.CX_UO_Not: { - return isUnsigned - ? (ulong)lhsValue - (ulong)rhsValue > (ulong)lhsValue - : lhsValue - rhsValue > lhsValue; + return IsUnsigned(targetTypeName) != IsUnsigned(sourceTypeName); } default: @@ -5096,75 +5018,76 @@ bool IsOverflow(BinaryOperator binaryOperator) } } } - } - private bool IsUnchecked(string typeName, CXEvalResult evalResult) - { - if (evalResult.Kind != CXEvalResultKind.CXEval_Int) + // case CX_StmtClass.CX_StmtClass_VAArgExpr: + + default: { + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported statement class: '{stmt.StmtClassName}'. Generated bindings may not be unchecked.", stmt); return false; } - - var signedValue = evalResult.AsLongLong; - return IsUnchecked(typeName, signedValue, signedValue < 0, isHex: false); } - private bool IsUnchecked(string typeName, long signedValue, bool isNegative, bool isHex) + bool IsOverflow(BinaryOperator binaryOperator) { - switch (typeName) + var lhs = binaryOperator.LHS; + var rhs = binaryOperator.RHS; + + long lhsValue, rhsValue; + + if (IsStmtAsWritten(lhs, out var lhsIntegerLiteral, removeParens: true)) { - case "byte": - case "Byte": - { - var unsignedValue = unchecked((ulong)signedValue); - return unsignedValue is < byte.MinValue or > byte.MaxValue; - } + lhsValue = lhsIntegerLiteral.Value; + } + else + { + var lhsEvaluation = lhs.Handle.Evaluate; - case "ushort": - case "UInt16": + if (lhsEvaluation.Kind == CXEvalResultKind.CXEval_Int) { - var unsignedValue = unchecked((ulong)signedValue); - return unsignedValue is < ushort.MinValue or > ushort.MaxValue; + lhsValue = lhsEvaluation.AsInt; } - - case "uint": - case "UInt32": - case "nuint": - case "UIntPtr": + else { return false; } + } - case "ulong": - case "UInt64": - { - return false; - } + if (IsStmtAsWritten(rhs, out var rhsIntegerLiteral, removeParens: true)) + { + rhsValue = rhsIntegerLiteral.Value; + } + else + { + var rhsEvaluation = rhs.Handle.Evaluate; - case "sbyte": - case "SByte": + if (rhsEvaluation.Kind == CXEvalResultKind.CXEval_Int) { - return (signedValue < sbyte.MinValue) || (sbyte.MaxValue < signedValue) || (isNegative && isHex); + rhsValue = rhsEvaluation.AsInt; } - - case "short": - case "Int16": + else { - return (signedValue < short.MinValue) || (short.MaxValue < signedValue) || (isNegative && isHex); + return false; } + } - case "int": - case "Int32": - case "nint": - case "IntPtr": + var targetTypeName = GetRemappedTypeName(binaryOperator, context: null, binaryOperator.Type, out _, skipUsing: true); + var isUnsigned = IsUnsigned(targetTypeName); + + switch (binaryOperator.Opcode) + { + case CX_BinaryOperatorKind.CX_BO_Add: { - return (signedValue < int.MinValue) || (int.MaxValue < signedValue) || (isNegative && isHex); + return isUnsigned + ? (ulong)lhsValue + (ulong)rhsValue < (ulong)lhsValue + : lhsValue + rhsValue < lhsValue; } - case "long": - case "Int64": + case CX_BinaryOperatorKind.CX_BO_Sub: { - return (signedValue < long.MinValue) || (long.MaxValue < signedValue) || (isNegative && isHex); + return isUnsigned + ? (ulong)lhsValue - (ulong)rhsValue > (ulong)lhsValue + : lhsValue - rhsValue > lhsValue; } default: @@ -5173,281 +5096,327 @@ private bool IsUnchecked(string typeName, long signedValue, bool isNegative, boo } } } + } - private bool IsUnsafe(FieldDecl fieldDecl) + private bool IsUnchecked(string typeName, CXEvalResult evalResult) + { + if (evalResult.Kind != CXEvalResultKind.CXEval_Int) { - var type = fieldDecl.Type; + return false; + } + + var signedValue = evalResult.AsLongLong; + return IsUnchecked(typeName, signedValue, signedValue < 0, isHex: false); + } - if (type.CanonicalType is ConstantArrayType or IncompleteArrayType) + private bool IsUnchecked(string typeName, long signedValue, bool isNegative, bool isHex) + { + switch (typeName) + { + case "byte": + case "Byte": { - var name = GetTypeName(fieldDecl, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + var unsignedValue = unchecked((ulong)signedValue); + return unsignedValue is < byte.MinValue or > byte.MaxValue; + } - if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) - { - remappedName = name; - } + case "ushort": + case "UInt16": + { + var unsignedValue = unchecked((ulong)signedValue); + return unsignedValue is < ushort.MinValue or > ushort.MaxValue; + } - return IsSupportedFixedSizedBufferType(remappedName); + case "uint": + case "UInt32": + case "nuint": + case "UIntPtr": + { + return false; } - return IsUnsafe(fieldDecl, type); - } + case "ulong": + case "UInt64": + { + return false; + } - private bool IsUnsafe(FunctionDecl functionDecl) - { - var name = GetRemappedCursorName(functionDecl); + case "sbyte": + case "SByte": + { + return (signedValue < sbyte.MinValue) || (sbyte.MaxValue < signedValue) || (isNegative && isHex); + } - if (_config.WithManualImports.Contains(name)) + case "short": + case "Int16": { - return true; + return (signedValue < short.MinValue) || (short.MaxValue < signedValue) || (isNegative && isHex); } - if (IsUnsafe(functionDecl, functionDecl.ReturnType)) + case "int": + case "Int32": + case "nint": + case "IntPtr": { - return true; + return (signedValue < int.MinValue) || (int.MaxValue < signedValue) || (isNegative && isHex); } - foreach (var parmVarDecl in functionDecl.Parameters) + case "long": + case "Int64": { - if (IsUnsafe(parmVarDecl)) - { - return true; - } + return (signedValue < long.MinValue) || (long.MaxValue < signedValue) || (isNegative && isHex); } - return false; + default: + { + return false; + } + } + } + + private bool IsUnsafe(FieldDecl fieldDecl) + { + var type = fieldDecl.Type; + + if (type.CanonicalType is ConstantArrayType or IncompleteArrayType) + { + var name = GetTypeName(fieldDecl, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + + if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) + { + remappedName = name; + } + + return IsSupportedFixedSizedBufferType(remappedName); + } + + return IsUnsafe(fieldDecl, type); + } + + private bool IsUnsafe(FunctionDecl functionDecl) + { + var name = GetRemappedCursorName(functionDecl); + + if (_config.WithManualImports.Contains(name)) + { + return true; } - private bool IsUnsafe(ParmVarDecl parmVarDecl) + if (IsUnsafe(functionDecl, functionDecl.ReturnType)) { - var type = parmVarDecl.Type; - return IsUnsafe(parmVarDecl, type); + return true; } - private bool IsUnsafe(RecordDecl recordDecl) + foreach (var parmVarDecl in functionDecl.Parameters) { - foreach (var decl in recordDecl.Decls) + if (IsUnsafe(parmVarDecl)) { - if ((decl is FieldDecl fieldDecl) && IsUnsafe(fieldDecl)) - { - return true; - } - else if ((decl is RecordDecl nestedRecordDecl) && nestedRecordDecl.IsAnonymousStructOrUnion && IsUnsafe(nestedRecordDecl)) - { - return true; - } + return true; } - return (recordDecl is CXXRecordDecl cxxRecordDecl) && (HasVtbl(cxxRecordDecl, out var hasBaseVtbl) || hasBaseVtbl || HasUnsafeMethod(cxxRecordDecl)); } - private bool IsUnsafe(TypedefDecl typedefDecl, FunctionProtoType functionProtoType) - { - var returnType = functionProtoType.ReturnType; + return false; + } - if (IsUnsafe(typedefDecl, returnType)) + private bool IsUnsafe(ParmVarDecl parmVarDecl) + { + var type = parmVarDecl.Type; + return IsUnsafe(parmVarDecl, type); + } + + private bool IsUnsafe(RecordDecl recordDecl) + { + foreach (var decl in recordDecl.Decls) + { + if ((decl is FieldDecl fieldDecl) && IsUnsafe(fieldDecl)) + { + return true; + } + else if ((decl is RecordDecl nestedRecordDecl) && nestedRecordDecl.IsAnonymousStructOrUnion && IsUnsafe(nestedRecordDecl)) { return true; } + } + return (recordDecl is CXXRecordDecl cxxRecordDecl) && (HasVtbl(cxxRecordDecl, out var hasBaseVtbl) || hasBaseVtbl || HasUnsafeMethod(cxxRecordDecl)); + } + + private bool IsUnsafe(TypedefDecl typedefDecl, FunctionProtoType functionProtoType) + { + var returnType = functionProtoType.ReturnType; + + if (IsUnsafe(typedefDecl, returnType)) + { + return true; + } - foreach (var paramType in functionProtoType.ParamTypes) + foreach (var paramType in functionProtoType.ParamTypes) + { + if (IsUnsafe(typedefDecl, paramType)) { - if (IsUnsafe(typedefDecl, paramType)) - { - return true; - } + return true; } + } - return false; + return false; + } + + private bool IsUnsafe(NamedDecl namedDecl, Type type) + { + var name = GetTypeName(namedDecl, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + + if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) + { + remappedName = name; } - private bool IsUnsafe(NamedDecl namedDecl, Type type) + return remappedName.Contains('*'); + } + + private static bool IsUnsigned(string typeName) + { + switch (typeName) { - var name = GetTypeName(namedDecl, context: null, type, ignoreTransparentStructsWhereRequired: false, out _); + case "byte": + case "Byte": + case "UInt16": + case "nuint": + case "uint": + case "UInt32": + case "ulong": + case "UInt64": + case "ushort": + case var _ when typeName.EndsWith("*"): + { + return true; + } - if (!_config.RemappedNames.TryGetValue(name, out var remappedName)) + case "Int16": + case "int": + case "Int32": + case "long": + case "Int64": + case "nint": + case "sbyte": + case "SByte": + case "short": { - remappedName = name; + return false; } - return remappedName.Contains('*'); + default: + { + return false; + } } + } + + private bool NeedsReturnFixup(CXXMethodDecl cxxMethodDecl) + { + Debug.Assert(cxxMethodDecl != null); - private static bool IsUnsigned(string typeName) + var needsReturnFixup = false; + + if (cxxMethodDecl.IsVirtual) { - switch (typeName) + var canonicalReturnType = cxxMethodDecl.ReturnType.CanonicalType; + + switch (canonicalReturnType.TypeClass) { - case "byte": - case "Byte": - case "UInt16": - case "nuint": - case "uint": - case "UInt32": - case "ulong": - case "UInt64": - case "ushort": - case var _ when typeName.EndsWith("*"): + case CX_TypeClass.CX_TypeClass_Builtin: + case CX_TypeClass.CX_TypeClass_Enum: + case CX_TypeClass.CX_TypeClass_Pointer: { - return true; + break; } - case "Int16": - case "int": - case "Int32": - case "long": - case "Int64": - case "nint": - case "sbyte": - case "SByte": - case "short": + case CX_TypeClass.CX_TypeClass_Record: { - return false; + needsReturnFixup = true; + break; } default: { - return false; + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported return type for abstract method: '{canonicalReturnType.TypeClass}'. Generated bindings may be incomplete.", cxxMethodDecl); + break; } } } - private bool NeedsReturnFixup(CXXMethodDecl cxxMethodDecl) - { - Debug.Assert(cxxMethodDecl != null); - - var needsReturnFixup = false; - - if (cxxMethodDecl.IsVirtual) - { - var canonicalReturnType = cxxMethodDecl.ReturnType.CanonicalType; - - switch (canonicalReturnType.TypeClass) - { - case CX_TypeClass.CX_TypeClass_Builtin: - case CX_TypeClass.CX_TypeClass_Enum: - case CX_TypeClass.CX_TypeClass_Pointer: - { - break; - } - - case CX_TypeClass.CX_TypeClass_Record: - { - needsReturnFixup = true; - break; - } - - default: - { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported return type for abstract method: '{canonicalReturnType.TypeClass}'. Generated bindings may be incomplete.", cxxMethodDecl); - break; - } - } - } + return needsReturnFixup; + } - return needsReturnFixup; - } + private static bool NeedsNewKeyword(string name) + { + return name.Equals("Equals") + || name.Equals("GetHashCode") + || name.Equals("GetType") + || name.Equals("MemberwiseClone") + || name.Equals("ReferenceEquals") + || name.Equals("ToString"); + } - private static bool NeedsNewKeyword(string name) - { - return name.Equals("Equals") - || name.Equals("GetHashCode") - || name.Equals("GetType") - || name.Equals("MemberwiseClone") - || name.Equals("ReferenceEquals") - || name.Equals("ToString"); - } + private static bool NeedsNewKeyword(string name, IReadOnlyList parmVarDecls) + { + return (name.Equals("GetHashCode") + || name.Equals("GetType") + || name.Equals("MemberwiseClone") + || name.Equals("ToString")) && parmVarDecls.Count == 0; + } - private static bool NeedsNewKeyword(string name, IReadOnlyList parmVarDecls) + private void ParenthesizeStmt(Stmt stmt) + { + if (IsStmtAsWritten(stmt, out _)) { - return (name.Equals("GetHashCode") - || name.Equals("GetType") - || name.Equals("MemberwiseClone") - || name.Equals("ToString")) && parmVarDecls.Count == 0; + Visit(stmt); } - - private void ParenthesizeStmt(Stmt stmt) + else { - if (IsStmtAsWritten(stmt, out _)) + if (_stmtOutputBuilderUsers > 0) { + _stmtOutputBuilder.Write('('); + _stmtOutputBuilder.BeginMarker("value"); Visit(stmt); + _stmtOutputBuilder.EndMarker("value"); + _stmtOutputBuilder.Write(')'); } else { - if (_stmtOutputBuilderUsers > 0) - { - _stmtOutputBuilder.Write('('); - _stmtOutputBuilder.BeginMarker("value"); - Visit(stmt); - _stmtOutputBuilder.EndMarker("value"); - _stmtOutputBuilder.Write(')'); - } - else - { - _outputBuilder.BeginInnerValue(); - Visit(stmt); - _outputBuilder.EndInnerValue(); - } + _outputBuilder.BeginInnerValue(); + Visit(stmt); + _outputBuilder.EndInnerValue(); } } + } - private string PrefixAndStripName(string name, uint overloadIndex) + private string PrefixAndStripName(string name, uint overloadIndex) + { + if (name.StartsWith(_config.MethodPrefixToStrip)) { - if (name.StartsWith(_config.MethodPrefixToStrip)) - { - name = name[_config.MethodPrefixToStrip.Length..]; - } - - return $"_{name}{((overloadIndex != 0) ? overloadIndex.ToString() : "")}"; + name = name[_config.MethodPrefixToStrip.Length..]; } - private void StartUsingOutputBuilder(string name, bool includeTestOutput = false) - { - var nameTests = $"{name}Tests"; - - // Set the current namespace so subsequent type lookups add the right using - _currentNamespace = GetNamespace(name); - _currentClass = name; - - if (_outputBuilder != null) - { - Debug.Assert(_outputBuilderUsers >= 1); - _outputBuilderUsers++; + return $"_{name}{((overloadIndex != 0) ? overloadIndex.ToString() : "")}"; + } - _outputBuilder.WriteDivider(); + private void StartUsingOutputBuilder(string name, bool includeTestOutput = false) + { + var nameTests = $"{name}Tests"; - if (includeTestOutput && !string.IsNullOrWhiteSpace(_config.TestOutputLocation)) - { - if (_testOutputBuilder is null) - { - if (!_outputBuilderFactory.TryGetOutputBuilder(nameTests, out var testOutputBuilder)) - { - CreateTestOutputBuilder(name, nameTests); - } - else - { - _testOutputBuilder = (CSharpOutputBuilder)testOutputBuilder; - } - } - _testOutputBuilder.NeedsNewline = true; - } - return; - } + // Set the current namespace so subsequent type lookups add the right using + _currentNamespace = GetNamespace(name); + _currentClass = name; - Debug.Assert(_outputBuilderUsers == 0); + if (_outputBuilder != null) + { + Debug.Assert(_outputBuilderUsers >= 1); + _outputBuilderUsers++; - if (!_outputBuilderFactory.TryGetOutputBuilder(name, out _outputBuilder)) - { - _outputBuilder = _outputBuilderFactory.Create(name); + _outputBuilder.WriteDivider(); - if (includeTestOutput && !string.IsNullOrWhiteSpace(_config.TestOutputLocation)) - { - CreateTestOutputBuilder(name, nameTests); - } - } - else + if (includeTestOutput && !string.IsNullOrWhiteSpace(_config.TestOutputLocation)) { - _outputBuilder.WriteDivider(); - - if (includeTestOutput && !string.IsNullOrWhiteSpace(_config.TestOutputLocation)) + if (_testOutputBuilder is null) { if (!_outputBuilderFactory.TryGetOutputBuilder(nameTests, out var testOutputBuilder)) { @@ -5457,751 +5426,781 @@ private void StartUsingOutputBuilder(string name, bool includeTestOutput = false { _testOutputBuilder = (CSharpOutputBuilder)testOutputBuilder; } - - Debug.Assert(_testOutputBuilder.IsTestOutput); - _testOutputBuilder.NeedsNewline = true; } + _testOutputBuilder.NeedsNewline = true; } - _outputBuilderUsers++; + return; + } - void CreateTestOutputBuilder(string name, string nameTests) - { - _testOutputBuilder = _outputBuilderFactory.CreateTests(nameTests); + Debug.Assert(_outputBuilderUsers == 0); - var isTopLevelStruct = _config.WithTypes.TryGetValue(name, out var withType) && (withType == "struct"); + if (!_outputBuilderFactory.TryGetOutputBuilder(name, out _outputBuilder)) + { + _outputBuilder = _outputBuilderFactory.Create(name); - if (!_topLevelClassNames.Contains(name) || isTopLevelStruct) - { - _testOutputBuilder.AddUsingDirective("System.Runtime.InteropServices"); - } + if (includeTestOutput && !string.IsNullOrWhiteSpace(_config.TestOutputLocation)) + { + CreateTestOutputBuilder(name, nameTests); + } + } + else + { + _outputBuilder.WriteDivider(); - if (_config.GenerateTestsNUnit) + if (includeTestOutput && !string.IsNullOrWhiteSpace(_config.TestOutputLocation)) + { + if (!_outputBuilderFactory.TryGetOutputBuilder(nameTests, out var testOutputBuilder)) { - _testOutputBuilder.AddUsingDirective("NUnit.Framework"); + CreateTestOutputBuilder(name, nameTests); } - else if (_config.GenerateTestsXUnit) + else { - _testOutputBuilder.AddUsingDirective("Xunit"); + _testOutputBuilder = (CSharpOutputBuilder)testOutputBuilder; } - } - } - private void StopUsingOutputBuilder() - { - if (_outputBuilderUsers == 1) - { - _currentClass = null; - _currentNamespace = null; - _outputBuilder = null; - _testOutputBuilder = null; + Debug.Assert(_testOutputBuilder.IsTestOutput); + _testOutputBuilder.NeedsNewline = true; } - _outputBuilderUsers--; } + _outputBuilderUsers++; - private bool TryGetUuid(RecordDecl recordDecl, out Guid uuid) + void CreateTestOutputBuilder(string name, string nameTests) { - if (TryGetRemappedValue(recordDecl, _config.WithGuids, out var guid)) + _testOutputBuilder = _outputBuilderFactory.CreateTests(nameTests); + + var isTopLevelStruct = _config.WithTypes.TryGetValue(name, out var withType) && (withType == "struct"); + + if (!_topLevelClassNames.Contains(name) || isTopLevelStruct) { - uuid = guid; - return true; + _testOutputBuilder.AddUsingDirective("System.Runtime.InteropServices"); } - var uuidAttrs = recordDecl.Attrs.Where((attr) => attr.Kind == CX_AttrKind.CX_AttrKind_Uuid); - - if (!uuidAttrs.Any()) + if (_config.GenerateTestsNUnit) { - uuid = Guid.Empty; - return false; + _testOutputBuilder.AddUsingDirective("NUnit.Framework"); } - else if (uuidAttrs.Count() != 1) + else if (_config.GenerateTestsXUnit) { - AddDiagnostic(DiagnosticLevel.Warning, $"Multiply uuid attributes for {recordDecl.Name}. Falling back to first attribute.", recordDecl); + _testOutputBuilder.AddUsingDirective("Xunit"); } + } + } - var uuidAttr = uuidAttrs.First(); - var uuidAttrText = GetSourceRangeContents(recordDecl.TranslationUnit.Handle, uuidAttr.Extent); - var uuidText = uuidAttrText.Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries)[1]; + private void StopUsingOutputBuilder() + { + if (_outputBuilderUsers == 1) + { + _currentClass = null; + _currentNamespace = null; + _outputBuilder = null; + _testOutputBuilder = null; + } + _outputBuilderUsers--; + } - if (!Guid.TryParse(uuidText, out uuid)) - { - AddDiagnostic(DiagnosticLevel.Warning, $"Failed to parse uuid attr text '{uuidAttrText}'. Extracted portion: '{uuidText}'.", recordDecl); - return false; - } + private bool TryGetUuid(RecordDecl recordDecl, out Guid uuid) + { + if (TryGetRemappedValue(recordDecl, _config.WithGuids, out var guid)) + { + uuid = guid; return true; } - private bool TryRemapOperatorName(ref string name, FunctionDecl functionDecl) + var uuidAttrs = recordDecl.Attrs.Where((attr) => attr.Kind == CX_AttrKind.CX_AttrKind_Uuid); + + if (!uuidAttrs.Any()) + { + uuid = Guid.Empty; + return false; + } + else if (uuidAttrs.Count() != 1) + { + AddDiagnostic(DiagnosticLevel.Warning, $"Multiply uuid attributes for {recordDecl.Name}. Falling back to first attribute.", recordDecl); + } + + var uuidAttr = uuidAttrs.First(); + var uuidAttrText = GetSourceRangeContents(recordDecl.TranslationUnit.Handle, uuidAttr.Extent); + var uuidText = uuidAttrText.Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries)[1]; + + if (!Guid.TryParse(uuidText, out uuid)) + { + AddDiagnostic(DiagnosticLevel.Warning, $"Failed to parse uuid attr text '{uuidAttrText}'. Extracted portion: '{uuidText}'.", recordDecl); + return false; + } + return true; + } + + private bool TryRemapOperatorName(ref string name, FunctionDecl functionDecl) + { + var numArgs = functionDecl.Parameters.Count; + + if (functionDecl.IsInstance) + { + numArgs++; + } + + if (functionDecl is CXXConversionDecl) { - var numArgs = functionDecl.Parameters.Count; + var returnType = functionDecl.ReturnType; + var returnTypeName = GetRemappedTypeName(cursor: null, context: null, returnType, out _, skipUsing: true); + + name = $"To{returnTypeName}"; + return true; + } - if (functionDecl.IsInstance) + switch (name) + { + case "operator+": { - numArgs++; + name = (numArgs == 1) ? "Plus" : "Add"; + return true; } - if (functionDecl is CXXConversionDecl) + case "operator-": { - var returnType = functionDecl.ReturnType; - var returnTypeName = GetRemappedTypeName(cursor: null, context: null, returnType, out _, skipUsing: true); - - name = $"To{returnTypeName}"; + name = (numArgs == 1) ? "Negate" : "Subtract"; return true; } - switch (name) + case "operator!": { - case "operator+": - { - name = (numArgs == 1) ? "Plus" : "Add"; - return true; - } - - case "operator-": - { - name = (numArgs == 1) ? "Negate" : "Subtract"; - return true; - } - - case "operator!": - { - name = "Not"; - return true; - } + name = "Not"; + return true; + } - case "operator~": - { - name = "OnesComplement"; - return true; - } + case "operator~": + { + name = "OnesComplement"; + return true; + } - case "operator++": - { - name = "Increment"; - return true; - } + case "operator++": + { + name = "Increment"; + return true; + } - case "operator--": - { - name = "Decrement"; - return true; - } + case "operator--": + { + name = "Decrement"; + return true; + } - case "operator*": - { - name = "Multiply"; - return true; - } + case "operator*": + { + name = "Multiply"; + return true; + } - case "operator/": - { - name = "Divide"; - return true; - } + case "operator/": + { + name = "Divide"; + return true; + } - case "operator%": - { - name = "Modulus"; - return true; - } + case "operator%": + { + name = "Modulus"; + return true; + } - case "operator&": - { - name = "And"; - return true; - } + case "operator&": + { + name = "And"; + return true; + } - case "operator|": - { - name = "Or"; - return true; - } + case "operator|": + { + name = "Or"; + return true; + } - case "operator^": - { - name = "Xor"; - return true; - } + case "operator^": + { + name = "Xor"; + return true; + } - case "operator<<": - { - name = "LeftShift"; - return true; - } + case "operator<<": + { + name = "LeftShift"; + return true; + } - case "operator>>": - { - name = "RightShift"; - return true; - } + case "operator>>": + { + name = "RightShift"; + return true; + } - case "operator==": - { - name = "Equals"; - return true; - } + case "operator==": + { + name = "Equals"; + return true; + } - case "operator!=": - { - name = "NotEquals"; - return true; - } + case "operator!=": + { + name = "NotEquals"; + return true; + } - case "operator<": - { - name = "LessThan"; - return true; - } + case "operator<": + { + name = "LessThan"; + return true; + } - case "operator>": - { - name = "GreaterThan"; - return true; - } + case "operator>": + { + name = "GreaterThan"; + return true; + } - case "operator<=": - { - name = "LessThanOrEquals"; - return true; - } + case "operator<=": + { + name = "LessThanOrEquals"; + return true; + } - case "operator>=": - { - name = "GreaterThanOrEquals"; - return true; - } + case "operator>=": + { + name = "GreaterThanOrEquals"; + return true; + } - default: - { - return false; - } + default: + { + return false; } } + } - private void UncheckStmt(string targetTypeName, Stmt stmt) + private void UncheckStmt(string targetTypeName, Stmt stmt) + { + if (!_outputBuilder.IsUncheckedContext && IsUnchecked(targetTypeName, stmt)) { - if (!_outputBuilder.IsUncheckedContext && IsUnchecked(targetTypeName, stmt)) - { - _outputBuilder.BeginUnchecked(); + _outputBuilder.BeginUnchecked(); - var needsCast = IsStmtAsWritten(stmt, out _, removeParens: true) && (stmt.DeclContext is EnumDecl); + var needsCast = IsStmtAsWritten(stmt, out _, removeParens: true) && (stmt.DeclContext is EnumDecl); - if (IsStmtAsWritten(stmt, out var unaryExprOrTypeTraitExpr, removeParens: true) && ((CurrentContext.Cursor is VarDecl) || IsPrevContextDecl(out _, out _))) - { - var argumentType = unaryExprOrTypeTraitExpr.TypeOfArgument; + if (IsStmtAsWritten(stmt, out var unaryExprOrTypeTraitExpr, removeParens: true) && ((CurrentContext.Cursor is VarDecl) || IsPrevContextDecl(out _, out _))) + { + var argumentType = unaryExprOrTypeTraitExpr.TypeOfArgument; - long alignment32 = -1; - long alignment64 = -1; + long alignment32 = -1; + long alignment64 = -1; - GetTypeSize(unaryExprOrTypeTraitExpr, argumentType, ref alignment32, ref alignment64, out var size32, out var size64); + GetTypeSize(unaryExprOrTypeTraitExpr, argumentType, ref alignment32, ref alignment64, out var size32, out var size64); - switch (unaryExprOrTypeTraitExpr.Kind) + switch (unaryExprOrTypeTraitExpr.Kind) + { + case CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf: { - case CX_UnaryExprOrTypeTrait.CX_UETT_SizeOf: - { - needsCast |= size32 != size64; - break; - } - - case CX_UnaryExprOrTypeTrait.CX_UETT_AlignOf: - case CX_UnaryExprOrTypeTrait.CX_UETT_PreferredAlignOf: - { - needsCast |= alignment32 != alignment64; - break; - } + needsCast |= size32 != size64; + break; + } - default: - { - break; - } + case CX_UnaryExprOrTypeTrait.CX_UETT_AlignOf: + case CX_UnaryExprOrTypeTrait.CX_UETT_PreferredAlignOf: + { + needsCast |= alignment32 != alignment64; + break; } - } - if (needsCast) - { - _outputBuilder.BeginInnerValue(); - _outputBuilder.BeginInnerCast(); - _outputBuilder.WriteCastType(targetTypeName); - _outputBuilder.EndInnerCast(); + default: + { + break; + } } + } - ParenthesizeStmt(stmt); + if (needsCast) + { + _outputBuilder.BeginInnerValue(); + _outputBuilder.BeginInnerCast(); + _outputBuilder.WriteCastType(targetTypeName); + _outputBuilder.EndInnerCast(); + } - if (needsCast) - { - _outputBuilder.EndInnerValue(); - } + ParenthesizeStmt(stmt); - _outputBuilder.EndUnchecked(); - } - else + if (needsCast) { - VisitStmt(stmt); + _outputBuilder.EndInnerValue(); } + + _outputBuilder.EndUnchecked(); + } + else + { + VisitStmt(stmt); } + } - private void Visit(Cursor cursor) + private void Visit(Cursor cursor) + { + var currentContext = _context.AddLast((cursor, null)); + var currentStmtUsers = _stmtOutputBuilder is not null ? (int?)_stmtOutputBuilderUsers : null; + + if (cursor is Attr attr) + { + VisitAttr(attr); + } + else if (cursor is Decl decl) { - var currentContext = _context.AddLast((cursor, null)); - var currentStmtUsers = _stmtOutputBuilder is not null ? (int?)_stmtOutputBuilderUsers : null; + VisitDecl(decl); + } + else if (cursor is Ref @ref) + { + VisitRef(@ref); + } + else if (cursor is Stmt stmt) + { + var targetTypeName = GetTargetTypeName(PreviousContext.Cursor, out _); - if (cursor is Attr attr) - { - VisitAttr(attr); - } - else if (cursor is Decl decl) - { - VisitDecl(decl); - } - else if (cursor is Ref @ref) + if (targetTypeName != "") { - VisitRef(@ref); - } - else if (cursor is Stmt stmt) - { - var targetTypeName = GetTargetTypeName(PreviousContext.Cursor, out _); - - if (targetTypeName != "") - { - UncheckStmt(targetTypeName, stmt); - } - else - { - VisitStmt(stmt); - } + UncheckStmt(targetTypeName, stmt); } else { - AddDiagnostic(DiagnosticLevel.Error, $"Unsupported cursor: '{cursor.CursorKindSpelling}'. Generated bindings may be incomplete.", cursor); + VisitStmt(stmt); } - - Debug.Assert(currentStmtUsers == (_stmtOutputBuilder is not null ? (int?)_stmtOutputBuilderUsers : null)); - Debug.Assert(_context.Last == currentContext); - _context.RemoveLast(); } - - private void Visit(IEnumerable cursors) + else { - foreach (var cursor in cursors) - { - Visit(cursor); - } + AddDiagnostic(DiagnosticLevel.Error, $"Unsupported cursor: '{cursor.CursorKindSpelling}'. Generated bindings may be incomplete.", cursor); } - private void Visit(IEnumerable cursors, IEnumerable excludedCursors) => Visit(cursors.Except(excludedCursors)); + Debug.Assert(currentStmtUsers == (_stmtOutputBuilder is not null ? (int?)_stmtOutputBuilderUsers : null)); + Debug.Assert(_context.Last == currentContext); + _context.RemoveLast(); + } - private void WithAttributes(NamedDecl namedDecl, bool onlySupportedOSPlatform = false, bool isTestOutput = false) + private void Visit(IEnumerable cursors) + { + foreach (var cursor in cursors) { - var outputBuilder = isTestOutput ? _testOutputBuilder : _outputBuilder; + Visit(cursor); + } + } - if (TryGetRemappedValue(namedDecl, _config.WithAttributes, out var attributes)) - { - foreach (var attribute in attributes.Where((a) => !onlySupportedOSPlatform || a.StartsWith("SupportedOSPlatform("))) - { - outputBuilder.WriteCustomAttribute(attribute); - } + private void Visit(IEnumerable cursors, IEnumerable excludedCursors) => Visit(cursors.Except(excludedCursors)); + + private void WithAttributes(NamedDecl namedDecl, bool onlySupportedOSPlatform = false, bool isTestOutput = false) + { + var outputBuilder = isTestOutput ? _testOutputBuilder : _outputBuilder; + + if (TryGetRemappedValue(namedDecl, _config.WithAttributes, out var attributes)) + { + foreach (var attribute in attributes.Where((a) => !onlySupportedOSPlatform || a.StartsWith("SupportedOSPlatform("))) + { + outputBuilder.WriteCustomAttribute(attribute); } + } - if (!isTestOutput && namedDecl.HasAttrs) + if (!isTestOutput && namedDecl.HasAttrs) + { + foreach (var attr in namedDecl.Attrs) { - foreach (var attr in namedDecl.Attrs) + switch (attr.Kind) { - switch (attr.Kind) + case CX_AttrKind.CX_AttrKind_Aligned: + case CX_AttrKind.CX_AttrKind_AlwaysInline: + case CX_AttrKind.CX_AttrKind_DLLExport: + case CX_AttrKind.CX_AttrKind_DLLImport: { - case CX_AttrKind.CX_AttrKind_Aligned: - case CX_AttrKind.CX_AttrKind_AlwaysInline: - case CX_AttrKind.CX_AttrKind_DLLExport: - case CX_AttrKind.CX_AttrKind_DLLImport: - { - // Nothing to handle - break; - } - - case CX_AttrKind.CX_AttrKind_Deprecated: - { - var attrText = GetSourceRangeContents(namedDecl.TranslationUnit.Handle, attr.Extent); + // Nothing to handle + break; + } - var textStart = attrText.IndexOf('"'); - var textLength = attrText.LastIndexOf('"') - textStart; + case CX_AttrKind.CX_AttrKind_Deprecated: + { + var attrText = GetSourceRangeContents(namedDecl.TranslationUnit.Handle, attr.Extent); - if (textLength > 2) - { - var text = attrText.AsSpan(textStart + 1, textLength - 2); - outputBuilder.WriteCustomAttribute($"Obsolete(\"{text}\")"); - } - else - { - outputBuilder.WriteCustomAttribute($"Obsolete"); - } - break; - } + var textStart = attrText.IndexOf('"'); + var textLength = attrText.LastIndexOf('"') - textStart; - case CX_AttrKind.CX_AttrKind_MSNoVTable: - case CX_AttrKind.CX_AttrKind_MSAllocator: - case CX_AttrKind.CX_AttrKind_MaxFieldAlignment: - case CX_AttrKind.CX_AttrKind_SelectAny: - case CX_AttrKind.CX_AttrKind_Uuid: + if (textLength > 2) { - // Nothing to handle - break; + var text = attrText.AsSpan(textStart + 1, textLength - 2); + outputBuilder.WriteCustomAttribute($"Obsolete(\"{text}\")"); } - - default: + else { - AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported attribute: '{attr.KindSpelling}'. Generated bindings may be incomplete.", namedDecl); - break; + outputBuilder.WriteCustomAttribute($"Obsolete"); } + break; + } + + case CX_AttrKind.CX_AttrKind_MSNoVTable: + case CX_AttrKind.CX_AttrKind_MSAllocator: + case CX_AttrKind.CX_AttrKind_MaxFieldAlignment: + case CX_AttrKind.CX_AttrKind_SelectAny: + case CX_AttrKind.CX_AttrKind_Uuid: + { + // Nothing to handle + break; + } + + default: + { + AddDiagnostic(DiagnosticLevel.Warning, $"Unsupported attribute: '{attr.KindSpelling}'. Generated bindings may be incomplete.", namedDecl); + break; } } } } + } + + private string GetLibraryPath(string remappedName) + { + return !_config.WithLibraryPaths.TryGetValue(remappedName, out var libraryPath) && !_config.WithLibraryPaths.TryGetValue("*", out libraryPath) + ? _config.LibraryPath + : libraryPath; + } + + private string GetClass(string remappedName, bool disallowPrefixMatch = false) + { + if (!TryGetClass(remappedName, out var className, disallowPrefixMatch)) + { + className = _config.DefaultClass; + _ = _topLevelClassNames.Add(className); + _ = _topLevelClassNames.Add($"{className}Tests"); + } + return className; + } + + private bool TryGetClass(string remappedName, out string className, bool disallowPrefixMatch = false) + { + var index = remappedName.IndexOf('*'); - private string GetLibraryPath(string remappedName) + if (index != -1) { - return !_config.WithLibraryPaths.TryGetValue(remappedName, out var libraryPath) && !_config.WithLibraryPaths.TryGetValue("*", out libraryPath) - ? _config.LibraryPath - : libraryPath; + remappedName = remappedName[..index]; } - private string GetClass(string remappedName, bool disallowPrefixMatch = false) + if (_config.WithClasses.TryGetValue(remappedName, out className)) { - if (!TryGetClass(remappedName, out var className, disallowPrefixMatch)) - { - className = _config.DefaultClass; - _ = _topLevelClassNames.Add(className); - _ = _topLevelClassNames.Add($"{className}Tests"); - } - return className; + _ = _topLevelClassNames.Add(className); + _ = _topLevelClassNames.Add($"{className}Tests"); + return true; } - private bool TryGetClass(string remappedName, out string className, bool disallowPrefixMatch = false) + if (disallowPrefixMatch) { - var index = remappedName.IndexOf('*'); + return false; + } - if (index != -1) + foreach (var withClass in _config.WithClasses) + { + if (!withClass.Key.EndsWith("*")) { - remappedName = remappedName[..index]; + continue; } - if (_config.WithClasses.TryGetValue(remappedName, out className)) + var prefix = withClass.Key[0..^1]; + + if (remappedName.StartsWith(prefix)) { + className = withClass.Value; _ = _topLevelClassNames.Add(className); _ = _topLevelClassNames.Add($"{className}Tests"); return true; } + } + return false; + } - if (disallowPrefixMatch) + private string GetNamespace(string remappedName, NamedDecl namedDecl = null) + { + if (!TryGetNamespace(remappedName, out var namespaceName)) + { + if ((namedDecl is not null) && (namedDecl.Parent is TypeDecl parentTypeDecl)) { - return false; + var parentName = GetRemappedCursorName(parentTypeDecl); + namespaceName = $"{GetNamespace(parentName, parentTypeDecl)}.{parentName}"; } - - foreach (var withClass in _config.WithClasses) + else if (s_needsSystemSupportRegex.IsMatch(remappedName)) { - if (!withClass.Key.EndsWith("*")) - { - continue; - } - - var prefix = withClass.Key[0..^1]; - - if (remappedName.StartsWith(prefix)) - { - className = withClass.Value; - _ = _topLevelClassNames.Add(className); - _ = _topLevelClassNames.Add($"{className}Tests"); - return true; - } + namespaceName = "System"; } - return false; - } - - private string GetNamespace(string remappedName, NamedDecl namedDecl = null) - { - if (!TryGetNamespace(remappedName, out var namespaceName)) + else { - if ((namedDecl is not null) && (namedDecl.Parent is TypeDecl parentTypeDecl)) - { - var parentName = GetRemappedCursorName(parentTypeDecl); - namespaceName = $"{GetNamespace(parentName, parentTypeDecl)}.{parentName}"; - } - else if (s_needsSystemSupportRegex.IsMatch(remappedName)) - { - namespaceName = "System"; - } - else - { - namespaceName = _config.DefaultNamespace; - } + namespaceName = _config.DefaultNamespace; } - return namespaceName; } + return namespaceName; + } + + private bool TryGetNamespace(string remappedName, out string namespaceName) + { + var index = remappedName.IndexOf('*'); - private bool TryGetNamespace(string remappedName, out string namespaceName) + if (index != -1) { - var index = remappedName.IndexOf('*'); + remappedName = remappedName[..index]; + } - if (index != -1) - { - remappedName = remappedName[..index]; - } + return _config.WithNamespaces.TryGetValue(remappedName, out namespaceName); + } - return _config.WithNamespaces.TryGetValue(remappedName, out namespaceName); - } + private bool GetSetLastError(NamedDecl namedDecl) => HasRemapping(namedDecl, _config.WithSetLastErrors, matchStar: true); - private bool GetSetLastError(NamedDecl namedDecl) => HasRemapping(namedDecl, _config.WithSetLastErrors, matchStar: true); + private bool HasRemapping(NamedDecl namedDecl, IReadOnlyCollection entries, bool matchStar = false) + { + var name = GetCursorQualifiedName(namedDecl); - private bool HasRemapping(NamedDecl namedDecl, IReadOnlyCollection entries, bool matchStar = false) + if (name.StartsWith("ClangSharpMacro_")) { - var name = GetCursorQualifiedName(namedDecl); + name = name["ClangSharpMacro_".Length..]; + } - if (name.StartsWith("ClangSharpMacro_")) - { - name = name["ClangSharpMacro_".Length..]; - } + if (entries.Contains(name)) + { + return true; + } - if (entries.Contains(name)) - { - return true; - } + name = name.Replace("::", "."); - name = name.Replace("::", "."); + if (entries.Contains(name)) + { + return true; + } - if (entries.Contains(name)) - { - return true; - } + name = GetCursorQualifiedName(namedDecl, truncateParameters: true); - name = GetCursorQualifiedName(namedDecl, truncateParameters: true); + if (name.StartsWith("ClangSharpMacro_")) + { + name = name["ClangSharpMacro_".Length..]; + } - if (name.StartsWith("ClangSharpMacro_")) - { - name = name["ClangSharpMacro_".Length..]; - } + if (entries.Contains(name)) + { + return true; + } - if (entries.Contains(name)) - { - return true; - } + name = name.Replace("::", "."); - name = name.Replace("::", "."); + if (entries.Contains(name)) + { + return true; + } - if (entries.Contains(name)) - { - return true; - } + name = GetRemappedCursorName(namedDecl); - name = GetRemappedCursorName(namedDecl); + if (name.StartsWith("ClangSharpMacro_")) + { + name = name["ClangSharpMacro_".Length..]; + } - if (name.StartsWith("ClangSharpMacro_")) - { - name = name["ClangSharpMacro_".Length..]; - } + if (entries.Contains(name)) + { + return true; + } - if (entries.Contains(name)) - { - return true; - } + if (matchStar && entries.Contains("*")) + { + return true; + } - if (matchStar && entries.Contains("*")) - { - return true; - } + return false; + } - return false; + private bool TryGetRemappedValue(NamedDecl namedDecl, IReadOnlyDictionary remappings, out T value, bool matchStar = false) + { + var name = GetCursorQualifiedName(namedDecl); + + if (name.StartsWith("ClangSharpMacro_")) + { + name = name["ClangSharpMacro_".Length..]; } - private bool TryGetRemappedValue(NamedDecl namedDecl, IReadOnlyDictionary remappings, out T value, bool matchStar = false) + if (remappings.TryGetValue(name, out value)) { - var name = GetCursorQualifiedName(namedDecl); + return true; + } - if (name.StartsWith("ClangSharpMacro_")) - { - name = name["ClangSharpMacro_".Length..]; - } + name = name.Replace("::", "."); - if (remappings.TryGetValue(name, out value)) - { - return true; - } + if (remappings.TryGetValue(name, out value)) + { + return true; + } - name = name.Replace("::", "."); + name = GetCursorQualifiedName(namedDecl, truncateParameters: true); - if (remappings.TryGetValue(name, out value)) - { - return true; - } + if (name.StartsWith("ClangSharpMacro_")) + { + name = name["ClangSharpMacro_".Length..]; + } - name = GetCursorQualifiedName(namedDecl, truncateParameters: true); + if (remappings.TryGetValue(name, out value)) + { + return true; + } - if (name.StartsWith("ClangSharpMacro_")) - { - name = name["ClangSharpMacro_".Length..]; - } + name = name.Replace("::", "."); - if (remappings.TryGetValue(name, out value)) - { - return true; - } + if (remappings.TryGetValue(name, out value)) + { + return true; + } - name = name.Replace("::", "."); + name = GetRemappedCursorName(namedDecl); - if (remappings.TryGetValue(name, out value)) - { - return true; - } + if (name.StartsWith("ClangSharpMacro_")) + { + name = name["ClangSharpMacro_".Length..]; + } - name = GetRemappedCursorName(namedDecl); + if (remappings.TryGetValue(name, out value)) + { + return true; + } - if (name.StartsWith("ClangSharpMacro_")) - { - name = name["ClangSharpMacro_".Length..]; - } + if (matchStar && remappings.TryGetValue("*", out value)) + { + return true; + } - if (remappings.TryGetValue(name, out value)) - { - return true; - } + value = default; + return false; + } - if (matchStar && remappings.TryGetValue("*", out value)) - { - return true; - } + private void WithTestAttribute() + { + if (_config.GenerateTestsNUnit) + { + _testOutputBuilder.WriteIndentedLine("[Test]"); + } + else if (_config.GenerateTestsXUnit) + { + _testOutputBuilder.WriteIndentedLine("[Fact]"); + } + } - value = default; - return false; + private void WithTestAssertEqual(string expected, string actual) + { + if (_config.GenerateTestsNUnit) + { + _testOutputBuilder.WriteIndented("Assert.That"); + _testOutputBuilder.Write('('); + _testOutputBuilder.Write(actual); + _testOutputBuilder.Write(", Is.EqualTo("); + _testOutputBuilder.Write(expected); + _testOutputBuilder.Write("))"); + _testOutputBuilder.WriteSemicolon(); + _testOutputBuilder.WriteNewline(); + } + else if (_config.GenerateTestsXUnit) + { + _testOutputBuilder.WriteIndented("Assert.Equal"); + _testOutputBuilder.Write('('); + _testOutputBuilder.Write(expected); + _testOutputBuilder.Write(", ");; + _testOutputBuilder.Write(actual); + _testOutputBuilder.Write(')'); + _testOutputBuilder.WriteSemicolon(); + _testOutputBuilder.WriteNewline(); } + } - private void WithTestAttribute() + private void WithTestAssertTrue(string actual) + { + if (_config.GenerateTestsNUnit) { - if (_config.GenerateTestsNUnit) - { - _testOutputBuilder.WriteIndentedLine("[Test]"); - } - else if (_config.GenerateTestsXUnit) - { - _testOutputBuilder.WriteIndentedLine("[Fact]"); - } + _testOutputBuilder.WriteIndented("Assert.That"); + _testOutputBuilder.Write('('); + _testOutputBuilder.Write(actual); + _testOutputBuilder.Write(", Is.True)"); + _testOutputBuilder.WriteSemicolon(); + _testOutputBuilder.WriteNewline(); } + else if (_config.GenerateTestsXUnit) + { + _testOutputBuilder.WriteIndented("Assert.True"); + _testOutputBuilder.Write('('); + _testOutputBuilder.Write(actual); + _testOutputBuilder.Write(')'); + _testOutputBuilder.WriteSemicolon(); + _testOutputBuilder.WriteNewline(); + } + } - private void WithTestAssertEqual(string expected, string actual) + private void WithType(NamedDecl namedDecl, ref string integerTypeName, ref string nativeTypeName) + { + if (TryGetRemappedValue(namedDecl, _config.WithTypes, out var type, matchStar: true)) { - if (_config.GenerateTestsNUnit) + if (string.IsNullOrWhiteSpace(nativeTypeName)) { - _testOutputBuilder.WriteIndented("Assert.That"); - _testOutputBuilder.Write('('); - _testOutputBuilder.Write(actual); - _testOutputBuilder.Write(", Is.EqualTo("); - _testOutputBuilder.Write(expected); - _testOutputBuilder.Write("))"); - _testOutputBuilder.WriteSemicolon(); - _testOutputBuilder.WriteNewline(); + nativeTypeName = integerTypeName; } - else if (_config.GenerateTestsXUnit) + + integerTypeName = type; + + if (IsNativeTypeNameEquivalent(nativeTypeName, type)) { - _testOutputBuilder.WriteIndented("Assert.Equal"); - _testOutputBuilder.Write('('); - _testOutputBuilder.Write(expected); - _testOutputBuilder.Write(", ");; - _testOutputBuilder.Write(actual); - _testOutputBuilder.Write(')'); - _testOutputBuilder.WriteSemicolon(); - _testOutputBuilder.WriteNewline(); + nativeTypeName = string.Empty; } } + } - private void WithTestAssertTrue(string actual) + private void WithUsings(NamedDecl namedDecl) + { + if (TryGetRemappedValue(namedDecl, _config.WithUsings, out var usings)) { - if (_config.GenerateTestsNUnit) + foreach (var @using in usings) { - _testOutputBuilder.WriteIndented("Assert.That"); - _testOutputBuilder.Write('('); - _testOutputBuilder.Write(actual); - _testOutputBuilder.Write(", Is.True)"); - _testOutputBuilder.WriteSemicolon(); - _testOutputBuilder.WriteNewline(); - } - else if (_config.GenerateTestsXUnit) - { - _testOutputBuilder.WriteIndented("Assert.True"); - _testOutputBuilder.Write('('); - _testOutputBuilder.Write(actual); - _testOutputBuilder.Write(')'); - _testOutputBuilder.WriteSemicolon(); - _testOutputBuilder.WriteNewline(); + _outputBuilder.EmitUsingDirective(@using); } } + } - private void WithType(NamedDecl namedDecl, ref string integerTypeName, ref string nativeTypeName) + private CSharpOutputBuilder StartCSharpCode() + { + if ((_outputBuilder == _testOutputBuilder) && (_testStmtOutputBuilder is null)) { - if (TryGetRemappedValue(namedDecl, _config.WithTypes, out var type, matchStar: true)) - { - if (string.IsNullOrWhiteSpace(nativeTypeName)) - { - nativeTypeName = integerTypeName; - } + _testStmtOutputBuilder = _stmtOutputBuilder; + _testStmtOutputBuilderUsers = _stmtOutputBuilderUsers; - integerTypeName = type; - - if (IsNativeTypeNameEquivalent(nativeTypeName, type)) - { - nativeTypeName = string.Empty; - } - } + _stmtOutputBuilder = null; + _stmtOutputBuilderUsers = 0; } - private void WithUsings(NamedDecl namedDecl) + if (_stmtOutputBuilder is null) { - if (TryGetRemappedValue(namedDecl, _config.WithUsings, out var usings)) - { - foreach (var @using in usings) - { - _outputBuilder.EmitUsingDirective(@using); - } - } + _stmtOutputBuilder = _outputBuilder.BeginCSharpCode(); + _stmtOutputBuilderUsers = 1; } - - private CSharpOutputBuilder StartCSharpCode() + else { - if ((_outputBuilder == _testOutputBuilder) && (_testStmtOutputBuilder is null)) - { - _testStmtOutputBuilder = _stmtOutputBuilder; - _testStmtOutputBuilderUsers = _stmtOutputBuilderUsers; + _stmtOutputBuilderUsers++; + } - _stmtOutputBuilder = null; - _stmtOutputBuilderUsers = 0; - } + return _stmtOutputBuilder; + } + + private void StopCSharpCode() + { + _stmtOutputBuilderUsers--; + if (_stmtOutputBuilderUsers <= 0) + { + _outputBuilder.EndCSharpCode(_stmtOutputBuilder); - if (_stmtOutputBuilder is null) + if (_testStmtOutputBuilder is not null) { - _stmtOutputBuilder = _outputBuilder.BeginCSharpCode(); - _stmtOutputBuilderUsers = 1; + _stmtOutputBuilder = _testStmtOutputBuilder; + _stmtOutputBuilderUsers = _testStmtOutputBuilderUsers; + + _testStmtOutputBuilder = null; + _testStmtOutputBuilderUsers = 0; } else { - _stmtOutputBuilderUsers++; - } - - return _stmtOutputBuilder; - } - - private void StopCSharpCode() - { - _stmtOutputBuilderUsers--; - if (_stmtOutputBuilderUsers <= 0) - { - _outputBuilder.EndCSharpCode(_stmtOutputBuilder); - - if (_testStmtOutputBuilder is not null) - { - _stmtOutputBuilder = _testStmtOutputBuilder; - _stmtOutputBuilderUsers = _testStmtOutputBuilderUsers; - - _testStmtOutputBuilder = null; - _testStmtOutputBuilderUsers = 0; - } - else - { - _stmtOutputBuilder = null; - } + _stmtOutputBuilder = null; } } } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs index dc0630e6..1766eecb 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs @@ -5,591 +5,590 @@ using System.IO; using ClangSharp.Abstractions; -namespace ClangSharp +namespace ClangSharp; + +public sealed class PInvokeGeneratorConfiguration { - public sealed class PInvokeGeneratorConfiguration + private const string DefaultClassValue = "Methods"; + private const string DefaultLibraryPathValue = @""""""; + private const string DefaultMethodPrefixToStripValue = ""; + private const string DefaultTestOutputLocationValue = ""; + + private readonly string _defaultNamespace; + private readonly string _headerText; + private readonly string _libraryPath; + private readonly string _outputLocation; + private readonly PInvokeGeneratorOutputMode _outputMode; + + private readonly string _defaultClass; + private readonly string _methodPrefixToStrip; + private readonly string _testOutputLocation; + + private readonly SortedSet _excludedNames; + private readonly SortedSet _forceRemappedNames; + private readonly SortedSet _includedNames; + private readonly SortedSet _withManualImports; + private readonly SortedSet _traversalNames; + private readonly SortedSet _withSetLastErrors; + private readonly SortedSet _withSuppressGCTransitions; + + private readonly SortedDictionary _remappedNames; + private readonly SortedDictionary _withAccessSpecifiers; + private readonly SortedDictionary> _withAttributes; + private readonly SortedDictionary _withCallConvs; + private readonly SortedDictionary _withClasses; + private readonly SortedDictionary _withGuids; + private readonly SortedDictionary _withLibraryPaths; + private readonly SortedDictionary _withNamespaces; + private readonly SortedDictionary _withTransparentStructs; + private readonly SortedDictionary _withTypes; + private readonly SortedDictionary> _withUsings; + + private PInvokeGeneratorConfigurationOptions _options; + + public PInvokeGeneratorConfiguration(string defaultNamespace, string outputLocation, string headerFile, PInvokeGeneratorOutputMode outputMode, PInvokeGeneratorConfigurationOptions options) { - private const string DefaultClassValue = "Methods"; - private const string DefaultLibraryPathValue = @""""""; - private const string DefaultMethodPrefixToStripValue = ""; - private const string DefaultTestOutputLocationValue = ""; - - private readonly string _defaultNamespace; - private readonly string _headerText; - private readonly string _libraryPath; - private readonly string _outputLocation; - private readonly PInvokeGeneratorOutputMode _outputMode; - - private readonly string _defaultClass; - private readonly string _methodPrefixToStrip; - private readonly string _testOutputLocation; - - private readonly SortedSet _excludedNames; - private readonly SortedSet _forceRemappedNames; - private readonly SortedSet _includedNames; - private readonly SortedSet _withManualImports; - private readonly SortedSet _traversalNames; - private readonly SortedSet _withSetLastErrors; - private readonly SortedSet _withSuppressGCTransitions; - - private readonly SortedDictionary _remappedNames; - private readonly SortedDictionary _withAccessSpecifiers; - private readonly SortedDictionary> _withAttributes; - private readonly SortedDictionary _withCallConvs; - private readonly SortedDictionary _withClasses; - private readonly SortedDictionary _withGuids; - private readonly SortedDictionary _withLibraryPaths; - private readonly SortedDictionary _withNamespaces; - private readonly SortedDictionary _withTransparentStructs; - private readonly SortedDictionary _withTypes; - private readonly SortedDictionary> _withUsings; - - private PInvokeGeneratorConfigurationOptions _options; - - public PInvokeGeneratorConfiguration(string defaultNamespace, string outputLocation, string headerFile, PInvokeGeneratorOutputMode outputMode, PInvokeGeneratorConfigurationOptions options) - { - if (string.IsNullOrWhiteSpace(defaultNamespace)) - { - throw new ArgumentNullException(nameof(defaultNamespace)); - } - _defaultNamespace = defaultNamespace; + if (string.IsNullOrWhiteSpace(defaultNamespace)) + { + throw new ArgumentNullException(nameof(defaultNamespace)); + } + _defaultNamespace = defaultNamespace; - if (string.IsNullOrWhiteSpace(outputLocation)) - { - throw new ArgumentNullException(nameof(outputLocation)); - } - _outputLocation = Path.GetFullPath(outputLocation); + if (string.IsNullOrWhiteSpace(outputLocation)) + { + throw new ArgumentNullException(nameof(outputLocation)); + } + _outputLocation = Path.GetFullPath(outputLocation); - if (outputMode is not PInvokeGeneratorOutputMode.CSharp and not PInvokeGeneratorOutputMode.Xml) - { - throw new ArgumentOutOfRangeException(nameof(outputMode)); - } - _outputMode = outputMode; - - _defaultClass = DefaultClassValue; - _headerText = string.IsNullOrWhiteSpace(headerFile) ? string.Empty : File.ReadAllText(headerFile); - _libraryPath = DefaultLibraryPathValue; - _methodPrefixToStrip = DefaultMethodPrefixToStripValue; - _testOutputLocation = DefaultTestOutputLocationValue; - - _excludedNames = new SortedSet(); - _forceRemappedNames = new SortedSet(); - _includedNames = new SortedSet(); - _withManualImports = new SortedSet(); - _traversalNames = new SortedSet(); - _withSetLastErrors = new SortedSet(); - _withSuppressGCTransitions = new SortedSet(); - - _remappedNames = new SortedDictionary(); - _withAccessSpecifiers = new SortedDictionary(); - _withAttributes = new SortedDictionary>(); - _withCallConvs = new SortedDictionary(); - _withClasses = new SortedDictionary(); - _withGuids = new SortedDictionary(); - _withLibraryPaths = new SortedDictionary(); - _withNamespaces = new SortedDictionary(); - _withTransparentStructs = new SortedDictionary(); - _withTypes = new SortedDictionary(); - _withUsings = new SortedDictionary>(); - - if ((outputMode == PInvokeGeneratorOutputMode.Xml) && !options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles) && (options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit) || options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit))) - { - // we can't mix XML and C#! we're in XML mode, not generating multiple files, and generating tests; fail - throw new ArgumentException("Can't generate tests in XML mode without multiple files.", nameof(options)); - } - else if (options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode) && options.HasFlag(PInvokeGeneratorConfigurationOptions.GeneratePreviewCode)) + if (outputMode is not PInvokeGeneratorOutputMode.CSharp and not PInvokeGeneratorOutputMode.Xml) + { + throw new ArgumentOutOfRangeException(nameof(outputMode)); + } + _outputMode = outputMode; + + _defaultClass = DefaultClassValue; + _headerText = string.IsNullOrWhiteSpace(headerFile) ? string.Empty : File.ReadAllText(headerFile); + _libraryPath = DefaultLibraryPathValue; + _methodPrefixToStrip = DefaultMethodPrefixToStripValue; + _testOutputLocation = DefaultTestOutputLocationValue; + + _excludedNames = new SortedSet(); + _forceRemappedNames = new SortedSet(); + _includedNames = new SortedSet(); + _withManualImports = new SortedSet(); + _traversalNames = new SortedSet(); + _withSetLastErrors = new SortedSet(); + _withSuppressGCTransitions = new SortedSet(); + + _remappedNames = new SortedDictionary(); + _withAccessSpecifiers = new SortedDictionary(); + _withAttributes = new SortedDictionary>(); + _withCallConvs = new SortedDictionary(); + _withClasses = new SortedDictionary(); + _withGuids = new SortedDictionary(); + _withLibraryPaths = new SortedDictionary(); + _withNamespaces = new SortedDictionary(); + _withTransparentStructs = new SortedDictionary(); + _withTypes = new SortedDictionary(); + _withUsings = new SortedDictionary>(); + + if ((outputMode == PInvokeGeneratorOutputMode.Xml) && !options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles) && (options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit) || options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit))) + { + // we can't mix XML and C#! we're in XML mode, not generating multiple files, and generating tests; fail + throw new ArgumentException("Can't generate tests in XML mode without multiple files.", nameof(options)); + } + else if (options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode) && options.HasFlag(PInvokeGeneratorConfigurationOptions.GeneratePreviewCode)) + { + throw new ArgumentOutOfRangeException(nameof(options)); + } + _options = options; + + if (!_options.HasFlag(PInvokeGeneratorConfigurationOptions.NoDefaultRemappings)) + { + if (!ExcludeNIntCodegen) { - throw new ArgumentOutOfRangeException(nameof(options)); + _remappedNames.Add("intptr_t", "nint"); + _remappedNames.Add("ptrdiff_t", "nint"); + _remappedNames.Add("size_t", "nuint"); + _remappedNames.Add("uintptr_t", "nuint"); } - _options = options; - - if (!_options.HasFlag(PInvokeGeneratorConfigurationOptions.NoDefaultRemappings)) + else { - if (!ExcludeNIntCodegen) - { - _remappedNames.Add("intptr_t", "nint"); - _remappedNames.Add("ptrdiff_t", "nint"); - _remappedNames.Add("size_t", "nuint"); - _remappedNames.Add("uintptr_t", "nuint"); - } - else - { - _remappedNames.Add("intptr_t", "IntPtr"); - _remappedNames.Add("ptrdiff_t", "IntPtr"); - _remappedNames.Add("size_t", "UIntPtr"); - _remappedNames.Add("uintptr_t", "UIntPtr"); - } + _remappedNames.Add("intptr_t", "IntPtr"); + _remappedNames.Add("ptrdiff_t", "IntPtr"); + _remappedNames.Add("size_t", "UIntPtr"); + _remappedNames.Add("uintptr_t", "UIntPtr"); } } + } - public string DefaultClass + public string DefaultClass + { + get { - get - { - return _defaultClass; - } + return _defaultClass; + } - init - { - _defaultClass = string.IsNullOrWhiteSpace(value) ? DefaultClassValue : value; - } + init + { + _defaultClass = string.IsNullOrWhiteSpace(value) ? DefaultClassValue : value; } + } - public bool DontUseUsingStaticsForEnums => _options.HasFlag(PInvokeGeneratorConfigurationOptions.DontUseUsingStaticsForEnums); + public bool DontUseUsingStaticsForEnums => _options.HasFlag(PInvokeGeneratorConfigurationOptions.DontUseUsingStaticsForEnums); - public bool ExcludeAnonymousFieldHelpers => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeAnonymousFieldHelpers); + public bool ExcludeAnonymousFieldHelpers => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeAnonymousFieldHelpers); - public bool ExcludeComProxies => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeComProxies); + public bool ExcludeComProxies => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeComProxies); - public bool ExcludeEmptyRecords => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeEmptyRecords); + public bool ExcludeEmptyRecords => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeEmptyRecords); - public bool ExcludeEnumOperators => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeEnumOperators); + public bool ExcludeEnumOperators => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeEnumOperators); + + public bool ExcludeFnptrCodegen + { + get + { + return GenerateCompatibleCode || _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeFnptrCodegen); + } - public bool ExcludeFnptrCodegen + set { - get + if (value) { - return GenerateCompatibleCode || _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeFnptrCodegen); + _options |= PInvokeGeneratorConfigurationOptions.ExcludeFnptrCodegen; } - - set + else { - if (value) - { - _options |= PInvokeGeneratorConfigurationOptions.ExcludeFnptrCodegen; - } - else - { - _options &= ~PInvokeGeneratorConfigurationOptions.ExcludeFnptrCodegen; - } + _options &= ~PInvokeGeneratorConfigurationOptions.ExcludeFnptrCodegen; } } + } - public bool ExcludeFunctionsWithBody => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeFunctionsWithBody); + public bool ExcludeFunctionsWithBody => _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeFunctionsWithBody); - public IReadOnlyCollection ExcludedNames + public IReadOnlyCollection ExcludedNames + { + get { - get - { - return _excludedNames; - } + return _excludedNames; + } - init - { - AddRange(_excludedNames, value); - } + init + { + AddRange(_excludedNames, value); } + } - public bool ExcludeNIntCodegen => GenerateCompatibleCode || _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeNIntCodegen); + public bool ExcludeNIntCodegen => GenerateCompatibleCode || _options.HasFlag(PInvokeGeneratorConfigurationOptions.ExcludeNIntCodegen); - public bool GenerateAggressiveInlining => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateAggressiveInlining); + public bool GenerateAggressiveInlining => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateAggressiveInlining); - public bool GenerateCompatibleCode => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode); + public bool GenerateCompatibleCode => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode); - public bool GenerateCppAttributes => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateCppAttributes); + public bool GenerateCppAttributes => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateCppAttributes); - public bool GenerateDocIncludes => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateDocIncludes); + public bool GenerateDocIncludes => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateDocIncludes); - public bool GenerateExplicitVtbls => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + public bool GenerateExplicitVtbls => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - public bool GenerateFileScopedNamespaces => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); + public bool GenerateFileScopedNamespaces => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); - public bool GenerateGuidMember => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateGuidMember); + public bool GenerateGuidMember => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateGuidMember); - public bool GenerateHelperTypes => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateHelperTypes); + public bool GenerateHelperTypes => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateHelperTypes); - public bool GenerateMacroBindings => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateMacroBindings); + public bool GenerateMacroBindings => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateMacroBindings); - public bool GenerateMarkerInterfaces => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + public bool GenerateMarkerInterfaces => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - public bool GenerateMultipleFiles => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles); + public bool GenerateMultipleFiles => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles); - public bool GenerateNativeInheritanceAttribute => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + public bool GenerateNativeInheritanceAttribute => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - public bool GeneratePreviewCode => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GeneratePreviewCode); + public bool GeneratePreviewCode => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GeneratePreviewCode); - public bool GenerateSetsLastSystemErrorAttribute => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateSetsLastSystemErrorAttribute); + public bool GenerateSetsLastSystemErrorAttribute => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateSetsLastSystemErrorAttribute); - public bool GenerateSourceLocationAttribute => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); + public bool GenerateSourceLocationAttribute => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - public bool GenerateTemplateBindings => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTemplateBindings); + public bool GenerateTemplateBindings => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTemplateBindings); - public bool GenerateTestsNUnit => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit); + public bool GenerateTestsNUnit => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit); - public bool GenerateTestsXUnit => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit); + public bool GenerateTestsXUnit => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit); - public bool GenerateTrimmableVtbls => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTrimmableVtbls); + public bool GenerateTrimmableVtbls => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTrimmableVtbls); - public bool GenerateUnixTypes => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateUnixTypes); + public bool GenerateUnixTypes => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateUnixTypes); - public bool GenerateUnmanagedConstants => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateUnmanagedConstants); + public bool GenerateUnmanagedConstants => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateUnmanagedConstants); - public bool GenerateVtblIndexAttribute => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); + public bool GenerateVtblIndexAttribute => _options.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - public string HeaderText => _headerText; + public string HeaderText => _headerText; - public IReadOnlyCollection IncludedNames + public IReadOnlyCollection IncludedNames + { + get { - get - { - return _includedNames; - } + return _includedNames; + } - init - { - AddRange(_includedNames, value); - } + init + { + AddRange(_includedNames, value); } + } - public string LibraryPath + public string LibraryPath + { + get { - get - { - return _libraryPath; - } + return _libraryPath; + } - init - { - _libraryPath = string.IsNullOrWhiteSpace(value) ? DefaultLibraryPathValue : $@"""{value}"""; - } + init + { + _libraryPath = string.IsNullOrWhiteSpace(value) ? DefaultLibraryPathValue : $@"""{value}"""; } + } - public bool LogExclusions => _options.HasFlag(PInvokeGeneratorConfigurationOptions.LogExclusions); + public bool LogExclusions => _options.HasFlag(PInvokeGeneratorConfigurationOptions.LogExclusions); - public bool LogPotentialTypedefRemappings => _options.HasFlag(PInvokeGeneratorConfigurationOptions.LogPotentialTypedefRemappings); + public bool LogPotentialTypedefRemappings => _options.HasFlag(PInvokeGeneratorConfigurationOptions.LogPotentialTypedefRemappings); - public bool LogVisitedFiles => _options.HasFlag(PInvokeGeneratorConfigurationOptions.LogVisitedFiles); + public bool LogVisitedFiles => _options.HasFlag(PInvokeGeneratorConfigurationOptions.LogVisitedFiles); - public string MethodPrefixToStrip + public string MethodPrefixToStrip + { + get { - get - { - return _methodPrefixToStrip; - } + return _methodPrefixToStrip; + } - init - { - _methodPrefixToStrip = string.IsNullOrWhiteSpace(value) ? DefaultMethodPrefixToStripValue : value; - } + init + { + _methodPrefixToStrip = string.IsNullOrWhiteSpace(value) ? DefaultMethodPrefixToStripValue : value; } + } - public string DefaultNamespace => _defaultNamespace; + public string DefaultNamespace => _defaultNamespace; - public PInvokeGeneratorOutputMode OutputMode => _outputMode; + public PInvokeGeneratorOutputMode OutputMode => _outputMode; - public string OutputLocation => _outputLocation; + public string OutputLocation => _outputLocation; - public IReadOnlyDictionary RemappedNames + public IReadOnlyDictionary RemappedNames + { + get { - get - { - return _remappedNames; - } + return _remappedNames; + } - init - { - AddRange(_forceRemappedNames, value, ValueStartsWithAt); - AddRange(_remappedNames, value, RemoveAtPrefix); - } + init + { + AddRange(_forceRemappedNames, value, ValueStartsWithAt); + AddRange(_remappedNames, value, RemoveAtPrefix); } + } - public IReadOnlyCollection ForceRemappedNames => _forceRemappedNames; + public IReadOnlyCollection ForceRemappedNames => _forceRemappedNames; - public string TestOutputLocation + public string TestOutputLocation + { + get { - get - { - return _testOutputLocation; - } + return _testOutputLocation; + } - init - { - _testOutputLocation = string.IsNullOrWhiteSpace(value) ? DefaultTestOutputLocationValue : Path.GetFullPath(value); - } + init + { + _testOutputLocation = string.IsNullOrWhiteSpace(value) ? DefaultTestOutputLocationValue : Path.GetFullPath(value); } + } - public IReadOnlyCollection TraversalNames + public IReadOnlyCollection TraversalNames + { + get { - get - { - return _traversalNames; - } + return _traversalNames; + } - init - { - AddRange(_traversalNames, value, NormalizePathSeparators); - } + init + { + AddRange(_traversalNames, value, NormalizePathSeparators); } + } - public IReadOnlyDictionary WithAccessSpecifiers + public IReadOnlyDictionary WithAccessSpecifiers + { + get { - get - { - return _withAccessSpecifiers; - } + return _withAccessSpecifiers; + } - init - { - AddRange(_withAccessSpecifiers, value); - } + init + { + AddRange(_withAccessSpecifiers, value); } + } - public IReadOnlyDictionary> WithAttributes + public IReadOnlyDictionary> WithAttributes + { + get { - get - { - return _withAttributes; - } + return _withAttributes; + } - init - { - AddRange(_withAttributes, value); - } + init + { + AddRange(_withAttributes, value); } + } - public IReadOnlyDictionary WithCallConvs + public IReadOnlyDictionary WithCallConvs + { + get { - get - { - return _withCallConvs; - } + return _withCallConvs; + } - init - { - AddRange(_withCallConvs, value); - } + init + { + AddRange(_withCallConvs, value); } + } - public IReadOnlyDictionary WithClasses + public IReadOnlyDictionary WithClasses + { + get { - get - { - return _withClasses; - } + return _withClasses; + } - init - { - AddRange(_withClasses, value); - } + init + { + AddRange(_withClasses, value); } + } - public IReadOnlyDictionary WithGuids + public IReadOnlyDictionary WithGuids + { + get { - get - { - return _withGuids; - } + return _withGuids; + } - init - { - AddRange(_withGuids, value); - } + init + { + AddRange(_withGuids, value); } + } - public IReadOnlyDictionary WithLibraryPaths + public IReadOnlyDictionary WithLibraryPaths + { + get { - get - { - return _withLibraryPaths; - } + return _withLibraryPaths; + } - init - { - AddRange(_withLibraryPaths, value); - } + init + { + AddRange(_withLibraryPaths, value); } + } - public IReadOnlyCollection WithManualImports + public IReadOnlyCollection WithManualImports + { + get { - get - { - return _withManualImports; - } + return _withManualImports; + } - init - { - AddRange(_withManualImports, value); - } + init + { + AddRange(_withManualImports, value); } + } - public IReadOnlyDictionary WithNamespaces + public IReadOnlyDictionary WithNamespaces + { + get { - get - { - return _withNamespaces; - } + return _withNamespaces; + } - init - { - AddRange(_withNamespaces, value); - } + init + { + AddRange(_withNamespaces, value); } + } - public IReadOnlyCollection WithSetLastErrors + public IReadOnlyCollection WithSetLastErrors + { + get { - get - { - return _withSetLastErrors; - } + return _withSetLastErrors; + } - init - { - AddRange(_withSetLastErrors, value); - } + init + { + AddRange(_withSetLastErrors, value); } + } - public IReadOnlyCollection WithSuppressGCTransitions + public IReadOnlyCollection WithSuppressGCTransitions + { + get { - get - { - return _withSuppressGCTransitions; - } + return _withSuppressGCTransitions; + } - init - { - AddRange(_withSuppressGCTransitions, value); - } + init + { + AddRange(_withSuppressGCTransitions, value); } + } - public IReadOnlyDictionary WithTransparentStructs + public IReadOnlyDictionary WithTransparentStructs + { + get { - get - { - return _withTransparentStructs; - } + return _withTransparentStructs; + } - init - { - AddRange(_withTransparentStructs, value, RemoveAtPrefix); - } + init + { + AddRange(_withTransparentStructs, value, RemoveAtPrefix); } + } - public IReadOnlyDictionary WithTypes + public IReadOnlyDictionary WithTypes + { + get { - get - { - return _withTypes; - } + return _withTypes; + } - init - { - AddRange(_withTypes, value); - } + init + { + AddRange(_withTypes, value); } + } - public IReadOnlyDictionary> WithUsings + public IReadOnlyDictionary> WithUsings + { + get { - get - { - return _withUsings; - } + return _withUsings; + } - init - { - AddRange(_withUsings, value); - } + init + { + AddRange(_withUsings, value); } + } - public static AccessSpecifier ConvertStringToAccessSpecifier(string input) + public static AccessSpecifier ConvertStringToAccessSpecifier(string input) + { + if (input.Equals("internal", StringComparison.OrdinalIgnoreCase)) { - if (input.Equals("internal", StringComparison.OrdinalIgnoreCase)) - { - return AccessSpecifier.Internal; - } - else if (input.Equals("private", StringComparison.OrdinalIgnoreCase)) - { - return AccessSpecifier.Private; - } - else if (input.Equals("private protected", StringComparison.OrdinalIgnoreCase)) - { - return AccessSpecifier.PrivateProtected; - } - else if (input.Equals("protected", StringComparison.OrdinalIgnoreCase)) - { - return AccessSpecifier.Protected; - } - else if (input.Equals("protected internal", StringComparison.OrdinalIgnoreCase)) - { - return AccessSpecifier.ProtectedInternal; - } - else if (input.Equals("public", StringComparison.OrdinalIgnoreCase)) - { - return AccessSpecifier.Public; - } - else - { - return AccessSpecifier.None; - } + return AccessSpecifier.Internal; } + else if (input.Equals("private", StringComparison.OrdinalIgnoreCase)) + { + return AccessSpecifier.Private; + } + else if (input.Equals("private protected", StringComparison.OrdinalIgnoreCase)) + { + return AccessSpecifier.PrivateProtected; + } + else if (input.Equals("protected", StringComparison.OrdinalIgnoreCase)) + { + return AccessSpecifier.Protected; + } + else if (input.Equals("protected internal", StringComparison.OrdinalIgnoreCase)) + { + return AccessSpecifier.ProtectedInternal; + } + else if (input.Equals("public", StringComparison.OrdinalIgnoreCase)) + { + return AccessSpecifier.Public; + } + else + { + return AccessSpecifier.None; + } + } - private static void AddRange(SortedDictionary dictionary, IEnumerable> keyValuePairs) + private static void AddRange(SortedDictionary dictionary, IEnumerable> keyValuePairs) + { + if (keyValuePairs != null) { - if (keyValuePairs != null) + foreach (var keyValuePair in keyValuePairs) { - foreach (var keyValuePair in keyValuePairs) - { - // Use the indexer, rather than Add, so that any - // default mappings can be overwritten if desired. - dictionary[keyValuePair.Key] = keyValuePair.Value; - } + // Use the indexer, rather than Add, so that any + // default mappings can be overwritten if desired. + dictionary[keyValuePair.Key] = keyValuePair.Value; } } + } - private static void AddRange(SortedDictionary dictionary, IEnumerable> keyValuePairs, Func convert) + private static void AddRange(SortedDictionary dictionary, IEnumerable> keyValuePairs, Func convert) + { + if (keyValuePairs != null) { - if (keyValuePairs != null) + foreach (var keyValuePair in keyValuePairs) { - foreach (var keyValuePair in keyValuePairs) - { - // Use the indexer, rather than Add, so that any - // default mappings can be overwritten if desired. - dictionary[keyValuePair.Key] = convert(keyValuePair.Value); - } + // Use the indexer, rather than Add, so that any + // default mappings can be overwritten if desired. + dictionary[keyValuePair.Key] = convert(keyValuePair.Value); } } + } - private static void AddRange(SortedSet hashSet, IEnumerable keys) + private static void AddRange(SortedSet hashSet, IEnumerable keys) + { + if (keys != null) { - if (keys != null) + foreach (var key in keys) { - foreach (var key in keys) - { - _ = hashSet.Add(key); - } + _ = hashSet.Add(key); } } + } - private static void AddRange(SortedSet hashSet, IEnumerable keys, Func convert) + private static void AddRange(SortedSet hashSet, IEnumerable keys, Func convert) + { + if (keys != null) { - if (keys != null) + foreach (var key in keys) { - foreach (var key in keys) - { - _ = hashSet.Add(convert(key)); - } + _ = hashSet.Add(convert(key)); } } + } - private static void AddRange(SortedSet hashSet, IEnumerable> keyValuePairs, Func shouldAdd) + private static void AddRange(SortedSet hashSet, IEnumerable> keyValuePairs, Func shouldAdd) + { + if (keyValuePairs != null) { - if (keyValuePairs != null) + foreach (var keyValuePair in keyValuePairs) { - foreach (var keyValuePair in keyValuePairs) + if (shouldAdd(keyValuePair.Value)) { - if (shouldAdd(keyValuePair.Value)) - { - _ = hashSet.Add(keyValuePair.Key); - } + _ = hashSet.Add(keyValuePair.Key); } } } + } - private static string NormalizePathSeparators(string value) => value.Replace('\\', '/'); + private static string NormalizePathSeparators(string value) => value.Replace('\\', '/'); - private static string RemoveAtPrefix(string value) => ValueStartsWithAt(value) ? value[1..] : value; + private static string RemoveAtPrefix(string value) => ValueStartsWithAt(value) ? value[1..] : value; - private static (string, PInvokeGeneratorTransparentStructKind) RemoveAtPrefix((string Name, PInvokeGeneratorTransparentStructKind Kind) value) => (ValueStartsWithAt(value.Name) ? value.Name[1..] : value.Name, value.Kind); + private static (string, PInvokeGeneratorTransparentStructKind) RemoveAtPrefix((string Name, PInvokeGeneratorTransparentStructKind Kind) value) => (ValueStartsWithAt(value.Name) ? value.Name[1..] : value.Name, value.Kind); - private static bool ValueStartsWithAt(string value) => value.StartsWith("@"); - } + private static bool ValueStartsWithAt(string value) => value.StartsWith("@"); } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs index 9f435e70..839aa280 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfigurationOptions.cs @@ -2,79 +2,78 @@ using System; -namespace ClangSharp +namespace ClangSharp; + +[Flags] +public enum PInvokeGeneratorConfigurationOptions : ulong { - [Flags] - public enum PInvokeGeneratorConfigurationOptions : ulong - { - None = 0, + None = 0, - GenerateMultipleFiles = 1UL << 0, + GenerateMultipleFiles = 1UL << 0, - GenerateUnixTypes = 1UL << 1, + GenerateUnixTypes = 1UL << 1, - NoDefaultRemappings = 1UL << 2, + NoDefaultRemappings = 1UL << 2, - GenerateCompatibleCode = 1UL << 3, + GenerateCompatibleCode = 1UL << 3, - ExcludeNIntCodegen = 1UL << 4, + ExcludeNIntCodegen = 1UL << 4, - ExcludeFnptrCodegen = 1UL << 5, + ExcludeFnptrCodegen = 1UL << 5, - LogExclusions = 1UL << 6, + LogExclusions = 1UL << 6, - LogVisitedFiles = 1UL << 7, + LogVisitedFiles = 1UL << 7, - GenerateExplicitVtbls = 1UL << 8, + GenerateExplicitVtbls = 1UL << 8, - GenerateTestsNUnit = 1UL << 9, + GenerateTestsNUnit = 1UL << 9, - GenerateTestsXUnit = 1UL << 10, + GenerateTestsXUnit = 1UL << 10, - GenerateMacroBindings = 1UL << 11, + GenerateMacroBindings = 1UL << 11, - ExcludeComProxies = 1UL << 12, + ExcludeComProxies = 1UL << 12, - ExcludeEmptyRecords = 1UL << 13, + ExcludeEmptyRecords = 1UL << 13, - ExcludeEnumOperators = 1UL << 14, + ExcludeEnumOperators = 1UL << 14, - GenerateAggressiveInlining = 1UL << 15, + GenerateAggressiveInlining = 1UL << 15, - ExcludeFunctionsWithBody = 1UL << 16, + ExcludeFunctionsWithBody = 1UL << 16, - ExcludeAnonymousFieldHelpers = 1UL << 17, + ExcludeAnonymousFieldHelpers = 1UL << 17, - LogPotentialTypedefRemappings = 1UL << 18, + LogPotentialTypedefRemappings = 1UL << 18, - GenerateCppAttributes = 1UL << 19, + GenerateCppAttributes = 1UL << 19, - GenerateNativeInheritanceAttribute = 1UL << 20, + GenerateNativeInheritanceAttribute = 1UL << 20, - DontUseUsingStaticsForEnums = 1UL << 21, + DontUseUsingStaticsForEnums = 1UL << 21, - GenerateVtblIndexAttribute = 1UL << 22, + GenerateVtblIndexAttribute = 1UL << 22, - GeneratePreviewCode = 1UL << 23, + GeneratePreviewCode = 1UL << 23, - GenerateTemplateBindings = 1UL << 24, + GenerateTemplateBindings = 1UL << 24, - GenerateSourceLocationAttribute = 1UL << 25, + GenerateSourceLocationAttribute = 1UL << 25, - GenerateUnmanagedConstants = 1UL << 26, + GenerateUnmanagedConstants = 1UL << 26, - GenerateHelperTypes = 1UL << 27, + GenerateHelperTypes = 1UL << 27, - GenerateTrimmableVtbls = 1UL << 28, + GenerateTrimmableVtbls = 1UL << 28, - GenerateMarkerInterfaces = 1UL << 29, + GenerateMarkerInterfaces = 1UL << 29, - GenerateFileScopedNamespaces = 1UL << 30, + GenerateFileScopedNamespaces = 1UL << 30, - GenerateSetsLastSystemErrorAttribute = 1UL << 31, + GenerateSetsLastSystemErrorAttribute = 1UL << 31, - GenerateDocIncludes = 1UL << 32, + GenerateDocIncludes = 1UL << 32, - GenerateGuidMember = 1UL << 33, - } + GenerateGuidMember = 1UL << 33, } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorOutputMode.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorOutputMode.cs index 2f112ad7..c9f54a56 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorOutputMode.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorOutputMode.cs @@ -1,8 +1,7 @@ -namespace ClangSharp +namespace ClangSharp; + +public enum PInvokeGeneratorOutputMode { - public enum PInvokeGeneratorOutputMode - { - CSharp, - Xml - } + CSharp, + Xml } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorTransparentStructKind.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorTransparentStructKind.cs index c9ddc47e..8f61061e 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorTransparentStructKind.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorTransparentStructKind.cs @@ -1,13 +1,12 @@ -namespace ClangSharp +namespace ClangSharp; + +public enum PInvokeGeneratorTransparentStructKind { - public enum PInvokeGeneratorTransparentStructKind - { - Unknown = 0, - Typedef = 1, - Handle = 2, - Boolean = 3, - HandleWin32 = 4, - TypedefHex = 5, - HandleVulkan = 6, - } + Unknown = 0, + Typedef = 1, + Handle = 2, + Boolean = 3, + HandleWin32 = 4, + TypedefHex = 5, + HandleVulkan = 6, } diff --git a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.Visit.cs b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.Visit.cs index 7a545c78..7f51c35e 100644 --- a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.Visit.cs +++ b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.Visit.cs @@ -2,45 +2,44 @@ using System; -namespace ClangSharp.XML +namespace ClangSharp.XML; + +internal partial class XmlOutputBuilder { - internal partial class XmlOutputBuilder + public void WriteCustomAttribute(string attribute, Action callback = null) + { + _ = _sb.Append($"{attribute}"); + callback?.Invoke(); + _ = _sb.Append("\n"); + } + + public void WriteIid(string name, Guid value) + { + var valueString = value.ToString("X").ToUpperInvariant().Replace("{", "").Replace("}", "").Replace('X', 'x').Replace(",", ", "); + WriteIid(name, valueString); + } + + public void WriteIid(string name, string value) + { + _ = _sb.Append(""); + } + + public void WriteDivider(bool force = false) + { + // nop, used only by C# + } + + public void SuppressDivider() + { + // nop, used only by C# + } + + public void EmitUsingDirective(string directive) { - public void WriteCustomAttribute(string attribute, Action callback = null) - { - _ = _sb.Append($"{attribute}"); - callback?.Invoke(); - _ = _sb.Append("\n"); - } - - public void WriteIid(string name, Guid value) - { - var valueString = value.ToString("X").ToUpperInvariant().Replace("{", "").Replace("}", "").Replace('X', 'x').Replace(",", ", "); - WriteIid(name, valueString); - } - - public void WriteIid(string name, string value) - { - _ = _sb.Append(""); - } - - public void WriteDivider(bool force = false) - { - // nop, used only by C# - } - - public void SuppressDivider() - { - // nop, used only by C# - } - - public void EmitUsingDirective(string directive) - { - // nop, used only by C# - } + // nop, used only by C# } } diff --git a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs index 5500485f..a79a2f43 100644 --- a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs @@ -6,417 +6,416 @@ using ClangSharp.Abstractions; using ClangSharp.CSharp; -namespace ClangSharp.XML +namespace ClangSharp.XML; + +internal partial class XmlOutputBuilder { - internal partial class XmlOutputBuilder + private readonly StringBuilder _sb = new(); + public void BeginInnerValue() => _sb.Append(""); + public void EndInnerValue() => _sb.Append(""); + + public void BeginInnerCast() => _sb.Append(""); + public void WriteCastType(string targetTypeName) => _sb.Append(targetTypeName); + public void EndInnerCast() => _sb.Append(""); + + public void BeginUnchecked() { - private readonly StringBuilder _sb = new(); - public void BeginInnerValue() => _sb.Append(""); - public void EndInnerValue() => _sb.Append(""); + Debug.Assert(!IsUncheckedContext); + _ = _sb.Append(""); + IsUncheckedContext = true; + } - public void BeginInnerCast() => _sb.Append(""); - public void WriteCastType(string targetTypeName) => _sb.Append(targetTypeName); - public void EndInnerCast() => _sb.Append(""); + public void EndUnchecked() + { + Debug.Assert(IsUncheckedContext); + _ = _sb.Append(""); + IsUncheckedContext = false; + } - public void BeginUnchecked() + public void BeginValue(in ValueDesc desc) + { + if (desc.Kind == ValueKind.Enumerator) { - Debug.Assert(!IsUncheckedContext); - _ = _sb.Append(""); - IsUncheckedContext = true; + _ = _sb.Append(""); - IsUncheckedContext = false; + _ = _sb.Append(""); + _ = _sb.Append($" name=\"{desc.EscapedName}\" access=\"{desc.AccessSpecifier.AsString()}\">"); - desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - _ = _sb.Append($""); - _ = _sb.Append(EscapeText(desc.TypeName)); - _ = _sb.Append(""); + desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); + _ = _sb.Append($""); + _ = _sb.Append(EscapeText(desc.TypeName)); + _ = _sb.Append(""); - if (desc.HasInitializer) - { - _ = _sb.Append(""); - } + if (desc.HasInitializer) + { + _ = _sb.Append(""); } + } - public void WriteConstantValue(long value) => _sb.Append(value); - public void WriteConstantValue(ulong value) => _sb.Append(value); + public void WriteConstantValue(long value) => _sb.Append(value); + public void WriteConstantValue(ulong value) => _sb.Append(value); - public void EndValue(in ValueDesc desc) + public void EndValue(in ValueDesc desc) + { + if (desc.HasInitializer) { - if (desc.HasInitializer) - { - _ = _sb.Append(""); - } - - if (desc.Kind == ValueKind.Enumerator) - { - _ = _sb.Append(""); - } - else if (desc.IsConstant) - { - _ = _sb.Append(""); - } - else - { - _ = _sb.Append(""); - } + _ = _sb.Append(""); } - public void BeginEnum(in EnumDesc desc) + if (desc.Kind == ValueKind.Enumerator) { - _ = _sb.Append($""); - desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - _ = _sb.Append($"{desc.TypeName}"); + _ = _sb.Append(""); } + else if (desc.IsConstant) + { + _ = _sb.Append(""); + } + else + { + _ = _sb.Append(""); + } + } + + public void BeginEnum(in EnumDesc desc) + { + _ = _sb.Append($""); + desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); + _ = _sb.Append($"{desc.TypeName}"); + } - public void EndEnum(in EnumDesc desc) => _sb.Append(""); + public void EndEnum(in EnumDesc desc) => _sb.Append(""); - public void BeginField(in FieldDesc desc) + public void BeginField(in FieldDesc desc) + { + _ = _sb.Append($"'); - desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - _ = _sb.Append("'); + desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); + _ = _sb.Append(" _sb.Append($" count=\"{count}\" fixed=\"{fixedName}\">" + - $"{EscapeText(typeName)}"); + public void WriteFixedCountField(string typeName, string escapedName, string fixedName, string count) + => _sb.Append($" count=\"{count}\" fixed=\"{fixedName}\">" + + $"{EscapeText(typeName)}"); - public void WriteRegularField(string typeName, string escapedName) - => _sb.Append($">{EscapeText(typeName)}"); - public void EndField(in FieldDesc desc) => _sb.Append(""); - public void BeginFunctionOrDelegate(in FunctionOrDelegateDesc desc, ref bool isMethodClassUnsafe) + public void WriteRegularField(string typeName, string escapedName) + => _sb.Append($">{EscapeText(typeName)}"); + public void EndField(in FieldDesc desc) => _sb.Append(""); + public void BeginFunctionOrDelegate(in FunctionOrDelegateDesc desc, ref bool isMethodClassUnsafe) + { + if (desc.IsVirtual) { - if (desc.IsVirtual) + Debug.Assert(!desc.HasFnPtrCodeGen); + _ = _sb.Append($"'); - - desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); - - _ = _sb.Append("'); - _ = _sb.Append(EscapeText(desc.ReturnType)); - _ = _sb.Append(""); } - - public void BeginFunctionInnerPrototype(in FunctionOrDelegateDesc info) + else { - // nop, only used in C# + _ = _sb.Append($""); - info.WriteCustomAttrs?.Invoke(info.CustomAttrGeneratorData); - _ = _sb.Append(""); - _ = _sb.Append(EscapeText(info.Type)); - _ = _sb.Append(""); + _ = _sb.Append(" static=\"true\""); } - public void BeginParameterDefault() => _ = _sb.Append(""); - - public void EndParameterDefault() => _ = _sb.Append(""); - - public void EndParameter(in ParameterDesc info) => _ = _sb.Append(""); - - public void WriteParameterSeparator() + if (desc.IsUnsafe) { - // nop, used only in C# + _ = _sb.Append(" unsafe=\"true\""); } - public void EndFunctionInnerPrototype(in FunctionOrDelegateDesc info) - { - // nop, used only in C# - } + var vtblIndex = desc.VtblIndex ?? -1; - public void BeginBody(bool isExpressionBody = false) + if (vtblIndex != -1) { - // nop, used only by C# + _ = _sb.Append($" vtblindex=\"{vtblIndex}\""); } - public void BeginConstructorInitializers() + _ = _sb.Append('>'); + + desc.WriteCustomAttrs?.Invoke(desc.CustomAttrGeneratorData); + + _ = _sb.Append(" - // "hint" is the name we're initializing using, but should only be used as a "hint" rather than a definitive - // value, which is contained within the init block. - _ = _sb.Append($""); + _ = _sb.Append('>'); + _ = _sb.Append(EscapeText(desc.ReturnType)); + _ = _sb.Append(""); + } - public void EndConstructorInitializer() => _sb.Append(""); + public void BeginFunctionInnerPrototype(in FunctionOrDelegateDesc info) + { + // nop, only used in C# + } - public void EndConstructorInitializers() - { - // nop, method only exists for consistency and/or future use - } + public void BeginParameter(in ParameterDesc info) + { + _ = _sb.Append($""); + info.WriteCustomAttrs?.Invoke(info.CustomAttrGeneratorData); + _ = _sb.Append(""); + _ = _sb.Append(EscapeText(info.Type)); + _ = _sb.Append(""); + } - public void BeginInnerFunctionBody() => _ = _sb.Append(""); + public void BeginParameterDefault() => _ = _sb.Append(""); - public void EndInnerFunctionBody() => _ = _sb.Append(""); + public void EndParameterDefault() => _ = _sb.Append(""); - public void EndBody(bool isExpressionBody = false) - { - // nop, used only by C# - } + public void EndParameter(in ParameterDesc info) => _ = _sb.Append(""); - public void EndFunctionOrDelegate(in FunctionOrDelegateDesc desc) - => _sb.Append(desc.IsVirtual ? "" : ""); + public void WriteParameterSeparator() + { + // nop, used only in C# + } - public void BeginStruct(in StructDesc info) - { - _ = _sb.Append(" + // "hint" is the name we're initializing using, but should only be used as a "hint" rather than a definitive + // value, which is contained within the init block. + _ = _sb.Append($""); - if (info.IsUnsafe) - { - _ = _sb.Append(" unsafe=\"true\""); - } + public void EndConstructorInitializer() => _sb.Append(""); - if (info.LayoutAttribute is not null) - { - _ = _sb.Append(" layout=\""); - _ = _sb.Append(info.LayoutAttribute.Value); - _ = _sb.Append('"'); + public void EndConstructorInitializers() + { + // nop, method only exists for consistency and/or future use + } - if (info.LayoutAttribute.Pack != 0) - { - _ = _sb.Append(" pack=\""); - _ = _sb.Append(info.LayoutAttribute.Pack); - _ = _sb.Append('"'); - } - } + public void BeginInnerFunctionBody() => _ = _sb.Append(""); - _ = _sb.Append('>'); - info.WriteCustomAttrs?.Invoke(info.CustomAttrGeneratorData); - } - public void BeginMarkerInterface(string[] baseTypeNames) => _sb.Append(""); - public void EndMarkerInterface() => _sb.Append(""); - public void BeginExplicitVtbl() => _sb.Append(""); - public void EndExplicitVtbl() => _sb.Append(""); + public void EndInnerFunctionBody() => _ = _sb.Append(""); - public void EndStruct(in StructDesc info) => _sb.Append(""); + public void EndBody(bool isExpressionBody = false) + { + // nop, used only by C# + } - public void EmitCompatibleCodeSupport() + public void EndFunctionOrDelegate(in FunctionOrDelegateDesc desc) + => _sb.Append(desc.IsVirtual ? "" : ""); + + public void BeginStruct(in StructDesc info) + { + _ = _sb.Append(""); - return new CSharpOutputBuilder("__Internal", _config, markerMode: MarkerMode.Xml); + _ = _sb.Append(" vtbl=\"true\""); } - public void EndCSharpCode(CSharpOutputBuilder output) + if (info.IsUnsafe) { - output.WritePendingLine(); + _ = _sb.Append(" unsafe=\"true\""); + } - var needsNewline = false; + if (info.LayoutAttribute is not null) + { + _ = _sb.Append(" layout=\""); + _ = _sb.Append(info.LayoutAttribute.Value); + _ = _sb.Append('"'); - foreach (var s in output.Contents) + if (info.LayoutAttribute.Pack != 0) { - if (needsNewline) - { - _ = _sb.Append('\n'); - } + _ = _sb.Append(" pack=\""); + _ = _sb.Append(info.LayoutAttribute.Pack); + _ = _sb.Append('"'); + } + } - _ = _sb.Append(EscapeText(s).Replace("/*M*/<", "<") - .Replace("/*M*/>", ">")); + _ = _sb.Append('>'); + info.WriteCustomAttrs?.Invoke(info.CustomAttrGeneratorData); + } + public void BeginMarkerInterface(string[] baseTypeNames) => _sb.Append(""); + public void EndMarkerInterface() => _sb.Append(""); + public void BeginExplicitVtbl() => _sb.Append(""); + public void EndExplicitVtbl() => _sb.Append(""); - needsNewline = true; - } + public void EndStruct(in StructDesc info) => _sb.Append(""); - _ = _sb.Append(""); - } + public void EmitCompatibleCodeSupport() + { + // nop, used only by C# + } - public void BeginGetter(bool aggressivelyInlined) - { - _ = _sb.Append("'); - } + public void EmitSystemSupport() + { + // nop, used only by C# + } + + public CSharpOutputBuilder BeginCSharpCode() + { + _ = _sb.Append(""); + return new CSharpOutputBuilder("__Internal", _config, markerMode: MarkerMode.Xml); + } + + public void EndCSharpCode(CSharpOutputBuilder output) + { + output.WritePendingLine(); - public void EndGetter() => _ = _sb.Append(""); + var needsNewline = false; - public void BeginSetter(bool aggressivelyInlined) + foreach (var s in output.Contents) { - _ = _sb.Append("'); + _ = _sb.Append(EscapeText(s).Replace("/*M*/<", "<") + .Replace("/*M*/>", ">")); + + needsNewline = true; } - public void EndSetter() => _ = _sb.Append(""); + _ = _sb.Append(""); + } - public void BeginIndexer(AccessSpecifier accessSpecifier, bool isUnsafe, bool needsUnscopedRef) + public void BeginGetter(bool aggressivelyInlined) + { + _ = _sb.Append("" : "\">"); + _ = _sb.Append(" inlining=\"aggressive\""); } - public void WriteIndexer(string typeName) - { - _ = _sb.Append(""); - _ = _sb.Append(EscapeText(typeName)); - _ = _sb.Append(""); - } + _ = _sb.Append('>'); + } - public void BeginIndexerParameters() - { - // nop, used only by C# - } + public void EndGetter() => _ = _sb.Append(""); - public void EndIndexerParameters() + public void BeginSetter(bool aggressivelyInlined) + { + _ = _sb.Append(" _sb.Append(""); + _ = _sb.Append('>'); + } - public void BeginDereference() => _sb.Append(""); + public void EndSetter() => _ = _sb.Append(""); - public void EndDereference() => _sb.Append(""); + public void BeginIndexer(AccessSpecifier accessSpecifier, bool isUnsafe, bool needsUnscopedRef) + { + _ = _sb.Append("" : "\">"); } + + public void WriteIndexer(string typeName) + { + _ = _sb.Append(""); + _ = _sb.Append(EscapeText(typeName)); + _ = _sb.Append(""); + } + + public void BeginIndexerParameters() + { + // nop, used only by C# + } + + public void EndIndexerParameters() + { + // nop, used only by C# + } + + public void EndIndexer() => _sb.Append(""); + + public void BeginDereference() => _sb.Append(""); + + public void EndDereference() => _sb.Append(""); } diff --git a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.cs b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.cs index deab2de0..8561c4d1 100644 --- a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.cs +++ b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.cs @@ -6,48 +6,47 @@ using System.Xml.Linq; using ClangSharp.Abstractions; -namespace ClangSharp.XML +namespace ClangSharp.XML; + +internal partial class XmlOutputBuilder : IOutputBuilder { - internal partial class XmlOutputBuilder : IOutputBuilder - { - private readonly PInvokeGeneratorConfiguration _config; + private readonly PInvokeGeneratorConfiguration _config; - public XmlOutputBuilder(string name, PInvokeGeneratorConfiguration config) - { - Name = name; - _config = config; - } + public XmlOutputBuilder(string name, PInvokeGeneratorConfiguration config) + { + Name = name; + _config = config; + } - public string Name { get; } - public string Extension { get; } = ".xml"; + public string Name { get; } + public string Extension { get; } = ".xml"; - public bool IsUncheckedContext { get; private set; } + public bool IsUncheckedContext { get; private set; } - public bool IsTestOutput { get; } = false; + public bool IsTestOutput { get; } = false; - public IEnumerable Contents + public IEnumerable Contents + { + get { - get + StringWriter sw = new(); + var writer = XmlWriter.Create(sw, new() + { + Indent = true, + IndentChars = " ", + ConformanceLevel = ConformanceLevel.Fragment, + NewLineChars = "\n", + }); + + foreach (var node in XElement.Parse("" + _sb + "").Nodes()) { - StringWriter sw = new(); - var writer = XmlWriter.Create(sw, new() - { - Indent = true, - IndentChars = " ", - ConformanceLevel = ConformanceLevel.Fragment, - NewLineChars = "\n", - }); - - foreach (var node in XElement.Parse("" + _sb + "").Nodes()) - { - node.WriteTo(writer); - } - - writer.Flush(); - return sw.ToString().Split('\n'); + node.WriteTo(writer); } - } - private static string EscapeText(string value) => new XText(value).ToString(); + writer.Flush(); + return sw.ToString().Split('\n'); + } } + + private static string EscapeText(string value) => new XText(value).ToString(); } diff --git a/sources/ClangSharp/Cursors/Attrs/Attr.cs b/sources/ClangSharp/Cursors/Attrs/Attr.cs index f85666e4..c2079d38 100644 --- a/sources/ClangSharp/Cursors/Attrs/Attr.cs +++ b/sources/ClangSharp/Cursors/Attrs/Attr.cs @@ -3,377 +3,376 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class Attr : Cursor { - public class Attr : Cursor + private protected Attr(CXCursor handle) : base(handle, handle.Kind) { - private protected Attr(CXCursor handle) : base(handle, handle.Kind) + if (handle.AttrKind == CX_AttrKind.CX_AttrKind_Invalid) { - if (handle.AttrKind == CX_AttrKind.CX_AttrKind_Invalid) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } + } - internal static new Attr Create(CXCursor handle) => handle.AttrKind switch { - CX_AttrKind.CX_AttrKind_Invalid => new Attr(handle), - CX_AttrKind.CX_AttrKind_AddressSpace => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_ArmMveStrictPolymorphism => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_BTFTypeTag => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_CmseNSCall => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_NoDeref => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCGC => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCInertUnsafeUnretained => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCKindOf => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLConstantAddressSpace => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLGenericAddressSpace => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLGlobalAddressSpace => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLGlobalDeviceAddressSpace => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLGlobalHostAddressSpace => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLLocalAddressSpace => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLPrivateAddressSpace => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_Ptr32 => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_Ptr64 => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_SPtr => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_TypeNonNull => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_TypeNullUnspecified => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_TypeNullable => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_TypeNullableResult => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_UPtr => new TypeAttr(handle), - CX_AttrKind.CX_AttrKind_FallThrough => new StmtAttr(handle), - CX_AttrKind.CX_AttrKind_Likely => new StmtAttr(handle), - CX_AttrKind.CX_AttrKind_MustTail => new StmtAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLUnrollHint => new StmtAttr(handle), - CX_AttrKind.CX_AttrKind_Suppress => new StmtAttr(handle), - CX_AttrKind.CX_AttrKind_Unlikely => new StmtAttr(handle), - CX_AttrKind.CX_AttrKind_NoMerge => new DeclOrStmtAttr(handle), - CX_AttrKind.CX_AttrKind_AArch64VectorPcs => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AcquireHandle => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AnyX86NoCfCheck => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CDecl => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_FastCall => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_IntelOclBicc => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_LifetimeBound => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MSABI => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NSReturnsRetained => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCOwnership => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Pascal => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Pcs => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PreserveAll => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PreserveMost => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_RegCall => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_StdCall => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftAsyncCall => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftCall => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SysVABI => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ThisCall => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_VectorCall => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftAsyncContext => new ParameterABIAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftContext => new ParameterABIAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftErrorResult => new ParameterABIAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftIndirectResult => new ParameterABIAttr(handle), - CX_AttrKind.CX_AttrKind_Annotate => new InheritableParamAttr(handle), - CX_AttrKind.CX_AttrKind_CFConsumed => new InheritableParamAttr(handle), - CX_AttrKind.CX_AttrKind_CarriesDependency => new InheritableParamAttr(handle), - CX_AttrKind.CX_AttrKind_NSConsumed => new InheritableParamAttr(handle), - CX_AttrKind.CX_AttrKind_NonNull => new InheritableParamAttr(handle), - CX_AttrKind.CX_AttrKind_OSConsumed => new InheritableParamAttr(handle), - CX_AttrKind.CX_AttrKind_PassObjectSize => new InheritableParamAttr(handle), - CX_AttrKind.CX_AttrKind_ReleaseHandle => new InheritableParamAttr(handle), - CX_AttrKind.CX_AttrKind_UseHandle => new InheritableParamAttr(handle), - CX_AttrKind.CX_AttrKind_AMDGPUFlatWorkGroupSize => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AMDGPUNumSGPR => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AMDGPUNumVGPR => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AMDGPUWavesPerEU => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ARMInterrupt => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AVRInterrupt => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AVRSignal => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AcquireCapability => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AcquiredAfter => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AcquiredBefore => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AlignMac68k => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AlignNatural => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Aligned => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AllocAlign => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AllocSize => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AlwaysDestroy => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AlwaysInline => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AnalyzerNoReturn => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AnyX86Interrupt => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AnyX86NoCallerSavedRegisters => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ArcWeakrefUnavailable => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ArgumentWithTypeTag => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ArmBuiltinAlias => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Artificial => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AsmLabel => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AssertCapability => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AssertExclusiveLock => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AssertSharedLock => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AssumeAligned => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Assumption => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Availability => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_BPFPreserveAccessIndex => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_BTFDeclTag => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Blocks => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Builtin => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_C11NoReturn => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CFAuditedTransfer => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CFGuard => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CFICanonicalJumpTable => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CFReturnsNotRetained => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CFReturnsRetained => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CFUnknownTransfer => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CPUDispatch => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CPUSpecific => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CUDAConstant => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CUDADevice => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CUDADeviceBuiltinSurfaceType => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CUDADeviceBuiltinTextureType => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CUDAGlobal => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CUDAHost => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CUDAInvalidTarget => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CUDALaunchBounds => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CUDAShared => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CXX11NoReturn => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CallableWhen => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Callback => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Capability => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CapturedRecord => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Cleanup => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CmseNSEntry => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_CodeSeg => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Cold => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Common => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Const => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ConstInit => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Constructor => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Consumable => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ConsumableAutoCast => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ConsumableSetOnRead => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Convergent => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_DLLExport => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_DLLExportStaticLocal => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_DLLImport => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_DLLImportStaticLocal => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Deprecated => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Destructor => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_DiagnoseAsBuiltin => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_DiagnoseIf => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_DisableSanitizerInstrumentation => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_DisableTailCalls => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_EmptyBases => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_EnableIf => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_EnforceTCB => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_EnforceTCBLeaf => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_EnumExtensibility => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Error => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ExcludeFromExplicitInstantiation => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ExclusiveTrylockFunction => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ExternalSourceSymbol => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Final => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_FlagEnum => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Flatten => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Format => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_FormatArg => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_GNUInline => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_GuardedBy => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_GuardedVar => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_HIPManaged => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Hot => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_IBAction => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_IBOutlet => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_IBOutletCollection => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_InitPriority => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_InternalLinkage => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_LTOVisibilityPublic => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_LayoutVersion => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Leaf => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_LockReturned => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_LocksExcluded => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_M68kInterrupt => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MIGServerRoutine => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MSAllocator => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MSInheritance => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MSNoVTable => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MSP430Interrupt => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MSStruct => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MSVtorDisp => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MaxFieldAlignment => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MayAlias => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MicroMips => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MinSize => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MinVectorWidth => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Mips16 => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MipsInterrupt => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MipsLongCall => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_MipsShortCall => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NSConsumesSelf => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NSErrorDomain => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NSReturnsAutoreleased => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NSReturnsNotRetained => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Naked => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoAlias => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoCommon => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoDebug => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoDestroy => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoDuplicate => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoInline => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoInstrumentFunction => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoMicroMips => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoMips16 => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoProfileFunction => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoReturn => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoSanitize => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoSpeculativeLoadHardening => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoSplitStack => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoStackProtector => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoThreadSafetyAnalysis => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoThrow => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NoUniqueAddress => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_NotTailCalled => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OMPAllocateDecl => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OMPCaptureNoInit => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OMPDeclareTargetDecl => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OMPDeclareVariant => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OMPThreadPrivateDecl => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OSConsumesThis => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OSReturnsNotRetained => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OSReturnsRetained => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnNonZero => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnZero => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCBridge => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCBridgeMutable => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCBridgeRelated => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCException => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCExplicitProtocolImpl => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCExternallyRetained => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCIndependentClass => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCMethodFamily => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCNSObject => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCPreciseLifetime => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCRequiresPropertyDefs => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCRequiresSuper => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCReturnsInnerPointer => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCRootClass => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ObjCSubclassingRestricted => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLIntelReqdSubGroupSize => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OpenCLKernel => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_OptimizeNone => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Override => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Owner => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Ownership => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Packed => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ParamTypestate => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PatchableFunctionEntry => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Pointer => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PragmaClangBSSSection => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PragmaClangDataSection => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PragmaClangRelroSection => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PragmaClangRodataSection => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PragmaClangTextSection => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PreferredName => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PtGuardedBy => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_PtGuardedVar => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Pure => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_RISCVInterrupt => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Reinitializes => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ReleaseCapability => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ReqdWorkGroupSize => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_RequiresCapability => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Restrict => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Retain => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ReturnTypestate => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ReturnsNonNull => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ReturnsTwice => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SYCLKernel => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SYCLSpecialClass => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_ScopedLockable => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Section => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SelectAny => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Sentinel => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SetTypestate => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SharedTrylockFunction => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SpeculativeLoadHardening => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_StandaloneDebug => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_StrictFP => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftAsync => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftAsyncError => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftAsyncName => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftAttr => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftBridge => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftBridgedTypedef => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftError => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftName => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftNewType => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_SwiftPrivate => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_TLSModel => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Target => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_TargetClones => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_TestTypestate => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_TransparentUnion => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_TrivialABI => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_TryAcquireCapability => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_TypeTagForDatatype => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_TypeVisibility => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Unavailable => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Uninitialized => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Unused => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Used => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_UsingIfExists => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Uuid => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_VecReturn => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_VecTypeHint => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Visibility => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_WarnUnused => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_WarnUnusedResult => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_Weak => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_WeakImport => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_WeakRef => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_WebAssemblyExportName => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_WebAssemblyImportModule => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_WebAssemblyImportName => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_WorkGroupSizeHint => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_X86ForceAlignArgPointer => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_XRayInstrument => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_XRayLogArgs => new InheritableAttr(handle), - CX_AttrKind.CX_AttrKind_AbiTag => new Attr(handle), - CX_AttrKind.CX_AttrKind_Alias => new Attr(handle), - CX_AttrKind.CX_AttrKind_AlignValue => new Attr(handle), - CX_AttrKind.CX_AttrKind_BuiltinAlias => new Attr(handle), - CX_AttrKind.CX_AttrKind_CalledOnce => new Attr(handle), - CX_AttrKind.CX_AttrKind_IFunc => new Attr(handle), - CX_AttrKind.CX_AttrKind_InitSeg => new Attr(handle), - CX_AttrKind.CX_AttrKind_LoaderUninitialized => new Attr(handle), - CX_AttrKind.CX_AttrKind_LoopHint => new Attr(handle), - CX_AttrKind.CX_AttrKind_Mode => new Attr(handle), - CX_AttrKind.CX_AttrKind_NoBuiltin => new Attr(handle), - CX_AttrKind.CX_AttrKind_NoEscape => new Attr(handle), - CX_AttrKind.CX_AttrKind_OMPCaptureKind => new Attr(handle), - CX_AttrKind.CX_AttrKind_OMPDeclareSimdDecl => new Attr(handle), - CX_AttrKind.CX_AttrKind_OMPReferencedVar => new Attr(handle), - CX_AttrKind.CX_AttrKind_ObjCBoxable => new Attr(handle), - CX_AttrKind.CX_AttrKind_ObjCClassStub => new Attr(handle), - CX_AttrKind.CX_AttrKind_ObjCDesignatedInitializer => new Attr(handle), - CX_AttrKind.CX_AttrKind_ObjCDirect => new Attr(handle), - CX_AttrKind.CX_AttrKind_ObjCDirectMembers => new Attr(handle), - CX_AttrKind.CX_AttrKind_ObjCNonLazyClass => new Attr(handle), - CX_AttrKind.CX_AttrKind_ObjCNonRuntimeProtocol => new Attr(handle), - CX_AttrKind.CX_AttrKind_ObjCRuntimeName => new Attr(handle), - CX_AttrKind.CX_AttrKind_ObjCRuntimeVisible => new Attr(handle), - CX_AttrKind.CX_AttrKind_OpenCLAccess => new Attr(handle), - CX_AttrKind.CX_AttrKind_Overloadable => new Attr(handle), - CX_AttrKind.CX_AttrKind_RenderScriptKernel => new Attr(handle), - CX_AttrKind.CX_AttrKind_SwiftObjCMembers => new Attr(handle), - CX_AttrKind.CX_AttrKind_Thread => new Attr(handle), - _ => new Attr(handle), - }; + internal static new Attr Create(CXCursor handle) => handle.AttrKind switch { + CX_AttrKind.CX_AttrKind_Invalid => new Attr(handle), + CX_AttrKind.CX_AttrKind_AddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_ArmMveStrictPolymorphism => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_BTFTypeTag => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_CmseNSCall => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_NoDeref => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCGC => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCInertUnsafeUnretained => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCKindOf => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLConstantAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLGenericAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLGlobalAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLGlobalDeviceAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLGlobalHostAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLLocalAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLPrivateAddressSpace => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_Ptr32 => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_Ptr64 => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_SPtr => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_TypeNonNull => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_TypeNullUnspecified => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_TypeNullable => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_TypeNullableResult => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_UPtr => new TypeAttr(handle), + CX_AttrKind.CX_AttrKind_FallThrough => new StmtAttr(handle), + CX_AttrKind.CX_AttrKind_Likely => new StmtAttr(handle), + CX_AttrKind.CX_AttrKind_MustTail => new StmtAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLUnrollHint => new StmtAttr(handle), + CX_AttrKind.CX_AttrKind_Suppress => new StmtAttr(handle), + CX_AttrKind.CX_AttrKind_Unlikely => new StmtAttr(handle), + CX_AttrKind.CX_AttrKind_NoMerge => new DeclOrStmtAttr(handle), + CX_AttrKind.CX_AttrKind_AArch64VectorPcs => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AcquireHandle => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AnyX86NoCfCheck => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CDecl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_FastCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_IntelOclBicc => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LifetimeBound => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSABI => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NSReturnsRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCOwnership => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Pascal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Pcs => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PreserveAll => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PreserveMost => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_RegCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_StdCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftAsyncCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SysVABI => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ThisCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_VectorCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftAsyncContext => new ParameterABIAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftContext => new ParameterABIAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftErrorResult => new ParameterABIAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftIndirectResult => new ParameterABIAttr(handle), + CX_AttrKind.CX_AttrKind_Annotate => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_CFConsumed => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_CarriesDependency => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_NSConsumed => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_NonNull => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_OSConsumed => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_PassObjectSize => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_ReleaseHandle => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_UseHandle => new InheritableParamAttr(handle), + CX_AttrKind.CX_AttrKind_AMDGPUFlatWorkGroupSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AMDGPUNumSGPR => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AMDGPUNumVGPR => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AMDGPUWavesPerEU => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ARMInterrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AVRInterrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AVRSignal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AcquireCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AcquiredAfter => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AcquiredBefore => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AlignMac68k => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AlignNatural => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Aligned => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AllocAlign => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AllocSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AlwaysDestroy => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AlwaysInline => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AnalyzerNoReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AnyX86Interrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AnyX86NoCallerSavedRegisters => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ArcWeakrefUnavailable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ArgumentWithTypeTag => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ArmBuiltinAlias => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Artificial => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AsmLabel => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AssertCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AssertExclusiveLock => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AssertSharedLock => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AssumeAligned => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Assumption => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Availability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_BPFPreserveAccessIndex => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_BTFDeclTag => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Blocks => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Builtin => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_C11NoReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFAuditedTransfer => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFGuard => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFICanonicalJumpTable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFReturnsNotRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFReturnsRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CFUnknownTransfer => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CPUDispatch => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CPUSpecific => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAConstant => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDADevice => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDADeviceBuiltinSurfaceType => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDADeviceBuiltinTextureType => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAGlobal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAHost => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAInvalidTarget => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDALaunchBounds => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CUDAShared => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CXX11NoReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CallableWhen => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Callback => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Capability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CapturedRecord => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Cleanup => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CmseNSEntry => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_CodeSeg => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Cold => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Common => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Const => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ConstInit => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Constructor => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Consumable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ConsumableAutoCast => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ConsumableSetOnRead => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Convergent => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DLLExport => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DLLExportStaticLocal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DLLImport => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DLLImportStaticLocal => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Deprecated => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Destructor => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DiagnoseAsBuiltin => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DiagnoseIf => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DisableSanitizerInstrumentation => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_DisableTailCalls => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_EmptyBases => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_EnableIf => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_EnforceTCB => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_EnforceTCBLeaf => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_EnumExtensibility => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Error => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ExcludeFromExplicitInstantiation => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ExclusiveTrylockFunction => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ExternalSourceSymbol => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Final => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_FlagEnum => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Flatten => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Format => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_FormatArg => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_GNUInline => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_GuardedBy => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_GuardedVar => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_HIPManaged => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Hot => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_IBAction => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_IBOutlet => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_IBOutletCollection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_InitPriority => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_InternalLinkage => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LTOVisibilityPublic => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LayoutVersion => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Leaf => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LockReturned => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_LocksExcluded => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_M68kInterrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MIGServerRoutine => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSAllocator => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSInheritance => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSNoVTable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSP430Interrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSStruct => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MSVtorDisp => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MaxFieldAlignment => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MayAlias => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MicroMips => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MinSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MinVectorWidth => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Mips16 => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MipsInterrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MipsLongCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_MipsShortCall => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NSConsumesSelf => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NSErrorDomain => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NSReturnsAutoreleased => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NSReturnsNotRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Naked => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoAlias => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoCommon => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoDebug => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoDestroy => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoDuplicate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoInline => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoInstrumentFunction => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoMicroMips => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoMips16 => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoProfileFunction => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoSanitize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoSpeculativeLoadHardening => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoSplitStack => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoStackProtector => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoThreadSafetyAnalysis => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoThrow => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NoUniqueAddress => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_NotTailCalled => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OMPAllocateDecl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OMPCaptureNoInit => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OMPDeclareTargetDecl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OMPDeclareVariant => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OMPThreadPrivateDecl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSConsumesThis => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSReturnsNotRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSReturnsRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnNonZero => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OSReturnsRetainedOnZero => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCBridge => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCBridgeMutable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCBridgeRelated => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCException => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCExplicitProtocolImpl => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCExternallyRetained => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCIndependentClass => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCMethodFamily => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCNSObject => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCPreciseLifetime => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCRequiresPropertyDefs => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCRequiresSuper => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCReturnsInnerPointer => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCRootClass => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ObjCSubclassingRestricted => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLIntelReqdSubGroupSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OpenCLKernel => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_OptimizeNone => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Override => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Owner => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Ownership => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Packed => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ParamTypestate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PatchableFunctionEntry => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Pointer => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PragmaClangBSSSection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PragmaClangDataSection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PragmaClangRelroSection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PragmaClangRodataSection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PragmaClangTextSection => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PreferredName => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PtGuardedBy => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_PtGuardedVar => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Pure => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_RISCVInterrupt => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Reinitializes => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReleaseCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReqdWorkGroupSize => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_RequiresCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Restrict => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Retain => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReturnTypestate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReturnsNonNull => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ReturnsTwice => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SYCLKernel => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SYCLSpecialClass => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_ScopedLockable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Section => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SelectAny => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Sentinel => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SetTypestate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SharedTrylockFunction => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SpeculativeLoadHardening => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_StandaloneDebug => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_StrictFP => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftAsync => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftAsyncError => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftAsyncName => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftAttr => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftBridge => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftBridgedTypedef => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftError => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftName => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftNewType => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_SwiftPrivate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TLSModel => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Target => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TargetClones => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TestTypestate => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TransparentUnion => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TrivialABI => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TryAcquireCapability => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TypeTagForDatatype => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_TypeVisibility => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Unavailable => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Uninitialized => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Unused => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Used => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_UsingIfExists => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Uuid => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_VecReturn => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_VecTypeHint => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Visibility => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WarnUnused => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WarnUnusedResult => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_Weak => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WeakImport => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WeakRef => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WebAssemblyExportName => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WebAssemblyImportModule => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WebAssemblyImportName => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_WorkGroupSizeHint => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_X86ForceAlignArgPointer => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_XRayInstrument => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_XRayLogArgs => new InheritableAttr(handle), + CX_AttrKind.CX_AttrKind_AbiTag => new Attr(handle), + CX_AttrKind.CX_AttrKind_Alias => new Attr(handle), + CX_AttrKind.CX_AttrKind_AlignValue => new Attr(handle), + CX_AttrKind.CX_AttrKind_BuiltinAlias => new Attr(handle), + CX_AttrKind.CX_AttrKind_CalledOnce => new Attr(handle), + CX_AttrKind.CX_AttrKind_IFunc => new Attr(handle), + CX_AttrKind.CX_AttrKind_InitSeg => new Attr(handle), + CX_AttrKind.CX_AttrKind_LoaderUninitialized => new Attr(handle), + CX_AttrKind.CX_AttrKind_LoopHint => new Attr(handle), + CX_AttrKind.CX_AttrKind_Mode => new Attr(handle), + CX_AttrKind.CX_AttrKind_NoBuiltin => new Attr(handle), + CX_AttrKind.CX_AttrKind_NoEscape => new Attr(handle), + CX_AttrKind.CX_AttrKind_OMPCaptureKind => new Attr(handle), + CX_AttrKind.CX_AttrKind_OMPDeclareSimdDecl => new Attr(handle), + CX_AttrKind.CX_AttrKind_OMPReferencedVar => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCBoxable => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCClassStub => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCDesignatedInitializer => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCDirect => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCDirectMembers => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCNonLazyClass => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCNonRuntimeProtocol => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCRuntimeName => new Attr(handle), + CX_AttrKind.CX_AttrKind_ObjCRuntimeVisible => new Attr(handle), + CX_AttrKind.CX_AttrKind_OpenCLAccess => new Attr(handle), + CX_AttrKind.CX_AttrKind_Overloadable => new Attr(handle), + CX_AttrKind.CX_AttrKind_RenderScriptKernel => new Attr(handle), + CX_AttrKind.CX_AttrKind_SwiftObjCMembers => new Attr(handle), + CX_AttrKind.CX_AttrKind_Thread => new Attr(handle), + _ => new Attr(handle), + }; - public bool IsImplicit => Handle.IsImplicit; + public bool IsImplicit => Handle.IsImplicit; - public bool IsPackExpansion => Handle.IsPackExpansion; + public bool IsPackExpansion => Handle.IsPackExpansion; - public CX_AttrKind Kind => Handle.AttrKind; + public CX_AttrKind Kind => Handle.AttrKind; - public string KindSpelling => Handle.AttrKindSpelling; - } + public string KindSpelling => Handle.AttrKindSpelling; } diff --git a/sources/ClangSharp/Cursors/Attrs/DeclOrStmtAttr.cs b/sources/ClangSharp/Cursors/Attrs/DeclOrStmtAttr.cs index 9fbfc0f6..33af0042 100644 --- a/sources/ClangSharp/Cursors/Attrs/DeclOrStmtAttr.cs +++ b/sources/ClangSharp/Cursors/Attrs/DeclOrStmtAttr.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DeclOrStmtAttr : InheritableAttr { - public sealed class DeclOrStmtAttr : InheritableAttr + internal DeclOrStmtAttr(CXCursor handle) : base(handle) { - internal DeclOrStmtAttr(CXCursor handle) : base(handle) + if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastDeclOrStmtAttr or < CX_AttrKind.CX_AttrKind_FirstDeclOrStmtAttr) { - if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastDeclOrStmtAttr or < CX_AttrKind.CX_AttrKind_FirstDeclOrStmtAttr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Attrs/InheritableAttr.cs b/sources/ClangSharp/Cursors/Attrs/InheritableAttr.cs index 15ffcdc5..24a411c5 100644 --- a/sources/ClangSharp/Cursors/Attrs/InheritableAttr.cs +++ b/sources/ClangSharp/Cursors/Attrs/InheritableAttr.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class InheritableAttr : Attr { - public class InheritableAttr : Attr + internal InheritableAttr(CXCursor handle) : base(handle) { - internal InheritableAttr(CXCursor handle) : base(handle) + if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastInheritableAttr or < CX_AttrKind.CX_AttrKind_FirstInheritableAttr) { - if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastInheritableAttr or < CX_AttrKind.CX_AttrKind_FirstInheritableAttr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Attrs/InheritableParamAttr.cs b/sources/ClangSharp/Cursors/Attrs/InheritableParamAttr.cs index 2d7cd605..34c932a8 100644 --- a/sources/ClangSharp/Cursors/Attrs/InheritableParamAttr.cs +++ b/sources/ClangSharp/Cursors/Attrs/InheritableParamAttr.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class InheritableParamAttr : InheritableAttr { - public class InheritableParamAttr : InheritableAttr + internal InheritableParamAttr(CXCursor handle) : base(handle) { - internal InheritableParamAttr(CXCursor handle) : base(handle) + if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastInheritableParamAttr or < CX_AttrKind.CX_AttrKind_FirstInheritableParamAttr) { - if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastInheritableParamAttr or < CX_AttrKind.CX_AttrKind_FirstInheritableParamAttr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Attrs/ParameterABIAttr.cs b/sources/ClangSharp/Cursors/Attrs/ParameterABIAttr.cs index b7b93c29..82b1841a 100644 --- a/sources/ClangSharp/Cursors/Attrs/ParameterABIAttr.cs +++ b/sources/ClangSharp/Cursors/Attrs/ParameterABIAttr.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ParameterABIAttr : InheritableParamAttr { - public sealed class ParameterABIAttr : InheritableParamAttr + internal ParameterABIAttr(CXCursor handle) : base(handle) { - internal ParameterABIAttr(CXCursor handle) : base(handle) + if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastParameterABIAttr or < CX_AttrKind.CX_AttrKind_FirstParameterABIAttr) { - if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastParameterABIAttr or < CX_AttrKind.CX_AttrKind_FirstParameterABIAttr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Attrs/StmtAttr.cs b/sources/ClangSharp/Cursors/Attrs/StmtAttr.cs index 0ea9b471..5436b899 100644 --- a/sources/ClangSharp/Cursors/Attrs/StmtAttr.cs +++ b/sources/ClangSharp/Cursors/Attrs/StmtAttr.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class StmtAttr : Attr { - public sealed class StmtAttr : Attr + internal StmtAttr(CXCursor handle) : base(handle) { - internal StmtAttr(CXCursor handle) : base(handle) + if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastStmtAttr or < CX_AttrKind.CX_AttrKind_FirstStmtAttr) { - if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastStmtAttr or < CX_AttrKind.CX_AttrKind_FirstStmtAttr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Attrs/TypeAttr.cs b/sources/ClangSharp/Cursors/Attrs/TypeAttr.cs index dd2ec35c..e33e34b2 100644 --- a/sources/ClangSharp/Cursors/Attrs/TypeAttr.cs +++ b/sources/ClangSharp/Cursors/Attrs/TypeAttr.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TypeAttr : Attr { - public sealed class TypeAttr : Attr + internal TypeAttr(CXCursor handle) : base(handle) { - internal TypeAttr(CXCursor handle) : base(handle) + if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastTypeAttr or < CX_AttrKind.CX_AttrKind_FirstTypeAttr) { - if (handle.AttrKind is > CX_AttrKind.CX_AttrKind_LastTypeAttr or < CX_AttrKind.CX_AttrKind_FirstTypeAttr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Cursor.cs b/sources/ClangSharp/Cursors/Cursor.cs index 5aa550b4..8ec6ea5a 100644 --- a/sources/ClangSharp/Cursors/Cursor.cs +++ b/sources/ClangSharp/Cursors/Cursor.cs @@ -7,138 +7,137 @@ using System.Runtime.InteropServices; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +[DebuggerDisplay("{Handle.DebuggerDisplayString,nq}")] +public unsafe class Cursor : IEquatable { - [DebuggerDisplay("{Handle.DebuggerDisplayString,nq}")] - public unsafe class Cursor : IEquatable + private readonly Lazy _kindSpelling; + private readonly Lazy _lexicalParentCursor; + private readonly Lazy _semanticParentCursor; + private readonly Lazy _spelling; + private readonly Lazy _translationUnit; + private List _cursorChildren; + + private protected Cursor(CXCursor handle, CXCursorKind expectedCursorKind) { - private readonly Lazy _kindSpelling; - private readonly Lazy _lexicalParentCursor; - private readonly Lazy _semanticParentCursor; - private readonly Lazy _spelling; - private readonly Lazy _translationUnit; - private List _cursorChildren; - - private protected Cursor(CXCursor handle, CXCursorKind expectedCursorKind) + if (handle.kind != expectedCursorKind) { - if (handle.kind != expectedCursorKind) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - Handle = handle; - - _kindSpelling = new Lazy(() => Handle.KindSpelling.ToString()); - _lexicalParentCursor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LexicalParent)); - _semanticParentCursor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SemanticParent)); - _spelling = new Lazy(() => Handle.Spelling.ToString()); - _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TranslationUnit)); + throw new ArgumentOutOfRangeException(nameof(handle)); } + Handle = handle; + + _kindSpelling = new Lazy(Handle.KindSpelling.ToString); + _lexicalParentCursor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LexicalParent)); + _semanticParentCursor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SemanticParent)); + _spelling = new Lazy(Handle.Spelling.ToString); + _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TranslationUnit)); + } - public IReadOnlyList CursorChildren + public IReadOnlyList CursorChildren + { + get { - get + if (_cursorChildren is null) { - if (_cursorChildren is null) - { - var cursorChildren = GCHandle.Alloc(new List()); + var cursorChildren = GCHandle.Alloc(new List()); #if !NET5_0_OR_GREATER - var visitor = (CXCursorVisitor)Visitor; - var pVisitor = Marshal.GetFunctionPointerForDelegate(visitor); + var visitor = (CXCursorVisitor)Visitor; + var pVisitor = Marshal.GetFunctionPointerForDelegate(visitor); #else - var pVisitor = (delegate* unmanaged[Cdecl])&Visitor; + var pVisitor = (delegate* unmanaged[Cdecl])&Visitor; #endif - var client_data = stackalloc nint[2] { - GCHandle.ToIntPtr(cursorChildren), - TranslationUnit.Handle.Handle - }; + var client_data = stackalloc nint[2] { + GCHandle.ToIntPtr(cursorChildren), + TranslationUnit.Handle.Handle + }; - _ = clang.visitChildren(Handle, (IntPtr)pVisitor, client_data); + _ = clang.visitChildren(Handle, (IntPtr)pVisitor, client_data); - _cursorChildren = (List)cursorChildren.Target; - cursorChildren.Free(); + _cursorChildren = (List)cursorChildren.Target; + cursorChildren.Free(); #if !NET5_0_OR_GREATER - GC.KeepAlive(visitor); + GC.KeepAlive(visitor); #else - [UnmanagedCallersOnly(CallConvs = new System.Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallersOnly(CallConvs = new System.Type[] { typeof(CallConvCdecl) })] #endif - static CXChildVisitResult Visitor(CXCursor cursor, CXCursor parent, void* client_data) - { - var cursorChildren = (List)GCHandle.FromIntPtr(((nint*)client_data)[0]).Target; - var translationUnit = TranslationUnit.GetOrCreate((CXTranslationUnitImpl*)((nint*)client_data)[1]); - - var cursorChild = translationUnit.GetOrCreate(cursor); - cursorChildren.Add(cursorChild); - return CXChildVisitResult.CXChildVisit_Continue; - } + static CXChildVisitResult Visitor(CXCursor cursor, CXCursor parent, void* client_data) + { + var cursorChildren = (List)GCHandle.FromIntPtr(((nint*)client_data)[0]).Target; + var translationUnit = TranslationUnit.GetOrCreate((CXTranslationUnitImpl*)((nint*)client_data)[1]); + + var cursorChild = translationUnit.GetOrCreate(cursor); + cursorChildren.Add(cursorChild); + return CXChildVisitResult.CXChildVisit_Continue; } - return _cursorChildren; } + return _cursorChildren; } + } - public CXCursorKind CursorKind => Handle.kind; - - public string CursorKindSpelling => _kindSpelling.Value; + public CXCursorKind CursorKind => Handle.kind; - public CXSourceRange Extent => Handle.Extent; + public string CursorKindSpelling => _kindSpelling.Value; - public CXCursor Handle { get; } + public CXSourceRange Extent => Handle.Extent; - public Cursor LexicalParentCursor => _lexicalParentCursor.Value; + public CXCursor Handle { get; } - public CXSourceLocation Location => Handle.Location; + public Cursor LexicalParentCursor => _lexicalParentCursor.Value; - public Cursor SemanticParentCursor => _semanticParentCursor.Value; + public CXSourceLocation Location => Handle.Location; - public string Spelling => _spelling.Value; + public Cursor SemanticParentCursor => _semanticParentCursor.Value; - public TranslationUnit TranslationUnit => _translationUnit.Value; + public string Spelling => _spelling.Value; - public static bool operator ==(Cursor left, Cursor right) => (left is object) ? ((right is object) && (left.Handle == right.Handle)) : (right is null); + public TranslationUnit TranslationUnit => _translationUnit.Value; - public static bool operator !=(Cursor left, Cursor right) => (left is object) ? ((right is null) || (left.Handle != right.Handle)) : (right is object); + public static bool operator ==(Cursor left, Cursor right) => (left is not null) ? ((right is not null) && (left.Handle == right.Handle)) : (right is null); - internal static Cursor Create(CXCursor handle) - { - Cursor result; + public static bool operator !=(Cursor left, Cursor right) => (left is not null) ? ((right is null) || (left.Handle != right.Handle)) : (right is not null); - if (handle.IsDeclaration || handle.IsTranslationUnit) - { - result = Decl.Create(handle); - } - else if (handle.IsReference) - { - result = Ref.Create(handle); - } - else if (handle.IsExpression || handle.IsStatement) - { - result = Stmt.Create(handle); - } - else if (handle.IsAttribute) - { - result = Attr.Create(handle); - } - else if (handle.IsPreprocessing) - { - result = PreprocessedEntity.Create(handle); - } - else - { - Debug.WriteLine($"Unhandled cursor kind: {handle.KindSpelling}."); - result = new Cursor(handle, handle.Kind); - } + internal static Cursor Create(CXCursor handle) + { + Cursor result; - return result; + if (handle.IsDeclaration || handle.IsTranslationUnit) + { + result = Decl.Create(handle); + } + else if (handle.IsReference) + { + result = Ref.Create(handle); + } + else if (handle.IsExpression || handle.IsStatement) + { + result = Stmt.Create(handle); + } + else if (handle.IsAttribute) + { + result = Attr.Create(handle); + } + else if (handle.IsPreprocessing) + { + result = PreprocessedEntity.Create(handle); + } + else + { + Debug.WriteLine($"Unhandled cursor kind: {handle.KindSpelling}."); + result = new Cursor(handle, handle.Kind); } - public override bool Equals(object obj) => (obj is Cursor other) && Equals(other); + return result; + } - public bool Equals(Cursor other) => this == other; + public override bool Equals(object obj) => (obj is Cursor other) && Equals(other); - public override int GetHashCode() => Handle.GetHashCode(); + public bool Equals(Cursor other) => this == other; - public override string ToString() => Spelling; - } + public override int GetHashCode() => Handle.GetHashCode(); + + public override string ToString() => Spelling; } diff --git a/sources/ClangSharp/Cursors/Decls/AccessSpecDecl.cs b/sources/ClangSharp/Cursors/Decls/AccessSpecDecl.cs index 6f18c4c6..b4cc74b3 100644 --- a/sources/ClangSharp/Cursors/Decls/AccessSpecDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/AccessSpecDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class AccessSpecDecl : Decl { - public sealed class AccessSpecDecl : Decl + internal AccessSpecDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXAccessSpecifier, CX_DeclKind.CX_DeclKind_AccessSpec) { - internal AccessSpecDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXAccessSpecifier, CX_DeclKind.CX_DeclKind_AccessSpec) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/BaseUsingDecl.cs b/sources/ClangSharp/Cursors/Decls/BaseUsingDecl.cs index b8540eb0..53d26c44 100644 --- a/sources/ClangSharp/Cursors/Decls/BaseUsingDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/BaseUsingDecl.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class BaseUsingDecl : NamedDecl { - public class BaseUsingDecl : NamedDecl + private protected BaseUsingDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { - private protected BaseUsingDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastBaseUsing or < CX_DeclKind.CX_DeclKind_FirstBaseUsing) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastBaseUsing or < CX_DeclKind.CX_DeclKind_FirstBaseUsing) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Decls/BindingDecl.cs b/sources/ClangSharp/Cursors/Decls/BindingDecl.cs index eaee141d..d695c043 100644 --- a/sources/ClangSharp/Cursors/Decls/BindingDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/BindingDecl.cs @@ -3,25 +3,24 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class BindingDecl : ValueDecl { - public sealed class BindingDecl : ValueDecl - { - private readonly Lazy _binding; - private readonly Lazy _decomposedDecl; - private readonly Lazy _holdingVar; + private readonly Lazy _binding; + private readonly Lazy _decomposedDecl; + private readonly Lazy _holdingVar; - internal BindingDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Binding) - { - _binding = new Lazy(() => TranslationUnit.GetOrCreate(Handle.BindingExpr)); - _decomposedDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DecomposedDecl)); - _holdingVar = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - } + internal BindingDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Binding) + { + _binding = new Lazy(() => TranslationUnit.GetOrCreate(Handle.BindingExpr)); + _decomposedDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DecomposedDecl)); + _holdingVar = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + } - public Expr Binding => _binding.Value; + public Expr Binding => _binding.Value; - public ValueDecl DecomposedDecl => _decomposedDecl.Value; + public ValueDecl DecomposedDecl => _decomposedDecl.Value; - public VarDecl HoldingVar => _holdingVar.Value; - } + public VarDecl HoldingVar => _holdingVar.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/BlockDecl.Capture.cs b/sources/ClangSharp/Cursors/Decls/BlockDecl.Capture.cs index d4c9c8bd..6394f7ee 100644 --- a/sources/ClangSharp/Cursors/Decls/BlockDecl.Capture.cs +++ b/sources/ClangSharp/Cursors/Decls/BlockDecl.Capture.cs @@ -2,39 +2,38 @@ using System; -namespace ClangSharp +namespace ClangSharp; + +public partial class BlockDecl { - public partial class BlockDecl + public sealed class Capture { - public sealed class Capture - { - private readonly Decl _parentDecl; - private readonly uint _index; - private readonly Lazy _copyExpr; - private readonly Lazy _variable; + private readonly Decl _parentDecl; + private readonly uint _index; + private readonly Lazy _copyExpr; + private readonly Lazy _variable; - internal Capture(Decl parentDecl, uint index) - { - _parentDecl = parentDecl; - _index = index; + internal Capture(Decl parentDecl, uint index) + { + _parentDecl = parentDecl; + _index = index; - _copyExpr = new Lazy(() => _parentDecl.TranslationUnit.GetOrCreate(_parentDecl.Handle.GetCaptureCopyExpr(_index))); - _variable = new Lazy(() => _parentDecl.TranslationUnit.GetOrCreate(_parentDecl.Handle.GetCaptureVariable(_index))); - } + _copyExpr = new Lazy(() => _parentDecl.TranslationUnit.GetOrCreate(_parentDecl.Handle.GetCaptureCopyExpr(_index))); + _variable = new Lazy(() => _parentDecl.TranslationUnit.GetOrCreate(_parentDecl.Handle.GetCaptureVariable(_index))); + } - public Expr CopyExpr => _copyExpr.Value; + public Expr CopyExpr => _copyExpr.Value; - public bool HasCopyExpr => _parentDecl.Handle.GetCaptureHasCopyExpr(_index); + public bool HasCopyExpr => _parentDecl.Handle.GetCaptureHasCopyExpr(_index); - public bool IsByRef => _parentDecl.Handle.GetCaptureIsByRef(_index); + public bool IsByRef => _parentDecl.Handle.GetCaptureIsByRef(_index); - public bool IsEscapingByRef => _parentDecl.Handle.GetCaptureIsEscapingByRef(_index); + public bool IsEscapingByRef => _parentDecl.Handle.GetCaptureIsEscapingByRef(_index); - public bool IsNested => _parentDecl.Handle.GetCaptureIsNested(_index); + public bool IsNested => _parentDecl.Handle.GetCaptureIsNested(_index); - public bool IsNonEscapingByRef => _parentDecl.Handle.GetCaptureIsNonEscapingByRef(_index); + public bool IsNonEscapingByRef => _parentDecl.Handle.GetCaptureIsNonEscapingByRef(_index); - public VarDecl Variable => _variable.Value; - } + public VarDecl Variable => _variable.Value; } } diff --git a/sources/ClangSharp/Cursors/Decls/BlockDecl.cs b/sources/ClangSharp/Cursors/Decls/BlockDecl.cs index 58aa805d..43611e62 100644 --- a/sources/ClangSharp/Cursors/Decls/BlockDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/BlockDecl.cs @@ -4,75 +4,74 @@ using System; using System.Collections.Generic; -namespace ClangSharp -{ - public sealed partial class BlockDecl : Decl, IDeclContext - { - private readonly Lazy _blockManglingContextDecl; - private readonly Lazy> _captures; - private readonly Lazy> _parameters; - - internal BlockDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Block) - { - _blockManglingContextDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.BlockManglingContextDecl)); - _captures = new Lazy>(() => { - var captureCount = Handle.NumCaptures; - var captures = new List(captureCount); - - for (var i = 0; i < captureCount; i++) - { - var capture = new Capture(this, unchecked((uint)i)); - captures.Add(capture); - } - - return captures; - }); - _parameters = new Lazy>(() => { - var parameterCount = Handle.NumArguments; - var parameters = new List(parameterCount); +namespace ClangSharp; - for (var i = 0; i < parameterCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); - parameters.Add(parameter); - } +public sealed partial class BlockDecl : Decl, IDeclContext +{ + private readonly Lazy _blockManglingContextDecl; + private readonly Lazy> _captures; + private readonly Lazy> _parameters; - return parameters; - }); - } + internal BlockDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Block) + { + _blockManglingContextDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.BlockManglingContextDecl)); + _captures = new Lazy>(() => { + var captureCount = Handle.NumCaptures; + var captures = new List(captureCount); + + for (var i = 0; i < captureCount; i++) + { + var capture = new Capture(this, unchecked((uint)i)); + captures.Add(capture); + } + + return captures; + }); + _parameters = new Lazy>(() => { + var parameterCount = Handle.NumArguments; + var parameters = new List(parameterCount); + + for (var i = 0; i < parameterCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); + parameters.Add(parameter); + } + + return parameters; + }); + } - public Decl BlockManglingContextDecl => _blockManglingContextDecl.Value; + public Decl BlockManglingContextDecl => _blockManglingContextDecl.Value; - public uint BlockManglingNumber => unchecked((uint)Handle.BlockManglingNumber); + public uint BlockManglingNumber => unchecked((uint)Handle.BlockManglingNumber); - public bool BlockMissingReturnType => Handle.BlockMissingReturnType; + public bool BlockMissingReturnType => Handle.BlockMissingReturnType; - public IReadOnlyList Captures => _captures.Value; + public IReadOnlyList Captures => _captures.Value; - public bool CanAvoidCopyToHeap() => Handle.CanAvoidCopyToHeap; + public bool CanAvoidCopyToHeap() => Handle.CanAvoidCopyToHeap; - public bool CapturesCXXThis => Handle.CapturesCXXThis; + public bool CapturesCXXThis => Handle.CapturesCXXThis; - public CompoundStmt CompoundBody => (CompoundStmt)Body; + public CompoundStmt CompoundBody => (CompoundStmt)Body; - public bool DoesNotEscape => Handle.DoesNotEscape; + public bool DoesNotEscape => Handle.DoesNotEscape; - public bool HasCaptures => NumCaptures != 0; + public bool HasCaptures => NumCaptures != 0; - public bool IsConversionFromLambda => Handle.IsConversionFromLambda; + public bool IsConversionFromLambda => Handle.IsConversionFromLambda; - public bool IsVariadic => Handle.IsVariadic; + public bool IsVariadic => Handle.IsVariadic; - public uint NumCaptures => unchecked((uint)Handle.NumCaptures); + public uint NumCaptures => unchecked((uint)Handle.NumCaptures); - public uint NumParams => unchecked((uint)Handle.NumArguments); + public uint NumParams => unchecked((uint)Handle.NumArguments); - public IReadOnlyList Parameters => _parameters.Value; + public IReadOnlyList Parameters => _parameters.Value; - public bool ParamEmpty => ParamSize == 0; + public bool ParamEmpty => ParamSize == 0; - public nuint ParamSize => NumParams; + public nuint ParamSize => NumParams; - public bool CapturesVariable(VarDecl var) => Handle.CapturesVariable(var.Handle); - } + public bool CapturesVariable(VarDecl var) => Handle.CapturesVariable(var.Handle); } diff --git a/sources/ClangSharp/Cursors/Decls/BuiltinTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/BuiltinTemplateDecl.cs index e86c9dfa..05ee5612 100644 --- a/sources/ClangSharp/Cursors/Decls/BuiltinTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/BuiltinTemplateDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class BuiltinTemplateDecl : TemplateDecl { - public sealed class BuiltinTemplateDecl : TemplateDecl + internal BuiltinTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_BuiltinTemplate) { - internal BuiltinTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_BuiltinTemplate) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs index eb5aa169..e2695e73 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs @@ -5,67 +5,66 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXConstructorDecl : CXXMethodDecl { - public sealed class CXXConstructorDecl : CXXMethodDecl + private readonly Lazy _inheritedConstructor; + private readonly Lazy> _initExprs; + + internal CXXConstructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Constructor, CX_DeclKind.CX_DeclKind_CXXConstructor) { - private readonly Lazy _inheritedConstructor; - private readonly Lazy> _initExprs; + _inheritedConstructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InheritedConstructor)); + _initExprs = new Lazy>(() => { + var numInitExprs = Handle.NumExprs; + var initExprs = new List(numInitExprs); - internal CXXConstructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Constructor, CX_DeclKind.CX_DeclKind_CXXConstructor) - { - _inheritedConstructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InheritedConstructor)); - _initExprs = new Lazy>(() => { - var numInitExprs = Handle.NumExprs; - var initExprs = new List(numInitExprs); - - for (var i = 0; i < numInitExprs; i++) - { - var initExpr = TranslationUnit.GetOrCreate(Handle.GetExpr(unchecked((uint)i))); - initExprs.Add(initExpr); - } - - return initExprs; - }); - } + for (var i = 0; i < numInitExprs; i++) + { + var initExpr = TranslationUnit.GetOrCreate(Handle.GetExpr(unchecked((uint)i))); + initExprs.Add(initExpr); + } - public new CXXConstructorDecl CanonicalDecl => (CXXConstructorDecl)base.CanonicalDecl; + return initExprs; + }); + } + + public new CXXConstructorDecl CanonicalDecl => (CXXConstructorDecl)base.CanonicalDecl; - public CXXConstructorDecl InheritedConstructor => _inheritedConstructor.Value; + public CXXConstructorDecl InheritedConstructor => _inheritedConstructor.Value; - public IReadOnlyList InitExprs => _initExprs.Value; + public IReadOnlyList InitExprs => _initExprs.Value; - public bool IsConvertingConstructor => Handle.CXXConstructor_IsConvertingConstructor; + public bool IsConvertingConstructor => Handle.CXXConstructor_IsConvertingConstructor; - public bool IsCopyConstructor => Handle.CXXConstructor_IsCopyConstructor; + public bool IsCopyConstructor => Handle.CXXConstructor_IsCopyConstructor; - public bool IsCopyOrMoveConstructor => Handle.IsCopyOrMoveConstructor; + public bool IsCopyOrMoveConstructor => Handle.IsCopyOrMoveConstructor; - public bool IsDefaultConstructor => Handle.CXXConstructor_IsDefaultConstructor; + public bool IsDefaultConstructor => Handle.CXXConstructor_IsDefaultConstructor; - public bool IsDelegatingConstructor => Handle.IsDelegatingConstructor; + public bool IsDelegatingConstructor => Handle.IsDelegatingConstructor; - public bool IsExplicit => !Handle.IsImplicit; + public bool IsExplicit => !Handle.IsImplicit; - public bool IsInheritingConstructor => Handle.IsInheritingConstructor; + public bool IsInheritingConstructor => Handle.IsInheritingConstructor; - public bool IsMoveConstructor => Handle.CXXConstructor_IsMoveConstructor; + public bool IsMoveConstructor => Handle.CXXConstructor_IsMoveConstructor; - public uint NumCtorInitializers => unchecked((uint)Handle.NumExprs); + public uint NumCtorInitializers => unchecked((uint)Handle.NumExprs); - public CXXConstructorDecl TargetConstructor + public CXXConstructorDecl TargetConstructor + { + get { - get + if (!IsDelegatingConstructor) { - if (!IsDelegatingConstructor) - { - return null; - } + return null; + } - var e = InitExprs.FirstOrDefault()?.IgnoreImplicit; + var e = InitExprs.FirstOrDefault()?.IgnoreImplicit; - return e is CXXConstructExpr construct ? construct.Constructor : null; - } + return e is CXXConstructExpr construct ? construct.Constructor : null; } } } diff --git a/sources/ClangSharp/Cursors/Decls/CXXConversionDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXConversionDecl.cs index b6c1e9c9..ecb601fe 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXConversionDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXConversionDecl.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXConversionDecl : CXXMethodDecl { - public sealed class CXXConversionDecl : CXXMethodDecl - { - private readonly Lazy _conversionType; + private readonly Lazy _conversionType; - internal CXXConversionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConversionFunction, CX_DeclKind.CX_DeclKind_CXXConversion) - { - _conversionType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } + internal CXXConversionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConversionFunction, CX_DeclKind.CX_DeclKind_CXXConversion) + { + _conversionType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + } - public new CXXConversionDecl CanonicalDecl => (CXXConversionDecl)base.CanonicalDecl; + public new CXXConversionDecl CanonicalDecl => (CXXConversionDecl)base.CanonicalDecl; - public bool IsExplicit => !Handle.IsImplicit; + public bool IsExplicit => !Handle.IsImplicit; - public Type ConversionType => _conversionType.Value; - } + public Type ConversionType => _conversionType.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/CXXDeductionGuideDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXDeductionGuideDecl.cs index e560969b..b8fdb851 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXDeductionGuideDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXDeductionGuideDecl.cs @@ -3,19 +3,18 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXDeductionGuideDecl : FunctionDecl { - public sealed class CXXDeductionGuideDecl : FunctionDecl - { - private readonly Lazy _deducedTemplate; + private readonly Lazy _deducedTemplate; - internal CXXDeductionGuideDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_CXXDeductionGuide) - { - _deducedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(handle.TemplatedDecl)); - } + internal CXXDeductionGuideDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_CXXDeductionGuide) + { + _deducedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(handle.TemplatedDecl)); + } - public bool IsExplicit => !Handle.IsImplicit; + public bool IsExplicit => !Handle.IsImplicit; - public TemplateDecl DeducedTemplate => _deducedTemplate.Value; - } + public TemplateDecl DeducedTemplate => _deducedTemplate.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/CXXDestructorDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXDestructorDecl.cs index 445d208b..2c06c25a 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXDestructorDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXDestructorDecl.cs @@ -3,23 +3,22 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXDestructorDecl : CXXMethodDecl { - public sealed class CXXDestructorDecl : CXXMethodDecl - { - private readonly Lazy _operatorDelete; - private readonly Lazy _operatorDeleteThisArg; + private readonly Lazy _operatorDelete; + private readonly Lazy _operatorDeleteThisArg; - internal CXXDestructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Destructor, CX_DeclKind.CX_DeclKind_CXXDestructor) - { - _operatorDelete = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _operatorDeleteThisArg = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); - } + internal CXXDestructorDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Destructor, CX_DeclKind.CX_DeclKind_CXXDestructor) + { + _operatorDelete = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _operatorDeleteThisArg = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); + } - public new CXXDestructorDecl CanonicalDecl => (CXXDestructorDecl)base.CanonicalDecl; + public new CXXDestructorDecl CanonicalDecl => (CXXDestructorDecl)base.CanonicalDecl; - public Expr OperatorDeleteThisArg => _operatorDeleteThisArg.Value; + public Expr OperatorDeleteThisArg => _operatorDeleteThisArg.Value; - public FunctionDecl OperatorDelete => _operatorDelete.Value; - } + public FunctionDecl OperatorDelete => _operatorDelete.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/CXXMethodDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXMethodDecl.cs index ab8b648f..03fdd100 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXMethodDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXMethodDecl.cs @@ -5,60 +5,59 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class CXXMethodDecl : FunctionDecl { - public class CXXMethodDecl : FunctionDecl + private readonly Lazy> _overriddenMethods; + private readonly Lazy _thisType; + private readonly Lazy _thisObjectType; + + internal CXXMethodDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CXXMethod, CX_DeclKind.CX_DeclKind_CXXMethod) { - private readonly Lazy> _overriddenMethods; - private readonly Lazy _thisType; - private readonly Lazy _thisObjectType; + } - internal CXXMethodDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CXXMethod, CX_DeclKind.CX_DeclKind_CXXMethod) + private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastCXXMethod or < CX_DeclKind.CX_DeclKind_FirstCXXMethod) { + throw new ArgumentOutOfRangeException(nameof(handle)); } - private protected CXXMethodDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) - { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastCXXMethod or < CX_DeclKind.CX_DeclKind_FirstCXXMethod) + _overriddenMethods = new Lazy>(() => { + var numOverriddenMethods = Handle.NumMethods; + var overriddenMethods = new List(numOverriddenMethods); + + for (var i = 0; i < numOverriddenMethods; i++) { - throw new ArgumentOutOfRangeException(nameof(handle)); + var overriddenMethod = TranslationUnit.GetOrCreate(Handle.GetMethod(unchecked((uint)i))); + overriddenMethods.Add(overriddenMethod); } - _overriddenMethods = new Lazy>(() => { - var numOverriddenMethods = Handle.NumMethods; - var overriddenMethods = new List(numOverriddenMethods); + return overriddenMethods; + }); - for (var i = 0; i < numOverriddenMethods; i++) - { - var overriddenMethod = TranslationUnit.GetOrCreate(Handle.GetMethod(unchecked((uint)i))); - overriddenMethods.Add(overriddenMethod); - } - - return overriddenMethods; - }); - - _thisType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ThisType)); - _thisObjectType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ThisObjectType)); - } + _thisType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ThisType)); + _thisObjectType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ThisObjectType)); + } - public new CXXMethodDecl CanonicalDecl => (CXXMethodDecl)base.CanonicalDecl; + public new CXXMethodDecl CanonicalDecl => (CXXMethodDecl)base.CanonicalDecl; - public bool IsConst => Handle.CXXMethod_IsConst; + public bool IsConst => Handle.CXXMethod_IsConst; - public bool IsVirtual => Handle.CXXMethod_IsVirtual; + public bool IsVirtual => Handle.CXXMethod_IsVirtual; - public new CXXMethodDecl MostRecentDecl => (CXXMethodDecl)base.MostRecentDecl; + public new CXXMethodDecl MostRecentDecl => (CXXMethodDecl)base.MostRecentDecl; - public IReadOnlyList OverriddenMethods => _overriddenMethods.Value; + public IReadOnlyList OverriddenMethods => _overriddenMethods.Value; - public new CXXRecordDecl Parent => (CXXRecordDecl)(base.Parent ?? ThisObjectType.AsCXXRecordDecl); + public new CXXRecordDecl Parent => (CXXRecordDecl)(base.Parent ?? ThisObjectType.AsCXXRecordDecl); - public uint SizeOverriddenMethods => unchecked((uint)Handle.NumMethods); + public uint SizeOverriddenMethods => unchecked((uint)Handle.NumMethods); - public Type ThisType => _thisType.Value; + public Type ThisType => _thisType.Value; - public Type ThisObjectType => _thisObjectType.Value; + public Type ThisObjectType => _thisObjectType.Value; - public long VtblIndex => IsVirtual ? Handle.VtblIdx : -1; - } + public long VtblIndex => IsVirtual ? Handle.VtblIdx : -1; } diff --git a/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs index a4b17562..68301c5c 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXRecordDecl.cs @@ -4,184 +4,183 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class CXXRecordDecl : RecordDecl { - public class CXXRecordDecl : RecordDecl + private readonly Lazy> _bases; + private readonly Lazy> _ctors; + private readonly Lazy _dependentLambdaCallOperator; + private readonly Lazy _describedClassTemplate; + private readonly Lazy _destructor; + private readonly Lazy> _friends; + private readonly Lazy _instantiatedFromMemberClass; + private readonly Lazy _lambdaCallOperator; + private readonly Lazy _lambdaContextDecl; + private readonly Lazy _lambdaStaticInvoker; + private readonly Lazy> _methods; + private readonly Lazy _templateInstantiationPattern; + private readonly Lazy> _vbases; + + internal CXXRecordDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_CXXRecord) { - private readonly Lazy> _bases; - private readonly Lazy> _ctors; - private readonly Lazy _dependentLambdaCallOperator; - private readonly Lazy _describedClassTemplate; - private readonly Lazy _destructor; - private readonly Lazy> _friends; - private readonly Lazy _instantiatedFromMemberClass; - private readonly Lazy _lambdaCallOperator; - private readonly Lazy _lambdaContextDecl; - private readonly Lazy _lambdaStaticInvoker; - private readonly Lazy> _methods; - private readonly Lazy _templateInstantiationPattern; - private readonly Lazy> _vbases; - - internal CXXRecordDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_CXXRecord) + } + + private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastCXXRecord or < CX_DeclKind.CX_DeclKind_FirstCXXRecord) { + throw new ArgumentOutOfRangeException(nameof(handle)); } - private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) - { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastCXXRecord or < CX_DeclKind.CX_DeclKind_FirstCXXRecord) + _bases = new Lazy>(() => { + var numBases = Handle.NumBases; + var bases = new List(numBases); + + for (var i = 0; i < numBases; i++) { - throw new ArgumentOutOfRangeException(nameof(handle)); + var @base = TranslationUnit.GetOrCreate(Handle.GetBase(unchecked((uint)i))); + bases.Add(@base); } - _bases = new Lazy>(() => { - var numBases = Handle.NumBases; - var bases = new List(numBases); - - for (var i = 0; i < numBases; i++) - { - var @base = TranslationUnit.GetOrCreate(Handle.GetBase(unchecked((uint)i))); - bases.Add(@base); - } - - return bases; - }); - - _ctors = new Lazy>(() => { - var numCtors = Handle.NumCtors; - var ctors = new List(numCtors); - - for (var i = 0; i < numCtors; i++) - { - var ctor = TranslationUnit.GetOrCreate(Handle.GetCtor(unchecked((uint)i))); - ctors.Add(ctor); - } - - return ctors; - }); - - _dependentLambdaCallOperator = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DependentLambdaCallOperator)); - _describedClassTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DescribedCursorTemplate)); - _destructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Destructor)); - - _friends = new Lazy>(() => { - var numFriends = Handle.NumFriends; - var friends = new List(numFriends); - - for (var i = 0; i < numFriends; i++) - { - var friend = TranslationUnit.GetOrCreate(Handle.GetFriend(unchecked((uint)i))); - friends.Add(friend); - } - - return friends; - }); - - _instantiatedFromMemberClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); - _lambdaCallOperator = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LambdaCallOperator)); - _lambdaContextDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LambdaContextDecl)); - _lambdaStaticInvoker = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LambdaStaticInvoker)); - - _methods = new Lazy>(() => { - var numMethods = Handle.NumMethods; - var methods = new List(numMethods); - - for (var i = 0; i < numMethods; i++) - { - var method = TranslationUnit.GetOrCreate(Handle.GetMethod(unchecked((uint)i))); - methods.Add(method); - } - - return methods; - }); - - _templateInstantiationPattern = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateInstantiationPattern)); - - _vbases = new Lazy>(() => { - var numVBases = Handle.NumVBases; - var vbases = new List(numVBases); - - for (var i = 0; i < numVBases; i++) - { - var vbase = TranslationUnit.GetOrCreate(Handle.GetVBase(unchecked((uint)i))); - vbases.Add(vbase); - } - - return vbases; - }); - } + return bases; + }); + + _ctors = new Lazy>(() => { + var numCtors = Handle.NumCtors; + var ctors = new List(numCtors); + + for (var i = 0; i < numCtors; i++) + { + var ctor = TranslationUnit.GetOrCreate(Handle.GetCtor(unchecked((uint)i))); + ctors.Add(ctor); + } + + return ctors; + }); + + _dependentLambdaCallOperator = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DependentLambdaCallOperator)); + _describedClassTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DescribedCursorTemplate)); + _destructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Destructor)); + + _friends = new Lazy>(() => { + var numFriends = Handle.NumFriends; + var friends = new List(numFriends); + + for (var i = 0; i < numFriends; i++) + { + var friend = TranslationUnit.GetOrCreate(Handle.GetFriend(unchecked((uint)i))); + friends.Add(friend); + } + + return friends; + }); - public bool IsAbstract => Handle.CXXRecord_IsAbstract; + _instantiatedFromMemberClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); + _lambdaCallOperator = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LambdaCallOperator)); + _lambdaContextDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LambdaContextDecl)); + _lambdaStaticInvoker = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LambdaStaticInvoker)); - public IReadOnlyList Bases => _bases.Value; + _methods = new Lazy>(() => { + var numMethods = Handle.NumMethods; + var methods = new List(numMethods); - public new CXXRecordDecl CanonicalDecl => (CXXRecordDecl)base.CanonicalDecl; + for (var i = 0; i < numMethods; i++) + { + var method = TranslationUnit.GetOrCreate(Handle.GetMethod(unchecked((uint)i))); + methods.Add(method); + } + + return methods; + }); + + _templateInstantiationPattern = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateInstantiationPattern)); + + _vbases = new Lazy>(() => { + var numVBases = Handle.NumVBases; + var vbases = new List(numVBases); + + for (var i = 0; i < numVBases; i++) + { + var vbase = TranslationUnit.GetOrCreate(Handle.GetVBase(unchecked((uint)i))); + vbases.Add(vbase); + } + + return vbases; + }); + } + + public bool IsAbstract => Handle.CXXRecord_IsAbstract; + + public IReadOnlyList Bases => _bases.Value; - public IReadOnlyList Ctors => _ctors.Value; + public new CXXRecordDecl CanonicalDecl => (CXXRecordDecl)base.CanonicalDecl; - public new CXXRecordDecl Definition => (CXXRecordDecl)base.Definition; + public IReadOnlyList Ctors => _ctors.Value; - public FunctionTemplateDecl DependentLambdaCallOperator => _dependentLambdaCallOperator.Value; + public new CXXRecordDecl Definition => (CXXRecordDecl)base.Definition; - public ClassTemplateDecl DescribedClassTemplate => _describedClassTemplate.Value; + public FunctionTemplateDecl DependentLambdaCallOperator => _dependentLambdaCallOperator.Value; - public CXXDestructorDecl Destructor => _destructor.Value; + public ClassTemplateDecl DescribedClassTemplate => _describedClassTemplate.Value; - public IReadOnlyList Friends => _friends.Value; + public CXXDestructorDecl Destructor => _destructor.Value; - public bool HasDefinition => Definition is not null; + public IReadOnlyList Friends => _friends.Value; - public bool HasFriends => Handle.NumFriends != 0; + public bool HasDefinition => Definition is not null; - public bool HasUserDeclaredConstructor => Handle.HasUserDeclaredConstructor; + public bool HasFriends => Handle.NumFriends != 0; - public bool HasUserDeclaredCopyAssignment => Handle.HasUserDeclaredCopyAssignment; + public bool HasUserDeclaredConstructor => Handle.HasUserDeclaredConstructor; - public bool HasUserDeclaredCopyConstructor => Handle.HasUserDeclaredCopyConstructor; + public bool HasUserDeclaredCopyAssignment => Handle.HasUserDeclaredCopyAssignment; - public bool HasUserDeclaredDestructor => Handle.HasUserDeclaredDestructor; + public bool HasUserDeclaredCopyConstructor => Handle.HasUserDeclaredCopyConstructor; - public bool HasUserDeclaredMoveAssignment => Handle.HasUserDeclaredMoveAssignment; + public bool HasUserDeclaredDestructor => Handle.HasUserDeclaredDestructor; - public bool HasUserDeclaredMoveConstructor => Handle.HasUserDeclaredMoveConstructor; + public bool HasUserDeclaredMoveAssignment => Handle.HasUserDeclaredMoveAssignment; - public bool HasUserDeclaredMoveOperation => Handle.HasUserDeclaredMoveOperation; + public bool HasUserDeclaredMoveConstructor => Handle.HasUserDeclaredMoveConstructor; - public CXXRecordDecl InstantiatedFromMemberClass => _instantiatedFromMemberClass.Value; + public bool HasUserDeclaredMoveOperation => Handle.HasUserDeclaredMoveOperation; - public CXXMethodDecl LambdaCallOperator => _lambdaCallOperator.Value; + public CXXRecordDecl InstantiatedFromMemberClass => _instantiatedFromMemberClass.Value; - public Decl LambdaContextDecl => _lambdaContextDecl.Value; + public CXXMethodDecl LambdaCallOperator => _lambdaCallOperator.Value; - public CXXMethodDecl LambdaStaticInvoker => _lambdaStaticInvoker.Value; + public Decl LambdaContextDecl => _lambdaContextDecl.Value; - public IReadOnlyList Methods => _methods.Value; + public CXXMethodDecl LambdaStaticInvoker => _lambdaStaticInvoker.Value; - public new CXXRecordDecl MostRecentDecl => (CXXRecordDecl)base.MostRecentDecl; + public IReadOnlyList Methods => _methods.Value; - public CXXRecordDecl MostRecentNonInjectedDecl + public new CXXRecordDecl MostRecentDecl => (CXXRecordDecl)base.MostRecentDecl; + + public CXXRecordDecl MostRecentNonInjectedDecl + { + get { - get - { - var recent = MostRecentDecl; + var recent = MostRecentDecl; - while ((recent != null) && recent.IsInjectedClassName) - { - recent = recent.PreviousDecl; - } - return recent; + while ((recent != null) && recent.IsInjectedClassName) + { + recent = recent.PreviousDecl; } + return recent; } + } - public uint NumBases => unchecked((uint)Handle.NumBases); + public uint NumBases => unchecked((uint)Handle.NumBases); - public uint NumVBases => unchecked((uint)Handle.NumVBases); + public uint NumVBases => unchecked((uint)Handle.NumVBases); - public new CXXRecordDecl PreviousDecl => (CXXRecordDecl)base.PreviousDecl; + public new CXXRecordDecl PreviousDecl => (CXXRecordDecl)base.PreviousDecl; - public CX_TemplateSpecializationKind TemplateSpecializationKind => Handle.TemplateSpecializationKind; + public CX_TemplateSpecializationKind TemplateSpecializationKind => Handle.TemplateSpecializationKind; - public CXXRecordDecl TemplateInstantiationPattern => _templateInstantiationPattern.Value; + public CXXRecordDecl TemplateInstantiationPattern => _templateInstantiationPattern.Value; - public IReadOnlyList VBases => _vbases.Value; - } + public IReadOnlyList VBases => _vbases.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/CapturedDecl.cs b/sources/ClangSharp/Cursors/Decls/CapturedDecl.cs index 93f8afc5..bb858850 100644 --- a/sources/ClangSharp/Cursors/Decls/CapturedDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CapturedDecl.cs @@ -4,38 +4,37 @@ using System; using System.Collections.Generic; -namespace ClangSharp -{ - public sealed class CapturedDecl : Decl, IDeclContext - { - private readonly Lazy _contextParam; - private readonly Lazy> _parameters; +namespace ClangSharp; - internal CapturedDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Captured) - { - _contextParam = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ContextParam)); - _parameters = new Lazy>(() => { - var parameterCount = Handle.NumArguments; - var parameters = new List(parameterCount); - - for (var i = 0; i < parameterCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); - parameters.Add(parameter); - } +public sealed class CapturedDecl : Decl, IDeclContext +{ + private readonly Lazy _contextParam; + private readonly Lazy> _parameters; - return parameters; - }); - } + internal CapturedDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Captured) + { + _contextParam = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ContextParam)); + _parameters = new Lazy>(() => { + var parameterCount = Handle.NumArguments; + var parameters = new List(parameterCount); + + for (var i = 0; i < parameterCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); + parameters.Add(parameter); + } + + return parameters; + }); + } - public ImplicitParamDecl ContextParam => _contextParam.Value; + public ImplicitParamDecl ContextParam => _contextParam.Value; - public uint ContextParamPosition => unchecked((uint)Handle.ContextParamPosition); + public uint ContextParamPosition => unchecked((uint)Handle.ContextParamPosition); - public bool IsNothrow => Handle.IsNothrow; + public bool IsNothrow => Handle.IsNothrow; - public uint NumParams => unchecked((uint)Handle.NumArguments); + public uint NumParams => unchecked((uint)Handle.NumArguments); - public IReadOnlyList Parameters => _parameters.Value; - } + public IReadOnlyList Parameters => _parameters.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs index 18425592..543d6fb9 100644 --- a/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ClassScopeFunctionSpecializationDecl.cs @@ -4,36 +4,35 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class ClassScopeFunctionSpecializationDecl : Decl - { - private readonly Lazy _specialization; - private readonly Lazy> _templateArgs; +namespace ClangSharp; - internal ClassScopeFunctionSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization) - { - _specialization = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSpecialization(0))); - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); - - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); - templateArgs.Add(templateArg); - } +public sealed class ClassScopeFunctionSpecializationDecl : Decl +{ + private readonly Lazy _specialization; + private readonly Lazy> _templateArgs; - return templateArgs; - }); - } + internal ClassScopeFunctionSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization) + { + _specialization = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSpecialization(0))); + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); + + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); + templateArgs.Add(templateArg); + } + + return templateArgs; + }); + } - public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; + public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; - public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); + public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); - public CXXMethodDecl Specialization => _specialization.Value; + public CXXMethodDecl Specialization => _specialization.Value; - public IReadOnlyList TemplateArgs => _templateArgs.Value; - } + public IReadOnlyList TemplateArgs => _templateArgs.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ClassTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/ClassTemplateDecl.cs index c77ec412..617a7f96 100644 --- a/sources/ClangSharp/Cursors/Decls/ClassTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ClassTemplateDecl.cs @@ -4,45 +4,44 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ClassTemplateDecl : RedeclarableTemplateDecl { - public sealed class ClassTemplateDecl : RedeclarableTemplateDecl - { - private readonly Lazy _injectedClassNameSpecialization; - private readonly Lazy> _specializations; + private readonly Lazy _injectedClassNameSpecialization; + private readonly Lazy> _specializations; - internal ClassTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplate, CX_DeclKind.CX_DeclKind_ClassTemplate) - { - _injectedClassNameSpecialization = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InjectedSpecializationType)); + internal ClassTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplate, CX_DeclKind.CX_DeclKind_ClassTemplate) + { + _injectedClassNameSpecialization = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InjectedSpecializationType)); - _specializations = new Lazy>(() => { - var numSpecializations = Handle.NumSpecializations; - var specializations = new List(numSpecializations); + _specializations = new Lazy>(() => { + var numSpecializations = Handle.NumSpecializations; + var specializations = new List(numSpecializations); - for (var i = 0; i (Handle.GetSpecialization(unchecked((uint)i))); - specializations.Add(specialization); - } + for (var i = 0; i (Handle.GetSpecialization(unchecked((uint)i))); + specializations.Add(specialization); + } - return specializations; - }); - } + return specializations; + }); + } - public new ClassTemplateDecl CanonicalDecl => (ClassTemplateDecl)base.CanonicalDecl; + public new ClassTemplateDecl CanonicalDecl => (ClassTemplateDecl)base.CanonicalDecl; - public Type InjectedClassNameSpecialization => _injectedClassNameSpecialization.Value; + public Type InjectedClassNameSpecialization => _injectedClassNameSpecialization.Value; - public new ClassTemplateDecl InstantiatedFromMemberTemplate => (ClassTemplateDecl)base.InstantiatedFromMemberTemplate; + public new ClassTemplateDecl InstantiatedFromMemberTemplate => (ClassTemplateDecl)base.InstantiatedFromMemberTemplate; - public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; + public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; - public new ClassTemplateDecl MostRecentDecl => (ClassTemplateDecl)base.MostRecentDecl; + public new ClassTemplateDecl MostRecentDecl => (ClassTemplateDecl)base.MostRecentDecl; - public new ClassTemplateDecl PreviousDecl => (ClassTemplateDecl)base.PreviousDecl; + public new ClassTemplateDecl PreviousDecl => (ClassTemplateDecl)base.PreviousDecl; - public IReadOnlyList Specializations => _specializations.Value; + public IReadOnlyList Specializations => _specializations.Value; - public new CXXRecordDecl TemplatedDecl => (CXXRecordDecl)base.TemplatedDecl; - } + public new CXXRecordDecl TemplatedDecl => (CXXRecordDecl)base.TemplatedDecl; } diff --git a/sources/ClangSharp/Cursors/Decls/ClassTemplatePartialSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/ClassTemplatePartialSpecializationDecl.cs index 619c6b9d..9c606b58 100644 --- a/sources/ClangSharp/Cursors/Decls/ClassTemplatePartialSpecializationDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ClassTemplatePartialSpecializationDecl.cs @@ -4,61 +4,60 @@ using System; using System.Collections.Generic; -namespace ClangSharp -{ - public sealed class ClassTemplatePartialSpecializationDecl : ClassTemplateSpecializationDecl - { - private readonly Lazy> _associatedConstraints; - private readonly Lazy _injectedSpecializationType; - private readonly Lazy _instantiatedFromMember; - private readonly Lazy> _templateParameters; - - internal ClassTemplatePartialSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplatePartialSpecialization, CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization) - { - _associatedConstraints = new Lazy>(() => { - var associatedConstraintCount = Handle.NumAssociatedConstraints; - var associatedConstraints = new List(associatedConstraintCount); - - for (var i = 0; i < associatedConstraintCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); - associatedConstraints.Add(parameter); - } - - return associatedConstraints; - }); - - _injectedSpecializationType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InjectedSpecializationType)); - _instantiatedFromMember = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); +namespace ClangSharp; - _templateParameters = new Lazy>(() => { - var parameterCount = Handle.GetNumTemplateParameters(0); - var parameters = new List(parameterCount); - - for (var i = 0; i < parameterCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(0, unchecked((uint)i))); - parameters.Add(parameter); - } +public sealed class ClassTemplatePartialSpecializationDecl : ClassTemplateSpecializationDecl +{ + private readonly Lazy> _associatedConstraints; + private readonly Lazy _injectedSpecializationType; + private readonly Lazy _instantiatedFromMember; + private readonly Lazy> _templateParameters; - return parameters; - }); - } + internal ClassTemplatePartialSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ClassTemplatePartialSpecialization, CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization) + { + _associatedConstraints = new Lazy>(() => { + var associatedConstraintCount = Handle.NumAssociatedConstraints; + var associatedConstraints = new List(associatedConstraintCount); + + for (var i = 0; i < associatedConstraintCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); + associatedConstraints.Add(parameter); + } + + return associatedConstraints; + }); + + _injectedSpecializationType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InjectedSpecializationType)); + _instantiatedFromMember = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); + + _templateParameters = new Lazy>(() => { + var parameterCount = Handle.GetNumTemplateParameters(0); + var parameters = new List(parameterCount); + + for (var i = 0; i < parameterCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(0, unchecked((uint)i))); + parameters.Add(parameter); + } + + return parameters; + }); + } - public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; + public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; - public bool HasAssociatedConstraints => Handle.NumAssociatedConstraints != 0; + public bool HasAssociatedConstraints => Handle.NumAssociatedConstraints != 0; - public Type InjectedSpecializationType => _injectedSpecializationType.Value; + public Type InjectedSpecializationType => _injectedSpecializationType.Value; - public ClassTemplatePartialSpecializationDecl InstantiatedFromMember => _instantiatedFromMember.Value; + public ClassTemplatePartialSpecializationDecl InstantiatedFromMember => _instantiatedFromMember.Value; - public ClassTemplatePartialSpecializationDecl InstantiatedFromMemberTemplate => InstantiatedFromMember; + public ClassTemplatePartialSpecializationDecl InstantiatedFromMemberTemplate => InstantiatedFromMember; - public bool IsMemberSpecialization => Handle.IsMemberSpecialization; + public bool IsMemberSpecialization => Handle.IsMemberSpecialization; - public new ClassTemplatePartialSpecializationDecl MostRecentDecl => (ClassTemplatePartialSpecializationDecl)base.MostRecentDecl; + public new ClassTemplatePartialSpecializationDecl MostRecentDecl => (ClassTemplatePartialSpecializationDecl)base.MostRecentDecl; - public IReadOnlyList TemplateParameters => _templateParameters.Value; - } + public IReadOnlyList TemplateParameters => _templateParameters.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ClassTemplateSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/ClassTemplateSpecializationDecl.cs index 48783f66..c81e9298 100644 --- a/sources/ClangSharp/Cursors/Decls/ClassTemplateSpecializationDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ClassTemplateSpecializationDecl.cs @@ -5,87 +5,86 @@ using System.Collections.Generic; using System.Diagnostics; -namespace ClangSharp +namespace ClangSharp; + +public class ClassTemplateSpecializationDecl : CXXRecordDecl { - public class ClassTemplateSpecializationDecl : CXXRecordDecl + private readonly Lazy _specializedTemplate; + private readonly Lazy> _templateArgs; + + internal ClassTemplateSpecializationDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization) { - private readonly Lazy _specializedTemplate; - private readonly Lazy> _templateArgs; + _specializedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); - internal ClassTemplateSpecializationDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization) - { - _specializedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); + templateArgs.Add(templateArg); + } - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); - templateArgs.Add(templateArg); - } + return templateArgs; + }); + } - return templateArgs; - }); + private protected ClassTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastClassTemplateSpecialization or < CX_DeclKind.CX_DeclKind_FirstClassTemplateSpecialization) + { + throw new ArgumentOutOfRangeException(nameof(handle)); } - private protected ClassTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) - { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastClassTemplateSpecialization or < CX_DeclKind.CX_DeclKind_FirstClassTemplateSpecialization) + _specializedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); + + for (var i = 0; i < templateArgCount; i++) { - throw new ArgumentOutOfRangeException(nameof(handle)); + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); + templateArgs.Add(templateArg); } - _specializedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); - - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); - templateArgs.Add(templateArg); - } - - return templateArgs; - }); - } + return templateArgs; + }); + } - public bool IsClassScopeExplicitSpecialization => IsExplicitSpecialization && (LexicalDeclContext is CXXRecordDecl); + public bool IsClassScopeExplicitSpecialization => IsExplicitSpecialization && (LexicalDeclContext is CXXRecordDecl); - public bool IsExplicitInstantiationOrSpecialization + public bool IsExplicitInstantiationOrSpecialization + { + get { - get + switch (SpecializationKind) { - switch (SpecializationKind) + case CX_TemplateSpecializationKind.CX_TSK_ExplicitSpecialization: + case CX_TemplateSpecializationKind.CX_TSK_ExplicitInstantiationDeclaration: + case CX_TemplateSpecializationKind.CX_TSK_ExplicitInstantiationDefinition: { - case CX_TemplateSpecializationKind.CX_TSK_ExplicitSpecialization: - case CX_TemplateSpecializationKind.CX_TSK_ExplicitInstantiationDeclaration: - case CX_TemplateSpecializationKind.CX_TSK_ExplicitInstantiationDefinition: - { - return true; - } - - case CX_TemplateSpecializationKind.CX_TSK_Undeclared: - case CX_TemplateSpecializationKind.CX_TSK_ImplicitInstantiation: - { - return false; - } + return true; } - Debug.Fail("bad template specialization kind"); - return false; + case CX_TemplateSpecializationKind.CX_TSK_Undeclared: + case CX_TemplateSpecializationKind.CX_TSK_ImplicitInstantiation: + { + return false; + } } + + Debug.Fail("bad template specialization kind"); + return false; } + } - public bool IsExplicitSpecialization => SpecializationKind == CX_TemplateSpecializationKind.CX_TSK_ExplicitSpecialization; + public bool IsExplicitSpecialization => SpecializationKind == CX_TemplateSpecializationKind.CX_TSK_ExplicitSpecialization; - public new ClassTemplateSpecializationDecl MostRecentDecl => (ClassTemplateSpecializationDecl)base.MostRecentDecl; + public new ClassTemplateSpecializationDecl MostRecentDecl => (ClassTemplateSpecializationDecl)base.MostRecentDecl; - public CX_TemplateSpecializationKind SpecializationKind => Handle.TemplateSpecializationKind; + public CX_TemplateSpecializationKind SpecializationKind => Handle.TemplateSpecializationKind; - public ClassTemplateDecl SpecializedTemplate => _specializedTemplate.Value; + public ClassTemplateDecl SpecializedTemplate => _specializedTemplate.Value; - public IReadOnlyList TemplateArgs => _templateArgs.Value; - } + public IReadOnlyList TemplateArgs => _templateArgs.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ConceptDecl.cs b/sources/ClangSharp/Cursors/Decls/ConceptDecl.cs index c4392034..96330abc 100644 --- a/sources/ClangSharp/Cursors/Decls/ConceptDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ConceptDecl.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ConceptDecl : TemplateDecl, IMergeable { - public sealed class ConceptDecl : TemplateDecl, IMergeable - { - private readonly Lazy _constraintExpr; + private readonly Lazy _constraintExpr; - internal ConceptDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Concept) - { - _constraintExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ConstraintExpr)); - } + internal ConceptDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Concept) + { + _constraintExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ConstraintExpr)); + } - public new ConceptDecl CanonicalDecl => (ConceptDecl)base.CanonicalDecl; + public new ConceptDecl CanonicalDecl => (ConceptDecl)base.CanonicalDecl; - public Expr ConstraintExpr => _constraintExpr.Value; + public Expr ConstraintExpr => _constraintExpr.Value; - public bool IsTypeConcept => Handle.IsTypeConcept; - } + public bool IsTypeConcept => Handle.IsTypeConcept; } diff --git a/sources/ClangSharp/Cursors/Decls/ConstructorUsingShadowDecl.cs b/sources/ClangSharp/Cursors/Decls/ConstructorUsingShadowDecl.cs index 6aa52896..3f7add8c 100644 --- a/sources/ClangSharp/Cursors/Decls/ConstructorUsingShadowDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ConstructorUsingShadowDecl.cs @@ -3,33 +3,32 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ConstructorUsingShadowDecl : UsingShadowDecl { - public sealed class ConstructorUsingShadowDecl : UsingShadowDecl - { - private readonly Lazy _constructedBaseClass; - private readonly Lazy _constructedBaseClassShadowDecl; - private readonly Lazy _nominatedBaseClass; - private readonly Lazy _nominatedBaseClassShadowDecl; + private readonly Lazy _constructedBaseClass; + private readonly Lazy _constructedBaseClassShadowDecl; + private readonly Lazy _nominatedBaseClass; + private readonly Lazy _nominatedBaseClassShadowDecl; - internal ConstructorUsingShadowDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ConstructorUsingShadow) - { - _constructedBaseClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ConstructedBaseClass)); - _constructedBaseClassShadowDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ConstructedBaseClassShadowDecl)); - _nominatedBaseClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NominatedBaseClass)); - _nominatedBaseClassShadowDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NominatedBaseClassShadowDecl)); - } + internal ConstructorUsingShadowDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ConstructorUsingShadow) + { + _constructedBaseClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ConstructedBaseClass)); + _constructedBaseClassShadowDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ConstructedBaseClassShadowDecl)); + _nominatedBaseClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NominatedBaseClass)); + _nominatedBaseClassShadowDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NominatedBaseClassShadowDecl)); + } - public CXXRecordDecl ConstructedBaseClass => _constructedBaseClass.Value; + public CXXRecordDecl ConstructedBaseClass => _constructedBaseClass.Value; - public ConstructorUsingShadowDecl ConstructedBaseClassShadowDecl => _constructedBaseClassShadowDecl.Value; + public ConstructorUsingShadowDecl ConstructedBaseClassShadowDecl => _constructedBaseClassShadowDecl.Value; - public bool ConstructsVirtualBase => Handle.ConstructsVirtualBase; + public bool ConstructsVirtualBase => Handle.ConstructsVirtualBase; - public CXXRecordDecl NominatedBaseClass => _nominatedBaseClass.Value; + public CXXRecordDecl NominatedBaseClass => _nominatedBaseClass.Value; - public ConstructorUsingShadowDecl NominatedBaseClassShadowDecl => _nominatedBaseClassShadowDecl.Value; + public ConstructorUsingShadowDecl NominatedBaseClassShadowDecl => _nominatedBaseClassShadowDecl.Value; - public new CXXRecordDecl Parent => (CXXRecordDecl)DeclContext; - } + public new CXXRecordDecl Parent => (CXXRecordDecl)DeclContext; } diff --git a/sources/ClangSharp/Cursors/Decls/Decl.cs b/sources/ClangSharp/Cursors/Decls/Decl.cs index 0059a7ce..72813e37 100644 --- a/sources/ClangSharp/Cursors/Decls/Decl.cs +++ b/sources/ClangSharp/Cursors/Decls/Decl.cs @@ -4,233 +4,232 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class Decl : Cursor { - public class Decl : Cursor + private readonly Lazy _asFunction; + private readonly Lazy> _attrs; + private readonly Lazy _body; + private readonly Lazy _canonicalDecl; + private readonly Lazy> _decls; + private readonly Lazy _describedTemplate; + private readonly Lazy _mostRecentDecl; + private readonly Lazy _nextDeclInContext; + private readonly Lazy _nonClosureContext; + private readonly Lazy _parentFunctionOrMethod; + private readonly Lazy _previousDecl; + private readonly Lazy _redeclContext; + private readonly Lazy _translationUnitDecl; + + private protected Decl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind) { - private readonly Lazy _asFunction; - private readonly Lazy> _attrs; - private readonly Lazy _body; - private readonly Lazy _canonicalDecl; - private readonly Lazy> _decls; - private readonly Lazy _describedTemplate; - private readonly Lazy _mostRecentDecl; - private readonly Lazy _nextDeclInContext; - private readonly Lazy _nonClosureContext; - private readonly Lazy _parentFunctionOrMethod; - private readonly Lazy _previousDecl; - private readonly Lazy _redeclContext; - private readonly Lazy _translationUnitDecl; - - private protected Decl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind) + if ((handle.DeclKind == CX_DeclKind.CX_DeclKind_Invalid) || (handle.DeclKind != expectedDeclKind)) { - if ((handle.DeclKind == CX_DeclKind.CX_DeclKind_Invalid) || (handle.DeclKind != expectedDeclKind)) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); + } - _asFunction = new Lazy(() => TranslationUnit.GetOrCreate(Handle.AsFunction)); + _asFunction = new Lazy(() => TranslationUnit.GetOrCreate(Handle.AsFunction)); - _attrs = new Lazy>(() => { - var attrCount = Handle.NumAttrs; - var attrs = new List(attrCount); + _attrs = new Lazy>(() => { + var attrCount = Handle.NumAttrs; + var attrs = new List(attrCount); - for (var i = 0; i < attrCount; i++) - { - var attr = TranslationUnit.GetOrCreate(Handle.GetAttr(unchecked((uint)i))); - attrs.Add(attr); - } + for (var i = 0; i < attrCount; i++) + { + var attr = TranslationUnit.GetOrCreate(Handle.GetAttr(unchecked((uint)i))); + attrs.Add(attr); + } - return attrs; - }); + return attrs; + }); - _body = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Body)); - _canonicalDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CanonicalCursor)); + _body = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Body)); + _canonicalDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CanonicalCursor)); - _decls = new Lazy>(() => { - var declCount = Handle.NumDecls; - var decls = new List(declCount); + _decls = new Lazy>(() => { + var declCount = Handle.NumDecls; + var decls = new List(declCount); - for (var i = 0; i < declCount; i++) - { - var decl = TranslationUnit.GetOrCreate(Handle.GetDecl(unchecked((uint)i))); - decls.Add(decl); - } + for (var i = 0; i < declCount; i++) + { + var decl = TranslationUnit.GetOrCreate(Handle.GetDecl(unchecked((uint)i))); + decls.Add(decl); + } - return decls; - }); + return decls; + }); ; - _describedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DescribedTemplate)); - _mostRecentDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.MostRecentDecl)); - _nextDeclInContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NextDeclInContext)); - _nonClosureContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NonClosureContext)); - _parentFunctionOrMethod = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ParentFunctionOrMethod) as IDeclContext); - _previousDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PreviousDecl)); - _redeclContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.RedeclContext) as IDeclContext); - _translationUnitDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TranslationUnit.Cursor)); - } + _describedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DescribedTemplate)); + _mostRecentDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.MostRecentDecl)); + _nextDeclInContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NextDeclInContext)); + _nonClosureContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NonClosureContext)); + _parentFunctionOrMethod = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ParentFunctionOrMethod) as IDeclContext); + _previousDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PreviousDecl)); + _redeclContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.RedeclContext) as IDeclContext); + _translationUnitDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TranslationUnit.Cursor)); + } - public CX_CXXAccessSpecifier Access => Handle.CXXAccessSpecifier; + public CX_CXXAccessSpecifier Access => Handle.CXXAccessSpecifier; - public FunctionDecl AsFunction => _asFunction.Value; + public FunctionDecl AsFunction => _asFunction.Value; - public IReadOnlyList Attrs => _attrs.Value; + public IReadOnlyList Attrs => _attrs.Value; - public CXAvailabilityKind Availability => Handle.Availability; + public CXAvailabilityKind Availability => Handle.Availability; - public Stmt Body => _body.Value; + public Stmt Body => _body.Value; - public Decl CanonicalDecl => _canonicalDecl.Value; + public Decl CanonicalDecl => _canonicalDecl.Value; - public IDeclContext DeclContext => SemanticParentCursor as IDeclContext; + public IDeclContext DeclContext => SemanticParentCursor as IDeclContext; - public string DeclKindName => Handle.DeclKindSpelling; + public string DeclKindName => Handle.DeclKindSpelling; - public IReadOnlyList Decls => _decls.Value; + public IReadOnlyList Decls => _decls.Value; - public TemplateDecl DescribedTemplate => _describedTemplate.Value; + public TemplateDecl DescribedTemplate => _describedTemplate.Value; - public bool HasAttrs => Handle.HasAttrs; + public bool HasAttrs => Handle.HasAttrs; - public bool IsCanonicalDecl => Handle.IsCanonical; + public bool IsCanonicalDecl => Handle.IsCanonical; - public bool IsDeprecated => Handle.IsDeprecated; + public bool IsDeprecated => Handle.IsDeprecated; - public bool IsInStdNamespace => (DeclContext?.IsStdNamespace).GetValueOrDefault(); + public bool IsInStdNamespace => (DeclContext?.IsStdNamespace).GetValueOrDefault(); - public bool IsInvalidDecl => Handle.IsInvalidDeclaration; + public bool IsInvalidDecl => Handle.IsInvalidDeclaration; - public bool IsNamespace => Kind == CX_DeclKind.CX_DeclKind_Namespace; + public bool IsNamespace => Kind == CX_DeclKind.CX_DeclKind_Namespace; - public bool IsStdNamespace + public bool IsStdNamespace + { + get { - get - { - return this is NamespaceDecl nd - && (nd.IsInline ? nd.Parent.IsStdNamespace : nd.Parent.RedeclContext.IsTranslationUnit && nd.Name == "std"); - } + return this is NamespaceDecl nd + && (nd.IsInline ? nd.Parent.IsStdNamespace : nd.Parent.RedeclContext.IsTranslationUnit && nd.Name == "std"); } - - public bool IsTemplated => Handle.IsTemplated; - - public bool IsTranslationUnit => Kind == CX_DeclKind.CX_DeclKind_TranslationUnit; - - public bool IsUnavailable => Handle.IsUnavailable; - - public bool IsUnconditionallyVisible => Handle.IsUnconditionallyVisible; - - public CX_DeclKind Kind => Handle.DeclKind; - - public IDeclContext LexicalDeclContext => LexicalParentCursor as IDeclContext; - - public IDeclContext LexicalParent => (this is IDeclContext) ? LexicalDeclContext : null; - - public uint MaxAlignment => Handle.MaxAlignment; - - public Decl MostRecentDecl => _mostRecentDecl.Value; - - public Decl NextDeclInContext => _nextDeclInContext.Value; - - public Decl NonClosureContext => _nonClosureContext.Value; - - public IDeclContext Parent => (this is IDeclContext) ? DeclContext : null; - - public IDeclContext ParentFunctionOrMethod => _parentFunctionOrMethod.Value; - - public Decl PreviousDecl => _previousDecl.Value; - - public IDeclContext RedeclContext => _redeclContext.Value; - - public CXSourceRange SourceRange => clangsharp.Cursor_getSourceRange(Handle); - - public TranslationUnitDecl TranslationUnitDecl => _translationUnitDecl.Value; - - internal static new Decl Create(CXCursor handle) => handle.DeclKind switch { - CX_DeclKind.CX_DeclKind_Invalid => new Decl(handle, handle.kind, handle.DeclKind), - CX_DeclKind.CX_DeclKind_AccessSpec => new AccessSpecDecl(handle), - CX_DeclKind.CX_DeclKind_Block => new BlockDecl(handle), - CX_DeclKind.CX_DeclKind_Captured => new CapturedDecl(handle), - CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization => new ClassScopeFunctionSpecializationDecl(handle), - CX_DeclKind.CX_DeclKind_Empty => new EmptyDecl(handle), - CX_DeclKind.CX_DeclKind_Export => new ExportDecl(handle), - CX_DeclKind.CX_DeclKind_ExternCContext => new ExternCContextDecl(handle), - CX_DeclKind.CX_DeclKind_FileScopeAsm => new FileScopeAsmDecl(handle), - CX_DeclKind.CX_DeclKind_Friend => new FriendDecl(handle), - CX_DeclKind.CX_DeclKind_FriendTemplate => new FriendTemplateDecl(handle), - CX_DeclKind.CX_DeclKind_Import => new ImportDecl(handle), - CX_DeclKind.CX_DeclKind_LifetimeExtendedTemporary => new LifetimeExtendedTemporaryDecl(handle), - CX_DeclKind.CX_DeclKind_LinkageSpec => new LinkageSpecDecl(handle), - CX_DeclKind.CX_DeclKind_Using => new UsingDecl(handle), - CX_DeclKind.CX_DeclKind_UsingEnum => new UsingEnumDecl(handle), - CX_DeclKind.CX_DeclKind_Label => new LabelDecl(handle), - CX_DeclKind.CX_DeclKind_Namespace => new NamespaceDecl(handle), - CX_DeclKind.CX_DeclKind_NamespaceAlias => new NamespaceAliasDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias => new ObjCCompatibleAliasDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCCategory => new ObjCCategoryDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCCategoryImpl => new ObjCCategoryImplDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCImplementation => new ObjCImplementationDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCInterface => new ObjCInterfaceDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCProtocol => new ObjCProtocolDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCMethod => new ObjCMethodDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCProperty => new ObjCPropertyDecl(handle), - CX_DeclKind.CX_DeclKind_BuiltinTemplate => new BuiltinTemplateDecl(handle), - CX_DeclKind.CX_DeclKind_Concept => new ConceptDecl(handle), - CX_DeclKind.CX_DeclKind_ClassTemplate => new ClassTemplateDecl(handle), - CX_DeclKind.CX_DeclKind_FunctionTemplate => new FunctionTemplateDecl(handle), - CX_DeclKind.CX_DeclKind_TypeAliasTemplate => new TypeAliasTemplateDecl(handle), - CX_DeclKind.CX_DeclKind_VarTemplate => new VarTemplateDecl(handle), - CX_DeclKind.CX_DeclKind_TemplateTemplateParm => new TemplateTemplateParmDecl(handle), - CX_DeclKind.CX_DeclKind_Enum => new EnumDecl(handle), - CX_DeclKind.CX_DeclKind_Record => new RecordDecl(handle), - CX_DeclKind.CX_DeclKind_CXXRecord => new CXXRecordDecl(handle), - CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization => new ClassTemplateSpecializationDecl(handle), - CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization => new ClassTemplatePartialSpecializationDecl(handle), - CX_DeclKind.CX_DeclKind_TemplateTypeParm => new TemplateTypeParmDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCTypeParam => new ObjCTypeParamDecl(handle), - CX_DeclKind.CX_DeclKind_TypeAlias => new TypeAliasDecl(handle), - CX_DeclKind.CX_DeclKind_Typedef => new TypedefDecl(handle), - CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename => new UnresolvedUsingTypenameDecl(handle), - CX_DeclKind.CX_DeclKind_UnresolvedUsingIfExists => new UnresolvedUsingIfExistsDecl(handle), - CX_DeclKind.CX_DeclKind_UsingDirective => new UsingDirectiveDecl(handle), - CX_DeclKind.CX_DeclKind_UsingPack => new UsingPackDecl(handle), - CX_DeclKind.CX_DeclKind_UsingShadow => new UsingShadowDecl(handle), - CX_DeclKind.CX_DeclKind_ConstructorUsingShadow => new ConstructorUsingShadowDecl(handle), - CX_DeclKind.CX_DeclKind_Binding => new BindingDecl(handle), - CX_DeclKind.CX_DeclKind_Field => new FieldDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCAtDefsField => new ObjCAtDefsFieldDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCIvar => new ObjCIvarDecl(handle), - CX_DeclKind.CX_DeclKind_Function => new FunctionDecl(handle), - CX_DeclKind.CX_DeclKind_CXXDeductionGuide => new CXXDeductionGuideDecl(handle), - CX_DeclKind.CX_DeclKind_CXXMethod => new CXXMethodDecl(handle), - CX_DeclKind.CX_DeclKind_CXXConstructor => new CXXConstructorDecl(handle), - CX_DeclKind.CX_DeclKind_CXXConversion => new CXXConversionDecl(handle), - CX_DeclKind.CX_DeclKind_CXXDestructor => new CXXDestructorDecl(handle), - CX_DeclKind.CX_DeclKind_MSProperty => new MSPropertyDecl(handle), - CX_DeclKind.CX_DeclKind_NonTypeTemplateParm => new NonTypeTemplateParmDecl(handle), - CX_DeclKind.CX_DeclKind_Var => new VarDecl(handle), - CX_DeclKind.CX_DeclKind_Decomposition => new DecompositionDecl(handle), - CX_DeclKind.CX_DeclKind_ImplicitParam => new ImplicitParamDecl(handle), - CX_DeclKind.CX_DeclKind_OMPCapturedExpr => new OMPCapturedExprDecl(handle), - CX_DeclKind.CX_DeclKind_ParmVar => new ParmVarDecl(handle), - CX_DeclKind.CX_DeclKind_VarTemplateSpecialization => new VarTemplateSpecializationDecl(handle), - CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization => new VarTemplatePartialSpecializationDecl(handle), - CX_DeclKind.CX_DeclKind_EnumConstant => new EnumConstantDecl(handle), - CX_DeclKind.CX_DeclKind_IndirectField => new IndirectFieldDecl(handle), - CX_DeclKind.CX_DeclKind_MSGuid => new MSGuidDecl(handle), - CX_DeclKind.CX_DeclKind_OMPDeclareMapper => new OMPDeclareMapperDecl(handle), - CX_DeclKind.CX_DeclKind_OMPDeclareReduction => new OMPDeclareReductionDecl(handle), - CX_DeclKind.CX_DeclKind_TemplateParamObject => new TemplateParamObjectDecl(handle), - CX_DeclKind.CX_DeclKind_UnresolvedUsingValue => new UnresolvedUsingValueDecl(handle), - CX_DeclKind.CX_DeclKind_OMPAllocate => new OMPAllocateDecl(handle), - CX_DeclKind.CX_DeclKind_OMPRequires => new OMPRequiresDecl(handle), - CX_DeclKind.CX_DeclKind_OMPThreadPrivate => new OMPThreadPrivateDecl(handle), - CX_DeclKind.CX_DeclKind_ObjCPropertyImpl => new ObjCPropertyImplDecl(handle), - CX_DeclKind.CX_DeclKind_PragmaComment => new PragmaCommentDecl(handle), - CX_DeclKind.CX_DeclKind_PragmaDetectMismatch => new PragmaDetectMismatchDecl(handle), - CX_DeclKind.CX_DeclKind_RequiresExprBody => new RequiresExprBodyDecl(handle), - CX_DeclKind.CX_DeclKind_StaticAssert => new StaticAssertDecl(handle), - CX_DeclKind.CX_DeclKind_TranslationUnit => new TranslationUnitDecl(handle), - _ => new Decl(handle, handle.kind, handle.DeclKind), - }; } + + public bool IsTemplated => Handle.IsTemplated; + + public bool IsTranslationUnit => Kind == CX_DeclKind.CX_DeclKind_TranslationUnit; + + public bool IsUnavailable => Handle.IsUnavailable; + + public bool IsUnconditionallyVisible => Handle.IsUnconditionallyVisible; + + public CX_DeclKind Kind => Handle.DeclKind; + + public IDeclContext LexicalDeclContext => LexicalParentCursor as IDeclContext; + + public IDeclContext LexicalParent => (this is IDeclContext) ? LexicalDeclContext : null; + + public uint MaxAlignment => Handle.MaxAlignment; + + public Decl MostRecentDecl => _mostRecentDecl.Value; + + public Decl NextDeclInContext => _nextDeclInContext.Value; + + public Decl NonClosureContext => _nonClosureContext.Value; + + public IDeclContext Parent => (this is IDeclContext) ? DeclContext : null; + + public IDeclContext ParentFunctionOrMethod => _parentFunctionOrMethod.Value; + + public Decl PreviousDecl => _previousDecl.Value; + + public IDeclContext RedeclContext => _redeclContext.Value; + + public CXSourceRange SourceRange => clangsharp.Cursor_getSourceRange(Handle); + + public TranslationUnitDecl TranslationUnitDecl => _translationUnitDecl.Value; + + internal static new Decl Create(CXCursor handle) => handle.DeclKind switch { + CX_DeclKind.CX_DeclKind_Invalid => new Decl(handle, handle.kind, handle.DeclKind), + CX_DeclKind.CX_DeclKind_AccessSpec => new AccessSpecDecl(handle), + CX_DeclKind.CX_DeclKind_Block => new BlockDecl(handle), + CX_DeclKind.CX_DeclKind_Captured => new CapturedDecl(handle), + CX_DeclKind.CX_DeclKind_ClassScopeFunctionSpecialization => new ClassScopeFunctionSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_Empty => new EmptyDecl(handle), + CX_DeclKind.CX_DeclKind_Export => new ExportDecl(handle), + CX_DeclKind.CX_DeclKind_ExternCContext => new ExternCContextDecl(handle), + CX_DeclKind.CX_DeclKind_FileScopeAsm => new FileScopeAsmDecl(handle), + CX_DeclKind.CX_DeclKind_Friend => new FriendDecl(handle), + CX_DeclKind.CX_DeclKind_FriendTemplate => new FriendTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_Import => new ImportDecl(handle), + CX_DeclKind.CX_DeclKind_LifetimeExtendedTemporary => new LifetimeExtendedTemporaryDecl(handle), + CX_DeclKind.CX_DeclKind_LinkageSpec => new LinkageSpecDecl(handle), + CX_DeclKind.CX_DeclKind_Using => new UsingDecl(handle), + CX_DeclKind.CX_DeclKind_UsingEnum => new UsingEnumDecl(handle), + CX_DeclKind.CX_DeclKind_Label => new LabelDecl(handle), + CX_DeclKind.CX_DeclKind_Namespace => new NamespaceDecl(handle), + CX_DeclKind.CX_DeclKind_NamespaceAlias => new NamespaceAliasDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias => new ObjCCompatibleAliasDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCCategory => new ObjCCategoryDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCCategoryImpl => new ObjCCategoryImplDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCImplementation => new ObjCImplementationDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCInterface => new ObjCInterfaceDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCProtocol => new ObjCProtocolDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCMethod => new ObjCMethodDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCProperty => new ObjCPropertyDecl(handle), + CX_DeclKind.CX_DeclKind_BuiltinTemplate => new BuiltinTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_Concept => new ConceptDecl(handle), + CX_DeclKind.CX_DeclKind_ClassTemplate => new ClassTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_FunctionTemplate => new FunctionTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_TypeAliasTemplate => new TypeAliasTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_VarTemplate => new VarTemplateDecl(handle), + CX_DeclKind.CX_DeclKind_TemplateTemplateParm => new TemplateTemplateParmDecl(handle), + CX_DeclKind.CX_DeclKind_Enum => new EnumDecl(handle), + CX_DeclKind.CX_DeclKind_Record => new RecordDecl(handle), + CX_DeclKind.CX_DeclKind_CXXRecord => new CXXRecordDecl(handle), + CX_DeclKind.CX_DeclKind_ClassTemplateSpecialization => new ClassTemplateSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_ClassTemplatePartialSpecialization => new ClassTemplatePartialSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_TemplateTypeParm => new TemplateTypeParmDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCTypeParam => new ObjCTypeParamDecl(handle), + CX_DeclKind.CX_DeclKind_TypeAlias => new TypeAliasDecl(handle), + CX_DeclKind.CX_DeclKind_Typedef => new TypedefDecl(handle), + CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename => new UnresolvedUsingTypenameDecl(handle), + CX_DeclKind.CX_DeclKind_UnresolvedUsingIfExists => new UnresolvedUsingIfExistsDecl(handle), + CX_DeclKind.CX_DeclKind_UsingDirective => new UsingDirectiveDecl(handle), + CX_DeclKind.CX_DeclKind_UsingPack => new UsingPackDecl(handle), + CX_DeclKind.CX_DeclKind_UsingShadow => new UsingShadowDecl(handle), + CX_DeclKind.CX_DeclKind_ConstructorUsingShadow => new ConstructorUsingShadowDecl(handle), + CX_DeclKind.CX_DeclKind_Binding => new BindingDecl(handle), + CX_DeclKind.CX_DeclKind_Field => new FieldDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCAtDefsField => new ObjCAtDefsFieldDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCIvar => new ObjCIvarDecl(handle), + CX_DeclKind.CX_DeclKind_Function => new FunctionDecl(handle), + CX_DeclKind.CX_DeclKind_CXXDeductionGuide => new CXXDeductionGuideDecl(handle), + CX_DeclKind.CX_DeclKind_CXXMethod => new CXXMethodDecl(handle), + CX_DeclKind.CX_DeclKind_CXXConstructor => new CXXConstructorDecl(handle), + CX_DeclKind.CX_DeclKind_CXXConversion => new CXXConversionDecl(handle), + CX_DeclKind.CX_DeclKind_CXXDestructor => new CXXDestructorDecl(handle), + CX_DeclKind.CX_DeclKind_MSProperty => new MSPropertyDecl(handle), + CX_DeclKind.CX_DeclKind_NonTypeTemplateParm => new NonTypeTemplateParmDecl(handle), + CX_DeclKind.CX_DeclKind_Var => new VarDecl(handle), + CX_DeclKind.CX_DeclKind_Decomposition => new DecompositionDecl(handle), + CX_DeclKind.CX_DeclKind_ImplicitParam => new ImplicitParamDecl(handle), + CX_DeclKind.CX_DeclKind_OMPCapturedExpr => new OMPCapturedExprDecl(handle), + CX_DeclKind.CX_DeclKind_ParmVar => new ParmVarDecl(handle), + CX_DeclKind.CX_DeclKind_VarTemplateSpecialization => new VarTemplateSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization => new VarTemplatePartialSpecializationDecl(handle), + CX_DeclKind.CX_DeclKind_EnumConstant => new EnumConstantDecl(handle), + CX_DeclKind.CX_DeclKind_IndirectField => new IndirectFieldDecl(handle), + CX_DeclKind.CX_DeclKind_MSGuid => new MSGuidDecl(handle), + CX_DeclKind.CX_DeclKind_OMPDeclareMapper => new OMPDeclareMapperDecl(handle), + CX_DeclKind.CX_DeclKind_OMPDeclareReduction => new OMPDeclareReductionDecl(handle), + CX_DeclKind.CX_DeclKind_TemplateParamObject => new TemplateParamObjectDecl(handle), + CX_DeclKind.CX_DeclKind_UnresolvedUsingValue => new UnresolvedUsingValueDecl(handle), + CX_DeclKind.CX_DeclKind_OMPAllocate => new OMPAllocateDecl(handle), + CX_DeclKind.CX_DeclKind_OMPRequires => new OMPRequiresDecl(handle), + CX_DeclKind.CX_DeclKind_OMPThreadPrivate => new OMPThreadPrivateDecl(handle), + CX_DeclKind.CX_DeclKind_ObjCPropertyImpl => new ObjCPropertyImplDecl(handle), + CX_DeclKind.CX_DeclKind_PragmaComment => new PragmaCommentDecl(handle), + CX_DeclKind.CX_DeclKind_PragmaDetectMismatch => new PragmaDetectMismatchDecl(handle), + CX_DeclKind.CX_DeclKind_RequiresExprBody => new RequiresExprBodyDecl(handle), + CX_DeclKind.CX_DeclKind_StaticAssert => new StaticAssertDecl(handle), + CX_DeclKind.CX_DeclKind_TranslationUnit => new TranslationUnitDecl(handle), + _ => new Decl(handle, handle.kind, handle.DeclKind), + }; } diff --git a/sources/ClangSharp/Cursors/Decls/DeclaratorDecl.cs b/sources/ClangSharp/Cursors/Decls/DeclaratorDecl.cs index b45b46d3..496393d3 100644 --- a/sources/ClangSharp/Cursors/Decls/DeclaratorDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/DeclaratorDecl.cs @@ -4,48 +4,47 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class DeclaratorDecl : ValueDecl { - public class DeclaratorDecl : ValueDecl - { - private readonly Lazy>> _templateParameterLists; - private readonly Lazy _trailingRequiresClause; + private readonly Lazy>> _templateParameterLists; + private readonly Lazy _trailingRequiresClause; - private protected DeclaratorDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected DeclaratorDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastDeclarator or < CX_DeclKind.CX_DeclKind_FirstDeclarator) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastDeclarator or < CX_DeclKind.CX_DeclKind_FirstDeclarator) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _templateParameterLists = new Lazy>>(() => { - var numTemplateParameterLists = Handle.NumTemplateParameterLists; - var templateParameterLists = new List>(numTemplateParameterLists); + throw new ArgumentOutOfRangeException(nameof(handle)); + } - for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++) - { - var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked((uint)listIndex)); - var templateParameterList = new List(numTemplateParameters); + _templateParameterLists = new Lazy>>(() => { + var numTemplateParameterLists = Handle.NumTemplateParameterLists; + var templateParameterLists = new List>(numTemplateParameterLists); - for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++) - { - var templateParameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(unchecked((uint)listIndex), unchecked((uint)parameterIndex))); - templateParameterList.Add(templateParameter); - } + for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++) + { + var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked((uint)listIndex)); + var templateParameterList = new List(numTemplateParameters); - templateParameterLists.Add(templateParameterList); + for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++) + { + var templateParameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(unchecked((uint)listIndex), unchecked((uint)parameterIndex))); + templateParameterList.Add(templateParameter); } - return templateParameterLists; - }); + templateParameterLists.Add(templateParameterList); + } - _trailingRequiresClause = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TrailingRequiresClause)); - } + return templateParameterLists; + }); - public uint NumTemplateParameterLists => unchecked((uint)Handle.NumTemplateParameterLists); + _trailingRequiresClause = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TrailingRequiresClause)); + } - public IReadOnlyList> TemplateParameterLists => _templateParameterLists.Value; + public uint NumTemplateParameterLists => unchecked((uint)Handle.NumTemplateParameterLists); - public Expr TrailingRequiresClause => _trailingRequiresClause.Value; - } + public IReadOnlyList> TemplateParameterLists => _templateParameterLists.Value; + + public Expr TrailingRequiresClause => _trailingRequiresClause.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/DecompositionDecl.cs b/sources/ClangSharp/Cursors/Decls/DecompositionDecl.cs index 1f26873e..774efd65 100644 --- a/sources/ClangSharp/Cursors/Decls/DecompositionDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/DecompositionDecl.cs @@ -4,28 +4,27 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class DecompositionDecl : VarDecl - { - private readonly Lazy> _bindings; +namespace ClangSharp; - internal DecompositionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Decomposition) - { - _bindings = new Lazy>(() => { - var numBindings = Handle.NumBindings; - var bindings = new List(numBindings); +public sealed class DecompositionDecl : VarDecl +{ + private readonly Lazy> _bindings; - for (var i = 0; i < numBindings; i++) - { - var binding = TranslationUnit.GetOrCreate(Handle.GetBindingDecl(unchecked((uint)i))); - bindings.Add(binding); - } + internal DecompositionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Decomposition) + { + _bindings = new Lazy>(() => { + var numBindings = Handle.NumBindings; + var bindings = new List(numBindings); - return bindings; - }); - } + for (var i = 0; i < numBindings; i++) + { + var binding = TranslationUnit.GetOrCreate(Handle.GetBindingDecl(unchecked((uint)i))); + bindings.Add(binding); + } - public IReadOnlyList Bindings => _bindings.Value; + return bindings; + }); } + + public IReadOnlyList Bindings => _bindings.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/EmptyDecl.cs b/sources/ClangSharp/Cursors/Decls/EmptyDecl.cs index 0a1db7db..e9370ffc 100644 --- a/sources/ClangSharp/Cursors/Decls/EmptyDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/EmptyDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class EmptyDecl : Decl { - public sealed class EmptyDecl : Decl + internal EmptyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Empty) { - internal EmptyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Empty) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/EnumConstantDecl.cs b/sources/ClangSharp/Cursors/Decls/EnumConstantDecl.cs index 7f3edd9f..dea06366 100644 --- a/sources/ClangSharp/Cursors/Decls/EnumConstantDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/EnumConstantDecl.cs @@ -3,33 +3,32 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class EnumConstantDecl : ValueDecl, IMergeable { - public sealed class EnumConstantDecl : ValueDecl, IMergeable - { - private readonly Lazy _initExpr; + private readonly Lazy _initExpr; - internal EnumConstantDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumConstantDecl, CX_DeclKind.CX_DeclKind_EnumConstant) - { - _initExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InitExpr)); - } + internal EnumConstantDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumConstantDecl, CX_DeclKind.CX_DeclKind_EnumConstant) + { + _initExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InitExpr)); + } - public new EnumConstantDecl CanonicalDecl => (EnumConstantDecl)base.CanonicalDecl; + public new EnumConstantDecl CanonicalDecl => (EnumConstantDecl)base.CanonicalDecl; - public Expr InitExpr => _initExpr.Value; + public Expr InitExpr => _initExpr.Value; - public long InitVal => Handle.EnumConstantDeclValue; + public long InitVal => Handle.EnumConstantDeclValue; - public ulong UnsignedInitVal => Handle.EnumConstantDeclUnsignedValue; + public ulong UnsignedInitVal => Handle.EnumConstantDeclUnsignedValue; - public bool IsNegative => Handle.IsNegative; + public bool IsNegative => Handle.IsNegative; - public bool IsNonNegative => Handle.IsNonNegative; + public bool IsNonNegative => Handle.IsNonNegative; - public bool IsSigned => Handle.IsSigned; + public bool IsSigned => Handle.IsSigned; - public bool IsStrictlyPositive => Handle.IsStrictlyPositive; + public bool IsStrictlyPositive => Handle.IsStrictlyPositive; - public bool IsUnsigned => Handle.IsUnsigned; - } + public bool IsUnsigned => Handle.IsUnsigned; } diff --git a/sources/ClangSharp/Cursors/Decls/EnumDecl.cs b/sources/ClangSharp/Cursors/Decls/EnumDecl.cs index 1929672e..a364dcc0 100644 --- a/sources/ClangSharp/Cursors/Decls/EnumDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/EnumDecl.cs @@ -4,59 +4,58 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class EnumDecl : TagDecl - { - private readonly Lazy> _enumerators; - private readonly Lazy _instantiatedFromMemberEnum; - private readonly Lazy _integerType; - private readonly Lazy _promotionType; - private readonly Lazy _templateInstantiationPattern; - - internal EnumDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumDecl, CX_DeclKind.CX_DeclKind_Enum) - { - _enumerators = new Lazy>(() => { - var numEnumerators = Handle.NumEnumerators; - var enumerators = new List(numEnumerators); - - for (var i = 0; i < numEnumerators; i++) - { - var enumerator = TranslationUnit.GetOrCreate(Handle.GetEnumerator(unchecked((uint)i))); - enumerators.Add(enumerator); - } +namespace ClangSharp; - return enumerators; - }); +public sealed class EnumDecl : TagDecl +{ + private readonly Lazy> _enumerators; + private readonly Lazy _instantiatedFromMemberEnum; + private readonly Lazy _integerType; + private readonly Lazy _promotionType; + private readonly Lazy _templateInstantiationPattern; - _instantiatedFromMemberEnum = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); - _integerType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.EnumDecl_IntegerType)); - _promotionType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.EnumDecl_PromotionType)); - _templateInstantiationPattern = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateInstantiationPattern)); - } + internal EnumDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_EnumDecl, CX_DeclKind.CX_DeclKind_Enum) + { + _enumerators = new Lazy>(() => { + var numEnumerators = Handle.NumEnumerators; + var enumerators = new List(numEnumerators); + + for (var i = 0; i < numEnumerators; i++) + { + var enumerator = TranslationUnit.GetOrCreate(Handle.GetEnumerator(unchecked((uint)i))); + enumerators.Add(enumerator); + } + + return enumerators; + }); + + _instantiatedFromMemberEnum = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); + _integerType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.EnumDecl_IntegerType)); + _promotionType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.EnumDecl_PromotionType)); + _templateInstantiationPattern = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateInstantiationPattern)); + } - public new EnumDecl CanonicalDecl => (EnumDecl)base.CanonicalDecl; + public new EnumDecl CanonicalDecl => (EnumDecl)base.CanonicalDecl; - public new EnumDecl Definition => (EnumDecl)base.Definition; + public new EnumDecl Definition => (EnumDecl)base.Definition; - public IReadOnlyList Enumerators => _enumerators.Value; + public IReadOnlyList Enumerators => _enumerators.Value; - public EnumDecl InstantiatedFromMemberEnum => _instantiatedFromMemberEnum.Value; + public EnumDecl InstantiatedFromMemberEnum => _instantiatedFromMemberEnum.Value; - public Type IntegerType => _integerType.Value; + public Type IntegerType => _integerType.Value; - public bool IsComplete => IsCompleteDefinition || (IntegerType is not null); + public bool IsComplete => IsCompleteDefinition || (IntegerType is not null); - public bool IsScoped => Handle.EnumDecl_IsScoped; + public bool IsScoped => Handle.EnumDecl_IsScoped; - public new EnumDecl MostRecentDecl => (EnumDecl)base.MostRecentDecl; + public new EnumDecl MostRecentDecl => (EnumDecl)base.MostRecentDecl; - public new EnumDecl PreviousDecl => (EnumDecl)base.PreviousDecl; + public new EnumDecl PreviousDecl => (EnumDecl)base.PreviousDecl; - public Type PromotionType => _promotionType.Value; + public Type PromotionType => _promotionType.Value; - public EnumDecl TemplateInstantiationPattern => _templateInstantiationPattern.Value; + public EnumDecl TemplateInstantiationPattern => _templateInstantiationPattern.Value; - public CX_TemplateSpecializationKind TemplateSpecializationKind => Handle.TemplateSpecializationKind; - } + public CX_TemplateSpecializationKind TemplateSpecializationKind => Handle.TemplateSpecializationKind; } diff --git a/sources/ClangSharp/Cursors/Decls/ExportDecl.cs b/sources/ClangSharp/Cursors/Decls/ExportDecl.cs index 317d20b8..5c8369f4 100644 --- a/sources/ClangSharp/Cursors/Decls/ExportDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ExportDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ExportDecl : Decl, IDeclContext { - public sealed class ExportDecl : Decl, IDeclContext + internal ExportDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Export) { - internal ExportDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Export) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/ExternCContextDecl.cs b/sources/ClangSharp/Cursors/Decls/ExternCContextDecl.cs index 40499349..b902c011 100644 --- a/sources/ClangSharp/Cursors/Decls/ExternCContextDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ExternCContextDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ExternCContextDecl : Decl, IDeclContext { - public sealed class ExternCContextDecl : Decl, IDeclContext + internal ExternCContextDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ExternCContext) { - internal ExternCContextDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ExternCContext) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/FieldDecl.cs b/sources/ClangSharp/Cursors/Decls/FieldDecl.cs index ee4a0ab3..1529957c 100644 --- a/sources/ClangSharp/Cursors/Decls/FieldDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FieldDecl.cs @@ -3,48 +3,47 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class FieldDecl : DeclaratorDecl, IMergeable { - public class FieldDecl : DeclaratorDecl, IMergeable + private readonly Lazy _bitWidth; + private readonly Lazy _inClassInitializer; + + internal FieldDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_FieldDecl, CX_DeclKind.CX_DeclKind_Field) { - private readonly Lazy _bitWidth; - private readonly Lazy _inClassInitializer; + } - internal FieldDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_FieldDecl, CX_DeclKind.CX_DeclKind_Field) + private protected FieldDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastField or < CX_DeclKind.CX_DeclKind_FirstField) { + throw new ArgumentOutOfRangeException(nameof(handle)); } - private protected FieldDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) - { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastField or < CX_DeclKind.CX_DeclKind_FirstField) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _bitWidth = new Lazy(() => TranslationUnit.GetOrCreate(Handle.BitWidth)); - _inClassInitializer = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InClassInitializer)); - } + _bitWidth = new Lazy(() => TranslationUnit.GetOrCreate(Handle.BitWidth)); + _inClassInitializer = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InClassInitializer)); + } - public Expr BitWidth => _bitWidth.Value; + public Expr BitWidth => _bitWidth.Value; - public int BitWidthValue => Handle.FieldDeclBitWidth; + public int BitWidthValue => Handle.FieldDeclBitWidth; - public new FieldDecl CanonicalDecl => (FieldDecl)base.CanonicalDecl; + public new FieldDecl CanonicalDecl => (FieldDecl)base.CanonicalDecl; - public int FieldIndex => Handle.FieldIndex; + public int FieldIndex => Handle.FieldIndex; - public Expr InClassInitializer => _inClassInitializer.Value; + public Expr InClassInitializer => _inClassInitializer.Value; - public bool IsAnonymousField => string.IsNullOrWhiteSpace(Name); + public bool IsAnonymousField => string.IsNullOrWhiteSpace(Name); - public bool IsAnonymousStructOrUnion => Handle.IsAnonymousStructOrUnion; + public bool IsAnonymousStructOrUnion => Handle.IsAnonymousStructOrUnion; - public bool IsBitField => Handle.IsBitField; + public bool IsBitField => Handle.IsBitField; - public bool IsMutable => Handle.CXXField_IsMutable; + public bool IsMutable => Handle.CXXField_IsMutable; - public bool IsUnnamedBitfield => Handle.IsUnnamedBitfield; + public bool IsUnnamedBitfield => Handle.IsUnnamedBitfield; - public new RecordDecl Parent => (RecordDecl)DeclContext ?? ((SemanticParentCursor is ClassTemplateDecl classTemplateDecl) ? (RecordDecl)classTemplateDecl.TemplatedDecl : null); - } + public new RecordDecl Parent => (RecordDecl)DeclContext ?? ((SemanticParentCursor is ClassTemplateDecl classTemplateDecl) ? (RecordDecl)classTemplateDecl.TemplatedDecl : null); } diff --git a/sources/ClangSharp/Cursors/Decls/FileScopeAsmDecl.cs b/sources/ClangSharp/Cursors/Decls/FileScopeAsmDecl.cs index 8fb7e8c3..2e81be72 100644 --- a/sources/ClangSharp/Cursors/Decls/FileScopeAsmDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FileScopeAsmDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class FileScopeAsmDecl : Decl { - public sealed class FileScopeAsmDecl : Decl + internal FileScopeAsmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_FileScopeAsm) { - internal FileScopeAsmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_FileScopeAsm) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/FriendDecl.cs b/sources/ClangSharp/Cursors/Decls/FriendDecl.cs index a3f17a8e..30d8f77b 100644 --- a/sources/ClangSharp/Cursors/Decls/FriendDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FriendDecl.cs @@ -4,45 +4,44 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class FriendDecl : Decl { - public sealed class FriendDecl : Decl + private readonly Lazy _friendNamedDecl; + private readonly Lazy>> _friendTypeTemplateParameterLists; + + internal FriendDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FriendDecl, CX_DeclKind.CX_DeclKind_Friend) { - private readonly Lazy _friendNamedDecl; - private readonly Lazy>> _friendTypeTemplateParameterLists; + _friendNamedDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.FriendDecl)); - internal FriendDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FriendDecl, CX_DeclKind.CX_DeclKind_Friend) - { - _friendNamedDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.FriendDecl)); + _friendTypeTemplateParameterLists = new Lazy>>(() => { + var numTemplateParameterLists = Handle.NumTemplateParameterLists; + var templateParameterLists = new List>(numTemplateParameterLists); - _friendTypeTemplateParameterLists = new Lazy>>(() => { - var numTemplateParameterLists = Handle.NumTemplateParameterLists; - var templateParameterLists = new List>(numTemplateParameterLists); + for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++) + { + var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked((uint)listIndex)); + var templateParameterList = new List(numTemplateParameters); - for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++) + for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++) { - var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked((uint)listIndex)); - var templateParameterList = new List(numTemplateParameters); - - for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++) - { - var templateParameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(unchecked((uint)listIndex), unchecked((uint)parameterIndex))); - templateParameterList.Add(templateParameter); - } - - templateParameterLists.Add(templateParameterList); + var templateParameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(unchecked((uint)listIndex), unchecked((uint)parameterIndex))); + templateParameterList.Add(templateParameter); } - return templateParameterLists; - }); - } + templateParameterLists.Add(templateParameterList); + } - public NamedDecl FriendNamedDecl => _friendNamedDecl.Value; + return templateParameterLists; + }); + } - public bool IsUnsupportedFriend => Handle.IsUnsupportedFriend; + public NamedDecl FriendNamedDecl => _friendNamedDecl.Value; - public uint FriendTypeNumTemplateParameterLists => unchecked((uint)Handle.NumTemplateParameterLists); + public bool IsUnsupportedFriend => Handle.IsUnsupportedFriend; - public IReadOnlyList> FriendTypeTemplateParameterLists => _friendTypeTemplateParameterLists.Value; - } + public uint FriendTypeNumTemplateParameterLists => unchecked((uint)Handle.NumTemplateParameterLists); + + public IReadOnlyList> FriendTypeTemplateParameterLists => _friendTypeTemplateParameterLists.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/FriendTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/FriendTemplateDecl.cs index c824f6a2..eb82f359 100644 --- a/sources/ClangSharp/Cursors/Decls/FriendTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FriendTemplateDecl.cs @@ -4,47 +4,46 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class FriendTemplateDecl : Decl { - public sealed class FriendTemplateDecl : Decl + private readonly Lazy _friendDecl; + private readonly Lazy _friendType; + private readonly Lazy>> _templateParameterLists; + + internal FriendTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_FriendTemplate) { - private readonly Lazy _friendDecl; - private readonly Lazy _friendType; - private readonly Lazy>> _templateParameterLists; + _friendDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.FriendDecl)); + _friendType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - internal FriendTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_FriendTemplate) - { - _friendDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.FriendDecl)); - _friendType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + _templateParameterLists = new Lazy>>(() => { + var numTemplateParameterLists = Handle.NumTemplateParameterLists; + var templateParameterLists = new List>(numTemplateParameterLists); - _templateParameterLists = new Lazy>>(() => { - var numTemplateParameterLists = Handle.NumTemplateParameterLists; - var templateParameterLists = new List>(numTemplateParameterLists); + for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++) + { + var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked((uint)listIndex)); + var templateParameterList = new List(numTemplateParameters); - for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++) + for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++) { - var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked((uint)listIndex)); - var templateParameterList = new List(numTemplateParameters); - - for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++) - { - var templateParameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(unchecked((uint)listIndex), unchecked((uint)parameterIndex))); - templateParameterList.Add(templateParameter); - } - - templateParameterLists.Add(templateParameterList); + var templateParameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(unchecked((uint)listIndex), unchecked((uint)parameterIndex))); + templateParameterList.Add(templateParameter); } - return templateParameterLists; - }); - } + templateParameterLists.Add(templateParameterList); + } - public NamedDecl FriendDecl => _friendDecl.Value; + return templateParameterLists; + }); + } - public Type FriendType => _friendType.Value; + public NamedDecl FriendDecl => _friendDecl.Value; - public uint NumTemplateParameterLists => unchecked((uint)Handle.NumTemplateParameterLists); + public Type FriendType => _friendType.Value; - public IReadOnlyList> TemplateParameterLists => _templateParameterLists.Value; - } + public uint NumTemplateParameterLists => unchecked((uint)Handle.NumTemplateParameterLists); + + public IReadOnlyList> TemplateParameterLists => _templateParameterLists.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs b/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs index 9457f5c8..161927b7 100644 --- a/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FunctionDecl.cs @@ -4,135 +4,134 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class FunctionDecl : DeclaratorDecl, IDeclContext, IRedeclarable { - public class FunctionDecl : DeclaratorDecl, IDeclContext, IRedeclarable + private readonly Lazy _callResultType; + private readonly Lazy _declaredReturnType; + private readonly Lazy _definition; + private readonly Lazy _describedFunctionDecl; + private readonly Lazy _instantiatedFromMemberFunction; + private readonly Lazy> _parameters; + private readonly Lazy _primaryTemplate; + private readonly Lazy _returnType; + private readonly Lazy _templateInstantiationPattern; + private readonly Lazy> _templateSpecializationArgs; + + internal FunctionDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_FunctionDecl, CX_DeclKind.CX_DeclKind_Function) + { + } + + private protected FunctionDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { - private readonly Lazy _callResultType; - private readonly Lazy _declaredReturnType; - private readonly Lazy _definition; - private readonly Lazy _describedFunctionDecl; - private readonly Lazy _instantiatedFromMemberFunction; - private readonly Lazy> _parameters; - private readonly Lazy _primaryTemplate; - private readonly Lazy _returnType; - private readonly Lazy _templateInstantiationPattern; - private readonly Lazy> _templateSpecializationArgs; - - internal FunctionDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_FunctionDecl, CX_DeclKind.CX_DeclKind_Function) + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastFunction or < CX_DeclKind.CX_DeclKind_FirstFunction) { + throw new ArgumentOutOfRangeException(nameof(handle)); } - private protected FunctionDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) - { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastFunction or < CX_DeclKind.CX_DeclKind_FirstFunction) + _callResultType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CallResultType)); + _declaredReturnType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DeclaredReturnType)); + _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); + _describedFunctionDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DescribedCursorTemplate)); + _instantiatedFromMemberFunction = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); + + _parameters = new Lazy>(() => { + var parameterCount = Handle.NumArguments; + var parameters = new List(parameterCount); + + for (var i = 0; i < parameterCount; i++) { - throw new ArgumentOutOfRangeException(nameof(handle)); + var parameter = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); + parameters.Add(parameter); } - _callResultType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CallResultType)); - _declaredReturnType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DeclaredReturnType)); - _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); - _describedFunctionDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DescribedCursorTemplate)); - _instantiatedFromMemberFunction = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); - - _parameters = new Lazy>(() => { - var parameterCount = Handle.NumArguments; - var parameters = new List(parameterCount); - - for (var i = 0; i < parameterCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); - parameters.Add(parameter); - } - - return parameters; - }); - - _primaryTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PrimaryTemplate)); - _returnType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ReturnType)); - _templateInstantiationPattern = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateInstantiationPattern)); - - _templateSpecializationArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); - - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); - templateArgs.Add(templateArg); - } - - return templateArgs; - }); - } + return parameters; + }); - public Type CallResultType => _callResultType.Value; + _primaryTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PrimaryTemplate)); + _returnType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ReturnType)); + _templateInstantiationPattern = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateInstantiationPattern)); - public new FunctionDecl CanonicalDecl => (FunctionDecl)base.CanonicalDecl; + _templateSpecializationArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); - public Type DeclaredReturnType => _declaredReturnType.Value; + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); + templateArgs.Add(templateArg); + } - public FunctionDecl Definition => _definition.Value; + return templateArgs; + }); + } - public FunctionTemplateDecl DescribedFunctionDecl => _describedFunctionDecl.Value; + public Type CallResultType => _callResultType.Value; - public CXCursor_ExceptionSpecificationKind ExceptionSpecType => (CXCursor_ExceptionSpecificationKind)Handle.ExceptionSpecificationType; + public new FunctionDecl CanonicalDecl => (FunctionDecl)base.CanonicalDecl; - public bool HasBody => Handle.HasBody; + public Type DeclaredReturnType => _declaredReturnType.Value; - public bool HasImplicitReturnZero => Handle.HasImplicitReturnZero; + public FunctionDecl Definition => _definition.Value; - public FunctionDecl InstantiatedFromMemberFunction => _instantiatedFromMemberFunction.Value; + public FunctionTemplateDecl DescribedFunctionDecl => _describedFunctionDecl.Value; - public bool IsDefaulted => Handle.CXXMethod_IsDefaulted; + public CXCursor_ExceptionSpecificationKind ExceptionSpecType => (CXCursor_ExceptionSpecificationKind)Handle.ExceptionSpecificationType; - public bool IsDefined => Handle.IsDefined; + public bool HasBody => Handle.HasBody; - public bool IsDeleted => Handle.IsDeleted; + public bool HasImplicitReturnZero => Handle.HasImplicitReturnZero; - public bool IsExplicitlyDefaulted => Handle.IsExplicitlyDefaulted; + public FunctionDecl InstantiatedFromMemberFunction => _instantiatedFromMemberFunction.Value; - public bool IsExternC => Handle.IsExternC; + public bool IsDefaulted => Handle.CXXMethod_IsDefaulted; - public bool IsGlobal => Handle.IsGlobal; + public bool IsDefined => Handle.IsDefined; - public bool IsInlined => Handle.IsFunctionInlined; + public bool IsDeleted => Handle.IsDeleted; - public bool IsInstance => !IsStatic; + public bool IsExplicitlyDefaulted => Handle.IsExplicitlyDefaulted; - public bool IsNoReturn => Handle.IsNoReturn; + public bool IsExternC => Handle.IsExternC; - public bool IsOverloadedOperator => Handle.IsOverloadedOperator; + public bool IsGlobal => Handle.IsGlobal; - public bool IsPure => Handle.IsPure; + public bool IsInlined => Handle.IsFunctionInlined; - public bool IsStatic => Handle.IsStatic; + public bool IsInstance => !IsStatic; - public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; + public bool IsNoReturn => Handle.IsNoReturn; - public bool IsUserProvided => Handle.IsUserProvided; + public bool IsOverloadedOperator => Handle.IsOverloadedOperator; - public bool IsVariadic => Handle.IsVariadic; + public bool IsPure => Handle.IsPure; - public string NameInfoName => Handle.Name.CString; + public bool IsStatic => Handle.IsStatic; - public uint NumParams => unchecked((uint)Handle.NumArguments); + public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; - public CX_OverloadedOperatorKind OverloadedOperator => Handle.OverloadedOperatorKind; + public bool IsUserProvided => Handle.IsUserProvided; - public IReadOnlyList Parameters => _parameters.Value; + public bool IsVariadic => Handle.IsVariadic; - public FunctionTemplateDecl PrimaryTemplate => _primaryTemplate.Value; + public string NameInfoName => Handle.Name.CString; - public Type ReturnType => _returnType.Value; + public uint NumParams => unchecked((uint)Handle.NumArguments); - public CX_StorageClass StorageClass => Handle.StorageClass; + public CX_OverloadedOperatorKind OverloadedOperator => Handle.OverloadedOperatorKind; - public FunctionDecl TemplateInstantiationPattern => _templateInstantiationPattern.Value; + public IReadOnlyList Parameters => _parameters.Value; - public IReadOnlyList TemplateSpecializationArgs => _templateSpecializationArgs.Value; + public FunctionTemplateDecl PrimaryTemplate => _primaryTemplate.Value; - public CX_TemplateSpecializationKind TemplateSpecializationKind => Handle.TemplateSpecializationKind; - } + public Type ReturnType => _returnType.Value; + + public CX_StorageClass StorageClass => Handle.StorageClass; + + public FunctionDecl TemplateInstantiationPattern => _templateInstantiationPattern.Value; + + public IReadOnlyList TemplateSpecializationArgs => _templateSpecializationArgs.Value; + + public CX_TemplateSpecializationKind TemplateSpecializationKind => Handle.TemplateSpecializationKind; } diff --git a/sources/ClangSharp/Cursors/Decls/FunctionTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/FunctionTemplateDecl.cs index d377c8a4..e198b573 100644 --- a/sources/ClangSharp/Cursors/Decls/FunctionTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/FunctionTemplateDecl.cs @@ -4,56 +4,55 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class FunctionTemplateDecl : RedeclarableTemplateDecl - { - private readonly Lazy> _injectedTemplateArgs; - private readonly Lazy> _specializations; - - internal FunctionTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FunctionTemplate, CX_DeclKind.CX_DeclKind_FunctionTemplate) - { - _injectedTemplateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); - - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); - templateArgs.Add(templateArg); - } - - return templateArgs; - }); +namespace ClangSharp; - _specializations = new Lazy>(() => { - var numSpecializations = Handle.NumSpecializations; - var specializations = new List(numSpecializations); - - for (var i = 0; i < numSpecializations; i++) - { - var specialization = TranslationUnit.GetOrCreate(Handle.GetSpecialization(unchecked((uint)i))); - specializations.Add(specialization); - } +public sealed class FunctionTemplateDecl : RedeclarableTemplateDecl +{ + private readonly Lazy> _injectedTemplateArgs; + private readonly Lazy> _specializations; - return specializations; - }); - } + internal FunctionTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FunctionTemplate, CX_DeclKind.CX_DeclKind_FunctionTemplate) + { + _injectedTemplateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); + + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); + templateArgs.Add(templateArg); + } + + return templateArgs; + }); + + _specializations = new Lazy>(() => { + var numSpecializations = Handle.NumSpecializations; + var specializations = new List(numSpecializations); + + for (var i = 0; i < numSpecializations; i++) + { + var specialization = TranslationUnit.GetOrCreate(Handle.GetSpecialization(unchecked((uint)i))); + specializations.Add(specialization); + } + + return specializations; + }); + } - public new FunctionTemplateDecl CanonicalDecl => (FunctionTemplateDecl)base.CanonicalDecl; + public new FunctionTemplateDecl CanonicalDecl => (FunctionTemplateDecl)base.CanonicalDecl; - public IReadOnlyList InjectedTemplateArgs => _injectedTemplateArgs.Value; + public IReadOnlyList InjectedTemplateArgs => _injectedTemplateArgs.Value; - public new FunctionTemplateDecl InstantiatedFromMemberTemplate => (FunctionTemplateDecl)base.InstantiatedFromMemberTemplate; + public new FunctionTemplateDecl InstantiatedFromMemberTemplate => (FunctionTemplateDecl)base.InstantiatedFromMemberTemplate; - public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; + public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; - public new FunctionTemplateDecl MostRecentDecl => (FunctionTemplateDecl)base.MostRecentDecl; + public new FunctionTemplateDecl MostRecentDecl => (FunctionTemplateDecl)base.MostRecentDecl; - public new FunctionTemplateDecl PreviousDecl => (FunctionTemplateDecl)base.PreviousDecl; + public new FunctionTemplateDecl PreviousDecl => (FunctionTemplateDecl)base.PreviousDecl; - public IReadOnlyList Specializations => _specializations.Value; + public IReadOnlyList Specializations => _specializations.Value; - public new FunctionDecl TemplatedDecl => (FunctionDecl)base.TemplatedDecl; - } + public new FunctionDecl TemplatedDecl => (FunctionDecl)base.TemplatedDecl; } diff --git a/sources/ClangSharp/Cursors/Decls/ImplicitParamDecl.cs b/sources/ClangSharp/Cursors/Decls/ImplicitParamDecl.cs index a2813bf8..bfab4e28 100644 --- a/sources/ClangSharp/Cursors/Decls/ImplicitParamDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ImplicitParamDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ImplicitParamDecl : VarDecl { - public sealed class ImplicitParamDecl : VarDecl + internal ImplicitParamDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ImplicitParam) { - internal ImplicitParamDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ImplicitParam) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/ImportDecl.cs b/sources/ClangSharp/Cursors/Decls/ImportDecl.cs index 5c32c995..2a3f486d 100644 --- a/sources/ClangSharp/Cursors/Decls/ImportDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ImportDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ImportDecl : Decl { - public sealed class ImportDecl : Decl + internal ImportDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ModuleImportDecl, CX_DeclKind.CX_DeclKind_Import) { - internal ImportDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ModuleImportDecl, CX_DeclKind.CX_DeclKind_Import) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/IndirectFieldDecl.cs b/sources/ClangSharp/Cursors/Decls/IndirectFieldDecl.cs index c2b0980c..7d8bfc34 100644 --- a/sources/ClangSharp/Cursors/Decls/IndirectFieldDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/IndirectFieldDecl.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class IndirectFieldDecl : ValueDecl, IMergeable { - public sealed class IndirectFieldDecl : ValueDecl, IMergeable - { - private readonly Lazy _anonField; - private readonly Lazy _varDecl; + private readonly Lazy _anonField; + private readonly Lazy _varDecl; - internal IndirectFieldDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_IndirectField) - { - _anonField = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _varDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - } + internal IndirectFieldDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_IndirectField) + { + _anonField = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _varDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + } - public FieldDecl AnonField => _anonField.Value; + public FieldDecl AnonField => _anonField.Value; - public VarDecl VarDecl => _varDecl.Value; - } + public VarDecl VarDecl => _varDecl.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/LabelDecl.cs b/sources/ClangSharp/Cursors/Decls/LabelDecl.cs index af7472cc..b6476065 100644 --- a/sources/ClangSharp/Cursors/Decls/LabelDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/LabelDecl.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class LabelDecl : NamedDecl - { - private readonly Lazy _stmt; +namespace ClangSharp; - internal LabelDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Label) - { - _stmt = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); - } +public sealed class LabelDecl : NamedDecl +{ + private readonly Lazy _stmt; - public LabelStmt Stmt => _stmt.Value; + internal LabelDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_Label) + { + _stmt = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); } + + public LabelStmt Stmt => _stmt.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/LifetimeExtendedTemporaryDecl.cs b/sources/ClangSharp/Cursors/Decls/LifetimeExtendedTemporaryDecl.cs index 7a4bc9bb..ebfd4047 100644 --- a/sources/ClangSharp/Cursors/Decls/LifetimeExtendedTemporaryDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/LifetimeExtendedTemporaryDecl.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class LifetimeExtendedTemporaryDecl : Decl, IMergeable { - public sealed class LifetimeExtendedTemporaryDecl : Decl, IMergeable - { - private readonly Lazy _extendingDecl; - private readonly Lazy _temporaryExpr; + private readonly Lazy _extendingDecl; + private readonly Lazy _temporaryExpr; - internal LifetimeExtendedTemporaryDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_LifetimeExtendedTemporary) - { - _extendingDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - _temporaryExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); - } + internal LifetimeExtendedTemporaryDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_LifetimeExtendedTemporary) + { + _extendingDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + _temporaryExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); + } - public ValueDecl ExtendingDecl => _extendingDecl.Value; + public ValueDecl ExtendingDecl => _extendingDecl.Value; - public Expr TemporaryExpr => _temporaryExpr.Value; - } + public Expr TemporaryExpr => _temporaryExpr.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs b/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs index 5a8f95a8..4d2affe7 100644 --- a/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs @@ -3,18 +3,17 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class LinkageSpecDecl : Decl, IDeclContext { - public sealed class LinkageSpecDecl : Decl, IDeclContext + internal LinkageSpecDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_LinkageSpec) { - internal LinkageSpecDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_LinkageSpec) + if (handle.Kind is not CXCursorKind.CXCursor_LinkageSpec and not CXCursorKind.CXCursor_UnexposedDecl) { - if (handle.Kind is not CXCursorKind.CXCursor_LinkageSpec and not CXCursorKind.CXCursor_UnexposedDecl) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } - - public CXLanguageKind Langage => Handle.Language; } + + public CXLanguageKind Langage => Handle.Language; } diff --git a/sources/ClangSharp/Cursors/Decls/MSGuidDecl.cs b/sources/ClangSharp/Cursors/Decls/MSGuidDecl.cs index 5f23df7c..321fd348 100644 --- a/sources/ClangSharp/Cursors/Decls/MSGuidDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/MSGuidDecl.cs @@ -3,14 +3,13 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MSGuidDecl : ValueDecl, IMergeable { - public sealed class MSGuidDecl : ValueDecl, IMergeable + internal MSGuidDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_MSGuid) { - internal MSGuidDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_MSGuid) - { - } - - public Guid Value => Handle.GuidValue; } + + public Guid Value => Handle.GuidValue; } diff --git a/sources/ClangSharp/Cursors/Decls/MSPropertyDecl.cs b/sources/ClangSharp/Cursors/Decls/MSPropertyDecl.cs index b6a38100..b8e6d1f0 100644 --- a/sources/ClangSharp/Cursors/Decls/MSPropertyDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/MSPropertyDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MSPropertyDecl : DeclaratorDecl { - public sealed class MSPropertyDecl : DeclaratorDecl + internal MSPropertyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_MSProperty) { - internal MSPropertyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_MSProperty) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/NamedDecl.cs b/sources/ClangSharp/Cursors/Decls/NamedDecl.cs index 5bf1f91f..4482599c 100644 --- a/sources/ClangSharp/Cursors/Decls/NamedDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/NamedDecl.cs @@ -3,30 +3,29 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class NamedDecl : Decl { - public class NamedDecl : Decl - { - private readonly Lazy _underlyingDecl; + private readonly Lazy _underlyingDecl; - private protected NamedDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected NamedDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastNamed or < CX_DeclKind.CX_DeclKind_FirstNamed) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastNamed or < CX_DeclKind.CX_DeclKind_FirstNamed) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _underlyingDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingDecl)); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public CXLinkageKind LinkageInternal => Handle.Linkage; + _underlyingDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingDecl)); + } - public new NamedDecl MostRecentDecl => (NamedDecl)base.MostRecentDecl; + public CXLinkageKind LinkageInternal => Handle.Linkage; - public string Name => Spelling; + public new NamedDecl MostRecentDecl => (NamedDecl)base.MostRecentDecl; - public NamedDecl UnderlyingDecl => _underlyingDecl.Value; + public string Name => Spelling; - public CXVisibilityKind Visibility => Handle.Visibility; - } + public NamedDecl UnderlyingDecl => _underlyingDecl.Value; + + public CXVisibilityKind Visibility => Handle.Visibility; } diff --git a/sources/ClangSharp/Cursors/Decls/NamespaceAliasDecl.cs b/sources/ClangSharp/Cursors/Decls/NamespaceAliasDecl.cs index 7dc4a8ec..d8e53aea 100644 --- a/sources/ClangSharp/Cursors/Decls/NamespaceAliasDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/NamespaceAliasDecl.cs @@ -3,23 +3,22 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class NamespaceAliasDecl : NamedDecl, IRedeclarable { - public sealed class NamespaceAliasDecl : NamedDecl, IRedeclarable - { - private readonly Lazy _aliasedNamespace; - private readonly Lazy _namespace; + private readonly Lazy _aliasedNamespace; + private readonly Lazy _namespace; - internal NamespaceAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NamespaceAlias, CX_DeclKind.CX_DeclKind_NamespaceAlias) - { - _aliasedNamespace = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _namespace = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - } + internal NamespaceAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NamespaceAlias, CX_DeclKind.CX_DeclKind_NamespaceAlias) + { + _aliasedNamespace = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _namespace = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + } - public NamedDecl AliasedNamespace => _aliasedNamespace.Value; + public NamedDecl AliasedNamespace => _aliasedNamespace.Value; - public new NamespaceAliasDecl CanonicalDecl => (NamespaceAliasDecl)base.CanonicalDecl; + public new NamespaceAliasDecl CanonicalDecl => (NamespaceAliasDecl)base.CanonicalDecl; - public NamespaceDecl Namespace => _namespace.Value; - } + public NamespaceDecl Namespace => _namespace.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/NamespaceDecl.cs b/sources/ClangSharp/Cursors/Decls/NamespaceDecl.cs index d55d4474..81533de5 100644 --- a/sources/ClangSharp/Cursors/Decls/NamespaceDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/NamespaceDecl.cs @@ -3,27 +3,26 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class NamespaceDecl : NamedDecl, IDeclContext, IRedeclarable { - public sealed class NamespaceDecl : NamedDecl, IDeclContext, IRedeclarable - { - private readonly Lazy _anonymousNamespace; - private readonly Lazy _originalNamespace; + private readonly Lazy _anonymousNamespace; + private readonly Lazy _originalNamespace; - internal NamespaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Namespace, CX_DeclKind.CX_DeclKind_Namespace) - { - _anonymousNamespace = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _originalNamespace = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - } + internal NamespaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_Namespace, CX_DeclKind.CX_DeclKind_Namespace) + { + _anonymousNamespace = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _originalNamespace = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + } - public NamespaceDecl AnonymousNamespace => _anonymousNamespace.Value; + public NamespaceDecl AnonymousNamespace => _anonymousNamespace.Value; - public new NamespaceDecl CanonicalDecl => (NamespaceDecl)base.CanonicalDecl; + public new NamespaceDecl CanonicalDecl => (NamespaceDecl)base.CanonicalDecl; - public bool IsAnonymousNamespace => Handle.IsAnonymous; + public bool IsAnonymousNamespace => Handle.IsAnonymous; - public bool IsInline => Handle.IsInlineNamespace; + public bool IsInline => Handle.IsInlineNamespace; - public NamespaceDecl OriginalNamespace => _originalNamespace.Value; - } + public NamespaceDecl OriginalNamespace => _originalNamespace.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/NonTypeTemplateParmDecl.cs b/sources/ClangSharp/Cursors/Decls/NonTypeTemplateParmDecl.cs index a9e077f1..590d28cb 100644 --- a/sources/ClangSharp/Cursors/Decls/NonTypeTemplateParmDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/NonTypeTemplateParmDecl.cs @@ -4,70 +4,69 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class NonTypeTemplateParmDecl : DeclaratorDecl, ITemplateParmPosition { - public sealed class NonTypeTemplateParmDecl : DeclaratorDecl, ITemplateParmPosition - { - private readonly Lazy> _associatedConstraints; - private readonly Lazy _defaultArgument; - private readonly Lazy> _expansionTypes; - private readonly Lazy _placeholderTypeConstraint; + private readonly Lazy> _associatedConstraints; + private readonly Lazy _defaultArgument; + private readonly Lazy> _expansionTypes; + private readonly Lazy _placeholderTypeConstraint; - internal NonTypeTemplateParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NonTypeTemplateParameter, CX_DeclKind.CX_DeclKind_NonTypeTemplateParm) - { - _associatedConstraints = new Lazy>(() => { - var associatedConstraintCount = Handle.NumAssociatedConstraints; - var associatedConstraints = new List(associatedConstraintCount); + internal NonTypeTemplateParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NonTypeTemplateParameter, CX_DeclKind.CX_DeclKind_NonTypeTemplateParm) + { + _associatedConstraints = new Lazy>(() => { + var associatedConstraintCount = Handle.NumAssociatedConstraints; + var associatedConstraints = new List(associatedConstraintCount); - for (var i = 0; i < associatedConstraintCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); - associatedConstraints.Add(parameter); - } + for (var i = 0; i < associatedConstraintCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); + associatedConstraints.Add(parameter); + } - return associatedConstraints; - }); + return associatedConstraints; + }); - _defaultArgument = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DefaultArg)); + _defaultArgument = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DefaultArg)); - _expansionTypes = new Lazy>(() => { - var numExpansionTypes = Handle.NumExpansionTypes; - var expansionTypes = new List(numExpansionTypes); + _expansionTypes = new Lazy>(() => { + var numExpansionTypes = Handle.NumExpansionTypes; + var expansionTypes = new List(numExpansionTypes); - for (var i = 0; i < numExpansionTypes; i++) - { - var expansionType = TranslationUnit.GetOrCreate(Handle.GetExpansionType(unchecked((uint)i))); - expansionTypes.Add(expansionType); - } + for (var i = 0; i < numExpansionTypes; i++) + { + var expansionType = TranslationUnit.GetOrCreate(Handle.GetExpansionType(unchecked((uint)i))); + expansionTypes.Add(expansionType); + } - return expansionTypes; - }); + return expansionTypes; + }); - _placeholderTypeConstraint = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PlaceholderTypeConstraint)); - } + _placeholderTypeConstraint = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PlaceholderTypeConstraint)); + } - public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; + public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; - public Expr DefaultArgument => _defaultArgument.Value; + public Expr DefaultArgument => _defaultArgument.Value; - public bool DefaultArgumentWasInherited => Handle.HasInheritedDefaultArg; + public bool DefaultArgumentWasInherited => Handle.HasInheritedDefaultArg; - public uint Depth => unchecked((uint)Handle.TemplateTypeParmDepth); + public uint Depth => unchecked((uint)Handle.TemplateTypeParmDepth); - public IReadOnlyList ExpansionTypes => _expansionTypes.Value; + public IReadOnlyList ExpansionTypes => _expansionTypes.Value; - public bool HasDefaultArgument => Handle.HasDefaultArg; + public bool HasDefaultArgument => Handle.HasDefaultArg; - public bool HasPlaceholderTypeConstraint => Handle.HasPlaceholderTypeConstraint; + public bool HasPlaceholderTypeConstraint => Handle.HasPlaceholderTypeConstraint; - public uint Index => unchecked((uint)Handle.TemplateTypeParmIndex); + public uint Index => unchecked((uint)Handle.TemplateTypeParmIndex); - public bool IsPackExpansion => Handle.IsPackExpansion; + public bool IsPackExpansion => Handle.IsPackExpansion; - public bool IsParameterPack => Handle.IsParameterPack; + public bool IsParameterPack => Handle.IsParameterPack; - public Expr PlaceholderTypeConstraint => _placeholderTypeConstraint.Value; + public Expr PlaceholderTypeConstraint => _placeholderTypeConstraint.Value; - public uint Position => unchecked((uint)Handle.TemplateTypeParmPosition); - } + public uint Position => unchecked((uint)Handle.TemplateTypeParmPosition); } diff --git a/sources/ClangSharp/Cursors/Decls/OMPAllocateDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPAllocateDecl.cs index 981f2428..337a0c51 100644 --- a/sources/ClangSharp/Cursors/Decls/OMPAllocateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/OMPAllocateDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPAllocateDecl : Decl { - public sealed class OMPAllocateDecl : Decl + internal OMPAllocateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPAllocate) { - internal OMPAllocateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPAllocate) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/OMPCapturedExprDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPCapturedExprDecl.cs index e53d2daa..c9f8fcf7 100644 --- a/sources/ClangSharp/Cursors/Decls/OMPCapturedExprDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/OMPCapturedExprDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPCapturedExprDecl : VarDecl { - public sealed class OMPCapturedExprDecl : VarDecl + internal OMPCapturedExprDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPCapturedExpr) { - internal OMPCapturedExprDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPCapturedExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/OMPDeclareMapperDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPDeclareMapperDecl.cs index 2df8ce7b..73e6a463 100644 --- a/sources/ClangSharp/Cursors/Decls/OMPDeclareMapperDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/OMPDeclareMapperDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPDeclareMapperDecl : ValueDecl, IDeclContext { - public sealed class OMPDeclareMapperDecl : ValueDecl, IDeclContext + internal OMPDeclareMapperDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPDeclareMapper) { - internal OMPDeclareMapperDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPDeclareMapper) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/OMPDeclareReductionDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPDeclareReductionDecl.cs index bd119b95..48d0f14d 100644 --- a/sources/ClangSharp/Cursors/Decls/OMPDeclareReductionDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/OMPDeclareReductionDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPDeclareReductionDecl : ValueDecl, IDeclContext { - public sealed class OMPDeclareReductionDecl : ValueDecl, IDeclContext + internal OMPDeclareReductionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPDeclareReduction) { - internal OMPDeclareReductionDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPDeclareReduction) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/OMPRequiresDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPRequiresDecl.cs index f9a943f0..ec4c4a3f 100644 --- a/sources/ClangSharp/Cursors/Decls/OMPRequiresDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/OMPRequiresDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPRequiresDecl : Decl { - public sealed class OMPRequiresDecl : Decl + internal OMPRequiresDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPRequires) { - internal OMPRequiresDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPRequires) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/OMPThreadPrivateDecl.cs b/sources/ClangSharp/Cursors/Decls/OMPThreadPrivateDecl.cs index bbfc4b8b..943a0ad3 100644 --- a/sources/ClangSharp/Cursors/Decls/OMPThreadPrivateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/OMPThreadPrivateDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPThreadPrivateDecl : Decl { - public sealed class OMPThreadPrivateDecl : Decl + internal OMPThreadPrivateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPThreadPrivate) { - internal OMPThreadPrivateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_OMPThreadPrivate) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCAtDefsFieldDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCAtDefsFieldDecl.cs index d572e296..3e9170c9 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCAtDefsFieldDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCAtDefsFieldDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCAtDefsFieldDecl : FieldDecl { - public sealed class ObjCAtDefsFieldDecl : FieldDecl + internal ObjCAtDefsFieldDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ObjCAtDefsField) { - internal ObjCAtDefsFieldDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ObjCAtDefsField) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCCategoryDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCCategoryDecl.cs index c78455d2..7f44ddf2 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCCategoryDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCCategoryDecl.cs @@ -5,69 +5,68 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCCategoryDecl : ObjCContainerDecl { - public sealed class ObjCCategoryDecl : ObjCContainerDecl + private readonly Lazy _classInterface; + private readonly Lazy _implementation; + private readonly Lazy> _ivars; + private readonly Lazy _nextClassCategory; + private readonly Lazy _nextClassCategoryRaw; + private readonly Lazy> _protocols; + private readonly Lazy> _typeParamList; + + internal ObjCCategoryDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCCategoryDecl, CX_DeclKind.CX_DeclKind_ObjCCategory) { - private readonly Lazy _classInterface; - private readonly Lazy _implementation; - private readonly Lazy> _ivars; - private readonly Lazy _nextClassCategory; - private readonly Lazy _nextClassCategoryRaw; - private readonly Lazy> _protocols; - private readonly Lazy> _typeParamList; - - internal ObjCCategoryDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCCategoryDecl, CX_DeclKind.CX_DeclKind_ObjCCategory) - { - _classInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _implementation = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - _ivars = new Lazy>(() => Decls.OfType().ToList()); - _nextClassCategory = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); - _nextClassCategoryRaw = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(3))); - - _protocols = new Lazy>(() => { - var numProtocols = Handle.NumProtocols; - var protocols = new List(numProtocols); - - for (var i = 0; i < numProtocols; i++) - { - var protocol = TranslationUnit.GetOrCreate(Handle.GetProtocol(unchecked((uint)i))); - protocols.Add(protocol); - } - - return protocols; - }); - - _typeParamList = new Lazy>(() => { - var numTypeParams = Handle.NumArguments; - var typeParams = new List(numTypeParams); - - for (var i = 0; i < numTypeParams; i++) - { - var typeParam = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); - typeParams.Add(typeParam); - } - - return typeParams; - }); - } + _classInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _implementation = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + _ivars = new Lazy>(() => Decls.OfType().ToList()); + _nextClassCategory = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); + _nextClassCategoryRaw = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(3))); + + _protocols = new Lazy>(() => { + var numProtocols = Handle.NumProtocols; + var protocols = new List(numProtocols); + + for (var i = 0; i < numProtocols; i++) + { + var protocol = TranslationUnit.GetOrCreate(Handle.GetProtocol(unchecked((uint)i))); + protocols.Add(protocol); + } + + return protocols; + }); + + _typeParamList = new Lazy>(() => { + var numTypeParams = Handle.NumArguments; + var typeParams = new List(numTypeParams); + + for (var i = 0; i < numTypeParams; i++) + { + var typeParam = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); + typeParams.Add(typeParam); + } + + return typeParams; + }); + } - public ObjCInterfaceDecl ClassInterface => _classInterface.Value; + public ObjCInterfaceDecl ClassInterface => _classInterface.Value; - public ObjCCategoryImplDecl Implementation => _implementation.Value; + public ObjCCategoryImplDecl Implementation => _implementation.Value; - public bool IsClassExtension => Handle.IsClassExtension; + public bool IsClassExtension => Handle.IsClassExtension; - public IReadOnlyList Ivars => _ivars.Value; + public IReadOnlyList Ivars => _ivars.Value; - public ObjCCategoryDecl NextClassCategory => _nextClassCategory.Value; + public ObjCCategoryDecl NextClassCategory => _nextClassCategory.Value; - public ObjCCategoryDecl NextClassCategoryRaw => _nextClassCategoryRaw.Value; + public ObjCCategoryDecl NextClassCategoryRaw => _nextClassCategoryRaw.Value; - public IReadOnlyList Protocols => _protocols.Value; + public IReadOnlyList Protocols => _protocols.Value; - public IReadOnlyList ReferencedProtocols => Protocols; + public IReadOnlyList ReferencedProtocols => Protocols; - public IReadOnlyList TypeParamList => _typeParamList.Value; - } + public IReadOnlyList TypeParamList => _typeParamList.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCCategoryImplDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCCategoryImplDecl.cs index 93f22518..293776dd 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCCategoryImplDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCCategoryImplDecl.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class ObjCCategoryImplDecl : ObjCImplDecl - { - private readonly Lazy _categoryDecl; +namespace ClangSharp; - internal ObjCCategoryImplDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCCategoryImplDecl, CX_DeclKind.CX_DeclKind_ObjCCategoryImpl) - { - _categoryDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - } +public sealed class ObjCCategoryImplDecl : ObjCImplDecl +{ + private readonly Lazy _categoryDecl; - public ObjCCategoryDecl CategoryDecl => _categoryDecl.Value; + internal ObjCCategoryImplDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCCategoryImplDecl, CX_DeclKind.CX_DeclKind_ObjCCategoryImpl) + { + _categoryDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); } + + public ObjCCategoryDecl CategoryDecl => _categoryDecl.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCCompatibleAliasDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCCompatibleAliasDecl.cs index afd05f2b..da4fe45b 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCCompatibleAliasDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCCompatibleAliasDecl.cs @@ -3,18 +3,17 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class ObjCCompatibleAliasDecl : NamedDecl - { - private readonly Lazy _classInterface; +namespace ClangSharp; - internal ObjCCompatibleAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias) - { +public sealed class ObjCCompatibleAliasDecl : NamedDecl +{ + private readonly Lazy _classInterface; - _classInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - } + internal ObjCCompatibleAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ObjCCompatibleAlias) + { - public ObjCInterfaceDecl ClassInterface => _classInterface.Value; + _classInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); } + + public ObjCInterfaceDecl ClassInterface => _classInterface.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCContainerDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCContainerDecl.cs index 8e1e3268..4bab8aba 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCContainerDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCContainerDecl.cs @@ -5,42 +5,41 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class ObjCContainerDecl : NamedDecl, IDeclContext { - public class ObjCContainerDecl : NamedDecl, IDeclContext + private readonly Lazy> _classMethods; + private readonly Lazy> _classProperties; + private readonly Lazy> _instanceMethods; + private readonly Lazy> _instanceProperties; + private readonly Lazy> _methods; + private readonly Lazy> _properties; + + private protected ObjCContainerDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { - private readonly Lazy> _classMethods; - private readonly Lazy> _classProperties; - private readonly Lazy> _instanceMethods; - private readonly Lazy> _instanceProperties; - private readonly Lazy> _methods; - private readonly Lazy> _properties; - - private protected ObjCContainerDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastObjCContainer or < CX_DeclKind.CX_DeclKind_FirstObjCContainer) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastObjCContainer or < CX_DeclKind.CX_DeclKind_FirstObjCContainer) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _classMethods = new Lazy>(() => Methods.Where((method) => method.IsClassMethod).ToList()); - _classProperties = new Lazy>(() => Properties.Where((property) => property.IsClassProperty).ToList()); - _instanceMethods = new Lazy>(() => Methods.Where((method) => method.IsInstanceMethod).ToList()); - _instanceProperties = new Lazy>(() => Properties.Where((property) => property.IsInstanceProperty).ToList()); - _methods = new Lazy>(() => Decls.OfType().ToList()); - _properties = new Lazy>(() => Decls.OfType().ToList()); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public IReadOnlyList ClassMethods => _classMethods.Value; + _classMethods = new Lazy>(() => Methods.Where((method) => method.IsClassMethod).ToList()); + _classProperties = new Lazy>(() => Properties.Where((property) => property.IsClassProperty).ToList()); + _instanceMethods = new Lazy>(() => Methods.Where((method) => method.IsInstanceMethod).ToList()); + _instanceProperties = new Lazy>(() => Properties.Where((property) => property.IsInstanceProperty).ToList()); + _methods = new Lazy>(() => Decls.OfType().ToList()); + _properties = new Lazy>(() => Decls.OfType().ToList()); + } + + public IReadOnlyList ClassMethods => _classMethods.Value; - public IReadOnlyList ClassProperties => _classProperties.Value; + public IReadOnlyList ClassProperties => _classProperties.Value; - public IReadOnlyList InstanceMethods => _instanceMethods.Value; + public IReadOnlyList InstanceMethods => _instanceMethods.Value; - public IReadOnlyList InstanceProperties => _instanceProperties.Value; + public IReadOnlyList InstanceProperties => _instanceProperties.Value; - public IReadOnlyList Methods => _methods.Value; + public IReadOnlyList Methods => _methods.Value; - public IReadOnlyList Properties => _properties.Value; - } + public IReadOnlyList Properties => _properties.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCImplDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCImplDecl.cs index 679958e4..9160c9d2 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCImplDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCImplDecl.cs @@ -5,26 +5,25 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class ObjCImplDecl : ObjCContainerDecl { - public class ObjCImplDecl : ObjCContainerDecl - { - private readonly Lazy _classInterface; - private readonly Lazy> _propertyImpls; + private readonly Lazy _classInterface; + private readonly Lazy> _propertyImpls; - private protected ObjCImplDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected ObjCImplDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastObjCImpl or < CX_DeclKind.CX_DeclKind_FirstObjCImpl) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastObjCImpl or < CX_DeclKind.CX_DeclKind_FirstObjCImpl) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _classInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _propertyImpls = new Lazy>(() => Decls.OfType().ToList()); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public ObjCInterfaceDecl ClassInterface => _classInterface.Value; - - public IReadOnlyList PropertyImpls => _propertyImpls.Value; + _classInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _propertyImpls = new Lazy>(() => Decls.OfType().ToList()); } + + public ObjCInterfaceDecl ClassInterface => _classInterface.Value; + + public IReadOnlyList PropertyImpls => _propertyImpls.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCImplementationDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCImplementationDecl.cs index d1fbdf44..75a3cc2d 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCImplementationDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCImplementationDecl.cs @@ -5,39 +5,38 @@ using ClangSharp.Interop; using System.Linq; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCImplementationDecl : ObjCImplDecl { - public sealed class ObjCImplementationDecl : ObjCImplDecl - { - private readonly Lazy> _initExprs; - private readonly Lazy> _ivars; - private readonly Lazy _superClass; + private readonly Lazy> _initExprs; + private readonly Lazy> _ivars; + private readonly Lazy _superClass; - internal ObjCImplementationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCImplementationDecl, CX_DeclKind.CX_DeclKind_ObjCImplementation) - { - _initExprs = new Lazy>(() => { - var numInitExprs = Handle.NumExprs; - var initExprs = new List(numInitExprs); + internal ObjCImplementationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCImplementationDecl, CX_DeclKind.CX_DeclKind_ObjCImplementation) + { + _initExprs = new Lazy>(() => { + var numInitExprs = Handle.NumExprs; + var initExprs = new List(numInitExprs); - for (var i = 0; i < numInitExprs; i++) - { - var initExpr = TranslationUnit.GetOrCreate(Handle.GetExpr(unchecked((uint)i))); - initExprs.Add(initExpr); - } + for (var i = 0; i < numInitExprs; i++) + { + var initExpr = TranslationUnit.GetOrCreate(Handle.GetExpr(unchecked((uint)i))); + initExprs.Add(initExpr); + } - return initExprs; - }); + return initExprs; + }); - _ivars = new Lazy>(() => Decls.OfType().ToList()); - _superClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - } + _ivars = new Lazy>(() => Decls.OfType().ToList()); + _superClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + } - public IReadOnlyList InitExprs => _initExprs.Value; + public IReadOnlyList InitExprs => _initExprs.Value; - public IReadOnlyList Ivars => _ivars.Value; + public IReadOnlyList Ivars => _ivars.Value; - public uint NumIvarInitializers => unchecked((uint)_ivars.Value.Count); + public uint NumIvarInitializers => unchecked((uint)_ivars.Value.Count); - public ObjCInterfaceDecl SuperClass => _superClass.Value; - } + public ObjCInterfaceDecl SuperClass => _superClass.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCInterfaceDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCInterfaceDecl.cs index ba038e37..f6ebf140 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCInterfaceDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCInterfaceDecl.cs @@ -5,108 +5,107 @@ using ClangSharp.Interop; using System.Linq; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCInterfaceDecl : ObjCContainerDecl, IRedeclarable { - public sealed class ObjCInterfaceDecl : ObjCContainerDecl, IRedeclarable + private readonly Lazy> _categoryList; + private readonly Lazy _definition; + private readonly Lazy _implementation; + private readonly Lazy> _ivars; + private readonly Lazy> _knownExtensions; + private readonly Lazy> _protocols; + private readonly Lazy _superClass; + private readonly Lazy _superClassType; + private readonly Lazy _typeForDecl; + private readonly Lazy> _typeParamList; + private readonly Lazy> _visibleCategories; + private readonly Lazy> _visibleExtensions; + + internal ObjCInterfaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCInterfaceDecl, CX_DeclKind.CX_DeclKind_ObjCInterface) { - private readonly Lazy> _categoryList; - private readonly Lazy _definition; - private readonly Lazy _implementation; - private readonly Lazy> _ivars; - private readonly Lazy> _knownExtensions; - private readonly Lazy> _protocols; - private readonly Lazy _superClass; - private readonly Lazy _superClassType; - private readonly Lazy _typeForDecl; - private readonly Lazy> _typeParamList; - private readonly Lazy> _visibleCategories; - private readonly Lazy> _visibleExtensions; - - internal ObjCInterfaceDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCInterfaceDecl, CX_DeclKind.CX_DeclKind_ObjCInterface) - { - _categoryList = new Lazy>(() => { - var categories = new List(); + _categoryList = new Lazy>(() => { + var categories = new List(); - var category = TranslationUnit.GetOrCreate(handle.GetSubDecl(0)); + var category = TranslationUnit.GetOrCreate(handle.GetSubDecl(0)); - while (category != null) - { - categories.Add(category); - category = category.NextClassCategoryRaw; - } + while (category != null) + { + categories.Add(category); + category = category.NextClassCategoryRaw; + } - return categories; - }); + return categories; + }); - _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); - _implementation = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - _ivars = new Lazy>(() => Decls.OfType().ToList()); - _knownExtensions = new Lazy>(() => CategoryList.Where((category) => category.IsClassExtension).ToList()); + _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); + _implementation = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + _ivars = new Lazy>(() => Decls.OfType().ToList()); + _knownExtensions = new Lazy>(() => CategoryList.Where((category) => category.IsClassExtension).ToList()); - _protocols = new Lazy>(() => { - var numProtocols = Handle.NumProtocols; - var protocols = new List(numProtocols); + _protocols = new Lazy>(() => { + var numProtocols = Handle.NumProtocols; + var protocols = new List(numProtocols); - for (var i = 0; i < numProtocols; i++) - { - var protocol = TranslationUnit.GetOrCreate(Handle.GetProtocol(unchecked((uint)i))); - protocols.Add(protocol); - } + for (var i = 0; i < numProtocols; i++) + { + var protocol = TranslationUnit.GetOrCreate(Handle.GetProtocol(unchecked((uint)i))); + protocols.Add(protocol); + } - return protocols; - }); + return protocols; + }); - _superClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); - _superClassType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - _typeForDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ThisType)); + _superClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); + _superClassType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + _typeForDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ThisType)); - _typeParamList = new Lazy>(() => { - var numTypeParams = Handle.NumArguments; - var typeParams = new List(numTypeParams); + _typeParamList = new Lazy>(() => { + var numTypeParams = Handle.NumArguments; + var typeParams = new List(numTypeParams); - for (var i = 0; i < numTypeParams; i++) - { - var typeParam = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); - typeParams.Add(typeParam); - } + for (var i = 0; i < numTypeParams; i++) + { + var typeParam = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); + typeParams.Add(typeParam); + } - return typeParams; - }); + return typeParams; + }); - _visibleCategories = new Lazy>(() => CategoryList.Where((category) => category.IsUnconditionallyVisible).ToList()); - _visibleExtensions = new Lazy>(() => CategoryList.Where((category) => category.IsClassExtension && category.IsUnconditionallyVisible).ToList()); - } + _visibleCategories = new Lazy>(() => CategoryList.Where((category) => category.IsUnconditionallyVisible).ToList()); + _visibleExtensions = new Lazy>(() => CategoryList.Where((category) => category.IsClassExtension && category.IsUnconditionallyVisible).ToList()); + } - public new ObjCInterfaceDecl CanonicalDecl => (ObjCInterfaceDecl)base.CanonicalDecl; + public new ObjCInterfaceDecl CanonicalDecl => (ObjCInterfaceDecl)base.CanonicalDecl; - public IReadOnlyList CategoryList => _categoryList.Value; + public IReadOnlyList CategoryList => _categoryList.Value; - public ObjCInterfaceDecl Definition => _definition.Value; + public ObjCInterfaceDecl Definition => _definition.Value; - public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; + public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; - public ObjCImplementationDecl Implementation => _implementation.Value; + public ObjCImplementationDecl Implementation => _implementation.Value; - public IReadOnlyList Ivars => _ivars.Value; + public IReadOnlyList Ivars => _ivars.Value; - public IReadOnlyList KnownCategories => CategoryList; + public IReadOnlyList KnownCategories => CategoryList; - public IReadOnlyList KnownExtensions => _knownExtensions.Value; + public IReadOnlyList KnownExtensions => _knownExtensions.Value; - public ObjCInterfaceDecl SuperClass => _superClass.Value; + public ObjCInterfaceDecl SuperClass => _superClass.Value; - public ObjCObjectType SuperClassType => _superClassType.Value; + public ObjCObjectType SuperClassType => _superClassType.Value; - public IReadOnlyList Protocols => _protocols.Value; + public IReadOnlyList Protocols => _protocols.Value; - public IReadOnlyList ReferencedProtocols => Protocols; + public IReadOnlyList ReferencedProtocols => Protocols; - public IReadOnlyList TypeParamList => _typeParamList.Value; + public IReadOnlyList TypeParamList => _typeParamList.Value; - public Type TypeForDecl => _typeForDecl.Value; + public Type TypeForDecl => _typeForDecl.Value; - public IReadOnlyList VisibleCategories => _visibleCategories.Value; + public IReadOnlyList VisibleCategories => _visibleCategories.Value; - public IReadOnlyList VisibleExtensions => _visibleExtensions.Value; - } + public IReadOnlyList VisibleExtensions => _visibleExtensions.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCIvarDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCIvarDecl.cs index 92377fb2..34360615 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCIvarDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCIvarDecl.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCIvarDecl : FieldDecl { - public sealed class ObjCIvarDecl : FieldDecl - { - private readonly Lazy _containingInterface; - private readonly Lazy _nextIvar; + private readonly Lazy _containingInterface; + private readonly Lazy _nextIvar; - internal ObjCIvarDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCIvarDecl, CX_DeclKind.CX_DeclKind_ObjCIvar) - { - _containingInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _nextIvar = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - } + internal ObjCIvarDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCIvarDecl, CX_DeclKind.CX_DeclKind_ObjCIvar) + { + _containingInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _nextIvar = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + } - public ObjCInterfaceDecl ContainingInterface => _containingInterface.Value; + public ObjCInterfaceDecl ContainingInterface => _containingInterface.Value; - public ObjCIvarDecl NextIvar => _nextIvar.Value; - } + public ObjCIvarDecl NextIvar => _nextIvar.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCMethodDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCMethodDecl.cs index 3f0d3b54..dff44b5a 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCMethodDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCMethodDecl.cs @@ -4,65 +4,64 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCMethodDecl : NamedDecl, IDeclContext { - public sealed class ObjCMethodDecl : NamedDecl, IDeclContext + private readonly Lazy _classInterface; + private readonly Lazy _cmdDecl; + private readonly Lazy> _parameters; + private readonly Lazy _returnType; + private readonly Lazy _selfDecl; + private readonly Lazy _sendResultType; + + internal ObjCMethodDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ObjCMethod) { - private readonly Lazy _classInterface; - private readonly Lazy _cmdDecl; - private readonly Lazy> _parameters; - private readonly Lazy _returnType; - private readonly Lazy _selfDecl; - private readonly Lazy _sendResultType; - - internal ObjCMethodDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ObjCMethod) + if (handle.Kind is not CXCursorKind.CXCursor_ObjCInstanceMethodDecl and not CXCursorKind.CXCursor_ObjCClassMethodDecl) { - if (handle.Kind is not CXCursorKind.CXCursor_ObjCInstanceMethodDecl and not CXCursorKind.CXCursor_ObjCClassMethodDecl) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); + } - _classInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _cmdDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + _classInterface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _cmdDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - _parameters = new Lazy>(() => { - var parameterCount = Handle.NumArguments; - var parameters = new List(parameterCount); + _parameters = new Lazy>(() => { + var parameterCount = Handle.NumArguments; + var parameters = new List(parameterCount); - for (var i = 0; i < parameterCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); - parameters.Add(parameter); - } + for (var i = 0; i < parameterCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); + parameters.Add(parameter); + } - return parameters; - }); + return parameters; + }); - _selfDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); - _returnType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ReturnType)); - _sendResultType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } + _selfDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); + _returnType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ReturnType)); + _sendResultType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + } - public new ObjCMethodDecl CanonicalDecl => (ObjCMethodDecl)base.CanonicalDecl; + public new ObjCMethodDecl CanonicalDecl => (ObjCMethodDecl)base.CanonicalDecl; - public ObjCInterfaceDecl ClassInterface => _classInterface.Value; + public ObjCInterfaceDecl ClassInterface => _classInterface.Value; - public ImplicitParamDecl CmdDecl => _cmdDecl.Value; + public ImplicitParamDecl CmdDecl => _cmdDecl.Value; - public bool IsClassMethod => CursorKind == CXCursorKind.CXCursor_ObjCClassMethodDecl; + public bool IsClassMethod => CursorKind == CXCursorKind.CXCursor_ObjCClassMethodDecl; - public bool IsInstanceMethod => CursorKind == CXCursorKind.CXCursor_ObjCInstanceMethodDecl; + public bool IsInstanceMethod => CursorKind == CXCursorKind.CXCursor_ObjCInstanceMethodDecl; - public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; + public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; - public CXObjCDeclQualifierKind ObjCDeclQualifier => Handle.ObjCDeclQualifiers; + public CXObjCDeclQualifierKind ObjCDeclQualifier => Handle.ObjCDeclQualifiers; - public IReadOnlyList Parameters => _parameters.Value; + public IReadOnlyList Parameters => _parameters.Value; - public Type ReturnType => _returnType.Value; + public Type ReturnType => _returnType.Value; - public ImplicitParamDecl SelfDecl => _selfDecl.Value; + public ImplicitParamDecl SelfDecl => _selfDecl.Value; - public Type SendResultType => _sendResultType.Value; - } + public Type SendResultType => _sendResultType.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCPropertyDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCPropertyDecl.cs index ec4ce814..3014d9c2 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCPropertyDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCPropertyDecl.cs @@ -3,35 +3,34 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCPropertyDecl : NamedDecl { - public sealed class ObjCPropertyDecl : NamedDecl - { - private readonly Lazy _getterMethodDecl; - private readonly Lazy _propertyIvarDecl; - private readonly Lazy _setterMethodDecl; - private readonly Lazy _type; + private readonly Lazy _getterMethodDecl; + private readonly Lazy _propertyIvarDecl; + private readonly Lazy _setterMethodDecl; + private readonly Lazy _type; - internal ObjCPropertyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCPropertyDecl, CX_DeclKind.CX_DeclKind_ObjCProperty) - { - _getterMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _propertyIvarDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - _setterMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); - _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ReturnType)); - } + internal ObjCPropertyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCPropertyDecl, CX_DeclKind.CX_DeclKind_ObjCProperty) + { + _getterMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _propertyIvarDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + _setterMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); + _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ReturnType)); + } - public ObjCMethodDecl GetterMethodDecl => _getterMethodDecl.Value; + public ObjCMethodDecl GetterMethodDecl => _getterMethodDecl.Value; - public bool IsClassProperty => (PropertyAttributes & CXObjCPropertyAttrKind.CXObjCPropertyAttr_class) != 0; + public bool IsClassProperty => (PropertyAttributes & CXObjCPropertyAttrKind.CXObjCPropertyAttr_class) != 0; - public bool IsInstanceProperty => !IsClassProperty; + public bool IsInstanceProperty => !IsClassProperty; - public CXObjCPropertyAttrKind PropertyAttributes => Handle.GetObjCPropertyAttributes(0); + public CXObjCPropertyAttrKind PropertyAttributes => Handle.GetObjCPropertyAttributes(0); - public ObjCIvarDecl PropertyIvarDecl => _propertyIvarDecl.Value; + public ObjCIvarDecl PropertyIvarDecl => _propertyIvarDecl.Value; - public ObjCMethodDecl SetterMethodDecl => _setterMethodDecl.Value; + public ObjCMethodDecl SetterMethodDecl => _setterMethodDecl.Value; - public Type Type => _type.Value; - } + public Type Type => _type.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCPropertyImplDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCPropertyImplDecl.cs index e64e3ab4..f0441baa 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCPropertyImplDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCPropertyImplDecl.cs @@ -3,42 +3,41 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCPropertyImplDecl : Decl { - public sealed class ObjCPropertyImplDecl : Decl + private readonly Lazy _getterCXXConstructor; + private readonly Lazy _getterMethodDecl; + private readonly Lazy _propertyDecl; + private readonly Lazy _propertyIvarDecl; + private readonly Lazy _setterMethodDecl; + private readonly Lazy _setterCXXAssignment; + + internal ObjCPropertyImplDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ObjCPropertyImpl) { - private readonly Lazy _getterCXXConstructor; - private readonly Lazy _getterMethodDecl; - private readonly Lazy _propertyDecl; - private readonly Lazy _propertyIvarDecl; - private readonly Lazy _setterMethodDecl; - private readonly Lazy _setterCXXAssignment; - - internal ObjCPropertyImplDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKind.CX_DeclKind_ObjCPropertyImpl) + if (handle.Kind is not CXCursorKind.CXCursor_ObjCSynthesizeDecl and not CXCursorKind.CXCursor_ObjCDynamicDecl) { - if (handle.Kind is not CXCursorKind.CXCursor_ObjCSynthesizeDecl and not CXCursorKind.CXCursor_ObjCDynamicDecl) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _getterCXXConstructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); - _getterMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); - _propertyDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); - _propertyIvarDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); - _setterMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(3))); - _setterCXXAssignment = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(1))); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public Expr GetterCXXConstructor => _getterCXXConstructor.Value; + _getterCXXConstructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); + _getterMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(0))); + _propertyDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(1))); + _propertyIvarDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(2))); + _setterMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetSubDecl(3))); + _setterCXXAssignment = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(1))); + } + + public Expr GetterCXXConstructor => _getterCXXConstructor.Value; - public ObjCMethodDecl GetterMethodDecl => _getterMethodDecl.Value; + public ObjCMethodDecl GetterMethodDecl => _getterMethodDecl.Value; - public ObjCPropertyDecl PropertyDecl => _propertyDecl.Value; + public ObjCPropertyDecl PropertyDecl => _propertyDecl.Value; - public ObjCIvarDecl PropertyIvarDecl => _propertyIvarDecl.Value; + public ObjCIvarDecl PropertyIvarDecl => _propertyIvarDecl.Value; - public Expr SetterCXXAssignment => _setterCXXAssignment.Value; + public Expr SetterCXXAssignment => _setterCXXAssignment.Value; - public ObjCMethodDecl SetterMethodDecl => _setterMethodDecl.Value; - } + public ObjCMethodDecl SetterMethodDecl => _setterMethodDecl.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCProtocolDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCProtocolDecl.cs index 2b61ee4e..93b8c560 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCProtocolDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCProtocolDecl.cs @@ -4,43 +4,42 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCProtocolDecl : ObjCContainerDecl, IRedeclarable { - public sealed class ObjCProtocolDecl : ObjCContainerDecl, IRedeclarable - { - private readonly Lazy _definition; - private readonly Lazy> _protocols; + private readonly Lazy _definition; + private readonly Lazy> _protocols; - internal ObjCProtocolDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCProtocolDecl, CX_DeclKind.CX_DeclKind_ObjCProtocol) - { - _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); + internal ObjCProtocolDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCProtocolDecl, CX_DeclKind.CX_DeclKind_ObjCProtocol) + { + _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); - _protocols = new Lazy>(() => { - var numProtocols = Handle.NumProtocols; - var protocols = new List(numProtocols); + _protocols = new Lazy>(() => { + var numProtocols = Handle.NumProtocols; + var protocols = new List(numProtocols); - for (var i = 0; i < numProtocols; i++) - { - var protocol = TranslationUnit.GetOrCreate(Handle.GetProtocol(unchecked((uint)i))); - protocols.Add(protocol); - } + for (var i = 0; i < numProtocols; i++) + { + var protocol = TranslationUnit.GetOrCreate(Handle.GetProtocol(unchecked((uint)i))); + protocols.Add(protocol); + } - return protocols; - }); - } + return protocols; + }); + } - public new ObjCProtocolDecl CanonicalDecl => (ObjCProtocolDecl)base.CanonicalDecl; + public new ObjCProtocolDecl CanonicalDecl => (ObjCProtocolDecl)base.CanonicalDecl; - public ObjCProtocolDecl Definition => _definition.Value; + public ObjCProtocolDecl Definition => _definition.Value; - public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; + public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; - public string ObjCRuntimeNameAsString => Handle.Name.CString; + public string ObjCRuntimeNameAsString => Handle.Name.CString; - public IReadOnlyList Protocols => _protocols.Value; + public IReadOnlyList Protocols => _protocols.Value; - public uint ProtocolSize => unchecked((uint)Handle.NumProtocols); + public uint ProtocolSize => unchecked((uint)Handle.NumProtocols); - public IReadOnlyList ReferencedProtocols => Protocols; - } + public IReadOnlyList ReferencedProtocols => Protocols; } diff --git a/sources/ClangSharp/Cursors/Decls/ObjCTypeParamDecl.cs b/sources/ClangSharp/Cursors/Decls/ObjCTypeParamDecl.cs index c6fa7369..300b2278 100644 --- a/sources/ClangSharp/Cursors/Decls/ObjCTypeParamDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ObjCTypeParamDecl.cs @@ -2,14 +2,13 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCTypeParamDecl : TypedefNameDecl { - public sealed class ObjCTypeParamDecl : TypedefNameDecl + internal ObjCTypeParamDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ObjCTypeParam) { - internal ObjCTypeParamDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_ObjCTypeParam) - { - } - - public uint Index => unchecked((uint)Handle.TemplateTypeParmIndex); } + + public uint Index => unchecked((uint)Handle.TemplateTypeParmIndex); } diff --git a/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs b/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs index 2bc031f9..ff13ec9d 100644 --- a/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ParmVarDecl.cs @@ -3,33 +3,32 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ParmVarDecl : VarDecl { - public sealed class ParmVarDecl : VarDecl - { - private readonly Lazy _defaultArg; - private readonly Lazy _originalType; - private readonly Lazy _uninstantiatedDefaultArg; + private readonly Lazy _defaultArg; + private readonly Lazy _originalType; + private readonly Lazy _uninstantiatedDefaultArg; - internal ParmVarDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ParmDecl, CX_DeclKind.CX_DeclKind_ParmVar) - { - _defaultArg = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DefaultArg)); - _originalType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); - _uninstantiatedDefaultArg = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UninstantiatedDefaultArg)); - } + internal ParmVarDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ParmDecl, CX_DeclKind.CX_DeclKind_ParmVar) + { + _defaultArg = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DefaultArg)); + _originalType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); + _uninstantiatedDefaultArg = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UninstantiatedDefaultArg)); + } - public Expr DefaultArg => _defaultArg.Value; + public Expr DefaultArg => _defaultArg.Value; - public int FunctionScopeDepth => Handle.FunctionScopeDepth; + public int FunctionScopeDepth => Handle.FunctionScopeDepth; - public int FunctionScopeIndex => Handle.FunctionScopeIndex; + public int FunctionScopeIndex => Handle.FunctionScopeIndex; - public bool HasDefaultArg => Handle.HasDefaultArg; + public bool HasDefaultArg => Handle.HasDefaultArg; - public bool HasInheritedDefaultArg => Handle.HasInheritedDefaultArg; + public bool HasInheritedDefaultArg => Handle.HasInheritedDefaultArg; - public Type OriginalType => _originalType.Value; + public Type OriginalType => _originalType.Value; - public Expr UninstantiatedDefaultArg => _uninstantiatedDefaultArg.Value; - } + public Expr UninstantiatedDefaultArg => _uninstantiatedDefaultArg.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/PragmaCommentDecl.cs b/sources/ClangSharp/Cursors/Decls/PragmaCommentDecl.cs index 5732f393..33634dfd 100644 --- a/sources/ClangSharp/Cursors/Decls/PragmaCommentDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/PragmaCommentDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class PragmaCommentDecl : Decl { - public sealed class PragmaCommentDecl : Decl + internal PragmaCommentDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_PragmaComment) { - internal PragmaCommentDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_PragmaComment) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/PragmaDetectMismatchDecl.cs b/sources/ClangSharp/Cursors/Decls/PragmaDetectMismatchDecl.cs index 1dce6e96..ede99a06 100644 --- a/sources/ClangSharp/Cursors/Decls/PragmaDetectMismatchDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/PragmaDetectMismatchDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class PragmaDetectMismatchDecl : Decl { - public sealed class PragmaDetectMismatchDecl : Decl + internal PragmaDetectMismatchDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_PragmaDetectMismatch) { - internal PragmaDetectMismatchDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_PragmaDetectMismatch) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/RecordDecl.cs b/sources/ClangSharp/Cursors/Decls/RecordDecl.cs index 947f27a9..5a9282b3 100644 --- a/sources/ClangSharp/Cursors/Decls/RecordDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/RecordDecl.cs @@ -5,70 +5,69 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class RecordDecl : TagDecl { - public class RecordDecl : TagDecl + private readonly Lazy> _anonymousFields; + private readonly Lazy> _anonymousRecords; + private readonly Lazy> _fields; + private readonly Lazy> _indirectFields; + private readonly Lazy _injectedClassName; + + + internal RecordDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_Record) + { + } + + private protected RecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) { - private readonly Lazy> _anonymousFields; - private readonly Lazy> _anonymousRecords; - private readonly Lazy> _fields; - private readonly Lazy> _indirectFields; - private readonly Lazy _injectedClassName; - - - internal RecordDecl(CXCursor handle) : this(handle, handle.Kind, CX_DeclKind.CX_DeclKind_Record) + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastRecord or < CX_DeclKind.CX_DeclKind_FirstRecord) { + throw new ArgumentOutOfRangeException(nameof(handle)); } - private protected RecordDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + if (handle.Kind is not CXCursorKind.CXCursor_StructDecl and not CXCursorKind.CXCursor_UnionDecl and not CXCursorKind.CXCursor_ClassDecl and not CXCursorKind.CXCursor_ClassTemplatePartialSpecialization) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastRecord or < CX_DeclKind.CX_DeclKind_FirstRecord) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); + } - if (handle.Kind is not CXCursorKind.CXCursor_StructDecl and not CXCursorKind.CXCursor_UnionDecl and not CXCursorKind.CXCursor_ClassDecl and not CXCursorKind.CXCursor_ClassTemplatePartialSpecialization) + _fields = new Lazy>(() => { + var numFields = Handle.NumFields; + var fields = new List(numFields); + + for (var i = 0; i < numFields; i++) { - throw new ArgumentOutOfRangeException(nameof(handle)); + var field = TranslationUnit.GetOrCreate(Handle.GetField(unchecked((uint)i))); + fields.Add(field); } - _fields = new Lazy>(() => { - var numFields = Handle.NumFields; - var fields = new List(numFields); - - for (var i = 0; i < numFields; i++) - { - var field = TranslationUnit.GetOrCreate(Handle.GetField(unchecked((uint)i))); - fields.Add(field); - } - - return fields; - }); + return fields; + }); - _anonymousFields = new Lazy>(() => Decls.OfType().Where(decl => decl.IsAnonymousField).ToList()); - _anonymousRecords = new Lazy>(() => Decls.OfType().Where(decl => decl.IsAnonymousStructOrUnion && !decl.IsInjectedClassName).ToList()); - _indirectFields = new Lazy>(() => Decls.OfType().ToList()); - _injectedClassName = new Lazy(() => Decls.OfType().Where(decl => decl.IsInjectedClassName).SingleOrDefault()); - } + _anonymousFields = new Lazy>(() => Decls.OfType().Where(decl => decl.IsAnonymousField).ToList()); + _anonymousRecords = new Lazy>(() => Decls.OfType().Where(decl => decl.IsAnonymousStructOrUnion && !decl.IsInjectedClassName).ToList()); + _indirectFields = new Lazy>(() => Decls.OfType().ToList()); + _injectedClassName = new Lazy(() => Decls.OfType().Where(decl => decl.IsInjectedClassName).SingleOrDefault()); + } - public bool IsAnonymousStructOrUnion => Handle.IsAnonymousStructOrUnion; + public bool IsAnonymousStructOrUnion => Handle.IsAnonymousStructOrUnion; - public IReadOnlyList AnonymousFields => _anonymousFields.Value; + public IReadOnlyList AnonymousFields => _anonymousFields.Value; - public IReadOnlyList AnonymousRecords => _anonymousRecords.Value; + public IReadOnlyList AnonymousRecords => _anonymousRecords.Value; - public new RecordDecl Definition => (RecordDecl)base.Definition; + public new RecordDecl Definition => (RecordDecl)base.Definition; - public IReadOnlyList Fields => _fields.Value; + public IReadOnlyList Fields => _fields.Value; - public IReadOnlyList IndirectFields => _indirectFields.Value; + public IReadOnlyList IndirectFields => _indirectFields.Value; - public RecordDecl InjectedClassName => _injectedClassName.Value; + public RecordDecl InjectedClassName => _injectedClassName.Value; - public bool IsInjectedClassName => Handle.IsInjectedClassName; + public bool IsInjectedClassName => Handle.IsInjectedClassName; - public new RecordDecl MostRecentDecl => (RecordDecl)base.MostRecentDecl; + public new RecordDecl MostRecentDecl => (RecordDecl)base.MostRecentDecl; - public new RecordDecl PreviousDecl => (RecordDecl)base.PreviousDecl; - } + public new RecordDecl PreviousDecl => (RecordDecl)base.PreviousDecl; } diff --git a/sources/ClangSharp/Cursors/Decls/RedeclarableTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/RedeclarableTemplateDecl.cs index 2b7862bf..5783d98f 100644 --- a/sources/ClangSharp/Cursors/Decls/RedeclarableTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/RedeclarableTemplateDecl.cs @@ -3,26 +3,25 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class RedeclarableTemplateDecl : TemplateDecl, IRedeclarable { - public class RedeclarableTemplateDecl : TemplateDecl, IRedeclarable - { - private readonly Lazy _instantiatedFromMemberTemplate; + private readonly Lazy _instantiatedFromMemberTemplate; - private protected RedeclarableTemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected RedeclarableTemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastRedeclarableTemplate or < CX_DeclKind.CX_DeclKind_FirstRedeclarableTemplate) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastRedeclarableTemplate or < CX_DeclKind.CX_DeclKind_FirstRedeclarableTemplate) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _instantiatedFromMemberTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public new RedeclarableTemplateDecl CanonicalDecl => (RedeclarableTemplateDecl)base.CanonicalDecl; + _instantiatedFromMemberTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); + } - public bool IsMemberSpecialization => Handle.IsMemberSpecialization; + public new RedeclarableTemplateDecl CanonicalDecl => (RedeclarableTemplateDecl)base.CanonicalDecl; - public RedeclarableTemplateDecl InstantiatedFromMemberTemplate => _instantiatedFromMemberTemplate.Value; - } + public bool IsMemberSpecialization => Handle.IsMemberSpecialization; + + public RedeclarableTemplateDecl InstantiatedFromMemberTemplate => _instantiatedFromMemberTemplate.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/RequiresExprBodyDecl.cs b/sources/ClangSharp/Cursors/Decls/RequiresExprBodyDecl.cs index 5c2ed8ab..779b2e4e 100644 --- a/sources/ClangSharp/Cursors/Decls/RequiresExprBodyDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/RequiresExprBodyDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class RequiresExprBodyDecl : Decl, IDeclContext { - public sealed class RequiresExprBodyDecl : Decl, IDeclContext + internal RequiresExprBodyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_RequiresExprBody) { - internal RequiresExprBodyDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_RequiresExprBody) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/StaticAssertDecl.cs b/sources/ClangSharp/Cursors/Decls/StaticAssertDecl.cs index 4e46b12a..15fb424b 100644 --- a/sources/ClangSharp/Cursors/Decls/StaticAssertDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/StaticAssertDecl.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class StaticAssertDecl : Decl { - public sealed class StaticAssertDecl : Decl - { - private readonly Lazy _assertExpr; - private readonly Lazy _message; + private readonly Lazy _assertExpr; + private readonly Lazy _message; - internal StaticAssertDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StaticAssert, CX_DeclKind.CX_DeclKind_StaticAssert) - { - _assertExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); - _message = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(1))); - } + internal StaticAssertDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StaticAssert, CX_DeclKind.CX_DeclKind_StaticAssert) + { + _assertExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); + _message = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(1))); + } - public Expr AssertExpr => _assertExpr.Value; + public Expr AssertExpr => _assertExpr.Value; - public StringLiteral Message => _message.Value; - } + public StringLiteral Message => _message.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/TagDecl.cs b/sources/ClangSharp/Cursors/Decls/TagDecl.cs index 465c6487..59c6ec8e 100644 --- a/sources/ClangSharp/Cursors/Decls/TagDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TagDecl.cs @@ -4,67 +4,66 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public unsafe class TagDecl : TypeDecl, IDeclContext, IRedeclarable { - public unsafe class TagDecl : TypeDecl, IDeclContext, IRedeclarable - { - private readonly Lazy _definition; - private readonly Lazy>> _templateParameterLists; - private readonly Lazy _typedefNameForAnonDecl; + private readonly Lazy _definition; + private readonly Lazy>> _templateParameterLists; + private readonly Lazy _typedefNameForAnonDecl; - private protected TagDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected TagDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastTag or < CX_DeclKind.CX_DeclKind_FirstTag) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastTag or < CX_DeclKind.CX_DeclKind_FirstTag) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); + throw new ArgumentOutOfRangeException(nameof(handle)); + } - _templateParameterLists = new Lazy>>(() => { - var numTemplateParameterLists = Handle.NumTemplateParameterLists; - var templateParameterLists = new List>(numTemplateParameterLists); + _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); - for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++) - { - var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked((uint)listIndex)); - var templateParameterList = new List(numTemplateParameters); + _templateParameterLists = new Lazy>>(() => { + var numTemplateParameterLists = Handle.NumTemplateParameterLists; + var templateParameterLists = new List>(numTemplateParameterLists); - for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++) - { - var templateParameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(unchecked((uint)listIndex), unchecked((uint)parameterIndex))); - templateParameterList.Add(templateParameter); - } + for (var listIndex = 0; listIndex < numTemplateParameterLists; listIndex++) + { + var numTemplateParameters = Handle.GetNumTemplateParameters(unchecked((uint)listIndex)); + var templateParameterList = new List(numTemplateParameters); - templateParameterLists.Add(templateParameterList); + for (var parameterIndex = 0; parameterIndex < numTemplateParameters; parameterIndex++) + { + var templateParameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(unchecked((uint)listIndex), unchecked((uint)parameterIndex))); + templateParameterList.Add(templateParameter); } - return templateParameterLists; - }); + templateParameterLists.Add(templateParameterList); + } - _typedefNameForAnonDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypedefNameForAnonDecl)); - } + return templateParameterLists; + }); - public new TagDecl CanonicalDecl => (TagDecl)base.CanonicalDecl; + _typedefNameForAnonDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypedefNameForAnonDecl)); + } - public TagDecl Definition => _definition.Value; + public new TagDecl CanonicalDecl => (TagDecl)base.CanonicalDecl; - public bool IsClass => CursorKind == CXCursorKind.CXCursor_ClassDecl; + public TagDecl Definition => _definition.Value; - public bool IsCompleteDefinition => Handle.IsCompleteDefinition; + public bool IsClass => CursorKind == CXCursorKind.CXCursor_ClassDecl; - public bool IsEnum => CursorKind == CXCursorKind.CXCursor_EnumDecl; + public bool IsCompleteDefinition => Handle.IsCompleteDefinition; - public bool IsStruct => CursorKind == CXCursorKind.CXCursor_StructDecl; + public bool IsEnum => CursorKind == CXCursorKind.CXCursor_EnumDecl; - public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; + public bool IsStruct => CursorKind == CXCursorKind.CXCursor_StructDecl; - public bool IsUnion => CursorKind == CXCursorKind.CXCursor_UnionDecl; + public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; - public uint NumTemplateParameterLists => unchecked((uint)Handle.NumTemplateParameterLists); + public bool IsUnion => CursorKind == CXCursorKind.CXCursor_UnionDecl; - public IReadOnlyList> TemplateParameterLists => _templateParameterLists.Value; + public uint NumTemplateParameterLists => unchecked((uint)Handle.NumTemplateParameterLists); - public TypedefNameDecl TypedefNameForAnonDecl => _typedefNameForAnonDecl.Value; - } + public IReadOnlyList> TemplateParameterLists => _templateParameterLists.Value; + + public TypedefNameDecl TypedefNameForAnonDecl => _typedefNameForAnonDecl.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/TemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/TemplateDecl.cs index 7d82fdbe..cd8e06db 100644 --- a/sources/ClangSharp/Cursors/Decls/TemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TemplateDecl.cs @@ -4,54 +4,53 @@ using System; using System.Collections.Generic; -namespace ClangSharp +namespace ClangSharp; + +public class TemplateDecl : NamedDecl { - public class TemplateDecl : NamedDecl - { - private readonly Lazy> _associatedConstraints; - private readonly Lazy _templatedDecl; - private readonly Lazy> _templateParameters; + private readonly Lazy> _associatedConstraints; + private readonly Lazy _templatedDecl; + private readonly Lazy> _templateParameters; - private protected TemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected TemplateDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastTemplate or < CX_DeclKind.CX_DeclKind_FirstTemplate) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastTemplate or < CX_DeclKind.CX_DeclKind_FirstTemplate) + throw new ArgumentOutOfRangeException(nameof(handle)); + } + + _associatedConstraints = new Lazy>(() => { + var associatedConstraintCount = Handle.NumAssociatedConstraints; + var associatedConstraints = new List(associatedConstraintCount); + + for (var i = 0; i < associatedConstraintCount; i++) { - throw new ArgumentOutOfRangeException(nameof(handle)); + var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); + associatedConstraints.Add(parameter); } - _associatedConstraints = new Lazy>(() => { - var associatedConstraintCount = Handle.NumAssociatedConstraints; - var associatedConstraints = new List(associatedConstraintCount); - - for (var i = 0; i < associatedConstraintCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); - associatedConstraints.Add(parameter); - } - - return associatedConstraints; - }); - _templatedDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplatedDecl)); - _templateParameters = new Lazy>(() => { - var parameterCount = Handle.GetNumTemplateParameters(0); - var parameters = new List(parameterCount); - - for (var i = 0; i < parameterCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(0, unchecked((uint)i))); - parameters.Add(parameter); - } - - return parameters; - }); - } + return associatedConstraints; + }); + _templatedDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplatedDecl)); + _templateParameters = new Lazy>(() => { + var parameterCount = Handle.GetNumTemplateParameters(0); + var parameters = new List(parameterCount); - public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; + for (var i = 0; i < parameterCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(0, unchecked((uint)i))); + parameters.Add(parameter); + } + + return parameters; + }); + } - public bool HasAssociatedConstraints => AssociatedConstraints.Count != 0; + public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; - public NamedDecl TemplatedDecl => _templatedDecl.Value; + public bool HasAssociatedConstraints => AssociatedConstraints.Count != 0; - public IReadOnlyList TemplateParameters => _templateParameters.Value; - } + public NamedDecl TemplatedDecl => _templatedDecl.Value; + + public IReadOnlyList TemplateParameters => _templateParameters.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/TemplateParamObjectDecl.cs b/sources/ClangSharp/Cursors/Decls/TemplateParamObjectDecl.cs index cb608b84..62ae486f 100644 --- a/sources/ClangSharp/Cursors/Decls/TemplateParamObjectDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TemplateParamObjectDecl.cs @@ -2,14 +2,13 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TemplateParamObjectDecl : ValueDecl, IMergeable { - public sealed class TemplateParamObjectDecl : ValueDecl, IMergeable + internal TemplateParamObjectDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_TemplateParamObject) { - internal TemplateParamObjectDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_TemplateParamObject) - { - } - - public new TemplateParamObjectDecl CanonicalDecl => (TemplateParamObjectDecl)base.CanonicalDecl; } + + public new TemplateParamObjectDecl CanonicalDecl => (TemplateParamObjectDecl)base.CanonicalDecl; } diff --git a/sources/ClangSharp/Cursors/Decls/TemplateTemplateParmDecl.cs b/sources/ClangSharp/Cursors/Decls/TemplateTemplateParmDecl.cs index a062d991..7661a2bb 100644 --- a/sources/ClangSharp/Cursors/Decls/TemplateTemplateParmDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TemplateTemplateParmDecl.cs @@ -3,31 +3,30 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TemplateTemplateParmDecl : TemplateDecl, ITemplateParmPosition { - public sealed class TemplateTemplateParmDecl : TemplateDecl, ITemplateParmPosition - { - private readonly Lazy _defaultArgument; + private readonly Lazy _defaultArgument; - internal TemplateTemplateParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TemplateTemplateParameter, CX_DeclKind.CX_DeclKind_TemplateTemplateParm) - { - _defaultArgument = new Lazy(() => TranslationUnit.GetOrCreate(handle.GetTemplateArgumentLoc(0))); - } + internal TemplateTemplateParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TemplateTemplateParameter, CX_DeclKind.CX_DeclKind_TemplateTemplateParm) + { + _defaultArgument = new Lazy(() => TranslationUnit.GetOrCreate(handle.GetTemplateArgumentLoc(0))); + } - public TemplateArgumentLoc DefaultArgument => _defaultArgument.Value; + public TemplateArgumentLoc DefaultArgument => _defaultArgument.Value; - public bool DefaultArgumentWasInherited => Handle.HasInheritedDefaultArg; + public bool DefaultArgumentWasInherited => Handle.HasInheritedDefaultArg; - public uint Depth => unchecked((uint)Handle.TemplateTypeParmDepth); + public uint Depth => unchecked((uint)Handle.TemplateTypeParmDepth); - public uint Index => unchecked((uint)Handle.TemplateTypeParmIndex); + public uint Index => unchecked((uint)Handle.TemplateTypeParmIndex); - public bool IsExpandedParameterPack => Handle.IsExpandedParameterPack; + public bool IsExpandedParameterPack => Handle.IsExpandedParameterPack; - public bool IsPackExpansion => Handle.IsPackExpansion; + public bool IsPackExpansion => Handle.IsPackExpansion; - public bool IsParameterPack => Handle.IsParameterPack; + public bool IsParameterPack => Handle.IsParameterPack; - public uint Position => unchecked((uint)Handle.TemplateTypeParmPosition); - } + public uint Position => unchecked((uint)Handle.TemplateTypeParmPosition); } diff --git a/sources/ClangSharp/Cursors/Decls/TemplateTypeParmDecl.cs b/sources/ClangSharp/Cursors/Decls/TemplateTypeParmDecl.cs index 499a5a22..56b40e06 100644 --- a/sources/ClangSharp/Cursors/Decls/TemplateTypeParmDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TemplateTypeParmDecl.cs @@ -4,46 +4,45 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class TemplateTypeParmDecl : TypeDecl - { - private readonly Lazy> _associatedConstraints; - private readonly Lazy _defaultArgument; +namespace ClangSharp; - internal TemplateTypeParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TemplateTypeParameter, CX_DeclKind.CX_DeclKind_TemplateTypeParm) - { - _associatedConstraints = new Lazy>(() => { - var associatedConstraintCount = Handle.NumAssociatedConstraints; - var associatedConstraints = new List(associatedConstraintCount); - - for (var i = 0; i < associatedConstraintCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); - associatedConstraints.Add(parameter); - } +public sealed class TemplateTypeParmDecl : TypeDecl +{ + private readonly Lazy> _associatedConstraints; + private readonly Lazy _defaultArgument; - return associatedConstraints; - }); - _defaultArgument = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DefaultArgType)); - } + internal TemplateTypeParmDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TemplateTypeParameter, CX_DeclKind.CX_DeclKind_TemplateTypeParm) + { + _associatedConstraints = new Lazy>(() => { + var associatedConstraintCount = Handle.NumAssociatedConstraints; + var associatedConstraints = new List(associatedConstraintCount); + + for (var i = 0; i < associatedConstraintCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); + associatedConstraints.Add(parameter); + } + + return associatedConstraints; + }); + _defaultArgument = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DefaultArgType)); + } - public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; + public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; - public Type DefaultArgument => _defaultArgument.Value; + public Type DefaultArgument => _defaultArgument.Value; - public bool DefaultArgumentWasInherited => Handle.HasInheritedDefaultArg; + public bool DefaultArgumentWasInherited => Handle.HasInheritedDefaultArg; - public int Depth => Handle.TemplateTypeParmDepth; + public int Depth => Handle.TemplateTypeParmDepth; - public int Index => Handle.TemplateTypeParmIndex; + public int Index => Handle.TemplateTypeParmIndex; - public bool HasDefaultArgument => Handle.HasDefaultArg; + public bool HasDefaultArgument => Handle.HasDefaultArg; - public bool IsExpandedParameterPack => Handle.IsExpandedParameterPack; + public bool IsExpandedParameterPack => Handle.IsExpandedParameterPack; - public bool IsPackExpansion => Handle.IsPackExpansion; + public bool IsPackExpansion => Handle.IsPackExpansion; - public bool IsParameterPack => Handle.IsParameterPack; - } + public bool IsParameterPack => Handle.IsParameterPack; } diff --git a/sources/ClangSharp/Cursors/Decls/TranslationUnitDecl.cs b/sources/ClangSharp/Cursors/Decls/TranslationUnitDecl.cs index 133f70ee..abdd9065 100644 --- a/sources/ClangSharp/Cursors/Decls/TranslationUnitDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TranslationUnitDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed unsafe class TranslationUnitDecl : Decl, IDeclContext { - public sealed unsafe class TranslationUnitDecl : Decl, IDeclContext + internal TranslationUnitDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TranslationUnit, CX_DeclKind.CX_DeclKind_TranslationUnit) { - internal TranslationUnitDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TranslationUnit, CX_DeclKind.CX_DeclKind_TranslationUnit) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/TypeAliasDecl.cs b/sources/ClangSharp/Cursors/Decls/TypeAliasDecl.cs index ba36d9d2..8597fb5a 100644 --- a/sources/ClangSharp/Cursors/Decls/TypeAliasDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypeAliasDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TypeAliasDecl : TypedefNameDecl { - public sealed class TypeAliasDecl : TypedefNameDecl + internal TypeAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypeAliasDecl, CX_DeclKind.CX_DeclKind_TypeAlias) { - internal TypeAliasDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypeAliasDecl, CX_DeclKind.CX_DeclKind_TypeAlias) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/TypeAliasTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/TypeAliasTemplateDecl.cs index cce28bde..cd1c1349 100644 --- a/sources/ClangSharp/Cursors/Decls/TypeAliasTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypeAliasTemplateDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TypeAliasTemplateDecl : RedeclarableTemplateDecl { - public sealed class TypeAliasTemplateDecl : RedeclarableTemplateDecl + internal TypeAliasTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypeAliasTemplateDecl, CX_DeclKind.CX_DeclKind_TypeAliasTemplate) { - internal TypeAliasTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypeAliasTemplateDecl, CX_DeclKind.CX_DeclKind_TypeAliasTemplate) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/TypeDecl.cs b/sources/ClangSharp/Cursors/Decls/TypeDecl.cs index d5de3d3a..6bc05525 100644 --- a/sources/ClangSharp/Cursors/Decls/TypeDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypeDecl.cs @@ -3,22 +3,21 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class TypeDecl : NamedDecl { - public class TypeDecl : NamedDecl - { - private readonly Lazy _typeForDecl; + private readonly Lazy _typeForDecl; - private protected TypeDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected TypeDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastType or < CX_DeclKind.CX_DeclKind_FirstType) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastType or < CX_DeclKind.CX_DeclKind_FirstType) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _typeForDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public Type TypeForDecl => _typeForDecl.Value; + _typeForDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); } + + public Type TypeForDecl => _typeForDecl.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/TypedefDecl.cs b/sources/ClangSharp/Cursors/Decls/TypedefDecl.cs index 04a21f2e..311cb42f 100644 --- a/sources/ClangSharp/Cursors/Decls/TypedefDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypedefDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TypedefDecl : TypedefNameDecl { - public sealed class TypedefDecl : TypedefNameDecl + internal TypedefDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypedefDecl, CX_DeclKind.CX_DeclKind_Typedef) { - internal TypedefDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_TypedefDecl, CX_DeclKind.CX_DeclKind_Typedef) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/TypedefNameDecl.cs b/sources/ClangSharp/Cursors/Decls/TypedefNameDecl.cs index b13a5dfe..ebcbec96 100644 --- a/sources/ClangSharp/Cursors/Decls/TypedefNameDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/TypedefNameDecl.cs @@ -3,26 +3,25 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class TypedefNameDecl : TypeDecl, IRedeclarable { - public class TypedefNameDecl : TypeDecl, IRedeclarable - { - private readonly Lazy _underlyingType; + private readonly Lazy _underlyingType; - private protected TypedefNameDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected TypedefNameDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastTypedefName or < CX_DeclKind.CX_DeclKind_FirstTypedefName) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastTypedefName or < CX_DeclKind.CX_DeclKind_FirstTypedefName) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypedefDeclUnderlyingType)); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public new TypedefNameDecl CanonicalDecl => (TypedefNameDecl)base.CanonicalDecl; + _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypedefDeclUnderlyingType)); + } - public bool IsTransparentTag => Handle.IsTransparent; + public new TypedefNameDecl CanonicalDecl => (TypedefNameDecl)base.CanonicalDecl; - public Type UnderlyingType => _underlyingType.Value; - } + public bool IsTransparentTag => Handle.IsTransparent; + + public Type UnderlyingType => _underlyingType.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/UnresolvedUsingIfExistsDecl.cs b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingIfExistsDecl.cs index 245d5189..af0e2513 100644 --- a/sources/ClangSharp/Cursors/Decls/UnresolvedUsingIfExistsDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingIfExistsDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UnresolvedUsingIfExistsDecl : NamedDecl { - public sealed class UnresolvedUsingIfExistsDecl : NamedDecl + internal UnresolvedUsingIfExistsDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_UnresolvedUsingIfExists) { - internal UnresolvedUsingIfExistsDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_UnresolvedUsingIfExists) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/UnresolvedUsingTypenameDecl.cs b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingTypenameDecl.cs index dba5b5c9..0e2f11a4 100644 --- a/sources/ClangSharp/Cursors/Decls/UnresolvedUsingTypenameDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingTypenameDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UnresolvedUsingTypenameDecl : TypeDecl, IMergeable { - public sealed class UnresolvedUsingTypenameDecl : TypeDecl, IMergeable + internal UnresolvedUsingTypenameDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename) { - internal UnresolvedUsingTypenameDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_UnresolvedUsingTypename) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/UnresolvedUsingValueDecl.cs b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingValueDecl.cs index 0829cbbd..84d7af59 100644 --- a/sources/ClangSharp/Cursors/Decls/UnresolvedUsingValueDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UnresolvedUsingValueDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UnresolvedUsingValueDecl : ValueDecl, IMergeable { - public sealed class UnresolvedUsingValueDecl : ValueDecl, IMergeable + internal UnresolvedUsingValueDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_UnresolvedUsingValue) { - internal UnresolvedUsingValueDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_UnresolvedUsingValue) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/UsingDecl.cs b/sources/ClangSharp/Cursors/Decls/UsingDecl.cs index 3758bf12..4ac9fa45 100644 --- a/sources/ClangSharp/Cursors/Decls/UsingDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UsingDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UsingDecl : BaseUsingDecl, IMergeable { - public sealed class UsingDecl : BaseUsingDecl, IMergeable + internal UsingDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_Using) { - internal UsingDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDeclaration, CX_DeclKind.CX_DeclKind_Using) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/UsingDirectiveDecl.cs b/sources/ClangSharp/Cursors/Decls/UsingDirectiveDecl.cs index c4c84bfe..08b91f2f 100644 --- a/sources/ClangSharp/Cursors/Decls/UsingDirectiveDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UsingDirectiveDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UsingDirectiveDecl : NamedDecl { - public sealed class UsingDirectiveDecl : NamedDecl + internal UsingDirectiveDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDirective, CX_DeclKind.CX_DeclKind_UsingDirective) { - internal UsingDirectiveDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UsingDirective, CX_DeclKind.CX_DeclKind_UsingDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/UsingEnumDecl.cs b/sources/ClangSharp/Cursors/Decls/UsingEnumDecl.cs index 97344d1f..24de6753 100644 --- a/sources/ClangSharp/Cursors/Decls/UsingEnumDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UsingEnumDecl.cs @@ -3,19 +3,18 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UsingEnumDecl : BaseUsingDecl, IMergeable { - public sealed class UsingEnumDecl : BaseUsingDecl, IMergeable - { - private readonly Lazy _enumDecl; + private readonly Lazy _enumDecl; - internal UsingEnumDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_UsingEnum) - { - _enumDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); - } + internal UsingEnumDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_UsingEnum) + { + _enumDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); + } - public new UsingEnumDecl CanonicalDecl => (UsingEnumDecl)base.CanonicalDecl; + public new UsingEnumDecl CanonicalDecl => (UsingEnumDecl)base.CanonicalDecl; - public EnumDecl EnumDecl => _enumDecl.Value; - } + public EnumDecl EnumDecl => _enumDecl.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/UsingPackDecl.cs b/sources/ClangSharp/Cursors/Decls/UsingPackDecl.cs index e314a17b..50a501d8 100644 --- a/sources/ClangSharp/Cursors/Decls/UsingPackDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UsingPackDecl.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UsingPackDecl : NamedDecl, IMergeable { - public sealed class UsingPackDecl : NamedDecl, IMergeable + internal UsingPackDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_UsingPack) { - internal UsingPackDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_UsingPack) - { - } } } diff --git a/sources/ClangSharp/Cursors/Decls/UsingShadowDecl.cs b/sources/ClangSharp/Cursors/Decls/UsingShadowDecl.cs index 69649adb..142156d5 100644 --- a/sources/ClangSharp/Cursors/Decls/UsingShadowDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/UsingShadowDecl.cs @@ -3,20 +3,19 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class UsingShadowDecl : NamedDecl, IRedeclarable { - public class UsingShadowDecl : NamedDecl, IRedeclarable + internal UsingShadowDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_UsingShadow) { - internal UsingShadowDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_UsingShadow) - { - } + } - private protected UsingShadowDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected UsingShadowDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastUsingShadow or < CX_DeclKind.CX_DeclKind_FirstUsingShadow) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastUsingShadow or < CX_DeclKind.CX_DeclKind_FirstUsingShadow) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Decls/ValueDecl.cs b/sources/ClangSharp/Cursors/Decls/ValueDecl.cs index f7ab4c0e..4efda5f0 100644 --- a/sources/ClangSharp/Cursors/Decls/ValueDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/ValueDecl.cs @@ -3,22 +3,21 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class ValueDecl : NamedDecl { - public class ValueDecl : NamedDecl - { - private readonly Lazy _type; + private readonly Lazy _type; - private protected ValueDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + private protected ValueDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastValue or < CX_DeclKind.CX_DeclKind_FirstValue) { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastValue or < CX_DeclKind.CX_DeclKind_FirstValue) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public Type Type => _type.Value; + _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); } + + public Type Type => _type.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/VarDecl.cs b/sources/ClangSharp/Cursors/Decls/VarDecl.cs index d5613439..16ce516e 100644 --- a/sources/ClangSharp/Cursors/Decls/VarDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/VarDecl.cs @@ -3,56 +3,55 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class VarDecl : DeclaratorDecl, IRedeclarable { - public class VarDecl : DeclaratorDecl, IRedeclarable + private readonly Lazy _definition; + private readonly Lazy _init; + private readonly Lazy _instantiatedFromStaticDataMember; + + internal VarDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_VarDecl, CX_DeclKind.CX_DeclKind_Var) { - private readonly Lazy _definition; - private readonly Lazy _init; - private readonly Lazy _instantiatedFromStaticDataMember; + } - internal VarDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_VarDecl, CX_DeclKind.CX_DeclKind_Var) + private protected VarDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastVar or < CX_DeclKind.CX_DeclKind_FirstVar) { + throw new ArgumentOutOfRangeException(nameof(handle)); } - private protected VarDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) - { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastVar or < CX_DeclKind.CX_DeclKind_FirstVar) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); - _init = new Lazy(() => TranslationUnit.GetOrCreate(handle.InitExpr)); - _instantiatedFromStaticDataMember = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); - } + _definition = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Definition)); + _init = new Lazy(() => TranslationUnit.GetOrCreate(handle.InitExpr)); + _instantiatedFromStaticDataMember = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); + } - public new VarDecl CanonicalDecl => (VarDecl)base.CanonicalDecl; + public new VarDecl CanonicalDecl => (VarDecl)base.CanonicalDecl; - public VarDecl Definition => _definition.Value; + public VarDecl Definition => _definition.Value; - public bool HasExternalStorage => Handle.HasVarDeclExternalStorage; + public bool HasExternalStorage => Handle.HasVarDeclExternalStorage; - public bool HasGlobalStorage => Handle.HasVarDeclGlobalStorage; + public bool HasGlobalStorage => Handle.HasVarDeclGlobalStorage; - public bool HasInit => Handle.HasInit; + public bool HasInit => Handle.HasInit; - public bool HasLocalStorage => Handle.HasLocalStorage; + public bool HasLocalStorage => Handle.HasLocalStorage; - public Expr Init => _init.Value; + public Expr Init => _init.Value; - public VarDecl InstantiatedFromStaticDataMember => _instantiatedFromStaticDataMember.Value; + public VarDecl InstantiatedFromStaticDataMember => _instantiatedFromStaticDataMember.Value; - public bool IsExternC => Handle.IsExternC; + public bool IsExternC => Handle.IsExternC; - public bool IsLocalVarDecl => Handle.IsLocalVarDecl; + public bool IsLocalVarDecl => Handle.IsLocalVarDecl; - public bool IsLocalVarDeclOrParm => Handle.IsLocalVarDeclOrParm; + public bool IsLocalVarDeclOrParm => Handle.IsLocalVarDeclOrParm; - public bool IsStaticDataMember => Handle.IsStaticDataMember; + public bool IsStaticDataMember => Handle.IsStaticDataMember; - public CX_StorageClass StorageClass => Handle.StorageClass; + public CX_StorageClass StorageClass => Handle.StorageClass; - public CXTLSKind TlsKind => Handle.TlsKind; - } + public CXTLSKind TlsKind => Handle.TlsKind; } diff --git a/sources/ClangSharp/Cursors/Decls/VarTemplateDecl.cs b/sources/ClangSharp/Cursors/Decls/VarTemplateDecl.cs index 63644ea5..be5e3b33 100644 --- a/sources/ClangSharp/Cursors/Decls/VarTemplateDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/VarTemplateDecl.cs @@ -2,24 +2,23 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class VarTemplateDecl : RedeclarableTemplateDecl { - public sealed class VarTemplateDecl : RedeclarableTemplateDecl + internal VarTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_VarTemplate) { - internal VarTemplateDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_VarTemplate) - { - } + } - public new VarTemplateDecl CanonicalDecl => (VarTemplateDecl)base.CanonicalDecl; + public new VarTemplateDecl CanonicalDecl => (VarTemplateDecl)base.CanonicalDecl; - public new VarTemplateDecl InstantiatedFromMemberTemplate => (VarTemplateDecl)base.InstantiatedFromMemberTemplate; + public new VarTemplateDecl InstantiatedFromMemberTemplate => (VarTemplateDecl)base.InstantiatedFromMemberTemplate; - public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; + public bool IsThisDeclarationADefinition => Handle.IsThisDeclarationADefinition; - public new VarTemplateDecl MostRecentDecl => (VarTemplateDecl)base.MostRecentDecl; + public new VarTemplateDecl MostRecentDecl => (VarTemplateDecl)base.MostRecentDecl; - public new VarTemplateDecl PreviousDecl => (VarTemplateDecl)base.PreviousDecl; + public new VarTemplateDecl PreviousDecl => (VarTemplateDecl)base.PreviousDecl; - public new CXXRecordDecl TemplatedDecl => (CXXRecordDecl)base.TemplatedDecl; - } + public new CXXRecordDecl TemplatedDecl => (CXXRecordDecl)base.TemplatedDecl; } diff --git a/sources/ClangSharp/Cursors/Decls/VarTemplatePartialSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/VarTemplatePartialSpecializationDecl.cs index 36960e81..7224f909 100644 --- a/sources/ClangSharp/Cursors/Decls/VarTemplatePartialSpecializationDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/VarTemplatePartialSpecializationDecl.cs @@ -4,49 +4,48 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class VarTemplatePartialSpecializationDecl : VarDecl { - public class VarTemplatePartialSpecializationDecl : VarDecl + private readonly Lazy> _associatedConstraints; + private readonly Lazy _instantiatedFromMember; + private readonly Lazy> _templateParameters; + + internal VarTemplatePartialSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization) { - private readonly Lazy> _associatedConstraints; - private readonly Lazy _instantiatedFromMember; - private readonly Lazy> _templateParameters; - - internal VarTemplatePartialSpecializationDecl(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_VarTemplatePartialSpecialization) - { - _associatedConstraints = new Lazy>(() => { - var associatedConstraintCount = Handle.NumAssociatedConstraints; - var associatedConstraints = new List(associatedConstraintCount); - - for (var i = 0; i < associatedConstraintCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); - associatedConstraints.Add(parameter); - } - - return associatedConstraints; - }); - _instantiatedFromMember = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); - _templateParameters = new Lazy>(() => { - var parameterCount = Handle.GetNumTemplateParameters(0); - var parameters = new List(parameterCount); - - for (var i = 0; i < parameterCount; i++) - { - var parameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(0, unchecked((uint)i))); - parameters.Add(parameter); - } - - return parameters; - }); - } - - public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; - - public VarTemplatePartialSpecializationDecl InstantiatedFromMember => _instantiatedFromMember.Value; - - public new VarTemplatePartialSpecializationDecl MostRecentDecl => (VarTemplatePartialSpecializationDecl)base.MostRecentDecl; - - public IReadOnlyList TemplateParameters => _templateParameters.Value; + _associatedConstraints = new Lazy>(() => { + var associatedConstraintCount = Handle.NumAssociatedConstraints; + var associatedConstraints = new List(associatedConstraintCount); + + for (var i = 0; i < associatedConstraintCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetAssociatedConstraint(unchecked((uint)i))); + associatedConstraints.Add(parameter); + } + + return associatedConstraints; + }); + _instantiatedFromMember = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InstantiatedFromMember)); + _templateParameters = new Lazy>(() => { + var parameterCount = Handle.GetNumTemplateParameters(0); + var parameters = new List(parameterCount); + + for (var i = 0; i < parameterCount; i++) + { + var parameter = TranslationUnit.GetOrCreate(Handle.GetTemplateParameter(0, unchecked((uint)i))); + parameters.Add(parameter); + } + + return parameters; + }); } + + public IReadOnlyList AssociatedConstraints => _associatedConstraints.Value; + + public VarTemplatePartialSpecializationDecl InstantiatedFromMember => _instantiatedFromMember.Value; + + public new VarTemplatePartialSpecializationDecl MostRecentDecl => (VarTemplatePartialSpecializationDecl)base.MostRecentDecl; + + public IReadOnlyList TemplateParameters => _templateParameters.Value; } diff --git a/sources/ClangSharp/Cursors/Decls/VarTemplateSpecializationDecl.cs b/sources/ClangSharp/Cursors/Decls/VarTemplateSpecializationDecl.cs index 8e167f01..c40f220a 100644 --- a/sources/ClangSharp/Cursors/Decls/VarTemplateSpecializationDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/VarTemplateSpecializationDecl.cs @@ -4,43 +4,42 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class VarTemplateSpecializationDecl : VarDecl { - public class VarTemplateSpecializationDecl : VarDecl + private readonly Lazy _specializedTemplate; + private readonly Lazy> _templateArgs; + + internal VarTemplateSpecializationDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_VarTemplateSpecialization) { - private readonly Lazy _specializedTemplate; - private readonly Lazy> _templateArgs; + } - internal VarTemplateSpecializationDecl(CXCursor handle) : this(handle, CXCursorKind.CXCursor_UnexposedDecl, CX_DeclKind.CX_DeclKind_VarTemplateSpecialization) + private protected VarTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) + { + if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastVarTemplateSpecialization or < CX_DeclKind.CX_DeclKind_FirstVarTemplateSpecialization) { + throw new ArgumentOutOfRangeException(nameof(handle)); } - private protected VarTemplateSpecializationDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX_DeclKind expectedDeclKind) : base(handle, expectedCursorKind, expectedDeclKind) - { - if (handle.DeclKind is > CX_DeclKind.CX_DeclKind_LastVarTemplateSpecialization or < CX_DeclKind.CX_DeclKind_FirstVarTemplateSpecialization) + _specializedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); + + for (var i = 0; i < templateArgCount; i++) { - throw new ArgumentOutOfRangeException(nameof(handle)); + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); + templateArgs.Add(templateArg); } - _specializedTemplate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SpecializedCursorTemplate)); - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); - - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); - templateArgs.Add(templateArg); - } - - return templateArgs; - }); - } + return templateArgs; + }); + } - public new VarTemplateSpecializationDecl MostRecentDecl => (VarTemplateSpecializationDecl)base.MostRecentDecl; + public new VarTemplateSpecializationDecl MostRecentDecl => (VarTemplateSpecializationDecl)base.MostRecentDecl; - public VarTemplateDecl SpecializedTemplate => _specializedTemplate.Value; + public VarTemplateDecl SpecializedTemplate => _specializedTemplate.Value; - public IReadOnlyList TemplateArgs => _templateArgs.Value; - } + public IReadOnlyList TemplateArgs => _templateArgs.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/AbstractConditionalOperator.cs b/sources/ClangSharp/Cursors/Exprs/AbstractConditionalOperator.cs index 3487b29b..31f7f2d7 100644 --- a/sources/ClangSharp/Cursors/Exprs/AbstractConditionalOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/AbstractConditionalOperator.cs @@ -3,22 +3,21 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class AbstractConditionalOperator : Expr { - public class AbstractConditionalOperator : Expr + private protected AbstractConditionalOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected AbstractConditionalOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastAbstractConditionalOperator or < CX_StmtClass.CX_StmtClass_FirstAbstractConditionalOperator) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastAbstractConditionalOperator or < CX_StmtClass.CX_StmtClass_FirstAbstractConditionalOperator) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } + } - public Expr Cond => this is ConditionalOperator co ? co.Cond : ((BinaryConditionalOperator)this).Cond; + public Expr Cond => this is ConditionalOperator co ? co.Cond : ((BinaryConditionalOperator)this).Cond; - public Expr FalseExpr => this is ConditionalOperator co ? co.FalseExpr : ((BinaryConditionalOperator)this).FalseExpr; + public Expr FalseExpr => this is ConditionalOperator co ? co.FalseExpr : ((BinaryConditionalOperator)this).FalseExpr; - public Expr TrueExpr => this is ConditionalOperator co ? co.TrueExpr : ((BinaryConditionalOperator)this).TrueExpr; - } + public Expr TrueExpr => this is ConditionalOperator co ? co.TrueExpr : ((BinaryConditionalOperator)this).TrueExpr; } diff --git a/sources/ClangSharp/Cursors/Exprs/AddrLabelExpr.cs b/sources/ClangSharp/Cursors/Exprs/AddrLabelExpr.cs index 826a1f00..fc33bb55 100644 --- a/sources/ClangSharp/Cursors/Exprs/AddrLabelExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/AddrLabelExpr.cs @@ -4,18 +4,17 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class AddrLabelExpr : Expr - { - private readonly Lazy _label; +namespace ClangSharp; - internal AddrLabelExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_AddrLabelExpr, CX_StmtClass.CX_StmtClass_AddrLabelExpr) - { - Debug.Assert(NumChildren is 0); - _label = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } +public sealed class AddrLabelExpr : Expr +{ + private readonly Lazy _label; - public LabelDecl Label => _label.Value; + internal AddrLabelExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_AddrLabelExpr, CX_StmtClass.CX_StmtClass_AddrLabelExpr) + { + Debug.Assert(NumChildren is 0); + _label = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); } + + public LabelDecl Label => _label.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/ArrayInitIndexExpr.cs b/sources/ClangSharp/Cursors/Exprs/ArrayInitIndexExpr.cs index 733833e7..7e51f46f 100644 --- a/sources/ClangSharp/Cursors/Exprs/ArrayInitIndexExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ArrayInitIndexExpr.cs @@ -3,13 +3,12 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ArrayInitIndexExpr : Expr { - public sealed class ArrayInitIndexExpr : Expr + internal ArrayInitIndexExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr) { - internal ArrayInitIndexExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr) - { - Debug.Assert(NumChildren is 0); - } + Debug.Assert(NumChildren is 0); } } diff --git a/sources/ClangSharp/Cursors/Exprs/ArrayInitLoopExpr.cs b/sources/ClangSharp/Cursors/Exprs/ArrayInitLoopExpr.cs index 575f9318..1e0845d5 100644 --- a/sources/ClangSharp/Cursors/Exprs/ArrayInitLoopExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ArrayInitLoopExpr.cs @@ -3,19 +3,18 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ArrayInitLoopExpr : Expr { - public sealed class ArrayInitLoopExpr : Expr + internal ArrayInitLoopExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr) { - internal ArrayInitLoopExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr) - { - Debug.Assert(NumChildren is 2); - } + Debug.Assert(NumChildren is 2); + } - public long ArraySize => Handle.ArraySize; + public long ArraySize => Handle.ArraySize; - public OpaqueValueExpr CommonExpr => (OpaqueValueExpr)Children[0]; + public OpaqueValueExpr CommonExpr => (OpaqueValueExpr)Children[0]; - public Expr SubExpr => (Expr)Children[1]; - } + public Expr SubExpr => (Expr)Children[1]; } diff --git a/sources/ClangSharp/Cursors/Exprs/ArraySubscriptExpr.cs b/sources/ClangSharp/Cursors/Exprs/ArraySubscriptExpr.cs index ad8b328b..b385195d 100644 --- a/sources/ClangSharp/Cursors/Exprs/ArraySubscriptExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ArraySubscriptExpr.cs @@ -3,23 +3,22 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ArraySubscriptExpr : Expr { - public sealed class ArraySubscriptExpr : Expr + internal ArraySubscriptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ArraySubscriptExpr, CX_StmtClass.CX_StmtClass_ArraySubscriptExpr) { - internal ArraySubscriptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ArraySubscriptExpr, CX_StmtClass.CX_StmtClass_ArraySubscriptExpr) - { - Debug.Assert(NumChildren is 2); - } + Debug.Assert(NumChildren is 2); + } - public Expr Base => LHSIsBase ? LHS : RHS; + public Expr Base => LHSIsBase ? LHS : RHS; - public Expr Idx => LHSIsBase ? RHS : LHS; + public Expr Idx => LHSIsBase ? RHS : LHS; - public Expr LHS => (Expr)Children[0]; + public Expr LHS => (Expr)Children[0]; - public Expr RHS => (Expr)Children[1]; + public Expr RHS => (Expr)Children[1]; - private bool LHSIsBase => RHS.Type.IsIntegerType; - } + private bool LHSIsBase => RHS.Type.IsIntegerType; } diff --git a/sources/ClangSharp/Cursors/Exprs/ArrayTypeTraitExpr.cs b/sources/ClangSharp/Cursors/Exprs/ArrayTypeTraitExpr.cs index e4e61ed0..35e437c5 100644 --- a/sources/ClangSharp/Cursors/Exprs/ArrayTypeTraitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ArrayTypeTraitExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ArrayTypeTraitExpr : Expr { - public sealed class ArrayTypeTraitExpr : Expr + internal ArrayTypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr) { - internal ArrayTypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/AsTypeExpr.cs b/sources/ClangSharp/Cursors/Exprs/AsTypeExpr.cs index f49ae430..04bbc6ac 100644 --- a/sources/ClangSharp/Cursors/Exprs/AsTypeExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/AsTypeExpr.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class AsTypeExpr : Expr { - public sealed class AsTypeExpr : Expr + internal AsTypeExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_AsTypeExpr) { - internal AsTypeExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_AsTypeExpr) - { - Debug.Assert(NumChildren is 1); - } - - public Expr SrcExpr => (Expr)Children[0]; + Debug.Assert(NumChildren is 1); } + + public Expr SrcExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/AtomicExpr.cs b/sources/ClangSharp/Cursors/Exprs/AtomicExpr.cs index acff8db3..3b646332 100644 --- a/sources/ClangSharp/Cursors/Exprs/AtomicExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/AtomicExpr.cs @@ -5,47 +5,46 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class AtomicExpr : Expr { - public sealed class AtomicExpr : Expr - { - private readonly Lazy> _subExprs; - private readonly Lazy _valueType; + private readonly Lazy> _subExprs; + private readonly Lazy _valueType; - internal AtomicExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_AtomicExpr) - { - _subExprs = new Lazy>(() => Children.Cast().ToList()); - _valueType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } + internal AtomicExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_AtomicExpr) + { + _subExprs = new Lazy>(() => Children.Cast().ToList()); + _valueType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + } - public CX_AtomicOperatorKind Op => Handle.AtomicOperatorKind; + public CX_AtomicOperatorKind Op => Handle.AtomicOperatorKind; - public uint NumSubExprs => NumChildren; + public uint NumSubExprs => NumChildren; - public Expr Order => SubExprs[1]; + public Expr Order => SubExprs[1]; - public Expr OrderFail => NumSubExprs > 3 ? SubExprs[3] : null; + public Expr OrderFail => NumSubExprs > 3 ? SubExprs[3] : null; - public Expr Ptr => SubExprs[0]; + public Expr Ptr => SubExprs[0]; - public Expr Scope => (Op is >= CX_AtomicOperatorKind.CX_AO__opencl_atomic_load and <= CX_AtomicOperatorKind.CX_AO__opencl_atomic_fetch_max) ? SubExprs[(int)(NumSubExprs - 1)] : null; + public Expr Scope => (Op is >= CX_AtomicOperatorKind.CX_AO__opencl_atomic_load and <= CX_AtomicOperatorKind.CX_AO__opencl_atomic_fetch_max) ? SubExprs[(int)(NumSubExprs - 1)] : null; - public IReadOnlyList SubExprs => _subExprs.Value; + public IReadOnlyList SubExprs => _subExprs.Value; - public Expr Val1 + public Expr Val1 + { + get { - get - { - return Op is CX_AtomicOperatorKind.CX_AO__c11_atomic_init or CX_AtomicOperatorKind.CX_AO__opencl_atomic_init - ? Order - : (NumSubExprs > 2) ? SubExprs[2] : null; - } + return Op is CX_AtomicOperatorKind.CX_AO__c11_atomic_init or CX_AtomicOperatorKind.CX_AO__opencl_atomic_init + ? Order + : (NumSubExprs > 2) ? SubExprs[2] : null; } + } - public Expr Val => Op == CX_AtomicOperatorKind.CX_AO__atomic_exchange ? OrderFail : (NumSubExprs > 4) ? SubExprs[4] : null; + public Expr Val => Op == CX_AtomicOperatorKind.CX_AO__atomic_exchange ? OrderFail : (NumSubExprs > 4) ? SubExprs[4] : null; - public Type ValueType => _valueType.Value; + public Type ValueType => _valueType.Value; - public Expr Weak => (NumSubExprs > 5) ? SubExprs[5] : null; - } + public Expr Weak => (NumSubExprs > 5) ? SubExprs[5] : null; } diff --git a/sources/ClangSharp/Cursors/Exprs/BinaryConditionalOperator.cs b/sources/ClangSharp/Cursors/Exprs/BinaryConditionalOperator.cs index 813c6a91..f48e47b6 100644 --- a/sources/ClangSharp/Cursors/Exprs/BinaryConditionalOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/BinaryConditionalOperator.cs @@ -4,26 +4,25 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class BinaryConditionalOperator : AbstractConditionalOperator { - public sealed class BinaryConditionalOperator : AbstractConditionalOperator - { - private readonly Lazy _opaqueValue; + private readonly Lazy _opaqueValue; - internal BinaryConditionalOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_BinaryConditionalOperator) - { - Debug.Assert(NumChildren is 4); - _opaqueValue = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OpaqueValue)); - } + internal BinaryConditionalOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_BinaryConditionalOperator) + { + Debug.Assert(NumChildren is 4); + _opaqueValue = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OpaqueValue)); + } - public Expr Common => (Expr)Children[0]; + public Expr Common => (Expr)Children[0]; - public new Expr Cond => (Expr)Children[1]; + public new Expr Cond => (Expr)Children[1]; - public new Expr FalseExpr => (Expr)Children[3]; + public new Expr FalseExpr => (Expr)Children[3]; - public OpaqueValueExpr OpaqueValue => _opaqueValue.Value; + public OpaqueValueExpr OpaqueValue => _opaqueValue.Value; - public new Expr TrueExpr => (Expr)Children[2]; - } + public new Expr TrueExpr => (Expr)Children[2]; } diff --git a/sources/ClangSharp/Cursors/Exprs/BinaryOperator.cs b/sources/ClangSharp/Cursors/Exprs/BinaryOperator.cs index 6e254372..df99bc06 100644 --- a/sources/ClangSharp/Cursors/Exprs/BinaryOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/BinaryOperator.cs @@ -4,56 +4,55 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class BinaryOperator : Expr { - public class BinaryOperator : Expr + internal BinaryOperator(CXCursor handle) : this(handle, CXCursorKind.CXCursor_BinaryOperator, CX_StmtClass.CX_StmtClass_BinaryOperator) { - internal BinaryOperator(CXCursor handle) : this(handle, CXCursorKind.CXCursor_BinaryOperator, CX_StmtClass.CX_StmtClass_BinaryOperator) - { - } + } - private protected BinaryOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + private protected BinaryOperator(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastBinaryOperator or < CX_StmtClass.CX_StmtClass_FirstBinaryOperator) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastBinaryOperator or < CX_StmtClass.CX_StmtClass_FirstBinaryOperator) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - Debug.Assert(NumChildren is 2); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public bool IsAdditiveOp => Opcode is CX_BinaryOperatorKind.CX_BO_Add or CX_BinaryOperatorKind.CX_BO_Sub; + Debug.Assert(NumChildren is 2); + } + + public bool IsAdditiveOp => Opcode is CX_BinaryOperatorKind.CX_BO_Add or CX_BinaryOperatorKind.CX_BO_Sub; - public bool IsAssignmentOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_Assign and <= CX_BinaryOperatorKind.CX_BO_OrAssign; + public bool IsAssignmentOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_Assign and <= CX_BinaryOperatorKind.CX_BO_OrAssign; - public bool IsBitwiseOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_And and <= CX_BinaryOperatorKind.CX_BO_Or; + public bool IsBitwiseOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_And and <= CX_BinaryOperatorKind.CX_BO_Or; - public bool IsCommaOp => Opcode == CX_BinaryOperatorKind.CX_BO_Comma; + public bool IsCommaOp => Opcode == CX_BinaryOperatorKind.CX_BO_Comma; - public bool IsComparisonOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_Cmp and <= CX_BinaryOperatorKind.CX_BO_NE; + public bool IsComparisonOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_Cmp and <= CX_BinaryOperatorKind.CX_BO_NE; - public bool IsCompoundAssignmentOp=> Opcode is > CX_BinaryOperatorKind.CX_BO_Assign and <= CX_BinaryOperatorKind.CX_BO_OrAssign; + public bool IsCompoundAssignmentOp=> Opcode is > CX_BinaryOperatorKind.CX_BO_Assign and <= CX_BinaryOperatorKind.CX_BO_OrAssign; - public bool IsEqualityOp => Opcode is CX_BinaryOperatorKind.CX_BO_EQ or CX_BinaryOperatorKind.CX_BO_NE; + public bool IsEqualityOp => Opcode is CX_BinaryOperatorKind.CX_BO_EQ or CX_BinaryOperatorKind.CX_BO_NE; - public bool IsLogicalOp => Opcode is CX_BinaryOperatorKind.CX_BO_LAnd or CX_BinaryOperatorKind.CX_BO_LOr; + public bool IsLogicalOp => Opcode is CX_BinaryOperatorKind.CX_BO_LAnd or CX_BinaryOperatorKind.CX_BO_LOr; - public bool IsMultiplicativeOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_Mul and <= CX_BinaryOperatorKind.CX_BO_Rem; + public bool IsMultiplicativeOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_Mul and <= CX_BinaryOperatorKind.CX_BO_Rem; - public bool IsPtrMemOp => Opcode is CX_BinaryOperatorKind.CX_BO_PtrMemD or CX_BinaryOperatorKind.CX_BO_PtrMemI; + public bool IsPtrMemOp => Opcode is CX_BinaryOperatorKind.CX_BO_PtrMemD or CX_BinaryOperatorKind.CX_BO_PtrMemI; - public bool IsRelationalOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_LT and <= CX_BinaryOperatorKind.CX_BO_GE; + public bool IsRelationalOp => Opcode is >= CX_BinaryOperatorKind.CX_BO_LT and <= CX_BinaryOperatorKind.CX_BO_GE; - public bool IsShiftAssignOp=> Opcode is CX_BinaryOperatorKind.CX_BO_ShlAssign or CX_BinaryOperatorKind.CX_BO_ShrAssign; + public bool IsShiftAssignOp=> Opcode is CX_BinaryOperatorKind.CX_BO_ShlAssign or CX_BinaryOperatorKind.CX_BO_ShrAssign; - public bool IsShiftOp => Opcode is CX_BinaryOperatorKind.CX_BO_Shl or CX_BinaryOperatorKind.CX_BO_Shr; + public bool IsShiftOp => Opcode is CX_BinaryOperatorKind.CX_BO_Shl or CX_BinaryOperatorKind.CX_BO_Shr; - public Expr LHS => (Expr)Children[0]; + public Expr LHS => (Expr)Children[0]; - public CX_BinaryOperatorKind Opcode => Handle.BinaryOperatorKind; + public CX_BinaryOperatorKind Opcode => Handle.BinaryOperatorKind; - public string OpcodeStr => Handle.BinaryOperatorKindSpelling.CString; + public string OpcodeStr => Handle.BinaryOperatorKindSpelling.CString; - public Expr RHS => (Expr)Children[1]; - } + public Expr RHS => (Expr)Children[1]; } diff --git a/sources/ClangSharp/Cursors/Exprs/BlockExpr.cs b/sources/ClangSharp/Cursors/Exprs/BlockExpr.cs index 9937ee29..3a4574e4 100644 --- a/sources/ClangSharp/Cursors/Exprs/BlockExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/BlockExpr.cs @@ -4,22 +4,21 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class BlockExpr : Expr { - public sealed class BlockExpr : Expr - { - private readonly Lazy _blockDecl; + private readonly Lazy _blockDecl; - internal BlockExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BlockExpr, CX_StmtClass.CX_StmtClass_BlockExpr) - { - Debug.Assert(NumChildren is 0); - _blockDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal BlockExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BlockExpr, CX_StmtClass.CX_StmtClass_BlockExpr) + { + Debug.Assert(NumChildren is 0); + _blockDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public BlockDecl BlockDecl => _blockDecl.Value; + public BlockDecl BlockDecl => _blockDecl.Value; - public Stmt Body => BlockDecl.Body; + public Stmt Body => BlockDecl.Body; - public FunctionProtoType FunctionType => (FunctionProtoType)((BlockPointerType)Type).PointeeType; - } + public FunctionProtoType FunctionType => (FunctionProtoType)((BlockPointerType)Type).PointeeType; } diff --git a/sources/ClangSharp/Cursors/Exprs/BuiltinBitCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/BuiltinBitCastExpr.cs index e09fdc31..93008d65 100644 --- a/sources/ClangSharp/Cursors/Exprs/BuiltinBitCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/BuiltinBitCastExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class BuiltinBitCastExpr : ExplicitCastExpr { - public sealed class BuiltinBitCastExpr : ExplicitCastExpr + internal BuiltinBitCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BuiltinBitCastExpr, CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr) { - internal BuiltinBitCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BuiltinBitCastExpr, CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CStyleCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CStyleCastExpr.cs index 52a86bbb..be06ac1d 100644 --- a/sources/ClangSharp/Cursors/Exprs/CStyleCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CStyleCastExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CStyleCastExpr : ExplicitCastExpr { - public sealed class CStyleCastExpr : ExplicitCastExpr + internal CStyleCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CStyleCastExpr, CX_StmtClass.CX_StmtClass_CStyleCastExpr) { - internal CStyleCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CStyleCastExpr, CX_StmtClass.CX_StmtClass_CStyleCastExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CUDAKernelCallExpr.cs b/sources/ClangSharp/Cursors/Exprs/CUDAKernelCallExpr.cs index b36f3541..e9e78e4f 100644 --- a/sources/ClangSharp/Cursors/Exprs/CUDAKernelCallExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CUDAKernelCallExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CUDAKernelCallExpr : CallExpr { - public sealed class CUDAKernelCallExpr : CallExpr + internal CUDAKernelCallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr) { - internal CUDAKernelCallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXAddrspaceCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXAddrspaceCastExpr.cs index 1704b881..450c40da 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXAddrspaceCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXAddrspaceCastExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXAddrspaceCastExpr : CXXNamedCastExpr { - public sealed class CXXAddrspaceCastExpr : CXXNamedCastExpr + internal CXXAddrspaceCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXAddrspaceCastExpr, CX_StmtClass.CX_StmtClass_CXXAddrspaceCastExpr) { - internal CXXAddrspaceCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXAddrspaceCastExpr, CX_StmtClass.CX_StmtClass_CXXAddrspaceCastExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXBindTemporaryExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXBindTemporaryExpr.cs index aed5df6c..e2078c2a 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXBindTemporaryExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXBindTemporaryExpr.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXBindTemporaryExpr : Expr { - public sealed class CXXBindTemporaryExpr : Expr + internal CXXBindTemporaryExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr) { - internal CXXBindTemporaryExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr) - { - Debug.Assert(NumChildren is 1); - } - - public Expr SubExpr => (Expr)Children[0]; + Debug.Assert(NumChildren is 1); } + + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXBoolLiteralExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXBoolLiteralExpr.cs index c836f0f7..7198e98d 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXBoolLiteralExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXBoolLiteralExpr.cs @@ -4,30 +4,29 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXBoolLiteralExpr : Expr { - public sealed class CXXBoolLiteralExpr : Expr - { - private readonly Lazy _valueString; + private readonly Lazy _valueString; - internal CXXBoolLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXBoolLiteralExpr, CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr) - { - Debug.Assert(NumChildren is 0); + internal CXXBoolLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXBoolLiteralExpr, CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr) + { + Debug.Assert(NumChildren is 0); - _valueString = new Lazy(() => { - var tokens = Handle.TranslationUnit.Tokenize(Handle.SourceRange); + _valueString = new Lazy(() => { + var tokens = Handle.TranslationUnit.Tokenize(Handle.SourceRange); - Debug.Assert(tokens.Length == 1); - Debug.Assert(tokens[0].Kind == CXTokenKind.CXToken_Keyword); + Debug.Assert(tokens.Length == 1); + Debug.Assert(tokens[0].Kind == CXTokenKind.CXToken_Keyword); - var spelling = tokens[0].GetSpelling(Handle.TranslationUnit).ToString(); - spelling = spelling.Trim('\\', '\r', '\n'); - return spelling; - }); - } + var spelling = tokens[0].GetSpelling(Handle.TranslationUnit).ToString(); + spelling = spelling.Trim('\\', '\r', '\n'); + return spelling; + }); + } - public bool Value => Handle.BoolLiteralValue; + public bool Value => Handle.BoolLiteralValue; - public string ValueString => _valueString.Value; - } + public string ValueString => _valueString.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXConstCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXConstCastExpr.cs index 17817099..78b6a47a 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXConstCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXConstCastExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXConstCastExpr : CXXNamedCastExpr { - public sealed class CXXConstCastExpr : CXXNamedCastExpr + internal CXXConstCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXConstCastExpr, CX_StmtClass.CX_StmtClass_CXXConstCastExpr) { - internal CXXConstCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXConstCastExpr, CX_StmtClass.CX_StmtClass_CXXConstCastExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXConstructExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXConstructExpr.cs index f5258060..c04a022d 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXConstructExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXConstructExpr.cs @@ -6,45 +6,44 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class CXXConstructExpr : Expr { - public class CXXConstructExpr : Expr + private readonly Lazy> _args; + private readonly Lazy _constructor; + + internal CXXConstructExpr(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXConstructExpr) { - private readonly Lazy> _args; - private readonly Lazy _constructor; + } - internal CXXConstructExpr(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXConstructExpr) + private protected CXXConstructExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCXXConstructExpr or < CX_StmtClass.CX_StmtClass_FirstCXXConstructExpr) { + throw new ArgumentOutOfRangeException(nameof(handle)); } + Debug.Assert(NumChildren == NumArgs); - private protected CXXConstructExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) - { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCXXConstructExpr or < CX_StmtClass.CX_StmtClass_FirstCXXConstructExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - Debug.Assert(NumChildren == NumArgs); - - _args = new Lazy>(() => Children.Cast().ToList()); - _constructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + _args = new Lazy>(() => Children.Cast().ToList()); + _constructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public IReadOnlyList Args => _args.Value; + public IReadOnlyList Args => _args.Value; - public CXXConstructorDecl Constructor => _constructor.Value; + public CXXConstructorDecl Constructor => _constructor.Value; - public CX_ConstructionKind ConstructionKind => Handle.ConstructionKind; + public CX_ConstructionKind ConstructionKind => Handle.ConstructionKind; - public bool HadMultipleCandidates => Handle.HadMultipleCandidates; + public bool HadMultipleCandidates => Handle.HadMultipleCandidates; - public bool IsElidable => Handle.IsElidable; + public bool IsElidable => Handle.IsElidable; - public bool IsListInitialization => Handle.IsListInitialization; + public bool IsListInitialization => Handle.IsListInitialization; - public bool IsStdInitListInitialization => Handle.IsStdInitListInitialization; + public bool IsStdInitListInitialization => Handle.IsStdInitListInitialization; - public uint NumArgs => (uint)Handle.NumArguments; + public uint NumArgs => (uint)Handle.NumArguments; - public bool RequiresZeroInitialization => Handle.RequiresZeroInitialization; - } + public bool RequiresZeroInitialization => Handle.RequiresZeroInitialization; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs index 51aefe0d..c980f572 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXDefaultArgExpr.cs @@ -4,25 +4,24 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXDefaultArgExpr : Expr { - public sealed class CXXDefaultArgExpr : Expr - { - private readonly Lazy _param; - private readonly Lazy _usedContext; + private readonly Lazy _param; + private readonly Lazy _usedContext; - internal CXXDefaultArgExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr) - { - Debug.Assert(NumChildren is 0); + internal CXXDefaultArgExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr) + { + Debug.Assert(NumChildren is 0); - _param = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _usedContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UsedContext) as IDeclContext); - } + _param = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _usedContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UsedContext) as IDeclContext); + } - public Expr Expr => Param.DefaultArg; + public Expr Expr => Param.DefaultArg; - public ParmVarDecl Param => _param.Value; + public ParmVarDecl Param => _param.Value; - public IDeclContext UsedContext => _usedContext.Value; - } + public IDeclContext UsedContext => _usedContext.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDefaultInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDefaultInitExpr.cs index 2bf2791e..23cfe325 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXDefaultInitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXDefaultInitExpr.cs @@ -4,25 +4,24 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXDefaultInitExpr : Expr { - public sealed class CXXDefaultInitExpr : Expr - { - private readonly Lazy _field; - private readonly Lazy _usedContext; + private readonly Lazy _field; + private readonly Lazy _usedContext; - internal CXXDefaultInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr) - { - Debug.Assert(NumChildren is 0); + internal CXXDefaultInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr) + { + Debug.Assert(NumChildren is 0); - _field = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _usedContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UsedContext) as IDeclContext); - } + _field = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _usedContext = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UsedContext) as IDeclContext); + } - public Expr Expr => Field.InClassInitializer; + public Expr Expr => Field.InClassInitializer; - public FieldDecl Field => _field.Value; + public FieldDecl Field => _field.Value; - public IDeclContext UsedContext => _usedContext.Value; - } + public IDeclContext UsedContext => _usedContext.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDeleteExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDeleteExpr.cs index 2498d8b8..62438435 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXDeleteExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXDeleteExpr.cs @@ -4,33 +4,32 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXDeleteExpr : Expr { - public sealed class CXXDeleteExpr : Expr - { - private readonly Lazy _destroyedType; - private readonly Lazy _operatorDelete; + private readonly Lazy _destroyedType; + private readonly Lazy _operatorDelete; - internal CXXDeleteExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXDeleteExpr, CX_StmtClass.CX_StmtClass_CXXDeleteExpr) - { - Debug.Assert(NumChildren is 1); + internal CXXDeleteExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXDeleteExpr, CX_StmtClass.CX_StmtClass_CXXDeleteExpr) + { + Debug.Assert(NumChildren is 1); - _destroyedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - _operatorDelete = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + _destroyedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + _operatorDelete = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public Expr Argument => (Expr)Children[0]; + public Expr Argument => (Expr)Children[0]; - public Type DestroyedType => _destroyedType.Value; + public Type DestroyedType => _destroyedType.Value; - public bool DoesUsualArrayDeleteWantSize => Handle.DoesUsualArrayDeleteWantSize; + public bool DoesUsualArrayDeleteWantSize => Handle.DoesUsualArrayDeleteWantSize; - public bool IsArrayForm => Handle.IsArrayForm; + public bool IsArrayForm => Handle.IsArrayForm; - public bool IsArrayFormAsWritten => Handle.IsArrayFormAsWritten; + public bool IsArrayFormAsWritten => Handle.IsArrayFormAsWritten; - public bool IsGlobalDelete => Handle.IsGlobal; + public bool IsGlobalDelete => Handle.IsGlobal; - public FunctionDecl OperatorDelete => _operatorDelete.Value; - } + public FunctionDecl OperatorDelete => _operatorDelete.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDependentScopeMemberExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDependentScopeMemberExpr.cs index 19e5ce42..53528bdb 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXDependentScopeMemberExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXDependentScopeMemberExpr.cs @@ -6,52 +6,51 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class CXXDependentScopeMemberExpr : Expr - { - private readonly Lazy _baseType; - private readonly Lazy _firstQualifierFoundInScope; - private readonly Lazy> _templateArgs; - - internal CXXDependentScopeMemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr) - { - Debug.Assert(NumChildren is 0 or 1); - - _baseType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - _firstQualifierFoundInScope = new Lazy(() => TranslationUnit.GetOrCreate(handle.Referenced)); - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); +namespace ClangSharp; - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); - templateArgs.Add(templateArg); - } +public sealed class CXXDependentScopeMemberExpr : Expr +{ + private readonly Lazy _baseType; + private readonly Lazy _firstQualifierFoundInScope; + private readonly Lazy> _templateArgs; - return templateArgs; - }); - } + internal CXXDependentScopeMemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr) + { + Debug.Assert(NumChildren is 0 or 1); + + _baseType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + _firstQualifierFoundInScope = new Lazy(() => TranslationUnit.GetOrCreate(handle.Referenced)); + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); + + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); + templateArgs.Add(templateArg); + } + + return templateArgs; + }); + } - public Expr Base => (Expr)Children.SingleOrDefault(); + public Expr Base => (Expr)Children.SingleOrDefault(); - public Type BaseType => _baseType.Value; + public Type BaseType => _baseType.Value; - public NamedDecl FirstQualifierFoundInScope => _firstQualifierFoundInScope.Value; + public NamedDecl FirstQualifierFoundInScope => _firstQualifierFoundInScope.Value; - public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; + public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; - public bool HasTemplateKeyword => Handle.HasTemplateKeyword; + public bool HasTemplateKeyword => Handle.HasTemplateKeyword; - public bool IsArrow => Handle.IsArrow; + public bool IsArrow => Handle.IsArrow; - public bool IsImplicitAccess => (Base is null) || Base.IsImplicitCXXThis; + public bool IsImplicitAccess => (Base is null) || Base.IsImplicitCXXThis; - public string MemberName => Handle.Name.CString; + public string MemberName => Handle.Name.CString; - public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); + public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); - public IReadOnlyList TemplateArgs => _templateArgs.Value; - } + public IReadOnlyList TemplateArgs => _templateArgs.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXDynamicCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXDynamicCastExpr.cs index 53fec088..71d3d2d3 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXDynamicCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXDynamicCastExpr.cs @@ -2,14 +2,13 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXDynamicCastExpr : CXXNamedCastExpr { - public sealed class CXXDynamicCastExpr : CXXNamedCastExpr + internal CXXDynamicCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXDynamicCastExpr, CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr) { - internal CXXDynamicCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXDynamicCastExpr, CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr) - { - } - - public bool IsAlwaysNull => Handle.IsAlwaysNull; } + + public bool IsAlwaysNull => Handle.IsAlwaysNull; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXFoldExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXFoldExpr.cs index 7244ab97..fa58b35c 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXFoldExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXFoldExpr.cs @@ -3,29 +3,28 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXFoldExpr : Expr { - public sealed class CXXFoldExpr : Expr + internal CXXFoldExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXFoldExpr) { - internal CXXFoldExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXFoldExpr) - { - Debug.Assert(NumChildren is 3); - } + Debug.Assert(NumChildren is 3); + } - public UnresolvedLookupExpr Callee => (UnresolvedLookupExpr)Children[0]; + public UnresolvedLookupExpr Callee => (UnresolvedLookupExpr)Children[0]; - public Expr Init => IsLeftFold ? LHS : RHS; + public Expr Init => IsLeftFold ? LHS : RHS; - public bool IsLeftFold => !IsRightFold; + public bool IsLeftFold => !IsRightFold; - public bool IsRightFold => (LHS != null) && LHS.ContainsUnexpandedParameterPack; + public bool IsRightFold => (LHS != null) && LHS.ContainsUnexpandedParameterPack; - public Expr LHS => (Expr)Children[1]; + public Expr LHS => (Expr)Children[1]; - public CX_BinaryOperatorKind Operator => Handle.BinaryOperatorKind; + public CX_BinaryOperatorKind Operator => Handle.BinaryOperatorKind; - public Expr Pattern => IsLeftFold ? RHS : LHS; + public Expr Pattern => IsLeftFold ? RHS : LHS; - public Expr RHS => (Expr)Children[2]; - } + public Expr RHS => (Expr)Children[2]; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXFunctionalCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXFunctionalCastExpr.cs index 0fb25869..f8d727dc 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXFunctionalCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXFunctionalCastExpr.cs @@ -2,14 +2,13 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXFunctionalCastExpr : ExplicitCastExpr { - public sealed class CXXFunctionalCastExpr : ExplicitCastExpr + internal CXXFunctionalCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXFunctionalCastExpr, CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr) { - internal CXXFunctionalCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXFunctionalCastExpr, CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr) - { - } - - public bool IsListInitialization => Handle.IsListInitialization; } + + public bool IsListInitialization => Handle.IsListInitialization; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXInheritedCtorInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXInheritedCtorInitExpr.cs index 35cce283..ba92e6e2 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXInheritedCtorInitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXInheritedCtorInitExpr.cs @@ -4,24 +4,23 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXInheritedCtorInitExpr : Expr { - public sealed class CXXInheritedCtorInitExpr : Expr - { - private readonly Lazy _constructor; + private readonly Lazy _constructor; - internal CXXInheritedCtorInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr) - { - Debug.Assert(NumChildren is 0); - _constructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal CXXInheritedCtorInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr) + { + Debug.Assert(NumChildren is 0); + _constructor = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public CX_ConstructionKind ConstructionKind => ConstructsVBase ? CX_ConstructionKind.CX_CK_VirtualBase : CX_ConstructionKind.CX_CK_NonVirtualBase; + public CX_ConstructionKind ConstructionKind => ConstructsVBase ? CX_ConstructionKind.CX_CK_VirtualBase : CX_ConstructionKind.CX_CK_NonVirtualBase; - public CXXConstructorDecl Constructor => _constructor.Value; + public CXXConstructorDecl Constructor => _constructor.Value; - public bool ConstructsVBase => Handle.ConstructsVirtualBase; + public bool ConstructsVBase => Handle.ConstructsVirtualBase; - public bool InheritedFromVBase => Handle.InheritedFromVBase; - } + public bool InheritedFromVBase => Handle.InheritedFromVBase; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXMemberCallExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXMemberCallExpr.cs index f4ca266d..8c2908cd 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXMemberCallExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXMemberCallExpr.cs @@ -2,63 +2,62 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXMemberCallExpr : CallExpr { - public sealed class CXXMemberCallExpr : CallExpr + internal CXXMemberCallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXMemberCallExpr) { - internal CXXMemberCallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXMemberCallExpr) - { - } + } - public Expr ImplicitObjectArgument + public Expr ImplicitObjectArgument + { + get { - get - { - var callee = Callee.IgnoreParens; + var callee = Callee.IgnoreParens; - if (callee is MemberExpr memExpr) - { - return memExpr.Base; - } + if (callee is MemberExpr memExpr) + { + return memExpr.Base; + } - if (callee is BinaryOperator bo) + if (callee is BinaryOperator bo) + { + if (bo.IsPtrMemOp) { - if (bo.IsPtrMemOp) - { - return bo.LHS; - } + return bo.LHS; } - - return null; } + + return null; } + } - public CXXMethodDecl MethodDecl => Callee.IgnoreParens is MemberExpr memExpr ? (CXXMethodDecl)memExpr.MemberDecl : null; + public CXXMethodDecl MethodDecl => Callee.IgnoreParens is MemberExpr memExpr ? (CXXMethodDecl)memExpr.MemberDecl : null; - public Type ObjectType + public Type ObjectType + { + get { - get - { - var ty = ImplicitObjectArgument.Type; + var ty = ImplicitObjectArgument.Type; - if (ty.IsPointerType) - { - ty = ty.PointeeType; - } - return ty; + if (ty.IsPointerType) + { + ty = ty.PointeeType; } + return ty; } + } - public CXXRecordDecl RecordDecl + public CXXRecordDecl RecordDecl + { + get { - get - { - var thisArg = ImplicitObjectArgument; + var thisArg = ImplicitObjectArgument; - return thisArg is null - ? null - : thisArg.Type.IsAnyPointerType ? thisArg.Type.PointeeType.AsCXXRecordDecl : thisArg.Type.AsCXXRecordDecl; - } + return thisArg is null + ? null + : thisArg.Type.IsAnyPointerType ? thisArg.Type.PointeeType.AsCXXRecordDecl : thisArg.Type.AsCXXRecordDecl; } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXNamedCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXNamedCastExpr.cs index dd304b7b..1e9d961f 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXNamedCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXNamedCastExpr.cs @@ -3,18 +3,17 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class CXXNamedCastExpr : ExplicitCastExpr { - public class CXXNamedCastExpr : ExplicitCastExpr + private protected CXXNamedCastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected CXXNamedCastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCXXNamedCastExpr or < CX_StmtClass.CX_StmtClass_FirstCXXNamedCastExpr) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCXXNamedCastExpr or < CX_StmtClass.CX_StmtClass_FirstCXXNamedCastExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } - - public string CastName => Handle.Name.CString; } + + public string CastName => Handle.Name.CString; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXNewExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXNewExpr.cs index 520b26ba..c7a3d2e8 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXNewExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXNewExpr.cs @@ -5,49 +5,48 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXNewExpr : Expr { - public sealed class CXXNewExpr : Expr - { - private readonly Lazy _operatorDelete; - private readonly Lazy _operatorNew; - private readonly Lazy> _placementArgs; + private readonly Lazy _operatorDelete; + private readonly Lazy _operatorNew; + private readonly Lazy> _placementArgs; - internal CXXNewExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXNewExpr, CX_StmtClass.CX_StmtClass_CXXNewExpr) - { - _operatorDelete = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(0))); - _operatorNew = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(1))); - _placementArgs = new Lazy>(() => Children.Skip(PlacementNewArgsOffset).Cast().ToList()); - } + internal CXXNewExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXNewExpr, CX_StmtClass.CX_StmtClass_CXXNewExpr) + { + _operatorDelete = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(0))); + _operatorNew = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(1))); + _placementArgs = new Lazy>(() => Children.Skip(PlacementNewArgsOffset).Cast().ToList()); + } - public Type AllocatedType => ((PointerType)Type).PointeeType; + public Type AllocatedType => ((PointerType)Type).PointeeType; - public Expr ArraySize => IsArray ? (Expr)Children[ArraySizeOffset] : null; + public Expr ArraySize => IsArray ? (Expr)Children[ArraySizeOffset] : null; - public CXXConstructExpr ConstructExpr => Initializer as CXXConstructExpr; + public CXXConstructExpr ConstructExpr => Initializer as CXXConstructExpr; - public bool DoesUsualArrayDeleteWantSize => Handle.DoesUsualArrayDeleteWantSize; + public bool DoesUsualArrayDeleteWantSize => Handle.DoesUsualArrayDeleteWantSize; - public bool HasInitializer => Handle.HasInit; + public bool HasInitializer => Handle.HasInit; - public Expr Initializer => HasInitializer ? (Expr)Children[InitExprOffset] : null; + public Expr Initializer => HasInitializer ? (Expr)Children[InitExprOffset] : null; - public bool IsArray => Handle.IsArrayForm; + public bool IsArray => Handle.IsArrayForm; - public bool IsGlobalNew => Handle.IsGlobal; + public bool IsGlobalNew => Handle.IsGlobal; - public uint NumPlacementArgs => unchecked((uint)(Handle.NumArguments - PlacementNewArgsOffset)); + public uint NumPlacementArgs => unchecked((uint)(Handle.NumArguments - PlacementNewArgsOffset)); - public FunctionDecl OperatorDelete => _operatorDelete.Value; + public FunctionDecl OperatorDelete => _operatorDelete.Value; - public FunctionDecl OperatorNew => _operatorNew.Value; + public FunctionDecl OperatorNew => _operatorNew.Value; - public IReadOnlyList PlacementArgs => _placementArgs.Value; + public IReadOnlyList PlacementArgs => _placementArgs.Value; - private static int ArraySizeOffset => 0; + private static int ArraySizeOffset => 0; - private int InitExprOffset => ArraySizeOffset + (IsArray ? 1 : 0); + private int InitExprOffset => ArraySizeOffset + (IsArray ? 1 : 0); - private int PlacementNewArgsOffset => InitExprOffset + (HasInitializer ? 1 : 0); - } + private int PlacementNewArgsOffset => InitExprOffset + (HasInitializer ? 1 : 0); } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXNoexceptExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXNoexceptExpr.cs index 3dc4f452..95a3cc27 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXNoexceptExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXNoexceptExpr.cs @@ -3,17 +3,16 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXNoexceptExpr : Expr { - public sealed class CXXNoexceptExpr : Expr + internal CXXNoexceptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryExpr, CX_StmtClass.CX_StmtClass_CXXNoexceptExpr) { - internal CXXNoexceptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryExpr, CX_StmtClass.CX_StmtClass_CXXNoexceptExpr) - { - Debug.Assert(NumChildren is 1); - } + Debug.Assert(NumChildren is 1); + } - public Expr Operand => (Expr)Children[0]; + public Expr Operand => (Expr)Children[0]; - public bool Value => Handle.BoolLiteralValue; - } + public bool Value => Handle.BoolLiteralValue; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXNullPtrLiteralExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXNullPtrLiteralExpr.cs index 08fc962b..76608364 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXNullPtrLiteralExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXNullPtrLiteralExpr.cs @@ -3,13 +3,12 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXNullPtrLiteralExpr : Expr { - public sealed class CXXNullPtrLiteralExpr : Expr + internal CXXNullPtrLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXNullPtrLiteralExpr, CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr) { - internal CXXNullPtrLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXNullPtrLiteralExpr, CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr) - { - Debug.Assert(NumChildren is 0); - } + Debug.Assert(NumChildren is 0); } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXOperatorCallExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXOperatorCallExpr.cs index a9eaebfe..ffe812ca 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXOperatorCallExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXOperatorCallExpr.cs @@ -2,14 +2,13 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXOperatorCallExpr : CallExpr { - public sealed class CXXOperatorCallExpr : CallExpr + internal CXXOperatorCallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr) { - internal CXXOperatorCallExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr) - { - } - - public CX_OverloadedOperatorKind Operator => Handle.OverloadedOperatorKind; } + + public CX_OverloadedOperatorKind Operator => Handle.OverloadedOperatorKind; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXPseudoDestructorExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXPseudoDestructorExpr.cs index cdb6cd6b..9287e91c 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXPseudoDestructorExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXPseudoDestructorExpr.cs @@ -4,22 +4,21 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXPseudoDestructorExpr : Expr { - public sealed class CXXPseudoDestructorExpr : Expr - { - private readonly Lazy _destroyedType; + private readonly Lazy _destroyedType; - internal CXXPseudoDestructorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr) - { - Debug.Assert(NumChildren is 1); - _destroyedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } + internal CXXPseudoDestructorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr) + { + Debug.Assert(NumChildren is 1); + _destroyedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + } - public Expr Base => (Expr)Children[0]; + public Expr Base => (Expr)Children[0]; - public Type DestroyedType => _destroyedType.Value; + public Type DestroyedType => _destroyedType.Value; - public bool IsArrow => Handle.IsArrow; - } + public bool IsArrow => Handle.IsArrow; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXReinterpretCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXReinterpretCastExpr.cs index 3b787351..04e42139 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXReinterpretCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXReinterpretCastExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXReinterpretCastExpr : CXXNamedCastExpr { - public sealed class CXXReinterpretCastExpr : CXXNamedCastExpr + internal CXXReinterpretCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXReinterpretCastExpr, CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr) { - internal CXXReinterpretCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXReinterpretCastExpr, CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXRewrittenBinaryOperator.cs b/sources/ClangSharp/Cursors/Exprs/CXXRewrittenBinaryOperator.cs index 07168b5f..5b9c31e8 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXRewrittenBinaryOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXRewrittenBinaryOperator.cs @@ -4,35 +4,34 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXRewrittenBinaryOperator : Expr { - public sealed class CXXRewrittenBinaryOperator : Expr - { - private readonly Lazy _lhs; - private readonly Lazy _rhs; + private readonly Lazy _lhs; + private readonly Lazy _rhs; - internal CXXRewrittenBinaryOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator) - { - Debug.Assert(NumChildren is 1); + internal CXXRewrittenBinaryOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator) + { + Debug.Assert(NumChildren is 1); - _lhs = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LhsExpr)); - _rhs = new Lazy(() => TranslationUnit.GetOrCreate(Handle.RhsExpr)); - } + _lhs = new Lazy(() => TranslationUnit.GetOrCreate(Handle.LhsExpr)); + _rhs = new Lazy(() => TranslationUnit.GetOrCreate(Handle.RhsExpr)); + } - public Expr LHS => _lhs.Value; + public Expr LHS => _lhs.Value; - public static bool IsAssignmentOp => false; + public static bool IsAssignmentOp => false; - public static bool IsComparisonOp => true; + public static bool IsComparisonOp => true; - public CX_BinaryOperatorKind Opcode => Operator; + public CX_BinaryOperatorKind Opcode => Operator; - public CX_BinaryOperatorKind Operator => Handle.BinaryOperatorKind; + public CX_BinaryOperatorKind Operator => Handle.BinaryOperatorKind; - public string OpcodeStr => Handle.BinaryOperatorKindSpelling.CString; + public string OpcodeStr => Handle.BinaryOperatorKindSpelling.CString; - public Expr RHS => _rhs.Value; + public Expr RHS => _rhs.Value; - public Expr SemanticForm => (Expr)Children[0]; - } + public Expr SemanticForm => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXScalarValueInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXScalarValueInitExpr.cs index 94063e74..760cfb34 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXScalarValueInitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXScalarValueInitExpr.cs @@ -4,18 +4,17 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class CXXScalarValueInitExpr : Expr - { - private readonly Lazy _typeSourceInfoType; +namespace ClangSharp; - internal CXXScalarValueInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr) - { - Debug.Assert(NumChildren is 0); - _typeSourceInfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } +public sealed class CXXScalarValueInitExpr : Expr +{ + private readonly Lazy _typeSourceInfoType; - public Type TypeSourceInfoType => _typeSourceInfoType.Value; + internal CXXScalarValueInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr) + { + Debug.Assert(NumChildren is 0); + _typeSourceInfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); } + + public Type TypeSourceInfoType => _typeSourceInfoType.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXStaticCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXStaticCastExpr.cs index 4982617a..73115c54 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXStaticCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXStaticCastExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXStaticCastExpr : CXXNamedCastExpr { - public sealed class CXXStaticCastExpr : CXXNamedCastExpr + internal CXXStaticCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXStaticCastExpr, CX_StmtClass.CX_StmtClass_CXXStaticCastExpr) { - internal CXXStaticCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXStaticCastExpr, CX_StmtClass.CX_StmtClass_CXXStaticCastExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXStdInitializerListExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXStdInitializerListExpr.cs index 09c5a3b8..6f9737fd 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXStdInitializerListExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXStdInitializerListExpr.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXStdInitializerListExpr : Expr { - public sealed class CXXStdInitializerListExpr : Expr + internal CXXStdInitializerListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr) { - internal CXXStdInitializerListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr) - { - Debug.Assert(NumChildren is 1); - } - - public Expr SubExpr => (Expr)Children[0]; + Debug.Assert(NumChildren is 1); } + + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXTemporaryObjectExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXTemporaryObjectExpr.cs index 1e0fcd2c..d385fe50 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXTemporaryObjectExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXTemporaryObjectExpr.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class CXXTemporaryObjectExpr : CXXConstructExpr - { - private readonly Lazy _typeSourceInfoType; +namespace ClangSharp; - internal CXXTemporaryObjectExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr) - { - _typeSourceInfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } +public sealed class CXXTemporaryObjectExpr : CXXConstructExpr +{ + private readonly Lazy _typeSourceInfoType; - public Type TypeSourceInfoType => _typeSourceInfoType.Value; + internal CXXTemporaryObjectExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr) + { + _typeSourceInfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); } + + public Type TypeSourceInfoType => _typeSourceInfoType.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXThisExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXThisExpr.cs index 5b73dc8b..5b5e7450 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXThisExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXThisExpr.cs @@ -2,14 +2,13 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXThisExpr : Expr { - public sealed class CXXThisExpr : Expr + internal CXXThisExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXThisExpr, CX_StmtClass.CX_StmtClass_CXXThisExpr) { - internal CXXThisExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXThisExpr, CX_StmtClass.CX_StmtClass_CXXThisExpr) - { - } - - public bool IsImplicit => Handle.IsImplicit; } + + public bool IsImplicit => Handle.IsImplicit; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXThrowExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXThrowExpr.cs index 16ceb023..dcd5e076 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXThrowExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXThrowExpr.cs @@ -3,17 +3,16 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXThrowExpr : Expr { - public sealed class CXXThrowExpr : Expr + internal CXXThrowExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXThrowExpr, CX_StmtClass.CX_StmtClass_CXXThrowExpr) { - internal CXXThrowExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXThrowExpr, CX_StmtClass.CX_StmtClass_CXXThrowExpr) - { - Debug.Assert(NumChildren is 1); - } + Debug.Assert(NumChildren is 1); + } - public bool IsThrownVariableInScope => Handle.IsThrownVariableInScope; + public bool IsThrownVariableInScope => Handle.IsThrownVariableInScope; - public Expr SubExpr => (Expr)Children[0]; - } + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXTypeidExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXTypeidExpr.cs index 9c012d5e..793f65a8 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXTypeidExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXTypeidExpr.cs @@ -5,24 +5,23 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXTypeidExpr : Expr { - public sealed class CXXTypeidExpr : Expr - { - private readonly Lazy _typeOperand; + private readonly Lazy _typeOperand; - internal CXXTypeidExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXTypeidExpr, CX_StmtClass.CX_StmtClass_CXXTypeidExpr) - { - Debug.Assert(NumChildren is 0 or 1); - _typeOperand = new Lazy(() => TranslationUnit.GetOrCreate(handle.TypeOperand)); - } + internal CXXTypeidExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXTypeidExpr, CX_StmtClass.CX_StmtClass_CXXTypeidExpr) + { + Debug.Assert(NumChildren is 0 or 1); + _typeOperand = new Lazy(() => TranslationUnit.GetOrCreate(handle.TypeOperand)); + } - public Expr ExprOperand => (Expr)Children.SingleOrDefault(); + public Expr ExprOperand => (Expr)Children.SingleOrDefault(); - public bool IsPotentiallyEvaluated => Handle.IsPotentiallyEvaluated; + public bool IsPotentiallyEvaluated => Handle.IsPotentiallyEvaluated; - public bool IsTypeOperand => NumChildren is 0; + public bool IsTypeOperand => NumChildren is 0; - public Type TypeOperand => _typeOperand.Value; - } + public Type TypeOperand => _typeOperand.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXUnresolvedConstructExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXUnresolvedConstructExpr.cs index 8a33a843..ab4a6d93 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXUnresolvedConstructExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXUnresolvedConstructExpr.cs @@ -5,25 +5,24 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXUnresolvedConstructExpr : Expr { - public sealed class CXXUnresolvedConstructExpr : Expr - { - private readonly Lazy> _args; - private readonly Lazy _typeAsWritten; + private readonly Lazy> _args; + private readonly Lazy _typeAsWritten; - internal CXXUnresolvedConstructExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr) - { - _args = new Lazy>(() => Children.Cast().ToList()); - _typeAsWritten = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } + internal CXXUnresolvedConstructExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr) + { + _args = new Lazy>(() => Children.Cast().ToList()); + _typeAsWritten = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + } - public IReadOnlyList Args => _args.Value; + public IReadOnlyList Args => _args.Value; - public bool IsListInitialization => Handle.IsListInitialization; + public bool IsListInitialization => Handle.IsListInitialization; - public uint NumArgs => unchecked((uint)Handle.NumArguments); + public uint NumArgs => unchecked((uint)Handle.NumArguments); - public Type TypeAsWritten => _typeAsWritten.Value; - } + public Type TypeAsWritten => _typeAsWritten.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CXXUuidofExpr.cs b/sources/ClangSharp/Cursors/Exprs/CXXUuidofExpr.cs index b1fbb969..27247d71 100644 --- a/sources/ClangSharp/Cursors/Exprs/CXXUuidofExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CXXUuidofExpr.cs @@ -5,27 +5,26 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXUuidofExpr : Expr { - public sealed class CXXUuidofExpr : Expr - { - private readonly Lazy _typeOperand; - private readonly Lazy _guidDecl; + private readonly Lazy _typeOperand; + private readonly Lazy _guidDecl; - internal CXXUuidofExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXUuidofExpr) - { - Debug.Assert(NumChildren is 0 or 1); + internal CXXUuidofExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CXXUuidofExpr) + { + Debug.Assert(NumChildren is 0 or 1); - _typeOperand = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - _guidDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + _typeOperand = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + _guidDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public Expr ExprOperand => (Expr)Children.SingleOrDefault(); + public Expr ExprOperand => (Expr)Children.SingleOrDefault(); - public MSGuidDecl GuidDecl => _guidDecl.Value; + public MSGuidDecl GuidDecl => _guidDecl.Value; - public bool IsTypeOperand => NumChildren is 0; + public bool IsTypeOperand => NumChildren is 0; - public Type TypeOperand => _typeOperand.Value; - } + public Type TypeOperand => _typeOperand.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CallExpr.cs b/sources/ClangSharp/Cursors/Exprs/CallExpr.cs index 421e7eb7..5d5d1227 100644 --- a/sources/ClangSharp/Cursors/Exprs/CallExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CallExpr.cs @@ -6,40 +6,39 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class CallExpr : Expr { - public class CallExpr : Expr + private readonly Lazy> _args; + private readonly Lazy _calleeDecl; + + internal CallExpr(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CallExpr) { - private readonly Lazy> _args; - private readonly Lazy _calleeDecl; + } - internal CallExpr(CXCursor handle) : this(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_CallExpr) + private protected CallExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCallExpr or < CX_StmtClass.CX_StmtClass_FirstCallExpr) { + throw new ArgumentOutOfRangeException(nameof(handle)); } - private protected CallExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) - { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCallExpr or < CX_StmtClass.CX_StmtClass_FirstCallExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + Debug.Assert(NumChildren >= 1); - Debug.Assert(NumChildren >= 1); - - _args = new Lazy>(() => Children.Skip(1).Take((int)NumArgs).Cast().ToList()); - _calleeDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + _args = new Lazy>(() => Children.Skip(1).Take((int)NumArgs).Cast().ToList()); + _calleeDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public IReadOnlyList Args => _args.Value; + public IReadOnlyList Args => _args.Value; - public Expr Callee => (Expr)Children[0]; + public Expr Callee => (Expr)Children[0]; - public Decl CalleeDecl => _calleeDecl.Value; + public Decl CalleeDecl => _calleeDecl.Value; - public FunctionDecl DirectCallee => CalleeDecl as FunctionDecl; + public FunctionDecl DirectCallee => CalleeDecl as FunctionDecl; - public bool IsCallToStdMove => (NumArgs == 1) && (DirectCallee is FunctionDecl fd) && fd.IsInStdNamespace && (fd.Name == "move"); + public bool IsCallToStdMove => (NumArgs == 1) && (DirectCallee is FunctionDecl fd) && fd.IsInStdNamespace && (fd.Name == "move"); - public uint NumArgs => (uint)Handle.NumArguments; - } + public uint NumArgs => (uint)Handle.NumArguments; } diff --git a/sources/ClangSharp/Cursors/Exprs/CastExpr.cs b/sources/ClangSharp/Cursors/Exprs/CastExpr.cs index 3311e226..382e476a 100644 --- a/sources/ClangSharp/Cursors/Exprs/CastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CastExpr.cs @@ -5,111 +5,110 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class CastExpr : Expr { - public class CastExpr : Expr - { - private readonly Lazy> _path; - private readonly Lazy _targetUnionField; + private readonly Lazy> _path; + private readonly Lazy _targetUnionField; - private protected CastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + private protected CastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCastExpr or < CX_StmtClass.CX_StmtClass_FirstCastExpr) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCastExpr or < CX_StmtClass.CX_StmtClass_FirstCastExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); + } - Debug.Assert(NumChildren is 1); + Debug.Assert(NumChildren is 1); - _path = new Lazy>(() => { - var pathSize = Handle.NumArguments; - var path = new List(pathSize); + _path = new Lazy>(() => { + var pathSize = Handle.NumArguments; + var path = new List(pathSize); - for (var i = 0; i < pathSize; i++) - { - var item = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); - path.Add(item); - } + for (var i = 0; i < pathSize; i++) + { + var item = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); + path.Add(item); + } - return path; - }); - _targetUnionField = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TargetUnionField)); - } + return path; + }); + _targetUnionField = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TargetUnionField)); + } - public CX_CastKind CastKind => Handle.CastKind; + public CX_CastKind CastKind => Handle.CastKind; - public string CastKindName => Handle.CastKindSpelling; + public string CastKindName => Handle.CastKindSpelling; - public NamedDecl ConversionFunction + public NamedDecl ConversionFunction + { + get { - get + Expr subExpr; + + for (var e = this; e is not null; e = subExpr as ImplicitCastExpr) { - Expr subExpr; + subExpr = SkipImplicitTemporary(e.SubExpr); - for (var e = this; e is not null; e = subExpr as ImplicitCastExpr) + if (e.CastKind == CX_CastKind.CX_CK_ConstructorConversion) { - subExpr = SkipImplicitTemporary(e.SubExpr); - - if (e.CastKind == CX_CastKind.CX_CK_ConstructorConversion) - { - return ((CXXConstructExpr)subExpr).Constructor; - } + return ((CXXConstructExpr)subExpr).Constructor; + } - if (e.CastKind == CX_CastKind.CX_CK_UserDefinedConversion) + if (e.CastKind == CX_CastKind.CX_CK_UserDefinedConversion) + { + if (subExpr is CXXMemberCallExpr mce) { - if (subExpr is CXXMemberCallExpr mce) - { - return mce.MethodDecl; - } + return mce.MethodDecl; } } - - return null; } + + return null; } + } - public bool PathEmpty => PathSize == 0; + public bool PathEmpty => PathSize == 0; - public IReadOnlyList Path => _path.Value; + public IReadOnlyList Path => _path.Value; - public uint PathSize => unchecked((uint)Handle.NumArguments); + public uint PathSize => unchecked((uint)Handle.NumArguments); - public Expr SubExpr => (Expr)Children[0]; + public Expr SubExpr => (Expr)Children[0]; - public Expr SubExprAsWritten + public Expr SubExprAsWritten + { + get { - get + Expr subExpr; + var e = this; + + do { - Expr subExpr; - var e = this; + subExpr = SkipImplicitTemporary(e.SubExpr); - do + // Conversions by constructor and conversion functions have a subexpression describing the call; strip it off. + if (e.CastKind == CX_CastKind.CX_CK_ConstructorConversion) + { + subExpr = SkipImplicitTemporary(((CXXConstructExpr)subExpr).Args[0]); + } + else if (e.CastKind == CX_CastKind.CX_CK_UserDefinedConversion) { - subExpr = SkipImplicitTemporary(e.SubExpr); + Debug.Assert(subExpr is CXXMemberCallExpr or BlockExpr, "Unexpected SubExpr for CK_UserDefinedConversion."); - // Conversions by constructor and conversion functions have a subexpression describing the call; strip it off. - if (e.CastKind == CX_CastKind.CX_CK_ConstructorConversion) - { - subExpr = SkipImplicitTemporary(((CXXConstructExpr)subExpr).Args[0]); - } - else if (e.CastKind == CX_CastKind.CX_CK_UserDefinedConversion) + if (subExpr is CXXMemberCallExpr mce) { - Debug.Assert(subExpr is CXXMemberCallExpr or BlockExpr, "Unexpected SubExpr for CK_UserDefinedConversion."); - - if (subExpr is CXXMemberCallExpr mce) - { - subExpr = mce.ImplicitObjectArgument; - } + subExpr = mce.ImplicitObjectArgument; } + } - // If the subexpression we're left with is an implicit cast, look - // through that, too. - } while ((e = subExpr as ImplicitCastExpr) is not null); + // If the subexpression we're left with is an implicit cast, look + // through that, too. + } while ((e = subExpr as ImplicitCastExpr) is not null); - return subExpr; - } + return subExpr; } - - public FieldDecl TargetUnionField => _targetUnionField.Value; } + + public FieldDecl TargetUnionField => _targetUnionField.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CharacterLiteral.cs b/sources/ClangSharp/Cursors/Exprs/CharacterLiteral.cs index 856d337f..13206484 100644 --- a/sources/ClangSharp/Cursors/Exprs/CharacterLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/CharacterLiteral.cs @@ -4,32 +4,31 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CharacterLiteral : Expr { - public sealed class CharacterLiteral : Expr - { - private readonly Lazy _valueString; + private readonly Lazy _valueString; - internal CharacterLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CharacterLiteral, CX_StmtClass.CX_StmtClass_CharacterLiteral) - { - Debug.Assert(NumChildren is 0); + internal CharacterLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CharacterLiteral, CX_StmtClass.CX_StmtClass_CharacterLiteral) + { + Debug.Assert(NumChildren is 0); - _valueString = new Lazy(() => { - var tokens = Handle.TranslationUnit.Tokenize(Handle.SourceRange); + _valueString = new Lazy(() => { + var tokens = Handle.TranslationUnit.Tokenize(Handle.SourceRange); - Debug.Assert(tokens.Length == 1); - Debug.Assert(tokens[0].Kind == CXTokenKind.CXToken_Literal); + Debug.Assert(tokens.Length == 1); + Debug.Assert(tokens[0].Kind == CXTokenKind.CXToken_Literal); - var spelling = tokens[0].GetSpelling(Handle.TranslationUnit).ToString(); - spelling = spelling.Trim('\\', '\r', '\n'); - return spelling; - }); - } + var spelling = tokens[0].GetSpelling(Handle.TranslationUnit).ToString(); + spelling = spelling.Trim('\\', '\r', '\n'); + return spelling; + }); + } - public CX_CharacterKind Kind => Handle.CharacterLiteralKind; + public CX_CharacterKind Kind => Handle.CharacterLiteralKind; - public uint Value => Handle.CharacterLiteralValue; + public uint Value => Handle.CharacterLiteralValue; - public string ValueString => _valueString.Value; - } + public string ValueString => _valueString.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/ChooseExpr.cs b/sources/ClangSharp/Cursors/Exprs/ChooseExpr.cs index b815b773..d69f1849 100644 --- a/sources/ClangSharp/Cursors/Exprs/ChooseExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ChooseExpr.cs @@ -3,25 +3,24 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ChooseExpr : Expr { - public sealed class ChooseExpr : Expr + internal ChooseExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ChooseExpr) { - internal ChooseExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ChooseExpr) - { - Debug.Assert(NumChildren is 3); - } + Debug.Assert(NumChildren is 3); + } - public Expr ChosenSubExpr => IsConditionDependent ? (IsConditionTrue ? LHS : RHS) : null; + public Expr ChosenSubExpr => IsConditionDependent ? (IsConditionTrue ? LHS : RHS) : null; - public Expr Cond => (Expr)Children[0]; + public Expr Cond => (Expr)Children[0]; - public bool IsConditionTrue => Handle.IsConditionTrue; + public bool IsConditionTrue => Handle.IsConditionTrue; - public bool IsConditionDependent => Cond.IsTypeDependent || Cond.IsValueDependent; + public bool IsConditionDependent => Cond.IsTypeDependent || Cond.IsValueDependent; - public Expr LHS => (Expr)Children[1]; + public Expr LHS => (Expr)Children[1]; - public Expr RHS => (Expr)Children[2]; - } + public Expr RHS => (Expr)Children[2]; } diff --git a/sources/ClangSharp/Cursors/Exprs/CoawaitExpr.cs b/sources/ClangSharp/Cursors/Exprs/CoawaitExpr.cs index 0fb48c76..27f5be68 100644 --- a/sources/ClangSharp/Cursors/Exprs/CoawaitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CoawaitExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CoawaitExpr : CoroutineSuspendExpr { - public sealed class CoawaitExpr : CoroutineSuspendExpr + internal CoawaitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CoawaitExpr) { - internal CoawaitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CoawaitExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CompoundAssignOperator.cs b/sources/ClangSharp/Cursors/Exprs/CompoundAssignOperator.cs index ed02f68b..cbff9dd8 100644 --- a/sources/ClangSharp/Cursors/Exprs/CompoundAssignOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/CompoundAssignOperator.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CompoundAssignOperator : BinaryOperator { - public sealed class CompoundAssignOperator : BinaryOperator - { - private readonly Lazy _computationLHSType; - private readonly Lazy _computationResultType; + private readonly Lazy _computationLHSType; + private readonly Lazy _computationResultType; - internal CompoundAssignOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundAssignOperator, CX_StmtClass.CX_StmtClass_CompoundAssignOperator) - { - _computationLHSType = new Lazy(() => TranslationUnit.GetOrCreate(handle.ComputationLhsType)); - _computationResultType = new Lazy(() => TranslationUnit.GetOrCreate(handle.ComputationResultType)); - } + internal CompoundAssignOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundAssignOperator, CX_StmtClass.CX_StmtClass_CompoundAssignOperator) + { + _computationLHSType = new Lazy(() => TranslationUnit.GetOrCreate(handle.ComputationLhsType)); + _computationResultType = new Lazy(() => TranslationUnit.GetOrCreate(handle.ComputationResultType)); + } - public Type ComputationLHSType => _computationLHSType.Value; + public Type ComputationLHSType => _computationLHSType.Value; - public Type ComputationResultType => _computationResultType.Value; - } + public Type ComputationResultType => _computationResultType.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs b/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs index 63c04db8..54a69292 100644 --- a/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs @@ -4,22 +4,21 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CompoundLiteralExpr : Expr { - public sealed class CompoundLiteralExpr : Expr - { - private readonly Lazy _typeSourceinfoType; + private readonly Lazy _typeSourceinfoType; - internal CompoundLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundLiteralExpr, CX_StmtClass.CX_StmtClass_CompoundLiteralExpr) - { - Debug.Assert(NumChildren is 1); - _typeSourceinfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } + internal CompoundLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundLiteralExpr, CX_StmtClass.CX_StmtClass_CompoundLiteralExpr) + { + Debug.Assert(NumChildren is 1); + _typeSourceinfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + } - public bool IsFileScope => Handle.IsFileScope; + public bool IsFileScope => Handle.IsFileScope; - public Expr Initializer => (Expr)Children[0]; + public Expr Initializer => (Expr)Children[0]; - public Type TypeSourceInfoType => _typeSourceinfoType.Value; - } + public Type TypeSourceInfoType => _typeSourceinfoType.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/ConceptSpecializationExpr.cs b/sources/ClangSharp/Cursors/Exprs/ConceptSpecializationExpr.cs index c30d8b50..8ddcd8a6 100644 --- a/sources/ClangSharp/Cursors/Exprs/ConceptSpecializationExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ConceptSpecializationExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ConceptSpecializationExpr : Expr { - public sealed class ConceptSpecializationExpr : Expr + internal ConceptSpecializationExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr) { - internal ConceptSpecializationExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ConditionalOperator.cs b/sources/ClangSharp/Cursors/Exprs/ConditionalOperator.cs index 5352fe6e..56747302 100644 --- a/sources/ClangSharp/Cursors/Exprs/ConditionalOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/ConditionalOperator.cs @@ -3,23 +3,22 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ConditionalOperator : AbstractConditionalOperator { - public sealed class ConditionalOperator : AbstractConditionalOperator + internal ConditionalOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConditionalOperator, CX_StmtClass.CX_StmtClass_ConditionalOperator) { - internal ConditionalOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ConditionalOperator, CX_StmtClass.CX_StmtClass_ConditionalOperator) - { - Debug.Assert(NumChildren is 3); - } + Debug.Assert(NumChildren is 3); + } - public new Expr Cond => (Expr)Children[0]; + public new Expr Cond => (Expr)Children[0]; - public new Expr FalseExpr => RHS; + public new Expr FalseExpr => RHS; - public Expr LHS => (Expr)Children[1]; + public Expr LHS => (Expr)Children[1]; - public Expr RHS => (Expr)Children[2]; + public Expr RHS => (Expr)Children[2]; - public new Expr TrueExpr => LHS; - } + public new Expr TrueExpr => LHS; } diff --git a/sources/ClangSharp/Cursors/Exprs/ConstantExpr.cs b/sources/ClangSharp/Cursors/Exprs/ConstantExpr.cs index a7595058..a5e2143f 100644 --- a/sources/ClangSharp/Cursors/Exprs/ConstantExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ConstantExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ConstantExpr : FullExpr { - public sealed class ConstantExpr : FullExpr + internal ConstantExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ConstantExpr) { - internal ConstantExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ConstantExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ConvertVectorExpr.cs b/sources/ClangSharp/Cursors/Exprs/ConvertVectorExpr.cs index 56da281d..0c7288fa 100644 --- a/sources/ClangSharp/Cursors/Exprs/ConvertVectorExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ConvertVectorExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ConvertVectorExpr : Expr { - public sealed class ConvertVectorExpr : Expr + internal ConvertVectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ConvertVectorExpr) { - internal ConvertVectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ConvertVectorExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CoroutineSuspendExpr.cs b/sources/ClangSharp/Cursors/Exprs/CoroutineSuspendExpr.cs index 4bbb29e7..7571db0c 100644 --- a/sources/ClangSharp/Cursors/Exprs/CoroutineSuspendExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CoroutineSuspendExpr.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class CoroutineSuspendExpr : Expr { - public class CoroutineSuspendExpr : Expr + private protected CoroutineSuspendExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected CoroutineSuspendExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCoroutineSuspendExpr or < CX_StmtClass.CX_StmtClass_FirstCoroutineSuspendExpr) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastCoroutineSuspendExpr or < CX_StmtClass.CX_StmtClass_FirstCoroutineSuspendExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Exprs/CoyieldExpr.cs b/sources/ClangSharp/Cursors/Exprs/CoyieldExpr.cs index 7e344f91..68a6ca2e 100644 --- a/sources/ClangSharp/Cursors/Exprs/CoyieldExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CoyieldExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CoyieldExpr : CoroutineSuspendExpr { - public sealed class CoyieldExpr : CoroutineSuspendExpr + internal CoyieldExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CoyieldExpr) { - internal CoyieldExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_CoyieldExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/DeclRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/DeclRefExpr.cs index 20214619..8ce9a14b 100644 --- a/sources/ClangSharp/Cursors/Exprs/DeclRefExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/DeclRefExpr.cs @@ -5,54 +5,53 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DeclRefExpr : Expr { - public sealed class DeclRefExpr : Expr - { - private readonly Lazy _decl; - private readonly Lazy _foundDecl; - private readonly Lazy> _templateArgs; + private readonly Lazy _decl; + private readonly Lazy _foundDecl; + private readonly Lazy> _templateArgs; - internal DeclRefExpr(CXCursor handle) : base(handle, handle.Kind, CX_StmtClass.CX_StmtClass_DeclRefExpr) + internal DeclRefExpr(CXCursor handle) : base(handle, handle.Kind, CX_StmtClass.CX_StmtClass_DeclRefExpr) + { + if (handle.Kind is not CXCursorKind.CXCursor_DeclRefExpr and not CXCursorKind.CXCursor_ObjCSelfExpr) { - if (handle.Kind is not CXCursorKind.CXCursor_DeclRefExpr and not CXCursorKind.CXCursor_ObjCSelfExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); + } - Debug.Assert(NumChildren is 0); + Debug.Assert(NumChildren is 0); - _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _foundDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.FoundDecl)); + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _foundDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.FoundDecl)); - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); - templateArgs.Add(templateArg); - } + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); + templateArgs.Add(templateArg); + } - return templateArgs; - }); - } + return templateArgs; + }); + } - public ValueDecl Decl => _decl.Value; + public ValueDecl Decl => _decl.Value; - public NamedDecl FoundDecl => _foundDecl.Value; + public NamedDecl FoundDecl => _foundDecl.Value; - public bool HadMultipleCandidates => Handle.HadMultipleCandidates; + public bool HadMultipleCandidates => Handle.HadMultipleCandidates; - public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; + public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; - public bool HasTemplateKeyword => Handle.HasTemplateKeyword; + public bool HasTemplateKeyword => Handle.HasTemplateKeyword; - public string Name => Handle.Name.CString; + public string Name => Handle.Name.CString; - public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); + public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); - public IReadOnlyList TemplateArgs => _templateArgs.Value; - } + public IReadOnlyList TemplateArgs => _templateArgs.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/DependentCoawaitExpr.cs b/sources/ClangSharp/Cursors/Exprs/DependentCoawaitExpr.cs index 7fc2eb3e..1b384ab6 100644 --- a/sources/ClangSharp/Cursors/Exprs/DependentCoawaitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/DependentCoawaitExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DependentCoawaitExpr : Expr { - public sealed class DependentCoawaitExpr : Expr + internal DependentCoawaitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_DependentCoawaitExpr) { - internal DependentCoawaitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_DependentCoawaitExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/DependentScopeDeclRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/DependentScopeDeclRefExpr.cs index 82098b97..950d315e 100644 --- a/sources/ClangSharp/Cursors/Exprs/DependentScopeDeclRefExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/DependentScopeDeclRefExpr.cs @@ -5,36 +5,35 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DependentScopeDeclRefExpr : Expr { - public sealed class DependentScopeDeclRefExpr : Expr - { - private readonly Lazy> _templateArgs; + private readonly Lazy> _templateArgs; - internal DependentScopeDeclRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr) - { - Debug.Assert(NumChildren is 0); + internal DependentScopeDeclRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr) + { + Debug.Assert(NumChildren is 0); - _templateArgs = new Lazy>(() => { - var numTemplateArgs = Handle.NumTemplateArguments; - var templateArgs = new List(numTemplateArgs); + _templateArgs = new Lazy>(() => { + var numTemplateArgs = Handle.NumTemplateArguments; + var templateArgs = new List(numTemplateArgs); - for (var i = 0; i < numTemplateArgs; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); - templateArgs.Add(templateArg); - } + for (var i = 0; i < numTemplateArgs; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); + templateArgs.Add(templateArg); + } - return templateArgs; - }); - } + return templateArgs; + }); + } - public string DeclName => Handle.Name.CString; + public string DeclName => Handle.Name.CString; - public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; + public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; - public bool HasTemplateKeyword => Handle.HasTemplateKeyword; + public bool HasTemplateKeyword => Handle.HasTemplateKeyword; - public IReadOnlyList TemplateArgs => _templateArgs.Value; - } + public IReadOnlyList TemplateArgs => _templateArgs.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/DesignatedInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/DesignatedInitExpr.cs index 4a00d382..cbed7f33 100644 --- a/sources/ClangSharp/Cursors/Exprs/DesignatedInitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/DesignatedInitExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DesignatedInitExpr : Expr { - public sealed class DesignatedInitExpr : Expr + internal DesignatedInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_DesignatedInitExpr) { - internal DesignatedInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_DesignatedInitExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/DesignatedInitUpdateExpr.cs b/sources/ClangSharp/Cursors/Exprs/DesignatedInitUpdateExpr.cs index 3fbe7076..3570bf31 100644 --- a/sources/ClangSharp/Cursors/Exprs/DesignatedInitUpdateExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/DesignatedInitUpdateExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DesignatedInitUpdateExpr : Expr { - public sealed class DesignatedInitUpdateExpr : Expr + internal DesignatedInitUpdateExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr) { - internal DesignatedInitUpdateExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ExplicitCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/ExplicitCastExpr.cs index f6dcc52b..4bcdc8ae 100644 --- a/sources/ClangSharp/Cursors/Exprs/ExplicitCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ExplicitCastExpr.cs @@ -3,22 +3,21 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class ExplicitCastExpr : CastExpr { - public class ExplicitCastExpr : CastExpr - { - private readonly Lazy _typeAsWritten; + private readonly Lazy _typeAsWritten; - private protected ExplicitCastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + private protected ExplicitCastExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastExplicitCastExpr or < CX_StmtClass.CX_StmtClass_FirstExplicitCastExpr) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastExplicitCastExpr or < CX_StmtClass.CX_StmtClass_FirstExplicitCastExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _typeAsWritten = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public Type TypeAsWritten => _typeAsWritten.Value; + _typeAsWritten = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); } + + public Type TypeAsWritten => _typeAsWritten.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/Expr.cs b/sources/ClangSharp/Cursors/Exprs/Expr.cs index 7ff1b0cb..b23e42bd 100644 --- a/sources/ClangSharp/Cursors/Exprs/Expr.cs +++ b/sources/ClangSharp/Cursors/Exprs/Expr.cs @@ -3,154 +3,153 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class Expr : ValueStmt { - public class Expr : ValueStmt - { - private static readonly Func s_ignoreImplicitCastsSingleStep = (e) => e is ImplicitCastExpr ice ? ice.SubExpr : e is FullExpr fe ? fe.SubExpr : e; + private static readonly Func s_ignoreImplicitCastsSingleStep = (e) => e is ImplicitCastExpr ice ? ice.SubExpr : e is FullExpr fe ? fe.SubExpr : e; - private static readonly Func s_ignoreImplicitSingleStep = (e) => - { - var subE = s_ignoreImplicitCastsSingleStep(e); + private static readonly Func s_ignoreImplicitSingleStep = (e) => + { + var subE = s_ignoreImplicitCastsSingleStep(e); - return subE != e ? subE : e is MaterializeTemporaryExpr mte ? mte.SubExpr : e is CXXBindTemporaryExpr bte ? bte.SubExpr : e; - }; + return subE != e ? subE : e is MaterializeTemporaryExpr mte ? mte.SubExpr : e is CXXBindTemporaryExpr bte ? bte.SubExpr : e; + }; - private static readonly Func s_ignoreParensSingleStep = (e) => + private static readonly Func s_ignoreParensSingleStep = (e) => + { + if (e is ParenExpr pe) { - if (e is ParenExpr pe) - { - return pe.SubExpr; - } + return pe.SubExpr; + } - if (e is UnaryOperator uo) + if (e is UnaryOperator uo) + { + if (uo.Opcode == CX_UnaryOperatorKind.CX_UO_Extension) { - if (uo.Opcode == CX_UnaryOperatorKind.CX_UO_Extension) - { - return uo.SubExpr; - } + return uo.SubExpr; } - else if (e is GenericSelectionExpr gse) + } + else if (e is GenericSelectionExpr gse) + { + if (!gse.IsResultDependent) { - if (!gse.IsResultDependent) - { - return gse.ResultExpr; - } + return gse.ResultExpr; } - else if (e is ChooseExpr ce) + } + else if (e is ChooseExpr ce) + { + if (!ce.IsConditionDependent) { - if (!ce.IsConditionDependent) - { - return ce.ChosenSubExpr; - } + return ce.ChosenSubExpr; } + } - return e; - }; + return e; + }; - private readonly Lazy _type; + private readonly Lazy _type; - private protected Expr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + private protected Expr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastExpr or < CX_StmtClass.CX_StmtClass_FirstExpr) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastExpr or < CX_StmtClass.CX_StmtClass_FirstExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public bool ContainsErrors => (Dependence & CX_ExprDependence.CX_ED_Error) != 0; + _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); + } + + public bool ContainsErrors => (Dependence & CX_ExprDependence.CX_ED_Error) != 0; - public bool ContainsUnexpandedParameterPack => (Dependence & CX_ExprDependence.CX_ED_UnexpandedPack) != 0; + public bool ContainsUnexpandedParameterPack => (Dependence & CX_ExprDependence.CX_ED_UnexpandedPack) != 0; - public CX_ExprDependence Dependence => Handle.ExprDependence; + public CX_ExprDependence Dependence => Handle.ExprDependence; - public Expr IgnoreImplicit => IgnoreExprNodes(this, s_ignoreImplicitSingleStep); + public Expr IgnoreImplicit => IgnoreExprNodes(this, s_ignoreImplicitSingleStep); - public Expr IgnoreParens => IgnoreExprNodes(this, s_ignoreParensSingleStep); + public Expr IgnoreParens => IgnoreExprNodes(this, s_ignoreParensSingleStep); - public bool IsImplicitCXXThis + public bool IsImplicitCXXThis + { + get { - get + var e = this; + + while (true) { - var e = this; + if (e is ParenExpr paren) + { + e = paren.SubExpr; + continue; + } - while (true) + if (e is ImplicitCastExpr ice) { - if (e is ParenExpr paren) + if (ice.CastKind is CX_CastKind.CX_CK_NoOp or CX_CastKind.CX_CK_LValueToRValue or CX_CastKind.CX_CK_DerivedToBase or CX_CastKind.CX_CK_UncheckedDerivedToBase) { - e = paren.SubExpr; + e = ice.SubExpr; continue; } + } - if (e is ImplicitCastExpr ice) - { - if (ice.CastKind is CX_CastKind.CX_CK_NoOp or CX_CastKind.CX_CK_LValueToRValue or CX_CastKind.CX_CK_DerivedToBase or CX_CastKind.CX_CK_UncheckedDerivedToBase) - { - e = ice.SubExpr; - continue; - } - } - - if (e is UnaryOperator unOp) - { - if (unOp.Opcode == CX_UnaryOperatorKind.CX_UO_Extension) - { - e = unOp.SubExpr; - continue; - } - } - - if (e is MaterializeTemporaryExpr m) + if (e is UnaryOperator unOp) + { + if (unOp.Opcode == CX_UnaryOperatorKind.CX_UO_Extension) { - e = m.SubExpr; + e = unOp.SubExpr; continue; } + } - break; + if (e is MaterializeTemporaryExpr m) + { + e = m.SubExpr; + continue; } - return e is CXXThisExpr self && self.IsImplicit; + break; } + + return e is CXXThisExpr self && self.IsImplicit; } + } + + public bool IsInstantiationDependent => (Dependence & CX_ExprDependence.CX_ED_Instantiation) != 0; - public bool IsInstantiationDependent => (Dependence & CX_ExprDependence.CX_ED_Instantiation) != 0; + public bool IsTypeDependent => (Dependence & CX_ExprDependence.CX_ED_Type) != 0; - public bool IsTypeDependent => (Dependence & CX_ExprDependence.CX_ED_Type) != 0; + public bool IsValueDependent => (Dependence & CX_ExprDependence.CX_ED_Value) != 0; - public bool IsValueDependent => (Dependence & CX_ExprDependence.CX_ED_Value) != 0; + public Type Type => _type.Value; - public Type Type => _type.Value; + private static Expr IgnoreExprNodes(Expr e, Func fn) + { + Expr lastE = null; - private static Expr IgnoreExprNodes(Expr e, Func fn) + while (e != lastE) { - Expr lastE = null; + lastE = e; + e = fn(e); + } - while (e != lastE) - { - lastE = e; - e = fn(e); - } + return e; + } - return e; + protected static Expr SkipImplicitTemporary(Expr e) + { + // Skip through reference binding to temporary. + if (e is MaterializeTemporaryExpr materialize) + { + e = materialize.SubExpr; } - protected static Expr SkipImplicitTemporary(Expr e) + // Skip any temporary bindings; they're implicit. + if (e is CXXBindTemporaryExpr binder) { - // Skip through reference binding to temporary. - if (e is MaterializeTemporaryExpr materialize) - { - e = materialize.SubExpr; - } - - // Skip any temporary bindings; they're implicit. - if (e is CXXBindTemporaryExpr binder) - { - e = binder.SubExpr; - } - - return e; + e = binder.SubExpr; } + + return e; } } diff --git a/sources/ClangSharp/Cursors/Exprs/ExprWithCleanups.cs b/sources/ClangSharp/Cursors/Exprs/ExprWithCleanups.cs index a908cdb5..4f28e61b 100644 --- a/sources/ClangSharp/Cursors/Exprs/ExprWithCleanups.cs +++ b/sources/ClangSharp/Cursors/Exprs/ExprWithCleanups.cs @@ -4,30 +4,29 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ExprWithCleanups : FullExpr { - public sealed class ExprWithCleanups : FullExpr - { - private readonly Lazy> _objects; + private readonly Lazy> _objects; - internal ExprWithCleanups(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ExprWithCleanups) - { - _objects = new Lazy>(() => { - var numObjects = Handle.NumArguments; - var objects = new List(numObjects); + internal ExprWithCleanups(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ExprWithCleanups) + { + _objects = new Lazy>(() => { + var numObjects = Handle.NumArguments; + var objects = new List(numObjects); - for (var i = 0; i < numObjects; i++) - { - var obj = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); - objects.Add(obj); - } + for (var i = 0; i < numObjects; i++) + { + var obj = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); + objects.Add(obj); + } - return objects; - }); - } + return objects; + }); + } - public uint NumObjects => unchecked((uint)Handle.NumArguments); + public uint NumObjects => unchecked((uint)Handle.NumArguments); - public IReadOnlyList Objects => _objects.Value; - } + public IReadOnlyList Objects => _objects.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/ExpressionTraitExpr.cs b/sources/ClangSharp/Cursors/Exprs/ExpressionTraitExpr.cs index c2533f90..2cb94ae8 100644 --- a/sources/ClangSharp/Cursors/Exprs/ExpressionTraitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ExpressionTraitExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ExpressionTraitExpr : Expr { - public sealed class ExpressionTraitExpr : Expr + internal ExpressionTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ExpressionTraitExpr) { - internal ExpressionTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ExpressionTraitExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ExtVectorElementExpr.cs b/sources/ClangSharp/Cursors/Exprs/ExtVectorElementExpr.cs index 54238862..aff059de 100644 --- a/sources/ClangSharp/Cursors/Exprs/ExtVectorElementExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ExtVectorElementExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ExtVectorElementExpr : Expr { - public sealed class ExtVectorElementExpr : Expr + internal ExtVectorElementExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ExtVectorElementExpr) { - internal ExtVectorElementExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ExtVectorElementExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/FixedPointLiteral.cs b/sources/ClangSharp/Cursors/Exprs/FixedPointLiteral.cs index 9fc91114..2734c15c 100644 --- a/sources/ClangSharp/Cursors/Exprs/FixedPointLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/FixedPointLiteral.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class FixedPointLiteral : Expr { - public sealed class FixedPointLiteral : Expr + internal FixedPointLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FixedPointLiteral, CX_StmtClass.CX_StmtClass_FixedPointLiteral) { - internal FixedPointLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FixedPointLiteral, CX_StmtClass.CX_StmtClass_FixedPointLiteral) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/FloatingLiteral.cs b/sources/ClangSharp/Cursors/Exprs/FloatingLiteral.cs index d710a6c2..a7075309 100644 --- a/sources/ClangSharp/Cursors/Exprs/FloatingLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/FloatingLiteral.cs @@ -4,30 +4,29 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class FloatingLiteral : Expr { - public sealed class FloatingLiteral : Expr - { - private readonly Lazy _valueString; + private readonly Lazy _valueString; - internal FloatingLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FloatingLiteral, CX_StmtClass.CX_StmtClass_FloatingLiteral) - { - _valueString = new Lazy(() => { - var tokens = Handle.TranslationUnit.Tokenize(Handle.SourceRange); + internal FloatingLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_FloatingLiteral, CX_StmtClass.CX_StmtClass_FloatingLiteral) + { + _valueString = new Lazy(() => { + var tokens = Handle.TranslationUnit.Tokenize(Handle.SourceRange); - Debug.Assert(tokens.Length == 1); - Debug.Assert(tokens[0].Kind == CXTokenKind.CXToken_Literal); + Debug.Assert(tokens.Length == 1); + Debug.Assert(tokens[0].Kind == CXTokenKind.CXToken_Literal); - var spelling = tokens[0].GetSpelling(Handle.TranslationUnit).ToString(); - spelling = spelling.Trim('\\', '\r', '\n'); - return spelling; - }); - } + var spelling = tokens[0].GetSpelling(Handle.TranslationUnit).ToString(); + spelling = spelling.Trim('\\', '\r', '\n'); + return spelling; + }); + } - public CX_FloatingSemantics RawSemantics => Handle.FloatingLiteralSemantics; + public CX_FloatingSemantics RawSemantics => Handle.FloatingLiteralSemantics; - public double ValueAsApproximateDouble => Handle.FloatingLiteralValueAsApproximateDouble; + public double ValueAsApproximateDouble => Handle.FloatingLiteralValueAsApproximateDouble; - public string ValueString => _valueString.Value; - } + public string ValueString => _valueString.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/FullExpr.cs b/sources/ClangSharp/Cursors/Exprs/FullExpr.cs index cb9c6ff8..ff8d917a 100644 --- a/sources/ClangSharp/Cursors/Exprs/FullExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/FullExpr.cs @@ -4,20 +4,19 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class FullExpr : Expr { - public class FullExpr : Expr + private protected FullExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected FullExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastFullExpr or < CX_StmtClass.CX_StmtClass_FirstFullExpr) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastFullExpr or < CX_StmtClass.CX_StmtClass_FirstFullExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - Debug.Assert(NumChildren is 1); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public Expr SubExpr => (Expr)Children[0]; + Debug.Assert(NumChildren is 1); } + + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/FunctionParmPackExpr.cs b/sources/ClangSharp/Cursors/Exprs/FunctionParmPackExpr.cs index 25882d3f..a8bcebe3 100644 --- a/sources/ClangSharp/Cursors/Exprs/FunctionParmPackExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/FunctionParmPackExpr.cs @@ -5,36 +5,35 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class FunctionParmPackExpr : Expr { - public sealed class FunctionParmPackExpr : Expr - { - private readonly Lazy> _expansions; - private readonly Lazy _parameterPack; + private readonly Lazy> _expansions; + private readonly Lazy _parameterPack; - internal FunctionParmPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_FunctionParmPackExpr) - { - Debug.Assert(NumChildren is 0); + internal FunctionParmPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_FunctionParmPackExpr) + { + Debug.Assert(NumChildren is 0); - _expansions = new Lazy>(() => { - var numExpansions = Handle.NumDecls; - var expansions = new List(numExpansions); + _expansions = new Lazy>(() => { + var numExpansions = Handle.NumDecls; + var expansions = new List(numExpansions); - for (var i = 0; i < numExpansions; i++) - { - var expansion = TranslationUnit.GetOrCreate(Handle.GetDecl(unchecked((uint)i))); - expansions.Add(expansion); - } + for (var i = 0; i < numExpansions; i++) + { + var expansion = TranslationUnit.GetOrCreate(Handle.GetDecl(unchecked((uint)i))); + expansions.Add(expansion); + } - return expansions; - }); - _parameterPack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + return expansions; + }); + _parameterPack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public IReadOnlyList Expansions => _expansions.Value; + public IReadOnlyList Expansions => _expansions.Value; - public uint NumExpansions => unchecked((uint)Handle.NumDecls); + public uint NumExpansions => unchecked((uint)Handle.NumDecls); - public VarDecl ParameterPack => _parameterPack.Value; - } + public VarDecl ParameterPack => _parameterPack.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/GNUNullExpr.cs b/sources/ClangSharp/Cursors/Exprs/GNUNullExpr.cs index 0c05aa7c..2c27a118 100644 --- a/sources/ClangSharp/Cursors/Exprs/GNUNullExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/GNUNullExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class GNUNullExpr : Expr { - public sealed class GNUNullExpr : Expr + internal GNUNullExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GNUNullExpr, CX_StmtClass.CX_StmtClass_GNUNullExpr) { - internal GNUNullExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GNUNullExpr, CX_StmtClass.CX_StmtClass_GNUNullExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/GenericSelectionExpr.cs b/sources/ClangSharp/Cursors/Exprs/GenericSelectionExpr.cs index 3e8a2353..33a32cf5 100644 --- a/sources/ClangSharp/Cursors/Exprs/GenericSelectionExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/GenericSelectionExpr.cs @@ -5,27 +5,26 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class GenericSelectionExpr : Expr { - public sealed class GenericSelectionExpr : Expr - { - private readonly Lazy> _assocExprs; + private readonly Lazy> _assocExprs; - internal GenericSelectionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GenericSelectionExpr, CX_StmtClass.CX_StmtClass_GenericSelectionExpr) - { - _assocExprs = new Lazy>(() => Children.Skip(1).Take((int)NumAssocs).Cast().ToList()); - } + internal GenericSelectionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GenericSelectionExpr, CX_StmtClass.CX_StmtClass_GenericSelectionExpr) + { + _assocExprs = new Lazy>(() => Children.Skip(1).Take((int)NumAssocs).Cast().ToList()); + } - public IReadOnlyList AssocExprs => _assocExprs.Value; + public IReadOnlyList AssocExprs => _assocExprs.Value; - public Expr ControllingExpr => (Expr)Children[0]; + public Expr ControllingExpr => (Expr)Children[0]; - public bool IsResultDependent => Handle.IsResultDependent; + public bool IsResultDependent => Handle.IsResultDependent; - public uint NumAssocs => unchecked((uint)Handle.NumAssocs); + public uint NumAssocs => unchecked((uint)Handle.NumAssocs); - public Expr ResultExpr => IsResultDependent ? null : (Expr)Children[(int)ResultIndex]; + public Expr ResultExpr => IsResultDependent ? null : (Expr)Children[(int)ResultIndex]; - public uint ResultIndex => unchecked((uint)Handle.ResultIndex); - } + public uint ResultIndex => unchecked((uint)Handle.ResultIndex); } diff --git a/sources/ClangSharp/Cursors/Exprs/ImaginaryLiteral.cs b/sources/ClangSharp/Cursors/Exprs/ImaginaryLiteral.cs index 5f28cd24..6584c4e1 100644 --- a/sources/ClangSharp/Cursors/Exprs/ImaginaryLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/ImaginaryLiteral.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ImaginaryLiteral : Expr { - public sealed class ImaginaryLiteral : Expr + internal ImaginaryLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ImaginaryLiteral, CX_StmtClass.CX_StmtClass_ImaginaryLiteral) { - internal ImaginaryLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ImaginaryLiteral, CX_StmtClass.CX_StmtClass_ImaginaryLiteral) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ImplicitCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/ImplicitCastExpr.cs index f0416def..caa87249 100644 --- a/sources/ClangSharp/Cursors/Exprs/ImplicitCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ImplicitCastExpr.cs @@ -2,14 +2,13 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ImplicitCastExpr : CastExpr { - public sealed class ImplicitCastExpr : CastExpr + internal ImplicitCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ImplicitCastExpr) { - internal ImplicitCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ImplicitCastExpr) - { - } - - public bool IsPartOfExplicitCast => !Handle.IsImplicit; } + + public bool IsPartOfExplicitCast => !Handle.IsImplicit; } diff --git a/sources/ClangSharp/Cursors/Exprs/ImplicitValueInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/ImplicitValueInitExpr.cs index 4f4a2bf9..a772737d 100644 --- a/sources/ClangSharp/Cursors/Exprs/ImplicitValueInitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ImplicitValueInitExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ImplicitValueInitExpr : Expr { - public sealed class ImplicitValueInitExpr : Expr + internal ImplicitValueInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr) { - internal ImplicitValueInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/InitListExpr.cs b/sources/ClangSharp/Cursors/Exprs/InitListExpr.cs index 81424b63..29eca951 100644 --- a/sources/ClangSharp/Cursors/Exprs/InitListExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/InitListExpr.cs @@ -5,33 +5,32 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class InitListExpr : Expr { - public sealed class InitListExpr : Expr - { - private readonly Lazy _arrayFiller; - private readonly Lazy _initializedFieldInUnion; - private readonly Lazy> _inits; + private readonly Lazy _arrayFiller; + private readonly Lazy _initializedFieldInUnion; + private readonly Lazy> _inits; - internal InitListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_InitListExpr, CX_StmtClass.CX_StmtClass_InitListExpr) - { - _arrayFiller = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SubExpr)); - _initializedFieldInUnion = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _inits = new Lazy>(() => Children.Cast().ToList()); - } + internal InitListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_InitListExpr, CX_StmtClass.CX_StmtClass_InitListExpr) + { + _arrayFiller = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SubExpr)); + _initializedFieldInUnion = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _inits = new Lazy>(() => Children.Cast().ToList()); + } - public Expr ArrayFiller => _arrayFiller.Value; + public Expr ArrayFiller => _arrayFiller.Value; - public bool HasArrayFiller => ArrayFiller is not null; + public bool HasArrayFiller => ArrayFiller is not null; - public FieldDecl InitializedFieldInUnion => _initializedFieldInUnion.Value; + public FieldDecl InitializedFieldInUnion => _initializedFieldInUnion.Value; - public IReadOnlyList Inits => _inits.Value; + public IReadOnlyList Inits => _inits.Value; - public bool IsExplicit => !Handle.IsImplicit; + public bool IsExplicit => !Handle.IsImplicit; - public bool IsTransparent => Handle.IsTransparent; + public bool IsTransparent => Handle.IsTransparent; - public uint NumInits => NumChildren; - } + public uint NumInits => NumChildren; } diff --git a/sources/ClangSharp/Cursors/Exprs/IntegerLiteral.cs b/sources/ClangSharp/Cursors/Exprs/IntegerLiteral.cs index b8d8530a..b7c85a72 100644 --- a/sources/ClangSharp/Cursors/Exprs/IntegerLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/IntegerLiteral.cs @@ -4,34 +4,33 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class IntegerLiteral : Expr { - public sealed class IntegerLiteral : Expr - { - private readonly Lazy _valueString; + private readonly Lazy _valueString; - internal IntegerLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IntegerLiteral, CX_StmtClass.CX_StmtClass_IntegerLiteral) - { - _valueString = new Lazy(() => { - var tokens = Handle.TranslationUnit.Tokenize(Handle.SourceRange); + internal IntegerLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IntegerLiteral, CX_StmtClass.CX_StmtClass_IntegerLiteral) + { + _valueString = new Lazy(() => { + var tokens = Handle.TranslationUnit.Tokenize(Handle.SourceRange); - Debug.Assert(tokens.Length == 1); - Debug.Assert(tokens[0].Kind is CXTokenKind.CXToken_Literal or CXTokenKind.CXToken_Identifier); + Debug.Assert(tokens.Length == 1); + Debug.Assert(tokens[0].Kind is CXTokenKind.CXToken_Literal or CXTokenKind.CXToken_Identifier); - var spelling = tokens[0].GetSpelling(Handle.TranslationUnit).ToString(); - spelling = spelling.Trim('\\', '\r', '\n'); - return spelling; - }); - } + var spelling = tokens[0].GetSpelling(Handle.TranslationUnit).ToString(); + spelling = spelling.Trim('\\', '\r', '\n'); + return spelling; + }); + } - public bool IsNegative => Handle.IsNegative; + public bool IsNegative => Handle.IsNegative; - public bool IsNonNegative => Handle.IsNonNegative; + public bool IsNonNegative => Handle.IsNonNegative; - public bool IsStrictlyPositive => Handle.IsStrictlyPositive; + public bool IsStrictlyPositive => Handle.IsStrictlyPositive; - public long Value => Handle.IntegerLiteralValue; + public long Value => Handle.IntegerLiteralValue; - public string ValueString => _valueString.Value; - } + public string ValueString => _valueString.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/LambdaExpr.cs b/sources/ClangSharp/Cursors/Exprs/LambdaExpr.cs index 39a5df79..d95843ce 100644 --- a/sources/ClangSharp/Cursors/Exprs/LambdaExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/LambdaExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class LambdaExpr : Expr { - public sealed class LambdaExpr : Expr + internal LambdaExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LambdaExpr, CX_StmtClass.CX_StmtClass_LambdaExpr) { - internal LambdaExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LambdaExpr, CX_StmtClass.CX_StmtClass_LambdaExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/MSPropertyRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/MSPropertyRefExpr.cs index eb80717a..0e57e405 100644 --- a/sources/ClangSharp/Cursors/Exprs/MSPropertyRefExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/MSPropertyRefExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MSPropertyRefExpr : Expr { - public sealed class MSPropertyRefExpr : Expr + internal MSPropertyRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_MSPropertyRefExpr) { - internal MSPropertyRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_MSPropertyRefExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/MSPropertySubscriptExpr.cs b/sources/ClangSharp/Cursors/Exprs/MSPropertySubscriptExpr.cs index 9bf5e7a0..2d402b99 100644 --- a/sources/ClangSharp/Cursors/Exprs/MSPropertySubscriptExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/MSPropertySubscriptExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MSPropertySubscriptExpr : Expr { - public sealed class MSPropertySubscriptExpr : Expr + internal MSPropertySubscriptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ArraySubscriptExpr, CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr) { - internal MSPropertySubscriptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ArraySubscriptExpr, CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/MaterializeTemporaryExpr.cs b/sources/ClangSharp/Cursors/Exprs/MaterializeTemporaryExpr.cs index 9e837a41..f5426e77 100644 --- a/sources/ClangSharp/Cursors/Exprs/MaterializeTemporaryExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/MaterializeTemporaryExpr.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MaterializeTemporaryExpr : Expr { - public sealed class MaterializeTemporaryExpr : Expr - { - private readonly Lazy _lifetimeExtendedTemporaryDecl; + private readonly Lazy _lifetimeExtendedTemporaryDecl; - internal MaterializeTemporaryExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr) - { - _lifetimeExtendedTemporaryDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal MaterializeTemporaryExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr) + { + _lifetimeExtendedTemporaryDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public ValueDecl ExtendingDecl => LifetimeExtendedTemporaryDecl?.ExtendingDecl; + public ValueDecl ExtendingDecl => LifetimeExtendedTemporaryDecl?.ExtendingDecl; - public LifetimeExtendedTemporaryDecl LifetimeExtendedTemporaryDecl => _lifetimeExtendedTemporaryDecl.Value; + public LifetimeExtendedTemporaryDecl LifetimeExtendedTemporaryDecl => _lifetimeExtendedTemporaryDecl.Value; - public Expr SubExpr => (Expr)Children[0]; - } + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/MatrixSubscriptExpr.cs b/sources/ClangSharp/Cursors/Exprs/MatrixSubscriptExpr.cs index 55e2330c..03273b6b 100644 --- a/sources/ClangSharp/Cursors/Exprs/MatrixSubscriptExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/MatrixSubscriptExpr.cs @@ -3,21 +3,20 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MatrixSubscriptExpr : Expr { - public sealed class MatrixSubscriptExpr : Expr + internal MatrixSubscriptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_MatrixSubscriptExpr) { - internal MatrixSubscriptExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_MatrixSubscriptExpr) - { - Debug.Assert(NumChildren is 3); - } + Debug.Assert(NumChildren is 3); + } - public Expr Base => (Expr)Children[0]; + public Expr Base => (Expr)Children[0]; - public Expr ColumnIdx => IsIncomplete ? null : (Expr)Children[2]; + public Expr ColumnIdx => IsIncomplete ? null : (Expr)Children[2]; - public bool IsIncomplete => Handle.IsIncomplete; + public bool IsIncomplete => Handle.IsIncomplete; - public Expr RowIdx => (Expr)Children[1]; - } + public Expr RowIdx => (Expr)Children[1]; } diff --git a/sources/ClangSharp/Cursors/Exprs/MemberExpr.cs b/sources/ClangSharp/Cursors/Exprs/MemberExpr.cs index 67f139bd..4253a57d 100644 --- a/sources/ClangSharp/Cursors/Exprs/MemberExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/MemberExpr.cs @@ -5,50 +5,49 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MemberExpr : Expr { - public sealed class MemberExpr : Expr - { - private readonly Lazy _memberDecl; - private readonly Lazy> _templateArgs; + private readonly Lazy _memberDecl; + private readonly Lazy> _templateArgs; - internal MemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_MemberExpr) - { - Debug.Assert(NumChildren is 1); + internal MemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_MemberExpr) + { + Debug.Assert(NumChildren is 1); - _memberDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); + _memberDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); - templateArgs.Add(templateArg); - } + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); + templateArgs.Add(templateArg); + } - return templateArgs; - }); - } + return templateArgs; + }); + } - public Expr Base => (Expr)Children[0]; + public Expr Base => (Expr)Children[0]; - public bool HadMultipleCandidates => Handle.HadMultipleCandidates; + public bool HadMultipleCandidates => Handle.HadMultipleCandidates; - public bool HasExplicitTemplateArg => Handle.HasExplicitTemplateArgs; + public bool HasExplicitTemplateArg => Handle.HasExplicitTemplateArgs; - public bool HasTemplateKeyword => Handle.HasTemplateKeyword; + public bool HasTemplateKeyword => Handle.HasTemplateKeyword; - public bool IsArrow => Handle.IsArrow; + public bool IsArrow => Handle.IsArrow; - public bool IsImplicitAccess => Handle.IsImplicit; + public bool IsImplicitAccess => Handle.IsImplicit; - public ValueDecl MemberDecl => _memberDecl.Value; + public ValueDecl MemberDecl => _memberDecl.Value; - public string MemberName => Handle.Name.CString; + public string MemberName => Handle.Name.CString; - public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); + public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); - public IReadOnlyList TemplateArgs => _templateArgs.Value; - } + public IReadOnlyList TemplateArgs => _templateArgs.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/NoInitExpr.cs b/sources/ClangSharp/Cursors/Exprs/NoInitExpr.cs index 4745b458..e89d1f3a 100644 --- a/sources/ClangSharp/Cursors/Exprs/NoInitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/NoInitExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class NoInitExpr : Expr { - public sealed class NoInitExpr : Expr + internal NoInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_NoInitExpr) { - internal NoInitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_NoInitExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/OMPArraySectionExpr.cs b/sources/ClangSharp/Cursors/Exprs/OMPArraySectionExpr.cs index cac3f53b..e45b9ba2 100644 --- a/sources/ClangSharp/Cursors/Exprs/OMPArraySectionExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/OMPArraySectionExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPArraySectionExpr : Expr { - public sealed class OMPArraySectionExpr : Expr + internal OMPArraySectionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPArraySectionExpr, CX_StmtClass.CX_StmtClass_OMPArraySectionExpr) { - internal OMPArraySectionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPArraySectionExpr, CX_StmtClass.CX_StmtClass_OMPArraySectionExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/OMPArrayShapingExpr.cs b/sources/ClangSharp/Cursors/Exprs/OMPArrayShapingExpr.cs index 88720ee8..150afcbe 100644 --- a/sources/ClangSharp/Cursors/Exprs/OMPArrayShapingExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/OMPArrayShapingExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPArrayShapingExpr : Expr { - public sealed class OMPArrayShapingExpr : Expr + internal OMPArrayShapingExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPArrayShapingExpr, CX_StmtClass.CX_StmtClass_OMPArrayShapingExpr) { - internal OMPArrayShapingExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPArrayShapingExpr, CX_StmtClass.CX_StmtClass_OMPArrayShapingExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/OMPIteratorExpr.cs b/sources/ClangSharp/Cursors/Exprs/OMPIteratorExpr.cs index e4bea846..1598bd36 100644 --- a/sources/ClangSharp/Cursors/Exprs/OMPIteratorExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/OMPIteratorExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPIteratorExpr : Expr { - public sealed class OMPIteratorExpr : Expr + internal OMPIteratorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPIteratorExpr, CX_StmtClass.CX_StmtClass_OMPIteratorExpr) { - internal OMPIteratorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPIteratorExpr, CX_StmtClass.CX_StmtClass_OMPIteratorExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCArrayLiteral.cs b/sources/ClangSharp/Cursors/Exprs/ObjCArrayLiteral.cs index 477cc0b1..0872e076 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCArrayLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCArrayLiteral.cs @@ -5,23 +5,22 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCArrayLiteral : Expr { - public sealed class ObjCArrayLiteral : Expr - { - private readonly Lazy _arrayWithObjectsMethod; - private readonly Lazy> _elements; + private readonly Lazy _arrayWithObjectsMethod; + private readonly Lazy> _elements; - internal ObjCArrayLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCArrayLiteral) - { - _arrayWithObjectsMethod = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _elements = new Lazy>(() => Children.Cast().ToList()); - } + internal ObjCArrayLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCArrayLiteral) + { + _arrayWithObjectsMethod = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _elements = new Lazy>(() => Children.Cast().ToList()); + } - public ObjCMethodDecl ArrayWithObjectsMethod => _arrayWithObjectsMethod.Value; + public ObjCMethodDecl ArrayWithObjectsMethod => _arrayWithObjectsMethod.Value; - public IReadOnlyList Elements => _elements.Value; + public IReadOnlyList Elements => _elements.Value; - public uint NumElements => NumChildren; - } + public uint NumElements => NumChildren; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCAvailabilityCheckExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCAvailabilityCheckExpr.cs index dbd92246..4e287e41 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCAvailabilityCheckExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCAvailabilityCheckExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCAvailabilityCheckExpr : Expr { - public sealed class ObjCAvailabilityCheckExpr : Expr + internal ObjCAvailabilityCheckExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAvailabilityCheckExpr, CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr) { - internal ObjCAvailabilityCheckExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAvailabilityCheckExpr, CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCBoolLiteralExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCBoolLiteralExpr.cs index 62feaade..8de9431f 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCBoolLiteralExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCBoolLiteralExpr.cs @@ -2,14 +2,13 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCBoolLiteralExpr : Expr { - public sealed class ObjCBoolLiteralExpr : Expr + internal ObjCBoolLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCBoolLiteralExpr, CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr) { - internal ObjCBoolLiteralExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCBoolLiteralExpr, CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr) - { - } - - public bool Value => Handle.BoolLiteralValue; } + + public bool Value => Handle.BoolLiteralValue; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCBoxedExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCBoxedExpr.cs index a8fcd04c..7e0a588c 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCBoxedExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCBoxedExpr.cs @@ -4,20 +4,19 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCBoxedExpr : Expr { - public sealed class ObjCBoxedExpr : Expr - { - private readonly Lazy _boxingMethod; + private readonly Lazy _boxingMethod; - internal ObjCBoxedExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCBoxedExpr) - { - Debug.Assert(NumChildren is 1); - _boxingMethod = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal ObjCBoxedExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCBoxedExpr) + { + Debug.Assert(NumChildren is 1); + _boxingMethod = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public ObjCMethodDecl BoxingMethod => _boxingMethod.Value; + public ObjCMethodDecl BoxingMethod => _boxingMethod.Value; - public Expr SubExpr => (Expr)Children[0]; - } + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCBridgedCastExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCBridgedCastExpr.cs index e22607eb..d1413ab4 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCBridgedCastExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCBridgedCastExpr.cs @@ -2,14 +2,13 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCBridgedCastExpr : ExplicitCastExpr { - public sealed class ObjCBridgedCastExpr : ExplicitCastExpr + internal ObjCBridgedCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCBridgedCastExpr, CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr) { - internal ObjCBridgedCastExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCBridgedCastExpr, CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr) - { - } - - public string BridgeKindName => Handle.Name.CString; } + + public string BridgeKindName => Handle.Name.CString; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCDictionaryLiteral.cs b/sources/ClangSharp/Cursors/Exprs/ObjCDictionaryLiteral.cs index 6c4de341..9e76fd3e 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCDictionaryLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCDictionaryLiteral.cs @@ -5,35 +5,34 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCDictionaryLiteral : Expr { - public sealed class ObjCDictionaryLiteral : Expr - { - private readonly Lazy _dictWithObjectsMethod; - private readonly Lazy> _keyValueElements; + private readonly Lazy _dictWithObjectsMethod; + private readonly Lazy> _keyValueElements; - internal ObjCDictionaryLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral) - { - Debug.Assert((NumChildren % 2) == 0); - _dictWithObjectsMethod = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + internal ObjCDictionaryLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral) + { + Debug.Assert((NumChildren % 2) == 0); + _dictWithObjectsMethod = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _keyValueElements = new Lazy>(() => { - var numChildren = Handle.NumChildren; - var keyValueElements = new List<(Expr Key, Expr Value)>(numChildren / 2); + _keyValueElements = new Lazy>(() => { + var numChildren = Handle.NumChildren; + var keyValueElements = new List<(Expr Key, Expr Value)>(numChildren / 2); - for (var i = 0; i < numChildren; i += 2) - { - keyValueElements.Add(((Expr)Children[i + 0], (Expr)Children[i + 1])); - } + for (var i = 0; i < numChildren; i += 2) + { + keyValueElements.Add(((Expr)Children[i + 0], (Expr)Children[i + 1])); + } - return keyValueElements; - }); - } + return keyValueElements; + }); + } - public ObjCMethodDecl DictWithObjectsMethod => _dictWithObjectsMethod.Value; + public ObjCMethodDecl DictWithObjectsMethod => _dictWithObjectsMethod.Value; - public IReadOnlyList<(Expr Key, Expr Value)> KeyValueElements => _keyValueElements.Value; + public IReadOnlyList<(Expr Key, Expr Value)> KeyValueElements => _keyValueElements.Value; - public uint NumElements => NumChildren / 2; - } + public uint NumElements => NumChildren / 2; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCEncodeExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCEncodeExpr.cs index b1892c9f..17946682 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCEncodeExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCEncodeExpr.cs @@ -4,18 +4,17 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class ObjCEncodeExpr : Expr - { - private readonly Lazy _encodedType; +namespace ClangSharp; - internal ObjCEncodeExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCEncodeExpr, CX_StmtClass.CX_StmtClass_ObjCEncodeExpr) - { - Debug.Assert(NumChildren is 0); - _encodedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } +public sealed class ObjCEncodeExpr : Expr +{ + private readonly Lazy _encodedType; - public Type EncodedType => _encodedType.Value; + internal ObjCEncodeExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCEncodeExpr, CX_StmtClass.CX_StmtClass_ObjCEncodeExpr) + { + Debug.Assert(NumChildren is 0); + _encodedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); } + + public Type EncodedType => _encodedType.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCIndirectCopyRestoreExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCIndirectCopyRestoreExpr.cs index 0b0e7a87..ed115cf1 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCIndirectCopyRestoreExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCIndirectCopyRestoreExpr.cs @@ -3,17 +3,16 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCIndirectCopyRestoreExpr : Expr { - public sealed class ObjCIndirectCopyRestoreExpr : Expr + internal ObjCIndirectCopyRestoreExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr) { - internal ObjCIndirectCopyRestoreExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr) - { - Debug.Assert(NumChildren is 1); - } + Debug.Assert(NumChildren is 1); + } - public bool ShouldCopy => Handle.ShouldCopy; + public bool ShouldCopy => Handle.ShouldCopy; - public Expr SubExpr => (Expr)Children[0]; - } + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCIsaExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCIsaExpr.cs index 793a69e5..5312a765 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCIsaExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCIsaExpr.cs @@ -3,17 +3,16 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCIsaExpr : Expr { - public sealed class ObjCIsaExpr : Expr + internal ObjCIsaExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_ObjCIsaExpr) { - internal ObjCIsaExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_ObjCIsaExpr) - { - Debug.Assert(NumChildren is 1); - } + Debug.Assert(NumChildren is 1); + } - public Expr Base => (Expr)Children[0]; + public Expr Base => (Expr)Children[0]; - public bool IsArrow => Handle.IsArrow; - } + public bool IsArrow => Handle.IsArrow; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCIvarRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCIvarRefExpr.cs index 28f4e54c..bd2684f4 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCIvarRefExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCIvarRefExpr.cs @@ -4,22 +4,21 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCIvarRefExpr : Expr { - public sealed class ObjCIvarRefExpr : Expr - { - private readonly Lazy _decl; + private readonly Lazy _decl; - internal ObjCIvarRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr) - { - Debug.Assert(NumChildren is 1); - _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal ObjCIvarRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr) + { + Debug.Assert(NumChildren is 1); + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public Expr Base => (Expr)Children[0]; + public Expr Base => (Expr)Children[0]; - public ObjCIvarDecl Decl => _decl.Value; + public ObjCIvarDecl Decl => _decl.Value; - public bool IsArrow => Handle.IsArrow; - } + public bool IsArrow => Handle.IsArrow; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCMessageExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCMessageExpr.cs index 5a7c1349..19ae7f5b 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCMessageExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCMessageExpr.cs @@ -4,53 +4,52 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCMessageExpr : Expr { - public sealed class ObjCMessageExpr : Expr + private readonly Lazy> _args; + private readonly Lazy _classReceiver; + private readonly Lazy _instanceReceiver; + private readonly Lazy _methodDecl; + private readonly Lazy _receiverType; + private readonly Lazy _superType; + + internal ObjCMessageExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCMessageExpr, CX_StmtClass.CX_StmtClass_ObjCMessageExpr) { - private readonly Lazy> _args; - private readonly Lazy _classReceiver; - private readonly Lazy _instanceReceiver; - private readonly Lazy _methodDecl; - private readonly Lazy _receiverType; - private readonly Lazy _superType; - - internal ObjCMessageExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCMessageExpr, CX_StmtClass.CX_StmtClass_ObjCMessageExpr) - { - _args = new Lazy>(() => { - var numArgs = Handle.NumArguments; - var args = new List(numArgs); - - for (var i = 0; i < numArgs; i++) - { - var arg = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); - args.Add(arg); - } - - return args; - }); - - _classReceiver = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - _instanceReceiver = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); - _methodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _receiverType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ReceiverType)); - _superType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ThisObjectType)); - } + _args = new Lazy>(() => { + var numArgs = Handle.NumArguments; + var args = new List(numArgs); + + for (var i = 0; i < numArgs; i++) + { + var arg = TranslationUnit.GetOrCreate(Handle.GetArgument(unchecked((uint)i))); + args.Add(arg); + } + + return args; + }); + + _classReceiver = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + _instanceReceiver = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); + _methodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _receiverType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ReceiverType)); + _superType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ThisObjectType)); + } - public IReadOnlyList Args => _args.Value; + public IReadOnlyList Args => _args.Value; - public Type ClassReceiver => _classReceiver.Value; + public Type ClassReceiver => _classReceiver.Value; - public bool IsImplicit => Handle.IsImplicit; + public bool IsImplicit => Handle.IsImplicit; - public Expr InstanceReceiver => _instanceReceiver.Value; + public Expr InstanceReceiver => _instanceReceiver.Value; - public Type ReceiverType => _receiverType.Value; + public Type ReceiverType => _receiverType.Value; - public Type SuperType => _superType.Value; + public Type SuperType => _superType.Value; - public ObjCMethodDecl MethodDecl => _methodDecl.Value; + public ObjCMethodDecl MethodDecl => _methodDecl.Value; - public uint NumArgs => unchecked((uint)Handle.NumArguments); - } + public uint NumArgs => unchecked((uint)Handle.NumArguments); } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCPropertyRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCPropertyRefExpr.cs index b846f369..7333dbab 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCPropertyRefExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCPropertyRefExpr.cs @@ -3,42 +3,41 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCPropertyRefExpr : Expr { - public sealed class ObjCPropertyRefExpr : Expr + private readonly Lazy _base; + private readonly Lazy _classReceiver; + private readonly Lazy _explicitProperty; + private readonly Lazy _implicitPropertyGetter; + private readonly Lazy _implicitPropertySetter; + private readonly Lazy _superReceiverType; + + internal ObjCPropertyRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr) { - private readonly Lazy _base; - private readonly Lazy _classReceiver; - private readonly Lazy _explicitProperty; - private readonly Lazy _implicitPropertyGetter; - private readonly Lazy _implicitPropertySetter; - private readonly Lazy _superReceiverType; - - internal ObjCPropertyRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr) - { - _base = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); - _classReceiver = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(0))); - _explicitProperty = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(1))); - _implicitPropertyGetter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(2))); - _implicitPropertySetter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(3))); - _superReceiverType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } + _base = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetExpr(0))); + _classReceiver = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(0))); + _explicitProperty = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(1))); + _implicitPropertyGetter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(2))); + _implicitPropertySetter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetDecl(3))); + _superReceiverType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + } - public Expr Base => _base.Value; + public Expr Base => _base.Value; - public ObjCInterfaceDecl ClassReceiver => _classReceiver.Value; + public ObjCInterfaceDecl ClassReceiver => _classReceiver.Value; - public ObjCPropertyDecl ExplicitProperty => _explicitProperty.Value; + public ObjCPropertyDecl ExplicitProperty => _explicitProperty.Value; - public bool IsExplicitProperty => !IsImplicitProperty; + public bool IsExplicitProperty => !IsImplicitProperty; - public bool IsImplicitProperty => Handle.IsImplicit; + public bool IsImplicitProperty => Handle.IsImplicit; - public ObjCMethodDecl ImplicitPropertyGetter => _implicitPropertyGetter.Value; + public ObjCMethodDecl ImplicitPropertyGetter => _implicitPropertyGetter.Value; - public ObjCMethodDecl ImplicitPropertySetter => _implicitPropertySetter.Value; + public ObjCMethodDecl ImplicitPropertySetter => _implicitPropertySetter.Value; - public Type SuperReceiverType => _superReceiverType.Value; - } + public Type SuperReceiverType => _superReceiverType.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCProtocolExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCProtocolExpr.cs index 9d9c66b4..c118f857 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCProtocolExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCProtocolExpr.cs @@ -4,18 +4,17 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class ObjCProtocolExpr : Expr - { - private readonly Lazy _protocol; +namespace ClangSharp; - internal ObjCProtocolExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCProtocolExpr, CX_StmtClass.CX_StmtClass_ObjCProtocolExpr) - { - Debug.Assert(NumChildren is 0); - _protocol = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } +public sealed class ObjCProtocolExpr : Expr +{ + private readonly Lazy _protocol; - public ObjCProtocolDecl Protocol => _protocol.Value; + internal ObjCProtocolExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCProtocolExpr, CX_StmtClass.CX_StmtClass_ObjCProtocolExpr) + { + Debug.Assert(NumChildren is 0); + _protocol = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); } + + public ObjCProtocolDecl Protocol => _protocol.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCSelectorExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCSelectorExpr.cs index 49c8f7dd..8662833d 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCSelectorExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCSelectorExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCSelectorExpr : Expr { - public sealed class ObjCSelectorExpr : Expr + internal ObjCSelectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCSelectorExpr, CX_StmtClass.CX_StmtClass_ObjCSelectorExpr) { - internal ObjCSelectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCSelectorExpr, CX_StmtClass.CX_StmtClass_ObjCSelectorExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCStringLiteral.cs b/sources/ClangSharp/Cursors/Exprs/ObjCStringLiteral.cs index 065f96f7..817b5398 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCStringLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCStringLiteral.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCStringLiteral : Expr { - public sealed class ObjCStringLiteral : Expr + internal ObjCStringLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCStringLiteral, CX_StmtClass.CX_StmtClass_ObjCStringLiteral) { - internal ObjCStringLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCStringLiteral, CX_StmtClass.CX_StmtClass_ObjCStringLiteral) - { - Debug.Assert(NumChildren is 1); - } - - public StringLiteral String => (StringLiteral)Children[0]; + Debug.Assert(NumChildren is 1); } + + public StringLiteral String => (StringLiteral)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/ObjCSubscriptRefExpr.cs b/sources/ClangSharp/Cursors/Exprs/ObjCSubscriptRefExpr.cs index 55cc372d..da733a76 100644 --- a/sources/ClangSharp/Cursors/Exprs/ObjCSubscriptRefExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ObjCSubscriptRefExpr.cs @@ -4,24 +4,23 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCSubscriptRefExpr : Expr { - public sealed class ObjCSubscriptRefExpr : Expr - { - private readonly Lazy _atIndexMethodDecl; + private readonly Lazy _atIndexMethodDecl; - internal ObjCSubscriptRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr) - { - Debug.Assert(NumChildren is 2); - _atIndexMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal ObjCSubscriptRefExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr) + { + Debug.Assert(NumChildren is 2); + _atIndexMethodDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public ObjCMethodDecl AtIndexMethodDecl => _atIndexMethodDecl.Value; + public ObjCMethodDecl AtIndexMethodDecl => _atIndexMethodDecl.Value; - public Expr BaseExpr => (Expr)Children[0]; + public Expr BaseExpr => (Expr)Children[0]; - public Expr KeyExpr => (Expr)Children[1]; + public Expr KeyExpr => (Expr)Children[1]; - public bool IsArraySubscriptRefExpr => KeyExpr.Type.IsIntegralOrEnumerationType; - } + public bool IsArraySubscriptRefExpr => KeyExpr.Type.IsIntegralOrEnumerationType; } diff --git a/sources/ClangSharp/Cursors/Exprs/OffsetOfExpr.cs b/sources/ClangSharp/Cursors/Exprs/OffsetOfExpr.cs index 891d86d3..4f7ce6f4 100644 --- a/sources/ClangSharp/Cursors/Exprs/OffsetOfExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/OffsetOfExpr.cs @@ -5,27 +5,26 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OffsetOfExpr : Expr { - public sealed class OffsetOfExpr : Expr - { - private readonly Lazy> _indexExprs; - private readonly Lazy _referenced; - private readonly Lazy _typeSourceInfoType; + private readonly Lazy> _indexExprs; + private readonly Lazy _referenced; + private readonly Lazy _typeSourceInfoType; - internal OffsetOfExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_OffsetOfExpr) - { - _indexExprs = new Lazy>(() => Children.Cast().ToList()); - _referenced = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _typeSourceInfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } + internal OffsetOfExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_OffsetOfExpr) + { + _indexExprs = new Lazy>(() => Children.Cast().ToList()); + _referenced = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _typeSourceInfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + } - public IReadOnlyList IndexExprs => _indexExprs.Value; + public IReadOnlyList IndexExprs => _indexExprs.Value; - public uint NumExpressions => NumChildren; + public uint NumExpressions => NumChildren; - public Cursor Referenced => _referenced.Value; + public Cursor Referenced => _referenced.Value; - public Type TypeSourceInfoType => _typeSourceInfoType.Value; - } + public Type TypeSourceInfoType => _typeSourceInfoType.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/OpaqueValueExpr.cs b/sources/ClangSharp/Cursors/Exprs/OpaqueValueExpr.cs index 8e092520..4a148998 100644 --- a/sources/ClangSharp/Cursors/Exprs/OpaqueValueExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/OpaqueValueExpr.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class OpaqueValueExpr : Expr - { - private readonly Lazy _sourceExpr; +namespace ClangSharp; - internal OpaqueValueExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_OpaqueValueExpr) - { - _sourceExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.SubExpr)); - } +public sealed class OpaqueValueExpr : Expr +{ + private readonly Lazy _sourceExpr; - public Expr SourceExpr => _sourceExpr.Value; + internal OpaqueValueExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_OpaqueValueExpr) + { + _sourceExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.SubExpr)); } + + public Expr SourceExpr => _sourceExpr.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/OverloadExpr.cs b/sources/ClangSharp/Cursors/Exprs/OverloadExpr.cs index 067a436a..47460911 100644 --- a/sources/ClangSharp/Cursors/Exprs/OverloadExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/OverloadExpr.cs @@ -4,64 +4,63 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class OverloadExpr : Expr { - public class OverloadExpr : Expr - { - private readonly Lazy> _decls; - private readonly Lazy _namingClass; - private readonly Lazy> _templateArgs; + private readonly Lazy> _decls; + private readonly Lazy _namingClass; + private readonly Lazy> _templateArgs; - private protected OverloadExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + private protected OverloadExpr(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOverloadExpr or < CX_StmtClass.CX_StmtClass_FirstOverloadExpr) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOverloadExpr or < CX_StmtClass.CX_StmtClass_FirstOverloadExpr) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); + } - _decls = new Lazy>(() => { - var numDecls = Handle.NumDecls; - var decls = new List(numDecls); + _decls = new Lazy>(() => { + var numDecls = Handle.NumDecls; + var decls = new List(numDecls); - for (var i = 0; i < numDecls; i++) - { - var decl = TranslationUnit.GetOrCreate(Handle.GetDecl(unchecked((uint)i))); - decls.Add(decl); - } + for (var i = 0; i < numDecls; i++) + { + var decl = TranslationUnit.GetOrCreate(Handle.GetDecl(unchecked((uint)i))); + decls.Add(decl); + } - return decls; - }); + return decls; + }); - _namingClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _namingClass = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); - templateArgs.Add(templateArg); - } + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgumentLoc(unchecked((uint)i))); + templateArgs.Add(templateArg); + } - return templateArgs; - }); - } + return templateArgs; + }); + } - public IReadOnlyList Decls => _decls.Value; + public IReadOnlyList Decls => _decls.Value; - public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; + public bool HasExplicitTemplateArgs => Handle.HasExplicitTemplateArgs; - public bool HasTemplateKeyword => Handle.HasTemplateKeyword; + public bool HasTemplateKeyword => Handle.HasTemplateKeyword; - public CXXRecordDecl NamingClass => _namingClass.Value; + public CXXRecordDecl NamingClass => _namingClass.Value; - public string Name => Handle.Name.CString; + public string Name => Handle.Name.CString; - public uint NumDecls => unchecked((uint)Handle.NumDecls); + public uint NumDecls => unchecked((uint)Handle.NumDecls); - public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); + public uint NumTemplateArgs => unchecked((uint)Handle.NumTemplateArguments); - public IReadOnlyList TemplateArgs => _templateArgs.Value; - } + public IReadOnlyList TemplateArgs => _templateArgs.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/PackExpansionExpr.cs b/sources/ClangSharp/Cursors/Exprs/PackExpansionExpr.cs index bb06b06c..8f4faa85 100644 --- a/sources/ClangSharp/Cursors/Exprs/PackExpansionExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/PackExpansionExpr.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class PackExpansionExpr : Expr { - public sealed class PackExpansionExpr : Expr + internal PackExpansionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_PackExpansionExpr, CX_StmtClass.CX_StmtClass_PackExpansionExpr) { - internal PackExpansionExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_PackExpansionExpr, CX_StmtClass.CX_StmtClass_PackExpansionExpr) - { - Debug.Assert(NumChildren is 1); - } - - public Expr Pattern => (Expr)Children[0]; + Debug.Assert(NumChildren is 1); } + + public Expr Pattern => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/ParenExpr.cs b/sources/ClangSharp/Cursors/Exprs/ParenExpr.cs index 92db4815..6eddae38 100644 --- a/sources/ClangSharp/Cursors/Exprs/ParenExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ParenExpr.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ParenExpr : Expr { - public sealed class ParenExpr : Expr + internal ParenExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ParenExpr, CX_StmtClass.CX_StmtClass_ParenExpr) { - internal ParenExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ParenExpr, CX_StmtClass.CX_StmtClass_ParenExpr) - { - Debug.Assert(NumChildren is 1); - } - - public Expr SubExpr => (Expr)Children[0]; + Debug.Assert(NumChildren is 1); } + + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/ParenListExpr.cs b/sources/ClangSharp/Cursors/Exprs/ParenListExpr.cs index c1192b36..8995bd51 100644 --- a/sources/ClangSharp/Cursors/Exprs/ParenListExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ParenListExpr.cs @@ -5,19 +5,18 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ParenListExpr : Expr { - public sealed class ParenListExpr : Expr - { - private readonly Lazy> _exprs; + private readonly Lazy> _exprs; - internal ParenListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ParenListExpr) - { - _exprs = new Lazy>(() => Children.Cast().ToList()); - } + internal ParenListExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ParenListExpr) + { + _exprs = new Lazy>(() => Children.Cast().ToList()); + } - public IReadOnlyList Exprs => _exprs.Value; + public IReadOnlyList Exprs => _exprs.Value; - public uint NumExprs => NumChildren; - } + public uint NumExprs => NumChildren; } diff --git a/sources/ClangSharp/Cursors/Exprs/PredefinedExpr.cs b/sources/ClangSharp/Cursors/Exprs/PredefinedExpr.cs index a0b1a4db..c204de78 100644 --- a/sources/ClangSharp/Cursors/Exprs/PredefinedExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/PredefinedExpr.cs @@ -4,15 +4,14 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class PredefinedExpr : Expr { - public sealed class PredefinedExpr : Expr + internal PredefinedExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_PredefinedExpr) { - internal PredefinedExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_PredefinedExpr) - { - Debug.Assert(NumChildren is 0 or 1); - } - - public StringLiteral FunctionName => (StringLiteral)Children.SingleOrDefault(); + Debug.Assert(NumChildren is 0 or 1); } + + public StringLiteral FunctionName => (StringLiteral)Children.SingleOrDefault(); } diff --git a/sources/ClangSharp/Cursors/Exprs/PseudoObjectExpr.cs b/sources/ClangSharp/Cursors/Exprs/PseudoObjectExpr.cs index 20cd2b15..dd249b2d 100644 --- a/sources/ClangSharp/Cursors/Exprs/PseudoObjectExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/PseudoObjectExpr.cs @@ -6,26 +6,25 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class PseudoObjectExpr : Expr { - public sealed class PseudoObjectExpr : Expr - { - private readonly Lazy> _semantics; + private readonly Lazy> _semantics; - internal PseudoObjectExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_PseudoObjectExpr) - { - Debug.Assert(NumChildren >= 1); - _semantics = new Lazy>(() => Children.Skip(1).Cast().ToList()); - } + internal PseudoObjectExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_PseudoObjectExpr) + { + Debug.Assert(NumChildren >= 1); + _semantics = new Lazy>(() => Children.Skip(1).Cast().ToList()); + } - public uint NumSemanticExprs => NumChildren - 1; + public uint NumSemanticExprs => NumChildren - 1; - public Expr ResultExpr => (ResultExprIndex == 0) ? null : (Expr)Children[unchecked((int)ResultExprIndex)]; + public Expr ResultExpr => (ResultExprIndex == 0) ? null : (Expr)Children[unchecked((int)ResultExprIndex)]; - public uint ResultExprIndex => unchecked((uint)Handle.ResultIndex); + public uint ResultExprIndex => unchecked((uint)Handle.ResultIndex); - public IReadOnlyList Semantics => _semantics.Value; + public IReadOnlyList Semantics => _semantics.Value; - public Expr SyntacticForm => (Expr)Children[0]; - } + public Expr SyntacticForm => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/RecoveryExpr.cs b/sources/ClangSharp/Cursors/Exprs/RecoveryExpr.cs index 06142cf6..161081db 100644 --- a/sources/ClangSharp/Cursors/Exprs/RecoveryExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/RecoveryExpr.cs @@ -5,17 +5,16 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class RecoveryExpr : Expr - { - private readonly Lazy> _subExpressions; +namespace ClangSharp; - internal RecoveryExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_RecoveryExpr) - { - _subExpressions = new Lazy>(() => Children.Cast().ToList()); - } +public sealed class RecoveryExpr : Expr +{ + private readonly Lazy> _subExpressions; - public IReadOnlyList SubExpressions => _subExpressions.Value; + internal RecoveryExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_RecoveryExpr) + { + _subExpressions = new Lazy>(() => Children.Cast().ToList()); } + + public IReadOnlyList SubExpressions => _subExpressions.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/RequiresExpr.cs b/sources/ClangSharp/Cursors/Exprs/RequiresExpr.cs index e7d774e1..e37e444c 100644 --- a/sources/ClangSharp/Cursors/Exprs/RequiresExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/RequiresExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class RequiresExpr : Expr { - public sealed class RequiresExpr : Expr + internal RequiresExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_RequiresExpr) { - internal RequiresExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_RequiresExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/SYCLUniqueStableNameExpr.cs b/sources/ClangSharp/Cursors/Exprs/SYCLUniqueStableNameExpr.cs index f1f6b905..1244a847 100644 --- a/sources/ClangSharp/Cursors/Exprs/SYCLUniqueStableNameExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/SYCLUniqueStableNameExpr.cs @@ -4,12 +4,11 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SYCLUniqueStableNameExpr : Expr { - public sealed class SYCLUniqueStableNameExpr : Expr + internal SYCLUniqueStableNameExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_SYCLUniqueStableNameExpr) { - internal SYCLUniqueStableNameExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_SYCLUniqueStableNameExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/ShuffleVectorExpr.cs b/sources/ClangSharp/Cursors/Exprs/ShuffleVectorExpr.cs index 4194b1f5..05b5792f 100644 --- a/sources/ClangSharp/Cursors/Exprs/ShuffleVectorExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/ShuffleVectorExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ShuffleVectorExpr : Expr { - public sealed class ShuffleVectorExpr : Expr + internal ShuffleVectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ShuffleVectorExpr) { - internal ShuffleVectorExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_ShuffleVectorExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/SizeOfPackExpr.cs b/sources/ClangSharp/Cursors/Exprs/SizeOfPackExpr.cs index ee4e8a7d..3aade659 100644 --- a/sources/ClangSharp/Cursors/Exprs/SizeOfPackExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/SizeOfPackExpr.cs @@ -4,36 +4,35 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class SizeOfPackExpr : Expr - { - private readonly Lazy _pack; - private readonly Lazy> _partialArguments; +namespace ClangSharp; - internal SizeOfPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SizeOfPackExpr, CX_StmtClass.CX_StmtClass_SizeOfPackExpr) - { - _pack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _partialArguments = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); - - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); - templateArgs.Add(templateArg); - } +public sealed class SizeOfPackExpr : Expr +{ + private readonly Lazy _pack; + private readonly Lazy> _partialArguments; - return templateArgs; - }); - } + internal SizeOfPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SizeOfPackExpr, CX_StmtClass.CX_StmtClass_SizeOfPackExpr) + { + _pack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _partialArguments = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); + + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); + templateArgs.Add(templateArg); + } + + return templateArgs; + }); + } - public NamedDecl Pack => _pack.Value; + public NamedDecl Pack => _pack.Value; - public uint PackLength => unchecked((uint)Handle.PackLength); + public uint PackLength => unchecked((uint)Handle.PackLength); - public bool IsPartiallySubstituted => Handle.IsPartiallySubstituted; + public bool IsPartiallySubstituted => Handle.IsPartiallySubstituted; - public IReadOnlyList PartialArguments => _partialArguments.Value; - } + public IReadOnlyList PartialArguments => _partialArguments.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/SourceLocExpr.cs b/sources/ClangSharp/Cursors/Exprs/SourceLocExpr.cs index 7281c0d3..c98e6086 100644 --- a/sources/ClangSharp/Cursors/Exprs/SourceLocExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/SourceLocExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SourceLocExpr : Expr { - public sealed class SourceLocExpr : Expr + internal SourceLocExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_SourceLocExpr) { - internal SourceLocExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_SourceLocExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/StmtExpr.cs b/sources/ClangSharp/Cursors/Exprs/StmtExpr.cs index b8359a29..598e1197 100644 --- a/sources/ClangSharp/Cursors/Exprs/StmtExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/StmtExpr.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class StmtExpr : Expr { - public sealed class StmtExpr : Expr + internal StmtExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StmtExpr, CX_StmtClass.CX_StmtClass_StmtExpr) { - internal StmtExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StmtExpr, CX_StmtClass.CX_StmtClass_StmtExpr) - { - Debug.Assert(NumChildren is 1); - } - - public CompoundStmt SubStmt => (CompoundStmt)Children[0]; + Debug.Assert(NumChildren is 1); } + + public CompoundStmt SubStmt => (CompoundStmt)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs b/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs index 7283a6bc..5d08a9d1 100644 --- a/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/StringLiteral.cs @@ -4,62 +4,61 @@ using System.Runtime.InteropServices; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class StringLiteral : Expr { - public sealed class StringLiteral : Expr + internal StringLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StringLiteral, CX_StmtClass.CX_StmtClass_StringLiteral) { - internal StringLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_StringLiteral, CX_StmtClass.CX_StmtClass_StringLiteral) - { - } + } - public CX_CharacterKind Kind => Handle.CharacterLiteralKind; + public CX_CharacterKind Kind => Handle.CharacterLiteralKind; - public unsafe string String + public unsafe string String + { + get { - get + var pCString = clang.getCString(Handle.StringLiteralValue); + + if (pCString is null) { - var pCString = clang.getCString(Handle.StringLiteralValue); + return string.Empty; + } - if (pCString is null) + var constantArrayType = (ConstantArrayType)Type; + var length = unchecked((int)constantArrayType.Size - 1); + + switch (Kind) + { + case CX_CharacterKind.CX_CLK_Ascii: + case CX_CharacterKind.CX_CLK_UTF8: { - return string.Empty; + return new ReadOnlySpan(pCString, length).AsString(); } - var constantArrayType = (ConstantArrayType)Type; - var length = unchecked((int)constantArrayType.Size - 1); - - switch (Kind) + case CX_CharacterKind.CX_CLK_Wide: { - case CX_CharacterKind.CX_CLK_Ascii: - case CX_CharacterKind.CX_CLK_UTF8: + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - return new ReadOnlySpan(pCString, length).AsString(); + goto case CX_CharacterKind.CX_CLK_UTF16; } - case CX_CharacterKind.CX_CLK_Wide: - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - goto case CX_CharacterKind.CX_CLK_UTF16; - } - - goto case CX_CharacterKind.CX_CLK_UTF32; - } + goto case CX_CharacterKind.CX_CLK_UTF32; + } - case CX_CharacterKind.CX_CLK_UTF16: - { - return new ReadOnlySpan(pCString, length).AsString(); - } + case CX_CharacterKind.CX_CLK_UTF16: + { + return new ReadOnlySpan(pCString, length).AsString(); + } - case CX_CharacterKind.CX_CLK_UTF32: - { - return new ReadOnlySpan(pCString, length).AsString(); - } + case CX_CharacterKind.CX_CLK_UTF32: + { + return new ReadOnlySpan(pCString, length).AsString(); + } - default: - { - return string.Empty; - } + default: + { + return string.Empty; } } } diff --git a/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmExpr.cs b/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmExpr.cs index fead6565..bd218692 100644 --- a/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmExpr.cs @@ -4,20 +4,19 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SubstNonTypeTemplateParmExpr : Expr { - public sealed class SubstNonTypeTemplateParmExpr : Expr - { - private readonly Lazy _parameter; + private readonly Lazy _parameter; - internal SubstNonTypeTemplateParmExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr) - { - Debug.Assert(NumChildren is 1); - _parameter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal SubstNonTypeTemplateParmExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr) + { + Debug.Assert(NumChildren is 1); + _parameter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public NonTypeTemplateParmDecl Parameter => _parameter.Value; + public NonTypeTemplateParmDecl Parameter => _parameter.Value; - public Expr Replacement => (Expr)Children[0]; - } + public Expr Replacement => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmPackExpr.cs b/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmPackExpr.cs index 391f468f..78ab0578 100644 --- a/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmPackExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/SubstNonTypeTemplateParmPackExpr.cs @@ -4,23 +4,22 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SubstNonTypeTemplateParmPackExpr : Expr { - public sealed class SubstNonTypeTemplateParmPackExpr : Expr - { - private readonly Lazy _argumentPack; - private readonly Lazy _parameterPack; + private readonly Lazy _argumentPack; + private readonly Lazy _parameterPack; - internal SubstNonTypeTemplateParmPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr) - { - Debug.Assert(NumChildren is 0); + internal SubstNonTypeTemplateParmPackExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr) + { + Debug.Assert(NumChildren is 0); - _argumentPack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(0))); - _parameterPack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + _argumentPack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(0))); + _parameterPack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public TemplateArgument ArgumentPack => _argumentPack.Value; + public TemplateArgument ArgumentPack => _argumentPack.Value; - public NonTypeTemplateParmDecl Parameter => _parameterPack.Value; - } + public NonTypeTemplateParmDecl Parameter => _parameterPack.Value; } diff --git a/sources/ClangSharp/Cursors/Exprs/TypeTraitExpr.cs b/sources/ClangSharp/Cursors/Exprs/TypeTraitExpr.cs index 1f39f60d..efdecf94 100644 --- a/sources/ClangSharp/Cursors/Exprs/TypeTraitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/TypeTraitExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TypeTraitExpr : Expr { - public sealed class TypeTraitExpr : Expr + internal TypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_TypeTraitExpr) { - internal TypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_TypeTraitExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/TypoExpr.cs b/sources/ClangSharp/Cursors/Exprs/TypoExpr.cs index 8460df02..c4cb2a5d 100644 --- a/sources/ClangSharp/Cursors/Exprs/TypoExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/TypoExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TypoExpr : Expr { - public sealed class TypoExpr : Expr + internal TypoExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_TypoExpr) { - internal TypoExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_TypoExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/UnaryExprOrTypeTraitExpr.cs b/sources/ClangSharp/Cursors/Exprs/UnaryExprOrTypeTraitExpr.cs index 0aec3ab1..5decd3d0 100644 --- a/sources/ClangSharp/Cursors/Exprs/UnaryExprOrTypeTraitExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/UnaryExprOrTypeTraitExpr.cs @@ -3,27 +3,26 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UnaryExprOrTypeTraitExpr : Expr { - public sealed class UnaryExprOrTypeTraitExpr : Expr - { - private readonly Lazy _argumentExpr; - private readonly Lazy _argumentType; + private readonly Lazy _argumentExpr; + private readonly Lazy _argumentType; - internal UnaryExprOrTypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryExpr, CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr) - { - _argumentExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SubExpr)); - _argumentType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ArgumentType)); - } + internal UnaryExprOrTypeTraitExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryExpr, CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr) + { + _argumentExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SubExpr)); + _argumentType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ArgumentType)); + } - public Expr ArgumentExpr => _argumentExpr.Value; + public Expr ArgumentExpr => _argumentExpr.Value; - public Type ArgumentType => _argumentType.Value; + public Type ArgumentType => _argumentType.Value; - public bool IsArgumentType => Handle.IsArgumentType; + public bool IsArgumentType => Handle.IsArgumentType; - public CX_UnaryExprOrTypeTrait Kind => Handle.UnaryExprOrTypeTraitKind; + public CX_UnaryExprOrTypeTrait Kind => Handle.UnaryExprOrTypeTraitKind; - public Type TypeOfArgument => IsArgumentType ? ArgumentType : ArgumentExpr.Type; - } + public Type TypeOfArgument => IsArgumentType ? ArgumentType : ArgumentExpr.Type; } diff --git a/sources/ClangSharp/Cursors/Exprs/UnaryOperator.cs b/sources/ClangSharp/Cursors/Exprs/UnaryOperator.cs index 330a76a2..97a6a169 100644 --- a/sources/ClangSharp/Cursors/Exprs/UnaryOperator.cs +++ b/sources/ClangSharp/Cursors/Exprs/UnaryOperator.cs @@ -3,31 +3,30 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UnaryOperator : Expr { - public sealed class UnaryOperator : Expr + internal UnaryOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryOperator, CX_StmtClass.CX_StmtClass_UnaryOperator) { - internal UnaryOperator(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnaryOperator, CX_StmtClass.CX_StmtClass_UnaryOperator) - { - Debug.Assert(NumChildren is 1); - } + Debug.Assert(NumChildren is 1); + } - public bool IsArithmetic => Opcode is >= CX_UnaryOperatorKind.CX_UO_Plus and <= CX_UnaryOperatorKind.CX_UO_LNot; + public bool IsArithmetic => Opcode is >= CX_UnaryOperatorKind.CX_UO_Plus and <= CX_UnaryOperatorKind.CX_UO_LNot; - public bool IsDecrementOp => Opcode is CX_UnaryOperatorKind.CX_UO_PreDec or CX_UnaryOperatorKind.CX_UO_PostDec; + public bool IsDecrementOp => Opcode is CX_UnaryOperatorKind.CX_UO_PreDec or CX_UnaryOperatorKind.CX_UO_PostDec; - public bool IsIncrementOp => Opcode is CX_UnaryOperatorKind.CX_UO_PreInc or CX_UnaryOperatorKind.CX_UO_PostInc; + public bool IsIncrementOp => Opcode is CX_UnaryOperatorKind.CX_UO_PreInc or CX_UnaryOperatorKind.CX_UO_PostInc; - public bool IsIncrementDecrementOp => Opcode <= CX_UnaryOperatorKind.CX_UO_PreDec; + public bool IsIncrementDecrementOp => Opcode <= CX_UnaryOperatorKind.CX_UO_PreDec; - public bool IsPrefix => Opcode is CX_UnaryOperatorKind.CX_UO_PreInc or CX_UnaryOperatorKind.CX_UO_PreDec; + public bool IsPrefix => Opcode is CX_UnaryOperatorKind.CX_UO_PreInc or CX_UnaryOperatorKind.CX_UO_PreDec; - public bool IsPostfix => Opcode is CX_UnaryOperatorKind.CX_UO_PostInc or CX_UnaryOperatorKind.CX_UO_PostDec; + public bool IsPostfix => Opcode is CX_UnaryOperatorKind.CX_UO_PostInc or CX_UnaryOperatorKind.CX_UO_PostDec; - public CX_UnaryOperatorKind Opcode => Handle.UnaryOperatorKind; + public CX_UnaryOperatorKind Opcode => Handle.UnaryOperatorKind; - public string OpcodeStr => Handle.UnaryOperatorKindSpelling.ToString(); + public string OpcodeStr => Handle.UnaryOperatorKindSpelling.ToString(); - public Expr SubExpr => (Expr)Children[0]; - } + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Exprs/UnresolvedLookupExpr.cs b/sources/ClangSharp/Cursors/Exprs/UnresolvedLookupExpr.cs index 53d7cc9c..4bb7e155 100644 --- a/sources/ClangSharp/Cursors/Exprs/UnresolvedLookupExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/UnresolvedLookupExpr.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UnresolvedLookupExpr : OverloadExpr { - public sealed class UnresolvedLookupExpr : OverloadExpr + internal UnresolvedLookupExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr) { - internal UnresolvedLookupExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclRefExpr, CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/UnresolvedMemberExpr.cs b/sources/ClangSharp/Cursors/Exprs/UnresolvedMemberExpr.cs index e8ef4050..86b06fd5 100644 --- a/sources/ClangSharp/Cursors/Exprs/UnresolvedMemberExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/UnresolvedMemberExpr.cs @@ -5,26 +5,25 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UnresolvedMemberExpr : OverloadExpr { - public sealed class UnresolvedMemberExpr : OverloadExpr - { - private readonly Lazy _baseType; + private readonly Lazy _baseType; - internal UnresolvedMemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr) - { - Debug.Assert(NumChildren is 0 or 1); - _baseType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - } + internal UnresolvedMemberExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MemberRefExpr, CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr) + { + Debug.Assert(NumChildren is 0 or 1); + _baseType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + } - public Expr Base => (Expr)Children.SingleOrDefault(); + public Expr Base => (Expr)Children.SingleOrDefault(); - public Type BaseType => _baseType.Value; + public Type BaseType => _baseType.Value; - public bool IsImplicitAccess => NumChildren == 0; + public bool IsImplicitAccess => NumChildren == 0; - public bool IsArrow => Handle.IsArrow; + public bool IsArrow => Handle.IsArrow; - public string MemberName => Handle.Name.CString; - } + public string MemberName => Handle.Name.CString; } diff --git a/sources/ClangSharp/Cursors/Exprs/UserDefinedLiteral.cs b/sources/ClangSharp/Cursors/Exprs/UserDefinedLiteral.cs index 160578b3..48248a98 100644 --- a/sources/ClangSharp/Cursors/Exprs/UserDefinedLiteral.cs +++ b/sources/ClangSharp/Cursors/Exprs/UserDefinedLiteral.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class UserDefinedLiteral : CallExpr { - public sealed class UserDefinedLiteral : CallExpr + internal UserDefinedLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_UserDefinedLiteral) { - internal UserDefinedLiteral(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CallExpr, CX_StmtClass.CX_StmtClass_UserDefinedLiteral) - { - } } } diff --git a/sources/ClangSharp/Cursors/Exprs/VAArgExpr.cs b/sources/ClangSharp/Cursors/Exprs/VAArgExpr.cs index cbe15b59..710eb999 100644 --- a/sources/ClangSharp/Cursors/Exprs/VAArgExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/VAArgExpr.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class VAArgExpr : Expr { - public sealed class VAArgExpr : Expr + internal VAArgExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_VAArgExpr) { - internal VAArgExpr(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedExpr, CX_StmtClass.CX_StmtClass_VAArgExpr) - { - Debug.Assert(NumChildren is 1); - } - - public Expr SubExpr => (Expr)Children[0]; + Debug.Assert(NumChildren is 1); } + + public Expr SubExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Preprocessings/InclusionDirective.cs b/sources/ClangSharp/Cursors/Preprocessings/InclusionDirective.cs index b82908de..e0aa3ab9 100644 --- a/sources/ClangSharp/Cursors/Preprocessings/InclusionDirective.cs +++ b/sources/ClangSharp/Cursors/Preprocessings/InclusionDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class InclusionDirective : PreprocessingDirective { - public sealed class InclusionDirective : PreprocessingDirective + internal InclusionDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_InclusionDirective) { - internal InclusionDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_InclusionDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Preprocessings/MacroDefinitionRecord.cs b/sources/ClangSharp/Cursors/Preprocessings/MacroDefinitionRecord.cs index 2c3e9e09..e2fc4c3b 100644 --- a/sources/ClangSharp/Cursors/Preprocessings/MacroDefinitionRecord.cs +++ b/sources/ClangSharp/Cursors/Preprocessings/MacroDefinitionRecord.cs @@ -2,18 +2,17 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MacroDefinitionRecord : PreprocessingDirective { - public sealed class MacroDefinitionRecord : PreprocessingDirective + internal MacroDefinitionRecord(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MacroDefinition) { - internal MacroDefinitionRecord(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MacroDefinition) - { - } + } - public bool IsFunctionLike => Handle.IsMacroFunctionLike; + public bool IsFunctionLike => Handle.IsMacroFunctionLike; - public bool IsBuiltinMacro => Handle.IsMacroBuiltIn; + public bool IsBuiltinMacro => Handle.IsMacroBuiltIn; - public string Name => Handle.Spelling.CString; - } + public string Name => Handle.Spelling.CString; } diff --git a/sources/ClangSharp/Cursors/Preprocessings/MacroExpansion.cs b/sources/ClangSharp/Cursors/Preprocessings/MacroExpansion.cs index 4f4c780f..931594fe 100644 --- a/sources/ClangSharp/Cursors/Preprocessings/MacroExpansion.cs +++ b/sources/ClangSharp/Cursors/Preprocessings/MacroExpansion.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MacroExpansion : PreprocessedEntity { - public sealed class MacroExpansion : PreprocessedEntity - { - private readonly Lazy _definition; + private readonly Lazy _definition; - internal MacroExpansion(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MacroExpansion) - { - _definition = new Lazy(() => TranslationUnit.GetOrCreate(handle.Referenced)); - } + internal MacroExpansion(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MacroExpansion) + { + _definition = new Lazy(() => TranslationUnit.GetOrCreate(handle.Referenced)); + } - public MacroDefinitionRecord Definition => _definition.Value; + public MacroDefinitionRecord Definition => _definition.Value; - public bool IsBuiltinMacro => Handle.IsMacroBuiltIn; + public bool IsBuiltinMacro => Handle.IsMacroBuiltIn; - public string Name => Handle.Spelling.CString; - } + public string Name => Handle.Spelling.CString; } diff --git a/sources/ClangSharp/Cursors/Preprocessings/PreprocessedEntity.cs b/sources/ClangSharp/Cursors/Preprocessings/PreprocessedEntity.cs index daddbecf..13a7bd9c 100644 --- a/sources/ClangSharp/Cursors/Preprocessings/PreprocessedEntity.cs +++ b/sources/ClangSharp/Cursors/Preprocessings/PreprocessedEntity.cs @@ -3,53 +3,52 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class PreprocessedEntity : Cursor { - public class PreprocessedEntity : Cursor + private protected PreprocessedEntity(CXCursor handle, CXCursorKind expectedCursorKind) : base(handle, expectedCursorKind) { - private protected PreprocessedEntity(CXCursor handle, CXCursorKind expectedCursorKind) : base(handle, expectedCursorKind) - { - } + } - internal static new PreprocessedEntity Create(CXCursor handle) + internal static new PreprocessedEntity Create(CXCursor handle) + { + PreprocessedEntity result; + + switch (handle.Kind) { - PreprocessedEntity result; + case CXCursorKind.CXCursor_PreprocessingDirective: + { + result = new PreprocessingDirective(handle); + break; + } - switch (handle.Kind) + case CXCursorKind.CXCursor_MacroDefinition: { - case CXCursorKind.CXCursor_PreprocessingDirective: - { - result = new PreprocessingDirective(handle); - break; - } - - case CXCursorKind.CXCursor_MacroDefinition: - { - result = new MacroDefinitionRecord(handle); - break; - } - - case CXCursorKind.CXCursor_MacroExpansion: - { - result = new MacroExpansion(handle); - break; - } - - case CXCursorKind.CXCursor_InclusionDirective: - { - result = new InclusionDirective(handle); - break; - } - - default: - { - Debug.WriteLine($"Unhandled preprocessing kind: {handle.KindSpelling}."); - result = new PreprocessedEntity(handle, handle.Kind); - break; - } + result = new MacroDefinitionRecord(handle); + break; } - return result; + case CXCursorKind.CXCursor_MacroExpansion: + { + result = new MacroExpansion(handle); + break; + } + + case CXCursorKind.CXCursor_InclusionDirective: + { + result = new InclusionDirective(handle); + break; + } + + default: + { + Debug.WriteLine($"Unhandled preprocessing kind: {handle.KindSpelling}."); + result = new PreprocessedEntity(handle, handle.Kind); + break; + } } + + return result; } } diff --git a/sources/ClangSharp/Cursors/Preprocessings/PreprocessingDirective.cs b/sources/ClangSharp/Cursors/Preprocessings/PreprocessingDirective.cs index cab56c93..4993f04a 100644 --- a/sources/ClangSharp/Cursors/Preprocessings/PreprocessingDirective.cs +++ b/sources/ClangSharp/Cursors/Preprocessings/PreprocessingDirective.cs @@ -2,16 +2,15 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class PreprocessingDirective : PreprocessedEntity { - public class PreprocessingDirective : PreprocessedEntity + internal PreprocessingDirective(CXCursor handle) : this(handle, CXCursorKind.CXCursor_PreprocessingDirective) { - internal PreprocessingDirective(CXCursor handle) : this(handle, CXCursorKind.CXCursor_PreprocessingDirective) - { - } + } - private protected PreprocessingDirective(CXCursor handle, CXCursorKind expectedCursorKind) : base(handle, expectedCursorKind) - { - } + private protected PreprocessingDirective(CXCursor handle, CXCursorKind expectedCursorKind) : base(handle, expectedCursorKind) + { } } diff --git a/sources/ClangSharp/Cursors/Refs/CXXBaseSpecifier.cs b/sources/ClangSharp/Cursors/Refs/CXXBaseSpecifier.cs index 779b9f4f..c9a8d3a9 100644 --- a/sources/ClangSharp/Cursors/Refs/CXXBaseSpecifier.cs +++ b/sources/ClangSharp/Cursors/Refs/CXXBaseSpecifier.cs @@ -2,16 +2,15 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXBaseSpecifier : Ref { - public sealed class CXXBaseSpecifier : Ref + internal CXXBaseSpecifier(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXBaseSpecifier) { - internal CXXBaseSpecifier(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXBaseSpecifier) - { - } + } - public CX_CXXAccessSpecifier AccessSpecifier => Handle.CXXAccessSpecifier; + public CX_CXXAccessSpecifier AccessSpecifier => Handle.CXXAccessSpecifier; - public bool IsVirtual => Handle.IsVirtualBase; - } + public bool IsVirtual => Handle.IsVirtualBase; } diff --git a/sources/ClangSharp/Cursors/Refs/Ref.cs b/sources/ClangSharp/Cursors/Refs/Ref.cs index aea51107..9932083c 100644 --- a/sources/ClangSharp/Cursors/Refs/Ref.cs +++ b/sources/ClangSharp/Cursors/Refs/Ref.cs @@ -4,59 +4,58 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class Ref : Cursor { - public class Ref : Cursor + private readonly Lazy _referenced; + private readonly Lazy _type; + + private protected Ref(CXCursor handle, CXCursorKind expectedCursorKind) : base(handle, expectedCursorKind) { - private readonly Lazy _referenced; - private readonly Lazy _type; + _referenced = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); + } - private protected Ref(CXCursor handle, CXCursorKind expectedCursorKind) : base(handle, expectedCursorKind) - { - _referenced = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - _type = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Type)); - } + public NamedDecl Referenced => _referenced.Value; - public NamedDecl Referenced => _referenced.Value; + public Type Type => _type.Value; - public Type Type => _type.Value; + internal static new Ref Create(CXCursor handle) + { + Ref result; - internal static new Ref Create(CXCursor handle) + switch (handle.Kind) { - Ref result; + case CXCursorKind.CXCursor_CXXBaseSpecifier: + { + result = new CXXBaseSpecifier(handle); + break; + } - switch (handle.Kind) + case CXCursorKind.CXCursor_ObjCSuperClassRef: + case CXCursorKind.CXCursor_ObjCProtocolRef: + case CXCursorKind.CXCursor_ObjCClassRef: + case CXCursorKind.CXCursor_TypeRef: + case CXCursorKind.CXCursor_TemplateRef: + case CXCursorKind.CXCursor_NamespaceRef: + case CXCursorKind.CXCursor_MemberRef: + case CXCursorKind.CXCursor_LabelRef: + case CXCursorKind.CXCursor_OverloadedDeclRef: + case CXCursorKind.CXCursor_VariableRef: { - case CXCursorKind.CXCursor_CXXBaseSpecifier: - { - result = new CXXBaseSpecifier(handle); - break; - } - - case CXCursorKind.CXCursor_ObjCSuperClassRef: - case CXCursorKind.CXCursor_ObjCProtocolRef: - case CXCursorKind.CXCursor_ObjCClassRef: - case CXCursorKind.CXCursor_TypeRef: - case CXCursorKind.CXCursor_TemplateRef: - case CXCursorKind.CXCursor_NamespaceRef: - case CXCursorKind.CXCursor_MemberRef: - case CXCursorKind.CXCursor_LabelRef: - case CXCursorKind.CXCursor_OverloadedDeclRef: - case CXCursorKind.CXCursor_VariableRef: - { - result = new Ref(handle, handle.Kind); - break; - } - - default: - { - Debug.WriteLine($"Unhandled reference kind: {handle.KindSpelling}."); - result = new Ref(handle, handle.Kind); - break; - } + result = new Ref(handle, handle.Kind); + break; } - return result; + default: + { + Debug.WriteLine($"Unhandled reference kind: {handle.KindSpelling}."); + result = new Ref(handle, handle.Kind); + break; + } } + + return result; } } diff --git a/sources/ClangSharp/Cursors/Stmts/AsmStmt.cs b/sources/ClangSharp/Cursors/Stmts/AsmStmt.cs index 7ebc022b..bad3d9bd 100644 --- a/sources/ClangSharp/Cursors/Stmts/AsmStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/AsmStmt.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class AsmStmt : Stmt { - public class AsmStmt : Stmt + private protected AsmStmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected AsmStmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastAsmStmt or < CX_StmtClass.CX_StmtClass_FirstAsmStmt) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastAsmStmt or < CX_StmtClass.CX_StmtClass_FirstAsmStmt) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Stmts/AttributedStmt.cs b/sources/ClangSharp/Cursors/Stmts/AttributedStmt.cs index 34a709c1..81a02019 100644 --- a/sources/ClangSharp/Cursors/Stmts/AttributedStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/AttributedStmt.cs @@ -5,32 +5,31 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class AttributedStmt : ValueStmt { - public sealed class AttributedStmt : ValueStmt - { - private readonly Lazy> _attrs; + private readonly Lazy> _attrs; - internal AttributedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_AttributedStmt) - { - Debug.Assert(NumChildren == 1); + internal AttributedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_AttributedStmt) + { + Debug.Assert(NumChildren == 1); - _attrs = new Lazy>(() => { - var numAttrs = Handle.NumAttrs; - var attrs = new List(numAttrs); + _attrs = new Lazy>(() => { + var numAttrs = Handle.NumAttrs; + var attrs = new List(numAttrs); - for (var i = 0; i < numAttrs; i++) - { - var attr = TranslationUnit.GetOrCreate(Handle.GetAttr(unchecked((uint)i))); - attrs.Add(attr); - } + for (var i = 0; i < numAttrs; i++) + { + var attr = TranslationUnit.GetOrCreate(Handle.GetAttr(unchecked((uint)i))); + attrs.Add(attr); + } - return attrs; - }); - } + return attrs; + }); + } - public IReadOnlyList Attrs => _attrs.Value; + public IReadOnlyList Attrs => _attrs.Value; - public Stmt SubStmt => Children[0]; - } + public Stmt SubStmt => Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/BreakStmt.cs b/sources/ClangSharp/Cursors/Stmts/BreakStmt.cs index 0a928000..c157befb 100644 --- a/sources/ClangSharp/Cursors/Stmts/BreakStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/BreakStmt.cs @@ -3,13 +3,12 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class BreakStmt : Stmt { - public sealed class BreakStmt : Stmt + internal BreakStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BreakStmt, CX_StmtClass.CX_StmtClass_BreakStmt) { - internal BreakStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_BreakStmt, CX_StmtClass.CX_StmtClass_BreakStmt) - { - Debug.Assert(NumChildren is 0); - } + Debug.Assert(NumChildren is 0); } } diff --git a/sources/ClangSharp/Cursors/Stmts/CXXCatchStmt.cs b/sources/ClangSharp/Cursors/Stmts/CXXCatchStmt.cs index f006d61f..28adad05 100644 --- a/sources/ClangSharp/Cursors/Stmts/CXXCatchStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CXXCatchStmt.cs @@ -4,25 +4,24 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXCatchStmt : Stmt { - public sealed class CXXCatchStmt : Stmt - { - private readonly Lazy _caughtType; - private readonly Lazy _exceptionDecl; + private readonly Lazy _caughtType; + private readonly Lazy _exceptionDecl; - internal CXXCatchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXCatchStmt, CX_StmtClass.CX_StmtClass_CXXCatchStmt) - { - Debug.Assert(NumChildren is 1); + internal CXXCatchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXCatchStmt, CX_StmtClass.CX_StmtClass_CXXCatchStmt) + { + Debug.Assert(NumChildren is 1); - _caughtType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); - _exceptionDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + _caughtType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + _exceptionDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public Type CaughtType => _caughtType.Value; + public Type CaughtType => _caughtType.Value; - public VarDecl ExceptionDecl => _exceptionDecl.Value; + public VarDecl ExceptionDecl => _exceptionDecl.Value; - public Stmt HandlerBlock => Children[0]; - } + public Stmt HandlerBlock => Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/CXXForRangeStmt.cs b/sources/ClangSharp/Cursors/Stmts/CXXForRangeStmt.cs index 9cfb2105..8c8a3aa5 100644 --- a/sources/ClangSharp/Cursors/Stmts/CXXForRangeStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CXXForRangeStmt.cs @@ -3,33 +3,32 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXForRangeStmt : Stmt { - public sealed class CXXForRangeStmt : Stmt + internal CXXForRangeStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXForRangeStmt, CX_StmtClass.CX_StmtClass_CXXForRangeStmt) { - internal CXXForRangeStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXForRangeStmt, CX_StmtClass.CX_StmtClass_CXXForRangeStmt) - { - Debug.Assert(NumChildren is 8); - } + Debug.Assert(NumChildren is 8); + } - public DeclStmt BeginStmt => (DeclStmt)Children[2]; + public DeclStmt BeginStmt => (DeclStmt)Children[2]; - public Stmt Body => Children[7]; + public Stmt Body => Children[7]; - public Expr Cond => (Expr)Children[4]; + public Expr Cond => (Expr)Children[4]; - public DeclStmt EndStmt => (DeclStmt)Children[3]; + public DeclStmt EndStmt => (DeclStmt)Children[3]; - public Expr Inc => (Expr)Children[5]; + public Expr Inc => (Expr)Children[5]; - public VarDecl LoopVariable => (VarDecl)LoopVarStmt.SingleDecl; + public VarDecl LoopVariable => (VarDecl)LoopVarStmt.SingleDecl; - public DeclStmt LoopVarStmt => (DeclStmt)Children[6]; + public DeclStmt LoopVarStmt => (DeclStmt)Children[6]; - public Stmt Init => Children[0]; + public Stmt Init => Children[0]; - public Expr RangeInit => ((VarDecl)RangeStmt.SingleDecl).Init; + public Expr RangeInit => ((VarDecl)RangeStmt.SingleDecl).Init; - public DeclStmt RangeStmt => (DeclStmt)Children[1]; - } + public DeclStmt RangeStmt => (DeclStmt)Children[1]; } diff --git a/sources/ClangSharp/Cursors/Stmts/CXXTryStmt.cs b/sources/ClangSharp/Cursors/Stmts/CXXTryStmt.cs index c58e59b1..6ca676e2 100644 --- a/sources/ClangSharp/Cursors/Stmts/CXXTryStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CXXTryStmt.cs @@ -6,22 +6,21 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CXXTryStmt : Stmt { - public sealed class CXXTryStmt : Stmt - { - private readonly Lazy> _handlers; + private readonly Lazy> _handlers; - internal CXXTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXTryStmt, CX_StmtClass.CX_StmtClass_CXXTryStmt) - { - Debug.Assert(NumChildren is >= 1); - _handlers = new Lazy>(() => Children.Skip(1).Cast().ToList()); - } + internal CXXTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CXXTryStmt, CX_StmtClass.CX_StmtClass_CXXTryStmt) + { + Debug.Assert(NumChildren is >= 1); + _handlers = new Lazy>(() => Children.Skip(1).Cast().ToList()); + } - public IReadOnlyList Handlers => _handlers.Value; + public IReadOnlyList Handlers => _handlers.Value; - public uint NumHandlers => (uint)(Children.Count - 1); + public uint NumHandlers => (uint)(Children.Count - 1); - public CompoundStmt TryBlock => (CompoundStmt)Children[0]; - } + public CompoundStmt TryBlock => (CompoundStmt)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/CapturedStmt.Capture.cs b/sources/ClangSharp/Cursors/Stmts/CapturedStmt.Capture.cs index 58c24ec0..0ff8f985 100644 --- a/sources/ClangSharp/Cursors/Stmts/CapturedStmt.Capture.cs +++ b/sources/ClangSharp/Cursors/Stmts/CapturedStmt.Capture.cs @@ -3,35 +3,34 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public partial class CapturedStmt { - public partial class CapturedStmt + public sealed class Capture { - public sealed class Capture - { - private readonly CapturedStmt _parentStmt; - private readonly uint _index; - private readonly Lazy _capturedVar; + private readonly CapturedStmt _parentStmt; + private readonly uint _index; + private readonly Lazy _capturedVar; - internal Capture(CapturedStmt parentStmt, uint index) - { - _parentStmt = parentStmt; - _index = index; + internal Capture(CapturedStmt parentStmt, uint index) + { + _parentStmt = parentStmt; + _index = index; - _capturedVar = new Lazy(() => _parentStmt.TranslationUnit.GetOrCreate(_parentStmt.Handle.GetCapturedVar(_index))); - } + _capturedVar = new Lazy(() => _parentStmt.TranslationUnit.GetOrCreate(_parentStmt.Handle.GetCapturedVar(_index))); + } - public VarDecl CapturedVar => _capturedVar.Value; + public VarDecl CapturedVar => _capturedVar.Value; - public CX_VariableCaptureKind CaptureKind => _parentStmt.Handle.GetCaptureKind(_index); + public CX_VariableCaptureKind CaptureKind => _parentStmt.Handle.GetCaptureKind(_index); - public bool CapturesThis => CaptureKind == CX_VariableCaptureKind.CX_VCK_This; + public bool CapturesThis => CaptureKind == CX_VariableCaptureKind.CX_VCK_This; - public bool CapturesVariable => CaptureKind == CX_VariableCaptureKind.CX_VCK_ByRef; + public bool CapturesVariable => CaptureKind == CX_VariableCaptureKind.CX_VCK_ByRef; - public bool CapturesVariableByCopy => CaptureKind == CX_VariableCaptureKind.CX_VCK_ByCopy; + public bool CapturesVariableByCopy => CaptureKind == CX_VariableCaptureKind.CX_VCK_ByCopy; - public bool CapturesVariableArrayType => CaptureKind == CX_VariableCaptureKind.CX_VCK_VLAType; - } + public bool CapturesVariableArrayType => CaptureKind == CX_VariableCaptureKind.CX_VCK_VLAType; } } diff --git a/sources/ClangSharp/Cursors/Stmts/CapturedStmt.cs b/sources/ClangSharp/Cursors/Stmts/CapturedStmt.cs index 801c69ed..a35e23fa 100644 --- a/sources/ClangSharp/Cursors/Stmts/CapturedStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CapturedStmt.cs @@ -5,67 +5,66 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed partial class CapturedStmt : Stmt { - public sealed partial class CapturedStmt : Stmt - { - private readonly Lazy _capturedDecl; - private readonly Lazy _capturedRecordDecl; - private readonly Lazy _captureStmt; - private readonly Lazy> _captures; - private readonly Lazy> _captureInits; + private readonly Lazy _capturedDecl; + private readonly Lazy _capturedRecordDecl; + private readonly Lazy _captureStmt; + private readonly Lazy> _captures; + private readonly Lazy> _captureInits; - internal CapturedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_CapturedStmt) - { - _capturedDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CapturedDecl)); - _capturedRecordDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CapturedRecordDecl)); - _captureStmt = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CapturedStmt)); + internal CapturedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_CapturedStmt) + { + _capturedDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CapturedDecl)); + _capturedRecordDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CapturedRecordDecl)); + _captureStmt = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CapturedStmt)); - _captures = new Lazy>(() => { - var numCaptures = Handle.NumCaptures; - var captures = new List(numCaptures); + _captures = new Lazy>(() => { + var numCaptures = Handle.NumCaptures; + var captures = new List(numCaptures); - for (var i = 0; i < numCaptures; i++) - { - var capture = new Capture(this, unchecked((uint)i)); - captures.Add(capture); - } + for (var i = 0; i < numCaptures; i++) + { + var capture = new Capture(this, unchecked((uint)i)); + captures.Add(capture); + } - return captures; - }); + return captures; + }); - _captureInits = new Lazy>(() => Children.Cast().ToList()); - } + _captureInits = new Lazy>(() => Children.Cast().ToList()); + } - public CapturedDecl CapturedDecl => _capturedDecl.Value; + public CapturedDecl CapturedDecl => _capturedDecl.Value; - public RecordDecl CapturedRecordDecl => _capturedRecordDecl.Value; + public RecordDecl CapturedRecordDecl => _capturedRecordDecl.Value; - public CX_CapturedRegionKind CapturedRegionKind => Handle.CapturedRegionKind; + public CX_CapturedRegionKind CapturedRegionKind => Handle.CapturedRegionKind; - public Stmt CaptureStmt => _captureStmt.Value; + public Stmt CaptureStmt => _captureStmt.Value; - public IReadOnlyList Captures => _captures.Value; + public IReadOnlyList Captures => _captures.Value; - public uint CaptureSize => unchecked((uint)Handle.NumCaptures); + public uint CaptureSize => unchecked((uint)Handle.NumCaptures); - public IReadOnlyList CaptureInits => _captureInits.Value; + public IReadOnlyList CaptureInits => _captureInits.Value; - public bool CapturesVariable(VarDecl var) + public bool CapturesVariable(VarDecl var) + { + foreach (var i in Captures) { - foreach (var i in Captures) + if (!i.CapturesVariable && !i.CapturesVariableByCopy) + { + continue; + } + + if (i.CapturedVar.CanonicalDecl == var.CanonicalDecl) { - if (!i.CapturesVariable && !i.CapturesVariableByCopy) - { - continue; - } - - if (i.CapturedVar.CanonicalDecl == var.CanonicalDecl) - { - return true; - } + return true; } - return false; } + return false; } } diff --git a/sources/ClangSharp/Cursors/Stmts/CaseStmt.cs b/sources/ClangSharp/Cursors/Stmts/CaseStmt.cs index 6b11fa57..37757673 100644 --- a/sources/ClangSharp/Cursors/Stmts/CaseStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CaseStmt.cs @@ -3,27 +3,26 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CaseStmt : SwitchCase { - public sealed class CaseStmt : SwitchCase + internal CaseStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CaseStmt, CX_StmtClass.CX_StmtClass_CaseStmt) { - internal CaseStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CaseStmt, CX_StmtClass.CX_StmtClass_CaseStmt) - { - Debug.Assert(NumChildren is 2 or 3); - } + Debug.Assert(NumChildren is 2 or 3); + } - public bool CaseStmtIsGNURange => NumChildren is 3; + public bool CaseStmtIsGNURange => NumChildren is 3; - public Expr LHS => (Expr)Children[LHSOffset]; + public Expr LHS => (Expr)Children[LHSOffset]; - public Expr RHS => CaseStmtIsGNURange ? (Expr)Children[RHSOffset] : null; + public Expr RHS => CaseStmtIsGNURange ? (Expr)Children[RHSOffset] : null; - public new Stmt SubStmt => Children[SubStmtOffset]; + public new Stmt SubStmt => Children[SubStmtOffset]; - private static int LHSOffset => 0; + private static int LHSOffset => 0; - private int RHSOffset => LHSOffset + (CaseStmtIsGNURange ? 1 : 0); + private int RHSOffset => LHSOffset + (CaseStmtIsGNURange ? 1 : 0); - private int SubStmtOffset => RHSOffset + 1; - } + private int SubStmtOffset => RHSOffset + 1; } diff --git a/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs b/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs index 4b76fde0..a835bb16 100644 --- a/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs @@ -4,35 +4,34 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CompoundStmt : Stmt { - public sealed class CompoundStmt : Stmt + public CompoundStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundStmt, CX_StmtClass.CX_StmtClass_CompoundStmt) { - public CompoundStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_CompoundStmt, CX_StmtClass.CX_StmtClass_CompoundStmt) - { - } + } - public IReadOnlyList Body => Children; + public IReadOnlyList Body => Children; - public Stmt BodyBack => Children.LastOrDefault(); + public Stmt BodyBack => Children.LastOrDefault(); - public Stmt BodyFront => Children.FirstOrDefault(); + public Stmt BodyFront => Children.FirstOrDefault(); - public uint Size => unchecked((uint)NumChildren); + public uint Size => unchecked((uint)NumChildren); - public Stmt StmtExprResult + public Stmt StmtExprResult + { + get { - get + foreach (var b in Body.Reverse()) { - foreach (var b in Body.Reverse()) + if (b is not NullStmt) { - if (b is not NullStmt) - { - return b; - } + return b; } - return BodyBack; } + return BodyBack; } } } diff --git a/sources/ClangSharp/Cursors/Stmts/ContinueStmt.cs b/sources/ClangSharp/Cursors/Stmts/ContinueStmt.cs index c01fa22b..aeb5dbe8 100644 --- a/sources/ClangSharp/Cursors/Stmts/ContinueStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ContinueStmt.cs @@ -3,13 +3,12 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ContinueStmt : Stmt { - public sealed class ContinueStmt : Stmt + internal ContinueStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ContinueStmt, CX_StmtClass.CX_StmtClass_ContinueStmt) { - internal ContinueStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ContinueStmt, CX_StmtClass.CX_StmtClass_ContinueStmt) - { - Debug.Assert(NumChildren is 0); - } + Debug.Assert(NumChildren is 0); } } diff --git a/sources/ClangSharp/Cursors/Stmts/CoreturnStmt.cs b/sources/ClangSharp/Cursors/Stmts/CoreturnStmt.cs index 18356be3..86abf723 100644 --- a/sources/ClangSharp/Cursors/Stmts/CoreturnStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CoreturnStmt.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CoreturnStmt : Stmt { - public sealed class CoreturnStmt : Stmt + internal CoreturnStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_CoreturnStmt) { - internal CoreturnStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_CoreturnStmt) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/CoroutineBodyStmt.cs b/sources/ClangSharp/Cursors/Stmts/CoroutineBodyStmt.cs index 92a16c91..2dc1b6da 100644 --- a/sources/ClangSharp/Cursors/Stmts/CoroutineBodyStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CoroutineBodyStmt.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class CoroutineBodyStmt : Stmt { - public sealed class CoroutineBodyStmt : Stmt + internal CoroutineBodyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_CoroutineBodyStmt) { - internal CoroutineBodyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_CoroutineBodyStmt) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/DeclStmt.cs b/sources/ClangSharp/Cursors/Stmts/DeclStmt.cs index 9c08fc02..2cc71bd1 100644 --- a/sources/ClangSharp/Cursors/Stmts/DeclStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/DeclStmt.cs @@ -5,32 +5,31 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class DeclStmt : Stmt - { - private readonly Lazy> _decls; +namespace ClangSharp; - internal DeclStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclStmt, CX_StmtClass.CX_StmtClass_DeclStmt) - { - _decls = new Lazy>(() => { - var numDecls = Handle.NumDecls; - var decls = new List(numDecls); - - for (var i = 0; i < numDecls; i++) - { - var decl = TranslationUnit.GetOrCreate(Handle.GetDecl(unchecked((uint)i))); - decls.Add(decl); - } +public sealed class DeclStmt : Stmt +{ + private readonly Lazy> _decls; - return decls; - }); - } + internal DeclStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DeclStmt, CX_StmtClass.CX_StmtClass_DeclStmt) + { + _decls = new Lazy>(() => { + var numDecls = Handle.NumDecls; + var decls = new List(numDecls); + + for (var i = 0; i < numDecls; i++) + { + var decl = TranslationUnit.GetOrCreate(Handle.GetDecl(unchecked((uint)i))); + decls.Add(decl); + } + + return decls; + }); + } - public IReadOnlyList Decls => _decls.Value; + public IReadOnlyList Decls => _decls.Value; - public bool IsSingleDecl => Decls.Count == 1; + public bool IsSingleDecl => Decls.Count == 1; - public Decl SingleDecl => Decls.SingleOrDefault(); - } + public Decl SingleDecl => Decls.SingleOrDefault(); } diff --git a/sources/ClangSharp/Cursors/Stmts/DefaultStmt.cs b/sources/ClangSharp/Cursors/Stmts/DefaultStmt.cs index 0e46fff0..0cb9a465 100644 --- a/sources/ClangSharp/Cursors/Stmts/DefaultStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/DefaultStmt.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DefaultStmt : SwitchCase { - public sealed class DefaultStmt : SwitchCase + internal DefaultStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DefaultStmt, CX_StmtClass.CX_StmtClass_DefaultStmt) { - internal DefaultStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DefaultStmt, CX_StmtClass.CX_StmtClass_DefaultStmt) - { - Debug.Assert(NumChildren is 1); - } - - public new Stmt SubStmt => Children[0]; + Debug.Assert(NumChildren is 1); } + + public new Stmt SubStmt => Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/DoStmt.cs b/sources/ClangSharp/Cursors/Stmts/DoStmt.cs index 867ce093..ded022ba 100644 --- a/sources/ClangSharp/Cursors/Stmts/DoStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/DoStmt.cs @@ -3,17 +3,16 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DoStmt : Stmt { - public sealed class DoStmt : Stmt + internal DoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DoStmt, CX_StmtClass.CX_StmtClass_DoStmt) { - internal DoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_DoStmt, CX_StmtClass.CX_StmtClass_DoStmt) - { - Debug.Assert(NumChildren is 2); - } + Debug.Assert(NumChildren is 2); + } - public Stmt Body => Children[0]; + public Stmt Body => Children[0]; - public Expr Cond => (Expr)Children[1]; - } + public Expr Cond => (Expr)Children[1]; } diff --git a/sources/ClangSharp/Cursors/Stmts/ForStmt.cs b/sources/ClangSharp/Cursors/Stmts/ForStmt.cs index 37b52120..e4d8c23f 100644 --- a/sources/ClangSharp/Cursors/Stmts/ForStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ForStmt.cs @@ -3,25 +3,24 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ForStmt : Stmt { - public sealed class ForStmt : Stmt + internal ForStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ForStmt, CX_StmtClass.CX_StmtClass_ForStmt) { - internal ForStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ForStmt, CX_StmtClass.CX_StmtClass_ForStmt) - { - Debug.Assert(NumChildren is 5); - } + Debug.Assert(NumChildren is 5); + } - public Stmt Body => Children[4]; + public Stmt Body => Children[4]; - public Expr Cond => (Expr)Children[2]; + public Expr Cond => (Expr)Children[2]; - public VarDecl ConditionVariable => (VarDecl)ConditionVariableDeclStmt?.SingleDecl; + public VarDecl ConditionVariable => (VarDecl)ConditionVariableDeclStmt?.SingleDecl; - public DeclStmt ConditionVariableDeclStmt => (DeclStmt)Children[1]; + public DeclStmt ConditionVariableDeclStmt => (DeclStmt)Children[1]; - public Expr Inc => (Expr)Children[3]; + public Expr Inc => (Expr)Children[3]; - public Stmt Init => Children[0]; - } + public Stmt Init => Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/GCCAsmStmt.cs b/sources/ClangSharp/Cursors/Stmts/GCCAsmStmt.cs index 6053b377..0850ecc3 100644 --- a/sources/ClangSharp/Cursors/Stmts/GCCAsmStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/GCCAsmStmt.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class GCCAsmStmt : AsmStmt { - public sealed class GCCAsmStmt : AsmStmt + internal GCCAsmStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GCCAsmStmt, CX_StmtClass.CX_StmtClass_GCCAsmStmt) { - internal GCCAsmStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GCCAsmStmt, CX_StmtClass.CX_StmtClass_GCCAsmStmt) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/GotoStmt.cs b/sources/ClangSharp/Cursors/Stmts/GotoStmt.cs index 0324e3c9..7c92e9ff 100644 --- a/sources/ClangSharp/Cursors/Stmts/GotoStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/GotoStmt.cs @@ -4,18 +4,17 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class GotoStmt : Stmt - { - private readonly Lazy _label; +namespace ClangSharp; - internal GotoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GotoStmt, CX_StmtClass.CX_StmtClass_GotoStmt) - { - Debug.Assert(NumChildren is 0); - _label = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } +public sealed class GotoStmt : Stmt +{ + private readonly Lazy _label; - public LabelDecl Label => _label.Value; + internal GotoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_GotoStmt, CX_StmtClass.CX_StmtClass_GotoStmt) + { + Debug.Assert(NumChildren is 0); + _label = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); } + + public LabelDecl Label => _label.Value; } diff --git a/sources/ClangSharp/Cursors/Stmts/IfStmt.cs b/sources/ClangSharp/Cursors/Stmts/IfStmt.cs index 805b8d2d..c1ad340e 100644 --- a/sources/ClangSharp/Cursors/Stmts/IfStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/IfStmt.cs @@ -3,45 +3,44 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class IfStmt : Stmt { - public sealed class IfStmt : Stmt + internal IfStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IfStmt, CX_StmtClass.CX_StmtClass_IfStmt) { - internal IfStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IfStmt, CX_StmtClass.CX_StmtClass_IfStmt) - { - Debug.Assert(NumChildren is >= 2 and <= 4); - } + Debug.Assert(NumChildren is >= 2 and <= 4); + } - public Expr Cond => (Expr)Children[CondOffset]; + public Expr Cond => (Expr)Children[CondOffset]; - public VarDecl ConditionVariable => (VarDecl)ConditionVariableDeclStmt?.SingleDecl; + public VarDecl ConditionVariable => (VarDecl)ConditionVariableDeclStmt?.SingleDecl; - public DeclStmt ConditionVariableDeclStmt => HasVarStorage ? (DeclStmt)Children[VarOffset] : null; + public DeclStmt ConditionVariableDeclStmt => HasVarStorage ? (DeclStmt)Children[VarOffset] : null; - public Stmt Else => HasElseStorage ? Children[ElseOffset] : null; + public Stmt Else => HasElseStorage ? Children[ElseOffset] : null; - public bool HasElseStorage => Handle.HasElseStorage; + public bool HasElseStorage => Handle.HasElseStorage; - public bool HasInitStorage => Handle.HasInitStorage; + public bool HasInitStorage => Handle.HasInitStorage; - public bool HasVarStorage => Handle.HasVarStorage; + public bool HasVarStorage => Handle.HasVarStorage; - public Stmt Init => HasInitStorage ? Children[InitOffset] : null; + public Stmt Init => HasInitStorage ? Children[InitOffset] : null; - public bool IsConstexpr => Handle.IsConstexpr; + public bool IsConstexpr => Handle.IsConstexpr; - public bool IsObjcAvailabilityCheck => Cond is ObjCAvailabilityCheckExpr; + public bool IsObjcAvailabilityCheck => Cond is ObjCAvailabilityCheckExpr; - public Stmt Then => Children[ThenOffset]; + public Stmt Then => Children[ThenOffset]; - private int CondOffset => VarOffset + (HasVarStorage ? 1 : 0); + private int CondOffset => VarOffset + (HasVarStorage ? 1 : 0); - private int ElseOffset => CondOffset + 2; + private int ElseOffset => CondOffset + 2; - private static int InitOffset => 0; + private static int InitOffset => 0; - private int ThenOffset => CondOffset + 1; + private int ThenOffset => CondOffset + 1; - private int VarOffset => InitOffset + (HasInitStorage ? 1 : 0); - } + private int VarOffset => InitOffset + (HasInitStorage ? 1 : 0); } diff --git a/sources/ClangSharp/Cursors/Stmts/IndirectGotoStmt.cs b/sources/ClangSharp/Cursors/Stmts/IndirectGotoStmt.cs index c5c19c5c..6a1cda6c 100644 --- a/sources/ClangSharp/Cursors/Stmts/IndirectGotoStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/IndirectGotoStmt.cs @@ -4,20 +4,19 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class IndirectGotoStmt : Stmt { - public sealed class IndirectGotoStmt : Stmt - { - private readonly Lazy _constantTarget; + private readonly Lazy _constantTarget; - internal IndirectGotoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IndirectGotoStmt, CX_StmtClass.CX_StmtClass_IndirectGotoStmt) - { - Debug.Assert(NumChildren is 1); - _constantTarget = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal IndirectGotoStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_IndirectGotoStmt, CX_StmtClass.CX_StmtClass_IndirectGotoStmt) + { + Debug.Assert(NumChildren is 1); + _constantTarget = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public LabelDecl ConstantTarget => _constantTarget.Value; + public LabelDecl ConstantTarget => _constantTarget.Value; - public Expr Target => (Expr)Children[0]; - } + public Expr Target => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/LabelStmt.cs b/sources/ClangSharp/Cursors/Stmts/LabelStmt.cs index 18d3774e..906f9406 100644 --- a/sources/ClangSharp/Cursors/Stmts/LabelStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/LabelStmt.cs @@ -4,22 +4,21 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class LabelStmt : ValueStmt { - public sealed class LabelStmt : ValueStmt - { - private readonly Lazy _decl; + private readonly Lazy _decl; - internal LabelStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LabelStmt, CX_StmtClass.CX_StmtClass_LabelStmt) - { - Debug.Assert(NumChildren is 1); - _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal LabelStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_LabelStmt, CX_StmtClass.CX_StmtClass_LabelStmt) + { + Debug.Assert(NumChildren is 1); + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public LabelDecl Decl => _decl.Value; + public LabelDecl Decl => _decl.Value; - public string Name => Handle.Name.CString; + public string Name => Handle.Name.CString; - public Stmt SubStmt => Children[0]; - } + public Stmt SubStmt => Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/MSAsmStmt.cs b/sources/ClangSharp/Cursors/Stmts/MSAsmStmt.cs index 638edc3f..52d6c7c2 100644 --- a/sources/ClangSharp/Cursors/Stmts/MSAsmStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/MSAsmStmt.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MSAsmStmt : AsmStmt { - public sealed class MSAsmStmt : AsmStmt + internal MSAsmStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MSAsmStmt, CX_StmtClass.CX_StmtClass_MSAsmStmt) { - internal MSAsmStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_MSAsmStmt, CX_StmtClass.CX_StmtClass_MSAsmStmt) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/MSDependentExistsStmt.cs b/sources/ClangSharp/Cursors/Stmts/MSDependentExistsStmt.cs index 0dde2d2f..62466eb6 100644 --- a/sources/ClangSharp/Cursors/Stmts/MSDependentExistsStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/MSDependentExistsStmt.cs @@ -3,21 +3,20 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MSDependentExistsStmt : Stmt { - public sealed class MSDependentExistsStmt : Stmt + internal MSDependentExistsStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_MSDependentExistsStmt) { - internal MSDependentExistsStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_UnexposedStmt, CX_StmtClass.CX_StmtClass_MSDependentExistsStmt) - { - Debug.Assert(NumChildren is 1); - } + Debug.Assert(NumChildren is 1); + } - public bool IsIfExists => Handle.IsIfExists; + public bool IsIfExists => Handle.IsIfExists; - public bool IsIfNotExists => !IsIfExists; + public bool IsIfNotExists => !IsIfExists; - public string Name => Handle.Name.CString; + public string Name => Handle.Name.CString; - public CompoundStmt SubStmt => (CompoundStmt)Children[0]; - } + public CompoundStmt SubStmt => (CompoundStmt)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/NullStmt.cs b/sources/ClangSharp/Cursors/Stmts/NullStmt.cs index 8eadb273..9a1c4378 100644 --- a/sources/ClangSharp/Cursors/Stmts/NullStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/NullStmt.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class NullStmt : Stmt { - public sealed class NullStmt : Stmt + internal NullStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NullStmt, CX_StmtClass.CX_StmtClass_NullStmt) { - internal NullStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_NullStmt, CX_StmtClass.CX_StmtClass_NullStmt) - { - Debug.Assert(NumChildren is 0); - } - - public bool HasLeadingEmptyMacro => Handle.HasLeadingEmptyMacro; + Debug.Assert(NumChildren is 0); } + + public bool HasLeadingEmptyMacro => Handle.HasLeadingEmptyMacro; } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPAtomicDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPAtomicDirective.cs index 27114ea2..0b4b34e6 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPAtomicDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPAtomicDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPAtomicDirective : OMPExecutableDirective { - public sealed class OMPAtomicDirective : OMPExecutableDirective + internal OMPAtomicDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPAtomicDirective, CX_StmtClass.CX_StmtClass_OMPAtomicDirective) { - internal OMPAtomicDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPAtomicDirective, CX_StmtClass.CX_StmtClass_OMPAtomicDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPBarrierDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPBarrierDirective.cs index c556c174..41c8ebf0 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPBarrierDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPBarrierDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPBarrierDirective : OMPExecutableDirective { - public sealed class OMPBarrierDirective : OMPExecutableDirective + internal OMPBarrierDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPBarrierDirective, CX_StmtClass.CX_StmtClass_OMPBarrierDirective) { - internal OMPBarrierDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPBarrierDirective, CX_StmtClass.CX_StmtClass_OMPBarrierDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPCancelDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPCancelDirective.cs index 140abc19..955e0bf9 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPCancelDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPCancelDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPCancelDirective : OMPExecutableDirective { - public sealed class OMPCancelDirective : OMPExecutableDirective + internal OMPCancelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCancelDirective, CX_StmtClass.CX_StmtClass_OMPCancelDirective) { - internal OMPCancelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCancelDirective, CX_StmtClass.CX_StmtClass_OMPCancelDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPCancellationPointDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPCancellationPointDirective.cs index e7cc9edf..c3d3f371 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPCancellationPointDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPCancellationPointDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPCancellationPointDirective : OMPExecutableDirective { - public sealed class OMPCancellationPointDirective : OMPExecutableDirective + internal OMPCancellationPointDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCancellationPointDirective, CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective) { - internal OMPCancellationPointDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCancellationPointDirective, CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPCanonicalLoop.cs b/sources/ClangSharp/Cursors/Stmts/OMPCanonicalLoop.cs index f1facb08..2f492eec 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPCanonicalLoop.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPCanonicalLoop.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPCanonicalLoop : Stmt { - public sealed class OMPCanonicalLoop : Stmt + internal OMPCanonicalLoop(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCanonicalLoop, CX_StmtClass.CX_StmtClass_OMPCanonicalLoop) { - internal OMPCanonicalLoop(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCanonicalLoop, CX_StmtClass.CX_StmtClass_OMPCanonicalLoop) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPCriticalDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPCriticalDirective.cs index 79027c33..9e5f6cb3 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPCriticalDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPCriticalDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPCriticalDirective : OMPExecutableDirective { - public sealed class OMPCriticalDirective : OMPExecutableDirective + internal OMPCriticalDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCriticalDirective, CX_StmtClass.CX_StmtClass_OMPCriticalDirective) { - internal OMPCriticalDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPCriticalDirective, CX_StmtClass.CX_StmtClass_OMPCriticalDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDepobjDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDepobjDirective.cs index 57ed4f9a..d265d39f 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDepobjDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDepobjDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPDepobjDirective : OMPExecutableDirective { - public sealed class OMPDepobjDirective : OMPExecutableDirective + internal OMPDepobjDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDepobjDirective, CX_StmtClass.CX_StmtClass_OMPDepobjDirective) { - internal OMPDepobjDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDepobjDirective, CX_StmtClass.CX_StmtClass_OMPDepobjDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDispatchDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDispatchDirective.cs index 169f4757..2ceacc22 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDispatchDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDispatchDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPDispatchDirective : OMPExecutableDirective { - public sealed class OMPDispatchDirective : OMPExecutableDirective + internal OMPDispatchDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDispatchDirective, CX_StmtClass.CX_StmtClass_OMPDispatchDirective) { - internal OMPDispatchDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDispatchDirective, CX_StmtClass.CX_StmtClass_OMPDispatchDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDistributeDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDistributeDirective.cs index d4aef4f0..b9aa22d8 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDistributeDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDistributeDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPDistributeDirective : OMPLoopDirective { - public sealed class OMPDistributeDirective : OMPLoopDirective + internal OMPDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeDirective, CX_StmtClass.CX_StmtClass_OMPDistributeDirective) { - internal OMPDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeDirective, CX_StmtClass.CX_StmtClass_OMPDistributeDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForDirective.cs index caaa411a..9c12b1b1 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPDistributeParallelForDirective : OMPLoopDirective { - public sealed class OMPDistributeParallelForDirective : OMPLoopDirective + internal OMPDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeParallelForDirective, CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective) { - internal OMPDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeParallelForDirective, CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForSimdDirective.cs index af0c81ac..716614b8 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDistributeParallelForSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPDistributeParallelForSimdDirective : OMPLoopDirective { - public sealed class OMPDistributeParallelForSimdDirective : OMPLoopDirective + internal OMPDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective) { - internal OMPDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPDistributeSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPDistributeSimdDirective.cs index 547c431d..ab8efb3c 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPDistributeSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPDistributeSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPDistributeSimdDirective : OMPLoopDirective { - public sealed class OMPDistributeSimdDirective : OMPLoopDirective + internal OMPDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeSimdDirective, CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective) { - internal OMPDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPDistributeSimdDirective, CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPExecutableDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPExecutableDirective.cs index 3b4002fa..4482c601 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPExecutableDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPExecutableDirective.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class OMPExecutableDirective : Stmt { - public class OMPExecutableDirective : Stmt + private protected OMPExecutableDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected OMPExecutableDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOMPExecutableDirective or < CX_StmtClass.CX_StmtClass_FirstOMPExecutableDirective) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOMPExecutableDirective or < CX_StmtClass.CX_StmtClass_FirstOMPExecutableDirective) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPFlushDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPFlushDirective.cs index 08408756..dcf90b73 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPFlushDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPFlushDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPFlushDirective : OMPExecutableDirective { - public sealed class OMPFlushDirective : OMPExecutableDirective + internal OMPFlushDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPFlushDirective, CX_StmtClass.CX_StmtClass_OMPFlushDirective) { - internal OMPFlushDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPFlushDirective, CX_StmtClass.CX_StmtClass_OMPFlushDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPForDirective.cs index 784bb2b8..2cc0018a 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPForDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPForDirective : OMPLoopDirective { - public sealed class OMPForDirective : OMPLoopDirective + internal OMPForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPForDirective, CX_StmtClass.CX_StmtClass_OMPForDirective) { - internal OMPForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPForDirective, CX_StmtClass.CX_StmtClass_OMPForDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPForSimdDirective.cs index bd4a0e05..d5287f47 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPForSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPForSimdDirective : OMPLoopDirective { - public sealed class OMPForSimdDirective : OMPLoopDirective + internal OMPForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPForSimdDirective, CX_StmtClass.CX_StmtClass_OMPForSimdDirective) { - internal OMPForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPForSimdDirective, CX_StmtClass.CX_StmtClass_OMPForSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPGenericLoopDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPGenericLoopDirective.cs index e51a0a9b..fa46f60d 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPGenericLoopDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPGenericLoopDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPGenericLoopDirective : OMPLoopDirective { - public sealed class OMPGenericLoopDirective : OMPLoopDirective + internal OMPGenericLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPGenericLoopDirective, CX_StmtClass.CX_StmtClass_OMPGenericLoopDirective) { - internal OMPGenericLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPGenericLoopDirective, CX_StmtClass.CX_StmtClass_OMPGenericLoopDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPInteropDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPInteropDirective.cs index c976060e..ff1d3a4b 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPInteropDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPInteropDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPInteropDirective : OMPExecutableDirective { - public sealed class OMPInteropDirective : OMPExecutableDirective + internal OMPInteropDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPInteropDirective, CX_StmtClass.CX_StmtClass_OMPInteropDirective) { - internal OMPInteropDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPInteropDirective, CX_StmtClass.CX_StmtClass_OMPInteropDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPLoopBasedDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPLoopBasedDirective.cs index 8375897c..c7aa0483 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPLoopBasedDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPLoopBasedDirective.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class OMPLoopBasedDirective : OMPExecutableDirective { - public class OMPLoopBasedDirective : OMPExecutableDirective + private protected OMPLoopBasedDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected OMPLoopBasedDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOMPLoopBasedDirective or < CX_StmtClass.CX_StmtClass_FirstOMPLoopBasedDirective) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOMPLoopBasedDirective or < CX_StmtClass.CX_StmtClass_FirstOMPLoopBasedDirective) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPLoopDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPLoopDirective.cs index be87d94f..84abefda 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPLoopDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPLoopDirective.cs @@ -3,16 +3,15 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class OMPLoopDirective : OMPExecutableDirective { - public class OMPLoopDirective : OMPExecutableDirective + private protected OMPLoopDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected OMPLoopDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOMPLoopDirective or < CX_StmtClass.CX_StmtClass_FirstOMPLoopDirective) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastOMPLoopDirective or < CX_StmtClass.CX_StmtClass_FirstOMPLoopDirective) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPLoopTransformationDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPLoopTransformationDirective.cs index 97dfa62e..2e2fbcee 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPLoopTransformationDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPLoopTransformationDirective.cs @@ -3,12 +3,11 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class OMPLoopTransformationDirective : OMPLoopBasedDirective { - public class OMPLoopTransformationDirective : OMPLoopBasedDirective + private protected OMPLoopTransformationDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected OMPLoopTransformationDirective(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPMaskedDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPMaskedDirective.cs index 3289d155..cb9349d1 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPMaskedDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPMaskedDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPMaskedDirective : OMPExecutableDirective { - public sealed class OMPMaskedDirective : OMPExecutableDirective + internal OMPMaskedDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMaskedDirective, CX_StmtClass.CX_StmtClass_OMPMaskedDirective) { - internal OMPMaskedDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMaskedDirective, CX_StmtClass.CX_StmtClass_OMPMaskedDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPMasterDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPMasterDirective.cs index 745cc28b..e80c1131 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPMasterDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPMasterDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPMasterDirective : OMPExecutableDirective { - public sealed class OMPMasterDirective : OMPExecutableDirective + internal OMPMasterDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMasterDirective, CX_StmtClass.CX_StmtClass_OMPMasterDirective) { - internal OMPMasterDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMasterDirective, CX_StmtClass.CX_StmtClass_OMPMasterDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPMasterTaskLoopDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPMasterTaskLoopDirective.cs index 98c38dee..ee2203c4 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPMasterTaskLoopDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPMasterTaskLoopDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPMasterTaskLoopDirective : OMPLoopDirective { - public sealed class OMPMasterTaskLoopDirective : OMPLoopDirective + internal OMPMasterTaskLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMasterTaskLoopDirective, CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopDirective) { - internal OMPMasterTaskLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMasterTaskLoopDirective, CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPMasterTaskLoopSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPMasterTaskLoopSimdDirective.cs index ea2a7437..b4a8e98d 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPMasterTaskLoopSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPMasterTaskLoopSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPMasterTaskLoopSimdDirective : OMPLoopDirective { - public sealed class OMPMasterTaskLoopSimdDirective : OMPLoopDirective + internal OMPMasterTaskLoopSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMasterTaskLoopSimdDirective, CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopSimdDirective) { - internal OMPMasterTaskLoopSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMasterTaskLoopSimdDirective, CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPMetaDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPMetaDirective.cs index de7dc0b0..48b11598 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPMetaDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPMetaDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPMetaDirective : OMPExecutableDirective { - public sealed class OMPMetaDirective : OMPExecutableDirective + internal OMPMetaDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMetaDirective, CX_StmtClass.CX_StmtClass_OMPMetaDirective) { - internal OMPMetaDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPMetaDirective, CX_StmtClass.CX_StmtClass_OMPMetaDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPOrderedDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPOrderedDirective.cs index 18db8234..8ffc87ed 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPOrderedDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPOrderedDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPOrderedDirective : OMPExecutableDirective { - public sealed class OMPOrderedDirective : OMPExecutableDirective + internal OMPOrderedDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPOrderedDirective, CX_StmtClass.CX_StmtClass_OMPOrderedDirective) { - internal OMPOrderedDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPOrderedDirective, CX_StmtClass.CX_StmtClass_OMPOrderedDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelDirective.cs index 6b932147..c39740f3 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPParallelDirective : OMPExecutableDirective { - public sealed class OMPParallelDirective : OMPExecutableDirective + internal OMPParallelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelDirective, CX_StmtClass.CX_StmtClass_OMPParallelDirective) { - internal OMPParallelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelDirective, CX_StmtClass.CX_StmtClass_OMPParallelDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelForDirective.cs index 1eb6c476..f7e6e258 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelForDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPParallelForDirective : OMPLoopDirective { - public sealed class OMPParallelForDirective : OMPLoopDirective + internal OMPParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelForDirective, CX_StmtClass.CX_StmtClass_OMPParallelForDirective) { - internal OMPParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelForDirective, CX_StmtClass.CX_StmtClass_OMPParallelForDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelForSimdDirective.cs index 84f0192e..d8d824ec 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelForSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPParallelForSimdDirective : OMPLoopDirective { - public sealed class OMPParallelForSimdDirective : OMPLoopDirective + internal OMPParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective) { - internal OMPParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterDirective.cs index a7011fa1..fdc4e923 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPParallelMasterDirective : OMPExecutableDirective { - public sealed class OMPParallelMasterDirective : OMPExecutableDirective + internal OMPParallelMasterDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelMasterDirective, CX_StmtClass.CX_StmtClass_OMPParallelMasterDirective) { - internal OMPParallelMasterDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelMasterDirective, CX_StmtClass.CX_StmtClass_OMPParallelMasterDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterTaskLoopDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterTaskLoopDirective.cs index 25b2f094..3f7af4f3 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterTaskLoopDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterTaskLoopDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPParallelMasterTaskLoopDirective : OMPLoopDirective { - public sealed class OMPParallelMasterTaskLoopDirective : OMPLoopDirective + internal OMPParallelMasterTaskLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelMasterTaskLoopDirective, CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopDirective) { - internal OMPParallelMasterTaskLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelMasterTaskLoopDirective, CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterTaskLoopSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterTaskLoopSimdDirective.cs index 3c8e4131..8a8b55b3 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterTaskLoopSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelMasterTaskLoopSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPParallelMasterTaskLoopSimdDirective : OMPLoopDirective { - public sealed class OMPParallelMasterTaskLoopSimdDirective : OMPLoopDirective + internal OMPParallelMasterTaskLoopSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelMasterTaskLoopSimdDirective, CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective) { - internal OMPParallelMasterTaskLoopSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelMasterTaskLoopSimdDirective, CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPParallelSectionsDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPParallelSectionsDirective.cs index 284e0eed..e5e2df68 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPParallelSectionsDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPParallelSectionsDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPParallelSectionsDirective : OMPExecutableDirective { - public sealed class OMPParallelSectionsDirective : OMPExecutableDirective + internal OMPParallelSectionsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelSectionsDirective, CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective) { - internal OMPParallelSectionsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPParallelSectionsDirective, CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPScanDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPScanDirective.cs index 9f2589c0..b503ad85 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPScanDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPScanDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPScanDirective : OMPExecutableDirective { - public sealed class OMPScanDirective : OMPExecutableDirective + internal OMPScanDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPScanDirective, CX_StmtClass.CX_StmtClass_OMPScanDirective) { - internal OMPScanDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPScanDirective, CX_StmtClass.CX_StmtClass_OMPScanDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPSectionDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPSectionDirective.cs index 15a30638..ff9cc5b3 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPSectionDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPSectionDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPSectionDirective : OMPExecutableDirective { - public sealed class OMPSectionDirective : OMPExecutableDirective + internal OMPSectionDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSectionDirective, CX_StmtClass.CX_StmtClass_OMPSectionDirective) { - internal OMPSectionDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSectionDirective, CX_StmtClass.CX_StmtClass_OMPSectionDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPSectionsDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPSectionsDirective.cs index ef235e9c..24fca09e 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPSectionsDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPSectionsDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPSectionsDirective : OMPExecutableDirective { - public sealed class OMPSectionsDirective : OMPExecutableDirective + internal OMPSectionsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSectionsDirective, CX_StmtClass.CX_StmtClass_OMPSectionsDirective) { - internal OMPSectionsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSectionsDirective, CX_StmtClass.CX_StmtClass_OMPSectionsDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPSimdDirective.cs index 7772fd89..ecad9513 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPSimdDirective : OMPLoopDirective { - public sealed class OMPSimdDirective : OMPLoopDirective + internal OMPSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSimdDirective, CX_StmtClass.CX_StmtClass_OMPSimdDirective) { - internal OMPSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSimdDirective, CX_StmtClass.CX_StmtClass_OMPSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPSingleDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPSingleDirective.cs index 28e9a4f9..0df0ea6c 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPSingleDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPSingleDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPSingleDirective : OMPExecutableDirective { - public sealed class OMPSingleDirective : OMPExecutableDirective + internal OMPSingleDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSingleDirective, CX_StmtClass.CX_StmtClass_OMPSingleDirective) { - internal OMPSingleDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPSingleDirective, CX_StmtClass.CX_StmtClass_OMPSingleDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetDataDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetDataDirective.cs index d9a41456..06e28e1c 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetDataDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetDataDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetDataDirective : OMPExecutableDirective { - public sealed class OMPTargetDataDirective : OMPExecutableDirective + internal OMPTargetDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetDataDirective, CX_StmtClass.CX_StmtClass_OMPTargetDataDirective) { - internal OMPTargetDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetDataDirective, CX_StmtClass.CX_StmtClass_OMPTargetDataDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetDirective.cs index 782775e5..8c264506 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetDirective : OMPExecutableDirective { - public sealed class OMPTargetDirective : OMPExecutableDirective + internal OMPTargetDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetDirective, CX_StmtClass.CX_StmtClass_OMPTargetDirective) { - internal OMPTargetDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetDirective, CX_StmtClass.CX_StmtClass_OMPTargetDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetEnterDataDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetEnterDataDirective.cs index 5a45726c..da51df5f 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetEnterDataDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetEnterDataDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetEnterDataDirective : OMPExecutableDirective { - public sealed class OMPTargetEnterDataDirective : OMPExecutableDirective + internal OMPTargetEnterDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetEnterDataDirective, CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective) { - internal OMPTargetEnterDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetEnterDataDirective, CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetExitDataDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetExitDataDirective.cs index 26a3d10f..eda53201 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetExitDataDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetExitDataDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetExitDataDirective : OMPExecutableDirective { - public sealed class OMPTargetExitDataDirective : OMPExecutableDirective + internal OMPTargetExitDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetExitDataDirective, CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective) { - internal OMPTargetExitDataDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetExitDataDirective, CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelDirective.cs index f549f938..9670d4ba 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetParallelDirective : OMPExecutableDirective { - public sealed class OMPTargetParallelDirective : OMPExecutableDirective + internal OMPTargetParallelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelDirective, CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective) { - internal OMPTargetParallelDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelDirective, CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForDirective.cs index ae2030b0..f3cc6d30 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetParallelForDirective : OMPLoopDirective { - public sealed class OMPTargetParallelForDirective : OMPLoopDirective + internal OMPTargetParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelForDirective, CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective) { - internal OMPTargetParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelForDirective, CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForSimdDirective.cs index 516f9ad4..268592b9 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetParallelForSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetParallelForSimdDirective : OMPLoopDirective { - public sealed class OMPTargetParallelForSimdDirective : OMPLoopDirective + internal OMPTargetParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective) { - internal OMPTargetParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetSimdDirective.cs index 80269e72..0242176e 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetSimdDirective : OMPLoopDirective { - public sealed class OMPTargetSimdDirective : OMPLoopDirective + internal OMPTargetSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective) { - internal OMPTargetSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDirective.cs index a2700281..dfdb3d9f 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetTeamsDirective : OMPExecutableDirective { - public sealed class OMPTargetTeamsDirective : OMPExecutableDirective + internal OMPTargetTeamsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective) { - internal OMPTargetTeamsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeDirective.cs index 2d184f79..b63cd898 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetTeamsDistributeDirective : OMPLoopDirective { - public sealed class OMPTargetTeamsDistributeDirective : OMPLoopDirective + internal OMPTargetTeamsDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective) { - internal OMPTargetTeamsDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForDirective.cs index 77e1268f..a6dd6856 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetTeamsDistributeParallelForDirective : OMPLoopDirective { - public sealed class OMPTargetTeamsDistributeParallelForDirective : OMPLoopDirective + internal OMPTargetTeamsDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective) { - internal OMPTargetTeamsDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForSimdDirective.cs index 4f8c9537..01cc9e81 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeParallelForSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetTeamsDistributeParallelForSimdDirective : OMPLoopDirective { - public sealed class OMPTargetTeamsDistributeParallelForSimdDirective : OMPLoopDirective + internal OMPTargetTeamsDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective) { - internal OMPTargetTeamsDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeSimdDirective.cs index 7ec178e5..bc9fd1ed 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetTeamsDistributeSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetTeamsDistributeSimdDirective : OMPLoopDirective { - public sealed class OMPTargetTeamsDistributeSimdDirective : OMPLoopDirective + internal OMPTargetTeamsDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective) { - internal OMPTargetTeamsDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetTeamsDistributeSimdDirective, CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTargetUpdateDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTargetUpdateDirective.cs index c84e37f9..dc3910b5 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTargetUpdateDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTargetUpdateDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTargetUpdateDirective : OMPExecutableDirective { - public sealed class OMPTargetUpdateDirective : OMPExecutableDirective + internal OMPTargetUpdateDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetUpdateDirective, CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective) { - internal OMPTargetUpdateDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTargetUpdateDirective, CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskDirective.cs index f7b90cd4..83f8a17f 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTaskDirective : OMPExecutableDirective { - public sealed class OMPTaskDirective : OMPExecutableDirective + internal OMPTaskDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskDirective, CX_StmtClass.CX_StmtClass_OMPTaskDirective) { - internal OMPTaskDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskDirective, CX_StmtClass.CX_StmtClass_OMPTaskDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopDirective.cs index 3367402b..ff7686d4 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTaskLoopDirective : OMPLoopDirective { - public sealed class OMPTaskLoopDirective : OMPLoopDirective + internal OMPTaskLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskLoopDirective, CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective) { - internal OMPTaskLoopDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskLoopDirective, CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopSimdDirective.cs index ff9f7f7d..509bac69 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskLoopSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTaskLoopSimdDirective : OMPLoopDirective { - public sealed class OMPTaskLoopSimdDirective : OMPLoopDirective + internal OMPTaskLoopSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskLoopSimdDirective, CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective) { - internal OMPTaskLoopSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskLoopSimdDirective, CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskgroupDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskgroupDirective.cs index 82276849..dfd4686d 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskgroupDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskgroupDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTaskgroupDirective : OMPExecutableDirective { - public sealed class OMPTaskgroupDirective : OMPExecutableDirective + internal OMPTaskgroupDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskgroupDirective, CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective) { - internal OMPTaskgroupDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskgroupDirective, CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskwaitDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskwaitDirective.cs index 6e3c42a6..f074a3da 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskwaitDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskwaitDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTaskwaitDirective : OMPExecutableDirective { - public sealed class OMPTaskwaitDirective : OMPExecutableDirective + internal OMPTaskwaitDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskwaitDirective, CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective) { - internal OMPTaskwaitDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskwaitDirective, CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTaskyieldDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTaskyieldDirective.cs index 3c0da266..c6aca909 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTaskyieldDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTaskyieldDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTaskyieldDirective : OMPExecutableDirective { - public sealed class OMPTaskyieldDirective : OMPExecutableDirective + internal OMPTaskyieldDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskyieldDirective, CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective) { - internal OMPTaskyieldDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTaskyieldDirective, CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDirective.cs index e6a9998d..c2cb2893 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTeamsDirective : OMPExecutableDirective { - public sealed class OMPTeamsDirective : OMPExecutableDirective + internal OMPTeamsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDirective) { - internal OMPTeamsDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeDirective.cs index fd4bddde..5e11da33 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTeamsDistributeDirective : OMPLoopDirective { - public sealed class OMPTeamsDistributeDirective : OMPLoopDirective + internal OMPTeamsDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective) { - internal OMPTeamsDistributeDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForDirective.cs index 8c92cb04..fdbfaa21 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTeamsDistributeParallelForDirective : OMPLoopDirective { - public sealed class OMPTeamsDistributeParallelForDirective : OMPLoopDirective + internal OMPTeamsDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeParallelForDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective) { - internal OMPTeamsDistributeParallelForDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeParallelForDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForSimdDirective.cs index 5fbc5af7..68733ee1 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeParallelForSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTeamsDistributeParallelForSimdDirective : OMPLoopDirective { - public sealed class OMPTeamsDistributeParallelForSimdDirective : OMPLoopDirective + internal OMPTeamsDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective) { - internal OMPTeamsDistributeParallelForSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeParallelForSimdDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeSimdDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeSimdDirective.cs index 75093276..5a1b855d 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeSimdDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTeamsDistributeSimdDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTeamsDistributeSimdDirective : OMPLoopDirective { - public sealed class OMPTeamsDistributeSimdDirective : OMPLoopDirective + internal OMPTeamsDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeSimdDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective) { - internal OMPTeamsDistributeSimdDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTeamsDistributeSimdDirective, CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPTileDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPTileDirective.cs index f8297524..52b4d0e0 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPTileDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPTileDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPTileDirective : OMPLoopTransformationDirective { - public sealed class OMPTileDirective : OMPLoopTransformationDirective + internal OMPTileDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTileDirective, CX_StmtClass.CX_StmtClass_OMPTileDirective) { - internal OMPTileDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPTileDirective, CX_StmtClass.CX_StmtClass_OMPTileDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/OMPUnrollDirective.cs b/sources/ClangSharp/Cursors/Stmts/OMPUnrollDirective.cs index 3e371bbe..48277d2a 100644 --- a/sources/ClangSharp/Cursors/Stmts/OMPUnrollDirective.cs +++ b/sources/ClangSharp/Cursors/Stmts/OMPUnrollDirective.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class OMPUnrollDirective : OMPLoopTransformationDirective { - public sealed class OMPUnrollDirective : OMPLoopTransformationDirective + internal OMPUnrollDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPUnrollDirective, CX_StmtClass.CX_StmtClass_OMPUnrollDirective) { - internal OMPUnrollDirective(CXCursor handle) : base(handle, CXCursorKind.CXCursor_OMPUnrollDirective, CX_StmtClass.CX_StmtClass_OMPUnrollDirective) - { - } } } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtCatchStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtCatchStmt.cs index becb025d..2ba4f503 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtCatchStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtCatchStmt.cs @@ -4,22 +4,21 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCAtCatchStmt : Stmt { - public sealed class ObjCAtCatchStmt : Stmt - { - private readonly Lazy _catchParamDecl; + private readonly Lazy _catchParamDecl; - internal ObjCAtCatchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtCatchStmt, CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt) - { - Debug.Assert(NumChildren is 1); - _catchParamDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + internal ObjCAtCatchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtCatchStmt, CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt) + { + Debug.Assert(NumChildren is 1); + _catchParamDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public Stmt CatchBody => Children[0]; + public Stmt CatchBody => Children[0]; - public VarDecl CatchParamDecl => _catchParamDecl.Value; + public VarDecl CatchParamDecl => _catchParamDecl.Value; - public bool HasEllipsis => CatchParamDecl == null; - } + public bool HasEllipsis => CatchParamDecl == null; } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtFinallyStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtFinallyStmt.cs index 5cd68705..6935508a 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtFinallyStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtFinallyStmt.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCAtFinallyStmt : Stmt { - public sealed class ObjCAtFinallyStmt : Stmt + internal ObjCAtFinallyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtFinallyStmt, CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt) { - internal ObjCAtFinallyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtFinallyStmt, CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt) - { - Debug.Assert(NumChildren is 1); - } - - public Stmt FinallyBody => Children[0]; + Debug.Assert(NumChildren is 1); } + + public Stmt FinallyBody => Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtSynchronizedStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtSynchronizedStmt.cs index fa2e9a6f..e46609ae 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtSynchronizedStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtSynchronizedStmt.cs @@ -3,17 +3,16 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCAtSynchronizedStmt : Stmt { - public sealed class ObjCAtSynchronizedStmt : Stmt + internal ObjCAtSynchronizedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtSynchronizedStmt, CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt) { - internal ObjCAtSynchronizedStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtSynchronizedStmt, CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt) - { - Debug.Assert(NumChildren is 2); - } + Debug.Assert(NumChildren is 2); + } - public CompoundStmt SynchBody => (CompoundStmt)Children[1]; + public CompoundStmt SynchBody => (CompoundStmt)Children[1]; - public Expr SynchExpr => (Expr)Children[0]; - } + public Expr SynchExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtThrowStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtThrowStmt.cs index 03047334..464b8e80 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtThrowStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtThrowStmt.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCAtThrowStmt : Stmt { - public sealed class ObjCAtThrowStmt : Stmt + internal ObjCAtThrowStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtThrowStmt, CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt) { - internal ObjCAtThrowStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtThrowStmt, CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt) - { - Debug.Assert(NumChildren is 1); - } - - public Expr ThrowExpr => (Expr)Children[0]; + Debug.Assert(NumChildren is 1); } + + public Expr ThrowExpr => (Expr)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs index 1fba2f55..5871888a 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs @@ -6,41 +6,40 @@ using System.Linq; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCAtTryStmt : Stmt { - public sealed class ObjCAtTryStmt : Stmt - { - private readonly Lazy> _catchStmts; - private readonly Lazy _finallyStmt; + private readonly Lazy> _catchStmts; + private readonly Lazy _finallyStmt; - internal ObjCAtTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtTryStmt, CX_StmtClass.CX_StmtClass_ObjCAtTryStmt) - { - Debug.Assert(NumChildren is >= 1); + internal ObjCAtTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAtTryStmt, CX_StmtClass.CX_StmtClass_ObjCAtTryStmt) + { + Debug.Assert(NumChildren is >= 1); - _catchStmts = new Lazy>(() => { - var children = Children; - var skipLast = 0; + _catchStmts = new Lazy>(() => { + var children = Children; + var skipLast = 0; - if (children.Last() is ObjCAtFinallyStmt) { - skipLast++; - } + if (children.Last() is ObjCAtFinallyStmt) { + skipLast++; + } - return children.Skip(1).Take((int)(NumChildren - 1 - skipLast)).Cast().ToList(); - }); + return children.Skip(1).Take((int)(NumChildren - 1 - skipLast)).Cast().ToList(); + }); - _finallyStmt = new Lazy(() => { - var children = Children; + _finallyStmt = new Lazy(() => { + var children = Children; - return children.Last() is ObjCAtFinallyStmt finallyStmt ? finallyStmt : null; - }); - } + return children.Last() is ObjCAtFinallyStmt finallyStmt ? finallyStmt : null; + }); + } - public Stmt Body => Children[0]; + public Stmt Body => Children[0]; - public IReadOnlyList CatchStmts => _catchStmts.Value; + public IReadOnlyList CatchStmts => _catchStmts.Value; - public ObjCAtFinallyStmt FinallyStmt => _finallyStmt.Value; + public ObjCAtFinallyStmt FinallyStmt => _finallyStmt.Value; - public uint NumCatchStmts => (uint)CatchStmts.Count; - } + public uint NumCatchStmts => (uint)CatchStmts.Count; } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAutoreleasePoolStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAutoreleasePoolStmt.cs index d1729a32..6f5422a5 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAutoreleasePoolStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAutoreleasePoolStmt.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCAutoreleasePoolStmt : Stmt { - public sealed class ObjCAutoreleasePoolStmt : Stmt + internal ObjCAutoreleasePoolStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAutoreleasePoolStmt, CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt) { - internal ObjCAutoreleasePoolStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCAutoreleasePoolStmt, CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt) - { - Debug.Assert(NumChildren is 1); - } - - public Stmt SubStmt => Children[0]; + Debug.Assert(NumChildren is 1); } + + public Stmt SubStmt => Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCForCollectionStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCForCollectionStmt.cs index 949c7a5a..da89c4f2 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCForCollectionStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCForCollectionStmt.cs @@ -3,19 +3,18 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCForCollectionStmt : Stmt { - public sealed class ObjCForCollectionStmt : Stmt + internal ObjCForCollectionStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCForCollectionStmt, CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt) { - internal ObjCForCollectionStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ObjCForCollectionStmt, CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt) - { - Debug.Assert(NumChildren is 3); - } + Debug.Assert(NumChildren is 3); + } - public Stmt Body => Children[2]; + public Stmt Body => Children[2]; - public Expr Collection => (Expr)Children[1]; + public Expr Collection => (Expr)Children[1]; - public Stmt Element => Children[0]; - } + public Stmt Element => Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/ReturnStmt.cs b/sources/ClangSharp/Cursors/Stmts/ReturnStmt.cs index 34d97242..d050ef06 100644 --- a/sources/ClangSharp/Cursors/Stmts/ReturnStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ReturnStmt.cs @@ -4,21 +4,20 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ReturnStmt : Stmt { - public sealed class ReturnStmt : Stmt - { - private readonly Lazy _nrvoCandidate; + private readonly Lazy _nrvoCandidate; - internal ReturnStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ReturnStmt, CX_StmtClass.CX_StmtClass_ReturnStmt) - { - Debug.Assert(NumChildren is 0 or 1); + internal ReturnStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_ReturnStmt, CX_StmtClass.CX_StmtClass_ReturnStmt) + { + Debug.Assert(NumChildren is 0 or 1); - _nrvoCandidate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); - } + _nrvoCandidate = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Referenced)); + } - public VarDecl NRVOCandidate => _nrvoCandidate.Value; + public VarDecl NRVOCandidate => _nrvoCandidate.Value; - public Expr RetValue => NumChildren != 0 ? (Expr)Children[0] : null; - } + public Expr RetValue => NumChildren != 0 ? (Expr)Children[0] : null; } diff --git a/sources/ClangSharp/Cursors/Stmts/SEHExceptStmt.cs b/sources/ClangSharp/Cursors/Stmts/SEHExceptStmt.cs index 6d482682..a472ffd4 100644 --- a/sources/ClangSharp/Cursors/Stmts/SEHExceptStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SEHExceptStmt.cs @@ -3,17 +3,16 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SEHExceptStmt : Stmt { - public sealed class SEHExceptStmt : Stmt + internal SEHExceptStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHExceptStmt, CX_StmtClass.CX_StmtClass_SEHExceptStmt) { - internal SEHExceptStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHExceptStmt, CX_StmtClass.CX_StmtClass_SEHExceptStmt) - { - Debug.Assert(NumChildren is 2); - } + Debug.Assert(NumChildren is 2); + } - public Expr FilterExpr => (Expr)Children[0]; + public Expr FilterExpr => (Expr)Children[0]; - public CompoundStmt Block => (CompoundStmt)Children[1]; - } + public CompoundStmt Block => (CompoundStmt)Children[1]; } diff --git a/sources/ClangSharp/Cursors/Stmts/SEHFinallyStmt.cs b/sources/ClangSharp/Cursors/Stmts/SEHFinallyStmt.cs index 89361947..76da589e 100644 --- a/sources/ClangSharp/Cursors/Stmts/SEHFinallyStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SEHFinallyStmt.cs @@ -3,15 +3,14 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SEHFinallyStmt : Stmt { - public sealed class SEHFinallyStmt : Stmt + internal SEHFinallyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHFinallyStmt, CX_StmtClass.CX_StmtClass_SEHFinallyStmt) { - internal SEHFinallyStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHFinallyStmt, CX_StmtClass.CX_StmtClass_SEHFinallyStmt) - { - Debug.Assert(NumChildren is 1); - } - - public CompoundStmt Block => (CompoundStmt)Children[0]; + Debug.Assert(NumChildren is 1); } + + public CompoundStmt Block => (CompoundStmt)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/SEHLeaveStmt.cs b/sources/ClangSharp/Cursors/Stmts/SEHLeaveStmt.cs index 7e070017..d02a2615 100644 --- a/sources/ClangSharp/Cursors/Stmts/SEHLeaveStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SEHLeaveStmt.cs @@ -3,13 +3,12 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SEHLeaveStmt : Stmt { - public sealed class SEHLeaveStmt : Stmt + internal SEHLeaveStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHLeaveStmt, CX_StmtClass.CX_StmtClass_SEHLeaveStmt) { - internal SEHLeaveStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHLeaveStmt, CX_StmtClass.CX_StmtClass_SEHLeaveStmt) - { - Debug.Assert(NumChildren is 0); - } + Debug.Assert(NumChildren is 0); } } diff --git a/sources/ClangSharp/Cursors/Stmts/SEHTryStmt.cs b/sources/ClangSharp/Cursors/Stmts/SEHTryStmt.cs index a7704e20..074b6a78 100644 --- a/sources/ClangSharp/Cursors/Stmts/SEHTryStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SEHTryStmt.cs @@ -3,23 +3,22 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SEHTryStmt : Stmt { - public sealed class SEHTryStmt : Stmt + internal SEHTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHTryStmt, CX_StmtClass.CX_StmtClass_SEHTryStmt) { - internal SEHTryStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SEHTryStmt, CX_StmtClass.CX_StmtClass_SEHTryStmt) - { - Debug.Assert(NumChildren is 2); - } + Debug.Assert(NumChildren is 2); + } - public SEHExceptStmt ExceptHandler => Handler as SEHExceptStmt; + public SEHExceptStmt ExceptHandler => Handler as SEHExceptStmt; - public SEHFinallyStmt FinallyHandler => Handler as SEHFinallyStmt; + public SEHFinallyStmt FinallyHandler => Handler as SEHFinallyStmt; - public bool IsCXXTry => Handle.IsCXXTry; + public bool IsCXXTry => Handle.IsCXXTry; - public Stmt Handler => Children[1]; + public Stmt Handler => Children[1]; - public CompoundStmt TryBlock => (CompoundStmt)Children[0]; - } + public CompoundStmt TryBlock => (CompoundStmt)Children[0]; } diff --git a/sources/ClangSharp/Cursors/Stmts/Stmt.cs b/sources/ClangSharp/Cursors/Stmts/Stmt.cs index 3df2909a..ffcbdd36 100644 --- a/sources/ClangSharp/Cursors/Stmts/Stmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/Stmt.cs @@ -4,340 +4,339 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class Stmt : Cursor { - public class Stmt : Cursor - { - private readonly Lazy> _children; - private readonly Lazy _declContext; + private readonly Lazy> _children; + private readonly Lazy _declContext; - private protected Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind) + private protected Stmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind) + { + if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass)) { - if ((handle.StmtClass == CX_StmtClass.CX_StmtClass_Invalid) || (handle.StmtClass != expectedStmtClass)) + throw new ArgumentOutOfRangeException(nameof(handle)); + } + + _children = new Lazy>(() => { + var numChildren = Handle.NumChildren; + var children = new List(numChildren); + + for (var i = 0; i < numChildren; i++) { - throw new ArgumentOutOfRangeException(nameof(handle)); + var child = TranslationUnit.GetOrCreate(Handle.GetChild(unchecked((uint)i))); + children.Add(child); } - _children = new Lazy>(() => { - var numChildren = Handle.NumChildren; - var children = new List(numChildren); + return children; + }); - for (var i = 0; i < numChildren; i++) - { - var child = TranslationUnit.GetOrCreate(Handle.GetChild(unchecked((uint)i))); - children.Add(child); - } - - return children; - }); + _declContext = new Lazy(() => { + var semanticParent = TranslationUnit.GetOrCreate(Handle.SemanticParent); - _declContext = new Lazy(() => { - var semanticParent = TranslationUnit.GetOrCreate(Handle.SemanticParent); + while (semanticParent is not IDeclContext and not null) + { + semanticParent = TranslationUnit.GetOrCreate(semanticParent.Handle.SemanticParent); + } - while (semanticParent is not IDeclContext and not null) - { - semanticParent = TranslationUnit.GetOrCreate(semanticParent.Handle.SemanticParent); - } + return (IDeclContext)semanticParent; + }); + } - return (IDeclContext)semanticParent; - }); - } + public IReadOnlyList Children => _children.Value; - public IReadOnlyList Children => _children.Value; + public IDeclContext DeclContext => _declContext.Value; - public IDeclContext DeclContext => _declContext.Value; + public uint NumChildren => unchecked((uint)Handle.NumChildren); - public uint NumChildren => unchecked((uint)Handle.NumChildren); + public CX_StmtClass StmtClass => Handle.StmtClass; - public CX_StmtClass StmtClass => Handle.StmtClass; + public string StmtClassName => Handle.StmtClassSpelling; - public string StmtClassName => Handle.StmtClassSpelling; + public Stmt IgnoreContainers(bool ignoreCaptured = false) + { + var s = this; - public Stmt IgnoreContainers(bool ignoreCaptured = false) + if (ignoreCaptured) { - var s = this; - - if (ignoreCaptured) + if (s is CapturedStmt capS) { - if (s is CapturedStmt capS) - { - s = capS.CaptureStmt; - } + s = capS.CaptureStmt; } + } - while (true) + while (true) + { + if (s is AttributedStmt @as) { - if (s is AttributedStmt @as) - { - s = @as.SubStmt; - } - else if (s is CompoundStmt cs) - { - if (cs.Size != 1) - { - break; - } - - s = cs.BodyBack; - } - else + s = @as.SubStmt; + } + else if (s is CompoundStmt cs) + { + if (cs.Size != 1) { break; } + + s = cs.BodyBack; + } + else + { + break; } - return s; } + return s; + } - public Stmt StripLabelLikeStatements() - { - var s = this; + public Stmt StripLabelLikeStatements() + { + var s = this; - while (true) + while (true) + { + if (s is LabelStmt ls) { - if (s is LabelStmt ls) - { - s = ls.SubStmt; - } - else if (s is SwitchCase sc) - { - s = sc.SubStmt; - } - else if (s is AttributedStmt @as) - { - s = @as.SubStmt; - } - else - { - return s; - } + s = ls.SubStmt; + } + else if (s is SwitchCase sc) + { + s = sc.SubStmt; + } + else if (s is AttributedStmt @as) + { + s = @as.SubStmt; + } + else + { + return s; } } - - internal static new Stmt Create(CXCursor handle) => handle.StmtClass switch { - CX_StmtClass.CX_StmtClass_Invalid => new Stmt(handle, handle.Kind, handle.StmtClass), - CX_StmtClass.CX_StmtClass_GCCAsmStmt => new GCCAsmStmt(handle), - CX_StmtClass.CX_StmtClass_MSAsmStmt => new MSAsmStmt(handle), - CX_StmtClass.CX_StmtClass_BreakStmt => new BreakStmt(handle), - CX_StmtClass.CX_StmtClass_CXXCatchStmt => new CXXCatchStmt(handle), - CX_StmtClass.CX_StmtClass_CXXForRangeStmt => new CXXForRangeStmt(handle), - CX_StmtClass.CX_StmtClass_CXXTryStmt => new CXXTryStmt(handle), - CX_StmtClass.CX_StmtClass_CapturedStmt => new CapturedStmt(handle), - CX_StmtClass.CX_StmtClass_CompoundStmt => new CompoundStmt(handle), - CX_StmtClass.CX_StmtClass_ContinueStmt => new ContinueStmt(handle), - CX_StmtClass.CX_StmtClass_CoreturnStmt => new CoreturnStmt(handle), - CX_StmtClass.CX_StmtClass_CoroutineBodyStmt => new CoroutineBodyStmt(handle), - CX_StmtClass.CX_StmtClass_DeclStmt => new DeclStmt(handle), - CX_StmtClass.CX_StmtClass_DoStmt => new DoStmt(handle), - CX_StmtClass.CX_StmtClass_ForStmt => new ForStmt(handle), - CX_StmtClass.CX_StmtClass_GotoStmt => new GotoStmt(handle), - CX_StmtClass.CX_StmtClass_IfStmt => new IfStmt(handle), - CX_StmtClass.CX_StmtClass_IndirectGotoStmt => new IndirectGotoStmt(handle), - CX_StmtClass.CX_StmtClass_MSDependentExistsStmt => new MSDependentExistsStmt(handle), - CX_StmtClass.CX_StmtClass_NullStmt => new NullStmt(handle), - CX_StmtClass.CX_StmtClass_OMPCanonicalLoop => new OMPCanonicalLoop(handle), - CX_StmtClass.CX_StmtClass_OMPAtomicDirective => new OMPAtomicDirective(handle), - CX_StmtClass.CX_StmtClass_OMPBarrierDirective => new OMPBarrierDirective(handle), - CX_StmtClass.CX_StmtClass_OMPCancelDirective => new OMPCancelDirective(handle), - CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective => new OMPCancellationPointDirective(handle), - CX_StmtClass.CX_StmtClass_OMPCriticalDirective => new OMPCriticalDirective(handle), - CX_StmtClass.CX_StmtClass_OMPDepobjDirective => new OMPDepobjDirective(handle), - CX_StmtClass.CX_StmtClass_OMPDispatchDirective => new OMPDispatchDirective(handle), - CX_StmtClass.CX_StmtClass_OMPFlushDirective => new OMPFlushDirective(handle), - CX_StmtClass.CX_StmtClass_OMPInteropDirective => new OMPInteropDirective(handle), - CX_StmtClass.CX_StmtClass_OMPDistributeDirective => new OMPDistributeDirective(handle), - CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective => new OMPDistributeParallelForDirective(handle), - CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective => new OMPDistributeParallelForSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective => new OMPDistributeSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPForDirective => new OMPForDirective(handle), - CX_StmtClass.CX_StmtClass_OMPForSimdDirective => new OMPForSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPGenericLoopDirective => new OMPGenericLoopDirective(handle), - CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopDirective => new OMPMasterTaskLoopDirective(handle), - CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopSimdDirective => new OMPMasterTaskLoopSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPParallelForDirective => new OMPParallelForDirective(handle), - CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective => new OMPParallelForSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopDirective => new OMPParallelMasterTaskLoopDirective(handle), - CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective => new OMPParallelMasterTaskLoopSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPSimdDirective => new OMPSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective => new OMPTargetParallelForSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective => new OMPTargetSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective => new OMPTargetTeamsDistributeDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective => new OMPTargetTeamsDistributeParallelForDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective => new OMPTargetTeamsDistributeParallelForSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective => new OMPTargetTeamsDistributeSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective => new OMPTaskLoopDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective => new OMPTaskLoopSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective => new OMPTeamsDistributeDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective => new OMPTeamsDistributeParallelForDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective => new OMPTeamsDistributeParallelForSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective => new OMPTeamsDistributeSimdDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTileDirective => new OMPTileDirective(handle), - CX_StmtClass.CX_StmtClass_OMPUnrollDirective => new OMPUnrollDirective(handle), - CX_StmtClass.CX_StmtClass_OMPMaskedDirective => new OMPMaskedDirective(handle), - CX_StmtClass.CX_StmtClass_OMPMasterDirective => new OMPMasterDirective(handle), - CX_StmtClass.CX_StmtClass_OMPMetaDirective => new OMPMetaDirective(handle), - CX_StmtClass.CX_StmtClass_OMPOrderedDirective => new OMPOrderedDirective(handle), - CX_StmtClass.CX_StmtClass_OMPParallelDirective => new OMPParallelDirective(handle), - CX_StmtClass.CX_StmtClass_OMPParallelMasterDirective => new OMPParallelMasterDirective(handle), - CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective => new OMPParallelSectionsDirective(handle), - CX_StmtClass.CX_StmtClass_OMPScanDirective => new OMPScanDirective(handle), - CX_StmtClass.CX_StmtClass_OMPSectionDirective => new OMPSectionDirective(handle), - CX_StmtClass.CX_StmtClass_OMPSectionsDirective => new OMPSectionsDirective(handle), - CX_StmtClass.CX_StmtClass_OMPSingleDirective => new OMPSingleDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetDataDirective => new OMPTargetDataDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetDirective => new OMPTargetDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective => new OMPTargetEnterDataDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective => new OMPTargetExitDataDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective => new OMPTargetParallelDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective => new OMPTargetParallelForDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective => new OMPTargetTeamsDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective => new OMPTargetUpdateDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTaskDirective => new OMPTaskDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective => new OMPTaskgroupDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective => new OMPTaskwaitDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective => new OMPTaskyieldDirective(handle), - CX_StmtClass.CX_StmtClass_OMPTeamsDirective => new OMPTeamsDirective(handle), - CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt => new ObjCAtCatchStmt(handle), - CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt => new ObjCAtFinallyStmt(handle), - CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt => new ObjCAtSynchronizedStmt(handle), - CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt => new ObjCAtThrowStmt(handle), - CX_StmtClass.CX_StmtClass_ObjCAtTryStmt => new ObjCAtTryStmt(handle), - CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt => new ObjCAutoreleasePoolStmt(handle), - CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt => new ObjCForCollectionStmt(handle), - CX_StmtClass.CX_StmtClass_ReturnStmt => new ReturnStmt(handle), - CX_StmtClass.CX_StmtClass_SEHExceptStmt => new SEHExceptStmt(handle), - CX_StmtClass.CX_StmtClass_SEHFinallyStmt => new SEHFinallyStmt(handle), - CX_StmtClass.CX_StmtClass_SEHLeaveStmt => new SEHLeaveStmt(handle), - CX_StmtClass.CX_StmtClass_SEHTryStmt => new SEHTryStmt(handle), - CX_StmtClass.CX_StmtClass_CaseStmt => new CaseStmt(handle), - CX_StmtClass.CX_StmtClass_DefaultStmt => new DefaultStmt(handle), - CX_StmtClass.CX_StmtClass_SwitchStmt => new SwitchStmt(handle), - CX_StmtClass.CX_StmtClass_AttributedStmt => new AttributedStmt(handle), - CX_StmtClass.CX_StmtClass_BinaryConditionalOperator => new BinaryConditionalOperator(handle), - CX_StmtClass.CX_StmtClass_ConditionalOperator => new ConditionalOperator(handle), - CX_StmtClass.CX_StmtClass_AddrLabelExpr => new AddrLabelExpr(handle), - CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr => new ArrayInitIndexExpr(handle), - CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr => new ArrayInitLoopExpr(handle), - CX_StmtClass.CX_StmtClass_ArraySubscriptExpr => new ArraySubscriptExpr(handle), - CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr => new ArrayTypeTraitExpr(handle), - CX_StmtClass.CX_StmtClass_AsTypeExpr => new AsTypeExpr(handle), - CX_StmtClass.CX_StmtClass_AtomicExpr => new AtomicExpr(handle), - CX_StmtClass.CX_StmtClass_BinaryOperator => new BinaryOperator(handle), - CX_StmtClass.CX_StmtClass_CompoundAssignOperator => new CompoundAssignOperator(handle), - CX_StmtClass.CX_StmtClass_BlockExpr => new BlockExpr(handle), - CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr => new CXXBindTemporaryExpr(handle), - CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr => new CXXBoolLiteralExpr(handle), - CX_StmtClass.CX_StmtClass_CXXConstructExpr => new CXXConstructExpr(handle), - CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr => new CXXTemporaryObjectExpr(handle), - CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr => new CXXDefaultArgExpr(handle), - CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr => new CXXDefaultInitExpr(handle), - CX_StmtClass.CX_StmtClass_CXXDeleteExpr => new CXXDeleteExpr(handle), - CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr => new CXXDependentScopeMemberExpr(handle), - CX_StmtClass.CX_StmtClass_CXXFoldExpr => new CXXFoldExpr(handle), - CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr => new CXXInheritedCtorInitExpr(handle), - CX_StmtClass.CX_StmtClass_CXXNewExpr => new CXXNewExpr(handle), - CX_StmtClass.CX_StmtClass_CXXNoexceptExpr => new CXXNoexceptExpr(handle), - CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr => new CXXNullPtrLiteralExpr(handle), - CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr => new CXXPseudoDestructorExpr(handle), - CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator => new CXXRewrittenBinaryOperator(handle), - CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr => new CXXScalarValueInitExpr(handle), - CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr => new CXXStdInitializerListExpr(handle), - CX_StmtClass.CX_StmtClass_CXXThisExpr => new CXXThisExpr(handle), - CX_StmtClass.CX_StmtClass_CXXThrowExpr => new CXXThrowExpr(handle), - CX_StmtClass.CX_StmtClass_CXXTypeidExpr => new CXXTypeidExpr(handle), - CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr => new CXXUnresolvedConstructExpr(handle), - CX_StmtClass.CX_StmtClass_CXXUuidofExpr => new CXXUuidofExpr(handle), - CX_StmtClass.CX_StmtClass_CallExpr => new CallExpr(handle), - CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr => new CUDAKernelCallExpr(handle), - CX_StmtClass.CX_StmtClass_CXXMemberCallExpr => new CXXMemberCallExpr(handle), - CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr => new CXXOperatorCallExpr(handle), - CX_StmtClass.CX_StmtClass_UserDefinedLiteral => new UserDefinedLiteral(handle), - CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr => new BuiltinBitCastExpr(handle), - CX_StmtClass.CX_StmtClass_CStyleCastExpr => new CStyleCastExpr(handle), - CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr => new CXXFunctionalCastExpr(handle), - CX_StmtClass.CX_StmtClass_CXXAddrspaceCastExpr => new CXXAddrspaceCastExpr(handle), - CX_StmtClass.CX_StmtClass_CXXConstCastExpr => new CXXConstCastExpr(handle), - CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr => new CXXDynamicCastExpr(handle), - CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr => new CXXReinterpretCastExpr(handle), - CX_StmtClass.CX_StmtClass_CXXStaticCastExpr => new CXXStaticCastExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr => new ObjCBridgedCastExpr(handle), - CX_StmtClass.CX_StmtClass_ImplicitCastExpr => new ImplicitCastExpr(handle), - CX_StmtClass.CX_StmtClass_CharacterLiteral => new CharacterLiteral(handle), - CX_StmtClass.CX_StmtClass_ChooseExpr => new ChooseExpr(handle), - CX_StmtClass.CX_StmtClass_CompoundLiteralExpr => new CompoundLiteralExpr(handle), - CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr => new ConceptSpecializationExpr(handle), - CX_StmtClass.CX_StmtClass_ConvertVectorExpr => new ConvertVectorExpr(handle), - CX_StmtClass.CX_StmtClass_CoawaitExpr => new CoawaitExpr(handle), - CX_StmtClass.CX_StmtClass_CoyieldExpr => new CoyieldExpr(handle), - CX_StmtClass.CX_StmtClass_DeclRefExpr => new DeclRefExpr(handle), - CX_StmtClass.CX_StmtClass_DependentCoawaitExpr => new DependentCoawaitExpr(handle), - CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr => new DependentScopeDeclRefExpr(handle), - CX_StmtClass.CX_StmtClass_DesignatedInitExpr => new DesignatedInitExpr(handle), - CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr => new DesignatedInitUpdateExpr(handle), - CX_StmtClass.CX_StmtClass_ExpressionTraitExpr => new ExpressionTraitExpr(handle), - CX_StmtClass.CX_StmtClass_ExtVectorElementExpr => new ExtVectorElementExpr(handle), - CX_StmtClass.CX_StmtClass_FixedPointLiteral => new FixedPointLiteral(handle), - CX_StmtClass.CX_StmtClass_FloatingLiteral => new FloatingLiteral(handle), - CX_StmtClass.CX_StmtClass_ConstantExpr => new ConstantExpr(handle), - CX_StmtClass.CX_StmtClass_ExprWithCleanups => new ExprWithCleanups(handle), - CX_StmtClass.CX_StmtClass_FunctionParmPackExpr => new FunctionParmPackExpr(handle), - CX_StmtClass.CX_StmtClass_GNUNullExpr => new GNUNullExpr(handle), - CX_StmtClass.CX_StmtClass_GenericSelectionExpr => new GenericSelectionExpr(handle), - CX_StmtClass.CX_StmtClass_ImaginaryLiteral => new ImaginaryLiteral(handle), - CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr => new ImplicitValueInitExpr(handle), - CX_StmtClass.CX_StmtClass_InitListExpr => new InitListExpr(handle), - CX_StmtClass.CX_StmtClass_IntegerLiteral => new IntegerLiteral(handle), - CX_StmtClass.CX_StmtClass_LambdaExpr => new LambdaExpr(handle), - CX_StmtClass.CX_StmtClass_MSPropertyRefExpr => new MSPropertyRefExpr(handle), - CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr => new MSPropertySubscriptExpr(handle), - CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr => new MaterializeTemporaryExpr(handle), - CX_StmtClass.CX_StmtClass_MatrixSubscriptExpr => new MatrixSubscriptExpr(handle), - CX_StmtClass.CX_StmtClass_MemberExpr => new MemberExpr(handle), - CX_StmtClass.CX_StmtClass_NoInitExpr => new NoInitExpr(handle), - CX_StmtClass.CX_StmtClass_OMPArraySectionExpr => new OMPArraySectionExpr(handle), - CX_StmtClass.CX_StmtClass_OMPArrayShapingExpr => new OMPArrayShapingExpr(handle), - CX_StmtClass.CX_StmtClass_OMPIteratorExpr => new OMPIteratorExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCArrayLiteral => new ObjCArrayLiteral(handle), - CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr => new ObjCAvailabilityCheckExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr => new ObjCBoolLiteralExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCBoxedExpr => new ObjCBoxedExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral => new ObjCDictionaryLiteral(handle), - CX_StmtClass.CX_StmtClass_ObjCEncodeExpr => new ObjCEncodeExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr => new ObjCIndirectCopyRestoreExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCIsaExpr => new ObjCIsaExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr => new ObjCIvarRefExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCMessageExpr => new ObjCMessageExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr => new ObjCPropertyRefExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCProtocolExpr => new ObjCProtocolExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCSelectorExpr => new ObjCSelectorExpr(handle), - CX_StmtClass.CX_StmtClass_ObjCStringLiteral => new ObjCStringLiteral(handle), - CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr => new ObjCSubscriptRefExpr(handle), - CX_StmtClass.CX_StmtClass_OffsetOfExpr => new OffsetOfExpr(handle), - CX_StmtClass.CX_StmtClass_OpaqueValueExpr => new OpaqueValueExpr(handle), - CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr => new UnresolvedLookupExpr(handle), - CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr => new UnresolvedMemberExpr(handle), - CX_StmtClass.CX_StmtClass_PackExpansionExpr => new PackExpansionExpr(handle), - CX_StmtClass.CX_StmtClass_ParenExpr => new ParenExpr(handle), - CX_StmtClass.CX_StmtClass_ParenListExpr => new ParenListExpr(handle), - CX_StmtClass.CX_StmtClass_PredefinedExpr => new PredefinedExpr(handle), - CX_StmtClass.CX_StmtClass_PseudoObjectExpr => new PseudoObjectExpr(handle), - CX_StmtClass.CX_StmtClass_RecoveryExpr => new RecoveryExpr(handle), - CX_StmtClass.CX_StmtClass_RequiresExpr => new RequiresExpr(handle), - CX_StmtClass.CX_StmtClass_SYCLUniqueStableNameExpr => new SYCLUniqueStableNameExpr(handle), - CX_StmtClass.CX_StmtClass_ShuffleVectorExpr => new ShuffleVectorExpr(handle), - CX_StmtClass.CX_StmtClass_SizeOfPackExpr => new SizeOfPackExpr(handle), - CX_StmtClass.CX_StmtClass_SourceLocExpr => new SourceLocExpr(handle), - CX_StmtClass.CX_StmtClass_StmtExpr => new StmtExpr(handle), - CX_StmtClass.CX_StmtClass_StringLiteral => new StringLiteral(handle), - CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr => new SubstNonTypeTemplateParmExpr(handle), - CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr => new SubstNonTypeTemplateParmPackExpr(handle), - CX_StmtClass.CX_StmtClass_TypeTraitExpr => new TypeTraitExpr(handle), - CX_StmtClass.CX_StmtClass_TypoExpr => new TypoExpr(handle), - CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr => new UnaryExprOrTypeTraitExpr(handle), - CX_StmtClass.CX_StmtClass_UnaryOperator => new UnaryOperator(handle), - CX_StmtClass.CX_StmtClass_VAArgExpr => new VAArgExpr(handle), - CX_StmtClass.CX_StmtClass_LabelStmt => new LabelStmt(handle), - CX_StmtClass.CX_StmtClass_WhileStmt => new WhileStmt(handle), - _ => new Stmt(handle, handle.Kind, handle.StmtClass), - }; } + + internal static new Stmt Create(CXCursor handle) => handle.StmtClass switch { + CX_StmtClass.CX_StmtClass_Invalid => new Stmt(handle, handle.Kind, handle.StmtClass), + CX_StmtClass.CX_StmtClass_GCCAsmStmt => new GCCAsmStmt(handle), + CX_StmtClass.CX_StmtClass_MSAsmStmt => new MSAsmStmt(handle), + CX_StmtClass.CX_StmtClass_BreakStmt => new BreakStmt(handle), + CX_StmtClass.CX_StmtClass_CXXCatchStmt => new CXXCatchStmt(handle), + CX_StmtClass.CX_StmtClass_CXXForRangeStmt => new CXXForRangeStmt(handle), + CX_StmtClass.CX_StmtClass_CXXTryStmt => new CXXTryStmt(handle), + CX_StmtClass.CX_StmtClass_CapturedStmt => new CapturedStmt(handle), + CX_StmtClass.CX_StmtClass_CompoundStmt => new CompoundStmt(handle), + CX_StmtClass.CX_StmtClass_ContinueStmt => new ContinueStmt(handle), + CX_StmtClass.CX_StmtClass_CoreturnStmt => new CoreturnStmt(handle), + CX_StmtClass.CX_StmtClass_CoroutineBodyStmt => new CoroutineBodyStmt(handle), + CX_StmtClass.CX_StmtClass_DeclStmt => new DeclStmt(handle), + CX_StmtClass.CX_StmtClass_DoStmt => new DoStmt(handle), + CX_StmtClass.CX_StmtClass_ForStmt => new ForStmt(handle), + CX_StmtClass.CX_StmtClass_GotoStmt => new GotoStmt(handle), + CX_StmtClass.CX_StmtClass_IfStmt => new IfStmt(handle), + CX_StmtClass.CX_StmtClass_IndirectGotoStmt => new IndirectGotoStmt(handle), + CX_StmtClass.CX_StmtClass_MSDependentExistsStmt => new MSDependentExistsStmt(handle), + CX_StmtClass.CX_StmtClass_NullStmt => new NullStmt(handle), + CX_StmtClass.CX_StmtClass_OMPCanonicalLoop => new OMPCanonicalLoop(handle), + CX_StmtClass.CX_StmtClass_OMPAtomicDirective => new OMPAtomicDirective(handle), + CX_StmtClass.CX_StmtClass_OMPBarrierDirective => new OMPBarrierDirective(handle), + CX_StmtClass.CX_StmtClass_OMPCancelDirective => new OMPCancelDirective(handle), + CX_StmtClass.CX_StmtClass_OMPCancellationPointDirective => new OMPCancellationPointDirective(handle), + CX_StmtClass.CX_StmtClass_OMPCriticalDirective => new OMPCriticalDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDepobjDirective => new OMPDepobjDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDispatchDirective => new OMPDispatchDirective(handle), + CX_StmtClass.CX_StmtClass_OMPFlushDirective => new OMPFlushDirective(handle), + CX_StmtClass.CX_StmtClass_OMPInteropDirective => new OMPInteropDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDistributeDirective => new OMPDistributeDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDistributeParallelForDirective => new OMPDistributeParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDistributeParallelForSimdDirective => new OMPDistributeParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPDistributeSimdDirective => new OMPDistributeSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPForDirective => new OMPForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPForSimdDirective => new OMPForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPGenericLoopDirective => new OMPGenericLoopDirective(handle), + CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopDirective => new OMPMasterTaskLoopDirective(handle), + CX_StmtClass.CX_StmtClass_OMPMasterTaskLoopSimdDirective => new OMPMasterTaskLoopSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelForDirective => new OMPParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelForSimdDirective => new OMPParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopDirective => new OMPParallelMasterTaskLoopDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelMasterTaskLoopSimdDirective => new OMPParallelMasterTaskLoopSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPSimdDirective => new OMPSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetParallelForSimdDirective => new OMPTargetParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetSimdDirective => new OMPTargetSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeDirective => new OMPTargetTeamsDistributeDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForDirective => new OMPTargetTeamsDistributeParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeParallelForSimdDirective => new OMPTargetTeamsDistributeParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDistributeSimdDirective => new OMPTargetTeamsDistributeSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskLoopDirective => new OMPTaskLoopDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskLoopSimdDirective => new OMPTaskLoopSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeDirective => new OMPTeamsDistributeDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForDirective => new OMPTeamsDistributeParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeParallelForSimdDirective => new OMPTeamsDistributeParallelForSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDistributeSimdDirective => new OMPTeamsDistributeSimdDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTileDirective => new OMPTileDirective(handle), + CX_StmtClass.CX_StmtClass_OMPUnrollDirective => new OMPUnrollDirective(handle), + CX_StmtClass.CX_StmtClass_OMPMaskedDirective => new OMPMaskedDirective(handle), + CX_StmtClass.CX_StmtClass_OMPMasterDirective => new OMPMasterDirective(handle), + CX_StmtClass.CX_StmtClass_OMPMetaDirective => new OMPMetaDirective(handle), + CX_StmtClass.CX_StmtClass_OMPOrderedDirective => new OMPOrderedDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelDirective => new OMPParallelDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelMasterDirective => new OMPParallelMasterDirective(handle), + CX_StmtClass.CX_StmtClass_OMPParallelSectionsDirective => new OMPParallelSectionsDirective(handle), + CX_StmtClass.CX_StmtClass_OMPScanDirective => new OMPScanDirective(handle), + CX_StmtClass.CX_StmtClass_OMPSectionDirective => new OMPSectionDirective(handle), + CX_StmtClass.CX_StmtClass_OMPSectionsDirective => new OMPSectionsDirective(handle), + CX_StmtClass.CX_StmtClass_OMPSingleDirective => new OMPSingleDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetDataDirective => new OMPTargetDataDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetDirective => new OMPTargetDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetEnterDataDirective => new OMPTargetEnterDataDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetExitDataDirective => new OMPTargetExitDataDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetParallelDirective => new OMPTargetParallelDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetParallelForDirective => new OMPTargetParallelForDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetTeamsDirective => new OMPTargetTeamsDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTargetUpdateDirective => new OMPTargetUpdateDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskDirective => new OMPTaskDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskgroupDirective => new OMPTaskgroupDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskwaitDirective => new OMPTaskwaitDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTaskyieldDirective => new OMPTaskyieldDirective(handle), + CX_StmtClass.CX_StmtClass_OMPTeamsDirective => new OMPTeamsDirective(handle), + CX_StmtClass.CX_StmtClass_ObjCAtCatchStmt => new ObjCAtCatchStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAtFinallyStmt => new ObjCAtFinallyStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAtSynchronizedStmt => new ObjCAtSynchronizedStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAtThrowStmt => new ObjCAtThrowStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAtTryStmt => new ObjCAtTryStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCAutoreleasePoolStmt => new ObjCAutoreleasePoolStmt(handle), + CX_StmtClass.CX_StmtClass_ObjCForCollectionStmt => new ObjCForCollectionStmt(handle), + CX_StmtClass.CX_StmtClass_ReturnStmt => new ReturnStmt(handle), + CX_StmtClass.CX_StmtClass_SEHExceptStmt => new SEHExceptStmt(handle), + CX_StmtClass.CX_StmtClass_SEHFinallyStmt => new SEHFinallyStmt(handle), + CX_StmtClass.CX_StmtClass_SEHLeaveStmt => new SEHLeaveStmt(handle), + CX_StmtClass.CX_StmtClass_SEHTryStmt => new SEHTryStmt(handle), + CX_StmtClass.CX_StmtClass_CaseStmt => new CaseStmt(handle), + CX_StmtClass.CX_StmtClass_DefaultStmt => new DefaultStmt(handle), + CX_StmtClass.CX_StmtClass_SwitchStmt => new SwitchStmt(handle), + CX_StmtClass.CX_StmtClass_AttributedStmt => new AttributedStmt(handle), + CX_StmtClass.CX_StmtClass_BinaryConditionalOperator => new BinaryConditionalOperator(handle), + CX_StmtClass.CX_StmtClass_ConditionalOperator => new ConditionalOperator(handle), + CX_StmtClass.CX_StmtClass_AddrLabelExpr => new AddrLabelExpr(handle), + CX_StmtClass.CX_StmtClass_ArrayInitIndexExpr => new ArrayInitIndexExpr(handle), + CX_StmtClass.CX_StmtClass_ArrayInitLoopExpr => new ArrayInitLoopExpr(handle), + CX_StmtClass.CX_StmtClass_ArraySubscriptExpr => new ArraySubscriptExpr(handle), + CX_StmtClass.CX_StmtClass_ArrayTypeTraitExpr => new ArrayTypeTraitExpr(handle), + CX_StmtClass.CX_StmtClass_AsTypeExpr => new AsTypeExpr(handle), + CX_StmtClass.CX_StmtClass_AtomicExpr => new AtomicExpr(handle), + CX_StmtClass.CX_StmtClass_BinaryOperator => new BinaryOperator(handle), + CX_StmtClass.CX_StmtClass_CompoundAssignOperator => new CompoundAssignOperator(handle), + CX_StmtClass.CX_StmtClass_BlockExpr => new BlockExpr(handle), + CX_StmtClass.CX_StmtClass_CXXBindTemporaryExpr => new CXXBindTemporaryExpr(handle), + CX_StmtClass.CX_StmtClass_CXXBoolLiteralExpr => new CXXBoolLiteralExpr(handle), + CX_StmtClass.CX_StmtClass_CXXConstructExpr => new CXXConstructExpr(handle), + CX_StmtClass.CX_StmtClass_CXXTemporaryObjectExpr => new CXXTemporaryObjectExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDefaultArgExpr => new CXXDefaultArgExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDefaultInitExpr => new CXXDefaultInitExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDeleteExpr => new CXXDeleteExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDependentScopeMemberExpr => new CXXDependentScopeMemberExpr(handle), + CX_StmtClass.CX_StmtClass_CXXFoldExpr => new CXXFoldExpr(handle), + CX_StmtClass.CX_StmtClass_CXXInheritedCtorInitExpr => new CXXInheritedCtorInitExpr(handle), + CX_StmtClass.CX_StmtClass_CXXNewExpr => new CXXNewExpr(handle), + CX_StmtClass.CX_StmtClass_CXXNoexceptExpr => new CXXNoexceptExpr(handle), + CX_StmtClass.CX_StmtClass_CXXNullPtrLiteralExpr => new CXXNullPtrLiteralExpr(handle), + CX_StmtClass.CX_StmtClass_CXXPseudoDestructorExpr => new CXXPseudoDestructorExpr(handle), + CX_StmtClass.CX_StmtClass_CXXRewrittenBinaryOperator => new CXXRewrittenBinaryOperator(handle), + CX_StmtClass.CX_StmtClass_CXXScalarValueInitExpr => new CXXScalarValueInitExpr(handle), + CX_StmtClass.CX_StmtClass_CXXStdInitializerListExpr => new CXXStdInitializerListExpr(handle), + CX_StmtClass.CX_StmtClass_CXXThisExpr => new CXXThisExpr(handle), + CX_StmtClass.CX_StmtClass_CXXThrowExpr => new CXXThrowExpr(handle), + CX_StmtClass.CX_StmtClass_CXXTypeidExpr => new CXXTypeidExpr(handle), + CX_StmtClass.CX_StmtClass_CXXUnresolvedConstructExpr => new CXXUnresolvedConstructExpr(handle), + CX_StmtClass.CX_StmtClass_CXXUuidofExpr => new CXXUuidofExpr(handle), + CX_StmtClass.CX_StmtClass_CallExpr => new CallExpr(handle), + CX_StmtClass.CX_StmtClass_CUDAKernelCallExpr => new CUDAKernelCallExpr(handle), + CX_StmtClass.CX_StmtClass_CXXMemberCallExpr => new CXXMemberCallExpr(handle), + CX_StmtClass.CX_StmtClass_CXXOperatorCallExpr => new CXXOperatorCallExpr(handle), + CX_StmtClass.CX_StmtClass_UserDefinedLiteral => new UserDefinedLiteral(handle), + CX_StmtClass.CX_StmtClass_BuiltinBitCastExpr => new BuiltinBitCastExpr(handle), + CX_StmtClass.CX_StmtClass_CStyleCastExpr => new CStyleCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXFunctionalCastExpr => new CXXFunctionalCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXAddrspaceCastExpr => new CXXAddrspaceCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXConstCastExpr => new CXXConstCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXDynamicCastExpr => new CXXDynamicCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXReinterpretCastExpr => new CXXReinterpretCastExpr(handle), + CX_StmtClass.CX_StmtClass_CXXStaticCastExpr => new CXXStaticCastExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCBridgedCastExpr => new ObjCBridgedCastExpr(handle), + CX_StmtClass.CX_StmtClass_ImplicitCastExpr => new ImplicitCastExpr(handle), + CX_StmtClass.CX_StmtClass_CharacterLiteral => new CharacterLiteral(handle), + CX_StmtClass.CX_StmtClass_ChooseExpr => new ChooseExpr(handle), + CX_StmtClass.CX_StmtClass_CompoundLiteralExpr => new CompoundLiteralExpr(handle), + CX_StmtClass.CX_StmtClass_ConceptSpecializationExpr => new ConceptSpecializationExpr(handle), + CX_StmtClass.CX_StmtClass_ConvertVectorExpr => new ConvertVectorExpr(handle), + CX_StmtClass.CX_StmtClass_CoawaitExpr => new CoawaitExpr(handle), + CX_StmtClass.CX_StmtClass_CoyieldExpr => new CoyieldExpr(handle), + CX_StmtClass.CX_StmtClass_DeclRefExpr => new DeclRefExpr(handle), + CX_StmtClass.CX_StmtClass_DependentCoawaitExpr => new DependentCoawaitExpr(handle), + CX_StmtClass.CX_StmtClass_DependentScopeDeclRefExpr => new DependentScopeDeclRefExpr(handle), + CX_StmtClass.CX_StmtClass_DesignatedInitExpr => new DesignatedInitExpr(handle), + CX_StmtClass.CX_StmtClass_DesignatedInitUpdateExpr => new DesignatedInitUpdateExpr(handle), + CX_StmtClass.CX_StmtClass_ExpressionTraitExpr => new ExpressionTraitExpr(handle), + CX_StmtClass.CX_StmtClass_ExtVectorElementExpr => new ExtVectorElementExpr(handle), + CX_StmtClass.CX_StmtClass_FixedPointLiteral => new FixedPointLiteral(handle), + CX_StmtClass.CX_StmtClass_FloatingLiteral => new FloatingLiteral(handle), + CX_StmtClass.CX_StmtClass_ConstantExpr => new ConstantExpr(handle), + CX_StmtClass.CX_StmtClass_ExprWithCleanups => new ExprWithCleanups(handle), + CX_StmtClass.CX_StmtClass_FunctionParmPackExpr => new FunctionParmPackExpr(handle), + CX_StmtClass.CX_StmtClass_GNUNullExpr => new GNUNullExpr(handle), + CX_StmtClass.CX_StmtClass_GenericSelectionExpr => new GenericSelectionExpr(handle), + CX_StmtClass.CX_StmtClass_ImaginaryLiteral => new ImaginaryLiteral(handle), + CX_StmtClass.CX_StmtClass_ImplicitValueInitExpr => new ImplicitValueInitExpr(handle), + CX_StmtClass.CX_StmtClass_InitListExpr => new InitListExpr(handle), + CX_StmtClass.CX_StmtClass_IntegerLiteral => new IntegerLiteral(handle), + CX_StmtClass.CX_StmtClass_LambdaExpr => new LambdaExpr(handle), + CX_StmtClass.CX_StmtClass_MSPropertyRefExpr => new MSPropertyRefExpr(handle), + CX_StmtClass.CX_StmtClass_MSPropertySubscriptExpr => new MSPropertySubscriptExpr(handle), + CX_StmtClass.CX_StmtClass_MaterializeTemporaryExpr => new MaterializeTemporaryExpr(handle), + CX_StmtClass.CX_StmtClass_MatrixSubscriptExpr => new MatrixSubscriptExpr(handle), + CX_StmtClass.CX_StmtClass_MemberExpr => new MemberExpr(handle), + CX_StmtClass.CX_StmtClass_NoInitExpr => new NoInitExpr(handle), + CX_StmtClass.CX_StmtClass_OMPArraySectionExpr => new OMPArraySectionExpr(handle), + CX_StmtClass.CX_StmtClass_OMPArrayShapingExpr => new OMPArrayShapingExpr(handle), + CX_StmtClass.CX_StmtClass_OMPIteratorExpr => new OMPIteratorExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCArrayLiteral => new ObjCArrayLiteral(handle), + CX_StmtClass.CX_StmtClass_ObjCAvailabilityCheckExpr => new ObjCAvailabilityCheckExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCBoolLiteralExpr => new ObjCBoolLiteralExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCBoxedExpr => new ObjCBoxedExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCDictionaryLiteral => new ObjCDictionaryLiteral(handle), + CX_StmtClass.CX_StmtClass_ObjCEncodeExpr => new ObjCEncodeExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCIndirectCopyRestoreExpr => new ObjCIndirectCopyRestoreExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCIsaExpr => new ObjCIsaExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCIvarRefExpr => new ObjCIvarRefExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCMessageExpr => new ObjCMessageExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCPropertyRefExpr => new ObjCPropertyRefExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCProtocolExpr => new ObjCProtocolExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCSelectorExpr => new ObjCSelectorExpr(handle), + CX_StmtClass.CX_StmtClass_ObjCStringLiteral => new ObjCStringLiteral(handle), + CX_StmtClass.CX_StmtClass_ObjCSubscriptRefExpr => new ObjCSubscriptRefExpr(handle), + CX_StmtClass.CX_StmtClass_OffsetOfExpr => new OffsetOfExpr(handle), + CX_StmtClass.CX_StmtClass_OpaqueValueExpr => new OpaqueValueExpr(handle), + CX_StmtClass.CX_StmtClass_UnresolvedLookupExpr => new UnresolvedLookupExpr(handle), + CX_StmtClass.CX_StmtClass_UnresolvedMemberExpr => new UnresolvedMemberExpr(handle), + CX_StmtClass.CX_StmtClass_PackExpansionExpr => new PackExpansionExpr(handle), + CX_StmtClass.CX_StmtClass_ParenExpr => new ParenExpr(handle), + CX_StmtClass.CX_StmtClass_ParenListExpr => new ParenListExpr(handle), + CX_StmtClass.CX_StmtClass_PredefinedExpr => new PredefinedExpr(handle), + CX_StmtClass.CX_StmtClass_PseudoObjectExpr => new PseudoObjectExpr(handle), + CX_StmtClass.CX_StmtClass_RecoveryExpr => new RecoveryExpr(handle), + CX_StmtClass.CX_StmtClass_RequiresExpr => new RequiresExpr(handle), + CX_StmtClass.CX_StmtClass_SYCLUniqueStableNameExpr => new SYCLUniqueStableNameExpr(handle), + CX_StmtClass.CX_StmtClass_ShuffleVectorExpr => new ShuffleVectorExpr(handle), + CX_StmtClass.CX_StmtClass_SizeOfPackExpr => new SizeOfPackExpr(handle), + CX_StmtClass.CX_StmtClass_SourceLocExpr => new SourceLocExpr(handle), + CX_StmtClass.CX_StmtClass_StmtExpr => new StmtExpr(handle), + CX_StmtClass.CX_StmtClass_StringLiteral => new StringLiteral(handle), + CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmExpr => new SubstNonTypeTemplateParmExpr(handle), + CX_StmtClass.CX_StmtClass_SubstNonTypeTemplateParmPackExpr => new SubstNonTypeTemplateParmPackExpr(handle), + CX_StmtClass.CX_StmtClass_TypeTraitExpr => new TypeTraitExpr(handle), + CX_StmtClass.CX_StmtClass_TypoExpr => new TypoExpr(handle), + CX_StmtClass.CX_StmtClass_UnaryExprOrTypeTraitExpr => new UnaryExprOrTypeTraitExpr(handle), + CX_StmtClass.CX_StmtClass_UnaryOperator => new UnaryOperator(handle), + CX_StmtClass.CX_StmtClass_VAArgExpr => new VAArgExpr(handle), + CX_StmtClass.CX_StmtClass_LabelStmt => new LabelStmt(handle), + CX_StmtClass.CX_StmtClass_WhileStmt => new WhileStmt(handle), + _ => new Stmt(handle, handle.Kind, handle.StmtClass), + }; } diff --git a/sources/ClangSharp/Cursors/Stmts/SwitchCase.cs b/sources/ClangSharp/Cursors/Stmts/SwitchCase.cs index 6f1f1940..a96ee2c4 100644 --- a/sources/ClangSharp/Cursors/Stmts/SwitchCase.cs +++ b/sources/ClangSharp/Cursors/Stmts/SwitchCase.cs @@ -4,40 +4,39 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class SwitchCase : Stmt { - public class SwitchCase : Stmt - { - private readonly Lazy _nextSwitchCase; + private readonly Lazy _nextSwitchCase; - private protected SwitchCase(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + private protected SwitchCase(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + { + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastSwitchCase or < CX_StmtClass.CX_StmtClass_FirstSwitchCase) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastSwitchCase or < CX_StmtClass.CX_StmtClass_FirstSwitchCase) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - - _nextSwitchCase = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NextSwitchCase)); + throw new ArgumentOutOfRangeException(nameof(handle)); } - public SwitchCase NextSwitchCase => _nextSwitchCase.Value; + _nextSwitchCase = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NextSwitchCase)); + } + + public SwitchCase NextSwitchCase => _nextSwitchCase.Value; - public Stmt SubStmt + public Stmt SubStmt + { + get { - get + if (this is CaseStmt cs) { - if (this is CaseStmt cs) - { - return cs.SubStmt; - } - else if (this is DefaultStmt ds) - { - return ds.SubStmt; - } - - Debug.Fail("SwitchCase is neither a CaseStmt nor a DefaultStmt!"); - return null; + return cs.SubStmt; } + else if (this is DefaultStmt ds) + { + return ds.SubStmt; + } + + Debug.Fail("SwitchCase is neither a CaseStmt nor a DefaultStmt!"); + return null; } } } diff --git a/sources/ClangSharp/Cursors/Stmts/SwitchStmt.cs b/sources/ClangSharp/Cursors/Stmts/SwitchStmt.cs index e1e1872c..2c4ef06e 100644 --- a/sources/ClangSharp/Cursors/Stmts/SwitchStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/SwitchStmt.cs @@ -4,43 +4,42 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SwitchStmt : Stmt { - public sealed class SwitchStmt : Stmt - { - private readonly Lazy _switchCaseList; + private readonly Lazy _switchCaseList; - internal SwitchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SwitchStmt, CX_StmtClass.CX_StmtClass_SwitchStmt) - { - Debug.Assert(NumChildren is >= 2 and <= 4); - _switchCaseList = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SubStmt)); - } + internal SwitchStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_SwitchStmt, CX_StmtClass.CX_StmtClass_SwitchStmt) + { + Debug.Assert(NumChildren is >= 2 and <= 4); + _switchCaseList = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SubStmt)); + } - public Stmt Body => Children[BodyOffset]; + public Stmt Body => Children[BodyOffset]; - public Expr Cond => (Expr)Children[CondOffset]; + public Expr Cond => (Expr)Children[CondOffset]; - public VarDecl ConditionVariable => (VarDecl)ConditionVariableDeclStmt?.SingleDecl; + public VarDecl ConditionVariable => (VarDecl)ConditionVariableDeclStmt?.SingleDecl; - public DeclStmt ConditionVariableDeclStmt => HasVarStorage ? (DeclStmt)Children[VarOffset] : null; + public DeclStmt ConditionVariableDeclStmt => HasVarStorage ? (DeclStmt)Children[VarOffset] : null; - public bool HasInitStorage => Handle.HasInit; + public bool HasInitStorage => Handle.HasInit; - public bool HasVarStorage => Handle.HasVarStorage; + public bool HasVarStorage => Handle.HasVarStorage; - public Stmt Init => HasInitStorage ? Children[InitOffset] : null; + public Stmt Init => HasInitStorage ? Children[InitOffset] : null; - public bool IsAllEnumCasesCovered => Handle.IsAllEnumCasesCovered; + public bool IsAllEnumCasesCovered => Handle.IsAllEnumCasesCovered; - public SwitchCase SwitchCaseList => _switchCaseList.Value; + public SwitchCase SwitchCaseList => _switchCaseList.Value; - private int BodyOffset => CondOffset + 1; + private int BodyOffset => CondOffset + 1; - private int CondOffset => VarOffset + (HasVarStorage ? 1 : 0); + private int CondOffset => VarOffset + (HasVarStorage ? 1 : 0); - private static int InitOffset => 0; + private static int InitOffset => 0; - private int VarOffset => InitOffset + (HasInitStorage ? 1 : 0); + private int VarOffset => InitOffset + (HasInitStorage ? 1 : 0); - } } diff --git a/sources/ClangSharp/Cursors/Stmts/ValueStmt.cs b/sources/ClangSharp/Cursors/Stmts/ValueStmt.cs index b8835f61..6d9b0bd8 100644 --- a/sources/ClangSharp/Cursors/Stmts/ValueStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ValueStmt.cs @@ -4,47 +4,46 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class ValueStmt : Stmt { - public class ValueStmt : Stmt + private protected ValueStmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) { - private protected ValueStmt(CXCursor handle, CXCursorKind expectedCursorKind, CX_StmtClass expectedStmtClass) : base(handle, expectedCursorKind, expectedStmtClass) + if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastValueStmt or < CX_StmtClass.CX_StmtClass_FirstValueStmt) { - if (handle.StmtClass is > CX_StmtClass.CX_StmtClass_LastValueStmt or < CX_StmtClass.CX_StmtClass_FirstValueStmt) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); } + } - public Expr ExprStmt + public Expr ExprStmt + { + get { - get - { - Stmt s = this; + Stmt s = this; - do + do + { + if (s is Expr e) { - if (s is Expr e) - { - return e; - } + return e; + } - if (s is LabelStmt ls) - { - s = ls.SubStmt; - } - else if (s is AttributedStmt @as) - { - s = @as.SubStmt; - } - else - { - Debug.Fail("unknown kind of ValueStmt"); - } - } while (s is ValueStmt); + if (s is LabelStmt ls) + { + s = ls.SubStmt; + } + else if (s is AttributedStmt @as) + { + s = @as.SubStmt; + } + else + { + Debug.Fail("unknown kind of ValueStmt"); + } + } while (s is ValueStmt); - return null; - } + return null; } } } diff --git a/sources/ClangSharp/Cursors/Stmts/WhileStmt.cs b/sources/ClangSharp/Cursors/Stmts/WhileStmt.cs index edb3e0ed..9dfad470 100644 --- a/sources/ClangSharp/Cursors/Stmts/WhileStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/WhileStmt.cs @@ -3,29 +3,28 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class WhileStmt : Stmt { - public sealed class WhileStmt : Stmt + internal WhileStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_WhileStmt, CX_StmtClass.CX_StmtClass_WhileStmt) { - internal WhileStmt(CXCursor handle) : base(handle, CXCursorKind.CXCursor_WhileStmt, CX_StmtClass.CX_StmtClass_WhileStmt) - { - Debug.Assert(NumChildren is 2 or 3); - } + Debug.Assert(NumChildren is 2 or 3); + } - public Stmt Body => Children[BodyOffset]; + public Stmt Body => Children[BodyOffset]; - public Expr Cond => (Expr)Children[CondOffset]; + public Expr Cond => (Expr)Children[CondOffset]; - public bool HasVarStorage => Handle.HasVarStorage; + public bool HasVarStorage => Handle.HasVarStorage; - public VarDecl ConditionVariable => (VarDecl)ConditionVariableDeclStmt?.SingleDecl; + public VarDecl ConditionVariable => (VarDecl)ConditionVariableDeclStmt?.SingleDecl; - public DeclStmt ConditionVariableDeclStmt => HasVarStorage ? (DeclStmt)Children[VarOffset] : null; + public DeclStmt ConditionVariableDeclStmt => HasVarStorage ? (DeclStmt)Children[VarOffset] : null; - private int BodyOffset => CondOffset + 1; + private int BodyOffset => CondOffset + 1; - private int CondOffset => VarOffset + (HasVarStorage ? 1 : 0); + private int CondOffset => VarOffset + (HasVarStorage ? 1 : 0); - private static int VarOffset => 0; - } + private static int VarOffset => 0; } diff --git a/sources/ClangSharp/IDeclContext.cs b/sources/ClangSharp/IDeclContext.cs index 7033c480..71cfb0f7 100644 --- a/sources/ClangSharp/IDeclContext.cs +++ b/sources/ClangSharp/IDeclContext.cs @@ -2,22 +2,21 @@ using System.Collections.Generic; -namespace ClangSharp +namespace ClangSharp; + +public interface IDeclContext { - public interface IDeclContext - { - IReadOnlyList Decls { get; } + IReadOnlyList Decls { get; } - bool IsNamespace { get; } + bool IsNamespace { get; } - bool IsStdNamespace { get; } + bool IsStdNamespace { get; } - bool IsTranslationUnit { get; } + bool IsTranslationUnit { get; } - IDeclContext LexicalParent { get; } + IDeclContext LexicalParent { get; } - IDeclContext Parent { get; } + IDeclContext Parent { get; } - IDeclContext RedeclContext { get; } - } + IDeclContext RedeclContext { get; } } diff --git a/sources/ClangSharp/IMergeable`1.cs b/sources/ClangSharp/IMergeable`1.cs index 29a180b6..756599aa 100644 --- a/sources/ClangSharp/IMergeable`1.cs +++ b/sources/ClangSharp/IMergeable`1.cs @@ -1,9 +1,8 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp +namespace ClangSharp; + +public interface IMergeable + where TDecl : Decl { - public interface IMergeable - where TDecl : Decl - { - } } diff --git a/sources/ClangSharp/IRedeclarable`1.cs b/sources/ClangSharp/IRedeclarable`1.cs index 1a00e2f9..6a7d7a6a 100644 --- a/sources/ClangSharp/IRedeclarable`1.cs +++ b/sources/ClangSharp/IRedeclarable`1.cs @@ -1,9 +1,8 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp +namespace ClangSharp; + +public interface IRedeclarable + where TDecl : Decl { - public interface IRedeclarable - where TDecl : Decl - { - } } diff --git a/sources/ClangSharp/ITemplateParmPosition.cs b/sources/ClangSharp/ITemplateParmPosition.cs index 79b441f8..04bbfa87 100644 --- a/sources/ClangSharp/ITemplateParmPosition.cs +++ b/sources/ClangSharp/ITemplateParmPosition.cs @@ -1,8 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. -namespace ClangSharp +namespace ClangSharp; + +public interface ITemplateParmPosition { - public interface ITemplateParmPosition - { - } } diff --git a/sources/ClangSharp/Index.cs b/sources/ClangSharp/Index.cs index bea61aac..46a6fbcd 100644 --- a/sources/ClangSharp/Index.cs +++ b/sources/ClangSharp/Index.cs @@ -3,58 +3,57 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class Index : IDisposable, IEquatable { - public sealed class Index : IDisposable, IEquatable + private bool _isDisposed; + + private Index(CXIndex handle) { - private bool _isDisposed; + Handle = handle; + } - private Index(CXIndex handle) - { - Handle = handle; - } + ~Index() + { + Dispose(isDisposing: false); + } - ~Index() - { - Dispose(isDisposing: false); - } + public CXIndex Handle { get; } - public CXIndex Handle { get; } + public static bool operator ==(Index left, Index right) => (left is not null) ? ((right is not null) && (left.Handle == right.Handle)) : (right is null); - public static bool operator ==(Index left, Index right) => (left is object) ? ((right is object) && (left.Handle == right.Handle)) : (right is null); + public static bool operator !=(Index left, Index right) => (left is not null) ? ((right is null) || (left.Handle != right.Handle)) : (right is not null); - public static bool operator !=(Index left, Index right) => (left is object) ? ((right is null) || (left.Handle != right.Handle)) : (right is object); + public static Index Create(bool excludeDeclarationsFromPch = false, bool displayDiagnostics = false) + { + var handle = CXIndex.Create(excludeDeclarationsFromPch, displayDiagnostics); + return new Index(handle); + } - public static Index Create(bool excludeDeclarationsFromPch = false, bool displayDiagnostics = false) - { - var handle = CXIndex.Create(excludeDeclarationsFromPch, displayDiagnostics); - return new Index(handle); - } + public void Dispose() + { + Dispose(isDisposing: true); + GC.SuppressFinalize(this); + } - public void Dispose() - { - Dispose(isDisposing: true); - GC.SuppressFinalize(this); - } + public override bool Equals(object obj) => (obj is Index other) && Equals(other); - public override bool Equals(object obj) => (obj is Index other) && Equals(other); + public bool Equals(Index other) => this == other; - public bool Equals(Index other) => this == other; + public override int GetHashCode() => Handle.GetHashCode(); - public override int GetHashCode() => Handle.GetHashCode(); + private void Dispose(bool isDisposing) + { + if (_isDisposed) + { + return; + } + _isDisposed = true; - private void Dispose(bool isDisposing) + if (Handle != default) { - if (_isDisposed) - { - return; - } - _isDisposed = true; - - if (Handle != default) - { - Handle.Dispose(); - } + Handle.Dispose(); } } } diff --git a/sources/ClangSharp/TemplateArgument.cs b/sources/ClangSharp/TemplateArgument.cs index 59cb0618..8bfb17c0 100644 --- a/sources/ClangSharp/TemplateArgument.cs +++ b/sources/ClangSharp/TemplateArgument.cs @@ -5,139 +5,138 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed unsafe class TemplateArgument : IDisposable { - public sealed unsafe class TemplateArgument : IDisposable + private readonly Lazy _asDecl; + private readonly Lazy _asExpr; + private readonly Lazy _asTemplate; + private readonly Lazy _asTemplateOrTemplatePattern; + private readonly Lazy _asType; + private readonly Lazy _integralType; + private readonly Lazy _nonTypeTemplateArgumentType; + private readonly Lazy _nullPtrType; + private readonly Lazy> _packElements; + private readonly Lazy _packExpansionPattern; + private readonly Lazy _paramTypeForDecl; + private readonly Lazy _translationUnit; + + internal TemplateArgument(CX_TemplateArgument handle) { - private readonly Lazy _asDecl; - private readonly Lazy _asExpr; - private readonly Lazy _asTemplate; - private readonly Lazy _asTemplateOrTemplatePattern; - private readonly Lazy _asType; - private readonly Lazy _integralType; - private readonly Lazy _nonTypeTemplateArgumentType; - private readonly Lazy _nullPtrType; - private readonly Lazy> _packElements; - private readonly Lazy _packExpansionPattern; - private readonly Lazy _paramTypeForDecl; - private readonly Lazy _translationUnit; - - internal TemplateArgument(CX_TemplateArgument handle) - { - Handle = handle; - - _asDecl = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsDecl)); - _asExpr = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsExpr)); - _asTemplate = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsTemplate)); - _asTemplateOrTemplatePattern = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsTemplateOrTemplatePattern)); - _asType = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsType)); - _integralType = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.IntegralType)); - _nonTypeTemplateArgumentType = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.NonTypeTemplateArgumentType)); - _nullPtrType = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.NullPtrType)); - _packExpansionPattern = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.PackExpansionPattern)); - - _packElements = new Lazy>(() => { - var numPackElements = Handle.NumPackElements; - var packElements = new List(numPackElements); - - for (var i = 0; i < numPackElements; i++) - { - var packElement = _translationUnit.Value.GetOrCreate(Handle.GetPackElement(unchecked((uint)i))); - packElements.Add(packElement); - } + Handle = handle; + + _asDecl = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsDecl)); + _asExpr = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsExpr)); + _asTemplate = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsTemplate)); + _asTemplateOrTemplatePattern = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsTemplateOrTemplatePattern)); + _asType = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsType)); + _integralType = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.IntegralType)); + _nonTypeTemplateArgumentType = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.NonTypeTemplateArgumentType)); + _nullPtrType = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.NullPtrType)); + _packExpansionPattern = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.PackExpansionPattern)); + + _packElements = new Lazy>(() => { + var numPackElements = Handle.NumPackElements; + var packElements = new List(numPackElements); + + for (var i = 0; i < numPackElements; i++) + { + var packElement = _translationUnit.Value.GetOrCreate(Handle.GetPackElement(unchecked((uint)i))); + packElements.Add(packElement); + } - return packElements; - }); + return packElements; + }); - _paramTypeForDecl = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.ParamTypeForDecl)); - _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate(Handle.tu)); - } + _paramTypeForDecl = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.ParamTypeForDecl)); + _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate(Handle.tu)); + } - ~TemplateArgument() => Dispose(isDisposing: false); + ~TemplateArgument() => Dispose(isDisposing: false); - public ValueDecl AsDecl => _asDecl.Value; + public ValueDecl AsDecl => _asDecl.Value; - public Expr AsExpr => _asExpr.Value; + public Expr AsExpr => _asExpr.Value; - public long AsIntegral => Handle.AsIntegral; + public long AsIntegral => Handle.AsIntegral; - public TemplateName AsTemplate => _asTemplate.Value; + public TemplateName AsTemplate => _asTemplate.Value; - public TemplateName AsTemplateOrTemplatePattern => _asTemplateOrTemplatePattern.Value; + public TemplateName AsTemplateOrTemplatePattern => _asTemplateOrTemplatePattern.Value; - public Type AsType => _asType.Value; + public Type AsType => _asType.Value; - public bool ContainsUnexpandedParameterPack => (Dependence & CX_TemplateArgumentDependence.CX_TAD_UnexpandedPack) != 0; + public bool ContainsUnexpandedParameterPack => (Dependence & CX_TemplateArgumentDependence.CX_TAD_UnexpandedPack) != 0; - public CX_TemplateArgumentDependence Dependence => Handle.Dependence; + public CX_TemplateArgumentDependence Dependence => Handle.Dependence; - public Type IntegralType => _integralType.Value; + public Type IntegralType => _integralType.Value; - public bool IsDependent => (Dependence & CX_TemplateArgumentDependence.CX_TAD_Dependent) != 0; + public bool IsDependent => (Dependence & CX_TemplateArgumentDependence.CX_TAD_Dependent) != 0; - public bool IsInstantiationDependent => (Dependence & CX_TemplateArgumentDependence.CX_TAD_Instantiation) != 0; + public bool IsInstantiationDependent => (Dependence & CX_TemplateArgumentDependence.CX_TAD_Instantiation) != 0; - public bool IsNull => Kind == CXTemplateArgumentKind.CXTemplateArgumentKind_Null; + public bool IsNull => Kind == CXTemplateArgumentKind.CXTemplateArgumentKind_Null; - public bool IsPackExpansion + public bool IsPackExpansion + { + get { - get - { - switch (Kind) + switch (Kind) { - case CXTemplateArgumentKind.CXTemplateArgumentKind_Null: - case CXTemplateArgumentKind.CXTemplateArgumentKind_Declaration: - case CXTemplateArgumentKind.CXTemplateArgumentKind_Integral: - case CXTemplateArgumentKind.CXTemplateArgumentKind_Pack: - case CXTemplateArgumentKind.CXTemplateArgumentKind_Template: - case CXTemplateArgumentKind.CXTemplateArgumentKind_NullPtr: - { - return false; - } - - case CXTemplateArgumentKind.CXTemplateArgumentKind_TemplateExpansion: - { - return true; - } - - case CXTemplateArgumentKind.CXTemplateArgumentKind_Type: - { - return AsType is PackExpansionType; - } - - case CXTemplateArgumentKind.CXTemplateArgumentKind_Expression: - { - return AsExpr is PackExpansionExpr; - } + case CXTemplateArgumentKind.CXTemplateArgumentKind_Null: + case CXTemplateArgumentKind.CXTemplateArgumentKind_Declaration: + case CXTemplateArgumentKind.CXTemplateArgumentKind_Integral: + case CXTemplateArgumentKind.CXTemplateArgumentKind_Pack: + case CXTemplateArgumentKind.CXTemplateArgumentKind_Template: + case CXTemplateArgumentKind.CXTemplateArgumentKind_NullPtr: + { + return false; + } + + case CXTemplateArgumentKind.CXTemplateArgumentKind_TemplateExpansion: + { + return true; + } + + case CXTemplateArgumentKind.CXTemplateArgumentKind_Type: + { + return AsType is PackExpansionType; } - Debug.Fail("Invalid TemplateArgument Kind!"); - return false; + case CXTemplateArgumentKind.CXTemplateArgumentKind_Expression: + { + return AsExpr is PackExpansionExpr; + } } - } - public CX_TemplateArgument Handle { get; } + Debug.Fail("Invalid TemplateArgument Kind!"); + return false; + } + } - public CXTemplateArgumentKind Kind => Handle.kind; + public CX_TemplateArgument Handle { get; } - public Type NonTypeTemplateArgumentType => _nonTypeTemplateArgumentType.Value; + public CXTemplateArgumentKind Kind => Handle.kind; - public Type NullPtrType => _nullPtrType.Value; + public Type NonTypeTemplateArgumentType => _nonTypeTemplateArgumentType.Value; - public IReadOnlyList PackElements => _packElements.Value; + public Type NullPtrType => _nullPtrType.Value; - public TemplateArgument PackExpansionPattern => _packExpansionPattern.Value; + public IReadOnlyList PackElements => _packElements.Value; - public Type ParamTypeForDecl => _paramTypeForDecl.Value; + public TemplateArgument PackExpansionPattern => _packExpansionPattern.Value; - public TranslationUnit TranslationUnit => _translationUnit.Value; + public Type ParamTypeForDecl => _paramTypeForDecl.Value; - public void Dispose() - { - Dispose(isDisposing: true); - GC.SuppressFinalize(this); - } + public TranslationUnit TranslationUnit => _translationUnit.Value; - private void Dispose(bool isDisposing) => Handle.Dispose(); + public void Dispose() + { + Dispose(isDisposing: true); + GC.SuppressFinalize(this); } + + private void Dispose(bool isDisposing) => Handle.Dispose(); } diff --git a/sources/ClangSharp/TemplateArgumentLoc.cs b/sources/ClangSharp/TemplateArgumentLoc.cs index 19797636..99554b53 100644 --- a/sources/ClangSharp/TemplateArgumentLoc.cs +++ b/sources/ClangSharp/TemplateArgumentLoc.cs @@ -3,45 +3,44 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed unsafe class TemplateArgumentLoc { - public sealed unsafe class TemplateArgumentLoc + private readonly Lazy _argument; + private readonly Lazy _sourceDeclExpression; + private readonly Lazy _sourceExpression; + private readonly Lazy _sourceIntegralExpression; + private readonly Lazy _sourceNullPtrExpression; + private readonly Lazy _translationUnit; + + internal TemplateArgumentLoc(CX_TemplateArgumentLoc handle) { - private readonly Lazy _argument; - private readonly Lazy _sourceDeclExpression; - private readonly Lazy _sourceExpression; - private readonly Lazy _sourceIntegralExpression; - private readonly Lazy _sourceNullPtrExpression; - private readonly Lazy _translationUnit; - - internal TemplateArgumentLoc(CX_TemplateArgumentLoc handle) - { - Handle = handle; - - _argument = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.Argument)); - _sourceDeclExpression = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.SourceDeclExpression)); - _sourceExpression = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.SourceExpression)); - _sourceIntegralExpression = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.SourceIntegralExpression)); - _sourceNullPtrExpression = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.SourceNullPtrExpression)); - _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate(Handle.tu)); - } + Handle = handle; + + _argument = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.Argument)); + _sourceDeclExpression = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.SourceDeclExpression)); + _sourceExpression = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.SourceExpression)); + _sourceIntegralExpression = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.SourceIntegralExpression)); + _sourceNullPtrExpression = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.SourceNullPtrExpression)); + _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate(Handle.tu)); + } - public TemplateArgument Argument => _argument.Value; + public TemplateArgument Argument => _argument.Value; - public CXSourceLocation Location => Handle.Location; + public CXSourceLocation Location => Handle.Location; - public CX_TemplateArgumentLoc Handle { get; } + public CX_TemplateArgumentLoc Handle { get; } - public Expr SourceDeclExpression => _sourceDeclExpression.Value; + public Expr SourceDeclExpression => _sourceDeclExpression.Value; - public Expr SourceExpression => _sourceExpression.Value; + public Expr SourceExpression => _sourceExpression.Value; - public Expr SourceIntegralExpression => _sourceIntegralExpression.Value; + public Expr SourceIntegralExpression => _sourceIntegralExpression.Value; - public Expr SourceNullPtrExpression => _sourceNullPtrExpression.Value; + public Expr SourceNullPtrExpression => _sourceNullPtrExpression.Value; - public CXSourceRange SourceRange => Handle.SourceRange; + public CXSourceRange SourceRange => Handle.SourceRange; - public TranslationUnit TranslationUnit => _translationUnit.Value; - } + public TranslationUnit TranslationUnit => _translationUnit.Value; } diff --git a/sources/ClangSharp/TemplateName.cs b/sources/ClangSharp/TemplateName.cs index 71d681e3..3e724194 100644 --- a/sources/ClangSharp/TemplateName.cs +++ b/sources/ClangSharp/TemplateName.cs @@ -3,25 +3,24 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed unsafe class TemplateName { - public sealed unsafe class TemplateName - { - private readonly Lazy _asTemplateDecl; - private readonly Lazy _translationUnit; + private readonly Lazy _asTemplateDecl; + private readonly Lazy _translationUnit; - internal TemplateName(CX_TemplateName handle) - { - Handle = handle; + internal TemplateName(CX_TemplateName handle) + { + Handle = handle; - _asTemplateDecl = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsTemplateDecl)); - _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate(Handle.tu)); - } + _asTemplateDecl = new Lazy(() => _translationUnit.Value.GetOrCreate(Handle.AsTemplateDecl)); + _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate(Handle.tu)); + } - public TemplateDecl AsTemplateDecl => _asTemplateDecl.Value; + public TemplateDecl AsTemplateDecl => _asTemplateDecl.Value; - public CX_TemplateName Handle { get; } + public CX_TemplateName Handle { get; } - public TranslationUnit TranslationUnit => _translationUnit.Value; - } + public TranslationUnit TranslationUnit => _translationUnit.Value; } diff --git a/sources/ClangSharp/TranslationUnit.cs b/sources/ClangSharp/TranslationUnit.cs index afa4abec..79c3c04e 100644 --- a/sources/ClangSharp/TranslationUnit.cs +++ b/sources/ClangSharp/TranslationUnit.cs @@ -5,209 +5,208 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed unsafe class TranslationUnit : IDisposable, IEquatable { - public sealed unsafe class TranslationUnit : IDisposable, IEquatable - { - private static readonly ConcurrentDictionary> s_createdTranslationUnits = new ConcurrentDictionary>(); - private static readonly object s_createTranslationUnitLock = new object(); + private static readonly ConcurrentDictionary> s_createdTranslationUnits = new ConcurrentDictionary>(); + private static readonly object s_createTranslationUnitLock = new object(); - private readonly Dictionary> _createdCursors; - private readonly Dictionary> _createdTemplateArguments; - private readonly Dictionary> _createdTemplateArgumentLocs; - private readonly Dictionary> _createdTemplateNames; - private readonly Dictionary> _createdTypes; - private readonly Lazy _translationUnitDecl; + private readonly Dictionary> _createdCursors; + private readonly Dictionary> _createdTemplateArguments; + private readonly Dictionary> _createdTemplateArgumentLocs; + private readonly Dictionary> _createdTemplateNames; + private readonly Dictionary> _createdTypes; + private readonly Lazy _translationUnitDecl; - private bool _isDisposed; + private bool _isDisposed; - private TranslationUnit(CXTranslationUnit handle) - { - Handle = handle; + private TranslationUnit(CXTranslationUnit handle) + { + Handle = handle; - _createdCursors = new Dictionary>(); - _createdTemplateArguments = new Dictionary>(); - _createdTemplateArgumentLocs = new Dictionary>(); - _createdTemplateNames = new Dictionary>(); - _createdTypes = new Dictionary>(); + _createdCursors = new Dictionary>(); + _createdTemplateArguments = new Dictionary>(); + _createdTemplateArgumentLocs = new Dictionary>(); + _createdTemplateNames = new Dictionary>(); + _createdTypes = new Dictionary>(); - _translationUnitDecl = new Lazy(() => GetOrCreate(Handle.Cursor)); - } + _translationUnitDecl = new Lazy(() => GetOrCreate(Handle.Cursor)); + } - ~TranslationUnit() - { - Dispose(isDisposing: false); - } + ~TranslationUnit() + { + Dispose(isDisposing: false); + } - public CXTranslationUnit Handle { get; } + public CXTranslationUnit Handle { get; } - public TranslationUnitDecl TranslationUnitDecl => _translationUnitDecl.Value; + public TranslationUnitDecl TranslationUnitDecl => _translationUnitDecl.Value; - public static bool operator ==(TranslationUnit left, TranslationUnit right) => (left is object) ? ((right is object) && (left.Handle == right.Handle)) : (right is null); + public static bool operator ==(TranslationUnit left, TranslationUnit right) => (left is not null) ? ((right is not null) && (left.Handle == right.Handle)) : (right is null); - public static bool operator !=(TranslationUnit left, TranslationUnit right) => (left is object) ? ((right is null) || (left.Handle != right.Handle)) : (right is object); + public static bool operator !=(TranslationUnit left, TranslationUnit right) => (left is not null) ? ((right is null) || (left.Handle != right.Handle)) : (right is not null); - public static TranslationUnit GetOrCreate(CXTranslationUnit handle) + public static TranslationUnit GetOrCreate(CXTranslationUnit handle) + { + if (handle == null) { - if (handle == null) - { - return null; - } + return null; + } - var translationUnitRef = s_createdTranslationUnits.GetOrAdd(handle, (handle) => new WeakReference(null)); + var translationUnitRef = s_createdTranslationUnits.GetOrAdd(handle, (handle) => new WeakReference(null)); - if (!translationUnitRef.TryGetTarget(out var translationUnit)) + if (!translationUnitRef.TryGetTarget(out var translationUnit)) + { + lock (s_createTranslationUnitLock) { - lock (s_createTranslationUnitLock) + if (!translationUnitRef.TryGetTarget(out translationUnit)) { - if (!translationUnitRef.TryGetTarget(out translationUnit)) - { - translationUnit = new TranslationUnit(handle); - translationUnitRef.SetTarget(translationUnit); - } + translationUnit = new TranslationUnit(handle); + translationUnitRef.SetTarget(translationUnit); } } - return translationUnit; - } - - public void Dispose() - { - Dispose(isDisposing: true); - GC.SuppressFinalize(this); } + return translationUnit; + } - public override bool Equals(object obj) => (obj is TranslationUnit other) && Equals(other); + public void Dispose() + { + Dispose(isDisposing: true); + GC.SuppressFinalize(this); + } - public bool Equals(TranslationUnit other) => this == other; + public override bool Equals(object obj) => (obj is TranslationUnit other) && Equals(other); - public override int GetHashCode() => Handle.GetHashCode(); + public bool Equals(TranslationUnit other) => this == other; - internal TCursor GetOrCreate(CXCursor handle) - where TCursor : Cursor - { - WeakReference cursorRef; + public override int GetHashCode() => Handle.GetHashCode(); - if (handle.IsNull) - { - return null; - } - else if (!_createdCursors.TryGetValue(handle, out cursorRef)) - { - cursorRef = new WeakReference(null); - _createdCursors.Add(handle, cursorRef); - } + internal TCursor GetOrCreate(CXCursor handle) + where TCursor : Cursor + { + WeakReference cursorRef; - if (!cursorRef.TryGetTarget(out var cursor)) - { - cursor = Cursor.Create(handle); - cursorRef.SetTarget(cursor); - } - return (TCursor)cursor; + if (handle.IsNull) + { + return null; + } + else if (!_createdCursors.TryGetValue(handle, out cursorRef)) + { + cursorRef = new WeakReference(null); + _createdCursors.Add(handle, cursorRef); } - internal TemplateArgument GetOrCreate(CX_TemplateArgument handle) + if (!cursorRef.TryGetTarget(out var cursor)) { - WeakReference templateArgumentRef; + cursor = Cursor.Create(handle); + cursorRef.SetTarget(cursor); + } + return (TCursor)cursor; + } - if (handle.kind == CXTemplateArgumentKind.CXTemplateArgumentKind_Invalid) - { - return null; - } - else if (!_createdTemplateArguments.TryGetValue(handle, out templateArgumentRef)) - { - templateArgumentRef = new WeakReference(null); - _createdTemplateArguments.Add(handle, templateArgumentRef); - } + internal TemplateArgument GetOrCreate(CX_TemplateArgument handle) + { + WeakReference templateArgumentRef; - if (!templateArgumentRef.TryGetTarget(out var templateArgument)) - { - templateArgument = new TemplateArgument(handle); - templateArgumentRef.SetTarget(templateArgument); -} - return templateArgument; + if (handle.kind == CXTemplateArgumentKind.CXTemplateArgumentKind_Invalid) + { + return null; + } + else if (!_createdTemplateArguments.TryGetValue(handle, out templateArgumentRef)) + { + templateArgumentRef = new WeakReference(null); + _createdTemplateArguments.Add(handle, templateArgumentRef); } - internal TemplateArgumentLoc GetOrCreate(CX_TemplateArgumentLoc handle) + if (!templateArgumentRef.TryGetTarget(out var templateArgument)) { - WeakReference templateArgumentLocRef; + templateArgument = new TemplateArgument(handle); + templateArgumentRef.SetTarget(templateArgument); +} + return templateArgument; + } - if (handle.value == null) - { - return null; - } - else if (!_createdTemplateArgumentLocs.TryGetValue(handle, out templateArgumentLocRef)) - { - templateArgumentLocRef = new WeakReference(null); - _createdTemplateArgumentLocs.Add(handle, templateArgumentLocRef); - } + internal TemplateArgumentLoc GetOrCreate(CX_TemplateArgumentLoc handle) + { + WeakReference templateArgumentLocRef; - if (!templateArgumentLocRef.TryGetTarget(out var templateArgumentLoc)) - { - templateArgumentLoc = new TemplateArgumentLoc(handle); - templateArgumentLocRef.SetTarget(templateArgumentLoc); - } - return templateArgumentLoc; + if (handle.value == null) + { + return null; + } + else if (!_createdTemplateArgumentLocs.TryGetValue(handle, out templateArgumentLocRef)) + { + templateArgumentLocRef = new WeakReference(null); + _createdTemplateArgumentLocs.Add(handle, templateArgumentLocRef); } - internal TemplateName GetOrCreate(CX_TemplateName handle) + if (!templateArgumentLocRef.TryGetTarget(out var templateArgumentLoc)) { - WeakReference templateNameRef; + templateArgumentLoc = new TemplateArgumentLoc(handle); + templateArgumentLocRef.SetTarget(templateArgumentLoc); + } + return templateArgumentLoc; + } - if (handle.kind == CX_TemplateNameKind.CX_TNK_Invalid) - { - return null; - } - else if (!_createdTemplateNames.TryGetValue(handle, out templateNameRef)) - { - templateNameRef = new WeakReference(null); - _createdTemplateNames.Add(handle, templateNameRef); - } + internal TemplateName GetOrCreate(CX_TemplateName handle) + { + WeakReference templateNameRef; - if (!templateNameRef.TryGetTarget(out var templateName)) - { - templateName = new TemplateName(handle); - templateNameRef.SetTarget(templateName); - } - return templateName; + if (handle.kind == CX_TemplateNameKind.CX_TNK_Invalid) + { + return null; + } + else if (!_createdTemplateNames.TryGetValue(handle, out templateNameRef)) + { + templateNameRef = new WeakReference(null); + _createdTemplateNames.Add(handle, templateNameRef); } - internal TType GetOrCreate(CXType handle) - where TType : Type + if (!templateNameRef.TryGetTarget(out var templateName)) { - WeakReference typeRef; + templateName = new TemplateName(handle); + templateNameRef.SetTarget(templateName); + } + return templateName; + } - if (handle.kind == CXTypeKind.CXType_Invalid) - { - return null; - } - else if (!_createdTypes.TryGetValue(handle, out typeRef)) - { - typeRef = new WeakReference(null); - _createdTypes.Add(handle, typeRef); - } + internal TType GetOrCreate(CXType handle) + where TType : Type + { + WeakReference typeRef; - if (!typeRef.TryGetTarget(out var type)) - { - type = Type.Create(handle); - typeRef.SetTarget(type); - } - return (TType)type; + if (handle.kind == CXTypeKind.CXType_Invalid) + { + return null; + } + else if (!_createdTypes.TryGetValue(handle, out typeRef)) + { + typeRef = new WeakReference(null); + _createdTypes.Add(handle, typeRef); } - private void Dispose(bool isDisposing) + if (!typeRef.TryGetTarget(out var type)) { - if (_isDisposed) - { - return; - } - _isDisposed = true; + type = Type.Create(handle); + typeRef.SetTarget(type); + } + return (TType)type; + } - if (Handle != default) - { - Handle.Dispose(); - } + private void Dispose(bool isDisposing) + { + if (_isDisposed) + { + return; + } + _isDisposed = true; - _ = s_createdTranslationUnits.TryRemove(Handle, out _); + if (Handle != default) + { + Handle.Dispose(); } + + _ = s_createdTranslationUnits.TryRemove(Handle, out _); } } diff --git a/sources/ClangSharp/Types/AdjustedType.cs b/sources/ClangSharp/Types/AdjustedType.cs index 300c6349..72385d77 100644 --- a/sources/ClangSharp/Types/AdjustedType.cs +++ b/sources/ClangSharp/Types/AdjustedType.cs @@ -3,25 +3,24 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class AdjustedType : Type { - public class AdjustedType : Type - { - private readonly Lazy _adjustedType; - private readonly Lazy _originalType; + private readonly Lazy _adjustedType; + private readonly Lazy _originalType; - internal AdjustedType(CXType handle) : this(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Adjusted) - { - } + internal AdjustedType(CXType handle) : this(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Adjusted) + { + } - private protected AdjustedType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - _adjustedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.AdjustedType)); - _originalType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); - } + private protected AdjustedType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + _adjustedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.AdjustedType)); + _originalType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); + } - public Type GetAdjustedType => _adjustedType.Value; + public Type GetAdjustedType => _adjustedType.Value; - public Type OriginalType => _originalType.Value; - } + public Type OriginalType => _originalType.Value; } diff --git a/sources/ClangSharp/Types/ArrayType.cs b/sources/ClangSharp/Types/ArrayType.cs index a26090bf..adb43ed4 100644 --- a/sources/ClangSharp/Types/ArrayType.cs +++ b/sources/ClangSharp/Types/ArrayType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public class ArrayType : Type - { - private readonly Lazy _elementType; +namespace ClangSharp; - private protected ArrayType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ArrayElementType)); - } +public class ArrayType : Type +{ + private readonly Lazy _elementType; - public Type ElementType => _elementType.Value; + private protected ArrayType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ArrayElementType)); } + + public Type ElementType => _elementType.Value; } diff --git a/sources/ClangSharp/Types/AtomicType.cs b/sources/ClangSharp/Types/AtomicType.cs index d77314c7..7e8dd832 100644 --- a/sources/ClangSharp/Types/AtomicType.cs +++ b/sources/ClangSharp/Types/AtomicType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class AtomicType : Type - { - private readonly Lazy _valueType; +namespace ClangSharp; - internal AtomicType(CXType handle) : base(handle, CXTypeKind.CXType_Atomic, CX_TypeClass.CX_TypeClass_Atomic) - { - _valueType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ValueType)); - } +public sealed class AtomicType : Type +{ + private readonly Lazy _valueType; - public Type ValueType => _valueType.Value; + internal AtomicType(CXType handle) : base(handle, CXTypeKind.CXType_Atomic, CX_TypeClass.CX_TypeClass_Atomic) + { + _valueType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ValueType)); } + + public Type ValueType => _valueType.Value; } diff --git a/sources/ClangSharp/Types/AttributedType.cs b/sources/ClangSharp/Types/AttributedType.cs index f43cb701..7633825e 100644 --- a/sources/ClangSharp/Types/AttributedType.cs +++ b/sources/ClangSharp/Types/AttributedType.cs @@ -3,23 +3,22 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class AttributedType : Type { - public sealed class AttributedType : Type - { - private readonly Lazy _equivalentType; - private readonly Lazy _modifiedType; + private readonly Lazy _equivalentType; + private readonly Lazy _modifiedType; - internal AttributedType(CXType handle) : base(handle, CXTypeKind.CXType_Attributed, CX_TypeClass.CX_TypeClass_Attributed) - { - _equivalentType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.EquivalentType)); - _modifiedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ModifiedType)); - } + internal AttributedType(CXType handle) : base(handle, CXTypeKind.CXType_Attributed, CX_TypeClass.CX_TypeClass_Attributed) + { + _equivalentType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.EquivalentType)); + _modifiedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ModifiedType)); + } - public CX_AttrKind AttrKind => Handle.AttrKind; + public CX_AttrKind AttrKind => Handle.AttrKind; - public Type EquivalentType => _equivalentType.Value; + public Type EquivalentType => _equivalentType.Value; - public Type ModifiedType => _modifiedType.Value; - } + public Type ModifiedType => _modifiedType.Value; } diff --git a/sources/ClangSharp/Types/AutoType.cs b/sources/ClangSharp/Types/AutoType.cs index f20ff330..c66cfcd4 100644 --- a/sources/ClangSharp/Types/AutoType.cs +++ b/sources/ClangSharp/Types/AutoType.cs @@ -4,28 +4,27 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class AutoType : DeducedType - { - private readonly Lazy> _templateArgs; +namespace ClangSharp; - internal AutoType(CXType handle) : base(handle, CXTypeKind.CXType_Auto, CX_TypeClass.CX_TypeClass_Auto) - { - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); +public sealed class AutoType : DeducedType +{ + private readonly Lazy> _templateArgs; - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); - templateArgs.Add(templateArg); - } + internal AutoType(CXType handle) : base(handle, CXTypeKind.CXType_Auto, CX_TypeClass.CX_TypeClass_Auto) + { + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); - return templateArgs; - }); - } + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); + templateArgs.Add(templateArg); + } - public IReadOnlyList Args => _templateArgs.Value; + return templateArgs; + }); } + + public IReadOnlyList Args => _templateArgs.Value; } diff --git a/sources/ClangSharp/Types/BitIntType.cs b/sources/ClangSharp/Types/BitIntType.cs index b2bf0ebb..8b5fdf74 100644 --- a/sources/ClangSharp/Types/BitIntType.cs +++ b/sources/ClangSharp/Types/BitIntType.cs @@ -2,18 +2,17 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class BitIntType : Type { - public sealed class BitIntType : Type + internal BitIntType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_BitInt) { - internal BitIntType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_BitInt) - { - } + } - public bool IsSigned => Handle.IsSigned; + public bool IsSigned => Handle.IsSigned; - public bool IsUnsigned => Handle.IsUnsigned; + public bool IsUnsigned => Handle.IsUnsigned; - public uint NumBits => unchecked((uint)Handle.NumBits); - } + public uint NumBits => unchecked((uint)Handle.NumBits); } diff --git a/sources/ClangSharp/Types/BlockPointerType.cs b/sources/ClangSharp/Types/BlockPointerType.cs index 3e6abb70..4f65c39d 100644 --- a/sources/ClangSharp/Types/BlockPointerType.cs +++ b/sources/ClangSharp/Types/BlockPointerType.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class BlockPointerType : Type { - public sealed class BlockPointerType : Type + internal BlockPointerType(CXType handle) : base(handle, CXTypeKind.CXType_BlockPointer, CX_TypeClass.CX_TypeClass_BlockPointer) { - internal BlockPointerType(CXType handle) : base(handle, CXTypeKind.CXType_BlockPointer, CX_TypeClass.CX_TypeClass_BlockPointer) - { - } } } diff --git a/sources/ClangSharp/Types/BuiltinType.cs b/sources/ClangSharp/Types/BuiltinType.cs index da60f532..a58f0b94 100644 --- a/sources/ClangSharp/Types/BuiltinType.cs +++ b/sources/ClangSharp/Types/BuiltinType.cs @@ -2,13 +2,12 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class BuiltinType : Type { - public sealed class BuiltinType : Type - { - internal BuiltinType(CXType handle) : base(handle, handle.kind, CX_TypeClass.CX_TypeClass_Builtin) - { - } + internal BuiltinType(CXType handle) : base(handle, handle.kind, CX_TypeClass.CX_TypeClass_Builtin) + { } } diff --git a/sources/ClangSharp/Types/ComplexType.cs b/sources/ClangSharp/Types/ComplexType.cs index b94b873e..16582d84 100644 --- a/sources/ClangSharp/Types/ComplexType.cs +++ b/sources/ClangSharp/Types/ComplexType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class ComplexType : Type - { - private readonly Lazy _elementType; +namespace ClangSharp; - internal ComplexType(CXType handle) : base(handle, CXTypeKind.CXType_Complex, CX_TypeClass.CX_TypeClass_Complex) - { - _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); - } +public sealed class ComplexType : Type +{ + private readonly Lazy _elementType; - public Type ElementType => _elementType.Value; + internal ComplexType(CXType handle) : base(handle, CXTypeKind.CXType_Complex, CX_TypeClass.CX_TypeClass_Complex) + { + _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); } + + public Type ElementType => _elementType.Value; } diff --git a/sources/ClangSharp/Types/ConstantArrayType.cs b/sources/ClangSharp/Types/ConstantArrayType.cs index d81542f3..4c4c0278 100644 --- a/sources/ClangSharp/Types/ConstantArrayType.cs +++ b/sources/ClangSharp/Types/ConstantArrayType.cs @@ -3,19 +3,18 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ConstantArrayType : ArrayType { - public sealed class ConstantArrayType : ArrayType - { - private readonly Lazy _sizeExpr; + private readonly Lazy _sizeExpr; - internal ConstantArrayType(CXType handle) : base(handle, CXTypeKind.CXType_ConstantArray, CX_TypeClass.CX_TypeClass_ConstantArray) - { - _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SizeExpr)); - } + internal ConstantArrayType(CXType handle) : base(handle, CXTypeKind.CXType_ConstantArray, CX_TypeClass.CX_TypeClass_ConstantArray) + { + _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SizeExpr)); + } - public long Size => Handle.ArraySize; + public long Size => Handle.ArraySize; - public Expr SizeExpr => _sizeExpr.Value; - } + public Expr SizeExpr => _sizeExpr.Value; } diff --git a/sources/ClangSharp/Types/ConstantMatrixType.cs b/sources/ClangSharp/Types/ConstantMatrixType.cs index a2ce712a..31982303 100644 --- a/sources/ClangSharp/Types/ConstantMatrixType.cs +++ b/sources/ClangSharp/Types/ConstantMatrixType.cs @@ -2,18 +2,17 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ConstantMatrixType : MatrixType { - public sealed class ConstantMatrixType : MatrixType + internal ConstantMatrixType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_ConstantMatrix) { - internal ConstantMatrixType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_ConstantMatrix) - { - } + } - public uint NumColumns => unchecked((uint)Handle.NumColumns); + public uint NumColumns => unchecked((uint)Handle.NumColumns); - public uint NumElementsFlattened => unchecked((uint)Handle.NumElementsFlattened); + public uint NumElementsFlattened => unchecked((uint)Handle.NumElementsFlattened); - public uint NumRows => unchecked((uint)Handle.NumRows); - } + public uint NumRows => unchecked((uint)Handle.NumRows); } diff --git a/sources/ClangSharp/Types/DecayedType.cs b/sources/ClangSharp/Types/DecayedType.cs index 9fe64562..5b822bf2 100644 --- a/sources/ClangSharp/Types/DecayedType.cs +++ b/sources/ClangSharp/Types/DecayedType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class DecayedType : AdjustedType - { - private readonly Lazy _decayedType; +namespace ClangSharp; - internal DecayedType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Decayed) - { - _decayedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DecayedType)); - } +public sealed class DecayedType : AdjustedType +{ + private readonly Lazy _decayedType; - public Type GetDecayedType => _decayedType.Value; + internal DecayedType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Decayed) + { + _decayedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DecayedType)); } + + public Type GetDecayedType => _decayedType.Value; } diff --git a/sources/ClangSharp/Types/DecltypeType.cs b/sources/ClangSharp/Types/DecltypeType.cs index 26ad7dda..4d3d91be 100644 --- a/sources/ClangSharp/Types/DecltypeType.cs +++ b/sources/ClangSharp/Types/DecltypeType.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DecltypeType : Type { - public sealed class DecltypeType : Type - { - private readonly Lazy _underlyingExpr; - private readonly Lazy _underlyingType; + private readonly Lazy _underlyingExpr; + private readonly Lazy _underlyingType; - internal DecltypeType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Decltype) - { - _underlyingExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingExpr)); - _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); - } + internal DecltypeType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Decltype) + { + _underlyingExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingExpr)); + _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); + } - public Expr UnderlyingExpr => _underlyingExpr.Value; + public Expr UnderlyingExpr => _underlyingExpr.Value; - public Type UnderlyingType => _underlyingType.Value; - } + public Type UnderlyingType => _underlyingType.Value; } diff --git a/sources/ClangSharp/Types/DeducedTemplateSpecializationType.cs b/sources/ClangSharp/Types/DeducedTemplateSpecializationType.cs index 15832c37..9be40ed5 100644 --- a/sources/ClangSharp/Types/DeducedTemplateSpecializationType.cs +++ b/sources/ClangSharp/Types/DeducedTemplateSpecializationType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class DeducedTemplateSpecializationType : DeducedType - { - private readonly Lazy _templateName; +namespace ClangSharp; - internal DeducedTemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DeducedTemplateSpecialization) - { - _templateName = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateName)); - } +public sealed class DeducedTemplateSpecializationType : DeducedType +{ + private readonly Lazy _templateName; - public TemplateName TemplateName => _templateName.Value; + internal DeducedTemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DeducedTemplateSpecialization) + { + _templateName = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateName)); } + + public TemplateName TemplateName => _templateName.Value; } diff --git a/sources/ClangSharp/Types/DeducedType.cs b/sources/ClangSharp/Types/DeducedType.cs index e605bcd3..4c77aa5a 100644 --- a/sources/ClangSharp/Types/DeducedType.cs +++ b/sources/ClangSharp/Types/DeducedType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public class DeducedType : Type - { - private readonly Lazy _deducedType; +namespace ClangSharp; - private protected DeducedType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - _deducedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DeducedType)); - } +public class DeducedType : Type +{ + private readonly Lazy _deducedType; - public Type GetDeducedType => _deducedType.Value; + private protected DeducedType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + _deducedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.DeducedType)); } + + public Type GetDeducedType => _deducedType.Value; } diff --git a/sources/ClangSharp/Types/DependentAddressSpaceType.cs b/sources/ClangSharp/Types/DependentAddressSpaceType.cs index 14104b74..9c7bce72 100644 --- a/sources/ClangSharp/Types/DependentAddressSpaceType.cs +++ b/sources/ClangSharp/Types/DependentAddressSpaceType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class DependentAddressSpaceType : Type - { - private readonly Lazy _addrSpaceExpr; +namespace ClangSharp; - internal DependentAddressSpaceType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentAddressSpace) - { - _addrSpaceExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.AddrSpaceExpr)); - } +public sealed class DependentAddressSpaceType : Type +{ + private readonly Lazy _addrSpaceExpr; - public Expr AddrSpaceExpr => _addrSpaceExpr.Value; + internal DependentAddressSpaceType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentAddressSpace) + { + _addrSpaceExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.AddrSpaceExpr)); } + + public Expr AddrSpaceExpr => _addrSpaceExpr.Value; } diff --git a/sources/ClangSharp/Types/DependentBitIntType.cs b/sources/ClangSharp/Types/DependentBitIntType.cs index ca91bb1e..f4b7c33d 100644 --- a/sources/ClangSharp/Types/DependentBitIntType.cs +++ b/sources/ClangSharp/Types/DependentBitIntType.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DependentBitIntType : Type { - public sealed class DependentBitIntType : Type - { - private readonly Lazy _numBitsExpr; + private readonly Lazy _numBitsExpr; - internal DependentBitIntType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentBitInt) - { - _numBitsExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.NumBitsExpr)); - } + internal DependentBitIntType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentBitInt) + { + _numBitsExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.NumBitsExpr)); + } - public bool IsSigned => Handle.IsSigned; + public bool IsSigned => Handle.IsSigned; - public bool IsUnsigned => Handle.IsUnsigned; + public bool IsUnsigned => Handle.IsUnsigned; - public Expr NumBitsExpr => _numBitsExpr.Value; - } + public Expr NumBitsExpr => _numBitsExpr.Value; } diff --git a/sources/ClangSharp/Types/DependentNameType.cs b/sources/ClangSharp/Types/DependentNameType.cs index 64eef6c6..3f9ec369 100644 --- a/sources/ClangSharp/Types/DependentNameType.cs +++ b/sources/ClangSharp/Types/DependentNameType.cs @@ -2,13 +2,12 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DependentNameType : TypeWithKeyword { - public sealed class DependentNameType : TypeWithKeyword - { - internal DependentNameType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentName) - { - } + internal DependentNameType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentName) + { } } diff --git a/sources/ClangSharp/Types/DependentSizedArrayType.cs b/sources/ClangSharp/Types/DependentSizedArrayType.cs index 8105c275..8a0a4a32 100644 --- a/sources/ClangSharp/Types/DependentSizedArrayType.cs +++ b/sources/ClangSharp/Types/DependentSizedArrayType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class DependentSizedArrayType : ArrayType - { - private readonly Lazy _sizeExpr; +namespace ClangSharp; - internal DependentSizedArrayType(CXType handle) : base(handle, CXTypeKind.CXType_DependentSizedArray, CX_TypeClass.CX_TypeClass_DependentSizedArray) - { - _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SizeExpr)); - } +public sealed class DependentSizedArrayType : ArrayType +{ + private readonly Lazy _sizeExpr; - public Expr SizeExpr => _sizeExpr.Value; + internal DependentSizedArrayType(CXType handle) : base(handle, CXTypeKind.CXType_DependentSizedArray, CX_TypeClass.CX_TypeClass_DependentSizedArray) + { + _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SizeExpr)); } + + public Expr SizeExpr => _sizeExpr.Value; } diff --git a/sources/ClangSharp/Types/DependentSizedExtVectorType.cs b/sources/ClangSharp/Types/DependentSizedExtVectorType.cs index e3975c21..3f6d446a 100644 --- a/sources/ClangSharp/Types/DependentSizedExtVectorType.cs +++ b/sources/ClangSharp/Types/DependentSizedExtVectorType.cs @@ -3,23 +3,22 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DependentSizedExtVectorType : Type { - public sealed class DependentSizedExtVectorType : Type - { - private readonly Lazy _elementType; - private readonly Lazy _sizeExpr; + private readonly Lazy _elementType; + private readonly Lazy _sizeExpr; - internal DependentSizedExtVectorType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentSizedExtVector) - { - _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); - _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SizeExpr)); - } + internal DependentSizedExtVectorType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentSizedExtVector) + { + _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); + _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SizeExpr)); + } - public Type ElementType => _elementType.Value; + public Type ElementType => _elementType.Value; - public long Size => Handle.ArraySize; + public long Size => Handle.ArraySize; - public Expr SizeExpr => _sizeExpr.Value; - } + public Expr SizeExpr => _sizeExpr.Value; } diff --git a/sources/ClangSharp/Types/DependentSizedMatrixType.cs b/sources/ClangSharp/Types/DependentSizedMatrixType.cs index 9c8c0337..562cbbab 100644 --- a/sources/ClangSharp/Types/DependentSizedMatrixType.cs +++ b/sources/ClangSharp/Types/DependentSizedMatrixType.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DependentSizedMatrixType : MatrixType { - public sealed class DependentSizedMatrixType : MatrixType - { - private readonly Lazy _rowExpr; - private readonly Lazy _columnExpr; + private readonly Lazy _rowExpr; + private readonly Lazy _columnExpr; - internal DependentSizedMatrixType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentSizedMatrix) - { - _rowExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.RowExpr)); - _columnExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.ColumnExpr)); - } + internal DependentSizedMatrixType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentSizedMatrix) + { + _rowExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.RowExpr)); + _columnExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.ColumnExpr)); + } - public Expr ColumnExpr => _columnExpr.Value; + public Expr ColumnExpr => _columnExpr.Value; - public Expr RowExpr => _rowExpr.Value; - } + public Expr RowExpr => _rowExpr.Value; } diff --git a/sources/ClangSharp/Types/DependentTemplateSpecializationType.cs b/sources/ClangSharp/Types/DependentTemplateSpecializationType.cs index eb399689..0c647fe1 100644 --- a/sources/ClangSharp/Types/DependentTemplateSpecializationType.cs +++ b/sources/ClangSharp/Types/DependentTemplateSpecializationType.cs @@ -4,28 +4,27 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class DependentTemplateSpecializationType : TypeWithKeyword - { - private readonly Lazy> _templateArgs; +namespace ClangSharp; - internal DependentTemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentTemplateSpecialization) - { - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); +public sealed class DependentTemplateSpecializationType : TypeWithKeyword +{ + private readonly Lazy> _templateArgs; - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); - templateArgs.Add(templateArg); - } + internal DependentTemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentTemplateSpecialization) + { + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); - return templateArgs; - }); - } + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); + templateArgs.Add(templateArg); + } - public IReadOnlyList Args => _templateArgs.Value; + return templateArgs; + }); } + + public IReadOnlyList Args => _templateArgs.Value; } diff --git a/sources/ClangSharp/Types/DependentVectorType.cs b/sources/ClangSharp/Types/DependentVectorType.cs index db24471a..22f38a96 100644 --- a/sources/ClangSharp/Types/DependentVectorType.cs +++ b/sources/ClangSharp/Types/DependentVectorType.cs @@ -3,23 +3,22 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class DependentVectorType : Type { - public sealed class DependentVectorType : Type - { - private readonly Lazy _elementType; - private readonly Lazy _sizeExpr; + private readonly Lazy _elementType; + private readonly Lazy _sizeExpr; - internal DependentVectorType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentVector) - { - _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); - _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SizeExpr)); - } + internal DependentVectorType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_DependentVector) + { + _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); + _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(Handle.SizeExpr)); + } - public Type ElementType => _elementType.Value; + public Type ElementType => _elementType.Value; - public long Size => Handle.ArraySize; + public long Size => Handle.ArraySize; - public Expr SizeExpr => _sizeExpr.Value; - } + public Expr SizeExpr => _sizeExpr.Value; } diff --git a/sources/ClangSharp/Types/ElaboratedType.cs b/sources/ClangSharp/Types/ElaboratedType.cs index 65070c18..0b490ea0 100644 --- a/sources/ClangSharp/Types/ElaboratedType.cs +++ b/sources/ClangSharp/Types/ElaboratedType.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ElaboratedType : TypeWithKeyword { - public sealed class ElaboratedType : TypeWithKeyword - { - private readonly Lazy _namedType; - private readonly Lazy _ownedTagDecl; + private readonly Lazy _namedType; + private readonly Lazy _ownedTagDecl; - internal ElaboratedType(CXType handle) : base(handle, CXTypeKind.CXType_Elaborated, CX_TypeClass.CX_TypeClass_Elaborated) - { - _namedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NamedType)); - _ownedTagDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OwnedTagDecl)); - } + internal ElaboratedType(CXType handle) : base(handle, CXTypeKind.CXType_Elaborated, CX_TypeClass.CX_TypeClass_Elaborated) + { + _namedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.NamedType)); + _ownedTagDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OwnedTagDecl)); + } - public Type NamedType => _namedType.Value; + public Type NamedType => _namedType.Value; - public TagDecl OwnedTagDecl => _ownedTagDecl.Value; - } + public TagDecl OwnedTagDecl => _ownedTagDecl.Value; } diff --git a/sources/ClangSharp/Types/EnumType.cs b/sources/ClangSharp/Types/EnumType.cs index 74df8444..9435c71e 100644 --- a/sources/ClangSharp/Types/EnumType.cs +++ b/sources/ClangSharp/Types/EnumType.cs @@ -2,15 +2,14 @@ using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class EnumType : TagType - { +namespace ClangSharp; - internal EnumType(CXType handle) : base(handle, CXTypeKind.CXType_Enum, CX_TypeClass.CX_TypeClass_Enum) - { - } +public sealed class EnumType : TagType +{ - public new EnumDecl Decl => (EnumDecl)base.Decl; + internal EnumType(CXType handle) : base(handle, CXTypeKind.CXType_Enum, CX_TypeClass.CX_TypeClass_Enum) + { } + + public new EnumDecl Decl => (EnumDecl)base.Decl; } diff --git a/sources/ClangSharp/Types/ExtVectorType.cs b/sources/ClangSharp/Types/ExtVectorType.cs index 14b3aae6..b53fd9a3 100644 --- a/sources/ClangSharp/Types/ExtVectorType.cs +++ b/sources/ClangSharp/Types/ExtVectorType.cs @@ -2,13 +2,12 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ExtVectorType : Type { - public sealed class ExtVectorType : Type - { - internal ExtVectorType(CXType handle) : base(handle, CXTypeKind.CXType_ExtVector, CX_TypeClass.CX_TypeClass_ExtVector) - { - } + internal ExtVectorType(CXType handle) : base(handle, CXTypeKind.CXType_ExtVector, CX_TypeClass.CX_TypeClass_ExtVector) + { } } diff --git a/sources/ClangSharp/Types/FunctionNoProtoType.cs b/sources/ClangSharp/Types/FunctionNoProtoType.cs index 1e1cd2a6..000991d2 100644 --- a/sources/ClangSharp/Types/FunctionNoProtoType.cs +++ b/sources/ClangSharp/Types/FunctionNoProtoType.cs @@ -2,13 +2,12 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class FunctionNoProtoType : FunctionType { - public sealed class FunctionNoProtoType : FunctionType - { - internal FunctionNoProtoType(CXType handle) : base(handle, CXTypeKind.CXType_FunctionNoProto, CX_TypeClass.CX_TypeClass_FunctionNoProto) - { - } + internal FunctionNoProtoType(CXType handle) : base(handle, CXTypeKind.CXType_FunctionNoProto, CX_TypeClass.CX_TypeClass_FunctionNoProto) + { } } diff --git a/sources/ClangSharp/Types/FunctionProtoType.cs b/sources/ClangSharp/Types/FunctionProtoType.cs index 3edcfd92..db4e2cf5 100644 --- a/sources/ClangSharp/Types/FunctionProtoType.cs +++ b/sources/ClangSharp/Types/FunctionProtoType.cs @@ -4,36 +4,35 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class FunctionProtoType : FunctionType - { - private readonly Lazy> _paramTypes; +namespace ClangSharp; - internal FunctionProtoType(CXType handle) : base(handle, CXTypeKind.CXType_FunctionProto, CX_TypeClass.CX_TypeClass_FunctionProto) - { - _paramTypes = new Lazy>(() => { - var paramTypeCount = Handle.NumArgTypes; - var paramTypes = new List(paramTypeCount); - - for (var i = 0; i < paramTypeCount; i++) - { - var paramType = TranslationUnit.GetOrCreate(Handle.GetArgType(unchecked((uint)i))); - paramTypes.Add(paramType); - } +public sealed class FunctionProtoType : FunctionType +{ + private readonly Lazy> _paramTypes; - return paramTypes; - }); - } + internal FunctionProtoType(CXType handle) : base(handle, CXTypeKind.CXType_FunctionProto, CX_TypeClass.CX_TypeClass_FunctionProto) + { + _paramTypes = new Lazy>(() => { + var paramTypeCount = Handle.NumArgTypes; + var paramTypes = new List(paramTypeCount); + + for (var i = 0; i < paramTypeCount; i++) + { + var paramType = TranslationUnit.GetOrCreate(Handle.GetArgType(unchecked((uint)i))); + paramTypes.Add(paramType); + } + + return paramTypes; + }); + } - public CXCursor_ExceptionSpecificationKind ExceptionSpecType => Handle.ExceptionSpecificationType; + public CXCursor_ExceptionSpecificationKind ExceptionSpecType => Handle.ExceptionSpecificationType; - public bool IsVariadic => Handle.IsFunctionTypeVariadic; + public bool IsVariadic => Handle.IsFunctionTypeVariadic; - public uint NumParams => (uint)Handle.NumArgTypes; + public uint NumParams => (uint)Handle.NumArgTypes; - public IReadOnlyList ParamTypes => _paramTypes.Value; + public IReadOnlyList ParamTypes => _paramTypes.Value; - public CXRefQualifierKind RefQualifier => Handle.CXXRefQualifier; - } + public CXRefQualifierKind RefQualifier => Handle.CXXRefQualifier; } diff --git a/sources/ClangSharp/Types/FunctionType.cs b/sources/ClangSharp/Types/FunctionType.cs index 6d2a65dc..343ce3de 100644 --- a/sources/ClangSharp/Types/FunctionType.cs +++ b/sources/ClangSharp/Types/FunctionType.cs @@ -3,19 +3,18 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class FunctionType : Type { - public class FunctionType : Type - { - private readonly Lazy _returnType; + private readonly Lazy _returnType; - private protected FunctionType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - _returnType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ResultType)); - } + private protected FunctionType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + _returnType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ResultType)); + } - public CXCallingConv CallConv => Handle.FunctionTypeCallingConv; + public CXCallingConv CallConv => Handle.FunctionTypeCallingConv; - public Type ReturnType => _returnType.Value; - } + public Type ReturnType => _returnType.Value; } diff --git a/sources/ClangSharp/Types/IncompleteArrayType.cs b/sources/ClangSharp/Types/IncompleteArrayType.cs index f2842741..38e41620 100644 --- a/sources/ClangSharp/Types/IncompleteArrayType.cs +++ b/sources/ClangSharp/Types/IncompleteArrayType.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class IncompleteArrayType : ArrayType { - public sealed class IncompleteArrayType : ArrayType + internal IncompleteArrayType(CXType handle) : base(handle, CXTypeKind.CXType_IncompleteArray, CX_TypeClass.CX_TypeClass_IncompleteArray) { - internal IncompleteArrayType(CXType handle) : base(handle, CXTypeKind.CXType_IncompleteArray, CX_TypeClass.CX_TypeClass_IncompleteArray) - { - } } } diff --git a/sources/ClangSharp/Types/InjectedClassNameType.cs b/sources/ClangSharp/Types/InjectedClassNameType.cs index 06920285..b8e92172 100644 --- a/sources/ClangSharp/Types/InjectedClassNameType.cs +++ b/sources/ClangSharp/Types/InjectedClassNameType.cs @@ -3,29 +3,28 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class InjectedClassNameType : Type { - public sealed class InjectedClassNameType : Type - { - private readonly Lazy _decl; - private readonly Lazy _injectedSpecializationType; - private readonly Lazy _injectedTST; - private readonly Lazy _templateName; + private readonly Lazy _decl; + private readonly Lazy _injectedSpecializationType; + private readonly Lazy _injectedTST; + private readonly Lazy _templateName; - internal InjectedClassNameType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_InjectedClassName) - { - _decl = new Lazy(() => TranslationUnit.GetOrCreate(handle.Declaration)); - _injectedSpecializationType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InjectedSpecializationType)); - _injectedTST = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InjectedTST)); - _templateName = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateName)); - } + internal InjectedClassNameType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_InjectedClassName) + { + _decl = new Lazy(() => TranslationUnit.GetOrCreate(handle.Declaration)); + _injectedSpecializationType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InjectedSpecializationType)); + _injectedTST = new Lazy(() => TranslationUnit.GetOrCreate(Handle.InjectedTST)); + _templateName = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateName)); + } - public CXXRecordDecl Decl => _decl.Value; + public CXXRecordDecl Decl => _decl.Value; - public Type InjectedSpecializationType => _injectedSpecializationType.Value; + public Type InjectedSpecializationType => _injectedSpecializationType.Value; - public TemplateSpecializationType InjectedTST => _injectedTST.Value; + public TemplateSpecializationType InjectedTST => _injectedTST.Value; - public TemplateName TemplateName => _templateName.Value; - } + public TemplateName TemplateName => _templateName.Value; } diff --git a/sources/ClangSharp/Types/LValueReferenceType.cs b/sources/ClangSharp/Types/LValueReferenceType.cs index 5a582717..9ed27a44 100644 --- a/sources/ClangSharp/Types/LValueReferenceType.cs +++ b/sources/ClangSharp/Types/LValueReferenceType.cs @@ -2,13 +2,12 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class LValueReferenceType : ReferenceType { - public sealed class LValueReferenceType : ReferenceType - { - internal LValueReferenceType(CXType handle) : base(handle, CXTypeKind.CXType_LValueReference, CX_TypeClass.CX_TypeClass_LValueReference) - { - } + internal LValueReferenceType(CXType handle) : base(handle, CXTypeKind.CXType_LValueReference, CX_TypeClass.CX_TypeClass_LValueReference) + { } } diff --git a/sources/ClangSharp/Types/MacroQualifiedType.cs b/sources/ClangSharp/Types/MacroQualifiedType.cs index 57014d7d..ebe12e56 100644 --- a/sources/ClangSharp/Types/MacroQualifiedType.cs +++ b/sources/ClangSharp/Types/MacroQualifiedType.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MacroQualifiedType : Type { - public sealed class MacroQualifiedType : Type - { - private readonly Lazy _modifiedType; - private readonly Lazy _underlyingType; + private readonly Lazy _modifiedType; + private readonly Lazy _underlyingType; - internal MacroQualifiedType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_MacroQualified) - { - _modifiedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ModifiedType)); - _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); - } + internal MacroQualifiedType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_MacroQualified) + { + _modifiedType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ModifiedType)); + _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); + } - public Type ModifiedType => _modifiedType.Value; + public Type ModifiedType => _modifiedType.Value; - public Type UnderlyingType => _underlyingType.Value; - } + public Type UnderlyingType => _underlyingType.Value; } diff --git a/sources/ClangSharp/Types/MatrixType.cs b/sources/ClangSharp/Types/MatrixType.cs index 0e311a93..b5098601 100644 --- a/sources/ClangSharp/Types/MatrixType.cs +++ b/sources/ClangSharp/Types/MatrixType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public class MatrixType : Type - { - private readonly Lazy _elementType; +namespace ClangSharp; - private protected MatrixType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - _elementType = new Lazy(() => TranslationUnit.GetOrCreate(handle.ElementType)); - } +public class MatrixType : Type +{ + private readonly Lazy _elementType; - public Type ElementType => _elementType.Value; + private protected MatrixType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + _elementType = new Lazy(() => TranslationUnit.GetOrCreate(handle.ElementType)); } + + public Type ElementType => _elementType.Value; } diff --git a/sources/ClangSharp/Types/MemberPointerType.cs b/sources/ClangSharp/Types/MemberPointerType.cs index 3693a63a..2991d9e0 100644 --- a/sources/ClangSharp/Types/MemberPointerType.cs +++ b/sources/ClangSharp/Types/MemberPointerType.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class MemberPointerType : Type { - public sealed class MemberPointerType : Type + internal MemberPointerType(CXType handle) : base(handle, CXTypeKind.CXType_MemberPointer, CX_TypeClass.CX_TypeClass_MemberPointer) { - internal MemberPointerType(CXType handle) : base(handle, CXTypeKind.CXType_MemberPointer, CX_TypeClass.CX_TypeClass_MemberPointer) - { - } } } diff --git a/sources/ClangSharp/Types/ObjCInterfaceType.cs b/sources/ClangSharp/Types/ObjCInterfaceType.cs index e7786022..71a1353b 100644 --- a/sources/ClangSharp/Types/ObjCInterfaceType.cs +++ b/sources/ClangSharp/Types/ObjCInterfaceType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class ObjCInterfaceType : ObjCObjectType - { - private readonly Lazy _decl; +namespace ClangSharp; - internal ObjCInterfaceType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCObject, CX_TypeClass.CX_TypeClass_ObjCInterface) - { - _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); - } +public sealed class ObjCInterfaceType : ObjCObjectType +{ + private readonly Lazy _decl; - public ObjCInterfaceDecl Decl => _decl.Value; + internal ObjCInterfaceType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCObject, CX_TypeClass.CX_TypeClass_ObjCInterface) + { + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); } + + public ObjCInterfaceDecl Decl => _decl.Value; } diff --git a/sources/ClangSharp/Types/ObjCObjectPointerType.cs b/sources/ClangSharp/Types/ObjCObjectPointerType.cs index 860ff37f..cf59f021 100644 --- a/sources/ClangSharp/Types/ObjCObjectPointerType.cs +++ b/sources/ClangSharp/Types/ObjCObjectPointerType.cs @@ -4,29 +4,28 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class ObjCObjectPointerType : Type { - public sealed class ObjCObjectPointerType : Type - { - private readonly Lazy _interfaceType; - private readonly Lazy _superClassType; + private readonly Lazy _interfaceType; + private readonly Lazy _superClassType; - internal ObjCObjectPointerType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCObjectPointer, CX_TypeClass.CX_TypeClass_ObjCObjectPointer) - { - _interfaceType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); - _superClassType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); - } + internal ObjCObjectPointerType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCObjectPointer, CX_TypeClass.CX_TypeClass_ObjCObjectPointer) + { + _interfaceType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); + _superClassType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); + } - public ObjCInterfaceDecl InterfaceDecl => ObjectType.Interface; + public ObjCInterfaceDecl InterfaceDecl => ObjectType.Interface; - public ObjCInterfaceType InterfaceType => _interfaceType.Value; + public ObjCInterfaceType InterfaceType => _interfaceType.Value; - public ObjCObjectType ObjectType => PointeeType.CastAs(); + public ObjCObjectType ObjectType => PointeeType.CastAs(); - public IReadOnlyList Protocols => ObjectType.Protocols; + public IReadOnlyList Protocols => ObjectType.Protocols; - public Type SuperClassType => _superClassType.Value; + public Type SuperClassType => _superClassType.Value; - public IReadOnlyList TypeArgs => ObjectType.TypeArgs; - } + public IReadOnlyList TypeArgs => ObjectType.TypeArgs; } diff --git a/sources/ClangSharp/Types/ObjCObjectType.cs b/sources/ClangSharp/Types/ObjCObjectType.cs index aa167bfb..d889318e 100644 --- a/sources/ClangSharp/Types/ObjCObjectType.cs +++ b/sources/ClangSharp/Types/ObjCObjectType.cs @@ -4,61 +4,60 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp -{ - public class ObjCObjectType : Type - { - private readonly Lazy _baseType; - private readonly Lazy _interface; - private readonly Lazy> _protocols; - private readonly Lazy _superClassType; - private readonly Lazy> _typeArgs; - - internal ObjCObjectType(CXType handle) : this(handle, CXTypeKind.CXType_ObjCObject, CX_TypeClass.CX_TypeClass_ObjCObject) - { - } - - private protected ObjCObjectType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - _baseType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ObjCObjectBaseType)); - _interface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); - - _protocols = new Lazy>(() => { - var numProtocols = unchecked((int)Handle.NumObjCProtocolRefs); - var protocols = new List(numProtocols); - - for (var i = 0; i < numProtocols; i++) - { - var protocol = TranslationUnit.GetOrCreate(Handle.GetObjCProtocolDecl(unchecked((uint)i))); - protocols.Add(protocol); - } - - return protocols; - }); +namespace ClangSharp; - _superClassType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); - _typeArgs = new Lazy>(() => { - var numTypeArgs = unchecked((int)Handle.NumObjCTypeArgs); - var typeArgs = new List(numTypeArgs); +public class ObjCObjectType : Type +{ + private readonly Lazy _baseType; + private readonly Lazy _interface; + private readonly Lazy> _protocols; + private readonly Lazy _superClassType; + private readonly Lazy> _typeArgs; - for (var i = 0; i < numTypeArgs; i++) - { - var typeArg = TranslationUnit.GetOrCreate(Handle.GetObjCTypeArg(unchecked((uint)i))); - typeArgs.Add(typeArg); - } + internal ObjCObjectType(CXType handle) : this(handle, CXTypeKind.CXType_ObjCObject, CX_TypeClass.CX_TypeClass_ObjCObject) + { + } - return typeArgs; - }); - } + private protected ObjCObjectType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + _baseType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ObjCObjectBaseType)); + _interface = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); + + _protocols = new Lazy>(() => { + var numProtocols = unchecked((int)Handle.NumObjCProtocolRefs); + var protocols = new List(numProtocols); + + for (var i = 0; i < numProtocols; i++) + { + var protocol = TranslationUnit.GetOrCreate(Handle.GetObjCProtocolDecl(unchecked((uint)i))); + protocols.Add(protocol); + } + + return protocols; + }); + + _superClassType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); + _typeArgs = new Lazy>(() => { + var numTypeArgs = unchecked((int)Handle.NumObjCTypeArgs); + var typeArgs = new List(numTypeArgs); + + for (var i = 0; i < numTypeArgs; i++) + { + var typeArg = TranslationUnit.GetOrCreate(Handle.GetObjCTypeArg(unchecked((uint)i))); + typeArgs.Add(typeArg); + } + + return typeArgs; + }); + } - public Type BaseType => _baseType.Value; + public Type BaseType => _baseType.Value; - public ObjCInterfaceDecl Interface => _interface.Value; + public ObjCInterfaceDecl Interface => _interface.Value; - public IReadOnlyList Protocols => _protocols.Value; + public IReadOnlyList Protocols => _protocols.Value; - public Type SuperClassType => _superClassType.Value; + public Type SuperClassType => _superClassType.Value; - public IReadOnlyList TypeArgs => _typeArgs.Value; - } + public IReadOnlyList TypeArgs => _typeArgs.Value; } diff --git a/sources/ClangSharp/Types/ObjCTypeParamType.cs b/sources/ClangSharp/Types/ObjCTypeParamType.cs index 6514e667..091064f6 100644 --- a/sources/ClangSharp/Types/ObjCTypeParamType.cs +++ b/sources/ClangSharp/Types/ObjCTypeParamType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class ObjCTypeParamType : Type - { - private readonly Lazy _decl; +namespace ClangSharp; - internal ObjCTypeParamType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCTypeParam, CX_TypeClass.CX_TypeClass_ObjCTypeParam) - { - _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); - } +public sealed class ObjCTypeParamType : Type +{ + private readonly Lazy _decl; - public ObjCTypeParamDecl Decl => _decl.Value; + internal ObjCTypeParamType(CXType handle) : base(handle, CXTypeKind.CXType_ObjCTypeParam, CX_TypeClass.CX_TypeClass_ObjCTypeParam) + { + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); } + + public ObjCTypeParamDecl Decl => _decl.Value; } diff --git a/sources/ClangSharp/Types/PackExpansionType.cs b/sources/ClangSharp/Types/PackExpansionType.cs index b9ceb7ab..dde44b70 100644 --- a/sources/ClangSharp/Types/PackExpansionType.cs +++ b/sources/ClangSharp/Types/PackExpansionType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class PackExpansionType : Type - { - private readonly Lazy _pattern; +namespace ClangSharp; - internal PackExpansionType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_PackExpansion) - { - _pattern = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); - } +public sealed class PackExpansionType : Type +{ + private readonly Lazy _pattern; - public Type Pattern => _pattern.Value; + internal PackExpansionType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_PackExpansion) + { + _pattern = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); } + + public Type Pattern => _pattern.Value; } diff --git a/sources/ClangSharp/Types/ParenType.cs b/sources/ClangSharp/Types/ParenType.cs index 7db3a96d..8b5175a4 100644 --- a/sources/ClangSharp/Types/ParenType.cs +++ b/sources/ClangSharp/Types/ParenType.cs @@ -2,15 +2,14 @@ using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class ParenType : Type - { +namespace ClangSharp; - internal ParenType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Paren) - { - } +public sealed class ParenType : Type +{ - public Type InnerType => Desugar; + internal ParenType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Paren) + { } + + public Type InnerType => Desugar; } diff --git a/sources/ClangSharp/Types/PipeType.cs b/sources/ClangSharp/Types/PipeType.cs index 339efb3c..6f182b50 100644 --- a/sources/ClangSharp/Types/PipeType.cs +++ b/sources/ClangSharp/Types/PipeType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class PipeType : Type - { - private readonly Lazy _elementType; +namespace ClangSharp; - internal PipeType(CXType handle) : base(handle, CXTypeKind.CXType_Pipe, CX_TypeClass.CX_TypeClass_Pipe) - { - _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); - } +public sealed class PipeType : Type +{ + private readonly Lazy _elementType; - public Type ElementType => _elementType.Value; + internal PipeType(CXType handle) : base(handle, CXTypeKind.CXType_Pipe, CX_TypeClass.CX_TypeClass_Pipe) + { + _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); } + + public Type ElementType => _elementType.Value; } diff --git a/sources/ClangSharp/Types/PointerType.cs b/sources/ClangSharp/Types/PointerType.cs index 778810ef..5509d6aa 100644 --- a/sources/ClangSharp/Types/PointerType.cs +++ b/sources/ClangSharp/Types/PointerType.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class PointerType : Type { - public sealed class PointerType : Type + internal PointerType(CXType handle) : base(handle, CXTypeKind.CXType_Pointer, CX_TypeClass.CX_TypeClass_Pointer) { - internal PointerType(CXType handle) : base(handle, CXTypeKind.CXType_Pointer, CX_TypeClass.CX_TypeClass_Pointer) - { - } } } diff --git a/sources/ClangSharp/Types/RValueReferenceType.cs b/sources/ClangSharp/Types/RValueReferenceType.cs index f83cd81a..30ec0350 100644 --- a/sources/ClangSharp/Types/RValueReferenceType.cs +++ b/sources/ClangSharp/Types/RValueReferenceType.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class RValueReferenceType : ReferenceType { - public sealed class RValueReferenceType : ReferenceType + internal RValueReferenceType(CXType handle) : base(handle, CXTypeKind.CXType_RValueReference, CX_TypeClass.CX_TypeClass_RValueReference) { - internal RValueReferenceType(CXType handle) : base(handle, CXTypeKind.CXType_RValueReference, CX_TypeClass.CX_TypeClass_RValueReference) - { - } } } diff --git a/sources/ClangSharp/Types/RecordType.cs b/sources/ClangSharp/Types/RecordType.cs index 9ec7407a..1a759603 100644 --- a/sources/ClangSharp/Types/RecordType.cs +++ b/sources/ClangSharp/Types/RecordType.cs @@ -2,15 +2,14 @@ using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class RecordType : TagType - { +namespace ClangSharp; - internal RecordType(CXType handle) : base(handle, CXTypeKind.CXType_Record, CX_TypeClass.CX_TypeClass_Record) - { - } +public sealed class RecordType : TagType +{ - public new RecordDecl Decl => (RecordDecl)base.Decl; + internal RecordType(CXType handle) : base(handle, CXTypeKind.CXType_Record, CX_TypeClass.CX_TypeClass_Record) + { } + + public new RecordDecl Decl => (RecordDecl)base.Decl; } diff --git a/sources/ClangSharp/Types/ReferenceType.cs b/sources/ClangSharp/Types/ReferenceType.cs index be6ae0e1..8c31aa52 100644 --- a/sources/ClangSharp/Types/ReferenceType.cs +++ b/sources/ClangSharp/Types/ReferenceType.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class ReferenceType : Type { - public class ReferenceType : Type + private protected ReferenceType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) { - private protected ReferenceType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - } } } diff --git a/sources/ClangSharp/Types/SubstTemplateTypeParmPackType.cs b/sources/ClangSharp/Types/SubstTemplateTypeParmPackType.cs index 498d9c7f..7f35cbb3 100644 --- a/sources/ClangSharp/Types/SubstTemplateTypeParmPackType.cs +++ b/sources/ClangSharp/Types/SubstTemplateTypeParmPackType.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SubstTemplateTypeParmPackType : Type { - public sealed class SubstTemplateTypeParmPackType : Type - { - private readonly Lazy _argumentPack; - private readonly Lazy _replacedParameter; + private readonly Lazy _argumentPack; + private readonly Lazy _replacedParameter; - internal SubstTemplateTypeParmPackType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_SubstTemplateTypeParmPack) - { - _argumentPack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(0))); - _replacedParameter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); - } + internal SubstTemplateTypeParmPackType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_SubstTemplateTypeParmPack) + { + _argumentPack = new Lazy(() => TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(0))); + _replacedParameter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); + } - public TemplateArgument ArgumentPack => _argumentPack.Value; + public TemplateArgument ArgumentPack => _argumentPack.Value; - public TemplateTypeParmType ReplacedParameter => _replacedParameter.Value; - } + public TemplateTypeParmType ReplacedParameter => _replacedParameter.Value; } diff --git a/sources/ClangSharp/Types/SubstTemplateTypeParmType.cs b/sources/ClangSharp/Types/SubstTemplateTypeParmType.cs index 23b5ee4a..b0fef226 100644 --- a/sources/ClangSharp/Types/SubstTemplateTypeParmType.cs +++ b/sources/ClangSharp/Types/SubstTemplateTypeParmType.cs @@ -3,19 +3,18 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class SubstTemplateTypeParmType : Type { - public sealed class SubstTemplateTypeParmType : Type - { - private readonly Lazy _replacedParameter; + private readonly Lazy _replacedParameter; - internal SubstTemplateTypeParmType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_SubstTemplateTypeParm) - { - _replacedParameter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); - } + internal SubstTemplateTypeParmType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_SubstTemplateTypeParm) + { + _replacedParameter = new Lazy(() => TranslationUnit.GetOrCreate(Handle.OriginalType)); + } - public TemplateTypeParmType ReplacedParameter => _replacedParameter.Value; + public TemplateTypeParmType ReplacedParameter => _replacedParameter.Value; - public Type ReplacementType => Desugar; - } + public Type ReplacementType => Desugar; } diff --git a/sources/ClangSharp/Types/TagType.cs b/sources/ClangSharp/Types/TagType.cs index 887ee6ac..52c25460 100644 --- a/sources/ClangSharp/Types/TagType.cs +++ b/sources/ClangSharp/Types/TagType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public class TagType : Type - { - private readonly Lazy _decl; +namespace ClangSharp; - private protected TagType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); - } +public class TagType : Type +{ + private readonly Lazy _decl; - public TagDecl Decl => _decl.Value; + private protected TagType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); } + + public TagDecl Decl => _decl.Value; } diff --git a/sources/ClangSharp/Types/TemplateSpecializationType.cs b/sources/ClangSharp/Types/TemplateSpecializationType.cs index 4fe33627..bfac55ee 100644 --- a/sources/ClangSharp/Types/TemplateSpecializationType.cs +++ b/sources/ClangSharp/Types/TemplateSpecializationType.cs @@ -4,37 +4,36 @@ using System.Collections.Generic; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TemplateSpecializationType : Type { - public sealed class TemplateSpecializationType : Type - { - private readonly Lazy> _templateArgs; - private readonly Lazy _templateName; + private readonly Lazy> _templateArgs; + private readonly Lazy _templateName; - internal TemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TemplateSpecialization) - { - _templateArgs = new Lazy>(() => { - var templateArgCount = Handle.NumTemplateArguments; - var templateArgs = new List(templateArgCount); + internal TemplateSpecializationType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TemplateSpecialization) + { + _templateArgs = new Lazy>(() => { + var templateArgCount = Handle.NumTemplateArguments; + var templateArgs = new List(templateArgCount); - for (var i = 0; i < templateArgCount; i++) - { - var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); - templateArgs.Add(templateArg); - } + for (var i = 0; i < templateArgCount; i++) + { + var templateArg = TranslationUnit.GetOrCreate(Handle.GetTemplateArgument(unchecked((uint)i))); + templateArgs.Add(templateArg); + } - return templateArgs; - }); + return templateArgs; + }); - _templateName = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateName)); - } + _templateName = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TemplateName)); + } - public Type AliasedType => IsTypeAlias ? Desugar : null; + public Type AliasedType => IsTypeAlias ? Desugar : null; - public IReadOnlyList Args => _templateArgs.Value; + public IReadOnlyList Args => _templateArgs.Value; - public bool IsTypeAlias => Handle.IsTypeAlias; + public bool IsTypeAlias => Handle.IsTypeAlias; - public TemplateName TemplateName => _templateName.Value; - } + public TemplateName TemplateName => _templateName.Value; } diff --git a/sources/ClangSharp/Types/TemplateTypeParmType.cs b/sources/ClangSharp/Types/TemplateTypeParmType.cs index 7a557a74..86f88795 100644 --- a/sources/ClangSharp/Types/TemplateTypeParmType.cs +++ b/sources/ClangSharp/Types/TemplateTypeParmType.cs @@ -3,21 +3,20 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public sealed class TemplateTypeParmType : Type { - public sealed class TemplateTypeParmType : Type - { - private readonly Lazy _decl; + private readonly Lazy _decl; - internal TemplateTypeParmType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TemplateTypeParm) - { - _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); - } + internal TemplateTypeParmType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TemplateTypeParm) + { + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); + } - public TemplateTypeParmDecl Decl => _decl.Value; + public TemplateTypeParmDecl Decl => _decl.Value; - public uint Depth => unchecked((uint)Handle.Depth); + public uint Depth => unchecked((uint)Handle.Depth); - public uint Index => unchecked((uint)Handle.Index); - } + public uint Index => unchecked((uint)Handle.Index); } diff --git a/sources/ClangSharp/Types/Type.cs b/sources/ClangSharp/Types/Type.cs index 69540b53..5f1b84e1 100644 --- a/sources/ClangSharp/Types/Type.cs +++ b/sources/ClangSharp/Types/Type.cs @@ -4,202 +4,201 @@ using System.Diagnostics; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +[DebuggerDisplay("{Handle.DebuggerDisplayString,nq}")] +public unsafe class Type : IEquatable { - [DebuggerDisplay("{Handle.DebuggerDisplayString,nq}")] - public unsafe class Type : IEquatable + private readonly Lazy _asString; + private readonly Lazy _canonicalType; + private readonly Lazy _desugar; + private readonly Lazy _kindSpelling; + private readonly Lazy _pointeeType; + private readonly Lazy _translationUnit; + + protected Type(CXType handle, CXTypeKind expectedKind, CX_TypeClass expectedTypeClass) { - private readonly Lazy _asString; - private readonly Lazy _canonicalType; - private readonly Lazy _desugar; - private readonly Lazy _kindSpelling; - private readonly Lazy _pointeeType; - private readonly Lazy _translationUnit; - - protected Type(CXType handle, CXTypeKind expectedKind, CX_TypeClass expectedTypeClass) + if (handle.kind != expectedKind) { - if (handle.kind != expectedKind) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } + throw new ArgumentOutOfRangeException(nameof(handle)); + } - if ((handle.TypeClass == CX_TypeClass.CX_TypeClass_Invalid) || (handle.TypeClass != expectedTypeClass)) - { - throw new ArgumentOutOfRangeException(nameof(handle)); - } - Handle = handle; - - _asString = new Lazy(() => Handle.Spelling.ToString()); - _canonicalType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CanonicalType)); - _desugar = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Desugar)); - _kindSpelling = new Lazy(() => Handle.KindSpelling.ToString()); - _pointeeType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PointeeType)); - _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate((CXTranslationUnit)Handle.data[1])); + if ((handle.TypeClass == CX_TypeClass.CX_TypeClass_Invalid) || (handle.TypeClass != expectedTypeClass)) + { + throw new ArgumentOutOfRangeException(nameof(handle)); } + Handle = handle; + + _asString = new Lazy(Handle.Spelling.ToString); + _canonicalType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.CanonicalType)); + _desugar = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Desugar)); + _kindSpelling = new Lazy(Handle.KindSpelling.ToString); + _pointeeType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.PointeeType)); + _translationUnit = new Lazy(() => TranslationUnit.GetOrCreate((CXTranslationUnit)Handle.data[1])); + } - public CXXRecordDecl AsCXXRecordDecl => AsTagDecl as CXXRecordDecl; + public CXXRecordDecl AsCXXRecordDecl => AsTagDecl as CXXRecordDecl; - public string AsString => _asString.Value; + public string AsString => _asString.Value; - public TagDecl AsTagDecl + public TagDecl AsTagDecl + { + get { - get - { - return GetAs() is TagType tt - ? tt.Decl - : (global::ClangSharp.TagDecl)(GetAs() is InjectedClassNameType injected ? injected.Decl : null); - } + return GetAs() is TagType tt + ? tt.Decl + : (global::ClangSharp.TagDecl)(GetAs() is InjectedClassNameType injected ? injected.Decl : null); } + } - public Type CanonicalType => _canonicalType.Value; + public Type CanonicalType => _canonicalType.Value; - public Type Desugar => _desugar.Value; + public Type Desugar => _desugar.Value; - public CXType Handle { get; } + public CXType Handle { get; } - public bool IsAnyPointerType => IsPointerType || IsObjCObjectPointerType; + public bool IsAnyPointerType => IsPointerType || IsObjCObjectPointerType; - public bool IsBitIntType => CanonicalType is BitIntType; + public bool IsBitIntType => CanonicalType is BitIntType; - public bool IsIntegerType => (CanonicalType is BuiltinType builtinType) && builtinType.Kind is >= CXTypeKind.CXType_Bool and <= CXTypeKind.CXType_Int128; + public bool IsIntegerType => (CanonicalType is BuiltinType builtinType) && builtinType.Kind is >= CXTypeKind.CXType_Bool and <= CXTypeKind.CXType_Int128; - public bool IsIntegralOrEnumerationType + public bool IsIntegralOrEnumerationType + { + get { - get - { - return CanonicalType is BuiltinType bt - ? bt.Kind is >= CXTypeKind.CXType_Bool and <= CXTypeKind.CXType_Int128 - : CanonicalType is EnumType et ? et.Decl.IsComplete : IsBitIntType; - } + return CanonicalType is BuiltinType bt + ? bt.Kind is >= CXTypeKind.CXType_Bool and <= CXTypeKind.CXType_Int128 + : CanonicalType is EnumType et ? et.Decl.IsComplete : IsBitIntType; } + } - public bool IsLocalConstQualified => Handle.IsConstQualified; + public bool IsLocalConstQualified => Handle.IsConstQualified; - public bool IsObjCObjectPointerType => CanonicalType is ObjCObjectPointerType; + public bool IsObjCObjectPointerType => CanonicalType is ObjCObjectPointerType; - public bool IsPointerType => CanonicalType is PointerType; + public bool IsPointerType => CanonicalType is PointerType; - public bool IsSugared => Handle.IsSugared; + public bool IsSugared => Handle.IsSugared; - public CXTypeKind Kind => Handle.kind; + public CXTypeKind Kind => Handle.kind; - public string KindSpelling => _kindSpelling.Value; + public string KindSpelling => _kindSpelling.Value; - public Type PointeeType => _pointeeType.Value; + public Type PointeeType => _pointeeType.Value; - public TranslationUnit TranslationUnit => _translationUnit.Value; + public TranslationUnit TranslationUnit => _translationUnit.Value; - public CX_TypeClass TypeClass => Handle.TypeClass; + public CX_TypeClass TypeClass => Handle.TypeClass; - public string TypeClassSpelling => Handle.TypeClassSpelling; + public string TypeClassSpelling => Handle.TypeClassSpelling; - public Type UnqualifiedDesugaredType + public Type UnqualifiedDesugaredType + { + get { - get - { - var cur = this; + var cur = this; - while (true) + while (true) + { + if (!cur.IsSugared) { - if (!cur.IsSugared) - { - return cur; - } - cur = cur.Desugar; + return cur; } + cur = cur.Desugar; } } + } - public static bool operator ==(Type left, Type right) => (left is object) ? ((right is object) && (left.Handle == right.Handle)) : (right is null); - - public static bool operator !=(Type left, Type right) => (left is object) ? ((right is null) || (left.Handle != right.Handle)) : (right is object); - - internal static Type Create(CXType handle) => handle.TypeClass switch { - CX_TypeClass.CX_TypeClass_Invalid => new Type(handle, handle.kind, handle.TypeClass), - CX_TypeClass.CX_TypeClass_Adjusted => new AdjustedType(handle), - CX_TypeClass.CX_TypeClass_Decayed => new DecayedType(handle), - CX_TypeClass.CX_TypeClass_ConstantArray => new ConstantArrayType(handle), - CX_TypeClass.CX_TypeClass_DependentSizedArray => new DependentSizedArrayType(handle), - CX_TypeClass.CX_TypeClass_IncompleteArray => new IncompleteArrayType(handle), - CX_TypeClass.CX_TypeClass_VariableArray => new VariableArrayType(handle), - CX_TypeClass.CX_TypeClass_Atomic => new AtomicType(handle), - CX_TypeClass.CX_TypeClass_Attributed => new AttributedType(handle), - CX_TypeClass.CX_TypeClass_BlockPointer => new BlockPointerType(handle), - CX_TypeClass.CX_TypeClass_Builtin => new BuiltinType(handle), - CX_TypeClass.CX_TypeClass_Complex => new ComplexType(handle), - CX_TypeClass.CX_TypeClass_Decltype => new DecltypeType(handle), - CX_TypeClass.CX_TypeClass_Auto => new AutoType(handle), - CX_TypeClass.CX_TypeClass_DeducedTemplateSpecialization => new DeducedTemplateSpecializationType(handle), - CX_TypeClass.CX_TypeClass_DependentAddressSpace => new DependentAddressSpaceType(handle), - CX_TypeClass.CX_TypeClass_DependentBitInt => new DependentBitIntType(handle), - CX_TypeClass.CX_TypeClass_DependentName => new DependentNameType(handle), - CX_TypeClass.CX_TypeClass_DependentSizedExtVector => new DependentSizedExtVectorType(handle), - CX_TypeClass.CX_TypeClass_DependentTemplateSpecialization => new DependentTemplateSpecializationType(handle), - CX_TypeClass.CX_TypeClass_DependentVector => new DependentVectorType(handle), - CX_TypeClass.CX_TypeClass_Elaborated => new ElaboratedType(handle), - CX_TypeClass.CX_TypeClass_BitInt => new BitIntType(handle), - CX_TypeClass.CX_TypeClass_FunctionNoProto => new FunctionNoProtoType(handle), - CX_TypeClass.CX_TypeClass_FunctionProto => new FunctionProtoType(handle), - CX_TypeClass.CX_TypeClass_InjectedClassName => new InjectedClassNameType(handle), - CX_TypeClass.CX_TypeClass_MacroQualified => new MacroQualifiedType(handle), - CX_TypeClass.CX_TypeClass_ConstantMatrix => new ConstantMatrixType(handle), - CX_TypeClass.CX_TypeClass_DependentSizedMatrix => new DependentSizedMatrixType(handle), - CX_TypeClass.CX_TypeClass_MemberPointer => new MemberPointerType(handle), - CX_TypeClass.CX_TypeClass_ObjCObjectPointer => new ObjCObjectPointerType(handle), - CX_TypeClass.CX_TypeClass_ObjCObject => new ObjCObjectType(handle), - CX_TypeClass.CX_TypeClass_ObjCInterface => new ObjCInterfaceType(handle), - CX_TypeClass.CX_TypeClass_ObjCTypeParam => new ObjCTypeParamType(handle), - CX_TypeClass.CX_TypeClass_PackExpansion => new PackExpansionType(handle), - CX_TypeClass.CX_TypeClass_Paren => new ParenType(handle), - CX_TypeClass.CX_TypeClass_Pipe => new PipeType(handle), - CX_TypeClass.CX_TypeClass_Pointer => new PointerType(handle), - CX_TypeClass.CX_TypeClass_LValueReference => new LValueReferenceType(handle), - CX_TypeClass.CX_TypeClass_RValueReference => new RValueReferenceType(handle), - CX_TypeClass.CX_TypeClass_SubstTemplateTypeParmPack => new SubstTemplateTypeParmPackType(handle), - CX_TypeClass.CX_TypeClass_SubstTemplateTypeParm => new SubstTemplateTypeParmType(handle), - CX_TypeClass.CX_TypeClass_Enum => new EnumType(handle), - CX_TypeClass.CX_TypeClass_Record => new RecordType(handle), - CX_TypeClass.CX_TypeClass_TemplateSpecialization => new TemplateSpecializationType(handle), - CX_TypeClass.CX_TypeClass_TemplateTypeParm => new TemplateTypeParmType(handle), - CX_TypeClass.CX_TypeClass_TypeOfExpr => new TypeOfExprType(handle), - CX_TypeClass.CX_TypeClass_TypeOf => new TypeOfType(handle), - CX_TypeClass.CX_TypeClass_Typedef => new TypedefType(handle), - CX_TypeClass.CX_TypeClass_UnaryTransform => new UnaryTransformType(handle), - CX_TypeClass.CX_TypeClass_UnresolvedUsing => new UnresolvedUsingType(handle), - CX_TypeClass.CX_TypeClass_Using => new UsingType(handle), - CX_TypeClass.CX_TypeClass_Vector => new VectorType(handle), - CX_TypeClass.CX_TypeClass_ExtVector => new ExtVectorType(handle), - _ => new Type(handle, handle.kind, handle.TypeClass), - }; - - public override bool Equals(object obj) => (obj is Type other) && Equals(other); - - public bool Equals(Type other) => this == other; - - public T CastAs() - where T : Type - { - Debug.Assert(!typeof(ArrayType).IsAssignableFrom(typeof(T)), "ArrayType cannot be used with castAs!"); - - if (this is T ty) - { - return ty; - } - - Debug.Assert(CanonicalType is T); - return (T)UnqualifiedDesugaredType; - } + public static bool operator ==(Type left, Type right) => (left is not null) ? ((right is not null) && (left.Handle == right.Handle)) : (right is null); + + public static bool operator !=(Type left, Type right) => (left is not null) ? ((right is null) || (left.Handle != right.Handle)) : (right is not null); + + internal static Type Create(CXType handle) => handle.TypeClass switch { + CX_TypeClass.CX_TypeClass_Invalid => new Type(handle, handle.kind, handle.TypeClass), + CX_TypeClass.CX_TypeClass_Adjusted => new AdjustedType(handle), + CX_TypeClass.CX_TypeClass_Decayed => new DecayedType(handle), + CX_TypeClass.CX_TypeClass_ConstantArray => new ConstantArrayType(handle), + CX_TypeClass.CX_TypeClass_DependentSizedArray => new DependentSizedArrayType(handle), + CX_TypeClass.CX_TypeClass_IncompleteArray => new IncompleteArrayType(handle), + CX_TypeClass.CX_TypeClass_VariableArray => new VariableArrayType(handle), + CX_TypeClass.CX_TypeClass_Atomic => new AtomicType(handle), + CX_TypeClass.CX_TypeClass_Attributed => new AttributedType(handle), + CX_TypeClass.CX_TypeClass_BlockPointer => new BlockPointerType(handle), + CX_TypeClass.CX_TypeClass_Builtin => new BuiltinType(handle), + CX_TypeClass.CX_TypeClass_Complex => new ComplexType(handle), + CX_TypeClass.CX_TypeClass_Decltype => new DecltypeType(handle), + CX_TypeClass.CX_TypeClass_Auto => new AutoType(handle), + CX_TypeClass.CX_TypeClass_DeducedTemplateSpecialization => new DeducedTemplateSpecializationType(handle), + CX_TypeClass.CX_TypeClass_DependentAddressSpace => new DependentAddressSpaceType(handle), + CX_TypeClass.CX_TypeClass_DependentBitInt => new DependentBitIntType(handle), + CX_TypeClass.CX_TypeClass_DependentName => new DependentNameType(handle), + CX_TypeClass.CX_TypeClass_DependentSizedExtVector => new DependentSizedExtVectorType(handle), + CX_TypeClass.CX_TypeClass_DependentTemplateSpecialization => new DependentTemplateSpecializationType(handle), + CX_TypeClass.CX_TypeClass_DependentVector => new DependentVectorType(handle), + CX_TypeClass.CX_TypeClass_Elaborated => new ElaboratedType(handle), + CX_TypeClass.CX_TypeClass_BitInt => new BitIntType(handle), + CX_TypeClass.CX_TypeClass_FunctionNoProto => new FunctionNoProtoType(handle), + CX_TypeClass.CX_TypeClass_FunctionProto => new FunctionProtoType(handle), + CX_TypeClass.CX_TypeClass_InjectedClassName => new InjectedClassNameType(handle), + CX_TypeClass.CX_TypeClass_MacroQualified => new MacroQualifiedType(handle), + CX_TypeClass.CX_TypeClass_ConstantMatrix => new ConstantMatrixType(handle), + CX_TypeClass.CX_TypeClass_DependentSizedMatrix => new DependentSizedMatrixType(handle), + CX_TypeClass.CX_TypeClass_MemberPointer => new MemberPointerType(handle), + CX_TypeClass.CX_TypeClass_ObjCObjectPointer => new ObjCObjectPointerType(handle), + CX_TypeClass.CX_TypeClass_ObjCObject => new ObjCObjectType(handle), + CX_TypeClass.CX_TypeClass_ObjCInterface => new ObjCInterfaceType(handle), + CX_TypeClass.CX_TypeClass_ObjCTypeParam => new ObjCTypeParamType(handle), + CX_TypeClass.CX_TypeClass_PackExpansion => new PackExpansionType(handle), + CX_TypeClass.CX_TypeClass_Paren => new ParenType(handle), + CX_TypeClass.CX_TypeClass_Pipe => new PipeType(handle), + CX_TypeClass.CX_TypeClass_Pointer => new PointerType(handle), + CX_TypeClass.CX_TypeClass_LValueReference => new LValueReferenceType(handle), + CX_TypeClass.CX_TypeClass_RValueReference => new RValueReferenceType(handle), + CX_TypeClass.CX_TypeClass_SubstTemplateTypeParmPack => new SubstTemplateTypeParmPackType(handle), + CX_TypeClass.CX_TypeClass_SubstTemplateTypeParm => new SubstTemplateTypeParmType(handle), + CX_TypeClass.CX_TypeClass_Enum => new EnumType(handle), + CX_TypeClass.CX_TypeClass_Record => new RecordType(handle), + CX_TypeClass.CX_TypeClass_TemplateSpecialization => new TemplateSpecializationType(handle), + CX_TypeClass.CX_TypeClass_TemplateTypeParm => new TemplateTypeParmType(handle), + CX_TypeClass.CX_TypeClass_TypeOfExpr => new TypeOfExprType(handle), + CX_TypeClass.CX_TypeClass_TypeOf => new TypeOfType(handle), + CX_TypeClass.CX_TypeClass_Typedef => new TypedefType(handle), + CX_TypeClass.CX_TypeClass_UnaryTransform => new UnaryTransformType(handle), + CX_TypeClass.CX_TypeClass_UnresolvedUsing => new UnresolvedUsingType(handle), + CX_TypeClass.CX_TypeClass_Using => new UsingType(handle), + CX_TypeClass.CX_TypeClass_Vector => new VectorType(handle), + CX_TypeClass.CX_TypeClass_ExtVector => new ExtVectorType(handle), + _ => new Type(handle, handle.kind, handle.TypeClass), + }; + + public override bool Equals(object obj) => (obj is Type other) && Equals(other); + + public bool Equals(Type other) => this == other; + + public T CastAs() + where T : Type + { + Debug.Assert(!typeof(ArrayType).IsAssignableFrom(typeof(T)), "ArrayType cannot be used with castAs!"); - public T GetAs() - where T : Type + if (this is T ty) { - Debug.Assert(!typeof(ArrayType).IsAssignableFrom(typeof(T)), "ArrayType cannot be used with getAs!"); - - return this is T ty ? ty : CanonicalType is not T ? null : (T)UnqualifiedDesugaredType; + return ty; } - public override int GetHashCode() => Handle.GetHashCode(); + Debug.Assert(CanonicalType is T); + return (T)UnqualifiedDesugaredType; + } + + public T GetAs() + where T : Type + { + Debug.Assert(!typeof(ArrayType).IsAssignableFrom(typeof(T)), "ArrayType cannot be used with getAs!"); - public override string ToString() => AsString; + return this is T ty ? ty : CanonicalType is not T ? null : (T)UnqualifiedDesugaredType; } + + public override int GetHashCode() => Handle.GetHashCode(); + + public override string ToString() => AsString; } diff --git a/sources/ClangSharp/Types/TypeOfExprType.cs b/sources/ClangSharp/Types/TypeOfExprType.cs index e8b5aa23..17b295ab 100644 --- a/sources/ClangSharp/Types/TypeOfExprType.cs +++ b/sources/ClangSharp/Types/TypeOfExprType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class TypeOfExprType : Type - { - private readonly Lazy _underlyingExpr; +namespace ClangSharp; - internal TypeOfExprType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TypeOfExpr) - { - _underlyingExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.UnderlyingExpr)); - } +public sealed class TypeOfExprType : Type +{ + private readonly Lazy _underlyingExpr; - public Expr UnderlyingExpr => _underlyingExpr.Value; + internal TypeOfExprType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TypeOfExpr) + { + _underlyingExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.UnderlyingExpr)); } + + public Expr UnderlyingExpr => _underlyingExpr.Value; } diff --git a/sources/ClangSharp/Types/TypeOfType.cs b/sources/ClangSharp/Types/TypeOfType.cs index d35b9830..e1a4ed2f 100644 --- a/sources/ClangSharp/Types/TypeOfType.cs +++ b/sources/ClangSharp/Types/TypeOfType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class TypeOfType : Type - { - private readonly Lazy _underlyingType; +namespace ClangSharp; - internal TypeOfType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TypeOf) - { - _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); - } +public sealed class TypeOfType : Type +{ + private readonly Lazy _underlyingType; - public Type UnderlyingType => _underlyingType.Value; + internal TypeOfType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_TypeOf) + { + _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); } + + public Type UnderlyingType => _underlyingType.Value; } diff --git a/sources/ClangSharp/Types/TypeWithKeyword.cs b/sources/ClangSharp/Types/TypeWithKeyword.cs index 3fa0d58a..2d1f5fdc 100644 --- a/sources/ClangSharp/Types/TypeWithKeyword.cs +++ b/sources/ClangSharp/Types/TypeWithKeyword.cs @@ -2,12 +2,11 @@ using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class TypeWithKeyword : Type { - public class TypeWithKeyword : Type + private protected TypeWithKeyword(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) { - private protected TypeWithKeyword(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - } } } diff --git a/sources/ClangSharp/Types/TypedefType.cs b/sources/ClangSharp/Types/TypedefType.cs index 81354089..9b3c1002 100644 --- a/sources/ClangSharp/Types/TypedefType.cs +++ b/sources/ClangSharp/Types/TypedefType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class TypedefType : Type - { - private readonly Lazy _decl; +namespace ClangSharp; - internal TypedefType(CXType handle) : base(handle, CXTypeKind.CXType_Typedef, CX_TypeClass.CX_TypeClass_Typedef) - { - _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); - } +public sealed class TypedefType : Type +{ + private readonly Lazy _decl; - public TypedefNameDecl Decl => _decl.Value; + internal TypedefType(CXType handle) : base(handle, CXTypeKind.CXType_Typedef, CX_TypeClass.CX_TypeClass_Typedef) + { + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); } + + public TypedefNameDecl Decl => _decl.Value; } diff --git a/sources/ClangSharp/Types/UnaryTransformType.cs b/sources/ClangSharp/Types/UnaryTransformType.cs index 4eafd720..a879ac7e 100644 --- a/sources/ClangSharp/Types/UnaryTransformType.cs +++ b/sources/ClangSharp/Types/UnaryTransformType.cs @@ -3,25 +3,24 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class UnaryTransformType : Type { - public class UnaryTransformType : Type - { - private readonly Lazy _baseType; - private readonly Lazy _underlyingType; + private readonly Lazy _baseType; + private readonly Lazy _underlyingType; - internal UnaryTransformType(CXType handle) : this(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_UnaryTransform) - { - } + internal UnaryTransformType(CXType handle) : this(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_UnaryTransform) + { + } - private protected UnaryTransformType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - _baseType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.BaseType)); - _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); - } + private protected UnaryTransformType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + _baseType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.BaseType)); + _underlyingType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.UnderlyingType)); + } - public Type BaseType => _baseType.Value; + public Type BaseType => _baseType.Value; - public Type UnderlyingType => _underlyingType.Value; - } + public Type UnderlyingType => _underlyingType.Value; } diff --git a/sources/ClangSharp/Types/UnresolvedUsingType.cs b/sources/ClangSharp/Types/UnresolvedUsingType.cs index 1222447f..f255d8b3 100644 --- a/sources/ClangSharp/Types/UnresolvedUsingType.cs +++ b/sources/ClangSharp/Types/UnresolvedUsingType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class UnresolvedUsingType : Type - { - private readonly Lazy _decl; +namespace ClangSharp; - internal UnresolvedUsingType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_UnresolvedUsing) - { - _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); - } +public sealed class UnresolvedUsingType : Type +{ + private readonly Lazy _decl; - public UnresolvedUsingTypenameDecl Decl => _decl.Value; + internal UnresolvedUsingType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_UnresolvedUsing) + { + _decl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); } + + public UnresolvedUsingTypenameDecl Decl => _decl.Value; } diff --git a/sources/ClangSharp/Types/UsingType.cs b/sources/ClangSharp/Types/UsingType.cs index ce0c79d9..01d74f79 100644 --- a/sources/ClangSharp/Types/UsingType.cs +++ b/sources/ClangSharp/Types/UsingType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class UsingType : Type - { - private readonly Lazy _foundDecl; +namespace ClangSharp; - internal UsingType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Using) - { - _foundDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); - } +public sealed class UsingType : Type +{ + private readonly Lazy _foundDecl; - public UsingShadowDecl FoundDecl => _foundDecl.Value; + internal UsingType(CXType handle) : base(handle, CXTypeKind.CXType_Unexposed, CX_TypeClass.CX_TypeClass_Using) + { + _foundDecl = new Lazy(() => TranslationUnit.GetOrCreate(Handle.Declaration)); } + + public UsingShadowDecl FoundDecl => _foundDecl.Value; } diff --git a/sources/ClangSharp/Types/VariableArrayType.cs b/sources/ClangSharp/Types/VariableArrayType.cs index 6b46d86d..e3ad9304 100644 --- a/sources/ClangSharp/Types/VariableArrayType.cs +++ b/sources/ClangSharp/Types/VariableArrayType.cs @@ -3,17 +3,16 @@ using System; using ClangSharp.Interop; -namespace ClangSharp -{ - public sealed class VariableArrayType : ArrayType - { - private readonly Lazy _sizeExpr; +namespace ClangSharp; - internal VariableArrayType(CXType handle) : base(handle, CXTypeKind.CXType_VariableArray, CX_TypeClass.CX_TypeClass_VariableArray) - { - _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.SizeExpr)); - } +public sealed class VariableArrayType : ArrayType +{ + private readonly Lazy _sizeExpr; - public Expr SizeExpr => _sizeExpr.Value; + internal VariableArrayType(CXType handle) : base(handle, CXTypeKind.CXType_VariableArray, CX_TypeClass.CX_TypeClass_VariableArray) + { + _sizeExpr = new Lazy(() => TranslationUnit.GetOrCreate(handle.SizeExpr)); } + + public Expr SizeExpr => _sizeExpr.Value; } diff --git a/sources/ClangSharp/Types/VectorType.cs b/sources/ClangSharp/Types/VectorType.cs index 94b74570..ca7bfe4e 100644 --- a/sources/ClangSharp/Types/VectorType.cs +++ b/sources/ClangSharp/Types/VectorType.cs @@ -3,23 +3,22 @@ using System; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class VectorType : Type { - public class VectorType : Type - { - private readonly Lazy _elementType; + private readonly Lazy _elementType; - internal VectorType(CXType handle) : base(handle, CXTypeKind.CXType_Vector, CX_TypeClass.CX_TypeClass_Vector) - { - } + internal VectorType(CXType handle) : base(handle, CXTypeKind.CXType_Vector, CX_TypeClass.CX_TypeClass_Vector) + { + } - private protected VectorType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) - { - _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); - } + private protected VectorType(CXType handle, CXTypeKind expectedTypeKind, CX_TypeClass expectedTypeClass) : base(handle, expectedTypeKind, expectedTypeClass) + { + _elementType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.ElementType)); + } - public Type ElementType => _elementType.Value; + public Type ElementType => _elementType.Value; - public long NumElements => Handle.NumElements; - } + public long NumElements => Handle.NumElements; } diff --git a/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs b/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs index c2987228..a889b800 100644 --- a/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs +++ b/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs @@ -7,39 +7,38 @@ using System.CommandLine.Help; using System.CommandLine.IO; -namespace ClangSharp +namespace ClangSharp; + +internal sealed class CustomHelpBuilder : HelpBuilder { - internal sealed class CustomHelpBuilder : HelpBuilder + private IConsole Console { get; } + + public CustomHelpBuilder(IConsole console, LocalizationResources localizationResources, + int maxWidth = int.MaxValue) + : base(localizationResources, maxWidth) + { + Console = console; + } + + public void Write(Option option) { - private IConsole Console { get; } - - public CustomHelpBuilder(IConsole console, LocalizationResources localizationResources, - int maxWidth = int.MaxValue) - : base(localizationResources, maxWidth) - { - Console = console; - } - - public void Write(Option option) - { - Write(string.Join(", ", option.Aliases)); - Write("\t"); - Write(option.Description); - WriteLine(); - } - - public void Write(string value) => Console.Out.Write(value); - - public void Write(params TwoColumnHelpRow[] helpItems) - { - WriteLine("Options:"); - var _ = new Command("unused"); - WriteColumns(helpItems, new HelpContext(this, _, Console.Out.CreateTextWriter())); - WriteLine(); - } - - public void WriteLine() => Console.Out.WriteLine(); - - public void WriteLine(string value) => Console.Out.WriteLine(value); + Write(string.Join(", ", option.Aliases)); + Write("\t"); + Write(option.Description); + WriteLine(); } + + public void Write(string value) => Console.Out.Write(value); + + public void Write(params TwoColumnHelpRow[] helpItems) + { + WriteLine("Options:"); + var _ = new Command("unused"); + WriteColumns(helpItems, new HelpContext(this, _, Console.Out.CreateTextWriter())); + WriteLine(); + } + + public void WriteLine() => Console.Out.WriteLine(); + + public void WriteLine(string value) => Console.Out.WriteLine(value); } diff --git a/sources/ClangSharpPInvokeGenerator/Program.cs b/sources/ClangSharpPInvokeGenerator/Program.cs index fea5dcc5..a4118701 100644 --- a/sources/ClangSharpPInvokeGenerator/Program.cs +++ b/sources/ClangSharpPInvokeGenerator/Program.cs @@ -15,1257 +15,1254 @@ using ClangSharp.Abstractions; using ClangSharp.Interop; -namespace ClangSharp +namespace ClangSharp; + +public class Program { - public class Program + private static RootCommand s_rootCommand; + private static Option s_versionOption; + private static Option s_addtionalOption; + private static Option s_configOption; + private static Option s_defineMacros; + private static Option s_excludedNames; + private static Option s_files; + private static Option s_fileDirectory; + private static Option s_headerFile; + private static Option s_includedNames; + private static Option s_includeDirectories; + private static Option s_language; + private static Option s_libraryPath; + private static Option s_methodClassName; + private static Option s_methodPrefixToStrip; + private static Option s_namespaceName; + private static Option s_outputLocation; + private static Option s_outputMode; + private static Option s_remappedNameValuePairs; + private static Option s_std; + private static Option s_testOutputLocation; + private static Option s_traversalNames; + private static Option s_withAccessSpecifierNameValuePairs; + private static Option s_withAttributeNameValuePairs; + private static Option s_withCallConvNameValuePairs; + private static Option s_withClassNameValuePairs; + private static Option s_withGuidNameValuePairs; + private static Option s_withLibraryPathNameValuePairs; + private static Option s_withManualImports; + private static Option s_withNamespaceNameValuePairs; + private static Option s_withSetLastErrors; + private static Option s_withSuppressGCTransitions; + private static Option s_withTransparentStructNameValuePairs; + private static Option s_withTypeNameValuePairs; + private static Option s_withUsingNameValuePairs; + + + private static readonly TwoColumnHelpRow[] s_configOptions = new TwoColumnHelpRow[] { - private static RootCommand s_rootCommand; - private static Option s_versionOption; - private static Option s_addtionalOption; - private static Option s_configOption; - private static Option s_defineMacros; - private static Option s_excludedNames; - private static Option s_files; - private static Option s_fileDirectory; - private static Option s_headerFile; - private static Option s_includedNames; - private static Option s_includeDirectories; - private static Option s_language; - private static Option s_libraryPath; - private static Option s_methodClassName; - private static Option s_methodPrefixToStrip; - private static Option s_namespaceName; - private static Option s_outputLocation; - private static Option s_outputMode; - private static Option s_remappedNameValuePairs; - private static Option s_std; - private static Option s_testOutputLocation; - private static Option s_traversalNames; - private static Option s_withAccessSpecifierNameValuePairs; - private static Option s_withAttributeNameValuePairs; - private static Option s_withCallConvNameValuePairs; - private static Option s_withClassNameValuePairs; - private static Option s_withGuidNameValuePairs; - private static Option s_withLibraryPathNameValuePairs; - private static Option s_withManualImports; - private static Option s_withNamespaceNameValuePairs; - private static Option s_withSetLastErrors; - private static Option s_withSuppressGCTransitions; - private static Option s_withTransparentStructNameValuePairs; - private static Option s_withTypeNameValuePairs; - private static Option s_withUsingNameValuePairs; - - - private static readonly TwoColumnHelpRow[] s_configOptions = new TwoColumnHelpRow[] - { - new TwoColumnHelpRow("?, h, help", "Show help and usage information for -c, --config"), + new TwoColumnHelpRow("?, h, help", "Show help and usage information for -c, --config"), - // Codegen Options + // Codegen Options - new TwoColumnHelpRow("compatible-codegen", "Bindings should be generated with .NET Standard 2.0 compatibility. Setting this disables preview code generation."), - new TwoColumnHelpRow("latest-codegen", "Bindings should be generated for the latest stable version of .NET/C#. This is currently .NET 6/C# 10."), - new TwoColumnHelpRow("preview-codegen", "Bindings should be generated for the latest preview version of .NET/C#. This is currently .NET 7/C# 11."), + new TwoColumnHelpRow("compatible-codegen", "Bindings should be generated with .NET Standard 2.0 compatibility. Setting this disables preview code generation."), + new TwoColumnHelpRow("latest-codegen", "Bindings should be generated for the latest stable version of .NET/C#. This is currently .NET 6/C# 10."), + new TwoColumnHelpRow("preview-codegen", "Bindings should be generated for the latest preview version of .NET/C#. This is currently .NET 7/C# 11."), - // File Options + // File Options - 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."), + 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 + // Type Options - 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."), + 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 + // Exclusion Options - 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. Thes are currently function declarations ending with _UserFree, _UserMarshal, _UserSize, _UserUnmarshal, _Proxy, or _Stub."), - new TwoColumnHelpRow("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"), - new TwoColumnHelpRow("exclude-empty-records", "Bindings for records that contain no members should not be generated. These are commonly encountered for opaque handle like types such as HWND."), - new TwoColumnHelpRow("exclude-enum-operators", "Bindings for operators over enum types should not be generated. These are largely unnecessary in C# as the operators are available by default."), - new TwoColumnHelpRow("exclude-fnptr-codegen", "Generated bindings for latest or preview codegen should not use function pointers."), - 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;'"), + 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. Thes are currently function declarations ending with _UserFree, _UserMarshal, _UserSize, _UserUnmarshal, _Proxy, or _Stub."), + new TwoColumnHelpRow("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"), + new TwoColumnHelpRow("exclude-empty-records", "Bindings for records that contain no members should not be generated. These are commonly encountered for opaque handle like types such as HWND."), + new TwoColumnHelpRow("exclude-enum-operators", "Bindings for operators over enum types should not be generated. These are largely unnecessary in C# as the operators are available by default."), + new TwoColumnHelpRow("exclude-fnptr-codegen", "Generated bindings for latest or preview codegen should not use function pointers."), + 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 + // VTBL Options - 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."), + 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 + // Test Options - 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."), + 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 + // Generation Options - new TwoColumnHelpRow("generate-aggressive-inlining", "[MethodImpl(MethodImplOptions.AggressiveInlining)] should be added to generated helper functions."), - new TwoColumnHelpRow("generate-cpp-attributes", "[CppAttributeList(\"\")] should be generated to document the encountered C++ attributes."), - new TwoColumnHelpRow("generate-doc-includes", " xml documentation tags should be generated for declarations."), - new TwoColumnHelpRow("generate-file-scoped-namespaces", "Namespaces should be scoped to the file to reduce nesting."), - new TwoColumnHelpRow("generate-guid-member", "Types with an associated GUID should have a corresponding member generated."), - new TwoColumnHelpRow("generate-helper-types", "Code files should be generated for various helper attributes and declared transparent structs."), - new TwoColumnHelpRow("generate-macro-bindings", "Bindings for macro-definitions should be generated. This currently only works with value like macros and not function-like ones."), - new TwoColumnHelpRow("generate-marker-interfaces", "Bindings for marker interfaces representing native inheritance hierarchies should be generated."), - new TwoColumnHelpRow("generate-native-inheritance-attribute", "[NativeInheritance(\"\")] attribute should be generated to document the encountered C++ base type."), - new TwoColumnHelpRow("generate-setslastsystemerror-attribute", "[SetsLastSystemError] attribute should be generated rather than using SetLastError = true."), - new TwoColumnHelpRow("generate-template-bindings", "Bindings for template-definitions should be generated. This is currently experimental."), - 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."), + new TwoColumnHelpRow("generate-aggressive-inlining", "[MethodImpl(MethodImplOptions.AggressiveInlining)] should be added to generated helper functions."), + new TwoColumnHelpRow("generate-cpp-attributes", "[CppAttributeList(\"\")] should be generated to document the encountered C++ attributes."), + new TwoColumnHelpRow("generate-doc-includes", " xml documentation tags should be generated for declarations."), + new TwoColumnHelpRow("generate-file-scoped-namespaces", "Namespaces should be scoped to the file to reduce nesting."), + new TwoColumnHelpRow("generate-guid-member", "Types with an associated GUID should have a corresponding member generated."), + new TwoColumnHelpRow("generate-helper-types", "Code files should be generated for various helper attributes and declared transparent structs."), + new TwoColumnHelpRow("generate-macro-bindings", "Bindings for macro-definitions should be generated. This currently only works with value like macros and not function-like ones."), + new TwoColumnHelpRow("generate-marker-interfaces", "Bindings for marker interfaces representing native inheritance hierarchies should be generated."), + new TwoColumnHelpRow("generate-native-inheritance-attribute", "[NativeInheritance(\"\")] attribute should be generated to document the encountered C++ base type."), + new TwoColumnHelpRow("generate-setslastsystemerror-attribute", "[SetsLastSystemError] attribute should be generated rather than using SetLastError = true."), + new TwoColumnHelpRow("generate-template-bindings", "Bindings for template-definitions should be generated. This is currently experimental."), + 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 + // Logging Options - 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."), - new TwoColumnHelpRow("log-visited-files", "A list of the visited files should be generated. This can help identify traversal issues."), + 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."), + new TwoColumnHelpRow("log-visited-files", "A list of the visited files should be generated. This can help identify traversal issues."), + }; + + public static async Task Main(params string[] args) + { + s_addtionalOption = GetAdditionalOption(); + s_configOption = GetConfigOption(); + s_defineMacros = GetDefineMacroOption(); + s_excludedNames = GetExcludeOption(); + s_files = GetFileOption(); + s_fileDirectory = GetFileDirectoryOption(); + s_headerFile = GetHeaderOption(); + s_includedNames = GetIncludeOption(); + s_includeDirectories = GetIncludeDirectoryOption(); + s_language = GetLanguageOption(); + s_libraryPath = GetLibraryOption(); + s_methodClassName = GetMethodClassNameOption(); + s_namespaceName = GetNamespaceOption(); + s_outputMode = GetOutputModeOption(); + s_outputLocation = GetOutputOption(); + s_methodPrefixToStrip = GetPrefixStripOption(); + s_remappedNameValuePairs = GetRemapOption(); + s_std = GetStdOption(); + s_testOutputLocation = GetTestOutputOption(); + s_traversalNames = GetTraverseOption(); + s_versionOption = GetVersionOption(); + s_withAccessSpecifierNameValuePairs = GetWithAccessSpecifierOption(); + s_withAttributeNameValuePairs = GetWithAttributeOption(); + s_withCallConvNameValuePairs = GetWithCallConvOption(); + s_withClassNameValuePairs = GetWithClassOption(); + s_withGuidNameValuePairs = GetWithGuidOption(); + s_withLibraryPathNameValuePairs = GetWithLibraryPathOption(); + s_withManualImports = GetWithManualImportOption(); + s_withNamespaceNameValuePairs = GetWithNamespaceOption(); + s_withSetLastErrors = GetWithSetLastErrorOption(); + s_withSuppressGCTransitions = GetWithSuppressGCTransitionOption(); + s_withTransparentStructNameValuePairs = GetWithTransparentStructOption(); + s_withTypeNameValuePairs = GetWithTypeOption(); + s_withUsingNameValuePairs = GetWithUsingOption(); + s_rootCommand = new RootCommand("ClangSharp P/Invoke Binding Generator") + { + s_addtionalOption, + s_configOption, + s_defineMacros, + s_excludedNames, + s_files, + s_fileDirectory, + s_headerFile, + s_includedNames, + s_includeDirectories, + s_language, + s_libraryPath, + s_methodClassName, + s_namespaceName, + s_outputMode, + s_outputLocation, + s_methodPrefixToStrip, + s_remappedNameValuePairs, + s_std, + s_testOutputLocation, + s_traversalNames, + s_versionOption, + s_withAccessSpecifierNameValuePairs, + s_withAttributeNameValuePairs, + s_withCallConvNameValuePairs, + s_withClassNameValuePairs, + s_withGuidNameValuePairs, + s_withLibraryPathNameValuePairs, + s_withManualImports, + s_withNamespaceNameValuePairs, + s_withSetLastErrors, + s_withSuppressGCTransitions, + s_withTransparentStructNameValuePairs, + s_withTypeNameValuePairs, + s_withUsingNameValuePairs }; + s_rootCommand.SetHandler(Run); + + var parser = new CommandLineBuilder(s_rootCommand) + .UseHelp() + .UseEnvironmentVariableDirective() + .UseParseDirective() + .UseSuggestDirective() + .RegisterWithDotnetSuggest() + .UseTypoCorrections() + .UseParseErrorReporting() + .UseExceptionHandler() + .CancelOnProcessTermination() + .Build(); + return await parser.InvokeAsync(args); + } -#pragma warning disable IDE1006 - public static async Task Main(params string[] args) + public static void Run(InvocationContext context) + { + var additionalArgs = context.ParseResult.GetValueForOption(s_addtionalOption); + var configSwitches = context.ParseResult.GetValueForOption(s_configOption); + var defineMacros = context.ParseResult.GetValueForOption(s_defineMacros); + var excludedNames = context.ParseResult.GetValueForOption(s_excludedNames); + var files = context.ParseResult.GetValueForOption(s_files); + var fileDirectory = context.ParseResult.GetValueForOption(s_fileDirectory); + var headerFile = context.ParseResult.GetValueForOption(s_headerFile); + var includedNames = context.ParseResult.GetValueForOption(s_includedNames); + var includeDirectories = context.ParseResult.GetValueForOption(s_includeDirectories); + var language = context.ParseResult.GetValueForOption(s_language); + var libraryPath = context.ParseResult.GetValueForOption(s_libraryPath); + var methodClassName = context.ParseResult.GetValueForOption(s_methodClassName); + var methodPrefixToStrip = context.ParseResult.GetValueForOption(s_methodPrefixToStrip); + var namespaceName = context.ParseResult.GetValueForOption(s_namespaceName); + var outputLocation = context.ParseResult.GetValueForOption(s_outputLocation); + var outputMode = context.ParseResult.GetValueForOption(s_outputMode); + var remappedNameValuePairs = context.ParseResult.GetValueForOption(s_remappedNameValuePairs); + var std = context.ParseResult.GetValueForOption(s_std); + var testOutputLocation = context.ParseResult.GetValueForOption(s_testOutputLocation); + var traversalNames = context.ParseResult.GetValueForOption(s_traversalNames); + var withAccessSpecifierNameValuePairs = context.ParseResult.GetValueForOption(s_withAccessSpecifierNameValuePairs); + var withAttributeNameValuePairs = context.ParseResult.GetValueForOption(s_withAttributeNameValuePairs); + var withCallConvNameValuePairs = context.ParseResult.GetValueForOption(s_withCallConvNameValuePairs); + var withClassNameValuePairs = context.ParseResult.GetValueForOption(s_withClassNameValuePairs); + var withGuidNameValuePairs = context.ParseResult.GetValueForOption(s_withGuidNameValuePairs); + var withLibraryPathNameValuePairs = context.ParseResult.GetValueForOption(s_withLibraryPathNameValuePairs); + var withManualImports = context.ParseResult.GetValueForOption(s_withManualImports); + var withNamespaceNameValuePairs = context.ParseResult.GetValueForOption(s_withNamespaceNameValuePairs); + var withSetLastErrors = context.ParseResult.GetValueForOption(s_withSetLastErrors); + var withSuppressGCTransitions = context.ParseResult.GetValueForOption(s_withSuppressGCTransitions); + var withTransparentStructNameValuePairs = context.ParseResult.GetValueForOption(s_withTransparentStructNameValuePairs); + var withTypeNameValuePairs = context.ParseResult.GetValueForOption(s_withTypeNameValuePairs); + var withUsingNameValuePairs = context.ParseResult.GetValueForOption(s_withUsingNameValuePairs); + + var versionResult = context.ParseResult.FindResultFor(s_versionOption); + + if (versionResult is not null) { - s_addtionalOption = GetAdditionalOption(); - s_configOption = GetConfigOption(); - s_defineMacros = GetDefineMacroOption(); - s_excludedNames = GetExcludeOption(); - s_files = GetFileOption(); - s_fileDirectory = GetFileDirectoryOption(); - s_headerFile = GetHeaderOption(); - s_includedNames = GetIncludeOption(); - s_includeDirectories = GetIncludeDirectoryOption(); - s_language = GetLanguageOption(); - s_libraryPath = GetLibraryOption(); - s_methodClassName = GetMethodClassNameOption(); - s_namespaceName = GetNamespaceOption(); - s_outputMode = GetOutputModeOption(); - s_outputLocation = GetOutputOption(); - s_methodPrefixToStrip = GetPrefixStripOption(); - s_remappedNameValuePairs = GetRemapOption(); - s_std = GetStdOption(); - s_testOutputLocation = GetTestOutputOption(); - s_traversalNames = GetTraverseOption(); - s_versionOption = GetVersionOption(); - s_withAccessSpecifierNameValuePairs = GetWithAccessSpecifierOption(); - s_withAttributeNameValuePairs = GetWithAttributeOption(); - s_withCallConvNameValuePairs = GetWithCallConvOption(); - s_withClassNameValuePairs = GetWithClassOption(); - s_withGuidNameValuePairs = GetWithGuidOption(); - s_withLibraryPathNameValuePairs = GetWithLibraryPathOption(); - s_withManualImports = GetWithManualImportOption(); - s_withNamespaceNameValuePairs = GetWithNamespaceOption(); - s_withSetLastErrors = GetWithSetLastErrorOption(); - s_withSuppressGCTransitions = GetWithSuppressGCTransitionOption(); - s_withTransparentStructNameValuePairs = GetWithTransparentStructOption(); - s_withTypeNameValuePairs = GetWithTypeOption(); - s_withUsingNameValuePairs = GetWithUsingOption(); - s_rootCommand = new RootCommand("ClangSharp P/Invoke Binding Generator") - { - s_addtionalOption, - s_configOption, - s_defineMacros, - s_excludedNames, - s_files, - s_fileDirectory, - s_headerFile, - s_includedNames, - s_includeDirectories, - s_language, - s_libraryPath, - s_methodClassName, - s_namespaceName, - s_outputMode, - s_outputLocation, - s_methodPrefixToStrip, - s_remappedNameValuePairs, - s_std, - s_testOutputLocation, - s_traversalNames, - s_versionOption, - s_withAccessSpecifierNameValuePairs, - s_withAttributeNameValuePairs, - s_withCallConvNameValuePairs, - s_withClassNameValuePairs, - s_withGuidNameValuePairs, - s_withLibraryPathNameValuePairs, - s_withManualImports, - s_withNamespaceNameValuePairs, - s_withSetLastErrors, - s_withSuppressGCTransitions, - s_withTransparentStructNameValuePairs, - s_withTypeNameValuePairs, - s_withUsingNameValuePairs - }; - s_rootCommand.SetHandler(Run); - - var parser = new CommandLineBuilder(s_rootCommand) - .UseHelp() - .UseEnvironmentVariableDirective() - .UseParseDirective() - .UseSuggestDirective() - .RegisterWithDotnetSuggest() - .UseTypoCorrections() - .UseParseErrorReporting() - .UseExceptionHandler() - .CancelOnProcessTermination() - .Build(); - return await parser.InvokeAsync(args); + context.Console.WriteLine($"{s_rootCommand.Description} version 14.0.0"); + context.Console.WriteLine($" {clang.getClangVersion()}"); + context.Console.WriteLine($" {clangsharp.getVersion()}"); + context.ExitCode = -1; + return; } -#pragma warning restore IDE1006 - public static void Run(InvocationContext context) + var errorList = new List(); + + if (!files.Any()) { - var additionalArgs = context.ParseResult.GetValueForOption(s_addtionalOption); - var configSwitches = context.ParseResult.GetValueForOption(s_configOption); - var defineMacros = context.ParseResult.GetValueForOption(s_defineMacros); - var excludedNames = context.ParseResult.GetValueForOption(s_excludedNames); - var files = context.ParseResult.GetValueForOption(s_files); - var fileDirectory = context.ParseResult.GetValueForOption(s_fileDirectory); - var headerFile = context.ParseResult.GetValueForOption(s_headerFile); - var includedNames = context.ParseResult.GetValueForOption(s_includedNames); - var includeDirectories = context.ParseResult.GetValueForOption(s_includeDirectories); - var language = context.ParseResult.GetValueForOption(s_language); - var libraryPath = context.ParseResult.GetValueForOption(s_libraryPath); - var methodClassName = context.ParseResult.GetValueForOption(s_methodClassName); - var methodPrefixToStrip = context.ParseResult.GetValueForOption(s_methodPrefixToStrip); - var namespaceName = context.ParseResult.GetValueForOption(s_namespaceName); - var outputLocation = context.ParseResult.GetValueForOption(s_outputLocation); - var outputMode = context.ParseResult.GetValueForOption(s_outputMode); - var remappedNameValuePairs = context.ParseResult.GetValueForOption(s_remappedNameValuePairs); - var std = context.ParseResult.GetValueForOption(s_std); - var testOutputLocation = context.ParseResult.GetValueForOption(s_testOutputLocation); - var traversalNames = context.ParseResult.GetValueForOption(s_traversalNames); - var withAccessSpecifierNameValuePairs = context.ParseResult.GetValueForOption(s_withAccessSpecifierNameValuePairs); - var withAttributeNameValuePairs = context.ParseResult.GetValueForOption(s_withAttributeNameValuePairs); - var withCallConvNameValuePairs = context.ParseResult.GetValueForOption(s_withCallConvNameValuePairs); - var withClassNameValuePairs = context.ParseResult.GetValueForOption(s_withClassNameValuePairs); - var withGuidNameValuePairs = context.ParseResult.GetValueForOption(s_withGuidNameValuePairs); - var withLibraryPathNameValuePairs = context.ParseResult.GetValueForOption(s_withLibraryPathNameValuePairs); - var withManualImports = context.ParseResult.GetValueForOption(s_withManualImports); - var withNamespaceNameValuePairs = context.ParseResult.GetValueForOption(s_withNamespaceNameValuePairs); - var withSetLastErrors = context.ParseResult.GetValueForOption(s_withSetLastErrors); - var withSuppressGCTransitions = context.ParseResult.GetValueForOption(s_withSuppressGCTransitions); - var withTransparentStructNameValuePairs = context.ParseResult.GetValueForOption(s_withTransparentStructNameValuePairs); - var withTypeNameValuePairs = context.ParseResult.GetValueForOption(s_withTypeNameValuePairs); - var withUsingNameValuePairs = context.ParseResult.GetValueForOption(s_withUsingNameValuePairs); - - var versionResult = context.ParseResult.FindResultFor(s_versionOption); - - if (versionResult is not null) - { - context.Console.WriteLine($"{s_rootCommand.Description} version 14.0.0"); - context.Console.WriteLine($" {clang.getClangVersion()}"); - context.Console.WriteLine($" {clangsharp.getVersion()}"); - context.ExitCode = -1; - return; - } + errorList.Add("Error: No input C/C++ files provided. Use --file or -f"); + } - var errorList = new List(); + if (string.IsNullOrWhiteSpace(namespaceName)) + { + errorList.Add("Error: No namespace provided. Use --namespace or -n"); + } - if (!files.Any()) - { - errorList.Add("Error: No input C/C++ files provided. Use --file or -f"); - } + if (string.IsNullOrWhiteSpace(outputLocation)) + { + errorList.Add("Error: No output file location provided. Use --output or -o"); + } - if (string.IsNullOrWhiteSpace(namespaceName)) - { - errorList.Add("Error: No namespace provided. Use --namespace or -n"); - } + ParseKeyValuePairs(remappedNameValuePairs, errorList, out Dictionary remappedNames); + ParseKeyValuePairs(withAccessSpecifierNameValuePairs, errorList, out Dictionary withAccessSpecifiers); + ParseKeyValuePairs(withAttributeNameValuePairs, errorList, out Dictionary> withAttributes); + ParseKeyValuePairs(withCallConvNameValuePairs, errorList, out Dictionary withCallConvs); + ParseKeyValuePairs(withClassNameValuePairs, errorList, out Dictionary withClasses); + ParseKeyValuePairs(withGuidNameValuePairs, errorList, out Dictionary withGuids); + ParseKeyValuePairs(withLibraryPathNameValuePairs, errorList, out Dictionary withLibraryPaths); + ParseKeyValuePairs(withNamespaceNameValuePairs, errorList, out Dictionary withNamespaces); + ParseKeyValuePairs(withTransparentStructNameValuePairs, errorList, out Dictionary withTransparentStructs); + ParseKeyValuePairs(withTypeNameValuePairs, errorList, out Dictionary withTypes); + ParseKeyValuePairs(withUsingNameValuePairs, errorList, out Dictionary> withUsings); + + foreach (var key in withTransparentStructs.Keys) + { + remappedNames.Add(key, key); + } - if (string.IsNullOrWhiteSpace(outputLocation)) - { - errorList.Add("Error: No output file location provided. Use --output or -o"); - } + var configOptions = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? PInvokeGeneratorConfigurationOptions.None : PInvokeGeneratorConfigurationOptions.GenerateUnixTypes; + var printConfigHelp = false; - ParseKeyValuePairs(remappedNameValuePairs, errorList, out Dictionary remappedNames); - ParseKeyValuePairs(withAccessSpecifierNameValuePairs, errorList, out Dictionary withAccessSpecifiers); - ParseKeyValuePairs(withAttributeNameValuePairs, errorList, out Dictionary> withAttributes); - ParseKeyValuePairs(withCallConvNameValuePairs, errorList, out Dictionary withCallConvs); - ParseKeyValuePairs(withClassNameValuePairs, errorList, out Dictionary withClasses); - ParseKeyValuePairs(withGuidNameValuePairs, errorList, out Dictionary withGuids); - ParseKeyValuePairs(withLibraryPathNameValuePairs, errorList, out Dictionary withLibraryPaths); - ParseKeyValuePairs(withNamespaceNameValuePairs, errorList, out Dictionary withNamespaces); - ParseKeyValuePairs(withTransparentStructNameValuePairs, errorList, out Dictionary withTransparentStructs); - ParseKeyValuePairs(withTypeNameValuePairs, errorList, out Dictionary withTypes); - ParseKeyValuePairs(withUsingNameValuePairs, errorList, out Dictionary> withUsings); - - foreach (var key in withTransparentStructs.Keys) + foreach (var configSwitch in configSwitches) + { + switch (configSwitch) { - remappedNames.Add(key, key); - } + case "?": + case "h": + case "help": + { + printConfigHelp = true; + break; + } - var configOptions = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? PInvokeGeneratorConfigurationOptions.None : PInvokeGeneratorConfigurationOptions.GenerateUnixTypes; - var printConfigHelp = false; + // Codegen Options - foreach (var configSwitch in configSwitches) - { - switch (configSwitch) + case "compatible-codegen": { - case "?": - case "h": - case "help": - { - printConfigHelp = true; - break; - } + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode; + configOptions &= ~PInvokeGeneratorConfigurationOptions.GeneratePreviewCode; + break; + } - // Codegen Options + case "latest-codegen": + { + configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode; + configOptions &= ~PInvokeGeneratorConfigurationOptions.GeneratePreviewCode; + break; + } - case "compatible-codegen": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode; - configOptions &= ~PInvokeGeneratorConfigurationOptions.GeneratePreviewCode; - break; - } + case "preview-codegen": + { + configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode; + configOptions |= PInvokeGeneratorConfigurationOptions.GeneratePreviewCode; + break; + } - case "latest-codegen": - { - configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode; - configOptions &= ~PInvokeGeneratorConfigurationOptions.GeneratePreviewCode; - break; - } + // File Options - case "preview-codegen": - { - configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode; - configOptions |= PInvokeGeneratorConfigurationOptions.GeneratePreviewCode; - break; - } + case "single-file": + { + configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles; + break; + } - // File Options + case "multi-file": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles; + break; + } - case "single-file": - { - configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles; - break; - } + // Type Options - case "multi-file": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMultipleFiles; - break; - } + case "unix-types": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateUnixTypes; + break; + } - // Type Options + case "windows-types": + { + configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateUnixTypes; + break; + } - case "unix-types": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateUnixTypes; - break; - } + // Exclusion Options - case "windows-types": - { - configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateUnixTypes; - break; - } + case "exclude-anonymous-field-helpers": + { + configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeAnonymousFieldHelpers; + break; + } - // Exclusion Options + case "exclude-com-proxies": + { + configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeComProxies; + break; + } - case "exclude-anonymous-field-helpers": - { - configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeAnonymousFieldHelpers; - break; - } + case "exclude-default-remappings": + case "no-default-remappings": + { + configOptions |= PInvokeGeneratorConfigurationOptions.NoDefaultRemappings; + break; + } - case "exclude-com-proxies": - { - configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeComProxies; - break; - } + case "exclude-empty-records": + { + configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeEmptyRecords; + break; + } - case "exclude-default-remappings": - case "no-default-remappings": - { - configOptions |= PInvokeGeneratorConfigurationOptions.NoDefaultRemappings; - break; - } + case "exclude-enum-operators": + { + configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeEnumOperators; + break; + } - case "exclude-empty-records": - { - configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeEmptyRecords; - break; - } + case "exclude-fnptr-codegen": + { + configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeFnptrCodegen; + break; + } - case "exclude-enum-operators": - { - configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeEnumOperators; - break; - } + case "exclude-funcs-with-body": + { + configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeFunctionsWithBody; + break; + } - case "exclude-fnptr-codegen": - { - configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeFnptrCodegen; - break; - } + case "exclude-nint-codegen": + { + configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeNIntCodegen; + break; + } - case "exclude-funcs-with-body": - { - configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeFunctionsWithBody; - break; - } + case "exclude-using-statics-for-enums": + case "dont-use-using-statics-for-enums": + { + configOptions |= PInvokeGeneratorConfigurationOptions.DontUseUsingStaticsForEnums; + break; + } - case "exclude-nint-codegen": - { - configOptions |= PInvokeGeneratorConfigurationOptions.ExcludeNIntCodegen; - break; - } + // VTBL Options - case "exclude-using-statics-for-enums": - case "dont-use-using-statics-for-enums": - { - configOptions |= PInvokeGeneratorConfigurationOptions.DontUseUsingStaticsForEnums; - break; - } + case "explicit-vtbls": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls; + configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateTrimmableVtbls; + break; + } - // VTBL Options + case "implicit-vtbls": + { + configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls; + configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateTrimmableVtbls; + break; + } - case "explicit-vtbls": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls; - configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateTrimmableVtbls; - break; - } + case "trimmable-vtbls": + { + configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls; + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTrimmableVtbls; + break; + } + + // Test Options - case "implicit-vtbls": + case "generate-tests-nunit": + { + if (string.IsNullOrWhiteSpace(testOutputLocation)) { - configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls; - configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateTrimmableVtbls; - break; + errorList.Add("Error: No test output file location provided. Use --test-output or -to"); } - case "trimmable-vtbls": + if (configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit)) { - configOptions &= ~PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls; - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTrimmableVtbls; - break; + errorList.Add("Cannot generate both NUnit and XUnit tests."); } + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit; + break; + } - // Test Options - - case "generate-tests-nunit": + case "generate-tests-xunit": + { + if (string.IsNullOrWhiteSpace(testOutputLocation)) { - if (string.IsNullOrWhiteSpace(testOutputLocation)) - { - errorList.Add("Error: No test output file location provided. Use --test-output or -to"); - } - - if (configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit)) - { - errorList.Add("Cannot generate both NUnit and XUnit tests."); - } - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit; - break; + errorList.Add("Error: No test output file location provided. Use --test-output or -to"); } - case "generate-tests-xunit": + if (configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit)) { - if (string.IsNullOrWhiteSpace(testOutputLocation)) - { - errorList.Add("Error: No test output file location provided. Use --test-output or -to"); - } - - if (configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit)) - { - errorList.Add("Cannot generate both NUnit and XUnit tests."); - } - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit; - break; + errorList.Add("Cannot generate both NUnit and XUnit tests."); } + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit; + break; + } - // Generation Options + // Generation Options - case "generate-aggressive-inlining": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateAggressiveInlining; - break; - } + case "generate-aggressive-inlining": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateAggressiveInlining; + break; + } - case "generate-cpp-attributes": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateCppAttributes; - break; - } + case "generate-cpp-attributes": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateCppAttributes; + break; + } - case "generate-doc-includes": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateDocIncludes; - break; - } + case "generate-doc-includes": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateDocIncludes; + break; + } - case "generate-file-scoped-namespaces": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces; - break; - } + case "generate-file-scoped-namespaces": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces; + break; + } - case "generate-guid-member": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateGuidMember; - break; - } + case "generate-guid-member": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateGuidMember; + break; + } - case "generate-helper-types": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateHelperTypes; - break; - } + case "generate-helper-types": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateHelperTypes; + break; + } - case "generate-macro-bindings": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMacroBindings; - break; - } + case "generate-macro-bindings": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMacroBindings; + break; + } - case "generate-marker-interfaces": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces; - break; - } + case "generate-marker-interfaces": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces; + break; + } - case "generate-native-inheritance-attribute": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute; - break; - } + case "generate-native-inheritance-attribute": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute; + break; + } - case "generate-setslastsystemerror-attribute": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateSetsLastSystemErrorAttribute; - break; - } + case "generate-setslastsystemerror-attribute": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateSetsLastSystemErrorAttribute; + break; + } - case "generate-template-bindings": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTemplateBindings; - break; - } + case "generate-template-bindings": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateTemplateBindings; + break; + } - case "generate-unmanaged-constants": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateUnmanagedConstants; - break; - } + case "generate-unmanaged-constants": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateUnmanagedConstants; + break; + } - case "generate-vtbl-index-attribute": - { - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute; - break; - } + case "generate-vtbl-index-attribute": + { + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute; + break; + } - // Logging Options + // Logging Options - case "log-exclusions": - { - configOptions |= PInvokeGeneratorConfigurationOptions.LogExclusions; - break; - } + case "log-exclusions": + { + configOptions |= PInvokeGeneratorConfigurationOptions.LogExclusions; + break; + } - case "log-potential-typedef-remappings": - { - configOptions |= PInvokeGeneratorConfigurationOptions.LogPotentialTypedefRemappings; - break; - } + case "log-potential-typedef-remappings": + { + configOptions |= PInvokeGeneratorConfigurationOptions.LogPotentialTypedefRemappings; + break; + } - case "log-visited-files": - { - configOptions |= PInvokeGeneratorConfigurationOptions.LogVisitedFiles; - break; - } + case "log-visited-files": + { + configOptions |= PInvokeGeneratorConfigurationOptions.LogVisitedFiles; + break; + } - // Legacy Options + // Legacy Options - case "default-remappings": - { - configOptions &= ~PInvokeGeneratorConfigurationOptions.NoDefaultRemappings; - break; - } + case "default-remappings": + { + configOptions &= ~PInvokeGeneratorConfigurationOptions.NoDefaultRemappings; + break; + } - default: - { - errorList.Add($"Error: Unrecognized config switch: {configSwitch}."); - break; - } + default: + { + errorList.Add($"Error: Unrecognized config switch: {configSwitch}."); + break; } } + } - if (!string.IsNullOrWhiteSpace(testOutputLocation) && !configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit) && !configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit)) - { - errorList.Add("Error: No test format provided. Use --config generate-tests-nunit or --config generate-tests-xunit"); - } + if (!string.IsNullOrWhiteSpace(testOutputLocation) && !configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsNUnit) && !configOptions.HasFlag(PInvokeGeneratorConfigurationOptions.GenerateTestsXUnit)) + { + errorList.Add("Error: No test format provided. Use --config generate-tests-nunit or --config generate-tests-xunit"); + } - if (printConfigHelp) - { - var helpBuilder = new CustomHelpBuilder(context.Console, context.LocalizationResources); + if (printConfigHelp) + { + var helpBuilder = new CustomHelpBuilder(context.Console, context.LocalizationResources); - helpBuilder.Write(s_configOption); - helpBuilder.WriteLine(); - helpBuilder.Write(s_configOptions); + helpBuilder.Write(s_configOption); + helpBuilder.WriteLine(); + helpBuilder.Write(s_configOptions); - context.ExitCode = -1; - return; - } + context.ExitCode = -1; + return; + } - if (errorList.Any()) - { - context.Console.Error.Write($"Error in args for '{files.FirstOrDefault()}'"); - context.Console.Error.Write(Environment.NewLine); + if (errorList.Any()) + { + context.Console.Error.Write($"Error in args for '{files.FirstOrDefault()}'"); + context.Console.Error.Write(Environment.NewLine); - foreach (var error in errorList) - { - context.Console.Error.Write(error); - context.Console.Error.Write(Environment.NewLine); - } + foreach (var error in errorList) + { + context.Console.Error.Write(error); context.Console.Error.Write(Environment.NewLine); - - new CustomHelpBuilder(context.Console, context.LocalizationResources) - .Write(s_rootCommand, context.Console.Out.CreateTextWriter()); - context.ExitCode = -1; - return; } + context.Console.Error.Write(Environment.NewLine); - string[] clangCommandLineArgs; + new CustomHelpBuilder(context.Console, context.LocalizationResources) + .Write(s_rootCommand, context.Console.Out.CreateTextWriter()); + context.ExitCode = -1; + return; + } - if (string.IsNullOrWhiteSpace(std)) - { - clangCommandLineArgs = new string[] { - $"--language={language}", // Treat subsequent input files as having type - "-Wno-pragma-once-outside-header" // We are processing files which may be header files - }; - } - else - { - clangCommandLineArgs = new string[] { - $"--language={language}", // Treat subsequent input files as having type - $"--std={std}", // Language standard to compile for - "-Wno-pragma-once-outside-header" // We are processing files which may be header files - }; - } + string[] clangCommandLineArgs; - clangCommandLineArgs = clangCommandLineArgs.Concat(includeDirectories.Select(x => "--include-directory=" + x)).ToArray(); - clangCommandLineArgs = clangCommandLineArgs.Concat(defineMacros.Select(x => "--define-macro=" + x)).ToArray(); - clangCommandLineArgs = clangCommandLineArgs.Concat(additionalArgs).ToArray(); - - var translationFlags = CXTranslationUnit_Flags.CXTranslationUnit_None; - - translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_IncludeAttributedTypes; // Include attributed types in CXType - translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_VisitImplicitAttributes; // Implicit attributes should be visited - - var config = new PInvokeGeneratorConfiguration(namespaceName, outputLocation, headerFile, outputMode, configOptions) { - DefaultClass = methodClassName, - ExcludedNames = excludedNames, - IncludedNames = includedNames, - LibraryPath = libraryPath, - MethodPrefixToStrip = methodPrefixToStrip, - RemappedNames = remappedNames, - TraversalNames = traversalNames, - TestOutputLocation = testOutputLocation, - WithAccessSpecifiers = withAccessSpecifiers, - WithAttributes = withAttributes, - WithCallConvs = withCallConvs, - WithClasses = withClasses, - WithGuids = withGuids, - WithLibraryPaths = withLibraryPaths, - WithManualImports = withManualImports, - WithNamespaces = withNamespaces, - WithSetLastErrors = withSetLastErrors, - WithSuppressGCTransitions = withSuppressGCTransitions, - WithTransparentStructs = withTransparentStructs, - WithTypes = withTypes, - WithUsings = withUsings, + if (string.IsNullOrWhiteSpace(std)) + { + clangCommandLineArgs = new string[] { + $"--language={language}", // Treat subsequent input files as having type + "-Wno-pragma-once-outside-header" // We are processing files which may be header files + }; + } + else + { + clangCommandLineArgs = new string[] { + $"--language={language}", // Treat subsequent input files as having type + $"--std={std}", // Language standard to compile for + "-Wno-pragma-once-outside-header" // We are processing files which may be header files }; + } - if (config.GenerateMacroBindings) - { - translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_DetailedPreprocessingRecord; - } + clangCommandLineArgs = clangCommandLineArgs.Concat(includeDirectories.Select(x => "--include-directory=" + x)).ToArray(); + clangCommandLineArgs = clangCommandLineArgs.Concat(defineMacros.Select(x => "--define-macro=" + x)).ToArray(); + clangCommandLineArgs = clangCommandLineArgs.Concat(additionalArgs).ToArray(); + + var translationFlags = CXTranslationUnit_Flags.CXTranslationUnit_None; + + translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_IncludeAttributedTypes; // Include attributed types in CXType + translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_VisitImplicitAttributes; // Implicit attributes should be visited + + var config = new PInvokeGeneratorConfiguration(namespaceName, outputLocation, headerFile, outputMode, configOptions) { + DefaultClass = methodClassName, + ExcludedNames = excludedNames, + IncludedNames = includedNames, + LibraryPath = libraryPath, + MethodPrefixToStrip = methodPrefixToStrip, + RemappedNames = remappedNames, + TraversalNames = traversalNames, + TestOutputLocation = testOutputLocation, + WithAccessSpecifiers = withAccessSpecifiers, + WithAttributes = withAttributes, + WithCallConvs = withCallConvs, + WithClasses = withClasses, + WithGuids = withGuids, + WithLibraryPaths = withLibraryPaths, + WithManualImports = withManualImports, + WithNamespaces = withNamespaces, + WithSetLastErrors = withSetLastErrors, + WithSuppressGCTransitions = withSuppressGCTransitions, + WithTransparentStructs = withTransparentStructs, + WithTypes = withTypes, + WithUsings = withUsings, + }; - var exitCode = 0; + if (config.GenerateMacroBindings) + { + translationFlags |= CXTranslationUnit_Flags.CXTranslationUnit_DetailedPreprocessingRecord; + } - using (var pinvokeGenerator = new PInvokeGenerator(config)) + var exitCode = 0; + + using (var pinvokeGenerator = new PInvokeGenerator(config)) + { + foreach (var file in files) { - foreach (var file in files) - { - var filePath = Path.Combine(fileDirectory, file); + var filePath = Path.Combine(fileDirectory, file); - var translationUnitError = CXTranslationUnit.TryParse(pinvokeGenerator.IndexHandle, filePath, clangCommandLineArgs, Array.Empty(), translationFlags, out var handle); - var skipProcessing = false; + var translationUnitError = CXTranslationUnit.TryParse(pinvokeGenerator.IndexHandle, filePath, clangCommandLineArgs, Array.Empty(), translationFlags, out var handle); + var skipProcessing = false; - if (translationUnitError != CXErrorCode.CXError_Success) - { - context.Console.WriteLine($"Error: Parsing failed for '{filePath}' due to '{translationUnitError}'."); - skipProcessing = true; - } - else if (handle.NumDiagnostics != 0) - { - context.Console.WriteLine($"Diagnostics for '{filePath}':"); + if (translationUnitError != CXErrorCode.CXError_Success) + { + context.Console.WriteLine($"Error: Parsing failed for '{filePath}' due to '{translationUnitError}'."); + skipProcessing = true; + } + else if (handle.NumDiagnostics != 0) + { + context.Console.WriteLine($"Diagnostics for '{filePath}':"); - for (uint i = 0; i < handle.NumDiagnostics; ++i) - { - using var diagnostic = handle.GetDiagnostic(i); + for (uint i = 0; i < handle.NumDiagnostics; ++i) + { + using var diagnostic = handle.GetDiagnostic(i); - context.Console.Write(" "); - context.Console.WriteLine(diagnostic.Format(CXDiagnostic.DefaultDisplayOptions).ToString()); + context.Console.Write(" "); + context.Console.WriteLine(diagnostic.Format(CXDiagnostic.DefaultDisplayOptions).ToString()); - skipProcessing |= diagnostic.Severity == CXDiagnosticSeverity.CXDiagnostic_Error; - skipProcessing |= diagnostic.Severity == CXDiagnosticSeverity.CXDiagnostic_Fatal; - } + skipProcessing |= diagnostic.Severity == CXDiagnosticSeverity.CXDiagnostic_Error; + skipProcessing |= diagnostic.Severity == CXDiagnosticSeverity.CXDiagnostic_Fatal; } + } - if (skipProcessing) - { - context.Console.WriteLine($"Skipping '{filePath}' due to one or more errors listed above."); - context.Console.WriteLine(""); + if (skipProcessing) + { + context.Console.WriteLine($"Skipping '{filePath}' due to one or more errors listed above."); + context.Console.WriteLine(""); - exitCode = -1; - continue; - } + exitCode = -1; + continue; + } - try - { - using var translationUnit = TranslationUnit.GetOrCreate(handle); - context.Console.WriteLine($"Processing '{filePath}'"); + try + { + using var translationUnit = TranslationUnit.GetOrCreate(handle); + context.Console.WriteLine($"Processing '{filePath}'"); - pinvokeGenerator.GenerateBindings(translationUnit, filePath, clangCommandLineArgs, translationFlags); - } - catch (Exception e) - { - context.Console.WriteLine(e.ToString()); - } + pinvokeGenerator.GenerateBindings(translationUnit, filePath, clangCommandLineArgs, translationFlags); + } + catch (Exception e) + { + context.Console.WriteLine(e.ToString()); } + } + + if (pinvokeGenerator.Diagnostics.Count != 0) + { + context.Console.WriteLine($"Diagnostics for binding generation of {pinvokeGenerator.FilePath}:"); - if (pinvokeGenerator.Diagnostics.Count != 0) + foreach (var diagnostic in pinvokeGenerator.Diagnostics) { - context.Console.WriteLine($"Diagnostics for binding generation of {pinvokeGenerator.FilePath}:"); + context.Console.Write(" "); + context.Console.WriteLine(diagnostic.ToString()); - foreach (var diagnostic in pinvokeGenerator.Diagnostics) + if (diagnostic.Level == DiagnosticLevel.Warning) { - context.Console.Write(" "); - context.Console.WriteLine(diagnostic.ToString()); - - if (diagnostic.Level == DiagnosticLevel.Warning) + if (exitCode >= 0) { - if (exitCode >= 0) - { - exitCode++; - } + exitCode++; } - else if (diagnostic.Level == DiagnosticLevel.Error) + } + else if (diagnostic.Level == DiagnosticLevel.Error) + { + if (exitCode >= 0) { - if (exitCode >= 0) - { - exitCode = -1; - } - else - { - exitCode--; - } + exitCode = -1; } - } + else + { + exitCode--; + } + } } } - - context.ExitCode = exitCode; } - private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary result) - { - result = new Dictionary(); + context.ExitCode = exitCode; + } - foreach (var keyValuePair in keyValuePairs) - { - var parts = keyValuePair.Split('='); + private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary result) + { + result = new Dictionary(); - if (parts.Length != 2) - { - errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value'"); - continue; - } + foreach (var keyValuePair in keyValuePairs) + { + var parts = keyValuePair.Split('='); - var key = parts[0].TrimEnd(); + if (parts.Length != 2) + { + errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value'"); + continue; + } - if (result.ContainsKey(key)) - { - errorList.Add($"Error: A key with the given name already exists: {key}. Existing: {result[key]}"); - continue; - } + var key = parts[0].TrimEnd(); - result.Add(key, parts[1].TrimStart()); + if (result.ContainsKey(key)) + { + errorList.Add($"Error: A key with the given name already exists: {key}. Existing: {result[key]}"); + continue; } + + result.Add(key, parts[1].TrimStart()); } + } - private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary result) + private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary result) + { + result = new Dictionary(); + + foreach (var keyValuePair in keyValuePairs) { - result = new Dictionary(); + var parts = keyValuePair.Split('='); - foreach (var keyValuePair in keyValuePairs) + if (parts.Length != 2) { - var parts = keyValuePair.Split('='); - - if (parts.Length != 2) - { - errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value'"); - continue; - } - - var key = parts[0].TrimEnd(); + errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value'"); + continue; + } - if (result.ContainsKey(key)) - { - errorList.Add($"Error: A key with the given name already exists: {key}. Existing: {result[key]}"); - continue; - } + var key = parts[0].TrimEnd(); - result.Add(key, PInvokeGeneratorConfiguration.ConvertStringToAccessSpecifier(parts[1].TrimStart())); + if (result.ContainsKey(key)) + { + errorList.Add($"Error: A key with the given name already exists: {key}. Existing: {result[key]}"); + continue; } + + result.Add(key, PInvokeGeneratorConfiguration.ConvertStringToAccessSpecifier(parts[1].TrimStart())); } + } - private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary result) + private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary result) + { + result = new Dictionary(); + + foreach (var keyValuePair in keyValuePairs) { - result = new Dictionary(); + var parts = keyValuePair.Split('='); - foreach (var keyValuePair in keyValuePairs) + if (parts.Length != 2) { - var parts = keyValuePair.Split('='); - - if (parts.Length != 2) - { - errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value'"); - continue; - } + errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value'"); + continue; + } - var key = parts[0].TrimEnd(); + var key = parts[0].TrimEnd(); - if (result.ContainsKey(key)) - { - errorList.Add($"Error: A key with the given name already exists: {key}. Existing: {result[key]}"); - continue; - } - - if (!Guid.TryParse(parts[1].TrimStart(), out var guid)) - { - errorList.Add($"Error: Failed to parse guid: {parts[1]}"); - continue; - } + if (result.ContainsKey(key)) + { + errorList.Add($"Error: A key with the given name already exists: {key}. Existing: {result[key]}"); + continue; + } - result.Add(key, guid); + if (!Guid.TryParse(parts[1].TrimStart(), out var guid)) + { + errorList.Add($"Error: Failed to parse guid: {parts[1]}"); + continue; } + + result.Add(key, guid); } + } + + private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary result) + { + result = new Dictionary(); - private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary result) + foreach (var keyValuePair in keyValuePairs) { - result = new Dictionary(); + var parts = keyValuePair.Split('='); - foreach (var keyValuePair in keyValuePairs) + if (parts.Length != 2) { - var parts = keyValuePair.Split('='); - - if (parts.Length != 2) - { - errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value' or 'name=value;kind'"); - continue; - } + errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value' or 'name=value;kind'"); + continue; + } - var key = parts[0].TrimEnd(); + var key = parts[0].TrimEnd(); - if (result.ContainsKey(key)) - { - errorList.Add($"Error: A key with the given name already exists: {key}. Existing: {result[key]}"); - continue; - } + if (result.ContainsKey(key)) + { + errorList.Add($"Error: A key with the given name already exists: {key}. Existing: {result[key]}"); + continue; + } - parts = parts[1].Split(';'); + parts = parts[1].Split(';'); - if (parts.Length == 1) - { - result.Add(key, (parts[0], PInvokeGeneratorTransparentStructKind.Unknown)); - } - else if ((parts.Length == 2) && Enum.TryParse(parts[1], out var transparentStructKind)) - { - result.Add(key, (parts[0], transparentStructKind)); - } - else - { - errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value' or 'name=value;kind'"); - continue; - } + if (parts.Length == 1) + { + result.Add(key, (parts[0], PInvokeGeneratorTransparentStructKind.Unknown)); + } + else if ((parts.Length == 2) && Enum.TryParse(parts[1], out var transparentStructKind)) + { + result.Add(key, (parts[0], transparentStructKind)); + } + else + { + errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value' or 'name=value;kind'"); + continue; } } + } + + private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary> result) + { + result = new Dictionary>(); - private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List errorList, out Dictionary> result) + foreach (var keyValuePair in keyValuePairs) { - result = new Dictionary>(); + var parts = keyValuePair.Split('='); - foreach (var keyValuePair in keyValuePairs) + if (parts.Length != 2) { - var parts = keyValuePair.Split('='); - - if (parts.Length != 2) - { - errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value'"); - continue; - } - - var key = parts[0].TrimEnd(); + errorList.Add($"Error: Invalid key/value pair argument: {keyValuePair}. Expected 'name=value'"); + continue; + } - if (!result.ContainsKey(key)) - { - result.Add(key, new List()); - } + var key = parts[0].TrimEnd(); - var list = (List)result[key]; - list.Add(parts[1].TrimStart()); + if (!result.ContainsKey(key)) + { + result.Add(key, new List()); } - } - private static Option GetAdditionalOption() - { - return new Option( - aliases: new string[] { "--additional", "-a" }, - description: "An argument to pass to Clang when parsing the input files.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; + var list = (List)result[key]; + list.Add(parts[1].TrimStart()); } + } - private static Option GetConfigOption() - { - return s_configOption = new Option( - aliases: new string[] { "--config", "-c" }, - description: "A configuration option that controls how the bindings are generated. Specify 'help' to see the available options.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetAdditionalOption() + { + return new Option( + aliases: new string[] { "--additional", "-a" }, + description: "An argument to pass to Clang when parsing the input files.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetDefineMacroOption() - { - return new Option( - aliases: new string[] { "--define-macro", "-D" }, - description: "Define to (or 1 if omitted).", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetConfigOption() + { + return s_configOption = new Option( + aliases: new string[] { "--config", "-c" }, + description: "A configuration option that controls how the bindings are generated. Specify 'help' to see the available options.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetExcludeOption() - { - return new Option( - aliases: new string[] { "--exclude", "-e" }, - description: "A declaration name to exclude from binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetDefineMacroOption() + { + return new Option( + aliases: new string[] { "--define-macro", "-D" }, + description: "Define to (or 1 if omitted).", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetFileOption() - { - return new Option( - aliases: new string[] { "--file", "-f" }, - description: "A file to parse and generate bindings for.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetExcludeOption() + { + return new Option( + aliases: new string[] { "--exclude", "-e" }, + description: "A declaration name to exclude from binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetFileDirectoryOption() - { - return new Option( - aliases: new string[] { "--file-directory", "-F" }, - description: "The base path for files to parse.", - getDefaultValue: () => string.Empty - ); - } + private static Option GetFileOption() + { + return new Option( + aliases: new string[] { "--file", "-f" }, + description: "A file to parse and generate bindings for.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetHeaderOption() - { - return new Option( - aliases: new string[] { "--headerFile", "-h" }, - description: "A file which contains the header to prefix every generated file with.", - getDefaultValue: () => string.Empty - ); - } + private static Option GetFileDirectoryOption() + { + return new Option( + aliases: new string[] { "--file-directory", "-F" }, + description: "The base path for files to parse.", + getDefaultValue: () => string.Empty + ); + } - private static Option GetIncludeOption() - { - return new Option( - aliases: new string[] { "--include", "-i" }, - description: "A declaration name to include in binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetHeaderOption() + { + return new Option( + aliases: new string[] { "--headerFile", "-h" }, + description: "A file which contains the header to prefix every generated file with.", + getDefaultValue: () => string.Empty + ); + } - private static Option GetIncludeDirectoryOption() - { - return new Option( - aliases: new string[] { "--include-directory", "-I" }, - description: "Add directory to include search path.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetIncludeOption() + { + return new Option( + aliases: new string[] { "--include", "-i" }, + description: "A declaration name to include in binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetLanguageOption() - { - return new Option( - aliases: new string[] { "--language", "-x" }, - description: "Treat subsequent input files as having type .", - getDefaultValue: () => "c++" - ); - } + private static Option GetIncludeDirectoryOption() + { + return new Option( + aliases: new string[] { "--include-directory", "-I" }, + description: "Add directory to include search path.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetLibraryOption() - { - return new Option( - aliases: new string[] { "--libraryPath", "-l" }, - description: "The string to use in the DllImport attribute used when generating bindings.", - getDefaultValue: () => string.Empty - ); - } + private static Option GetLanguageOption() + { + return new Option( + aliases: new string[] { "--language", "-x" }, + description: "Treat subsequent input files as having type .", + getDefaultValue: () => "c++" + ); + } - private static Option GetMethodClassNameOption() - { - return new Option( - aliases: new string[] { "--methodClassName", "-m" }, - description: "The name of the static class that will contain the generated method bindings.", - getDefaultValue: () => "Methods" - ); - } + private static Option GetLibraryOption() + { + return new Option( + aliases: new string[] { "--libraryPath", "-l" }, + description: "The string to use in the DllImport attribute used when generating bindings.", + getDefaultValue: () => string.Empty + ); + } - private static Option GetNamespaceOption() - { - return new Option( - aliases: new string[] { "--namespace", "-n" }, - description: "The namespace in which to place the generated bindings.", - getDefaultValue: () => string.Empty - ); - } + private static Option GetMethodClassNameOption() + { + return new Option( + aliases: new string[] { "--methodClassName", "-m" }, + description: "The name of the static class that will contain the generated method bindings.", + getDefaultValue: () => "Methods" + ); + } - private static Option GetOutputModeOption() - { - return new Option( - aliases: new string[] { "--output-mode", "-om" }, - description: "The mode describing how the information collected from the headers are presented in the resultant bindings.", - getDefaultValue: () => PInvokeGeneratorOutputMode.CSharp - ); - } + private static Option GetNamespaceOption() + { + return new Option( + aliases: new string[] { "--namespace", "-n" }, + description: "The namespace in which to place the generated bindings.", + getDefaultValue: () => string.Empty + ); + } - private static Option GetOutputOption() - { - return new Option( - aliases: new string[] { "--output", "-o" }, - description: "The output location to write the generated bindings to.", - getDefaultValue: () => string.Empty - ); - } + private static Option GetOutputModeOption() + { + return new Option( + aliases: new string[] { "--output-mode", "-om" }, + description: "The mode describing how the information collected from the headers are presented in the resultant bindings.", + getDefaultValue: () => PInvokeGeneratorOutputMode.CSharp + ); + } - private static Option GetPrefixStripOption() - { - return new Option( - aliases: new string[] { "--prefixStrip", "-p" }, - description: "The prefix to strip from the generated method bindings.", - getDefaultValue: () => string.Empty - ); - } + private static Option GetOutputOption() + { + return new Option( + aliases: new string[] { "--output", "-o" }, + description: "The output location to write the generated bindings to.", + getDefaultValue: () => string.Empty + ); + } - private static Option GetRemapOption() - { - return new Option( - aliases: new string[] { "--remap", "-r" }, - description: "A declaration name to be remapped to another name during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetPrefixStripOption() + { + return new Option( + aliases: new string[] { "--prefixStrip", "-p" }, + description: "The prefix to strip from the generated method bindings.", + getDefaultValue: () => string.Empty + ); + } - private static Option GetStdOption() - { - return new Option( - aliases: new string[] { "--std", "-std" }, - description: "Language standard to compile for.", - getDefaultValue: () => "" - ); - } + private static Option GetRemapOption() + { + return new Option( + aliases: new string[] { "--remap", "-r" }, + description: "A declaration name to be remapped to another name during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetTestOutputOption() - { - return new Option( - aliases: new string[] { "--test-output", "-to" }, - description: "The output location to write the generated tests to.", - getDefaultValue: () => string.Empty - ); - } + private static Option GetStdOption() + { + return new Option( + aliases: new string[] { "--std", "-std" }, + description: "Language standard to compile for.", + getDefaultValue: () => "" + ); + } - private static Option GetVersionOption() - { - return new Option( - aliases: new string[] { "--version", "-v" }, - description: "Prints the current version information for the tool and its native dependencies." - ) { - Arity = ArgumentArity.Zero - }; - } + private static Option GetTestOutputOption() + { + return new Option( + aliases: new string[] { "--test-output", "-to" }, + description: "The output location to write the generated tests to.", + getDefaultValue: () => string.Empty + ); + } - private static Option GetTraverseOption() - { - return new Option( - aliases: new string[] { "--traverse", "-t" }, - description: "A file name included either directly or indirectly by -f that should be traversed during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetVersionOption() + { + return new Option( + aliases: new string[] { "--version", "-v" }, + description: "Prints the current version information for the tool and its native dependencies." + ) { + Arity = ArgumentArity.Zero + }; + } - private static Option GetWithAccessSpecifierOption() - { - return new Option( - aliases: new string[] { "--with-access-specifier", "-was" }, - description: "An access specifier to be used with the given qualified or remapped declaration name during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetTraverseOption() + { + return new Option( + aliases: new string[] { "--traverse", "-t" }, + description: "A file name included either directly or indirectly by -f that should be traversed during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithAttributeOption() - { - return new Option( - aliases: new string[] { "--with-attribute", "-wa" }, - description: "An attribute to be added to the given remapped declaration name during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithAccessSpecifierOption() + { + return new Option( + aliases: new string[] { "--with-access-specifier", "-was" }, + description: "An access specifier to be used with the given qualified or remapped declaration name during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithCallConvOption() - { - return new Option( - aliases: new string[] { "--with-callconv", "-wcc" }, - description: "A calling convention to be used for the given declaration during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithAttributeOption() + { + return new Option( + aliases: new string[] { "--with-attribute", "-wa" }, + description: "An attribute to be added to the given remapped declaration name during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithClassOption() - { - return new Option( - aliases: new string[] { "--with-class", "-wc" }, - description: "A class to be used for the given remapped constant or function declaration name during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithCallConvOption() + { + return new Option( + aliases: new string[] { "--with-callconv", "-wcc" }, + description: "A calling convention to be used for the given declaration during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithGuidOption() - { - return new Option( - aliases: new string[] { "--with-guid", "-wg" }, - description: "A GUID to be used for the given declaration during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithClassOption() + { + return new Option( + aliases: new string[] { "--with-class", "-wc" }, + description: "A class to be used for the given remapped constant or function declaration name during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithLibraryPathOption() - { - return new Option( - aliases: new string[] { "--with-librarypath", "-wlb" }, - description: "A library path to be used for the given declaration during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithGuidOption() + { + return new Option( + aliases: new string[] { "--with-guid", "-wg" }, + description: "A GUID to be used for the given declaration during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithManualImportOption() - { - return new Option( - aliases: new string[] { "--with-manual-import", "-wmi" }, - description: "A remapped function name to be treated as a manual import during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithLibraryPathOption() + { + return new Option( + aliases: new string[] { "--with-librarypath", "-wlb" }, + description: "A library path to be used for the given declaration during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithNamespaceOption() - { - return new Option( - aliases: new string[] { "--with-namespace", "-wn" }, - description: "A namespace to be used for the given remapped declaration name during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithManualImportOption() + { + return new Option( + aliases: new string[] { "--with-manual-import", "-wmi" }, + description: "A remapped function name to be treated as a manual import during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithSetLastErrorOption() - { - return new Option( - aliases: new string[] { "--with-setlasterror", "-wsle" }, - description: "Add the SetLastError=true modifier or SetsSystemLastError attribute to a given DllImport or UnmanagedFunctionPointer.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithNamespaceOption() + { + return new Option( + aliases: new string[] { "--with-namespace", "-wn" }, + description: "A namespace to be used for the given remapped declaration name during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithSuppressGCTransitionOption() - { - return new Option( - aliases: new string[] { "--with-suppressgctransition", "-wsgct" }, - description: "Add the SuppressGCTransition calling convention to a given DllImport or UnmanagedFunctionPointer.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithSetLastErrorOption() + { + return new Option( + aliases: new string[] { "--with-setlasterror", "-wsle" }, + description: "Add the SetLastError=true modifier or SetsSystemLastError attribute to a given DllImport or UnmanagedFunctionPointer.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithTransparentStructOption() - { - return new Option( - aliases: new string[] { "--with-transparent-struct", "-wts" }, - description: "A remapped type name to be treated as a transparent wrapper during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithSuppressGCTransitionOption() + { + return new Option( + aliases: new string[] { "--with-suppressgctransition", "-wsgct" }, + description: "Add the SuppressGCTransition calling convention to a given DllImport or UnmanagedFunctionPointer.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithTypeOption() - { - return new Option( - aliases: new string[] { "--with-type", "-wt" }, - description: "A type to be used for the given enum declaration during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithTransparentStructOption() + { + return new Option( + aliases: new string[] { "--with-transparent-struct", "-wts" }, + description: "A remapped type name to be treated as a transparent wrapper during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } - private static Option GetWithUsingOption() - { - return new Option( - aliases: new string[] { "--with-using", "-wu" }, - description: "A using directive to be included for the given remapped declaration name during binding generation.", - getDefaultValue: Array.Empty - ) { - AllowMultipleArgumentsPerToken = true - }; - } + private static Option GetWithTypeOption() + { + return new Option( + aliases: new string[] { "--with-type", "-wt" }, + description: "A type to be used for the given enum declaration during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; + } + + private static Option GetWithUsingOption() + { + return new Option( + aliases: new string[] { "--with-using", "-wu" }, + description: "A using directive to be included for the given remapped declaration name during binding generation.", + getDefaultValue: Array.Empty + ) { + AllowMultipleArgumentsPerToken = true + }; } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs index 48849f0c..9b4a4dfc 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs @@ -3,68 +3,68 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class CXXMethodDeclarationTest : PInvokeGeneratorTest { - public abstract class CXXMethodDeclarationTest : PInvokeGeneratorTest - { - [Test] - public Task ConstructorTest() => ConstructorTestImpl(); + [Test] + public Task ConstructorTest() => ConstructorTestImpl(); - [Test] - public Task ConstructorWithInitializeTest() => ConstructorWithInitializeTestImpl(); + [Test] + public Task ConstructorWithInitializeTest() => ConstructorWithInitializeTestImpl(); - [Test] - public Task ConversionTest() => ConversionTestImpl(); + [Test] + public Task ConversionTest() => ConversionTestImpl(); - [Test] - public Task DestructorTest() => DestructorTestImpl(); + [Test] + public Task DestructorTest() => DestructorTestImpl(); - [Test] - public Task InstanceTest() => InstanceTestImpl(); + [Test] + public Task InstanceTest() => InstanceTestImpl(); - [Test] - public Task MemberCallTest() => MemberCallTestImpl(); + [Test] + public Task MemberCallTest() => MemberCallTestImpl(); - [Test] - public Task MemberTest() => MemberTestImpl(); + [Test] + public Task MemberTest() => MemberTestImpl(); - [Test] - public Task NewKeywordTest() => NewKeywordTestImpl(); + [Test] + public Task NewKeywordTest() => NewKeywordTestImpl(); - [Test] - public Task NewKeywordVirtualTest() => NewKeywordVirtualTestImpl(); + [Test] + public Task NewKeywordVirtualTest() => NewKeywordVirtualTestImpl(); - [Test] - public Task NewKeywordVirtualWithExplicitVtblTest() => NewKeywordVirtualWithExplicitVtblTestImpl(); + [Test] + public Task NewKeywordVirtualWithExplicitVtblTest() => NewKeywordVirtualWithExplicitVtblTestImpl(); - [Test] - public Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest() => NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl(); + [Test] + public Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest() => NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl(); - [Test] - public Task OperatorTest() => OperatorTestImpl(); + [Test] + public Task OperatorTest() => OperatorTestImpl(); - [Test] - public Task OperatorCallTest() => OperatorCallTestImpl(); + [Test] + public Task OperatorCallTest() => OperatorCallTestImpl(); - [Test] - public Task StaticTest() => StaticTestImpl(); + [Test] + public Task StaticTest() => StaticTestImpl(); - [Test] - public Task ThisTest() => ThisTestImpl(); + [Test] + public Task ThisTest() => ThisTestImpl(); - [Test] - public Task UnsafeDoesNotImpactDllImportTest() => UnsafeDoesNotImpactDllImportTestImpl(); + [Test] + public Task UnsafeDoesNotImpactDllImportTest() => UnsafeDoesNotImpactDllImportTestImpl(); - [Test] - public Task VirtualTest() => VirtualTestImpl(); + [Test] + public Task VirtualTest() => VirtualTestImpl(); - [Test] - public Task VirtualWithVtblIndexAttributeTest() => VirtualWithVtblIndexAttributeTestImpl(); + [Test] + public Task VirtualWithVtblIndexAttributeTest() => VirtualWithVtblIndexAttributeTestImpl(); - [Test] - public virtual Task MacrosExpansionTest() - { - var inputContents = @"typedef struct + [Test] + public virtual Task MacrosExpansionTest() + { + var inputContents = @"typedef struct { unsigned char *buf; int size; @@ -77,7 +77,7 @@ int buf_close(void *pcontext) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct context_t { @@ -98,45 +98,44 @@ public static int buf_close(void* pcontext) } "; - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateBindingsAsync(inputContents, expectedOutputContents); + } - protected abstract Task ConstructorTestImpl(); + protected abstract Task ConstructorTestImpl(); - protected abstract Task ConstructorWithInitializeTestImpl(); + protected abstract Task ConstructorWithInitializeTestImpl(); - protected abstract Task ConversionTestImpl(); + protected abstract Task ConversionTestImpl(); - protected abstract Task DestructorTestImpl(); + protected abstract Task DestructorTestImpl(); - protected abstract Task InstanceTestImpl(); + protected abstract Task InstanceTestImpl(); - protected abstract Task MemberCallTestImpl(); + protected abstract Task MemberCallTestImpl(); - protected abstract Task MemberTestImpl(); + protected abstract Task MemberTestImpl(); - protected abstract Task NewKeywordTestImpl(); + protected abstract Task NewKeywordTestImpl(); - protected abstract Task NewKeywordVirtualTestImpl(); + protected abstract Task NewKeywordVirtualTestImpl(); - protected abstract Task NewKeywordVirtualWithExplicitVtblTestImpl(); + protected abstract Task NewKeywordVirtualWithExplicitVtblTestImpl(); - protected abstract Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl(); + protected abstract Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl(); - protected abstract Task OperatorTestImpl(); + protected abstract Task OperatorTestImpl(); - protected abstract Task OperatorCallTestImpl(); + protected abstract Task OperatorCallTestImpl(); - protected abstract Task StaticTestImpl(); + protected abstract Task StaticTestImpl(); - protected abstract Task ThisTestImpl(); + protected abstract Task ThisTestImpl(); - protected abstract Task UnsafeDoesNotImpactDllImportTestImpl(); + protected abstract Task UnsafeDoesNotImpactDllImportTestImpl(); - protected abstract Task VirtualTestImpl(); + protected abstract Task VirtualTestImpl(); - protected abstract Task VirtualWithVtblIndexAttributeTestImpl(); + protected abstract Task VirtualWithVtblIndexAttributeTestImpl(); - protected abstract Task ValidateBindingsAsync(string inputContents, string expectedOutputContents); - } + protected abstract Task ValidateBindingsAsync(string inputContents, string expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationXmlTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationXmlTest.cs index 1629a16d..6c828d97 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationXmlTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationXmlTest.cs @@ -3,14 +3,14 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class CXXMethodDeclarationXmlTest: CXXMethodDeclarationTest { - public abstract class CXXMethodDeclarationXmlTest: CXXMethodDeclarationTest + [Test] + public override Task MacrosExpansionTest() { - [Test] - public override Task MacrosExpansionTest() - { - var inputContents = @"typedef struct + var inputContents = @"typedef struct { unsigned char *buf; int size; @@ -23,7 +23,7 @@ int buf_close(void *pcontext) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -48,7 +48,6 @@ int buf_close(void *pcontext) "; - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs index 53bac602..e0676c10 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs @@ -3,98 +3,97 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class EnumDeclarationTest : PInvokeGeneratorTest { - public abstract class EnumDeclarationTest : PInvokeGeneratorTest - { - [Test] - public Task BasicTest() => BasicTestImpl(); + [Test] + public Task BasicTest() => BasicTestImpl(); - [Test] - public Task BasicValueTest() => BasicValueTestImpl(); + [Test] + public Task BasicValueTest() => BasicValueTestImpl(); - [Test] - public Task ExcludeTest() => ExcludeTestImpl(); + [Test] + public Task ExcludeTest() => ExcludeTestImpl(); - [TestCase("short", "short")] - public Task ExplicitTypedTest(string nativeType, string expectedManagedType) => ExplicitTypedTestImpl(nativeType, expectedManagedType); + [TestCase("short", "short")] + public Task ExplicitTypedTest(string nativeType, string expectedManagedType) => ExplicitTypedTestImpl(nativeType, expectedManagedType); - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task ExplicitTypedWithNativeTypeNameTest(string nativeType, string expectedManagedType) => ExplicitTypedWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + public Task ExplicitTypedWithNativeTypeNameTest(string nativeType, string expectedManagedType) => ExplicitTypedWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - [Test] - public Task RemapTest() => RemapTestImpl(); + [Test] + public Task RemapTest() => RemapTestImpl(); - [Test] - public Task WithAttributeTest() => WithAttributeTestImpl(); + [Test] + public Task WithAttributeTest() => WithAttributeTestImpl(); - [Test] - public Task WithNamespaceTest() => WithNamespaceTestImpl(); + [Test] + public Task WithNamespaceTest() => WithNamespaceTestImpl(); - [Test] - public Task WithNamespaceStarTest() => WithNamespaceStarTestImpl(); + [Test] + public Task WithNamespaceStarTest() => WithNamespaceStarTestImpl(); - [Test] - public Task WithNamespaceStarPlusTest() => WithNamespaceStarPlusTestImpl(); + [Test] + public Task WithNamespaceStarPlusTest() => WithNamespaceStarPlusTestImpl(); - [Test] - public Task WithCastToEnumType() => WithCastToEnumTypeImpl(); + [Test] + public Task WithCastToEnumType() => WithCastToEnumTypeImpl(); - [Test] - public Task WithMultipleEnumsTest() => WithMultipleEnumsTestImpl(); + [Test] + public Task WithMultipleEnumsTest() => WithMultipleEnumsTestImpl(); - [Test] - public Task WithImplicitConversionTest() => WithImplicitConversionTestImpl(); + [Test] + public Task WithImplicitConversionTest() => WithImplicitConversionTestImpl(); - [Test] - public Task WithTypeTest() => WithTypeTestImpl(); + [Test] + public Task WithTypeTest() => WithTypeTestImpl(); - [Test] - public Task WithTypeAndImplicitConversionTest() => WithTypeAndImplicitConversionTestImpl(); + [Test] + public Task WithTypeAndImplicitConversionTest() => WithTypeAndImplicitConversionTestImpl(); - [Test] - public Task WithTypeStarTest() => WithTypeStarTestImpl(); + [Test] + public Task WithTypeStarTest() => WithTypeStarTestImpl(); - [Test] - public Task WithTypeStarOverrideTest() => WithTypeStarOverrideTestImpl(); + [Test] + public Task WithTypeStarOverrideTest() => WithTypeStarOverrideTestImpl(); - protected abstract Task BasicTestImpl(); + protected abstract Task BasicTestImpl(); - protected abstract Task BasicValueTestImpl(); + protected abstract Task BasicValueTestImpl(); - protected abstract Task ExcludeTestImpl(); + protected abstract Task ExcludeTestImpl(); - protected abstract Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType); + protected abstract Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType); - protected abstract Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task RemapTestImpl(); + protected abstract Task RemapTestImpl(); - protected abstract Task WithAttributeTestImpl(); + protected abstract Task WithAttributeTestImpl(); - protected abstract Task WithNamespaceTestImpl(); + protected abstract Task WithNamespaceTestImpl(); - protected abstract Task WithNamespaceStarTestImpl(); + protected abstract Task WithNamespaceStarTestImpl(); - protected abstract Task WithNamespaceStarPlusTestImpl(); + protected abstract Task WithNamespaceStarPlusTestImpl(); - protected abstract Task WithCastToEnumTypeImpl(); + protected abstract Task WithCastToEnumTypeImpl(); - protected abstract Task WithMultipleEnumsTestImpl(); + protected abstract Task WithMultipleEnumsTestImpl(); - protected abstract Task WithImplicitConversionTestImpl(); + protected abstract Task WithImplicitConversionTestImpl(); - protected abstract Task WithTypeTestImpl(); + protected abstract Task WithTypeTestImpl(); - protected abstract Task WithTypeAndImplicitConversionTestImpl(); + protected abstract Task WithTypeAndImplicitConversionTestImpl(); - protected abstract Task WithTypeStarTestImpl(); + protected abstract Task WithTypeStarTestImpl(); - protected abstract Task WithTypeStarOverrideTestImpl(); - } + protected abstract Task WithTypeStarOverrideTestImpl(); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationBodyImportTest.cs index c6cc7a33..52727f75 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationBodyImportTest.cs @@ -3,287 +3,286 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class FunctionDeclarationBodyImportTest : PInvokeGeneratorTest { - public abstract class FunctionDeclarationBodyImportTest : PInvokeGeneratorTest - { - [Test] - public Task AccessUnionMemberTest() => AccessUnionMemberTestImpl(); - - [Test] - public Task ArraySubscriptTest() => ArraySubscriptTestImpl(); - - [Test] - public Task BasicTest() => BasicTestImpl(); + [Test] + public Task AccessUnionMemberTest() => AccessUnionMemberTestImpl(); + + [Test] + public Task ArraySubscriptTest() => ArraySubscriptTestImpl(); + + [Test] + public Task BasicTest() => BasicTestImpl(); - [TestCase("%")] - [TestCase("%=")] - [TestCase("&")] - [TestCase("&=")] - [TestCase("*")] - [TestCase("*=")] - [TestCase("+")] - [TestCase("+=")] - [TestCase("-")] - [TestCase("-=")] - [TestCase("/")] - [TestCase("/=")] - [TestCase("<<")] - [TestCase("<<=")] - [TestCase("=")] - [TestCase(">>")] - [TestCase(">>=")] - [TestCase("^")] - [TestCase("^=")] - [TestCase("|")] - [TestCase("|=")] - public Task BinaryOperatorBasicTest(string opcode) => BinaryOperatorBasicTestImpl(opcode); + [TestCase("%")] + [TestCase("%=")] + [TestCase("&")] + [TestCase("&=")] + [TestCase("*")] + [TestCase("*=")] + [TestCase("+")] + [TestCase("+=")] + [TestCase("-")] + [TestCase("-=")] + [TestCase("/")] + [TestCase("/=")] + [TestCase("<<")] + [TestCase("<<=")] + [TestCase("=")] + [TestCase(">>")] + [TestCase(">>=")] + [TestCase("^")] + [TestCase("^=")] + [TestCase("|")] + [TestCase("|=")] + public Task BinaryOperatorBasicTest(string opcode) => BinaryOperatorBasicTestImpl(opcode); - [TestCase("==")] - [TestCase("!=")] - [TestCase("<")] - [TestCase("<=")] - [TestCase(">")] - [TestCase(">=")] - public Task BinaryOperatorCompareTest(string opcode) => BinaryOperatorCompareTestImpl(opcode); + [TestCase("==")] + [TestCase("!=")] + [TestCase("<")] + [TestCase("<=")] + [TestCase(">")] + [TestCase(">=")] + public Task BinaryOperatorCompareTest(string opcode) => BinaryOperatorCompareTestImpl(opcode); - [TestCase("&&")] - [TestCase("||")] - public Task BinaryOperatorBooleanTest(string opcode) => BinaryOperatorBooleanTestImpl(opcode); + [TestCase("&&")] + [TestCase("||")] + public Task BinaryOperatorBooleanTest(string opcode) => BinaryOperatorBooleanTestImpl(opcode); - [Test] - public Task BreakTest() => BreakTestImpl(); + [Test] + public Task BreakTest() => BreakTestImpl(); - [Test] - public Task CallFunctionTest() => CallFunctionTestImpl(); + [Test] + public Task CallFunctionTest() => CallFunctionTestImpl(); - [Test] - public Task CallFunctionWithArgsTest() => CallFunctionWithArgsTestImpl(); + [Test] + public Task CallFunctionWithArgsTest() => CallFunctionWithArgsTestImpl(); - [Test] - public Task CaseTest() => CaseTestImpl(); + [Test] + public Task CaseTest() => CaseTestImpl(); - [Test] - public Task CaseNoCompoundTest() => CaseNoCompoundTestImpl(); + [Test] + public Task CaseNoCompoundTest() => CaseNoCompoundTestImpl(); - [Test] - public Task CompareMultipleEnumTest() => CompareMultipleEnumTestImpl(); + [Test] + public Task CompareMultipleEnumTest() => CompareMultipleEnumTestImpl(); - [Test] - public Task ConditionalOperatorTest() => ConditionalOperatorTestImpl(); + [Test] + public Task ConditionalOperatorTest() => ConditionalOperatorTestImpl(); - [Test] - public Task ContinueTest() => ContinueTestImpl(); + [Test] + public Task ContinueTest() => ContinueTestImpl(); - [Test] - public Task CStyleFunctionalCastTest() => CStyleFunctionalCastTestImpl(); + [Test] + public Task CStyleFunctionalCastTest() => CStyleFunctionalCastTestImpl(); - [Test] - public Task CxxFunctionalCastTest() => CxxFunctionalCastTestImpl(); + [Test] + public Task CxxFunctionalCastTest() => CxxFunctionalCastTestImpl(); - [Test] - public Task CxxConstCastTest() => CxxConstCastTestImpl(); + [Test] + public Task CxxConstCastTest() => CxxConstCastTestImpl(); - [Test] - public Task CxxDynamicCastTest() => CxxDynamicCastTestImpl(); + [Test] + public Task CxxDynamicCastTest() => CxxDynamicCastTestImpl(); - [Test] - public Task CxxReinterpretCastTest() => CxxReinterpretCastTestImpl(); + [Test] + public Task CxxReinterpretCastTest() => CxxReinterpretCastTestImpl(); - [Test] - public Task CxxStaticCastTest() => CxxStaticCastTestImpl(); + [Test] + public Task CxxStaticCastTest() => CxxStaticCastTestImpl(); - [Test] - public Task DeclTest() => DeclTestImpl(); + [Test] + public Task DeclTest() => DeclTestImpl(); - [Test] - public Task DoTest() => DoTestImpl(); + [Test] + public Task DoTest() => DoTestImpl(); - [Test] - public Task DoNonCompoundTest() => DoNonCompoundTestImpl(); + [Test] + public Task DoNonCompoundTest() => DoNonCompoundTestImpl(); - [Test] - public Task ForTest() => ForTestImpl(); + [Test] + public Task ForTest() => ForTestImpl(); - [Test] - public Task ForNonCompoundTest() => ForNonCompoundTestImpl(); + [Test] + public Task ForNonCompoundTest() => ForNonCompoundTestImpl(); - [Test] - public Task IfTest() => IfTestImpl(); + [Test] + public Task IfTest() => IfTestImpl(); - [Test] - public Task IfElseTest() => IfElseTestImpl(); + [Test] + public Task IfElseTest() => IfElseTestImpl(); - [Test] - public Task IfElseIfTest() => IfElseIfTestImpl(); + [Test] + public Task IfElseIfTest() => IfElseIfTestImpl(); - [Test] - public Task IfElseNonCompoundTest() => IfElseNonCompoundTestImpl(); + [Test] + public Task IfElseNonCompoundTest() => IfElseNonCompoundTestImpl(); - [Test] - public Task InitListForArrayTest() => InitListForArrayTestImpl(); + [Test] + public Task InitListForArrayTest() => InitListForArrayTestImpl(); - [Test] - public Task InitListForRecordDeclTest() => InitListForRecordDeclTestImpl(); + [Test] + public Task InitListForRecordDeclTest() => InitListForRecordDeclTestImpl(); - [Test] - public Task MemberTest() => MemberTestImpl(); + [Test] + public Task MemberTest() => MemberTestImpl(); - [Test] - public Task RefToPtrTest() => RefToPtrTestImpl(); + [Test] + public Task RefToPtrTest() => RefToPtrTestImpl(); - [Test] - public Task ReturnCXXNullPtrTest() => ReturnCXXNullPtrTestImpl(); + [Test] + public Task ReturnCXXNullPtrTest() => ReturnCXXNullPtrTestImpl(); - [TestCase("false")] - [TestCase("true")] - public Task ReturnCXXBooleanLiteralTest(string value) => ReturnCXXBooleanLiteralTestImpl(value); + [TestCase("false")] + [TestCase("true")] + public Task ReturnCXXBooleanLiteralTest(string value) => ReturnCXXBooleanLiteralTestImpl(value); - [TestCase("5e-1")] - [TestCase("3.14")] - public Task ReturnFloatingLiteralDoubleTest(string value) => ReturnFloatingLiteralDoubleTestImpl(value); + [TestCase("5e-1")] + [TestCase("3.14")] + public Task ReturnFloatingLiteralDoubleTest(string value) => ReturnFloatingLiteralDoubleTestImpl(value); - [TestCase("5e-1f")] - [TestCase("3.14f")] - public Task ReturnFloatingLiteralSingleTest(string value) => ReturnFloatingLiteralSingleTestImpl(value); + [TestCase("5e-1f")] + [TestCase("3.14f")] + public Task ReturnFloatingLiteralSingleTest(string value) => ReturnFloatingLiteralSingleTestImpl(value); - [Test] - public Task ReturnEmptyTest() => ReturnEmptyTestImpl(); + [Test] + public Task ReturnEmptyTest() => ReturnEmptyTestImpl(); - [Test] - public Task ReturnIntegerLiteralInt32Test() => ReturnIntegerLiteralInt32TestImpl(); + [Test] + public Task ReturnIntegerLiteralInt32Test() => ReturnIntegerLiteralInt32TestImpl(); - [Test] - public Task ReturnStructTest() => ReturnStructTestImpl(); + [Test] + public Task ReturnStructTest() => ReturnStructTestImpl(); - [Test] - public Task SwitchTest() => SwitchTestImpl(); + [Test] + public Task SwitchTest() => SwitchTestImpl(); - [Test] - public Task SwitchNonCompoundTest() => SwitchNonCompoundTestImpl(); + [Test] + public Task SwitchNonCompoundTest() => SwitchNonCompoundTestImpl(); - [Test] - public Task UnaryOperatorAddrOfTest() => UnaryOperatorAddrOfTestImpl(); + [Test] + public Task UnaryOperatorAddrOfTest() => UnaryOperatorAddrOfTestImpl(); - [Test] - public Task UnaryOperatorDerefTest() => UnaryOperatorDerefTestImpl(); + [Test] + public Task UnaryOperatorDerefTest() => UnaryOperatorDerefTestImpl(); - [Test] - public Task UnaryOperatorLogicalNotTest() => UnaryOperatorLogicalNotTestImpl(); + [Test] + public Task UnaryOperatorLogicalNotTest() => UnaryOperatorLogicalNotTestImpl(); - [TestCase("++")] - [TestCase("--")] - public Task UnaryOperatorPostfixTest(string opcode) => UnaryOperatorPostfixTestImpl(opcode); + [TestCase("++")] + [TestCase("--")] + public Task UnaryOperatorPostfixTest(string opcode) => UnaryOperatorPostfixTestImpl(opcode); - [TestCase("+")] - [TestCase("++")] - [TestCase("-")] - [TestCase("--")] - [TestCase("~")] - public Task UnaryOperatorPrefixTest(string opcode) => UnaryOperatorPrefixTestImpl(opcode); + [TestCase("+")] + [TestCase("++")] + [TestCase("-")] + [TestCase("--")] + [TestCase("~")] + public Task UnaryOperatorPrefixTest(string opcode) => UnaryOperatorPrefixTestImpl(opcode); - [Test] - public Task WhileTest() => WhileTestImpl(); + [Test] + public Task WhileTest() => WhileTestImpl(); - [Test] - public Task WhileNonCompoundTest() => WhileNonCompoundTestImpl(); + [Test] + public Task WhileNonCompoundTest() => WhileNonCompoundTestImpl(); - protected abstract Task AccessUnionMemberTestImpl(); + protected abstract Task AccessUnionMemberTestImpl(); - protected abstract Task ArraySubscriptTestImpl(); + protected abstract Task ArraySubscriptTestImpl(); - protected abstract Task BasicTestImpl(); + protected abstract Task BasicTestImpl(); - protected abstract Task BinaryOperatorBasicTestImpl(string opcode); + protected abstract Task BinaryOperatorBasicTestImpl(string opcode); - protected abstract Task BinaryOperatorCompareTestImpl(string opcode); + protected abstract Task BinaryOperatorCompareTestImpl(string opcode); - protected abstract Task BinaryOperatorBooleanTestImpl(string opcode); + protected abstract Task BinaryOperatorBooleanTestImpl(string opcode); - protected abstract Task BreakTestImpl(); + protected abstract Task BreakTestImpl(); - protected abstract Task CallFunctionTestImpl(); + protected abstract Task CallFunctionTestImpl(); - protected abstract Task CallFunctionWithArgsTestImpl(); + protected abstract Task CallFunctionWithArgsTestImpl(); - protected abstract Task CaseTestImpl(); + protected abstract Task CaseTestImpl(); - protected abstract Task CaseNoCompoundTestImpl(); + protected abstract Task CaseNoCompoundTestImpl(); - protected abstract Task CompareMultipleEnumTestImpl(); + protected abstract Task CompareMultipleEnumTestImpl(); - protected abstract Task ConditionalOperatorTestImpl(); + protected abstract Task ConditionalOperatorTestImpl(); - protected abstract Task ContinueTestImpl(); + protected abstract Task ContinueTestImpl(); - protected abstract Task CStyleFunctionalCastTestImpl(); + protected abstract Task CStyleFunctionalCastTestImpl(); - protected abstract Task CxxFunctionalCastTestImpl(); + protected abstract Task CxxFunctionalCastTestImpl(); - protected abstract Task CxxConstCastTestImpl(); + protected abstract Task CxxConstCastTestImpl(); - protected abstract Task CxxDynamicCastTestImpl(); + protected abstract Task CxxDynamicCastTestImpl(); - protected abstract Task CxxReinterpretCastTestImpl(); + protected abstract Task CxxReinterpretCastTestImpl(); - protected abstract Task CxxStaticCastTestImpl(); + protected abstract Task CxxStaticCastTestImpl(); - protected abstract Task DeclTestImpl(); + protected abstract Task DeclTestImpl(); - protected abstract Task DoTestImpl(); + protected abstract Task DoTestImpl(); - protected abstract Task DoNonCompoundTestImpl(); + protected abstract Task DoNonCompoundTestImpl(); - protected abstract Task ForTestImpl(); + protected abstract Task ForTestImpl(); - protected abstract Task ForNonCompoundTestImpl(); + protected abstract Task ForNonCompoundTestImpl(); - protected abstract Task IfTestImpl(); + protected abstract Task IfTestImpl(); - protected abstract Task IfElseTestImpl(); + protected abstract Task IfElseTestImpl(); - protected abstract Task IfElseIfTestImpl(); + protected abstract Task IfElseIfTestImpl(); - protected abstract Task IfElseNonCompoundTestImpl(); + protected abstract Task IfElseNonCompoundTestImpl(); - protected abstract Task InitListForArrayTestImpl(); + protected abstract Task InitListForArrayTestImpl(); - protected abstract Task InitListForRecordDeclTestImpl(); + protected abstract Task InitListForRecordDeclTestImpl(); - protected abstract Task MemberTestImpl(); + protected abstract Task MemberTestImpl(); - protected abstract Task RefToPtrTestImpl(); + protected abstract Task RefToPtrTestImpl(); - protected abstract Task ReturnCXXNullPtrTestImpl(); + protected abstract Task ReturnCXXNullPtrTestImpl(); - protected abstract Task ReturnCXXBooleanLiteralTestImpl(string value); + protected abstract Task ReturnCXXBooleanLiteralTestImpl(string value); - protected abstract Task ReturnFloatingLiteralDoubleTestImpl(string value); + protected abstract Task ReturnFloatingLiteralDoubleTestImpl(string value); - protected abstract Task ReturnFloatingLiteralSingleTestImpl(string value); + protected abstract Task ReturnFloatingLiteralSingleTestImpl(string value); - protected abstract Task ReturnEmptyTestImpl(); + protected abstract Task ReturnEmptyTestImpl(); - protected abstract Task ReturnIntegerLiteralInt32TestImpl(); + protected abstract Task ReturnIntegerLiteralInt32TestImpl(); - protected abstract Task ReturnStructTestImpl(); + protected abstract Task ReturnStructTestImpl(); - protected abstract Task SwitchTestImpl(); + protected abstract Task SwitchTestImpl(); - protected abstract Task SwitchNonCompoundTestImpl(); + protected abstract Task SwitchNonCompoundTestImpl(); - protected abstract Task UnaryOperatorAddrOfTestImpl(); + protected abstract Task UnaryOperatorAddrOfTestImpl(); - protected abstract Task UnaryOperatorDerefTestImpl(); + protected abstract Task UnaryOperatorDerefTestImpl(); - protected abstract Task UnaryOperatorLogicalNotTestImpl(); + protected abstract Task UnaryOperatorLogicalNotTestImpl(); - protected abstract Task UnaryOperatorPostfixTestImpl(string opcode); + protected abstract Task UnaryOperatorPostfixTestImpl(string opcode); - protected abstract Task UnaryOperatorPrefixTestImpl(string opcode); + protected abstract Task UnaryOperatorPrefixTestImpl(string opcode); - protected abstract Task WhileTestImpl(); + protected abstract Task WhileTestImpl(); - protected abstract Task WhileNonCompoundTestImpl(); - } + protected abstract Task WhileNonCompoundTestImpl(); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs index b97dce36..8896767d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs @@ -3,113 +3,112 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class FunctionDeclarationDllImportTest : PInvokeGeneratorTest { - public abstract class FunctionDeclarationDllImportTest : PInvokeGeneratorTest - { - [Test] - public Task BasicTest() => BasicTestImpl(); + [Test] + public Task BasicTest() => BasicTestImpl(); - [Test] - public Task ArrayParameterTest() => ArrayParameterTestImpl(); + [Test] + public Task ArrayParameterTest() => ArrayParameterTestImpl(); - [Test] - public Task FunctionPointerParameterTest() => FunctionPointerParameterTestImpl(); + [Test] + public Task FunctionPointerParameterTest() => FunctionPointerParameterTestImpl(); - [Test] - public Task NamespaceTest() => NamespaceTestImpl(); + [Test] + public Task NamespaceTest() => NamespaceTestImpl(); - [TestCase("int", false, "int", "")] - [TestCase("bool", true, "byte", "")] - [TestCase("float *", true, "IntPtr", "using System;\n")] - [TestCase("void (*)(int)", true, "IntPtr", "using System;\n")] - public Task TemplateParameterTest(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) => TemplateParameterTestImpl(nativeType, expectedNativeTypeAttr, expectedManagedType, expectedUsingStatement); + [TestCase("int", false, "int", "")] + [TestCase("bool", true, "byte", "")] + [TestCase("float *", true, "IntPtr", "using System;\n")] + [TestCase("void (*)(int)", true, "IntPtr", "using System;\n")] + public Task TemplateParameterTest(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) => TemplateParameterTestImpl(nativeType, expectedNativeTypeAttr, expectedManagedType, expectedUsingStatement); - [Test] - public Task TemplateMemberTest() => TemplateMemberTestImpl(); + [Test] + public Task TemplateMemberTest() => TemplateMemberTestImpl(); - [Test] - public Task NoLibraryPathTest() => NoLibraryPathTestImpl(); + [Test] + public Task NoLibraryPathTest() => NoLibraryPathTestImpl(); - [Test] - public Task WithLibraryPathTest() => WithLibraryPathTestImpl(); + [Test] + public Task WithLibraryPathTest() => WithLibraryPathTestImpl(); - [Test] - public Task WithLibraryPathStarTest() => WithLibraryPathStarTestImpl(); + [Test] + public Task WithLibraryPathStarTest() => WithLibraryPathStarTestImpl(); - [TestCase("unsigned char", "0", true, "byte", "0")] - [TestCase("double", "1.0", false, "double", "1.0")] - [TestCase("short", "2", false, "short", "2")] - [TestCase("int", "3", false, "int", "3")] - [TestCase("long long", "4", true, "long", "4")] - [TestCase("signed char", "5", true, "sbyte", "5")] - [TestCase("float", "6.0f", false, "float", "6.0f")] - [TestCase("unsigned short", "7", true, "ushort", "7")] - [TestCase("unsigned int", "8", true, "uint", "8")] - [TestCase("unsigned long long", "9", true, "ulong", "9")] - [TestCase("unsigned short", "'A'", true, "ushort", "(byte)('A')")] - public Task OptionalParameterTest(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) => OptionalParameterTestImpl(nativeType, nativeInit, expectedNativeTypeNameAttr, expectedManagedType, expectedManagedInit); + [TestCase("unsigned char", "0", true, "byte", "0")] + [TestCase("double", "1.0", false, "double", "1.0")] + [TestCase("short", "2", false, "short", "2")] + [TestCase("int", "3", false, "int", "3")] + [TestCase("long long", "4", true, "long", "4")] + [TestCase("signed char", "5", true, "sbyte", "5")] + [TestCase("float", "6.0f", false, "float", "6.0f")] + [TestCase("unsigned short", "7", true, "ushort", "7")] + [TestCase("unsigned int", "8", true, "uint", "8")] + [TestCase("unsigned long long", "9", true, "ulong", "9")] + [TestCase("unsigned short", "'A'", true, "ushort", "(byte)('A')")] + public Task OptionalParameterTest(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) => OptionalParameterTestImpl(nativeType, nativeInit, expectedNativeTypeNameAttr, expectedManagedType, expectedManagedInit); - [TestCase("void *", "nullptr", "void*", "null")] - [TestCase("void *", "0", "void*", "null")] - public Task OptionalParameterUnsafeTest(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) => OptionalParameterUnsafeTestImpl(nativeType, nativeInit, expectedManagedType, expectedManagedInit); + [TestCase("void *", "nullptr", "void*", "null")] + [TestCase("void *", "0", "void*", "null")] + public Task OptionalParameterUnsafeTest(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) => OptionalParameterUnsafeTestImpl(nativeType, nativeInit, expectedManagedType, expectedManagedInit); - [Test] - public Task WithCallConvTest() => WithCallConvTestImpl(); + [Test] + public Task WithCallConvTest() => WithCallConvTestImpl(); - [Test] - public Task WithCallConvStarTest() => WithCallConvStarTestImpl(); + [Test] + public Task WithCallConvStarTest() => WithCallConvStarTestImpl(); - [Test] - public Task WithCallConvStarOverrideTest() => WithCallConvStarOverrideTestImpl(); + [Test] + public Task WithCallConvStarOverrideTest() => WithCallConvStarOverrideTestImpl(); - [Test] - public Task WithSetLastErrorTest() => WithSetLastErrorTestImpl(); + [Test] + public Task WithSetLastErrorTest() => WithSetLastErrorTestImpl(); - [Test] - public Task WithSetLastErrorStarTest() => WithSetLastErrorStarTestImpl(); + [Test] + public Task WithSetLastErrorStarTest() => WithSetLastErrorStarTestImpl(); - [Test] - public Task SourceLocationTest() => SourceLocationTestImpl(); + [Test] + public Task SourceLocationTest() => SourceLocationTestImpl(); - [Test] - public Task VarargsTest() => VarargsTestImpl(); + [Test] + public Task VarargsTest() => VarargsTestImpl(); - protected abstract Task BasicTestImpl(); + protected abstract Task BasicTestImpl(); - protected abstract Task ArrayParameterTestImpl(); + protected abstract Task ArrayParameterTestImpl(); - protected abstract Task FunctionPointerParameterTestImpl(); + protected abstract Task FunctionPointerParameterTestImpl(); - protected abstract Task NamespaceTestImpl(); + protected abstract Task NamespaceTestImpl(); - protected abstract Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement); + protected abstract Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement); - protected abstract Task TemplateMemberTestImpl(); + protected abstract Task TemplateMemberTestImpl(); - protected abstract Task NoLibraryPathTestImpl(); + protected abstract Task NoLibraryPathTestImpl(); - protected abstract Task WithLibraryPathTestImpl(); + protected abstract Task WithLibraryPathTestImpl(); - protected abstract Task WithLibraryPathStarTestImpl(); + protected abstract Task WithLibraryPathStarTestImpl(); - protected abstract Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit); + protected abstract Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit); - protected abstract Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit); + protected abstract Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit); - protected abstract Task WithCallConvTestImpl(); + protected abstract Task WithCallConvTestImpl(); - protected abstract Task WithCallConvStarTestImpl(); + protected abstract Task WithCallConvStarTestImpl(); - protected abstract Task WithCallConvStarOverrideTestImpl(); + protected abstract Task WithCallConvStarOverrideTestImpl(); - protected abstract Task WithSetLastErrorTestImpl(); + protected abstract Task WithSetLastErrorTestImpl(); - protected abstract Task WithSetLastErrorStarTestImpl(); + protected abstract Task WithSetLastErrorStarTestImpl(); - protected abstract Task SourceLocationTestImpl(); + protected abstract Task SourceLocationTestImpl(); - protected abstract Task VarargsTestImpl(); - } + protected abstract Task VarargsTestImpl(); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionPointerDeclarationTest.cs index 22bb0438..7938c6b1 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionPointerDeclarationTest.cs @@ -3,23 +3,22 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class FunctionPointerDeclarationTest : PInvokeGeneratorTest { - public abstract class FunctionPointerDeclarationTest : PInvokeGeneratorTest - { - [Test] - public Task BasicTest() => BasicTestImpl(); + [Test] + public Task BasicTest() => BasicTestImpl(); - [Test] - public Task CallconvTest() => CallconvTestImpl(); + [Test] + public Task CallconvTest() => CallconvTestImpl(); - [Test] - public Task PointerlessTypedefTest() => PointerlessTypedefTestImpl(); + [Test] + public Task PointerlessTypedefTest() => PointerlessTypedefTestImpl(); - protected abstract Task BasicTestImpl(); + protected abstract Task BasicTestImpl(); - protected abstract Task CallconvTestImpl(); + protected abstract Task CallconvTestImpl(); - protected abstract Task PointerlessTypedefTestImpl(); - } + protected abstract Task PointerlessTypedefTestImpl(); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs index 8b149cde..6bc5761c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs @@ -3,277 +3,276 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class StructDeclarationTest : PInvokeGeneratorTest { - public abstract class StructDeclarationTest : PInvokeGeneratorTest - { - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task IncompleteArraySizeTest(string nativeType, string expectedManagedType) => IncompleteArraySizeTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTest(string nativeType, string expectedManagedType) => BasicTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTestInCMode(string nativeType, string expectedManagedType) => BasicTestInCModeImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) => BasicWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task BitfieldTest() => BitfieldTestImpl(); - - [Test] - public Task ExcludeTest() => ExcludeTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTypedefTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [TestCase("double *", "double*")] - [TestCase("short *", "short*")] - [TestCase("int *", "int*")] - [TestCase("float *", "float*")] - public Task FixedSizedBufferPointerTest(string nativeType, string expectedManagedType) => FixedSizedBufferPointerTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTypedefTestImpl(nativeType, expectedManagedType); - - [Test] - public Task GuidTest() => GuidTestImpl(); - - [Test] - public Task InheritanceTest() => InheritanceTestImpl(); - - [Test] - public Task InheritanceWithNativeInheritanceAttributeTest() => InheritanceWithNativeInheritanceAttributeTestImpl(); - - [TestCase("double", "double", 10, 5)] - [TestCase("short", "short", 10, 5)] - [TestCase("int", "int", 10, 5)] - [TestCase("float", "float", 10, 5)] - public Task NestedAnonymousTest(string nativeType, string expectedManagedType, int line, int column) => NestedAnonymousTestImpl(nativeType, expectedManagedType, line, column); - - [Test] - public Task NestedAnonymousWithBitfieldTest() => NestedAnonymousWithBitfieldTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task NestedTest(string nativeType, string expectedManagedType) => NestedTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task NestedWithNativeTypeNameTest(string nativeType, string expectedManagedType) => NestedWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task NewKeywordTest() => NewKeywordTestImpl(); - - [Test] - public Task NoDefinitionTest() => NoDefinitionTestImpl(); + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task IncompleteArraySizeTest(string nativeType, string expectedManagedType) => IncompleteArraySizeTestImpl(nativeType, expectedManagedType); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task BasicTest(string nativeType, string expectedManagedType) => BasicTestImpl(nativeType, expectedManagedType); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task BasicTestInCMode(string nativeType, string expectedManagedType) => BasicTestInCModeImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) => BasicWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + + [Test] + public Task BitfieldTest() => BitfieldTestImpl(); + + [Test] + public Task ExcludeTest() => ExcludeTestImpl(); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTestImpl(nativeType, expectedManagedType); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTypedefTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + + [TestCase("double *", "double*")] + [TestCase("short *", "short*")] + [TestCase("int *", "int*")] + [TestCase("float *", "float*")] + public Task FixedSizedBufferPointerTest(string nativeType, string expectedManagedType) => FixedSizedBufferPointerTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTypedefTestImpl(nativeType, expectedManagedType); + + [Test] + public Task GuidTest() => GuidTestImpl(); + + [Test] + public Task InheritanceTest() => InheritanceTestImpl(); + + [Test] + public Task InheritanceWithNativeInheritanceAttributeTest() => InheritanceWithNativeInheritanceAttributeTestImpl(); + + [TestCase("double", "double", 10, 5)] + [TestCase("short", "short", 10, 5)] + [TestCase("int", "int", 10, 5)] + [TestCase("float", "float", 10, 5)] + public Task NestedAnonymousTest(string nativeType, string expectedManagedType, int line, int column) => NestedAnonymousTestImpl(nativeType, expectedManagedType, line, column); + + [Test] + public Task NestedAnonymousWithBitfieldTest() => NestedAnonymousWithBitfieldTestImpl(); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task NestedTest(string nativeType, string expectedManagedType) => NestedTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task NestedWithNativeTypeNameTest(string nativeType, string expectedManagedType) => NestedWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + + [Test] + public Task NewKeywordTest() => NewKeywordTestImpl(); + + [Test] + public Task NoDefinitionTest() => NoDefinitionTestImpl(); - [Test] - public Task PackTest() => PackTestImpl(); + [Test] + public Task PackTest() => PackTestImpl(); - [Test] - public Task PointerToSelfTest() => PointerToSelfTestImpl(); + [Test] + public Task PointerToSelfTest() => PointerToSelfTestImpl(); - [Test] - public Task PointerToSelfViaTypedefTest() => PointerToSelfViaTypedefTestImpl(); + [Test] + public Task PointerToSelfViaTypedefTest() => PointerToSelfViaTypedefTestImpl(); - [Test] - public Task RemapTest() => RemapTestImpl(); + [Test] + public Task RemapTest() => RemapTestImpl(); - [Test] - public Task RemapNestedAnonymousTest() => RemapNestedAnonymousTestImpl(); + [Test] + public Task RemapNestedAnonymousTest() => RemapNestedAnonymousTestImpl(); - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task SkipNonDefinitionTest(string nativeType, string expectedManagedType) => SkipNonDefinitionTestImpl(nativeType, expectedManagedType); + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task SkipNonDefinitionTest(string nativeType, string expectedManagedType) => SkipNonDefinitionTestImpl(nativeType, expectedManagedType); - [Test] - public Task SkipNonDefinitionPointerTest() => SkipNonDefinitionPointerTestImpl(); + [Test] + public Task SkipNonDefinitionPointerTest() => SkipNonDefinitionPointerTestImpl(); - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task SkipNonDefinitionWithNativeTypeNameTest(string nativeType, string expectedManagedType) => SkipNonDefinitionWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task SkipNonDefinitionWithNativeTypeNameTest(string nativeType, string expectedManagedType) => SkipNonDefinitionWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task TypedefTest(string nativeType, string expectedManagedType) => TypedefTestImpl(nativeType, expectedManagedType); + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task TypedefTest(string nativeType, string expectedManagedType) => TypedefTestImpl(nativeType, expectedManagedType); - [Test] - public Task UsingDeclarationTest() => UsingDeclarationTestImpl(); + [Test] + public Task UsingDeclarationTest() => UsingDeclarationTestImpl(); - [Test] - public Task WithAccessSpecifierTest() => WithAccessSpecifierTestImpl(); + [Test] + public Task WithAccessSpecifierTest() => WithAccessSpecifierTestImpl(); - [Test] - public Task SourceLocationAttributeTest() => SourceLocationAttributeTestImpl(); + [Test] + public Task SourceLocationAttributeTest() => SourceLocationAttributeTestImpl(); - protected abstract Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType); + protected abstract Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType); - protected abstract Task BasicTestImpl(string nativeType, string expectedManagedType); + protected abstract Task BasicTestImpl(string nativeType, string expectedManagedType); - protected abstract Task BasicTestInCModeImpl(string nativeType, string expectedManagedType); + protected abstract Task BasicTestInCModeImpl(string nativeType, string expectedManagedType); - protected abstract Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task BitfieldTestImpl(); + protected abstract Task BitfieldTestImpl(); - protected abstract Task ExcludeTestImpl(); + protected abstract Task ExcludeTestImpl(); - protected abstract Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); - protected abstract Task GuidTestImpl(); + protected abstract Task GuidTestImpl(); - protected abstract Task InheritanceTestImpl(); + protected abstract Task InheritanceTestImpl(); - protected abstract Task InheritanceWithNativeInheritanceAttributeTestImpl(); + protected abstract Task InheritanceWithNativeInheritanceAttributeTestImpl(); - protected abstract Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column); + protected abstract Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column); - protected abstract Task NestedAnonymousWithBitfieldTestImpl(); + protected abstract Task NestedAnonymousWithBitfieldTestImpl(); - protected abstract Task NestedTestImpl(string nativeType, string expectedManagedType); + protected abstract Task NestedTestImpl(string nativeType, string expectedManagedType); - protected abstract Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task NewKeywordTestImpl(); + protected abstract Task NewKeywordTestImpl(); - protected abstract Task NoDefinitionTestImpl(); + protected abstract Task NoDefinitionTestImpl(); - protected abstract Task PackTestImpl(); + protected abstract Task PackTestImpl(); - protected abstract Task PointerToSelfTestImpl(); + protected abstract Task PointerToSelfTestImpl(); - protected abstract Task PointerToSelfViaTypedefTestImpl(); + protected abstract Task PointerToSelfViaTypedefTestImpl(); - protected abstract Task RemapTestImpl(); + protected abstract Task RemapTestImpl(); - protected abstract Task RemapNestedAnonymousTestImpl(); + protected abstract Task RemapNestedAnonymousTestImpl(); - protected abstract Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType); + protected abstract Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType); - protected abstract Task SkipNonDefinitionPointerTestImpl(); + protected abstract Task SkipNonDefinitionPointerTestImpl(); - protected abstract Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task TypedefTestImpl(string nativeType, string expectedManagedType); + protected abstract Task TypedefTestImpl(string nativeType, string expectedManagedType); - protected abstract Task UsingDeclarationTestImpl(); + protected abstract Task UsingDeclarationTestImpl(); - protected abstract Task WithAccessSpecifierTestImpl(); + protected abstract Task WithAccessSpecifierTestImpl(); - protected abstract Task SourceLocationAttributeTestImpl(); - } + protected abstract Task SourceLocationAttributeTestImpl(); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs index f81d0029..0191a3db 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs @@ -3,239 +3,238 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class UnionDeclarationTest : PInvokeGeneratorTest { - public abstract class UnionDeclarationTest : PInvokeGeneratorTest - { - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTest(string nativeType, string expectedManagedType) => BasicTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTestInCMode(string nativeType, string expectedManagedType) => BasicTestInCModeImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) => BasicWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task BitfieldTest() => BitfieldTestImpl(); - - [Test] - public Task ExcludeTest() => ExcludeTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTypedefTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [TestCase("double *", "double*")] - [TestCase("short *", "short*")] - [TestCase("int *", "int*")] - [TestCase("float *", "float*")] - public Task FixedSizedBufferPointerTest(string nativeType, string expectedManagedType) => FixedSizedBufferPointerTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTypedefTestImpl(nativeType, expectedManagedType); - - [Test] - public Task GuidTest() => GuidTestImpl(); - - [TestCase("double", "double", 11, 5)] - [TestCase("short", "short", 11, 5)] - [TestCase("int", "int", 11, 5)] - [TestCase("float", "float", 11, 5)] - public Task NestedAnonymousTest(string nativeType, string expectedManagedType, int line, int column) => NestedAnonymousTestImpl(nativeType, expectedManagedType, line, column); - - [Test] - public Task NestedAnonymousWithBitfieldTest() => NestedAnonymousWithBitfieldTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task NestedTest(string nativeType, string expectedManagedType) => NestedTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task NestedWithNativeTypeNameTest(string nativeType, string expectedManagedType) => NestedWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task NewKeywordTest() => NewKeywordTestImpl(); + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task BasicTest(string nativeType, string expectedManagedType) => BasicTestImpl(nativeType, expectedManagedType); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task BasicTestInCMode(string nativeType, string expectedManagedType) => BasicTestInCModeImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) => BasicWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + + [Test] + public Task BitfieldTest() => BitfieldTestImpl(); + + [Test] + public Task ExcludeTest() => ExcludeTestImpl(); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTestImpl(nativeType, expectedManagedType); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTypedefTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + + [TestCase("double *", "double*")] + [TestCase("short *", "short*")] + [TestCase("int *", "int*")] + [TestCase("float *", "float*")] + public Task FixedSizedBufferPointerTest(string nativeType, string expectedManagedType) => FixedSizedBufferPointerTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTypedefTestImpl(nativeType, expectedManagedType); + + [Test] + public Task GuidTest() => GuidTestImpl(); + + [TestCase("double", "double", 11, 5)] + [TestCase("short", "short", 11, 5)] + [TestCase("int", "int", 11, 5)] + [TestCase("float", "float", 11, 5)] + public Task NestedAnonymousTest(string nativeType, string expectedManagedType, int line, int column) => NestedAnonymousTestImpl(nativeType, expectedManagedType, line, column); + + [Test] + public Task NestedAnonymousWithBitfieldTest() => NestedAnonymousWithBitfieldTestImpl(); + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task NestedTest(string nativeType, string expectedManagedType) => NestedTestImpl(nativeType, expectedManagedType); + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task NestedWithNativeTypeNameTest(string nativeType, string expectedManagedType) => NestedWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + + [Test] + public Task NewKeywordTest() => NewKeywordTestImpl(); - [Test] - public Task NoDefinitionTest() => NoDefinitionTestImpl(); + [Test] + public Task NoDefinitionTest() => NoDefinitionTestImpl(); - [Test] - public Task PointerToSelfTest() => PointerToSelfTestImpl(); + [Test] + public Task PointerToSelfTest() => PointerToSelfTestImpl(); - [Test] - public Task PointerToSelfViaTypedefTest() => PointerToSelfViaTypedefTestImpl(); + [Test] + public Task PointerToSelfViaTypedefTest() => PointerToSelfViaTypedefTestImpl(); - [Test] - public Task RemapTest() => RemapTestImpl(); + [Test] + public Task RemapTest() => RemapTestImpl(); - [Test] - public Task RemapNestedAnonymousTest() => RemapNestedAnonymousTestImpl(); + [Test] + public Task RemapNestedAnonymousTest() => RemapNestedAnonymousTestImpl(); - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task SkipNonDefinitionTest(string nativeType, string expectedManagedType) => SkipNonDefinitionTestImpl(nativeType, expectedManagedType); + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task SkipNonDefinitionTest(string nativeType, string expectedManagedType) => SkipNonDefinitionTestImpl(nativeType, expectedManagedType); - [Test] - public Task SkipNonDefinitionPointerTest() => SkipNonDefinitionPointerTestImpl(); + [Test] + public Task SkipNonDefinitionPointerTest() => SkipNonDefinitionPointerTestImpl(); - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task SkipNonDefinitionWithNativeTypeNameTest(string nativeType, string expectedManagedType) => SkipNonDefinitionWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task SkipNonDefinitionWithNativeTypeNameTest(string nativeType, string expectedManagedType) => SkipNonDefinitionWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task TypedefTest(string nativeType, string expectedManagedType) => TypedefTestImpl(nativeType, expectedManagedType); + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task TypedefTest(string nativeType, string expectedManagedType) => TypedefTestImpl(nativeType, expectedManagedType); - protected abstract Task BasicTestImpl(string nativeType, string expectedManagedType); + protected abstract Task BasicTestImpl(string nativeType, string expectedManagedType); - protected abstract Task BasicTestInCModeImpl(string nativeType, string expectedManagedType); + protected abstract Task BasicTestInCModeImpl(string nativeType, string expectedManagedType); - protected abstract Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task BitfieldTestImpl(); + protected abstract Task BitfieldTestImpl(); - protected abstract Task ExcludeTestImpl(); + protected abstract Task ExcludeTestImpl(); - protected abstract Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); - protected abstract Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); + protected abstract Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); - protected abstract Task GuidTestImpl(); + protected abstract Task GuidTestImpl(); - protected abstract Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column); + protected abstract Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column); - protected abstract Task NestedAnonymousWithBitfieldTestImpl(); + protected abstract Task NestedAnonymousWithBitfieldTestImpl(); - protected abstract Task NestedTestImpl(string nativeType, string expectedManagedType); + protected abstract Task NestedTestImpl(string nativeType, string expectedManagedType); - protected abstract Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task NewKeywordTestImpl(); + protected abstract Task NewKeywordTestImpl(); - protected abstract Task NoDefinitionTestImpl(); + protected abstract Task NoDefinitionTestImpl(); - protected abstract Task PointerToSelfTestImpl(); + protected abstract Task PointerToSelfTestImpl(); - protected abstract Task PointerToSelfViaTypedefTestImpl(); + protected abstract Task PointerToSelfViaTypedefTestImpl(); - protected abstract Task RemapTestImpl(); + protected abstract Task RemapTestImpl(); - protected abstract Task RemapNestedAnonymousTestImpl(); + protected abstract Task RemapNestedAnonymousTestImpl(); - protected abstract Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType); + protected abstract Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType); - protected abstract Task SkipNonDefinitionPointerTestImpl(); + protected abstract Task SkipNonDefinitionPointerTestImpl(); - protected abstract Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task TypedefTestImpl(string nativeType, string expectedManagedType); - } + protected abstract Task TypedefTestImpl(string nativeType, string expectedManagedType); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs index 97a12ea7..2fe6cacc 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs @@ -3,119 +3,118 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class VarDeclarationTest : PInvokeGeneratorTest { - public abstract class VarDeclarationTest : PInvokeGeneratorTest - { - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTest(string nativeType, string expectedManagedType) => BasicTestImpl(nativeType, expectedManagedType); + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task BasicTest(string nativeType, string expectedManagedType) => BasicTestImpl(nativeType, expectedManagedType); - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) => BasicWithNativeTypeNameTestImpl(nativeType, expectedManagedType); + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) => BasicWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - [Test] - public Task GuidMacroTest() => GuidMacroTestImpl(); + [Test] + public Task GuidMacroTest() => GuidMacroTestImpl(); - [TestCase("0", "int", "0")] - [TestCase("0U", "uint", "0U")] - [TestCase("0LL", "long", "0L")] - [TestCase("0ULL", "ulong", "0UL")] - [TestCase("0.0", "double", "0.0")] - [TestCase("0.f", "float", "0.0f")] - public Task MacroTest(string nativeValue, string expectedManagedType, string expectedManagedValue) => MacroTestImpl(nativeValue, expectedManagedType, expectedManagedValue); + [TestCase("0", "int", "0")] + [TestCase("0U", "uint", "0U")] + [TestCase("0LL", "long", "0L")] + [TestCase("0ULL", "ulong", "0UL")] + [TestCase("0.0", "double", "0.0")] + [TestCase("0.f", "float", "0.0f")] + public Task MacroTest(string nativeValue, string expectedManagedType, string expectedManagedValue) => MacroTestImpl(nativeValue, expectedManagedType, expectedManagedValue); - [Test] - public Task MultilineMacroTest() => MultilineMacroTestImpl(); + [Test] + public Task MultilineMacroTest() => MultilineMacroTestImpl(); - [TestCase("double")] - [TestCase("short")] - [TestCase("int")] - [TestCase("float")] - public Task NoInitializerTest(string nativeType) => NoInitializerTestImpl(nativeType); + [TestCase("double")] + [TestCase("short")] + [TestCase("int")] + [TestCase("float")] + public Task NoInitializerTest(string nativeType) => NoInitializerTestImpl(nativeType); - [Test] - public Task Utf8StringLiteralMacroTest() => Utf8StringLiteralMacroTestImpl(); + [Test] + public Task Utf8StringLiteralMacroTest() => Utf8StringLiteralMacroTestImpl(); - [Test] - public Task Utf16StringLiteralMacroTest() => Utf16StringLiteralMacroTestImpl(); + [Test] + public Task Utf16StringLiteralMacroTest() => Utf16StringLiteralMacroTestImpl(); - [Test] - public Task WideStringLiteralConstTest() => WideStringLiteralConstTestImpl(); + [Test] + public Task WideStringLiteralConstTest() => WideStringLiteralConstTestImpl(); - [Test] - public Task StringLiteralConstTest() => StringLiteralConstTestImpl(); + [Test] + public Task StringLiteralConstTest() => StringLiteralConstTestImpl(); - [Test] - public Task WideStringLiteralStaticConstTest() => WideStringLiteralStaticConstTestImpl(); + [Test] + public Task WideStringLiteralStaticConstTest() => WideStringLiteralStaticConstTestImpl(); - [Test] - public Task StringLiteralStaticConstTest() => StringLiteralStaticConstTestImpl(); + [Test] + public Task StringLiteralStaticConstTest() => StringLiteralStaticConstTestImpl(); - [Test] - public Task UncheckedConversionMacroTest() => UncheckedConversionMacroTestImpl(); + [Test] + public Task UncheckedConversionMacroTest() => UncheckedConversionMacroTestImpl(); - [Test] - public Task UncheckedFunctionLikeCastMacroTest() => UncheckedFunctionLikeCastMacroTestImpl(); + [Test] + public Task UncheckedFunctionLikeCastMacroTest() => UncheckedFunctionLikeCastMacroTestImpl(); - [Test] - public Task UncheckedConversionMacroTest2() => UncheckedConversionMacroTest2Impl(); + [Test] + public Task UncheckedConversionMacroTest2() => UncheckedConversionMacroTest2Impl(); - [Test] - public Task UncheckedPointerMacroTest() => UncheckedPointerMacroTestImpl(); + [Test] + public Task UncheckedPointerMacroTest() => UncheckedPointerMacroTestImpl(); - [Test] - public Task UncheckedReinterpretCastMacroTest() => UncheckedReinterpretCastMacroTestImpl(); + [Test] + public Task UncheckedReinterpretCastMacroTest() => UncheckedReinterpretCastMacroTestImpl(); - [Test] - public Task MultidimensionlArrayTest() => MultidimensionlArrayTestImpl(); + [Test] + public Task MultidimensionlArrayTest() => MultidimensionlArrayTestImpl(); - [Test] - public Task ConditionalDefineConstTest() => ConditionalDefineConstTestImpl(); + [Test] + public Task ConditionalDefineConstTest() => ConditionalDefineConstTestImpl(); - protected abstract Task BasicTestImpl(string nativeType, string expectedManagedType); + protected abstract Task BasicTestImpl(string nativeType, string expectedManagedType); - protected abstract Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); + protected abstract Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - protected abstract Task GuidMacroTestImpl(); + protected abstract Task GuidMacroTestImpl(); - protected abstract Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue); + protected abstract Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue); - protected abstract Task MultilineMacroTestImpl(); + protected abstract Task MultilineMacroTestImpl(); - protected abstract Task NoInitializerTestImpl(string nativeType); + protected abstract Task NoInitializerTestImpl(string nativeType); - protected abstract Task Utf8StringLiteralMacroTestImpl(); + protected abstract Task Utf8StringLiteralMacroTestImpl(); - protected abstract Task Utf16StringLiteralMacroTestImpl(); + protected abstract Task Utf16StringLiteralMacroTestImpl(); - protected abstract Task WideStringLiteralConstTestImpl(); + protected abstract Task WideStringLiteralConstTestImpl(); - protected abstract Task StringLiteralConstTestImpl(); + protected abstract Task StringLiteralConstTestImpl(); - protected abstract Task WideStringLiteralStaticConstTestImpl(); + protected abstract Task WideStringLiteralStaticConstTestImpl(); - protected abstract Task StringLiteralStaticConstTestImpl(); + protected abstract Task StringLiteralStaticConstTestImpl(); - protected abstract Task UncheckedConversionMacroTestImpl(); + protected abstract Task UncheckedConversionMacroTestImpl(); - protected abstract Task UncheckedFunctionLikeCastMacroTestImpl(); + protected abstract Task UncheckedFunctionLikeCastMacroTestImpl(); - protected abstract Task UncheckedConversionMacroTest2Impl(); + protected abstract Task UncheckedConversionMacroTest2Impl(); - protected abstract Task UncheckedPointerMacroTestImpl(); + protected abstract Task UncheckedPointerMacroTestImpl(); - protected abstract Task UncheckedReinterpretCastMacroTestImpl(); + protected abstract Task UncheckedReinterpretCastMacroTestImpl(); - protected abstract Task MultidimensionlArrayTestImpl(); + protected abstract Task MultidimensionlArrayTestImpl(); - protected abstract Task ConditionalDefineConstTestImpl(); - } + protected abstract Task ConditionalDefineConstTestImpl(); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs index fe522fff..83dcda73 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleUnix_CXXMethodDeclarationTest : CXXMethodDeclarationTest { - public sealed class CSharpCompatibleUnix_CXXMethodDeclarationTest : CXXMethodDeclarationTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -35,12 +35,12 @@ public MyStruct(int value) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -60,7 +60,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -90,12 +90,12 @@ public MyStruct(int x, int y, int z) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -106,7 +106,7 @@ operator int() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -120,12 +120,12 @@ public int ToInt32() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -133,7 +133,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -144,12 +144,12 @@ public void Dispose() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -164,21 +164,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -200,12 +200,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -236,7 +236,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -273,12 +273,12 @@ public static int MyFunctionB(MyStruct* x) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -289,7 +289,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -303,12 +303,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -326,7 +326,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -403,19 +403,19 @@ public int ToString(int obj) }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -460,26 +460,26 @@ public int GetType(int obj) }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -536,26 +536,26 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -621,12 +621,12 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -646,7 +646,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -673,12 +673,12 @@ public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -708,7 +708,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -745,12 +745,12 @@ public static MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -766,14 +766,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -795,12 +795,12 @@ public static int MyInt32Method() }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -811,7 +811,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -825,12 +825,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -840,7 +840,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -860,12 +860,12 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -880,7 +880,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -938,12 +938,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -958,7 +958,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1020,9 +1020,8 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs index 47fbdf50..35f7554e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleUnix_EnumDeclarationTest : EnumDeclarationTest { - public sealed class CSharpCompatibleUnix_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -28,12 +28,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -41,7 +41,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -52,12 +52,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -65,15 +65,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -81,7 +81,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public enum MyEnum : {expectedManagedType} {{ @@ -92,12 +92,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -105,7 +105,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ [NativeTypeName(""{nativeType}"")] public enum MyEnum : {expectedManagedType} @@ -117,12 +117,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum1 : int { MyEnum1_Value1, MyEnum1_Value2, @@ -157,7 +157,7 @@ namespace Namespace2 } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -189,13 +189,13 @@ public enum MyEnum4 } "; - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -206,7 +206,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; namespace ClangSharp.Test { @@ -223,16 +223,16 @@ public enum MyEnum2 } "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -243,7 +243,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -259,16 +259,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -279,7 +279,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -295,16 +295,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -315,7 +315,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test @@ -332,17 +332,17 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -350,7 +350,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -361,12 +361,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -378,7 +378,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -395,12 +395,12 @@ public enum MyEnum2 } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -408,7 +408,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -419,12 +419,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -432,7 +432,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -444,15 +444,15 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -460,7 +460,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -472,16 +472,16 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -492,7 +492,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum1 : uint @@ -508,16 +508,16 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -528,7 +528,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -543,12 +543,11 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationBodyImportTest.cs index af4a0dc0..437e9c89 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class CSharpCompatibleUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -28,17 +28,17 @@ public static int MyFunction(int* pData, int index) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -49,18 +49,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -72,18 +72,18 @@ public static int MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -95,18 +95,18 @@ public static bool MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -118,12 +118,12 @@ public static bool MyFunction(bool x, bool y) }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -134,7 +134,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -151,12 +151,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -166,7 +166,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -182,12 +182,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -197,7 +197,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -213,12 +213,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -238,7 +238,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -264,12 +264,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -285,7 +285,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -311,12 +311,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -331,7 +331,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; namespace ClangSharp.Test { @@ -352,18 +352,18 @@ public static int MyFunction(MyEnum x) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -375,12 +375,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -391,7 +391,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -408,18 +408,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -431,18 +431,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -454,18 +454,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -477,12 +477,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -495,7 +495,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -543,18 +543,18 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -566,18 +566,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -589,12 +589,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -603,7 +603,7 @@ int MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -618,12 +618,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -637,7 +637,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -657,12 +657,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -673,7 +673,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -692,12 +692,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -769,7 +769,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -838,12 +838,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -891,7 +891,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -960,12 +960,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -976,7 +976,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -993,12 +993,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1011,7 +1011,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1030,12 +1030,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1050,7 +1050,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1071,12 +1071,12 @@ public static int MyFunction(bool condition1, int a, int b, bool condition2, int } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1085,7 +1085,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1104,12 +1104,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1118,7 +1118,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1148,12 +1148,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1172,7 +1172,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1211,12 +1211,12 @@ public static MyStruct MyFunction2() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1232,7 +1232,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1254,12 +1254,12 @@ public static int MyFunction2(MyStruct* instance) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1269,7 +1269,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1286,18 +1286,18 @@ public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* l } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1309,18 +1309,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1332,18 +1332,18 @@ public static bool MyFunction() }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1355,18 +1355,18 @@ public static double MyFunction() }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1378,18 +1378,18 @@ public static float MyFunction() }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1401,18 +1401,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1424,12 +1424,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1441,7 +1441,7 @@ void MyFunction() } "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1481,12 +1481,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1500,7 +1500,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1523,12 +1523,12 @@ public static MyStruct MyFunction() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1540,7 +1540,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1558,12 +1558,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1577,7 +1577,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1603,18 +1603,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1626,18 +1626,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1649,18 +1649,18 @@ public static int MyFunction(int* value) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1672,18 +1672,18 @@ public static bool MyFunction(bool value) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1695,18 +1695,18 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1718,12 +1718,12 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1736,7 +1736,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1755,12 +1755,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1771,7 +1771,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1790,7 +1790,6 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs index d5b902be..de30ecd2 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs @@ -5,15 +5,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class CSharpCompatibleUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -25,14 +25,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -44,14 +44,14 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -64,24 +64,24 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -93,16 +93,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; + var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -114,12 +114,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -129,7 +129,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -141,14 +141,14 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -160,14 +160,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -179,18 +179,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -202,18 +202,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -225,14 +225,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -244,14 +244,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -266,17 +266,17 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -291,18 +291,18 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -317,19 +317,19 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -344,18 +344,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -370,18 +370,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -394,9 +394,8 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } + + protected override Task VarargsTestImpl() => Task.CompletedTask; } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionPointerDeclarationTest.cs index c3e95a45..a63ebae8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class CSharpCompatibleUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -31,19 +31,19 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -59,19 +59,19 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -87,7 +87,6 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs index 732379f3..f3a28042 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleUnix_StructDeclarationTest : StructDeclarationTest { - public sealed class CSharpCompatibleUnix_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -28,12 +28,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -41,7 +41,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -54,12 +54,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -67,7 +67,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -79,12 +79,12 @@ public partial struct MyStruct }} }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -92,7 +92,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -108,12 +108,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -138,7 +138,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1 { @@ -317,21 +317,21 @@ public uint o0_b1_1 } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -342,7 +342,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -375,12 +375,12 @@ public unsafe ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -391,7 +391,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -456,12 +456,12 @@ public unsafe ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -474,7 +474,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -507,12 +507,12 @@ public unsafe ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -523,7 +523,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -557,18 +557,18 @@ public unsafe ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -596,18 +596,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -617,18 +617,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -638,12 +638,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -651,7 +651,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -661,18 +661,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -685,7 +685,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -711,13 +711,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -736,7 +736,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -766,12 +766,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -790,7 +790,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -821,12 +821,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -866,7 +866,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1043,12 +1043,12 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1067,7 +1067,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1172,12 +1172,12 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1193,7 +1193,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1217,12 +1217,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1238,7 +1238,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1269,12 +1269,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1285,7 +1285,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1306,26 +1306,26 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ }} }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1344,16 +1344,16 @@ struct MyStruct2 { }; "; - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; + var usingStatement = "using System.Runtime.InteropServices;\n\n"; + var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } + if (!Environment.Is64BitProcess) + { + usingStatement = string.Empty; + packing = string.Empty; + } - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test + var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test {{ public unsafe partial struct MyStruct1 {{ @@ -1379,17 +1379,17 @@ public unsafe partial struct MyStruct1 }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1400,19 +1400,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1424,14 +1424,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1439,13 +1439,13 @@ public partial struct MyStruct }} "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1457,7 +1457,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1489,16 +1489,16 @@ public partial struct _Anonymous_e__Struct } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1508,7 +1508,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1521,16 +1521,16 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1538,12 +1538,12 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1553,7 +1553,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1569,12 +1569,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1584,7 +1584,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1600,12 +1600,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1616,7 +1616,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -1635,12 +1635,12 @@ public void MyMethod() } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1659,7 +1659,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { internal partial struct MyStruct1 { @@ -1684,18 +1684,18 @@ public partial struct MyStruct3 } "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1703,7 +1703,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @"namespace ClangSharp.Test + const string ExpectedOutputContents = @"namespace ClangSharp.Test { [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] public partial struct MyStruct @@ -1720,7 +1720,6 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs index 9ac32faa..fd48ec3e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleUnix_UnionDeclarationTest : UnionDeclarationTest { - public sealed class CSharpCompatibleUnix_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -38,12 +38,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -51,7 +51,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -69,12 +69,12 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -82,7 +82,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -104,12 +104,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -133,9 +133,9 @@ union MyUnion3 unsigned int o0_b1_1 : 1; }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -325,21 +325,21 @@ public uint o0_b1_1 }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -350,7 +350,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -389,12 +389,12 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -405,7 +405,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -476,12 +476,12 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -494,7 +494,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -533,12 +533,12 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -549,7 +549,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -589,18 +589,18 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -632,18 +632,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -657,18 +657,18 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -682,12 +682,12 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -695,7 +695,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -709,17 +709,17 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -732,7 +732,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -762,13 +762,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -789,7 +789,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -864,12 +864,12 @@ public unsafe partial struct _Anonymous_e__Union }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -888,7 +888,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1005,13 +1005,13 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1027,7 +1027,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1062,12 +1062,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1083,7 +1083,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1125,12 +1125,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1141,7 +1141,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1172,14 +1172,14 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1189,17 +1189,17 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1215,19 +1215,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1244,14 +1244,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1262,13 +1262,13 @@ public partial struct MyUnion }} "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1280,7 +1280,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1321,16 +1321,16 @@ public partial struct _Anonymous_e__Union } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1340,7 +1340,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1359,16 +1359,16 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1379,12 +1379,12 @@ public partial struct MyUnion } "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1394,7 +1394,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1416,12 +1416,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1431,7 +1431,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1453,7 +1453,6 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs index a348b68d..7ee90959 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleUnix_VarDeclarationTest : VarDeclarationTest { - public sealed class CSharpCompatibleUnix_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -20,14 +20,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -37,12 +37,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -52,7 +52,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -63,18 +63,18 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -87,15 +87,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -105,21 +105,21 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -131,14 +131,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -148,16 +148,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -173,16 +173,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -200,16 +200,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -225,16 +225,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -252,15 +252,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -275,14 +275,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -292,16 +292,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -313,15 +313,15 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -331,14 +331,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -348,14 +348,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -377,16 +377,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -395,9 +395,8 @@ public static partial class Methods }} }} "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs index c1cfce53..00d65f74 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleWindows_CXXMethodDeclarationTest : CXXMethodDeclarationTest { - public sealed class CSharpCompatibleWindows_CXXMethodDeclarationTest : CXXMethodDeclarationTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -35,12 +35,12 @@ public MyStruct(int value) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -60,7 +60,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -90,12 +90,12 @@ public MyStruct(int x, int y, int z) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -106,7 +106,7 @@ operator int() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -120,12 +120,12 @@ public int ToInt32() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -133,7 +133,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -144,12 +144,12 @@ public void Dispose() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -164,21 +164,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -200,12 +200,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -236,7 +236,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -273,12 +273,12 @@ public static int MyFunctionB(MyStruct* x) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -289,7 +289,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -303,12 +303,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -326,7 +326,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -403,19 +403,19 @@ public int ToString(int obj) }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -460,26 +460,26 @@ public int GetType(int obj) }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -536,26 +536,26 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -621,12 +621,12 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -646,7 +646,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -673,12 +673,12 @@ public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -708,7 +708,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -745,12 +745,12 @@ public static MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -766,14 +766,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -795,12 +795,12 @@ public static int MyInt32Method() }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -811,7 +811,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -825,12 +825,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -840,7 +840,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -860,12 +860,12 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -880,7 +880,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -938,12 +938,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -958,7 +958,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1020,9 +1020,8 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs index 19ece968..fcb6938a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleWindows_EnumDeclarationTest : EnumDeclarationTest { - public sealed class CSharpCompatibleWindows_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -28,12 +28,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -41,7 +41,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -52,12 +52,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -65,15 +65,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -81,7 +81,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public enum MyEnum : {expectedManagedType} {{ @@ -92,12 +92,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -105,7 +105,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ [NativeTypeName(""{nativeType}"")] public enum MyEnum : {expectedManagedType} @@ -117,12 +117,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum1 : int { MyEnum1_Value1, MyEnum1_Value2, @@ -157,7 +157,7 @@ namespace Namespace2 } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -189,13 +189,13 @@ public enum MyEnum4 } "; - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -206,7 +206,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; namespace ClangSharp.Test { @@ -223,16 +223,16 @@ public enum MyEnum2 } "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -243,7 +243,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -259,16 +259,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -279,7 +279,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -295,16 +295,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -315,7 +315,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test @@ -332,17 +332,17 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -350,7 +350,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -361,12 +361,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -378,7 +378,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -395,12 +395,12 @@ public enum MyEnum2 } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -408,7 +408,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -419,12 +419,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -432,7 +432,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -444,15 +444,15 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -460,7 +460,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -472,16 +472,16 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -492,7 +492,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum1 : uint @@ -508,16 +508,16 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -528,7 +528,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -543,12 +543,11 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationBodyImportTest.cs index 4645196d..9d3828dc 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class CSharpCompatibleWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -28,17 +28,17 @@ public static int MyFunction(int* pData, int index) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -49,18 +49,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -72,18 +72,18 @@ public static int MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -95,18 +95,18 @@ public static bool MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -118,12 +118,12 @@ public static bool MyFunction(bool x, bool y) }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -134,7 +134,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -151,12 +151,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -166,7 +166,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -182,12 +182,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -197,7 +197,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -213,12 +213,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -238,7 +238,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -264,12 +264,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -285,7 +285,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -311,12 +311,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -331,7 +331,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; namespace ClangSharp.Test { @@ -352,18 +352,18 @@ public static int MyFunction(MyEnum x) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -375,12 +375,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -391,7 +391,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -408,18 +408,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -431,18 +431,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -454,18 +454,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -477,12 +477,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -495,7 +495,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -543,18 +543,18 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -566,18 +566,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -589,12 +589,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -603,7 +603,7 @@ int MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -618,12 +618,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -637,7 +637,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -657,12 +657,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -673,7 +673,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -692,12 +692,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -769,7 +769,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -838,12 +838,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -891,7 +891,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -960,12 +960,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -976,7 +976,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -993,12 +993,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1011,7 +1011,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1030,12 +1030,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1050,7 +1050,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1071,12 +1071,12 @@ public static int MyFunction(bool condition1, int a, int b, bool condition2, int } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1085,7 +1085,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1104,12 +1104,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1118,7 +1118,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1148,12 +1148,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1172,7 +1172,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1211,12 +1211,12 @@ public static MyStruct MyFunction2() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1232,7 +1232,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1254,12 +1254,12 @@ public static int MyFunction2(MyStruct* instance) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1269,7 +1269,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1286,18 +1286,18 @@ public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* l } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1309,18 +1309,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1332,18 +1332,18 @@ public static bool MyFunction() }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1355,18 +1355,18 @@ public static double MyFunction() }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1378,18 +1378,18 @@ public static float MyFunction() }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1401,18 +1401,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1424,12 +1424,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1441,7 +1441,7 @@ void MyFunction() } "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1481,12 +1481,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1500,7 +1500,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1523,12 +1523,12 @@ public static MyStruct MyFunction() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1540,7 +1540,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1558,12 +1558,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1577,7 +1577,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1603,18 +1603,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1626,18 +1626,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1649,18 +1649,18 @@ public static int MyFunction(int* value) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1672,18 +1672,18 @@ public static bool MyFunction(bool value) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1695,18 +1695,18 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1718,12 +1718,12 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1736,7 +1736,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1755,12 +1755,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1771,7 +1771,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1790,7 +1790,6 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs index 5991bd3c..8844419b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class CSharpCompatibleWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -24,14 +24,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -43,14 +43,14 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -63,24 +63,24 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -92,16 +92,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; + var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -113,12 +113,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -128,7 +128,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -140,14 +140,14 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -159,14 +159,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -178,18 +178,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -201,18 +201,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -224,14 +224,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -243,14 +243,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -265,17 +265,17 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -290,18 +290,18 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -316,19 +316,19 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -343,18 +343,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -369,18 +369,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -393,14 +393,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); + } - protected override Task VarargsTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; + protected override Task VarargsTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; + const string ExpectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -412,7 +412,6 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionPointerDeclarationTest.cs index 2330c0a0..37511696 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class CSharpCompatibleWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -31,19 +31,19 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -59,19 +59,19 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -87,7 +87,6 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs index 6a040e37..4c24c34e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleWindows_StructDeclarationTest : StructDeclarationTest { - public sealed class CSharpCompatibleWindows_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -28,12 +28,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -41,7 +41,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -54,12 +54,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -67,7 +67,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -79,12 +79,12 @@ public partial struct MyStruct }} }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -92,7 +92,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -108,12 +108,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -138,7 +138,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1 { @@ -321,21 +321,21 @@ public uint o0_b1_1 } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -346,7 +346,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -379,12 +379,12 @@ public unsafe ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -395,7 +395,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -460,12 +460,12 @@ public unsafe ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -478,7 +478,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -511,12 +511,12 @@ public unsafe ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -527,7 +527,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -561,18 +561,18 @@ public unsafe ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -600,18 +600,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -621,18 +621,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -642,12 +642,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -655,7 +655,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -665,18 +665,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -689,7 +689,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -715,13 +715,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -740,7 +740,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -770,12 +770,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -794,7 +794,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -825,12 +825,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -870,7 +870,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1047,12 +1047,12 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1071,7 +1071,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1176,12 +1176,12 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1197,7 +1197,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1221,12 +1221,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1242,7 +1242,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1273,12 +1273,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1289,7 +1289,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1310,26 +1310,26 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ }} }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1348,16 +1348,16 @@ struct MyStruct2 { }; "; - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; + var usingStatement = "using System.Runtime.InteropServices;\n\n"; + var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } + if (!Environment.Is64BitProcess) + { + usingStatement = string.Empty; + packing = string.Empty; + } - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test + var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test {{ public unsafe partial struct MyStruct1 {{ @@ -1383,17 +1383,17 @@ public unsafe partial struct MyStruct1 }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1404,19 +1404,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1428,14 +1428,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1443,13 +1443,13 @@ public partial struct MyStruct }} "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1461,7 +1461,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1493,16 +1493,16 @@ public partial struct _Anonymous_e__Struct } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1512,7 +1512,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1525,16 +1525,16 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1542,12 +1542,12 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1557,7 +1557,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1573,12 +1573,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1588,7 +1588,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1604,12 +1604,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1620,7 +1620,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -1639,12 +1639,12 @@ public void MyMethod() } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1663,7 +1663,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { internal partial struct MyStruct1 { @@ -1688,18 +1688,18 @@ public partial struct MyStruct3 } "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1707,7 +1707,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @"namespace ClangSharp.Test + const string ExpectedOutputContents = @"namespace ClangSharp.Test { [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] public partial struct MyStruct @@ -1724,7 +1724,6 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs index 6fd56189..3a520b73 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleWindows_UnionDeclarationTest : UnionDeclarationTest { - public sealed class CSharpCompatibleWindows_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -38,12 +38,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -51,7 +51,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -69,12 +69,12 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -82,7 +82,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -104,12 +104,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -134,9 +134,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -332,21 +332,21 @@ public uint o0_b1_1 }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -357,7 +357,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -396,12 +396,12 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -412,7 +412,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -483,12 +483,12 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -501,7 +501,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -540,12 +540,12 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -556,7 +556,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -596,18 +596,18 @@ public unsafe ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -639,18 +639,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -664,18 +664,18 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -689,12 +689,12 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -702,7 +702,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -716,17 +716,17 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -739,7 +739,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -769,13 +769,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -796,7 +796,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -871,12 +871,12 @@ public unsafe partial struct _Anonymous_e__Union }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -895,7 +895,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1012,13 +1012,13 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1034,7 +1034,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1069,12 +1069,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1090,7 +1090,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1132,12 +1132,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1148,7 +1148,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1179,14 +1179,14 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1196,17 +1196,17 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1222,19 +1222,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1251,14 +1251,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1269,13 +1269,13 @@ public partial struct MyUnion }} "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1287,7 +1287,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1328,16 +1328,16 @@ public partial struct _Anonymous_e__Union } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1347,7 +1347,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1366,16 +1366,16 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1386,12 +1386,12 @@ public partial struct MyUnion } "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1401,7 +1401,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1423,12 +1423,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1438,7 +1438,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1460,7 +1460,6 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs index f639fcbb..334ecc34 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpCompatibleWindows_VarDeclarationTest : VarDeclarationTest { - public sealed class CSharpCompatibleWindows_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -20,14 +20,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -37,12 +37,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -52,7 +52,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -63,18 +63,18 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -87,15 +87,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -105,21 +105,21 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -131,14 +131,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -148,16 +148,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -173,16 +173,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -200,16 +200,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -225,16 +225,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -252,15 +252,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -273,14 +273,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -290,16 +290,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -309,15 +309,15 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -327,14 +327,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -344,14 +344,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -373,16 +373,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -391,9 +391,8 @@ public static partial class Methods }} }} "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs index eef855e4..1246574a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestUnix_CXXMethodDeclarationTest : CXXMethodDeclarationTest { - public sealed class CSharpLatestUnix_CXXMethodDeclarationTest : CXXMethodDeclarationTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -35,12 +35,12 @@ public MyStruct(int value) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -60,7 +60,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -90,12 +90,12 @@ public MyStruct(int x, int y, int z) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -106,7 +106,7 @@ operator int() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -120,12 +120,12 @@ public int ToInt32() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -133,7 +133,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -144,12 +144,12 @@ public void Dispose() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -164,21 +164,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -200,12 +200,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -236,7 +236,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -273,12 +273,12 @@ public static int MyFunctionB(MyStruct* x) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -289,7 +289,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -303,12 +303,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -326,7 +326,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -403,19 +403,19 @@ public int ToString(int obj) }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -441,26 +441,26 @@ public int GetType(int obj) }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -498,26 +498,26 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -565,12 +565,12 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -590,7 +590,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -617,12 +617,12 @@ public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -652,7 +652,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -689,12 +689,12 @@ public static MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -710,14 +710,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -739,12 +739,12 @@ public static int MyInt32Method() }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -755,7 +755,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -769,12 +769,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -784,7 +784,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -804,12 +804,12 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -824,7 +824,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -856,12 +856,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -876,7 +876,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -912,9 +912,8 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs index dd8f831d..4aa0b602 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestUnix_EnumDeclarationTest : EnumDeclarationTest { - public sealed class CSharpLatestUnix_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -28,12 +28,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -41,7 +41,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -52,12 +52,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -65,15 +65,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -81,7 +81,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public enum MyEnum : {expectedManagedType} {{ @@ -92,12 +92,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -105,7 +105,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ [NativeTypeName(""{nativeType}"")] public enum MyEnum : {expectedManagedType} @@ -117,12 +117,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum1 : int { MyEnum1_Value1, MyEnum1_Value2, @@ -157,7 +157,7 @@ namespace Namespace2 } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -189,13 +189,13 @@ public enum MyEnum4 } "; - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -206,7 +206,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; namespace ClangSharp.Test { @@ -223,16 +223,16 @@ public enum MyEnum2 } "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -243,7 +243,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -259,16 +259,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -279,7 +279,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -295,16 +295,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -315,7 +315,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test @@ -332,17 +332,17 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -350,7 +350,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -361,12 +361,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -378,7 +378,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -395,12 +395,12 @@ public enum MyEnum2 } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -408,7 +408,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -419,12 +419,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -432,7 +432,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -444,15 +444,15 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -460,7 +460,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -472,16 +472,16 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -492,7 +492,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum1 : uint @@ -508,16 +508,16 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -528,7 +528,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -543,12 +543,11 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationBodyImportTest.cs index 49ba29a0..e1a9d5f8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class CSharpLatestUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -28,17 +28,17 @@ public static int MyFunction(int* pData, int index) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -49,18 +49,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -72,18 +72,18 @@ public static int MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -95,18 +95,18 @@ public static bool MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -118,12 +118,12 @@ public static bool MyFunction(bool x, bool y) }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -134,7 +134,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -151,12 +151,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -166,7 +166,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -182,12 +182,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -197,7 +197,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -213,12 +213,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -238,7 +238,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -264,12 +264,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -285,7 +285,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -311,12 +311,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -331,7 +331,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; namespace ClangSharp.Test { @@ -352,18 +352,18 @@ public static int MyFunction(MyEnum x) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -375,12 +375,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -391,7 +391,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -408,18 +408,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -431,18 +431,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -454,18 +454,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -477,12 +477,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -495,7 +495,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -530,18 +530,18 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -553,18 +553,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -576,12 +576,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -590,7 +590,7 @@ int MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -605,12 +605,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -624,7 +624,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -644,12 +644,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -660,7 +660,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -679,12 +679,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -756,7 +756,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -825,12 +825,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -878,7 +878,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -947,12 +947,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -963,7 +963,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -980,12 +980,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -998,7 +998,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1017,12 +1017,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1037,7 +1037,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1058,12 +1058,12 @@ public static int MyFunction(bool condition1, int a, int b, bool condition2, int } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1072,7 +1072,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1091,12 +1091,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1105,7 +1105,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1135,12 +1135,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1159,7 +1159,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1198,12 +1198,12 @@ public static MyStruct MyFunction2() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1219,7 +1219,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1241,12 +1241,12 @@ public static int MyFunction2(MyStruct* instance) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1256,7 +1256,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1273,18 +1273,18 @@ public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* l } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1296,18 +1296,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1319,18 +1319,18 @@ public static bool MyFunction() }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1342,18 +1342,18 @@ public static double MyFunction() }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1365,18 +1365,18 @@ public static float MyFunction() }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1388,18 +1388,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1411,12 +1411,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1428,7 +1428,7 @@ void MyFunction() } "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1465,12 +1465,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1484,7 +1484,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1507,12 +1507,12 @@ public static MyStruct MyFunction() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1524,7 +1524,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1542,12 +1542,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1561,7 +1561,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1587,18 +1587,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1610,18 +1610,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1633,18 +1633,18 @@ public static int MyFunction(int* value) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1656,18 +1656,18 @@ public static bool MyFunction(bool value) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1679,18 +1679,18 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1702,12 +1702,12 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1720,7 +1720,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1739,12 +1739,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1755,7 +1755,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1774,7 +1774,6 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs index 759d4372..36c87a42 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class CSharpLatestUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -24,14 +24,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -43,14 +43,14 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -62,24 +62,24 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -91,16 +91,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; + var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -112,12 +112,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -127,7 +127,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -139,14 +139,14 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -158,14 +158,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -177,18 +177,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -200,18 +200,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -223,14 +223,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -242,14 +242,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -264,17 +264,17 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -289,18 +289,18 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -315,19 +315,19 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -342,18 +342,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -368,18 +368,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -392,9 +392,8 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } + + protected override Task VarargsTestImpl() => Task.CompletedTask; } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionPointerDeclarationTest.cs index 7d54bafe..b9c5747b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class CSharpLatestUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -25,19 +25,19 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -47,19 +47,19 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -69,7 +69,6 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs index 86e60f59..20c14a57 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestUnix_StructDeclarationTest : StructDeclarationTest { - public sealed class CSharpLatestUnix_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -28,12 +28,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -41,7 +41,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -54,12 +54,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -67,7 +67,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -79,12 +79,12 @@ public partial struct MyStruct }} }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -92,7 +92,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -108,12 +108,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -138,7 +138,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1 { @@ -317,21 +317,21 @@ public uint o0_b1_1 } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -342,7 +342,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -377,12 +377,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -393,7 +393,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -460,12 +460,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -478,7 +478,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -513,12 +513,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -529,7 +529,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -565,18 +565,18 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -604,18 +604,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -625,18 +625,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -646,12 +646,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -659,7 +659,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -669,18 +669,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -693,7 +693,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -719,13 +719,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -744,7 +744,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -774,12 +774,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -798,7 +798,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -829,12 +829,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -874,7 +874,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1027,12 +1027,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1051,7 +1051,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1152,12 +1152,12 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1173,7 +1173,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1197,12 +1197,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1218,7 +1218,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1249,12 +1249,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1265,7 +1265,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1286,26 +1286,26 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ }} }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1324,16 +1324,16 @@ struct MyStruct2 { }; "; - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; + var usingStatement = "using System.Runtime.InteropServices;\n\n"; + var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } + if (!Environment.Is64BitProcess) + { + usingStatement = string.Empty; + packing = string.Empty; + } - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test + var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test {{ public unsafe partial struct MyStruct1 {{ @@ -1359,17 +1359,17 @@ public unsafe partial struct MyStruct1 }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1380,19 +1380,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1404,14 +1404,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1419,13 +1419,13 @@ public partial struct MyStruct }} "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1437,7 +1437,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1468,16 +1468,16 @@ public partial struct _Anonymous_e__Struct } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1487,7 +1487,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1500,16 +1500,16 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1517,12 +1517,12 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1532,7 +1532,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1548,12 +1548,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1563,7 +1563,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1579,12 +1579,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1595,7 +1595,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -1614,12 +1614,12 @@ public void MyMethod() } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1638,7 +1638,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { internal partial struct MyStruct1 { @@ -1663,18 +1663,18 @@ public partial struct MyStruct3 } "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1682,7 +1682,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @"namespace ClangSharp.Test + const string ExpectedOutputContents = @"namespace ClangSharp.Test { [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] public partial struct MyStruct @@ -1699,7 +1699,6 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs index 3265521f..1b8019ed 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestUnix_UnionDeclarationTest : UnionDeclarationTest { - public sealed class CSharpLatestUnix_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -38,12 +38,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -51,7 +51,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -69,12 +69,12 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -82,7 +82,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -104,12 +104,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -134,9 +134,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -326,21 +326,21 @@ public uint o0_b1_1 }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -351,7 +351,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -390,12 +390,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -406,7 +406,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -477,12 +477,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -495,7 +495,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -534,12 +534,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -550,7 +550,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -590,18 +590,18 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -633,18 +633,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -658,18 +658,18 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -683,12 +683,12 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -696,7 +696,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -710,17 +710,17 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -733,7 +733,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -763,13 +763,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -790,7 +790,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -857,12 +857,12 @@ public unsafe partial struct _Anonymous_e__Union }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -881,7 +881,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -992,13 +992,13 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1014,7 +1014,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1049,12 +1049,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1070,7 +1070,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1112,12 +1112,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1128,7 +1128,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1159,14 +1159,14 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1176,17 +1176,17 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1202,19 +1202,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1231,14 +1231,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1249,13 +1249,13 @@ public partial struct MyUnion }} "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1267,7 +1267,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1305,16 +1305,16 @@ public partial struct _Anonymous_e__Union } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1324,7 +1324,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1343,16 +1343,16 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1363,12 +1363,12 @@ public partial struct MyUnion } "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1378,7 +1378,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1400,12 +1400,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1415,7 +1415,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1437,7 +1437,6 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs index 69d070b2..8e552790 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestUnix_VarDeclarationTest : VarDeclarationTest { - public sealed class CSharpLatestUnix_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -20,14 +20,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -37,12 +37,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -52,7 +52,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -63,18 +63,18 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -87,15 +87,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -105,21 +105,21 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -131,14 +131,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -148,16 +148,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -173,16 +173,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -200,16 +200,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -225,16 +225,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -252,15 +252,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -273,14 +273,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -290,16 +290,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -309,15 +309,15 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -327,14 +327,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -344,14 +344,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -373,16 +373,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -391,9 +391,8 @@ public static partial class Methods }} }} "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs index e120f1d0..461f1893 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestWindows_CXXMethodDeclarationTest : CXXMethodDeclarationTest { - public sealed class CSharpLatestWindows_CXXMethodDeclarationTest : CXXMethodDeclarationTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -35,12 +35,12 @@ public MyStruct(int value) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -60,7 +60,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -90,12 +90,12 @@ public MyStruct(int x, int y, int z) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -106,7 +106,7 @@ operator int() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -120,12 +120,12 @@ public int ToInt32() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -133,7 +133,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -144,12 +144,12 @@ public void Dispose() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -164,21 +164,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -200,12 +200,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -236,7 +236,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -273,12 +273,12 @@ public static int MyFunctionB(MyStruct* x) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -289,7 +289,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -303,12 +303,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -326,7 +326,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -403,19 +403,19 @@ public int ToString(int obj) }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -441,26 +441,26 @@ public int GetType(int obj) }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -498,26 +498,26 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -565,12 +565,12 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -590,7 +590,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -617,12 +617,12 @@ public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -652,7 +652,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -689,12 +689,12 @@ public static MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -710,14 +710,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -739,12 +739,12 @@ public static int MyInt32Method() }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -755,7 +755,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -769,12 +769,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -784,7 +784,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -804,12 +804,12 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -824,7 +824,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -856,12 +856,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -876,7 +876,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -912,9 +912,8 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs index 55970cb4..c2f9afe1 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestWindows_EnumDeclarationTest : EnumDeclarationTest { - public sealed class CSharpLatestWindows_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -28,12 +28,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -41,7 +41,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -52,12 +52,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -65,15 +65,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -81,7 +81,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public enum MyEnum : {expectedManagedType} {{ @@ -92,12 +92,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -105,7 +105,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ [NativeTypeName(""{nativeType}"")] public enum MyEnum : {expectedManagedType} @@ -117,12 +117,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum1 : int { MyEnum1_Value1, MyEnum1_Value2, @@ -157,7 +157,7 @@ namespace Namespace2 } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -189,13 +189,13 @@ public enum MyEnum4 } "; - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -206,7 +206,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; namespace ClangSharp.Test { @@ -223,16 +223,16 @@ public enum MyEnum2 } "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -243,7 +243,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -259,16 +259,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -279,7 +279,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -295,16 +295,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -315,7 +315,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test @@ -332,17 +332,17 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -350,7 +350,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -361,12 +361,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -378,7 +378,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -395,12 +395,12 @@ public enum MyEnum2 } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -408,7 +408,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -419,12 +419,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -432,7 +432,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -444,15 +444,15 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -460,7 +460,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -472,16 +472,16 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -492,7 +492,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum1 : uint @@ -508,16 +508,16 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -528,7 +528,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -543,12 +543,11 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationBodyImportTest.cs index 5b784c32..7f40760f 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class CSharpLatestWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -28,17 +28,17 @@ public static int MyFunction(int* pData, int index) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -49,18 +49,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -72,18 +72,18 @@ public static int MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -95,18 +95,18 @@ public static bool MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -118,12 +118,12 @@ public static bool MyFunction(bool x, bool y) }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -134,7 +134,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -151,12 +151,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -166,7 +166,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -182,12 +182,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -197,7 +197,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -213,12 +213,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -238,7 +238,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -264,12 +264,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -285,7 +285,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -311,12 +311,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -331,7 +331,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; namespace ClangSharp.Test { @@ -352,18 +352,18 @@ public static int MyFunction(MyEnum x) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -375,12 +375,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -391,7 +391,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -408,18 +408,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -431,18 +431,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -454,18 +454,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -477,12 +477,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -495,7 +495,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -530,18 +530,18 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -553,18 +553,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -576,12 +576,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -590,7 +590,7 @@ int MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -605,12 +605,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -624,7 +624,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -644,12 +644,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -660,7 +660,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -679,12 +679,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -756,7 +756,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -825,12 +825,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -878,7 +878,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -947,12 +947,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -963,7 +963,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -980,12 +980,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -998,7 +998,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1017,12 +1017,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1037,7 +1037,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1058,12 +1058,12 @@ public static int MyFunction(bool condition1, int a, int b, bool condition2, int } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1072,7 +1072,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1091,12 +1091,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1105,7 +1105,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1135,12 +1135,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1159,7 +1159,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1198,12 +1198,12 @@ public static MyStruct MyFunction2() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1219,7 +1219,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1241,12 +1241,12 @@ public static int MyFunction2(MyStruct* instance) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1256,7 +1256,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1273,18 +1273,18 @@ public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* l } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1296,18 +1296,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1319,18 +1319,18 @@ public static bool MyFunction() }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1342,18 +1342,18 @@ public static double MyFunction() }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1365,18 +1365,18 @@ public static float MyFunction() }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1388,18 +1388,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1411,12 +1411,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1428,7 +1428,7 @@ void MyFunction() } "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1465,12 +1465,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1484,7 +1484,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1507,12 +1507,12 @@ public static MyStruct MyFunction() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1524,7 +1524,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1542,12 +1542,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1561,7 +1561,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1587,18 +1587,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1610,18 +1610,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1633,18 +1633,18 @@ public static int MyFunction(int* value) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1656,18 +1656,18 @@ public static bool MyFunction(bool value) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1679,18 +1679,18 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1702,12 +1702,12 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1720,7 +1720,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1739,12 +1739,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1755,7 +1755,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1774,7 +1774,6 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs index 8ef3e790..e6c80b83 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class CSharpLatestWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -24,14 +24,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -43,14 +43,14 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -62,24 +62,24 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -91,16 +91,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; + var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -112,12 +112,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -127,7 +127,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -139,14 +139,14 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -158,14 +158,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -177,18 +177,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -200,18 +200,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -223,14 +223,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -242,14 +242,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -264,17 +264,17 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -289,18 +289,18 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -315,19 +315,19 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -342,18 +342,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -368,18 +368,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -392,14 +392,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); + } - protected override Task VarargsTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; + protected override Task VarargsTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; + const string ExpectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -411,7 +411,6 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionPointerDeclarationTest.cs index 79583040..2f83c559 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class CSharpLatestWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -25,19 +25,19 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -47,19 +47,19 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -69,7 +69,6 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs index 6890acaf..26379efc 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestWindows_StructDeclarationTest : StructDeclarationTest { - public sealed class CSharpLatestWindows_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -28,12 +28,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -41,7 +41,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -54,12 +54,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -67,7 +67,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -79,12 +79,12 @@ public partial struct MyStruct }} }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -92,7 +92,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -108,12 +108,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -138,7 +138,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1 { @@ -321,21 +321,21 @@ public uint o0_b1_1 } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -346,7 +346,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -381,12 +381,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -397,7 +397,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -464,12 +464,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -482,7 +482,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -517,12 +517,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -533,7 +533,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -569,18 +569,18 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -608,18 +608,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -629,18 +629,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -650,12 +650,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -663,7 +663,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -673,18 +673,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -697,7 +697,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -723,13 +723,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -748,7 +748,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -778,12 +778,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -802,7 +802,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -833,12 +833,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -878,7 +878,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1031,12 +1031,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1055,7 +1055,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1156,12 +1156,12 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1177,7 +1177,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1201,12 +1201,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1222,7 +1222,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1253,12 +1253,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1269,7 +1269,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1290,26 +1290,26 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ }} }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1328,16 +1328,16 @@ struct MyStruct2 { }; "; - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; + var usingStatement = "using System.Runtime.InteropServices;\n\n"; + var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } + if (!Environment.Is64BitProcess) + { + usingStatement = string.Empty; + packing = string.Empty; + } - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test + var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test {{ public unsafe partial struct MyStruct1 {{ @@ -1363,17 +1363,17 @@ public unsafe partial struct MyStruct1 }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1384,19 +1384,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1408,14 +1408,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1423,13 +1423,13 @@ public partial struct MyStruct }} "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1441,7 +1441,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1472,16 +1472,16 @@ public partial struct _Anonymous_e__Struct } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1491,7 +1491,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1504,16 +1504,16 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1521,12 +1521,12 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1536,7 +1536,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1552,12 +1552,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1567,7 +1567,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1583,12 +1583,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1599,7 +1599,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -1618,12 +1618,12 @@ public void MyMethod() } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1642,7 +1642,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { internal partial struct MyStruct1 { @@ -1667,18 +1667,18 @@ public partial struct MyStruct3 } "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1686,7 +1686,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @"namespace ClangSharp.Test + const string ExpectedOutputContents = @"namespace ClangSharp.Test { [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] public partial struct MyStruct @@ -1703,7 +1703,6 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs index 7a59f5f0..054c131f 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestWindows_UnionDeclarationTest : UnionDeclarationTest { - public sealed class CSharpLatestWindows_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -38,12 +38,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -51,7 +51,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -69,12 +69,12 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -82,7 +82,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -104,12 +104,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -134,9 +134,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -332,21 +332,21 @@ public uint o0_b1_1 }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -357,7 +357,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -396,12 +396,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -412,7 +412,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -483,12 +483,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -501,7 +501,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -540,12 +540,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -556,7 +556,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -596,18 +596,18 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -639,18 +639,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -664,18 +664,18 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -689,12 +689,12 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -702,7 +702,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -716,17 +716,17 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -739,7 +739,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -769,13 +769,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -796,7 +796,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -863,12 +863,12 @@ public unsafe partial struct _Anonymous_e__Union }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -887,7 +887,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -998,13 +998,13 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1020,7 +1020,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1055,12 +1055,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1076,7 +1076,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1118,12 +1118,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1134,7 +1134,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1165,14 +1165,14 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1182,17 +1182,17 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1208,19 +1208,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1237,14 +1237,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1255,13 +1255,13 @@ public partial struct MyUnion }} "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1273,7 +1273,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1311,16 +1311,16 @@ public partial struct _Anonymous_e__Union } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1330,7 +1330,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1349,16 +1349,16 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1369,12 +1369,12 @@ public partial struct MyUnion } "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1384,7 +1384,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1406,12 +1406,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1421,7 +1421,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1443,7 +1443,6 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs index 2713128a..12a5368d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpLatestWindows_VarDeclarationTest : VarDeclarationTest { - public sealed class CSharpLatestWindows_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -20,14 +20,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -37,12 +37,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -52,7 +52,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -63,18 +63,18 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -87,15 +87,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -105,21 +105,21 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -131,14 +131,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -148,16 +148,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -173,16 +173,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -200,16 +200,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -225,16 +225,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -252,15 +252,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -273,14 +273,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -290,16 +290,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -309,15 +309,15 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -327,14 +327,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -344,14 +344,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -373,16 +373,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -391,9 +391,8 @@ public static partial class Methods }} }} "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs index 12819549..090fabfb 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewUnix_CXXMethodDeclarationTest : CXXMethodDeclarationTest { - public sealed class CSharpPreviewUnix_CXXMethodDeclarationTest : CXXMethodDeclarationTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -35,12 +35,12 @@ public MyStruct(int value) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -60,7 +60,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -90,12 +90,12 @@ public MyStruct(int x, int y, int z) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -106,7 +106,7 @@ operator int() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -120,12 +120,12 @@ public int ToInt32() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -133,7 +133,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -144,12 +144,12 @@ public void Dispose() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -164,21 +164,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -200,12 +200,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -236,7 +236,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -273,12 +273,12 @@ public static int MyFunctionB(MyStruct* x) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -289,7 +289,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -303,12 +303,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -326,7 +326,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -403,19 +403,19 @@ public int ToString(int obj) }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -441,26 +441,26 @@ public int GetType(int obj) }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -498,26 +498,26 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -565,12 +565,12 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -590,7 +590,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -617,12 +617,12 @@ public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -652,7 +652,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -689,12 +689,12 @@ public static MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -710,14 +710,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -739,12 +739,12 @@ public static int MyInt32Method() }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -755,7 +755,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -769,12 +769,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -784,7 +784,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -804,12 +804,12 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -824,7 +824,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -856,12 +856,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -876,7 +876,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -912,9 +912,8 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs index ff9c8cb8..de68287b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewUnix_EnumDeclarationTest : EnumDeclarationTest { - public sealed class CSharpPreviewUnix_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -28,12 +28,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -41,7 +41,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -52,12 +52,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -65,15 +65,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -81,7 +81,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public enum MyEnum : {expectedManagedType} {{ @@ -92,12 +92,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -105,7 +105,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ [NativeTypeName(""{nativeType}"")] public enum MyEnum : {expectedManagedType} @@ -117,12 +117,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum1 : int { MyEnum1_Value1, MyEnum1_Value2, @@ -157,7 +157,7 @@ namespace Namespace2 } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -189,13 +189,13 @@ public enum MyEnum4 } "; - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -206,7 +206,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; namespace ClangSharp.Test { @@ -223,16 +223,16 @@ public enum MyEnum2 } "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -243,7 +243,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -259,16 +259,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -279,7 +279,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -295,16 +295,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -315,7 +315,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test @@ -332,17 +332,17 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -350,7 +350,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -361,12 +361,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -378,7 +378,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -395,12 +395,12 @@ public enum MyEnum2 } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -408,7 +408,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -419,12 +419,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -432,7 +432,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -444,15 +444,15 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -460,7 +460,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -472,16 +472,16 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -492,7 +492,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum1 : uint @@ -508,16 +508,16 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -528,7 +528,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -543,12 +543,11 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationBodyImportTest.cs index 9ccf9034..2547f373 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class CSharpPreviewUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -28,17 +28,17 @@ public static int MyFunction(int* pData, int index) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -49,18 +49,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -72,18 +72,18 @@ public static int MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -95,18 +95,18 @@ public static bool MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -118,12 +118,12 @@ public static bool MyFunction(bool x, bool y) }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -134,7 +134,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -151,12 +151,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -166,7 +166,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -182,12 +182,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -197,7 +197,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -213,12 +213,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -238,7 +238,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -264,12 +264,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -285,7 +285,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -311,12 +311,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -331,7 +331,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; namespace ClangSharp.Test { @@ -352,18 +352,18 @@ public static int MyFunction(MyEnum x) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -375,12 +375,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -391,7 +391,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -408,18 +408,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -431,18 +431,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -454,18 +454,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -477,12 +477,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -495,7 +495,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -530,18 +530,18 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -553,18 +553,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -576,12 +576,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -590,7 +590,7 @@ int MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -605,12 +605,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -624,7 +624,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -644,12 +644,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -660,7 +660,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -679,12 +679,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -756,7 +756,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -825,12 +825,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -878,7 +878,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -947,12 +947,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -963,7 +963,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -980,12 +980,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -998,7 +998,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1017,12 +1017,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1037,7 +1037,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1058,12 +1058,12 @@ public static int MyFunction(bool condition1, int a, int b, bool condition2, int } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1072,7 +1072,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1091,12 +1091,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1105,7 +1105,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1135,12 +1135,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1159,7 +1159,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1198,12 +1198,12 @@ public static MyStruct MyFunction2() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1219,7 +1219,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1241,12 +1241,12 @@ public static int MyFunction2(MyStruct* instance) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1256,7 +1256,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1273,18 +1273,18 @@ public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* l } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1296,18 +1296,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1319,18 +1319,18 @@ public static bool MyFunction() }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1342,18 +1342,18 @@ public static double MyFunction() }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1365,18 +1365,18 @@ public static float MyFunction() }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1388,18 +1388,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1411,12 +1411,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1428,7 +1428,7 @@ void MyFunction() } "; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1467,12 +1467,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1486,7 +1486,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1509,12 +1509,12 @@ public static MyStruct MyFunction() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1526,7 +1526,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1544,12 +1544,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1563,7 +1563,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1589,18 +1589,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1612,18 +1612,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1635,18 +1635,18 @@ public static int MyFunction(int* value) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1658,18 +1658,18 @@ public static bool MyFunction(bool value) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1681,18 +1681,18 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1704,12 +1704,12 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1722,7 +1722,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1741,12 +1741,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1757,7 +1757,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1776,7 +1776,6 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs index 54a0eb02..38c0367a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class CSharpPreviewUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -24,14 +24,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -43,14 +43,14 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -62,24 +62,24 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -91,16 +91,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; + var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -112,12 +112,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -127,7 +127,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -139,14 +139,14 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -158,14 +158,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -177,18 +177,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -200,18 +200,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -223,14 +223,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -242,14 +242,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -264,17 +264,17 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -289,18 +289,18 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -315,19 +315,19 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -342,18 +342,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -368,18 +368,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -392,9 +392,8 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } + + protected override Task VarargsTestImpl() => Task.CompletedTask; } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionPointerDeclarationTest.cs index 8ada843b..306535f9 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class CSharpPreviewUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -25,19 +25,19 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -47,19 +47,19 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -69,7 +69,6 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs index ccc47537..64aecd9a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewUnix_StructDeclarationTest : StructDeclarationTest { - public sealed class CSharpPreviewUnix_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -28,12 +28,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -41,7 +41,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -54,12 +54,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -67,7 +67,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -79,12 +79,12 @@ public partial struct MyStruct }} }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -92,7 +92,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -108,12 +108,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -138,7 +138,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1 { @@ -317,21 +317,21 @@ public uint o0_b1_1 } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -342,7 +342,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -380,12 +380,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -396,7 +396,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -466,12 +466,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -484,7 +484,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -522,12 +522,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -538,7 +538,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -577,18 +577,18 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -616,18 +616,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -637,18 +637,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -658,12 +658,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -671,7 +671,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -681,18 +681,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -705,7 +705,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -731,13 +731,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -756,7 +756,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -786,12 +786,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -810,7 +810,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -841,12 +841,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -886,7 +886,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -1050,12 +1050,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1074,7 +1074,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; namespace ClangSharp.Test { @@ -1177,12 +1177,12 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1198,7 +1198,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1222,12 +1222,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1243,7 +1243,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1274,12 +1274,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1290,7 +1290,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1311,26 +1311,26 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ }} }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1349,16 +1349,16 @@ struct MyStruct2 { }; "; - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; + var usingStatement = "using System.Runtime.InteropServices;\n\n"; + var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } + if (!Environment.Is64BitProcess) + { + usingStatement = string.Empty; + packing = string.Empty; + } - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test + var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test {{ public unsafe partial struct MyStruct1 {{ @@ -1384,17 +1384,17 @@ public unsafe partial struct MyStruct1 }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1405,19 +1405,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1429,14 +1429,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1444,13 +1444,13 @@ public partial struct MyStruct }} "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1462,7 +1462,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; namespace ClangSharp.Test { @@ -1494,16 +1494,16 @@ public partial struct _Anonymous_e__Struct } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1513,7 +1513,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1526,16 +1526,16 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1543,12 +1543,12 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1558,7 +1558,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1574,12 +1574,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1589,7 +1589,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1605,12 +1605,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1621,7 +1621,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -1640,12 +1640,12 @@ public void MyMethod() } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1664,7 +1664,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { internal partial struct MyStruct1 { @@ -1689,18 +1689,18 @@ public partial struct MyStruct3 } "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1708,7 +1708,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @"namespace ClangSharp.Test + const string ExpectedOutputContents = @"namespace ClangSharp.Test { [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] public partial struct MyStruct @@ -1725,7 +1725,6 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs index 9e0cba89..3c540663 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewUnix_UnionDeclarationTest : UnionDeclarationTest { - public sealed class CSharpPreviewUnix_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -38,12 +38,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -51,7 +51,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -69,12 +69,12 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -82,7 +82,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -104,12 +104,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -134,9 +134,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -326,21 +326,21 @@ public uint o0_b1_1 }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -351,7 +351,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -393,12 +393,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -409,7 +409,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -483,12 +483,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -501,7 +501,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -543,12 +543,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -559,7 +559,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -602,18 +602,18 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -645,18 +645,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -670,18 +670,18 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -695,12 +695,12 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -708,7 +708,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -722,17 +722,17 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -745,7 +745,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -775,13 +775,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -802,7 +802,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -873,12 +873,12 @@ public unsafe partial struct _Anonymous_e__Union }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -897,7 +897,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1011,13 +1011,13 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1033,7 +1033,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1068,12 +1068,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1089,7 +1089,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1131,12 +1131,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1147,7 +1147,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1178,14 +1178,14 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1195,17 +1195,17 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1221,19 +1221,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1250,14 +1250,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1268,13 +1268,13 @@ public partial struct MyUnion }} "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1286,7 +1286,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1326,16 +1326,16 @@ public partial struct _Anonymous_e__Union } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1345,7 +1345,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1364,16 +1364,16 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1384,12 +1384,12 @@ public partial struct MyUnion } "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1399,7 +1399,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1421,12 +1421,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1436,7 +1436,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1458,7 +1458,6 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs index b1d54c79..a78d4955 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewUnix_VarDeclarationTest : VarDeclarationTest { - public sealed class CSharpPreviewUnix_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -20,14 +20,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -37,12 +37,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -52,7 +52,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -63,18 +63,18 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -87,15 +87,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -105,21 +105,21 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -131,14 +131,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -148,16 +148,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -173,16 +173,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -200,16 +200,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -225,16 +225,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -252,15 +252,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -273,14 +273,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -290,16 +290,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -309,15 +309,15 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -327,14 +327,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -344,14 +344,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -373,16 +373,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -391,9 +391,8 @@ public static partial class Methods }} }} "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs index 5227df42..8e51fefd 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewWindows_CXXMethodDeclarationTest : CXXMethodDeclarationTest { - public sealed class CSharpPreviewWindows_CXXMethodDeclarationTest : CXXMethodDeclarationTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -35,12 +35,12 @@ public MyStruct(int value) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -60,7 +60,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -90,12 +90,12 @@ public MyStruct(int x, int y, int z) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -106,7 +106,7 @@ operator int() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -120,12 +120,12 @@ public int ToInt32() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -133,7 +133,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -144,12 +144,12 @@ public void Dispose() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -164,21 +164,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -200,12 +200,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -236,7 +236,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -273,12 +273,12 @@ public static int MyFunctionB(MyStruct* x) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -289,7 +289,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -303,12 +303,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -326,7 +326,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -403,19 +403,19 @@ public int ToString(int obj) }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -441,26 +441,26 @@ public int GetType(int obj) }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -498,26 +498,26 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -565,12 +565,12 @@ public partial struct Vtbl }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -590,7 +590,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -617,12 +617,12 @@ public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -652,7 +652,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -689,12 +689,12 @@ public static MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -710,14 +710,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -739,12 +739,12 @@ public static int MyInt32Method() }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -755,7 +755,7 @@ int MyFunction() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -769,12 +769,12 @@ public int MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -784,7 +784,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -804,12 +804,12 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -824,7 +824,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -856,12 +856,12 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -876,7 +876,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -912,9 +912,8 @@ public int MyInt32Method() }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs index f3c7d24d..baf2a46d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewWindows_EnumDeclarationTest : EnumDeclarationTest { - public sealed class CSharpPreviewWindows_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -28,12 +28,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -41,7 +41,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -52,12 +52,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -65,15 +65,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -81,7 +81,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public enum MyEnum : {expectedManagedType} {{ @@ -92,12 +92,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -105,7 +105,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ [NativeTypeName(""{nativeType}"")] public enum MyEnum : {expectedManagedType} @@ -117,12 +117,12 @@ public enum MyEnum : {expectedManagedType} }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum1 : int { MyEnum1_Value1, MyEnum1_Value2, @@ -157,7 +157,7 @@ namespace Namespace2 } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -189,13 +189,13 @@ public enum MyEnum4 } "; - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -206,7 +206,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; namespace ClangSharp.Test { @@ -223,16 +223,16 @@ public enum MyEnum2 } "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -243,7 +243,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -259,16 +259,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -279,7 +279,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -295,16 +295,16 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -315,7 +315,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using System; + var expectedOutputContents = @"using System; using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test @@ -332,17 +332,17 @@ public enum MyEnum2 } "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -350,7 +350,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -361,12 +361,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -378,7 +378,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; namespace ClangSharp.Test { @@ -395,12 +395,12 @@ public enum MyEnum2 } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -408,7 +408,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -419,12 +419,12 @@ public enum MyEnum } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -432,7 +432,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -444,15 +444,15 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -460,7 +460,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum : uint @@ -472,16 +472,16 @@ public enum MyEnum : uint } "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -492,7 +492,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""int"")] public enum MyEnum1 : uint @@ -508,16 +508,16 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -528,7 +528,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum1 { @@ -543,12 +543,11 @@ public enum MyEnum2 : uint } "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationBodyImportTest.cs index 99ff8018..2e278425 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class CSharpPreviewWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -28,17 +28,17 @@ public static int MyFunction(int* pData, int index) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -49,18 +49,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -72,18 +72,18 @@ public static int MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -95,18 +95,18 @@ public static bool MyFunction(int x, int y) }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -118,12 +118,12 @@ public static bool MyFunction(bool x, bool y) }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -134,7 +134,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -151,12 +151,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -166,7 +166,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -182,12 +182,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -197,7 +197,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -213,12 +213,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -238,7 +238,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -264,12 +264,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -285,7 +285,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -311,12 +311,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -331,7 +331,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; + var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; namespace ClangSharp.Test { @@ -352,18 +352,18 @@ public static int MyFunction(MyEnum x) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -375,12 +375,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -391,7 +391,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -408,18 +408,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -431,18 +431,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -454,18 +454,18 @@ public static int MyFunction(float input) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -477,12 +477,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -495,7 +495,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@"using System.Runtime.CompilerServices; + var expectedOutputContents = $@"using System.Runtime.CompilerServices; namespace ClangSharp.Test {{ @@ -530,18 +530,18 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -553,18 +553,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -576,12 +576,12 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -590,7 +590,7 @@ int MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -605,12 +605,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -624,7 +624,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -644,12 +644,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -660,7 +660,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -679,12 +679,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -756,7 +756,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -825,12 +825,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -878,7 +878,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -947,12 +947,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -963,7 +963,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -980,12 +980,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -998,7 +998,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1017,12 +1017,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1037,7 +1037,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1058,12 +1058,12 @@ public static int MyFunction(bool condition1, int a, int b, bool condition2, int } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1072,7 +1072,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1091,12 +1091,12 @@ public static int MyFunction(bool condition, int lhs, int rhs) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1105,7 +1105,7 @@ void MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1135,12 +1135,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1159,7 +1159,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1198,12 +1198,12 @@ public static MyStruct MyFunction2() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1219,7 +1219,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1241,12 +1241,12 @@ public static int MyFunction2(MyStruct* instance) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1256,7 +1256,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1273,18 +1273,18 @@ public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* l } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1296,18 +1296,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1319,18 +1319,18 @@ public static bool MyFunction() }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1342,18 +1342,18 @@ public static double MyFunction() }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1365,18 +1365,18 @@ public static float MyFunction() }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1388,18 +1388,18 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1411,12 +1411,12 @@ public static int MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1428,7 +1428,7 @@ void MyFunction() } "; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1467,12 +1467,12 @@ public static void MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1486,7 +1486,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1509,12 +1509,12 @@ public static MyStruct MyFunction() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1526,7 +1526,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1544,12 +1544,12 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1563,7 +1563,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1589,18 +1589,18 @@ public static int MyFunction(int value) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1612,18 +1612,18 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static unsafe partial class Methods { @@ -1635,18 +1635,18 @@ public static int MyFunction(int* value) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1658,18 +1658,18 @@ public static bool MyFunction(bool value) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1681,18 +1681,18 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -1704,12 +1704,12 @@ public static int MyFunction(int value) }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1722,7 +1722,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1741,12 +1741,12 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1757,7 +1757,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public static partial class Methods { @@ -1776,7 +1776,6 @@ public static int MyFunction(int count) } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs index 2f6fe44e..0bb5d394 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class CSharpPreviewWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -24,14 +24,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -43,14 +43,14 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -62,24 +62,24 @@ public static unsafe partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -91,16 +91,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; + var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -112,12 +112,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -127,7 +127,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -139,14 +139,14 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -158,14 +158,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -177,18 +177,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -200,18 +200,18 @@ public static partial class Methods } "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = $@"using System.Runtime.InteropServices; + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -223,14 +223,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -242,14 +242,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -264,17 +264,17 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -289,18 +289,18 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -315,19 +315,19 @@ public static partial class Methods } "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -342,18 +342,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -368,18 +368,18 @@ public static partial class Methods } "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -392,14 +392,14 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); + } - protected override Task VarargsTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; + protected override Task VarargsTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; + const string ExpectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -411,7 +411,6 @@ public static partial class Methods } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionPointerDeclarationTest.cs index 312475ef..df41fefd 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class CSharpPreviewWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -25,19 +25,19 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -47,19 +47,19 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public unsafe partial struct MyStruct { @@ -69,7 +69,6 @@ public unsafe partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs index 5d7b2863..8ac5b31b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewWindows_StructDeclarationTest : StructDeclarationTest { - public sealed class CSharpPreviewWindows_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -28,12 +28,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -41,7 +41,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -54,12 +54,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -67,7 +67,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -79,12 +79,12 @@ public partial struct MyStruct }} }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -92,7 +92,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -108,12 +108,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -138,7 +138,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1 { @@ -321,21 +321,21 @@ public uint o0_b1_1 } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -346,7 +346,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -384,12 +384,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -400,7 +400,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -470,12 +470,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -488,7 +488,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -526,12 +526,12 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -542,7 +542,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -581,18 +581,18 @@ public ref MyStruct this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -620,18 +620,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -641,18 +641,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -662,12 +662,12 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -675,7 +675,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct MyStruct {{ @@ -685,18 +685,18 @@ public unsafe partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -709,7 +709,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -735,13 +735,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -760,7 +760,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -790,12 +790,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -814,7 +814,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -845,12 +845,12 @@ public partial struct MyStruct2 } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -890,7 +890,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -1054,12 +1054,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1078,7 +1078,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; namespace ClangSharp.Test { @@ -1181,12 +1181,12 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1202,7 +1202,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1226,12 +1226,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1247,7 +1247,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1278,12 +1278,12 @@ public partial struct MyNestedStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1294,7 +1294,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1315,26 +1315,26 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ }} }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1353,16 +1353,16 @@ struct MyStruct2 { }; "; - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; + var usingStatement = "using System.Runtime.InteropServices;\n\n"; + var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } + if (!Environment.Is64BitProcess) + { + usingStatement = string.Empty; + packing = string.Empty; + } - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test + var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test {{ public unsafe partial struct MyStruct1 {{ @@ -1388,17 +1388,17 @@ public unsafe partial struct MyStruct1 }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1409,19 +1409,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public unsafe partial struct example_s {{ @@ -1433,14 +1433,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1448,13 +1448,13 @@ public partial struct MyStruct }} "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1466,7 +1466,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; namespace ClangSharp.Test { @@ -1498,16 +1498,16 @@ public partial struct _Anonymous_e__Struct } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1517,7 +1517,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1530,16 +1530,16 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct { @@ -1547,12 +1547,12 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1562,7 +1562,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1578,12 +1578,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1593,7 +1593,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public partial struct MyStruct {{ @@ -1609,12 +1609,12 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1625,7 +1625,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { public partial struct MyStruct1A { @@ -1644,12 +1644,12 @@ public void MyMethod() } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1668,7 +1668,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test + var expectedOutputContents = @"namespace ClangSharp.Test { internal partial struct MyStruct1 { @@ -1693,18 +1693,18 @@ public partial struct MyStruct3 } "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1712,7 +1712,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @"namespace ClangSharp.Test + const string ExpectedOutputContents = @"namespace ClangSharp.Test { [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] public partial struct MyStruct @@ -1729,7 +1729,6 @@ public partial struct MyStruct } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs index 3cedbb23..b24e6664 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewWindows_UnionDeclarationTest : UnionDeclarationTest { - public sealed class CSharpPreviewWindows_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -38,12 +38,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -51,7 +51,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -69,12 +69,12 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -82,7 +82,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -104,12 +104,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -134,9 +134,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -332,21 +332,21 @@ public uint o0_b1_1 }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -357,7 +357,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -399,12 +399,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -415,7 +415,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -489,12 +489,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -507,7 +507,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -549,12 +549,12 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -565,7 +565,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -608,18 +608,18 @@ public ref MyUnion this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -651,18 +651,18 @@ public ref {expectedManagedType} this[int index] }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -676,18 +676,18 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -701,12 +701,12 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -714,7 +714,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -728,17 +728,17 @@ public unsafe partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -751,7 +751,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -781,13 +781,13 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -808,7 +808,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; @@ -879,12 +879,12 @@ public unsafe partial struct _Anonymous_e__Union }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -903,7 +903,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1017,13 +1017,13 @@ public int o0_b16_4 } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1039,7 +1039,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1074,12 +1074,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1095,7 +1095,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1137,12 +1137,12 @@ public partial struct MyNestedUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1153,7 +1153,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1184,14 +1184,14 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1201,17 +1201,17 @@ public partial struct MyUnion }} }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1227,19 +1227,19 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1256,14 +1256,14 @@ public unsafe partial struct example_s }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1274,13 +1274,13 @@ public partial struct MyUnion }} "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1292,7 +1292,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; + var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; namespace ClangSharp.Test @@ -1332,16 +1332,16 @@ public partial struct _Anonymous_e__Union } "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1351,7 +1351,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1370,16 +1370,16 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; + var expectedOutputContents = @"using System.Runtime.InteropServices; namespace ClangSharp.Test { @@ -1390,12 +1390,12 @@ public partial struct MyUnion } "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1405,7 +1405,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1427,12 +1427,12 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1442,7 +1442,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@"using System.Runtime.InteropServices; + var expectedOutputContents = $@"using System.Runtime.InteropServices; namespace ClangSharp.Test {{ @@ -1464,7 +1464,6 @@ public partial struct MyUnion }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs index 4329bbbc..4b4b42e4 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CSharpPreviewWindows_VarDeclarationTest : VarDeclarationTest { - public sealed class CSharpPreviewWindows_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -20,14 +20,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -37,12 +37,12 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -52,7 +52,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -63,18 +63,18 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -87,15 +87,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -105,21 +105,21 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -131,14 +131,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -148,16 +148,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -173,16 +173,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -200,16 +200,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -225,16 +225,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@"using System; + var expectedOutputContents = $@"using System; namespace ClangSharp.Test {{ @@ -252,15 +252,15 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -273,14 +273,14 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -290,16 +290,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -309,15 +309,15 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -327,14 +327,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static unsafe partial class Methods {{ @@ -344,14 +344,14 @@ public static unsafe partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -373,16 +373,16 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@"namespace ClangSharp.Test + var expectedOutputContents = $@"namespace ClangSharp.Test {{ public static partial class Methods {{ @@ -391,9 +391,8 @@ public static partial class Methods }} }} "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CTest.cs index bc3d898c..b0572f26 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CTest.cs @@ -4,14 +4,14 @@ using System.Threading.Tasks; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class CTest : PInvokeGeneratorTest { - public sealed class CTest : PInvokeGeneratorTest + [Test] + public Task BasicTest() { - [Test] - public Task BasicTest() - { - var inputContents = @"typedef enum MyEnum { + var inputContents = @"typedef enum MyEnum { MyEnum_Value0, MyEnum_Value1, MyEnum_Value2, @@ -21,11 +21,11 @@ typedef struct MyStruct { enum_t _field; } struct_t; "; - string expectedOutputContents; + string expectedOutputContents; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - expectedOutputContents = @"namespace ClangSharp.Test + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + expectedOutputContents = @"namespace ClangSharp.Test { public enum MyEnum { @@ -41,10 +41,10 @@ public partial struct MyStruct } } "; - } - else - { - expectedOutputContents = @"namespace ClangSharp.Test + } + else + { + expectedOutputContents = @"namespace ClangSharp.Test { [NativeTypeName(""unsigned int"")] public enum MyEnum : uint @@ -61,9 +61,8 @@ public partial struct MyStruct } } "; - } - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: DefaultCClangCommandLineArgs); } + + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: DefaultCClangCommandLineArgs); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs index f03f2605..0d18c900 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs @@ -9,124 +9,123 @@ using ClangSharp.Interop; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class PInvokeGeneratorTest { - public abstract class PInvokeGeneratorTest - { - protected const string DefaultInputFileName = "ClangUnsavedFile.h"; - protected const string DefaultLibraryPath = "ClangSharpPInvokeGenerator"; - protected const string DefaultNamespaceName = "ClangSharp.Test"; + protected const string DefaultInputFileName = "ClangUnsavedFile.h"; + protected const string DefaultLibraryPath = "ClangSharpPInvokeGenerator"; + protected const string DefaultNamespaceName = "ClangSharp.Test"; - protected const CXTranslationUnit_Flags DefaultTranslationUnitFlags = CXTranslationUnit_Flags.CXTranslationUnit_IncludeAttributedTypes // Include attributed types in CXType - | CXTranslationUnit_Flags.CXTranslationUnit_VisitImplicitAttributes // Implicit attributes should be visited - | CXTranslationUnit_Flags.CXTranslationUnit_DetailedPreprocessingRecord; + protected const CXTranslationUnit_Flags DefaultTranslationUnitFlags = CXTranslationUnit_Flags.CXTranslationUnit_IncludeAttributedTypes // Include attributed types in CXType + | CXTranslationUnit_Flags.CXTranslationUnit_VisitImplicitAttributes // Implicit attributes should be visited + | CXTranslationUnit_Flags.CXTranslationUnit_DetailedPreprocessingRecord; - protected static readonly string[] DefaultCClangCommandLineArgs = new string[] - { - "-std=c17", // The input files should be compiled for C 17 - "-xc", // The input files are C - }; + protected static readonly string[] DefaultCClangCommandLineArgs = new string[] + { + "-std=c17", // The input files should be compiled for C 17 + "-xc", // The input files are C + }; - protected static readonly string[] DefaultCppClangCommandLineArgs = new string[] - { - "-std=c++17", // The input files should be compiled for C++ 17 - "-xc++", // The input files are C++ - "-Wno-pragma-once-outside-header", // We are processing files which may be header files - "-Wno-c++11-narrowing" - }; + protected static readonly string[] DefaultCppClangCommandLineArgs = new string[] + { + "-std=c++17", // The input files should be compiled for C++ 17 + "-xc++", // The input files are C++ + "-Wno-pragma-once-outside-header", // We are processing files which may be header files + "-Wno-c++11-narrowing" + }; - protected static string EscapeXml(string value) => new XText(value).ToString(); + protected static string EscapeXml(string value) => new XText(value).ToString(); - protected static Task ValidateGeneratedCSharpPreviewWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GeneratePreviewCode | PInvokeGeneratorConfigurationOptions.None | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedCSharpPreviewWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GeneratePreviewCode | PInvokeGeneratorConfigurationOptions.None | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - protected static Task ValidateGeneratedCSharpPreviewUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GeneratePreviewCode | PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedCSharpPreviewUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GeneratePreviewCode | PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - protected static Task ValidateGeneratedCSharpLatestWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.None | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedCSharpLatestWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.None | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - protected static Task ValidateGeneratedCSharpLatestUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedCSharpLatestUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - protected static Task ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - protected static Task ValidateGeneratedCSharpCompatibleUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode | PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedCSharpCompatibleUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode | PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - protected static Task ValidateGeneratedXmlPreviewWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null, [CallerFilePath] string filePath = "") - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GeneratePreviewCode | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs, filePath); + protected static Task ValidateGeneratedXmlPreviewWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null, [CallerFilePath] string filePath = "") + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GeneratePreviewCode | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs, filePath); - protected static Task ValidateGeneratedXmlPreviewUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GeneratePreviewCode | PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedXmlPreviewUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GeneratePreviewCode | PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - protected static Task ValidateGeneratedXmlLatestWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null, [CallerFilePath] string filePath = "") - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.None | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs, filePath); + protected static Task ValidateGeneratedXmlLatestWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null, [CallerFilePath] string filePath = "") + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.None | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs, filePath); - protected static Task ValidateGeneratedXmlLatestUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedXmlLatestUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - protected static Task ValidateGeneratedXmlCompatibleWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedXmlCompatibleWindowsBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - protected static Task ValidateGeneratedXmlCompatibleUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) - => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode | PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); + protected static Task ValidateGeneratedXmlCompatibleUnixBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[] excludedNames = null, IReadOnlyDictionary remappedNames = null, IReadOnlyDictionary withAccessSpecifiers = null, IReadOnlyDictionary> withAttributes = null, IReadOnlyDictionary withCallConvs = null, IReadOnlyDictionary withClasses = null, IReadOnlyDictionary withLibraryPaths = null, IReadOnlyDictionary withNamespaces = null, string[] withSetLastErrors = null, IReadOnlyDictionary withTransparentStructs = null, IReadOnlyDictionary withTypes = null, IReadOnlyDictionary> withUsings = null, IEnumerable expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[] commandlineArgs = null) + => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode | PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, expectedDiagnostics, libraryPath, commandlineArgs); - private static async Task ValidateGeneratedBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorOutputMode outputMode, PInvokeGeneratorConfigurationOptions configOptions, string[] excludedNames, IReadOnlyDictionary remappedNames, IReadOnlyDictionary withAccessSpecifiers, IReadOnlyDictionary> withAttributes, IReadOnlyDictionary withCallConvs, IReadOnlyDictionary withClasses, IReadOnlyDictionary withLibraryPaths, IReadOnlyDictionary withNamespaces, string[] withSetLastErrors, IReadOnlyDictionary withTransparentStructs, IReadOnlyDictionary withTypes, IReadOnlyDictionary> withUsings, IEnumerable expectedDiagnostics, string libraryPath, string[] commandlineArgs, [CallerFilePath] string filePath = "") + private static async Task ValidateGeneratedBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorOutputMode outputMode, PInvokeGeneratorConfigurationOptions configOptions, string[] excludedNames, IReadOnlyDictionary remappedNames, IReadOnlyDictionary withAccessSpecifiers, IReadOnlyDictionary> withAttributes, IReadOnlyDictionary withCallConvs, IReadOnlyDictionary withClasses, IReadOnlyDictionary withLibraryPaths, IReadOnlyDictionary withNamespaces, string[] withSetLastErrors, IReadOnlyDictionary withTransparentStructs, IReadOnlyDictionary withTypes, IReadOnlyDictionary> withUsings, IEnumerable expectedDiagnostics, string libraryPath, string[] commandlineArgs, [CallerFilePath] string filePath = "") + { + Assert.True(File.Exists(DefaultInputFileName)); + commandlineArgs ??= DefaultCppClangCommandLineArgs; + + configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMacroBindings; + + using var outputStream = new MemoryStream(); + using var unsavedFile = CXUnsavedFile.Create(DefaultInputFileName, inputContents); + + var unsavedFiles = new CXUnsavedFile[] { unsavedFile }; + var config = new PInvokeGeneratorConfiguration(DefaultNamespaceName, Path.GetRandomFileName(), headerFile: null, outputMode, configOptions) { + DefaultClass = null, + ExcludedNames = excludedNames, + IncludedNames = null, + LibraryPath = libraryPath, + MethodPrefixToStrip = null, + RemappedNames = remappedNames, + TraversalNames = null, + TestOutputLocation = null, + WithAccessSpecifiers = withAccessSpecifiers, + WithAttributes = withAttributes, + WithCallConvs = withCallConvs, + WithClasses = withClasses, + WithLibraryPaths = withLibraryPaths, + WithManualImports = null, + WithNamespaces = withNamespaces, + WithSetLastErrors = withSetLastErrors, + WithSuppressGCTransitions = null, + WithTransparentStructs = withTransparentStructs, + WithTypes = withTypes, + WithUsings = withUsings, + }; + + using (var pinvokeGenerator = new PInvokeGenerator(config, (path) => outputStream)) { - Assert.True(File.Exists(DefaultInputFileName)); - commandlineArgs ??= DefaultCppClangCommandLineArgs; - - configOptions |= PInvokeGeneratorConfigurationOptions.GenerateMacroBindings; - - using var outputStream = new MemoryStream(); - using var unsavedFile = CXUnsavedFile.Create(DefaultInputFileName, inputContents); - - var unsavedFiles = new CXUnsavedFile[] { unsavedFile }; - var config = new PInvokeGeneratorConfiguration(DefaultNamespaceName, Path.GetRandomFileName(), headerFile: null, outputMode, configOptions) { - DefaultClass = null, - ExcludedNames = excludedNames, - IncludedNames = null, - LibraryPath = libraryPath, - MethodPrefixToStrip = null, - RemappedNames = remappedNames, - TraversalNames = null, - TestOutputLocation = null, - WithAccessSpecifiers = withAccessSpecifiers, - WithAttributes = withAttributes, - WithCallConvs = withCallConvs, - WithClasses = withClasses, - WithLibraryPaths = withLibraryPaths, - WithManualImports = null, - WithNamespaces = withNamespaces, - WithSetLastErrors = withSetLastErrors, - WithSuppressGCTransitions = null, - WithTransparentStructs = withTransparentStructs, - WithTypes = withTypes, - WithUsings = withUsings, - }; - - using (var pinvokeGenerator = new PInvokeGenerator(config, (path) => outputStream)) + var handle = CXTranslationUnit.Parse(pinvokeGenerator.IndexHandle, DefaultInputFileName, commandlineArgs, unsavedFiles, DefaultTranslationUnitFlags); + using var translationUnit = TranslationUnit.GetOrCreate(handle); + + pinvokeGenerator.GenerateBindings(translationUnit, DefaultInputFileName, commandlineArgs, DefaultTranslationUnitFlags); + + if (expectedDiagnostics is null) { - var handle = CXTranslationUnit.Parse(pinvokeGenerator.IndexHandle, DefaultInputFileName, commandlineArgs, unsavedFiles, DefaultTranslationUnitFlags); - using var translationUnit = TranslationUnit.GetOrCreate(handle); - - pinvokeGenerator.GenerateBindings(translationUnit, DefaultInputFileName, commandlineArgs, DefaultTranslationUnitFlags); - - if (expectedDiagnostics is null) - { - Assert.IsEmpty(pinvokeGenerator.Diagnostics); - } - else - { - Assert.AreEqual(expectedDiagnostics, pinvokeGenerator.Diagnostics); - } + Assert.IsEmpty(pinvokeGenerator.Diagnostics); + } + else + { + Assert.AreEqual(expectedDiagnostics, pinvokeGenerator.Diagnostics); } - outputStream.Position = 0; - - var actualOutputContents = await new StreamReader(outputStream).ReadToEndAsync(); - Assert.AreEqual(expectedOutputContents, actualOutputContents); } + outputStream.Position = 0; + + var actualOutputContents = await new StreamReader(outputStream).ReadToEndAsync(); + Assert.AreEqual(expectedOutputContents, actualOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs index ddc1095e..21066678 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest { - public sealed class XmlCompatibleUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -40,12 +40,12 @@ protected override Task ConstructorTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -65,7 +65,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -128,12 +128,12 @@ protected override Task ConstructorWithInitializeTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -144,7 +144,7 @@ operator int() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -160,12 +160,12 @@ operator int() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -173,7 +173,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,12 +186,12 @@ protected override Task DestructorTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -206,21 +206,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -243,12 +243,12 @@ int MyInt32Method() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -279,7 +279,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -319,12 +319,12 @@ int MyFunctionB(MyStruct* x) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -335,7 +335,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -351,12 +351,12 @@ int MyFunction() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -374,7 +374,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -460,19 +460,19 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -547,26 +547,26 @@ protected override Task NewKeywordVirtualTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -652,26 +652,26 @@ protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -777,12 +777,12 @@ protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestI "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -802,7 +802,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -843,12 +843,12 @@ protected override Task OperatorTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -878,7 +878,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -939,12 +939,12 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -960,14 +960,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -987,12 +987,12 @@ static int MyInt32Method() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -1003,7 +1003,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1019,12 +1019,12 @@ int MyFunction() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -1034,7 +1034,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1052,12 +1052,12 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -1072,7 +1072,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1144,12 +1144,12 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -1164,7 +1164,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1236,9 +1236,8 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs index 37d1afaf..b7e01d3b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleUnix_EnumDeclarationTest : EnumDeclarationTest { - public sealed class XmlCompatibleUnix_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -36,12 +36,12 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -49,7 +49,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -71,12 +71,12 @@ protected override Task BasicValueTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -84,15 +84,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -100,7 +100,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -119,12 +119,12 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -132,7 +132,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -151,12 +151,12 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum : int { MyEnum_Value1, MyEnum_Value2, @@ -164,7 +164,7 @@ protected override Task RemapTestImpl() } MyEnum; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -183,13 +183,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -200,7 +200,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -226,16 +226,16 @@ enum MyEnum2 : int "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -246,7 +246,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -271,16 +271,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -291,7 +291,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -316,16 +316,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -336,7 +336,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -361,17 +361,17 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -379,7 +379,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -407,12 +407,12 @@ protected override Task WithCastToEnumTypeImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -424,7 +424,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -455,12 +455,12 @@ enum MyEnum2 : int "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -468,7 +468,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -497,12 +497,12 @@ protected override Task WithImplicitConversionTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -510,7 +510,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -529,15 +529,15 @@ protected override Task WithTypeTestImpl() "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -545,7 +545,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -567,16 +567,16 @@ protected override Task WithTypeAndImplicitConversionTestImpl() "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -587,7 +587,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -606,16 +606,16 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -626,7 +626,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -645,12 +645,11 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationBodyImportTest.cs index 03d67c93..87fb5a44 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class XmlCompatibleUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -35,17 +35,17 @@ protected override Task ArraySubscriptTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -58,18 +58,18 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -88,18 +88,18 @@ protected override Task BinaryOperatorBasicTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -118,18 +118,18 @@ protected override Task BinaryOperatorCompareTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,12 +148,12 @@ protected override Task BinaryOperatorBooleanTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -164,7 +164,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -185,12 +185,12 @@ protected override Task BreakTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -200,7 +200,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -217,12 +217,12 @@ void MyFunction() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -232,7 +232,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,12 +255,12 @@ void MyFunction() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -280,7 +280,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -310,12 +310,12 @@ protected override Task CaseTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -331,7 +331,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -361,12 +361,12 @@ protected override Task CaseNoCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -381,7 +381,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -409,18 +409,18 @@ static inline int MyFunction(MyEnum x) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -442,12 +442,12 @@ protected override Task ConditionalOperatorTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -458,7 +458,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -479,18 +479,18 @@ protected override Task ContinueTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -506,18 +506,18 @@ protected override Task CStyleFunctionalCastTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -533,18 +533,18 @@ protected override Task CxxFunctionalCastTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -560,12 +560,12 @@ protected override Task CxxConstCastTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -578,7 +578,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -634,18 +634,18 @@ struct MyStructB : MyStructA { }; "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -661,18 +661,18 @@ protected override Task CxxReinterpretCastTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -688,12 +688,12 @@ protected override Task CxxStaticCastTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -702,7 +702,7 @@ int MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -718,12 +718,12 @@ int MyFunction() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -737,7 +737,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -761,12 +761,12 @@ protected override Task DoTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -777,7 +777,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -800,12 +800,12 @@ protected override Task DoNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -877,7 +877,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -950,12 +950,12 @@ protected override Task ForTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -1003,7 +1003,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1076,12 +1076,12 @@ protected override Task ForNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1092,7 +1092,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1119,12 +1119,12 @@ protected override Task IfTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1137,7 +1137,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1166,12 +1166,12 @@ protected override Task IfElseTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1186,7 +1186,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1223,12 +1223,12 @@ protected override Task IfElseIfTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1237,7 +1237,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1266,12 +1266,12 @@ protected override Task IfElseNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1280,7 +1280,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1311,12 +1311,12 @@ void MyFunction() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1335,7 +1335,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1377,12 +1377,12 @@ MyStruct MyFunction2() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1398,7 +1398,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1426,12 +1426,12 @@ int MyFunction2(MyStruct* instance) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1441,7 +1441,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1465,18 +1465,18 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1489,18 +1489,18 @@ protected override Task ReturnCXXNullPtrTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1513,18 +1513,18 @@ protected override Task ReturnCXXBooleanLiteralTestImpl(string value) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1537,18 +1537,18 @@ protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1561,18 +1561,18 @@ protected override Task ReturnFloatingLiteralSingleTestImpl(string value) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1585,18 +1585,18 @@ protected override Task ReturnEmptyTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1609,12 +1609,12 @@ protected override Task ReturnIntegerLiteralInt32TestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1626,7 +1626,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1660,12 +1660,12 @@ void MyFunction() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1679,7 +1679,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1705,12 +1705,12 @@ MyStruct MyFunction() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1722,7 +1722,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1744,12 +1744,12 @@ protected override Task SwitchTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1763,7 +1763,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1793,18 +1793,18 @@ protected override Task SwitchNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1820,18 +1820,18 @@ protected override Task UnaryOperatorAddrOfTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1847,18 +1847,18 @@ protected override Task UnaryOperatorDerefTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1874,18 +1874,18 @@ protected override Task UnaryOperatorLogicalNotTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1901,18 +1901,18 @@ protected override Task UnaryOperatorPostfixTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1928,12 +1928,12 @@ protected override Task UnaryOperatorPrefixTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1946,7 +1946,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1969,12 +1969,12 @@ protected override Task WhileTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1985,7 +1985,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -2008,7 +2008,6 @@ protected override Task WhileNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs index 5ac4372f..c7b729b8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class XmlCompatibleUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -24,14 +24,14 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -46,14 +46,14 @@ protected override Task ArrayParameterTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -68,24 +68,24 @@ protected override Task FunctionPointerParameterTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -97,16 +97,16 @@ protected override Task NamespaceTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -121,12 +121,12 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -136,7 +136,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,14 +148,14 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -167,14 +167,14 @@ protected override Task NoLibraryPathTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,18 +186,18 @@ protected override Task WithLibraryPathTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @" + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @" @@ -209,18 +209,18 @@ protected override Task WithLibraryPathStarTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -238,14 +238,14 @@ protected override Task OptionalParameterTestImpl(string nativeType, string nati "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -263,14 +263,14 @@ protected override Task OptionalParameterUnsafeTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -291,17 +291,17 @@ protected override Task WithCallConvTestImpl() "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -322,18 +322,18 @@ protected override Task WithCallConvStarTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -354,19 +354,19 @@ protected override Task WithCallConvStarOverrideTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -387,18 +387,18 @@ protected override Task WithSetLastErrorTestImpl() "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @" + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @" @@ -419,18 +419,18 @@ protected override Task WithSetLastErrorStarTestImpl() "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @" + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @" @@ -445,9 +445,8 @@ protected override Task SourceLocationTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } + + protected override Task VarargsTestImpl() => Task.CompletedTask; } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionPointerDeclarationTest.cs index e79aefa2..32d626ee 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class XmlCompatibleUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -30,19 +30,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -57,19 +57,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -84,7 +84,6 @@ struct MyStruct { "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs index 3bb6b6a0..76f00139 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleUnix_StructDeclarationTest : StructDeclarationTest { - public sealed class XmlCompatibleUnix_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -30,12 +30,12 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -43,7 +43,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -61,12 +61,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -74,7 +74,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -91,12 +91,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -104,7 +104,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -122,12 +122,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -152,7 +152,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -293,21 +293,21 @@ struct MyStruct3 "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -318,7 +318,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -358,12 +358,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -374,7 +374,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -477,12 +477,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -495,7 +495,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -535,12 +535,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -551,7 +551,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -591,18 +591,18 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -637,18 +637,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -660,18 +660,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -683,12 +683,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -696,7 +696,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -708,18 +708,18 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Unix doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -732,7 +732,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -753,13 +753,13 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -778,7 +778,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -815,12 +815,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -839,7 +839,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -876,12 +876,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -906,7 +906,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1022,12 +1022,12 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1046,7 +1046,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1136,12 +1136,12 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1157,7 +1157,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1189,12 +1189,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1210,7 +1210,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1242,12 +1242,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1258,7 +1258,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1288,26 +1288,26 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1326,9 +1326,9 @@ struct MyStruct2 { }; "; - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; + var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1357,17 +1357,17 @@ struct MyStruct2 { "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1382,19 +1382,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1409,14 +1409,14 @@ struct example_s { "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1424,13 +1424,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1442,7 +1442,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1477,16 +1477,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1496,7 +1496,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1514,16 +1514,16 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1531,12 +1531,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1546,7 +1546,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1564,12 +1564,12 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1579,7 +1579,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1597,12 +1597,12 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1613,7 +1613,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1632,12 +1632,12 @@ struct MyStruct1B : MyStruct1A "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1656,7 +1656,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1687,18 +1687,18 @@ struct MyStruct3 "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1706,7 +1706,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @" + const string ExpectedOutputContents = @" @@ -1724,7 +1724,6 @@ protected override Task SourceLocationAttributeTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs index ac5fd20e..456200a5 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleUnix_UnionDeclarationTest : UnionDeclarationTest { - public sealed class XmlCompatibleUnix_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -37,12 +37,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -50,7 +50,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -67,12 +67,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -80,7 +80,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -98,12 +98,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -128,9 +128,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -271,21 +271,21 @@ union MyUnion3 "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -296,7 +296,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -336,12 +336,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -352,7 +352,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -455,12 +455,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -473,7 +473,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -513,12 +513,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -529,7 +529,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -569,18 +569,18 @@ union MyOtherUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -615,18 +615,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -638,18 +638,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -661,12 +661,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -674,7 +674,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -686,17 +686,17 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Unix doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -709,7 +709,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -730,13 +730,13 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -757,7 +757,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -821,12 +821,12 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -845,7 +845,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -935,13 +935,13 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -957,7 +957,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -989,12 +989,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1010,7 +1010,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1042,12 +1042,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1058,7 +1058,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1088,31 +1088,31 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1127,19 +1127,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1154,14 +1154,14 @@ union example_s { "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1169,13 +1169,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1187,7 +1187,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1222,16 +1222,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1241,7 +1241,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1259,16 +1259,16 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1276,12 +1276,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1291,7 +1291,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1309,12 +1309,12 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1324,7 +1324,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1342,7 +1342,6 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs index bec57106..57829f28 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleUnix_VarDeclarationTest : VarDeclarationTest { - public sealed class XmlCompatibleUnix_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -26,14 +26,14 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -48,12 +48,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -63,7 +63,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -77,18 +77,18 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -109,15 +109,15 @@ protected override Task MacroTestImpl(string nativeValue, string expectedManaged "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -132,21 +132,21 @@ protected override Task MultilineMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -161,14 +161,14 @@ protected override Task Utf8StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -183,16 +183,16 @@ protected override Task Utf16StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -219,16 +219,16 @@ protected override Task WideStringLiteralConstTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,16 +255,16 @@ protected override Task StringLiteralConstTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -291,16 +291,16 @@ protected override Task WideStringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -327,15 +327,15 @@ protected override Task StringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -364,14 +364,14 @@ protected override Task UncheckedConversionMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -390,16 +390,16 @@ protected override Task UncheckedFunctionLikeCastMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -416,15 +416,15 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -441,14 +441,14 @@ protected override Task UncheckedPointerMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -467,14 +467,14 @@ protected override Task UncheckedReinterpretCastMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -501,16 +501,16 @@ protected override Task MultidimensionlArrayTestImpl() "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -526,9 +526,8 @@ protected override Task ConditionalDefineConstTestImpl() "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs index cc69ee41..bcd409ee 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest { - public sealed class XmlCompatibleWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -40,12 +40,12 @@ protected override Task ConstructorTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -65,7 +65,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -128,12 +128,12 @@ protected override Task ConstructorWithInitializeTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -144,7 +144,7 @@ operator int() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -160,12 +160,12 @@ operator int() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -173,7 +173,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,12 +186,12 @@ protected override Task DestructorTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -206,21 +206,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -243,12 +243,12 @@ int MyInt32Method() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -279,7 +279,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -319,12 +319,12 @@ int MyFunctionB(MyStruct* x) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -335,7 +335,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -351,12 +351,12 @@ int MyFunction() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -374,7 +374,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -460,19 +460,19 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -547,26 +547,26 @@ protected override Task NewKeywordVirtualTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -652,26 +652,26 @@ protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -777,12 +777,12 @@ protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestI "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -802,7 +802,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -843,12 +843,12 @@ protected override Task OperatorTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -878,7 +878,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -939,12 +939,12 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -960,14 +960,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -987,12 +987,12 @@ static int MyInt32Method() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -1003,7 +1003,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1019,12 +1019,12 @@ int MyFunction() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -1034,7 +1034,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1052,12 +1052,12 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -1072,7 +1072,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1144,12 +1144,12 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -1164,7 +1164,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1236,9 +1236,8 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs index 6982c32d..48b4cb82 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleWindows_EnumDeclarationTest : EnumDeclarationTest { - public sealed class XmlCompatibleWindows_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -36,12 +36,12 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -49,7 +49,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -71,12 +71,12 @@ protected override Task BasicValueTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -84,15 +84,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -100,7 +100,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -119,12 +119,12 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -132,7 +132,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -151,12 +151,12 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum : int { MyEnum_Value1, MyEnum_Value2, @@ -164,7 +164,7 @@ protected override Task RemapTestImpl() } MyEnum; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -183,13 +183,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -200,7 +200,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -226,16 +226,16 @@ enum MyEnum2 : int "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -246,7 +246,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -271,16 +271,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -291,7 +291,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -316,16 +316,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -336,7 +336,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -361,17 +361,17 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -379,7 +379,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -407,12 +407,12 @@ protected override Task WithCastToEnumTypeImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -424,7 +424,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -455,12 +455,12 @@ enum MyEnum2 : int "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -468,7 +468,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -497,12 +497,12 @@ protected override Task WithImplicitConversionTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -510,7 +510,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -529,15 +529,15 @@ protected override Task WithTypeTestImpl() "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -545,7 +545,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -567,16 +567,16 @@ protected override Task WithTypeAndImplicitConversionTestImpl() "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -587,7 +587,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -606,16 +606,16 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -626,7 +626,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -645,12 +645,11 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationBodyImportTest.cs index de818147..8d5584ab 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class XmlCompatibleWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -35,17 +35,17 @@ protected override Task ArraySubscriptTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -58,18 +58,18 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -88,18 +88,18 @@ protected override Task BinaryOperatorBasicTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -118,18 +118,18 @@ protected override Task BinaryOperatorCompareTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,12 +148,12 @@ protected override Task BinaryOperatorBooleanTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -164,7 +164,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -185,12 +185,12 @@ protected override Task BreakTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -200,7 +200,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -217,12 +217,12 @@ void MyFunction() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -232,7 +232,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,12 +255,12 @@ void MyFunction() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -280,7 +280,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -310,12 +310,12 @@ protected override Task CaseTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -331,7 +331,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -361,12 +361,12 @@ protected override Task CaseNoCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -381,7 +381,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -409,18 +409,18 @@ static inline int MyFunction(MyEnum x) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -442,12 +442,12 @@ protected override Task ConditionalOperatorTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -458,7 +458,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -479,18 +479,18 @@ protected override Task ContinueTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -506,18 +506,18 @@ protected override Task CStyleFunctionalCastTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -533,18 +533,18 @@ protected override Task CxxFunctionalCastTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -560,12 +560,12 @@ protected override Task CxxConstCastTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -578,7 +578,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -634,18 +634,18 @@ struct MyStructB : MyStructA { }; "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -661,18 +661,18 @@ protected override Task CxxReinterpretCastTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -688,12 +688,12 @@ protected override Task CxxStaticCastTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -702,7 +702,7 @@ int MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -718,12 +718,12 @@ int MyFunction() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -737,7 +737,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -761,12 +761,12 @@ protected override Task DoTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -777,7 +777,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -800,12 +800,12 @@ protected override Task DoNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -877,7 +877,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -950,12 +950,12 @@ protected override Task ForTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -1003,7 +1003,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1076,12 +1076,12 @@ protected override Task ForNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1092,7 +1092,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1119,12 +1119,12 @@ protected override Task IfTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1137,7 +1137,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1166,12 +1166,12 @@ protected override Task IfElseTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1186,7 +1186,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1223,12 +1223,12 @@ protected override Task IfElseIfTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1237,7 +1237,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1266,12 +1266,12 @@ protected override Task IfElseNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1280,7 +1280,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1311,12 +1311,12 @@ void MyFunction() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1335,7 +1335,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1377,12 +1377,12 @@ MyStruct MyFunction2() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1398,7 +1398,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1426,12 +1426,12 @@ int MyFunction2(MyStruct* instance) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1441,7 +1441,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1465,18 +1465,18 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1489,18 +1489,18 @@ protected override Task ReturnCXXNullPtrTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1513,18 +1513,18 @@ protected override Task ReturnCXXBooleanLiteralTestImpl(string value) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1537,18 +1537,18 @@ protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1561,18 +1561,18 @@ protected override Task ReturnFloatingLiteralSingleTestImpl(string value) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1585,18 +1585,18 @@ protected override Task ReturnEmptyTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1609,12 +1609,12 @@ protected override Task ReturnIntegerLiteralInt32TestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1626,7 +1626,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1660,12 +1660,12 @@ void MyFunction() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1679,7 +1679,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1705,12 +1705,12 @@ MyStruct MyFunction() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1722,7 +1722,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1744,12 +1744,12 @@ protected override Task SwitchTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1763,7 +1763,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1793,18 +1793,18 @@ protected override Task SwitchNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1820,18 +1820,18 @@ protected override Task UnaryOperatorAddrOfTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1847,18 +1847,18 @@ protected override Task UnaryOperatorDerefTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1874,18 +1874,18 @@ protected override Task UnaryOperatorLogicalNotTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1901,18 +1901,18 @@ protected override Task UnaryOperatorPostfixTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1928,12 +1928,12 @@ protected override Task UnaryOperatorPrefixTestImpl(string opcode) "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1946,7 +1946,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1969,12 +1969,12 @@ protected override Task WhileTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1985,7 +1985,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -2008,7 +2008,6 @@ protected override Task WhileNonCompoundTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs index 895d9547..e54c8233 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class XmlCompatibleWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -24,14 +24,14 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -46,14 +46,14 @@ protected override Task ArrayParameterTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -68,24 +68,24 @@ protected override Task FunctionPointerParameterTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -97,16 +97,16 @@ protected override Task NamespaceTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -121,12 +121,12 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -136,7 +136,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,14 +148,14 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -167,14 +167,14 @@ protected override Task NoLibraryPathTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,18 +186,18 @@ protected override Task WithLibraryPathTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @" + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @" @@ -209,18 +209,18 @@ protected override Task WithLibraryPathStarTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -238,14 +238,14 @@ protected override Task OptionalParameterTestImpl(string nativeType, string nati "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -263,14 +263,14 @@ protected override Task OptionalParameterUnsafeTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -291,17 +291,17 @@ protected override Task WithCallConvTestImpl() "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -322,18 +322,18 @@ protected override Task WithCallConvStarTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -354,19 +354,19 @@ protected override Task WithCallConvStarOverrideTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -387,18 +387,18 @@ protected override Task WithSetLastErrorTestImpl() "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @" + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @" @@ -419,18 +419,18 @@ protected override Task WithSetLastErrorStarTestImpl() "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @" + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @" @@ -445,9 +445,8 @@ protected override Task SourceLocationTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } + + protected override Task VarargsTestImpl() => Task.CompletedTask; } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionPointerDeclarationTest.cs index 76e90c3d..a762a71a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class XmlCompatibleWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -30,19 +30,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -57,19 +57,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -84,7 +84,6 @@ struct MyStruct { "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs index b2d93212..99bdb561 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleWindows_StructDeclarationTest : StructDeclarationTest { - public sealed class XmlCompatibleWindows_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -30,12 +30,12 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -43,7 +43,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -61,12 +61,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -74,7 +74,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -91,12 +91,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -104,7 +104,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -122,12 +122,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -152,7 +152,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -299,21 +299,21 @@ struct MyStruct3 "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -324,7 +324,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -364,12 +364,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -380,7 +380,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -483,12 +483,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -501,7 +501,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -541,12 +541,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -557,7 +557,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -597,18 +597,18 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -643,18 +643,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -666,18 +666,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -689,12 +689,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -702,7 +702,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -714,18 +714,18 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -738,7 +738,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -759,13 +759,13 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -784,7 +784,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -821,12 +821,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -845,7 +845,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -882,12 +882,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -912,7 +912,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1028,12 +1028,12 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1052,7 +1052,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1142,12 +1142,12 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1163,7 +1163,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1195,12 +1195,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1216,7 +1216,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1248,12 +1248,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1264,7 +1264,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1294,25 +1294,25 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1331,9 +1331,9 @@ struct MyStruct2 { }; "; - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; + var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1362,17 +1362,17 @@ struct MyStruct2 { "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1387,19 +1387,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1414,14 +1414,14 @@ struct example_s { "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1429,13 +1429,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1447,7 +1447,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1482,16 +1482,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1501,7 +1501,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1519,16 +1519,16 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1536,12 +1536,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1551,7 +1551,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1569,12 +1569,12 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1584,7 +1584,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1602,12 +1602,12 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1618,7 +1618,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1637,12 +1637,12 @@ struct MyStruct1B : MyStruct1A "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1661,7 +1661,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1692,18 +1692,18 @@ struct MyStruct3 "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1711,7 +1711,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @" + const string ExpectedOutputContents = @" @@ -1729,7 +1729,6 @@ protected override Task SourceLocationAttributeTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs index 2d820839..167f1861 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleWindows_UnionDeclarationTest : UnionDeclarationTest { - public sealed class XmlCompatibleWindows_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -37,12 +37,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -50,7 +50,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -67,12 +67,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -80,7 +80,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -98,12 +98,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -128,9 +128,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -277,21 +277,21 @@ union MyUnion3 "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -302,7 +302,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -342,12 +342,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -358,7 +358,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -461,12 +461,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -479,7 +479,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -519,12 +519,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -535,7 +535,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -575,18 +575,18 @@ union MyOtherUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -621,18 +621,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -644,18 +644,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -667,12 +667,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -680,7 +680,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -692,17 +692,17 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -715,7 +715,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -736,13 +736,13 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -763,7 +763,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -827,12 +827,12 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -851,7 +851,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -941,13 +941,13 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -963,7 +963,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -995,12 +995,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1016,7 +1016,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1048,12 +1048,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1064,7 +1064,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1094,31 +1094,31 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1133,19 +1133,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1160,14 +1160,14 @@ union example_s { "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1175,13 +1175,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1193,7 +1193,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1228,16 +1228,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1247,7 +1247,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1265,16 +1265,16 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1282,12 +1282,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1297,7 +1297,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1315,12 +1315,12 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1330,7 +1330,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1348,7 +1348,6 @@ union MyUnion "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs index 03d55745..5bee145b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlCompatibleWindows_VarDeclarationTest : VarDeclarationTest { - public sealed class XmlCompatibleWindows_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -26,14 +26,14 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -48,12 +48,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -63,7 +63,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -77,18 +77,18 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -109,15 +109,15 @@ protected override Task MacroTestImpl(string nativeValue, string expectedManaged "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -132,21 +132,21 @@ protected override Task MultilineMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -161,14 +161,14 @@ protected override Task Utf8StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -183,16 +183,16 @@ protected override Task Utf16StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -219,16 +219,16 @@ protected override Task WideStringLiteralConstTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,16 +255,16 @@ protected override Task StringLiteralConstTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -291,16 +291,16 @@ protected override Task WideStringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -327,15 +327,15 @@ protected override Task StringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -364,14 +364,14 @@ protected override Task UncheckedConversionMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -390,16 +390,16 @@ protected override Task UncheckedFunctionLikeCastMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -416,15 +416,15 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -441,14 +441,14 @@ protected override Task UncheckedPointerMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -467,14 +467,14 @@ protected override Task UncheckedReinterpretCastMacroTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -501,16 +501,16 @@ protected override Task MultidimensionlArrayTestImpl() "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -526,9 +526,8 @@ protected override Task ConditionalDefineConstTestImpl() "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs index a3b0adde..22978b0c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest { - public sealed class XmlLatestUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -40,12 +40,12 @@ protected override Task ConstructorTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -65,7 +65,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -128,12 +128,12 @@ protected override Task ConstructorWithInitializeTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -144,7 +144,7 @@ operator int() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -160,12 +160,12 @@ operator int() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -173,7 +173,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,12 +186,12 @@ protected override Task DestructorTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -206,21 +206,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -243,12 +243,12 @@ int MyInt32Method() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -279,7 +279,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -319,12 +319,12 @@ int MyFunctionB(MyStruct* x) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -335,7 +335,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -351,12 +351,12 @@ int MyFunction() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -374,7 +374,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -460,19 +460,19 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -511,26 +511,26 @@ protected override Task NewKeywordVirtualTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -580,26 +580,26 @@ protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -669,12 +669,12 @@ protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestI "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -694,7 +694,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -735,12 +735,12 @@ protected override Task OperatorTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -770,7 +770,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -831,12 +831,12 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -852,14 +852,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -879,12 +879,12 @@ static int MyInt32Method() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -895,7 +895,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -911,12 +911,12 @@ int MyFunction() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -926,7 +926,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -944,12 +944,12 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -964,7 +964,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1000,12 +1000,12 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -1020,7 +1020,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1056,9 +1056,8 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs index b603e6ab..c1cdf5e8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestUnix_EnumDeclarationTest : EnumDeclarationTest { - public sealed class XmlLatestUnix_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -36,12 +36,12 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -49,7 +49,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -71,12 +71,12 @@ protected override Task BasicValueTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -84,15 +84,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -100,7 +100,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -119,12 +119,12 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -132,7 +132,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -151,12 +151,12 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum : int { MyEnum_Value1, MyEnum_Value2, @@ -164,7 +164,7 @@ protected override Task RemapTestImpl() } MyEnum; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -183,13 +183,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -200,7 +200,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -226,16 +226,16 @@ enum MyEnum2 : int "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -246,7 +246,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -271,16 +271,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -291,7 +291,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -316,16 +316,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -336,7 +336,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -361,17 +361,17 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -379,7 +379,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -407,12 +407,12 @@ protected override Task WithCastToEnumTypeImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -424,7 +424,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -455,12 +455,12 @@ enum MyEnum2 : int "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -468,7 +468,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -497,12 +497,12 @@ protected override Task WithImplicitConversionTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -510,7 +510,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -529,15 +529,15 @@ protected override Task WithTypeTestImpl() "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -545,7 +545,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -567,16 +567,16 @@ protected override Task WithTypeAndImplicitConversionTestImpl() "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -587,7 +587,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -606,16 +606,16 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -626,7 +626,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -645,12 +645,11 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationBodyImportTest.cs index 0a14866b..8ee0119a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class XmlLatestUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -35,17 +35,17 @@ protected override Task ArraySubscriptTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -58,18 +58,18 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -88,18 +88,18 @@ protected override Task BinaryOperatorBasicTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -118,18 +118,18 @@ protected override Task BinaryOperatorCompareTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,12 +148,12 @@ protected override Task BinaryOperatorBooleanTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -164,7 +164,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -185,12 +185,12 @@ protected override Task BreakTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -200,7 +200,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -217,12 +217,12 @@ void MyFunction() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -232,7 +232,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,12 +255,12 @@ void MyFunction() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -280,7 +280,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -310,12 +310,12 @@ protected override Task CaseTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -331,7 +331,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -361,12 +361,12 @@ protected override Task CaseNoCompoundTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -381,7 +381,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -409,18 +409,18 @@ static inline int MyFunction(MyEnum x) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -442,12 +442,12 @@ protected override Task ConditionalOperatorTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -458,7 +458,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -479,18 +479,18 @@ protected override Task ContinueTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -506,18 +506,18 @@ protected override Task CStyleFunctionalCastTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -533,18 +533,18 @@ protected override Task CxxFunctionalCastTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -560,12 +560,12 @@ protected override Task CxxConstCastTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -578,7 +578,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -616,18 +616,18 @@ struct MyStructB : MyStructA { }; "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -643,18 +643,18 @@ protected override Task CxxReinterpretCastTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -670,12 +670,12 @@ protected override Task CxxStaticCastTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -684,7 +684,7 @@ int MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -700,12 +700,12 @@ int MyFunction() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -719,7 +719,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -743,12 +743,12 @@ protected override Task DoTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -759,7 +759,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -782,12 +782,12 @@ protected override Task DoNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -859,7 +859,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -932,12 +932,12 @@ protected override Task ForTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -985,7 +985,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1058,12 +1058,12 @@ protected override Task ForNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1074,7 +1074,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1101,12 +1101,12 @@ protected override Task IfTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1119,7 +1119,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1148,12 +1148,12 @@ protected override Task IfElseTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1168,7 +1168,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1205,12 +1205,12 @@ protected override Task IfElseIfTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1219,7 +1219,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1248,12 +1248,12 @@ protected override Task IfElseNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1262,7 +1262,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1293,12 +1293,12 @@ void MyFunction() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1317,7 +1317,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1359,12 +1359,12 @@ MyStruct MyFunction2() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1380,7 +1380,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1408,12 +1408,12 @@ int MyFunction2(MyStruct* instance) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1423,7 +1423,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1447,18 +1447,18 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1471,18 +1471,18 @@ protected override Task ReturnCXXNullPtrTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1495,18 +1495,18 @@ protected override Task ReturnCXXBooleanLiteralTestImpl(string value) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1519,18 +1519,18 @@ protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1543,18 +1543,18 @@ protected override Task ReturnFloatingLiteralSingleTestImpl(string value) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1567,18 +1567,18 @@ protected override Task ReturnEmptyTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1591,12 +1591,12 @@ protected override Task ReturnIntegerLiteralInt32TestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1608,7 +1608,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1639,12 +1639,12 @@ void MyFunction() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1658,7 +1658,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1684,12 +1684,12 @@ MyStruct MyFunction() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1701,7 +1701,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1723,12 +1723,12 @@ protected override Task SwitchTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1742,7 +1742,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1772,18 +1772,18 @@ protected override Task SwitchNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1799,18 +1799,18 @@ protected override Task UnaryOperatorAddrOfTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1826,18 +1826,18 @@ protected override Task UnaryOperatorDerefTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1853,18 +1853,18 @@ protected override Task UnaryOperatorLogicalNotTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1880,18 +1880,18 @@ protected override Task UnaryOperatorPostfixTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1907,12 +1907,12 @@ protected override Task UnaryOperatorPrefixTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1925,7 +1925,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1948,12 +1948,12 @@ protected override Task WhileTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1964,7 +1964,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1987,7 +1987,6 @@ protected override Task WhileNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs index 2fa6dc87..3b673858 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class XmlLatestUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -24,14 +24,14 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -46,14 +46,14 @@ protected override Task ArrayParameterTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -68,24 +68,24 @@ protected override Task FunctionPointerParameterTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -97,16 +97,16 @@ protected override Task NamespaceTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -121,12 +121,12 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -136,7 +136,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,14 +148,14 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -167,14 +167,14 @@ protected override Task NoLibraryPathTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,18 +186,18 @@ protected override Task WithLibraryPathTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @" + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @" @@ -209,18 +209,18 @@ protected override Task WithLibraryPathStarTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -238,14 +238,14 @@ protected override Task OptionalParameterTestImpl(string nativeType, string nati "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -263,14 +263,14 @@ protected override Task OptionalParameterUnsafeTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -291,17 +291,17 @@ protected override Task WithCallConvTestImpl() "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -322,18 +322,18 @@ protected override Task WithCallConvStarTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -354,19 +354,19 @@ protected override Task WithCallConvStarOverrideTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -387,18 +387,18 @@ protected override Task WithSetLastErrorTestImpl() "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @" + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @" @@ -419,18 +419,18 @@ protected override Task WithSetLastErrorStarTestImpl() "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @" + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @" @@ -445,9 +445,8 @@ protected override Task SourceLocationTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; + return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } + + protected override Task VarargsTestImpl() => Task.CompletedTask; } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionPointerDeclarationTest.cs index 113d09a9..c0be5b45 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class XmlLatestUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -27,19 +27,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -51,19 +51,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -75,7 +75,6 @@ struct MyStruct { "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs index e6d1b1cf..d06082d2 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestUnix_StructDeclarationTest : StructDeclarationTest { - public sealed class XmlLatestUnix_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -30,12 +30,12 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -43,7 +43,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -61,12 +61,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -74,7 +74,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -91,12 +91,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -104,7 +104,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -122,12 +122,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -152,7 +152,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -293,21 +293,21 @@ struct MyStruct3 "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -318,7 +318,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -359,12 +359,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -375,7 +375,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -479,12 +479,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -497,7 +497,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -538,12 +538,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -554,7 +554,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -595,18 +595,18 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -641,18 +641,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -664,18 +664,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -687,12 +687,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -700,7 +700,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -712,18 +712,18 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Unix doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -736,7 +736,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -757,13 +757,13 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -782,7 +782,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -819,12 +819,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -843,7 +843,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -880,12 +880,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -910,7 +910,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1012,12 +1012,12 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1036,7 +1036,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1120,12 +1120,12 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1141,7 +1141,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1173,12 +1173,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1194,7 +1194,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1226,12 +1226,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1242,7 +1242,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1272,25 +1272,25 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1309,9 +1309,9 @@ struct MyStruct2 { }; "; - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; + var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1340,17 +1340,17 @@ struct MyStruct2 { "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1365,19 +1365,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1392,14 +1392,14 @@ struct example_s { "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1407,13 +1407,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1425,7 +1425,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1457,16 +1457,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1476,7 +1476,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1494,16 +1494,16 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1511,12 +1511,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1526,7 +1526,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1544,12 +1544,12 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1559,7 +1559,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1577,12 +1577,12 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1593,7 +1593,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1612,12 +1612,12 @@ struct MyStruct1B : MyStruct1A "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1636,7 +1636,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1667,18 +1667,18 @@ struct MyStruct3 "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1686,7 +1686,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @" + const string ExpectedOutputContents = @" @@ -1704,7 +1704,6 @@ protected override Task SourceLocationAttributeTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs index 9711f866..bb6e248c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestUnix_UnionDeclarationTest : UnionDeclarationTest { - public sealed class XmlLatestUnix_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -37,12 +37,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -50,7 +50,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -67,12 +67,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -80,7 +80,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -98,12 +98,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -128,9 +128,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -271,21 +271,21 @@ union MyUnion3 "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -296,7 +296,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -337,12 +337,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -353,7 +353,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -457,12 +457,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -475,7 +475,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -516,12 +516,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -532,7 +532,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -573,18 +573,18 @@ union MyOtherUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -619,18 +619,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -642,18 +642,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -665,12 +665,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -678,7 +678,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -690,17 +690,17 @@ union MyUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Unix doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -713,7 +713,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -734,13 +734,13 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -761,7 +761,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -816,12 +816,12 @@ union MyUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -840,7 +840,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -924,13 +924,13 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -946,7 +946,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -978,12 +978,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -999,7 +999,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1031,12 +1031,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1047,7 +1047,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1077,31 +1077,31 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1116,19 +1116,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1143,14 +1143,14 @@ union example_s { "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1158,13 +1158,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1176,7 +1176,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1208,16 +1208,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1227,7 +1227,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1245,16 +1245,16 @@ union MyUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1262,12 +1262,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1277,7 +1277,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1295,12 +1295,12 @@ union MyUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1310,7 +1310,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1328,7 +1328,6 @@ union MyUnion "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs index 2423b12b..5db9074c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestUnix_VarDeclarationTest : VarDeclarationTest { - public sealed class XmlLatestUnix_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -26,14 +26,14 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -48,12 +48,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -63,7 +63,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -77,18 +77,18 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -109,15 +109,15 @@ protected override Task MacroTestImpl(string nativeValue, string expectedManaged "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -132,21 +132,21 @@ protected override Task MultilineMacroTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -161,14 +161,14 @@ protected override Task Utf8StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -183,16 +183,16 @@ protected override Task Utf16StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -219,16 +219,16 @@ protected override Task WideStringLiteralConstTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,16 +255,16 @@ protected override Task StringLiteralConstTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -291,16 +291,16 @@ protected override Task WideStringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -327,15 +327,15 @@ protected override Task StringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -364,14 +364,14 @@ protected override Task UncheckedConversionMacroTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -390,16 +390,16 @@ protected override Task UncheckedFunctionLikeCastMacroTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -416,15 +416,15 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -441,14 +441,14 @@ protected override Task UncheckedPointerMacroTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -467,14 +467,14 @@ protected override Task UncheckedReinterpretCastMacroTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -501,16 +501,16 @@ protected override Task MultidimensionlArrayTestImpl() "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -526,9 +526,8 @@ protected override Task ConditionalDefineConstTestImpl() "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs index c480d7bf..ead9e451 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest { - public sealed class XmlLatestWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -40,12 +40,12 @@ protected override Task ConstructorTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -65,7 +65,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -128,12 +128,12 @@ protected override Task ConstructorWithInitializeTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -144,7 +144,7 @@ operator int() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -160,12 +160,12 @@ operator int() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -173,7 +173,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,12 +186,12 @@ protected override Task DestructorTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -206,21 +206,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -243,12 +243,12 @@ int MyInt32Method() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -279,7 +279,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -319,12 +319,12 @@ int MyFunctionB(MyStruct* x) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -335,7 +335,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -351,12 +351,12 @@ int MyFunction() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -374,7 +374,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -460,19 +460,19 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -511,26 +511,26 @@ protected override Task NewKeywordVirtualTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -580,26 +580,26 @@ protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -669,12 +669,12 @@ protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestI "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -694,7 +694,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -735,12 +735,12 @@ protected override Task OperatorTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -770,7 +770,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -831,12 +831,12 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -852,14 +852,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -879,12 +879,12 @@ static int MyInt32Method() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -895,7 +895,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -911,12 +911,12 @@ int MyFunction() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -926,7 +926,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -944,12 +944,12 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -964,7 +964,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1000,12 +1000,12 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -1020,7 +1020,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1056,9 +1056,8 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs index 5abb17db..7759d613 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestWindows_EnumDeclarationTest : EnumDeclarationTest { - public sealed class XmlLatestWindows_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -36,12 +36,12 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -49,7 +49,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -71,12 +71,12 @@ protected override Task BasicValueTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -84,15 +84,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -100,7 +100,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -119,12 +119,12 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -132,7 +132,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -151,12 +151,12 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum : int { MyEnum_Value1, MyEnum_Value2, @@ -164,7 +164,7 @@ protected override Task RemapTestImpl() } MyEnum; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -183,13 +183,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -200,7 +200,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -226,16 +226,16 @@ enum MyEnum2 : int "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -246,7 +246,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -271,16 +271,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -291,7 +291,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -316,16 +316,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -336,7 +336,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -361,17 +361,17 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -379,7 +379,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -407,12 +407,12 @@ protected override Task WithCastToEnumTypeImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -424,7 +424,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -455,12 +455,12 @@ enum MyEnum2 : int "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -468,7 +468,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -497,12 +497,12 @@ protected override Task WithImplicitConversionTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -510,7 +510,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -529,15 +529,15 @@ protected override Task WithTypeTestImpl() "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -545,7 +545,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -567,16 +567,16 @@ protected override Task WithTypeAndImplicitConversionTestImpl() "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -587,7 +587,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -606,16 +606,16 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -626,7 +626,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -645,12 +645,11 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationBodyImportTest.cs index 2ac21160..e5f505e7 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class XmlLatestWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -35,17 +35,17 @@ protected override Task ArraySubscriptTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -58,18 +58,18 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -88,18 +88,18 @@ protected override Task BinaryOperatorBasicTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -118,18 +118,18 @@ protected override Task BinaryOperatorCompareTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,12 +148,12 @@ protected override Task BinaryOperatorBooleanTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -164,7 +164,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -185,12 +185,12 @@ protected override Task BreakTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -200,7 +200,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -217,12 +217,12 @@ void MyFunction() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -232,7 +232,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,12 +255,12 @@ void MyFunction() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -280,7 +280,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -310,12 +310,12 @@ protected override Task CaseTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -331,7 +331,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -361,12 +361,12 @@ protected override Task CaseNoCompoundTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -381,7 +381,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -409,18 +409,18 @@ static inline int MyFunction(MyEnum x) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -442,12 +442,12 @@ protected override Task ConditionalOperatorTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -458,7 +458,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -479,18 +479,18 @@ protected override Task ContinueTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -506,18 +506,18 @@ protected override Task CStyleFunctionalCastTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -533,18 +533,18 @@ protected override Task CxxFunctionalCastTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -560,12 +560,12 @@ protected override Task CxxConstCastTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -578,7 +578,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -616,18 +616,18 @@ struct MyStructB : MyStructA { }; "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -643,18 +643,18 @@ protected override Task CxxReinterpretCastTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -670,12 +670,12 @@ protected override Task CxxStaticCastTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -684,7 +684,7 @@ int MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -700,12 +700,12 @@ int MyFunction() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -719,7 +719,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -743,12 +743,12 @@ protected override Task DoTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -759,7 +759,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -782,12 +782,12 @@ protected override Task DoNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -859,7 +859,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -932,12 +932,12 @@ protected override Task ForTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -985,7 +985,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1058,12 +1058,12 @@ protected override Task ForNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1074,7 +1074,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1101,12 +1101,12 @@ protected override Task IfTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1119,7 +1119,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1148,12 +1148,12 @@ protected override Task IfElseTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1168,7 +1168,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1205,12 +1205,12 @@ protected override Task IfElseIfTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1219,7 +1219,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1248,12 +1248,12 @@ protected override Task IfElseNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1262,7 +1262,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1293,12 +1293,12 @@ void MyFunction() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1317,7 +1317,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1359,12 +1359,12 @@ MyStruct MyFunction2() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1380,7 +1380,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1408,12 +1408,12 @@ int MyFunction2(MyStruct* instance) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1423,7 +1423,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1447,18 +1447,18 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1471,18 +1471,18 @@ protected override Task ReturnCXXNullPtrTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1495,18 +1495,18 @@ protected override Task ReturnCXXBooleanLiteralTestImpl(string value) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1519,18 +1519,18 @@ protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1543,18 +1543,18 @@ protected override Task ReturnFloatingLiteralSingleTestImpl(string value) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1567,18 +1567,18 @@ protected override Task ReturnEmptyTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1591,12 +1591,12 @@ protected override Task ReturnIntegerLiteralInt32TestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1608,7 +1608,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1639,12 +1639,12 @@ void MyFunction() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1658,7 +1658,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1684,12 +1684,12 @@ MyStruct MyFunction() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1701,7 +1701,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1723,12 +1723,12 @@ protected override Task SwitchTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1742,7 +1742,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1772,18 +1772,18 @@ protected override Task SwitchNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1799,18 +1799,18 @@ protected override Task UnaryOperatorAddrOfTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1826,18 +1826,18 @@ protected override Task UnaryOperatorDerefTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1853,18 +1853,18 @@ protected override Task UnaryOperatorLogicalNotTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1880,18 +1880,18 @@ protected override Task UnaryOperatorPostfixTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1907,12 +1907,12 @@ protected override Task UnaryOperatorPrefixTestImpl(string opcode) "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1925,7 +1925,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1948,12 +1948,12 @@ protected override Task WhileTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1964,7 +1964,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1987,7 +1987,6 @@ protected override Task WhileNonCompoundTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs index 80d170d5..464d5cc8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class XmlLatestWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -24,14 +24,14 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -46,14 +46,14 @@ protected override Task ArrayParameterTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -68,24 +68,24 @@ protected override Task FunctionPointerParameterTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -97,16 +97,16 @@ protected override Task NamespaceTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -121,12 +121,12 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -136,7 +136,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,14 +148,14 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -167,14 +167,14 @@ protected override Task NoLibraryPathTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,18 +186,18 @@ protected override Task WithLibraryPathTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @" + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @" @@ -209,18 +209,18 @@ protected override Task WithLibraryPathStarTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -238,14 +238,14 @@ protected override Task OptionalParameterTestImpl(string nativeType, string nati "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -263,14 +263,14 @@ protected override Task OptionalParameterUnsafeTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -291,17 +291,17 @@ protected override Task WithCallConvTestImpl() "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -322,18 +322,18 @@ protected override Task WithCallConvStarTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -354,19 +354,19 @@ protected override Task WithCallConvStarOverrideTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -387,18 +387,18 @@ protected override Task WithSetLastErrorTestImpl() "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @" + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @" @@ -419,18 +419,18 @@ protected override Task WithSetLastErrorStarTestImpl() "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @" + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @" @@ -445,9 +445,8 @@ protected override Task SourceLocationTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } + + protected override Task VarargsTestImpl() => Task.CompletedTask; } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionPointerDeclarationTest.cs index f012238f..e807dda2 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class XmlLatestWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -27,19 +27,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -51,19 +51,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -75,7 +75,6 @@ struct MyStruct { "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs index 03d9e1d6..90c79bf5 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestWindows_StructDeclarationTest : StructDeclarationTest { - public sealed class XmlLatestWindows_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -30,12 +30,12 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -43,7 +43,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -61,12 +61,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -74,7 +74,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -91,12 +91,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -104,7 +104,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -122,12 +122,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -152,7 +152,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -299,21 +299,21 @@ struct MyStruct3 "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -324,7 +324,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -365,12 +365,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -381,7 +381,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -485,12 +485,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -503,7 +503,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -544,12 +544,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -560,7 +560,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -601,18 +601,18 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -647,18 +647,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -670,18 +670,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -693,12 +693,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -706,7 +706,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -718,18 +718,18 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -742,7 +742,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -763,13 +763,13 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -788,7 +788,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -825,12 +825,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -849,7 +849,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -886,12 +886,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -916,7 +916,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1018,12 +1018,12 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1042,7 +1042,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1126,12 +1126,12 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1147,7 +1147,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1179,12 +1179,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1200,7 +1200,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1232,12 +1232,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1248,7 +1248,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1278,25 +1278,25 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1315,9 +1315,9 @@ struct MyStruct2 { }; "; - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; + var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1346,17 +1346,17 @@ struct MyStruct2 { "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1371,19 +1371,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1398,14 +1398,14 @@ struct example_s { "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1413,13 +1413,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1431,7 +1431,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1463,16 +1463,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1482,7 +1482,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1500,16 +1500,16 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1517,12 +1517,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1532,7 +1532,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1550,12 +1550,12 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1565,7 +1565,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1583,12 +1583,12 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1599,7 +1599,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1618,12 +1618,12 @@ struct MyStruct1B : MyStruct1A "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1642,7 +1642,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1673,18 +1673,18 @@ struct MyStruct3 "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1692,7 +1692,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @" + const string ExpectedOutputContents = @" @@ -1710,7 +1710,6 @@ protected override Task SourceLocationAttributeTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs index e5794ac2..72f7860a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestWindows_UnionDeclarationTest : UnionDeclarationTest { - public sealed class XmlLatestWindows_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -37,12 +37,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -50,7 +50,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -67,12 +67,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -80,7 +80,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -98,12 +98,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -128,9 +128,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -277,21 +277,21 @@ union MyUnion3 "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -302,7 +302,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -343,12 +343,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -359,7 +359,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -463,12 +463,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -481,7 +481,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -522,12 +522,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -538,7 +538,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -579,18 +579,18 @@ union MyOtherUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -625,18 +625,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -648,18 +648,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -671,12 +671,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -684,7 +684,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -696,17 +696,17 @@ union MyUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -719,7 +719,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -740,13 +740,13 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -767,7 +767,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -822,12 +822,12 @@ union MyUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -846,7 +846,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -930,13 +930,13 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -952,7 +952,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -984,12 +984,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1005,7 +1005,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1037,12 +1037,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1053,7 +1053,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1083,31 +1083,31 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1122,19 +1122,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1149,14 +1149,14 @@ union example_s { "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1164,13 +1164,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1182,7 +1182,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1214,16 +1214,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1233,7 +1233,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1251,16 +1251,16 @@ union MyUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1268,12 +1268,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1283,7 +1283,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1301,12 +1301,12 @@ union MyUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1316,7 +1316,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1334,7 +1334,6 @@ union MyUnion "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs index 24a3aaea..6e564c40 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlLatestWindows_VarDeclarationTest : VarDeclarationTest { - public sealed class XmlLatestWindows_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -26,14 +26,14 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -48,12 +48,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -63,7 +63,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -77,18 +77,18 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -109,15 +109,15 @@ protected override Task MacroTestImpl(string nativeValue, string expectedManaged "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -132,21 +132,21 @@ protected override Task MultilineMacroTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -161,14 +161,14 @@ protected override Task Utf8StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -183,16 +183,16 @@ protected override Task Utf16StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -219,16 +219,16 @@ protected override Task WideStringLiteralConstTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,16 +255,16 @@ protected override Task StringLiteralConstTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -291,16 +291,16 @@ protected override Task WideStringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -327,15 +327,15 @@ protected override Task StringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -364,14 +364,14 @@ protected override Task UncheckedConversionMacroTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -390,16 +390,16 @@ protected override Task UncheckedFunctionLikeCastMacroTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -416,15 +416,15 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -441,14 +441,14 @@ protected override Task UncheckedPointerMacroTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -467,14 +467,14 @@ protected override Task UncheckedReinterpretCastMacroTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -501,16 +501,16 @@ protected override Task MultidimensionlArrayTestImpl() "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -526,9 +526,8 @@ protected override Task ConditionalDefineConstTestImpl() "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs index 40a70c40..d111de8a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest { - public sealed class XmlPreviewUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -40,12 +40,12 @@ protected override Task ConstructorTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -65,7 +65,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -128,12 +128,12 @@ protected override Task ConstructorWithInitializeTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -144,7 +144,7 @@ operator int() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -160,12 +160,12 @@ operator int() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -173,7 +173,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,12 +186,12 @@ protected override Task DestructorTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -206,21 +206,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -243,12 +243,12 @@ int MyInt32Method() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -279,7 +279,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -319,12 +319,12 @@ int MyFunctionB(MyStruct* x) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -335,7 +335,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -351,12 +351,12 @@ int MyFunction() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -374,7 +374,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -460,19 +460,19 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -511,26 +511,26 @@ protected override Task NewKeywordVirtualTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -580,26 +580,26 @@ protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -669,12 +669,12 @@ protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestI "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -694,7 +694,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -735,12 +735,12 @@ protected override Task OperatorTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -770,7 +770,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -831,12 +831,12 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -852,14 +852,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -879,12 +879,12 @@ static int MyInt32Method() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -895,7 +895,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -911,12 +911,12 @@ int MyFunction() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -926,7 +926,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -944,12 +944,12 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -964,7 +964,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1000,12 +1000,12 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -1020,7 +1020,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1056,9 +1056,8 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs index 5c0a531a..c98a649e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewUnix_EnumDeclarationTest : EnumDeclarationTest { - public sealed class XmlPreviewUnix_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -36,12 +36,12 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -49,7 +49,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -71,12 +71,12 @@ protected override Task BasicValueTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -84,15 +84,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -100,7 +100,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -119,12 +119,12 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -132,7 +132,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -151,12 +151,12 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum : int { MyEnum_Value1, MyEnum_Value2, @@ -164,7 +164,7 @@ protected override Task RemapTestImpl() } MyEnum; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -183,13 +183,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -200,7 +200,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -226,16 +226,16 @@ enum MyEnum2 : int "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -246,7 +246,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -271,16 +271,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -291,7 +291,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -316,16 +316,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -336,7 +336,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -361,17 +361,17 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -379,7 +379,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -407,12 +407,12 @@ protected override Task WithCastToEnumTypeImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -424,7 +424,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -455,12 +455,12 @@ enum MyEnum2 : int "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -468,7 +468,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -497,12 +497,12 @@ protected override Task WithImplicitConversionTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -510,7 +510,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -529,15 +529,15 @@ protected override Task WithTypeTestImpl() "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -545,7 +545,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -567,16 +567,16 @@ protected override Task WithTypeAndImplicitConversionTestImpl() "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -587,7 +587,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -606,16 +606,16 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -626,7 +626,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -645,12 +645,11 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationBodyImportTest.cs index d3e36461..bb0b76f6 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class XmlPreviewUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -35,17 +35,17 @@ protected override Task ArraySubscriptTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -58,18 +58,18 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -88,18 +88,18 @@ protected override Task BinaryOperatorBasicTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -118,18 +118,18 @@ protected override Task BinaryOperatorCompareTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,12 +148,12 @@ protected override Task BinaryOperatorBooleanTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -164,7 +164,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -185,12 +185,12 @@ protected override Task BreakTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -200,7 +200,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -217,12 +217,12 @@ void MyFunction() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -232,7 +232,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,12 +255,12 @@ void MyFunction() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -280,7 +280,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -310,12 +310,12 @@ protected override Task CaseTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -331,7 +331,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -361,12 +361,12 @@ protected override Task CaseNoCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -381,7 +381,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -409,18 +409,18 @@ static inline int MyFunction(MyEnum x) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -442,12 +442,12 @@ protected override Task ConditionalOperatorTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -458,7 +458,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -479,18 +479,18 @@ protected override Task ContinueTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -506,18 +506,18 @@ protected override Task CStyleFunctionalCastTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -533,18 +533,18 @@ protected override Task CxxFunctionalCastTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -560,12 +560,12 @@ protected override Task CxxConstCastTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -578,7 +578,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -616,18 +616,18 @@ struct MyStructB : MyStructA { }; "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -643,18 +643,18 @@ protected override Task CxxReinterpretCastTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -670,12 +670,12 @@ protected override Task CxxStaticCastTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -684,7 +684,7 @@ int MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -700,12 +700,12 @@ int MyFunction() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -719,7 +719,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -743,12 +743,12 @@ protected override Task DoTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -759,7 +759,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -782,12 +782,12 @@ protected override Task DoNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -859,7 +859,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -932,12 +932,12 @@ protected override Task ForTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -985,7 +985,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1058,12 +1058,12 @@ protected override Task ForNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1074,7 +1074,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1101,12 +1101,12 @@ protected override Task IfTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1119,7 +1119,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1148,12 +1148,12 @@ protected override Task IfElseTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1168,7 +1168,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1205,12 +1205,12 @@ protected override Task IfElseIfTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1219,7 +1219,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1248,12 +1248,12 @@ protected override Task IfElseNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1262,7 +1262,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1293,12 +1293,12 @@ void MyFunction() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1317,7 +1317,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1359,12 +1359,12 @@ MyStruct MyFunction2() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1380,7 +1380,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1408,12 +1408,12 @@ int MyFunction2(MyStruct* instance) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1423,7 +1423,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1447,18 +1447,18 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1471,18 +1471,18 @@ protected override Task ReturnCXXNullPtrTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1495,18 +1495,18 @@ protected override Task ReturnCXXBooleanLiteralTestImpl(string value) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1519,18 +1519,18 @@ protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1543,18 +1543,18 @@ protected override Task ReturnFloatingLiteralSingleTestImpl(string value) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1567,18 +1567,18 @@ protected override Task ReturnEmptyTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1591,12 +1591,12 @@ protected override Task ReturnIntegerLiteralInt32TestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1608,7 +1608,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1639,12 +1639,12 @@ void MyFunction() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1658,7 +1658,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1684,12 +1684,12 @@ MyStruct MyFunction() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1701,7 +1701,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1723,12 +1723,12 @@ protected override Task SwitchTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1742,7 +1742,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1772,18 +1772,18 @@ protected override Task SwitchNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1799,18 +1799,18 @@ protected override Task UnaryOperatorAddrOfTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1826,18 +1826,18 @@ protected override Task UnaryOperatorDerefTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1853,18 +1853,18 @@ protected override Task UnaryOperatorLogicalNotTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1880,18 +1880,18 @@ protected override Task UnaryOperatorPostfixTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1907,12 +1907,12 @@ protected override Task UnaryOperatorPrefixTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1925,7 +1925,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1948,12 +1948,12 @@ protected override Task WhileTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1964,7 +1964,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1987,7 +1987,6 @@ protected override Task WhileNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs index 63e2289f..bfb100c0 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class XmlPreviewUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -24,14 +24,14 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -46,14 +46,14 @@ protected override Task ArrayParameterTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -68,24 +68,24 @@ protected override Task FunctionPointerParameterTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -97,16 +97,16 @@ protected override Task NamespaceTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -121,12 +121,12 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -136,7 +136,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,14 +148,14 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -167,14 +167,14 @@ protected override Task NoLibraryPathTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,18 +186,18 @@ protected override Task WithLibraryPathTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @" + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @" @@ -209,18 +209,18 @@ protected override Task WithLibraryPathStarTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -238,14 +238,14 @@ protected override Task OptionalParameterTestImpl(string nativeType, string nati "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -263,14 +263,14 @@ protected override Task OptionalParameterUnsafeTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -291,17 +291,17 @@ protected override Task WithCallConvTestImpl() "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -322,18 +322,18 @@ protected override Task WithCallConvStarTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -354,19 +354,19 @@ protected override Task WithCallConvStarOverrideTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -387,18 +387,18 @@ protected override Task WithSetLastErrorTestImpl() "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @" + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @" @@ -419,18 +419,18 @@ protected override Task WithSetLastErrorStarTestImpl() "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @" + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @" @@ -445,9 +445,8 @@ protected override Task SourceLocationTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } + + protected override Task VarargsTestImpl() => Task.CompletedTask; } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionPointerDeclarationTest.cs index 0e707f4c..9df4290f 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class XmlPreviewUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -27,19 +27,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -51,19 +51,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -75,7 +75,6 @@ struct MyStruct { "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs index b5b77f28..b11c37d5 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewUnix_StructDeclarationTest : StructDeclarationTest { - public sealed class XmlPreviewUnix_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -30,12 +30,12 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -43,7 +43,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -61,12 +61,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -74,7 +74,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -91,12 +91,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -104,7 +104,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -122,12 +122,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -152,7 +152,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -293,21 +293,21 @@ struct MyStruct3 "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -318,7 +318,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -359,12 +359,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -375,7 +375,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -479,12 +479,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -497,7 +497,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -538,12 +538,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -554,7 +554,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -595,18 +595,18 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -641,18 +641,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -664,18 +664,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -687,12 +687,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -700,7 +700,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -712,18 +712,18 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Unix doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -736,7 +736,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -757,13 +757,13 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -782,7 +782,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -819,12 +819,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -843,7 +843,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -880,12 +880,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -910,7 +910,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1012,12 +1012,12 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1036,7 +1036,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1120,12 +1120,12 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1141,7 +1141,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1173,12 +1173,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1194,7 +1194,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1226,12 +1226,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1242,7 +1242,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1272,25 +1272,25 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1309,9 +1309,9 @@ struct MyStruct2 { }; "; - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; + var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1340,17 +1340,17 @@ struct MyStruct2 { "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1365,19 +1365,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1392,14 +1392,14 @@ struct example_s { "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1407,13 +1407,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1425,7 +1425,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1457,16 +1457,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1476,7 +1476,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1494,16 +1494,16 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1511,12 +1511,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1526,7 +1526,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1544,12 +1544,12 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1559,7 +1559,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1577,12 +1577,12 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1593,7 +1593,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1612,12 +1612,12 @@ struct MyStruct1B : MyStruct1A "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1636,7 +1636,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1667,18 +1667,18 @@ struct MyStruct3 "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1686,7 +1686,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @" + const string ExpectedOutputContents = @" @@ -1704,7 +1704,6 @@ protected override Task SourceLocationAttributeTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs index 5ee6785e..7a10e43c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewUnix_UnionDeclarationTest : UnionDeclarationTest { - public sealed class XmlPreviewUnix_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -37,12 +37,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -50,7 +50,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -67,12 +67,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -80,7 +80,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -98,12 +98,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -128,9 +128,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -271,21 +271,21 @@ union MyUnion3 "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -296,7 +296,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -337,12 +337,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -353,7 +353,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -457,12 +457,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -475,7 +475,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -516,12 +516,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -532,7 +532,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -573,18 +573,18 @@ union MyOtherUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -619,18 +619,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -642,18 +642,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -665,12 +665,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -678,7 +678,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -690,17 +690,17 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Unix doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -713,7 +713,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -734,13 +734,13 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -761,7 +761,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -816,12 +816,12 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -840,7 +840,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -924,13 +924,13 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -946,7 +946,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -978,12 +978,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -999,7 +999,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1031,12 +1031,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1047,7 +1047,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1077,31 +1077,31 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1116,19 +1116,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1143,14 +1143,14 @@ union example_s { "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1158,13 +1158,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1176,7 +1176,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1208,16 +1208,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1227,7 +1227,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1245,16 +1245,16 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1262,12 +1262,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1277,7 +1277,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1295,12 +1295,12 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1310,7 +1310,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1328,7 +1328,6 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs index ea2425ad..0ea9ba3b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewUnix_VarDeclarationTest : VarDeclarationTest { - public sealed class XmlPreviewUnix_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -26,14 +26,14 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -48,12 +48,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -63,7 +63,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -77,18 +77,18 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -109,15 +109,15 @@ protected override Task MacroTestImpl(string nativeValue, string expectedManaged "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -132,21 +132,21 @@ protected override Task MultilineMacroTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -161,14 +161,14 @@ protected override Task Utf8StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -183,16 +183,16 @@ protected override Task Utf16StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -219,16 +219,16 @@ protected override Task WideStringLiteralConstTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,16 +255,16 @@ protected override Task StringLiteralConstTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -291,16 +291,16 @@ protected override Task WideStringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -327,15 +327,15 @@ protected override Task StringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -364,14 +364,14 @@ protected override Task UncheckedConversionMacroTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -390,16 +390,16 @@ protected override Task UncheckedFunctionLikeCastMacroTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -416,15 +416,15 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -441,14 +441,14 @@ protected override Task UncheckedPointerMacroTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -467,14 +467,14 @@ protected override Task UncheckedReinterpretCastMacroTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -501,16 +501,16 @@ protected override Task MultidimensionlArrayTestImpl() "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -526,9 +526,8 @@ protected override Task ConditionalDefineConstTestImpl() "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs index 303f9816..7aa48aa7 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs @@ -4,13 +4,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest { - public sealed class XmlPreviewWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest + protected override Task ConstructorTestImpl() { - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct + var inputContents = @"struct MyStruct { int _value; @@ -21,7 +21,7 @@ protected override Task ConstructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -40,12 +40,12 @@ protected override Task ConstructorTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConstructorWithInitializeTestImpl() + { + var inputContents = @"struct MyStruct { int _x; int _y; @@ -65,7 +65,7 @@ protected override Task ConstructorWithInitializeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -128,12 +128,12 @@ protected override Task ConstructorWithInitializeTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ConversionTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -144,7 +144,7 @@ operator int() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -160,12 +160,12 @@ operator int() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task DestructorTestImpl() + { + var inputContents = @"struct MyStruct { ~MyStruct() { @@ -173,7 +173,7 @@ protected override Task DestructorTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,12 +186,12 @@ protected override Task DestructorTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InstanceTestImpl() + { + var inputContents = @"struct MyStruct { void MyVoidMethod(); @@ -206,21 +206,21 @@ int MyInt32Method() } }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + if (!Environment.Is64BitProcess) + { + entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; + } + else { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } + entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; } + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -243,12 +243,12 @@ int MyInt32Method() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -279,7 +279,7 @@ int MyFunctionB(MyStruct* x) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -319,12 +319,12 @@ int MyFunctionB(MyStruct* x) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -335,7 +335,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -351,12 +351,12 @@ int MyFunction() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals() { return 0; } int Equals(int obj) { return 0; } @@ -374,7 +374,7 @@ protected override Task NewKeywordTestImpl() int ToString(int obj) { return 0; } };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -460,19 +460,19 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -511,26 +511,26 @@ protected override Task NewKeywordVirtualTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -580,26 +580,26 @@ protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + } - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() + { + var inputContents = @"struct MyStruct { virtual int GetType(int obj) = 0; virtual int GetType() = 0; virtual int GetType(int objA, int objB) = 0; };"; - var nativeCallConv = ""; + var nativeCallConv = ""; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) + { + nativeCallConv = " __attribute__((thiscall))"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -669,12 +669,12 @@ protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestI "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + } - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -694,7 +694,7 @@ protected override Task OperatorTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -735,12 +735,12 @@ protected override Task OperatorTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task OperatorCallTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -770,7 +770,7 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -831,12 +831,12 @@ MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task StaticTestImpl() + { + var inputContents = @"struct MyStruct { static void MyVoidMethod(); @@ -852,14 +852,14 @@ static int MyInt32Method() }; "; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + entryPoint = $"_{entryPoint}"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -879,12 +879,12 @@ static int MyInt32Method() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ThisTestImpl() + { + var inputContents = @"struct MyStruct { int value; @@ -895,7 +895,7 @@ int MyFunction() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -911,12 +911,12 @@ int MyFunction() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task UnsafeDoesNotImpactDllImportTestImpl() + { + var inputContents = @"struct MyStruct { void* MyVoidStarMethod() { @@ -926,7 +926,7 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -944,12 +944,12 @@ protected override Task UnsafeDoesNotImpactDllImportTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -964,7 +964,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1000,12 +1000,12 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task VirtualWithVtblIndexAttributeTestImpl() + { + var inputContents = @"struct MyStruct { virtual void MyVoidMethod() = 0; @@ -1020,7 +1020,7 @@ virtual char MyInt8Method() }; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1056,9 +1056,8 @@ virtual char MyInt8Method() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); } + + protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs index a668796c..a35b008f 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewWindows_EnumDeclarationTest : EnumDeclarationTest { - public sealed class XmlPreviewWindows_EnumDeclarationTest : EnumDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -17,7 +17,7 @@ protected override Task BasicTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -36,12 +36,12 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task BasicValueTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value1 = 1, MyEnum_Value2, @@ -49,7 +49,7 @@ protected override Task BasicValueTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -71,12 +71,12 @@ protected override Task BasicValueTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task ExcludeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -84,15 +84,15 @@ protected override Task ExcludeTestImpl() }; "; - var expectedOutputContents = string.Empty; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyEnum" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -100,7 +100,7 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -119,12 +119,12 @@ protected override Task ExplicitTypedTestImpl(string nativeType, string expected "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} + protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"enum MyEnum : {nativeType} {{ MyEnum_Value0, MyEnum_Value1, @@ -132,7 +132,7 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -151,12 +151,12 @@ protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeTyp "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int + protected override Task RemapTestImpl() + { + var inputContents = @"typedef enum _MyEnum : int { MyEnum_Value1, MyEnum_Value2, @@ -164,7 +164,7 @@ protected override Task RemapTestImpl() } MyEnum; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -183,13 +183,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithAttributeTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -200,7 +200,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -226,16 +226,16 @@ enum MyEnum2 : int "; - var withAttributes = new Dictionary> - { - ["MyEnum1"] = new List() { "Flags" } - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() + var withAttributes = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "Flags" } + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + } + + protected override Task WithNamespaceTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -246,7 +246,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -271,16 +271,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["MyEnum1"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -291,7 +291,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -316,16 +316,16 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum1 : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" } + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithNamespaceStarPlusTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value1 = 1, }; @@ -336,7 +336,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -361,17 +361,17 @@ enum MyEnum2 : int "; - var withNamespaces = new Dictionary> - { - ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, - ["MyEnum2"] = new List() { "System" } - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() + var withNamespaces = new Dictionary> { - var inputContents = @"enum MyEnum : int + ["*"] = new List() { "static ClangSharp.Test.MyEnum1" }, + ["MyEnum2"] = new List() { "System" } + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); + } + + protected override Task WithCastToEnumTypeImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0 = (MyEnum) 10, MyEnum_Value1 = (MyEnum) MyEnum_Value0, @@ -379,7 +379,7 @@ protected override Task WithCastToEnumTypeImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -407,12 +407,12 @@ protected override Task WithCastToEnumTypeImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int + protected override Task WithMultipleEnumsTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 = 10, }; @@ -424,7 +424,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -455,12 +455,12 @@ enum MyEnum2 : int "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -468,7 +468,7 @@ protected override Task WithImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -497,12 +497,12 @@ protected override Task WithImplicitConversionTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -510,7 +510,7 @@ protected override Task WithTypeTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -529,15 +529,15 @@ protected override Task WithTypeTestImpl() "; - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task WithTypeAndImplicitConversionTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -545,7 +545,7 @@ protected override Task WithTypeAndImplicitConversionTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -567,16 +567,16 @@ protected override Task WithTypeAndImplicitConversionTestImpl() "; - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["MyEnum"] = "uint" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -587,7 +587,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -606,16 +606,16 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() + var withTypes = new Dictionary { - var inputContents = @"enum MyEnum1 : int + ["*"] = "uint" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + } + + protected override Task WithTypeStarOverrideTestImpl() + { + var inputContents = @"enum MyEnum1 : int { MyEnum1_Value0 }; @@ -626,7 +626,7 @@ enum MyEnum2 : int }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -645,12 +645,11 @@ enum MyEnum2 : int "; - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationBodyImportTest.cs index 06b23f55..143b7360 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationBodyImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationBodyImportTest.cs @@ -4,19 +4,19 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest { - public sealed class XmlPreviewWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest + protected override Task ArraySubscriptTestImpl() { - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) + var inputContents = @"int MyFunction(int* pData, int index) { return pData[index]; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -35,17 +35,17 @@ protected override Task ArraySubscriptTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task BasicTestImpl() + { + var inputContents = @"void MyFunction() { } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -58,18 +58,18 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) + protected override Task BinaryOperatorBasicTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -88,18 +88,18 @@ protected override Task BinaryOperatorBasicTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) + protected override Task BinaryOperatorCompareTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -118,18 +118,18 @@ protected override Task BinaryOperatorCompareTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) + protected override Task BinaryOperatorBooleanTestImpl(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) {{ return x {opcode} y; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,12 +148,12 @@ protected override Task BinaryOperatorBooleanTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task BreakTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -164,7 +164,7 @@ protected override Task BreakTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -185,12 +185,12 @@ protected override Task BreakTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() + protected override Task CallFunctionTestImpl() + { + var inputContents = @"void MyCalledFunction() { } @@ -200,7 +200,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -217,12 +217,12 @@ void MyFunction() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) + protected override Task CallFunctionWithArgsTestImpl() + { + var inputContents = @"void MyCalledFunction(int x, int y) { } @@ -232,7 +232,7 @@ void MyFunction() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,12 +255,12 @@ void MyFunction() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -280,7 +280,7 @@ protected override Task CaseTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -310,12 +310,12 @@ protected override Task CaseTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task CaseNoCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -331,7 +331,7 @@ protected override Task CaseNoCompoundTestImpl() } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -361,12 +361,12 @@ protected override Task CaseNoCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int + protected override Task CompareMultipleEnumTestImpl() + { + var inputContents = @"enum MyEnum : int { MyEnum_Value0, MyEnum_Value1, @@ -381,7 +381,7 @@ static inline int MyFunction(MyEnum x) } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -409,18 +409,18 @@ static inline int MyFunction(MyEnum x) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task ConditionalOperatorTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { return condition ? lhs : rhs; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -442,12 +442,12 @@ protected override Task ConditionalOperatorTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task ContinueTestImpl() + { + var inputContents = @"int MyFunction(int value) { while (true) { @@ -458,7 +458,7 @@ protected override Task ContinueTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -479,18 +479,18 @@ protected override Task ContinueTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CStyleFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return (int)input; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -506,18 +506,18 @@ protected override Task CStyleFunctionalCastTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) + protected override Task CxxFunctionalCastTestImpl() + { + var inputContents = @"int MyFunction(float input) { return int(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -533,18 +533,18 @@ protected override Task CxxFunctionalCastTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) + protected override Task CxxConstCastTestImpl() + { + var inputContents = @"void* MyFunction(const void* input) { return const_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -560,12 +560,12 @@ protected override Task CxxConstCastTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA + protected override Task CxxDynamicCastTestImpl() + { + var inputContents = @"struct MyStructA { virtual void MyMethod() = 0; }; @@ -578,7 +578,7 @@ struct MyStructB : MyStructA { }; } "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -616,18 +616,18 @@ struct MyStructB : MyStructA { }; "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxReinterpretCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return reinterpret_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -643,18 +643,18 @@ protected override Task CxxReinterpretCastTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) + protected override Task CxxStaticCastTestImpl() + { + var inputContents = @"int* MyFunction(void* input) { return static_cast(input); } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -670,12 +670,12 @@ protected override Task CxxStaticCastTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DeclTestImpl() - { - var inputContents = @"\ + protected override Task DeclTestImpl() + { + var inputContents = @"\ int MyFunction() { int x = 0; @@ -684,7 +684,7 @@ int MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -700,12 +700,12 @@ int MyFunction() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -719,7 +719,7 @@ protected override Task DoTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -743,12 +743,12 @@ protected override Task DoTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task DoNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -759,7 +759,7 @@ protected override Task DoNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -782,12 +782,12 @@ protected override Task DoNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) { @@ -859,7 +859,7 @@ protected override Task ForTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -932,12 +932,12 @@ protected override Task ForTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task ForNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { for (int i = 0; i < count; i--) i += 2; @@ -985,7 +985,7 @@ protected override Task ForNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1058,12 +1058,12 @@ protected override Task ForNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1074,7 +1074,7 @@ protected override Task IfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1101,12 +1101,12 @@ protected override Task IfTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) { @@ -1119,7 +1119,7 @@ protected override Task IfElseTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1148,12 +1148,12 @@ protected override Task IfElseTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) + protected override Task IfElseIfTestImpl() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) { if (condition1) { @@ -1168,7 +1168,7 @@ protected override Task IfElseIfTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1205,12 +1205,12 @@ protected override Task IfElseIfTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) + protected override Task IfElseNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) { if (condition) return lhs; @@ -1219,7 +1219,7 @@ protected override Task IfElseNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1248,12 +1248,12 @@ protected override Task IfElseNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" + protected override Task InitListForArrayTestImpl() + { + var inputContents = @" void MyFunction() { int x[4] = { 1, 2, 3, 4 }; @@ -1262,7 +1262,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1293,12 +1293,12 @@ void MyFunction() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task InitListForRecordDeclTestImpl() + { + var inputContents = @"struct MyStruct { float x; float y; @@ -1317,7 +1317,7 @@ MyStruct MyFunction2() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1359,12 +1359,12 @@ MyStruct MyFunction2() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task MemberTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1380,7 +1380,7 @@ int MyFunction2(MyStruct* instance) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1408,12 +1408,12 @@ int MyFunction2(MyStruct* instance) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { + protected override Task RefToPtrTestImpl() + { + var inputContents = @"struct MyStruct { int value; }; @@ -1423,7 +1423,7 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1447,18 +1447,18 @@ bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() + protected override Task ReturnCXXNullPtrTestImpl() + { + var inputContents = @"void* MyFunction() { return nullptr; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1471,18 +1471,18 @@ protected override Task ReturnCXXNullPtrTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() + protected override Task ReturnCXXBooleanLiteralTestImpl(string value) + { + var inputContents = $@"bool MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1495,18 +1495,18 @@ protected override Task ReturnCXXBooleanLiteralTestImpl(string value) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() + protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) + { + var inputContents = $@"double MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1519,18 +1519,18 @@ protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() + protected override Task ReturnFloatingLiteralSingleTestImpl(string value) + { + var inputContents = $@"float MyFunction() {{ return {value}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1543,18 +1543,18 @@ protected override Task ReturnFloatingLiteralSingleTestImpl(string value) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() + protected override Task ReturnEmptyTestImpl() + { + var inputContents = @"void MyFunction() { return; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1567,18 +1567,18 @@ protected override Task ReturnEmptyTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() + protected override Task ReturnIntegerLiteralInt32TestImpl() + { + var inputContents = @"int MyFunction() { return -1; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1591,12 +1591,12 @@ protected override Task ReturnIntegerLiteralInt32TestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion + protected override Task AccessUnionMemberTestImpl() + { + var inputContents = @"union MyUnion { struct { int a; }; }; @@ -1608,7 +1608,7 @@ void MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1639,12 +1639,12 @@ void MyFunction() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task ReturnStructTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1658,7 +1658,7 @@ MyStruct MyFunction() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1684,12 +1684,12 @@ MyStruct MyFunction() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) { @@ -1701,7 +1701,7 @@ protected override Task SwitchTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1723,12 +1723,12 @@ protected override Task SwitchTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) + protected override Task SwitchNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int value) { switch (value) default: @@ -1742,7 +1742,7 @@ protected override Task SwitchNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1772,18 +1772,18 @@ protected override Task SwitchNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) + protected override Task UnaryOperatorAddrOfTestImpl() + { + var inputContents = @"int* MyFunction(int value) { return &value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1799,18 +1799,18 @@ protected override Task UnaryOperatorAddrOfTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) + protected override Task UnaryOperatorDerefTestImpl() + { + var inputContents = @"int MyFunction(int* value) { return *value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1826,18 +1826,18 @@ protected override Task UnaryOperatorDerefTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) + protected override Task UnaryOperatorLogicalNotTestImpl() + { + var inputContents = @"bool MyFunction(bool value) { return !value; } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1853,18 +1853,18 @@ protected override Task UnaryOperatorLogicalNotTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPostfixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return value{opcode}; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1880,18 +1880,18 @@ protected override Task UnaryOperatorPostfixTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) + protected override Task UnaryOperatorPrefixTestImpl(string opcode) + { + var inputContents = $@"int MyFunction(int value) {{ return {opcode}value; }} "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1907,12 +1907,12 @@ protected override Task UnaryOperatorPrefixTestImpl(string opcode) "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1925,7 +1925,7 @@ protected override Task WhileTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1948,12 +1948,12 @@ protected override Task WhileTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) + protected override Task WhileNonCompoundTestImpl() + { + var inputContents = @"int MyFunction(int count) { int i = 0; @@ -1964,7 +1964,7 @@ protected override Task WhileNonCompoundTestImpl() } "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1987,7 +1987,6 @@ protected override Task WhileNonCompoundTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs index 09168ade..4c946dfc 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs @@ -4,15 +4,15 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest { - public sealed class XmlPreviewWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -24,14 +24,14 @@ protected override Task BasicTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + protected override Task ArrayParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -46,14 +46,14 @@ protected override Task ArrayParameterTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + protected override Task FunctionPointerParameterTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -68,24 +68,24 @@ protected override Task FunctionPointerParameterTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace + protected override Task NamespaceTestImpl() + { + var inputContents = @"namespace MyNamespace { void MyFunction(); }"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; + var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; + } - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -97,16 +97,16 @@ protected override Task NamespaceTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; + protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -121,12 +121,12 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate + protected override Task TemplateMemberTestImpl() + { + var inputContents = @$"template struct MyTemplate {{ }}; @@ -136,7 +136,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -148,14 +148,14 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + } - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task NoLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -167,14 +167,14 @@ protected override Task NoLibraryPathTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); + } - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; + protected override Task WithLibraryPathTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -186,18 +186,18 @@ protected override Task WithLibraryPathTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() + var withLibraryPaths = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction();"; + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } - var expectedOutputContents = @" + protected override Task WithLibraryPathStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var expectedOutputContents = @" @@ -209,18 +209,18 @@ protected override Task WithLibraryPathStarTestImpl() "; - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + var withLibraryPaths = new Dictionary { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -238,14 +238,14 @@ protected override Task OptionalParameterTestImpl(string nativeType, string nati "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -263,14 +263,14 @@ protected override Task OptionalParameterUnsafeTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -291,17 +291,17 @@ protected override Task WithCallConvTestImpl() "; - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + protected override Task WithCallConvStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -322,18 +322,18 @@ protected override Task WithCallConvStarTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithCallConvStarOverrideTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -354,19 +354,19 @@ protected override Task WithCallConvStarOverrideTestImpl() "; - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() + var withCallConvs = new Dictionary { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); + } + + protected override Task WithSetLastErrorTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -387,18 +387,18 @@ protected override Task WithSetLastErrorTestImpl() "; - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() + var withSetLastErrors = new string[] { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + "MyFunction1" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - var expectedOutputContents = @" + protected override Task WithSetLastErrorStarTestImpl() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var expectedOutputContents = @" @@ -419,18 +419,18 @@ protected override Task WithSetLastErrorStarTestImpl() "; - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() + var withSetLastErrors = new string[] { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; + "*" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); + } - const string ExpectedOutputContents = @" + protected override Task SourceLocationTestImpl() + { + const string InputContents = @"extern ""C"" void MyFunction(float value);"; + + const string ExpectedOutputContents = @" @@ -445,9 +445,8 @@ protected override Task SourceLocationTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } + + protected override Task VarargsTestImpl() => Task.CompletedTask; } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionPointerDeclarationTest.cs index a66ff020..894a4bb9 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionPointerDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionPointerDeclarationTest.cs @@ -2,20 +2,20 @@ using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest { - public sealed class XmlPreviewWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest + protected override Task BasicTestImpl() { - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); + var inputContents = @"typedef void (*Callback)(); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -27,19 +27,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); + protected override Task CallconvTestImpl() + { + var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); struct MyStruct { Callback _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -51,19 +51,19 @@ struct MyStruct { "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); + protected override Task PointerlessTypedefTestImpl() + { + var inputContents = @"typedef void (Callback)(); struct MyStruct { Callback* _callback; }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -75,7 +75,6 @@ struct MyStruct { "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs index 44b5e788..41fc42da 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs @@ -6,19 +6,19 @@ using System.Threading.Tasks; using ClangSharp.Abstractions; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewWindows_StructDeclarationTest : StructDeclarationTest { - public sealed class XmlPreviewWindows_StructDeclarationTest : StructDeclarationTest + protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) { - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {nativeType} x[]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -30,12 +30,12 @@ protected override Task IncompleteArraySizeTestImpl(string nativeType, string ex "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -43,7 +43,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -61,12 +61,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct {{ {nativeType} r; {nativeType} g; @@ -74,7 +74,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyStruct; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -91,12 +91,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -104,7 +104,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -122,12 +122,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"struct MyStruct1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -152,7 +152,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -299,21 +299,21 @@ struct MyStruct3 "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyStruct" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -324,7 +324,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -365,12 +365,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -381,7 +381,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -485,12 +485,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -503,7 +503,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -544,12 +544,12 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} value; }}; @@ -560,7 +560,7 @@ struct MyOtherStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -601,18 +601,18 @@ struct MyOtherStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -647,18 +647,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -670,18 +670,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -693,12 +693,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; struct MyStruct {{ @@ -706,7 +706,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -718,18 +718,18 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidTestImpl() + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 {{ @@ -742,7 +742,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -763,13 +763,13 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -788,7 +788,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -825,12 +825,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() + { + var inputContents = @"struct MyStruct1A { int x; int y; @@ -849,7 +849,7 @@ struct MyStruct2 : MyStruct1A, MyStruct1B }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -886,12 +886,12 @@ struct MyStruct2 : MyStruct1A, MyStruct1B "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ {nativeType} value; }} MyUnion; @@ -916,7 +916,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1018,12 +1018,12 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"struct MyStruct { int x; int y; @@ -1042,7 +1042,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1126,12 +1126,12 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1147,7 +1147,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1179,12 +1179,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct {{ {nativeType} r; {nativeType} g; @@ -1200,7 +1200,7 @@ struct MyNestedStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1232,12 +1232,12 @@ struct MyNestedStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task NewKeywordTestImpl() + { + var inputContents = @"struct MyStruct { int Equals; int Dispose; @@ -1248,7 +1248,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1278,25 +1278,25 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task PackTestImpl() + { + const string InputContents = @"struct MyStruct1 { unsigned Field1; void* Field2; @@ -1315,9 +1315,9 @@ struct MyStruct2 { }; "; - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; + var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1346,17 +1346,17 @@ struct MyStruct2 { "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"struct example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1371,19 +1371,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef struct example_s example_t; struct example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1398,14 +1398,14 @@ struct example_s { "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1413,13 +1413,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"struct MyStruct { double r; double g; @@ -1431,7 +1431,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1463,16 +1463,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1482,7 +1482,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1500,16 +1500,16 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; typedef struct MyStruct& MyStructRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1517,12 +1517,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; struct MyStruct {{ @@ -1532,7 +1532,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1550,12 +1550,12 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; struct MyStruct {{ @@ -1565,7 +1565,7 @@ struct MyStruct }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1583,12 +1583,12 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A + protected override Task UsingDeclarationTestImpl() + { + var inputContents = @"struct MyStruct1A { void MyMethod() { } }; @@ -1599,7 +1599,7 @@ struct MyStruct1B : MyStruct1A }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1618,12 +1618,12 @@ struct MyStruct1B : MyStruct1A "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 + protected override Task WithAccessSpecifierTestImpl() + { + var inputContents = @"struct MyStruct1 { int Field1; int Field2; @@ -1642,7 +1642,7 @@ struct MyStruct3 }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1673,18 +1673,18 @@ struct MyStruct3 "; - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); + } - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct + protected override Task SourceLocationAttributeTestImpl() + { + const string InputContents = @"struct MyStruct { int r; int g; @@ -1692,7 +1692,7 @@ protected override Task SourceLocationAttributeTestImpl() }; "; - const string ExpectedOutputContents = @" + const string ExpectedOutputContents = @" @@ -1710,7 +1710,6 @@ protected override Task SourceLocationAttributeTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs index 2e707c41..c81a29cb 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewWindows_UnionDeclarationTest : UnionDeclarationTest { - public sealed class XmlPreviewWindows_UnionDeclarationTest : UnionDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -19,7 +19,7 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -37,12 +37,12 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union + protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union {{ {nativeType} r; {nativeType} g; @@ -50,7 +50,7 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM }} MyUnion; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -67,12 +67,12 @@ protected override Task BasicTestInCModeImpl(string nativeType, string expectedM "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandlineArgs: Array.Empty()); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -80,7 +80,7 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -98,12 +98,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 + protected override Task BitfieldTestImpl() + { + var inputContents = @"union MyUnion1 { unsigned int o0_b0_24 : 24; unsigned int o4_b0_16 : 16; @@ -128,9 +128,9 @@ union MyUnion3 }; "; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; + var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -277,21 +277,21 @@ union MyUnion3 "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; + protected override Task ExcludeTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; + var expectedOutputContents = string.Empty; - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyUnion" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -302,7 +302,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -343,12 +343,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -359,7 +359,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -463,12 +463,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -481,7 +481,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -522,12 +522,12 @@ union MyOtherUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} value; }}; @@ -538,7 +538,7 @@ union MyOtherUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -579,18 +579,18 @@ union MyOtherUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -625,18 +625,18 @@ protected override Task FixedSizedBufferPointerTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[3]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -648,18 +648,18 @@ protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, str "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} c[2][1][3][4]; }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -671,12 +671,12 @@ protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; + protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; union MyUnion {{ @@ -684,7 +684,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -696,17 +696,17 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } + protected override Task GuidTestImpl() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 {{ @@ -719,7 +719,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -740,13 +740,13 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "DECLSPEC_UUID" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ + protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ {nativeType} value; }} MyStruct; @@ -767,7 +767,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -822,12 +822,12 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NestedAnonymousWithBitfieldTestImpl() + { + var inputContents = @"union MyUnion { int x; int y; @@ -846,7 +846,7 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() }; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -930,13 +930,13 @@ protected override Task NestedAnonymousWithBitfieldTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -952,7 +952,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -984,12 +984,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion + protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion {{ {nativeType} r; {nativeType} g; @@ -1005,7 +1005,7 @@ union MyNestedUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1037,12 +1037,12 @@ union MyNestedUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion + protected override Task NewKeywordTestImpl() + { + var inputContents = @"union MyUnion { int Equals; int Dispose; @@ -1053,7 +1053,7 @@ protected override Task NewKeywordTestImpl() int ToString; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1083,31 +1083,31 @@ protected override Task NewKeywordTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; + protected override Task NoDefinitionTestImpl() + { + var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { + protected override Task PointerToSelfTestImpl() + { + var inputContents = @"union example_s { example_s* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1122,19 +1122,19 @@ protected override Task PointerToSelfTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; + protected override Task PointerToSelfViaTypedefTestImpl() + { + var inputContents = @"typedef union example_s example_t; union example_s { example_t* next; void* data; };"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1149,14 +1149,14 @@ union example_s { "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; + protected override Task RemapTestImpl() + { + var inputContents = "typedef union _MyUnion MyUnion;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1164,13 +1164,13 @@ protected override Task RemapTestImpl() "; - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion + protected override Task RemapNestedAnonymousTestImpl() + { + var inputContents = @"union MyUnion { double r; double g; @@ -1182,7 +1182,7 @@ protected override Task RemapNestedAnonymousTestImpl() }; };"; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1214,16 +1214,16 @@ protected override Task RemapNestedAnonymousTestImpl() "; - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + } - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1233,7 +1233,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1251,16 +1251,16 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; + protected override Task SkipNonDefinitionPointerTestImpl() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; typedef union MyUnion& MyUnionRef; "; - var expectedOutputContents = @" + var expectedOutputContents = @" @@ -1268,12 +1268,12 @@ protected override Task SkipNonDefinitionPointerTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; + protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; union MyUnion {{ @@ -1283,7 +1283,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1301,12 +1301,12 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; + protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; union MyUnion {{ @@ -1316,7 +1316,7 @@ union MyUnion }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -1334,7 +1334,6 @@ union MyUnion "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs index 0d335892..be1232b1 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs @@ -3,15 +3,15 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class XmlPreviewWindows_VarDeclarationTest : VarDeclarationTest { - public sealed class XmlPreviewWindows_VarDeclarationTest : VarDeclarationTest + protected override Task BasicTestImpl(string nativeType, string expectedManagedType) { - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -26,14 +26,14 @@ protected override Task BasicTestImpl(string nativeType, string expectedManagedT "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; + protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) + { + var inputContents = $@"{nativeType} MyVariable = 0;"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -48,12 +48,12 @@ protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, strin "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ + protected override Task GuidMacroTestImpl() + { + var inputContents = $@"struct GUID {{ unsigned long Data1; unsigned short Data2; unsigned short Data3; @@ -63,7 +63,7 @@ protected override Task GuidMacroTestImpl() const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; "; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -77,18 +77,18 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + var excludedNames = new string[] { "GUID" }; + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + } - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} + protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) + { + var inputContents = $@"#define MyMacro1 {nativeValue} #define MyMacro2 MyMacro1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -109,15 +109,15 @@ protected override Task MacroTestImpl(string nativeValue, string expectedManaged "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ + protected override Task MultilineMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 0 + \ 1"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -132,21 +132,21 @@ protected override Task MultilineMacroTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + protected override Task NoInitializerTestImpl(string nativeType) + { + var inputContents = $@"{nativeType} MyVariable;"; + var expectedOutputContents = ""; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test"""; + protected override Task Utf8StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 ""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -161,14 +161,14 @@ protected override Task Utf8StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test"""; + protected override Task Utf16StringLiteralMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 u""Test"""; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -183,16 +183,16 @@ protected override Task Utf16StringLiteralMacroTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralConstTestImpl() + { + var inputContents = $@"const wchar_t MyConst1[] = L""Test""; const wchar_t* MyConst2 = L""Test""; const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -219,16 +219,16 @@ protected override Task WideStringLiteralConstTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test""; + protected override Task StringLiteralConstTestImpl() + { + var inputContents = $@"const char MyConst1[] = ""Test""; const char* MyConst2 = ""Test""; const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -255,16 +255,16 @@ protected override Task StringLiteralConstTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; + protected override Task WideStringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const wchar_t MyConst1[] = L""Test""; static const wchar_t* MyConst2 = L""Test""; static const wchar_t* const MyConst3 = L""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -291,16 +291,16 @@ protected override Task WideStringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test""; + protected override Task StringLiteralStaticConstTestImpl() + { + var inputContents = $@"static const char MyConst1[] = ""Test""; static const char* MyConst2 = ""Test""; static const char* const MyConst3 = ""Test"";"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -327,15 +327,15 @@ protected override Task StringLiteralStaticConstTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L + protected override Task UncheckedConversionMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 (long)0x80000000L #define MyMacro2 (int)0x80000000"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -364,14 +364,14 @@ protected override Task UncheckedConversionMacroTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; + protected override Task UncheckedFunctionLikeCastMacroTestImpl() + { + var inputContents = $@"#define MyMacro1 unsigned(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -390,16 +390,16 @@ protected override Task UncheckedFunctionLikeCastMacroTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) + protected override Task UncheckedConversionMacroTest2Impl() + { + var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) #define MyMacro2(n) MyMacro1(1, 2, n) #define MyMacro3 MyMacro2(3)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -416,15 +416,15 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); - } + var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + } - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; + protected override Task UncheckedPointerMacroTestImpl() + { + var inputContents = $@"#define Macro1 ((int*) -1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -441,14 +441,14 @@ protected override Task UncheckedPointerMacroTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; + protected override Task UncheckedReinterpretCastMacroTestImpl() + { + var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -467,14 +467,14 @@ protected override Task UncheckedReinterpretCastMacroTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; + protected override Task MultidimensionlArrayTestImpl() + { + var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -501,16 +501,16 @@ protected override Task MultidimensionlArrayTestImpl() "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); + } - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; + protected override Task ConditionalDefineConstTestImpl() + { + var inputContents = @"typedef int TESTRESULT; #define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) #define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - var expectedOutputContents = $@" + var expectedOutputContents = $@" @@ -526,9 +526,8 @@ protected override Task ConditionalDefineConstTestImpl() "; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.UnitTests/.editorconfig b/tests/ClangSharp.UnitTests/.editorconfig new file mode 100644 index 00000000..94ffcc6b --- /dev/null +++ b/tests/ClangSharp.UnitTests/.editorconfig @@ -0,0 +1,41 @@ +# Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +############################################################################### +# EditorConfig is awesome: http://EditorConfig.org +############################################################################### + +############################################################################### +# Not top-most EditorConfig file +############################################################################### +root = false + +############################################################################### +# Set dotnet naming rules to: +# disable any parent naming rules since they are not applicable to interop +############################################################################### +[*.cs] +dotnet_naming_rule.async_methods_should_be_pascal_case_suffixed_with_async.severity = none +dotnet_naming_rule.const_fields_and_locals_should_be_pascal_case.severity = none +dotnet_naming_rule.interfaces_should_be_pascal_case_prefixed_with_i.severity = none +dotnet_naming_rule.locals_should_be_camel_case.severity = none +dotnet_naming_rule.parameters_should_be_camel_case.severity = none +dotnet_naming_rule.private_and_internal_static_fields_should_be_camel_case_prefixed_with_s_and_underscore.severity = none +dotnet_naming_rule.private_and_internal_fields_should_be_camel_case_prefixed_with_underscore.severity = none +dotnet_naming_rule.public_and_protected_declarations_should_be_pascal_case.severity = none +dotnet_naming_rule.type_parameters_should_be_pascal_case_prefixed_with_t.severity = none + +############################################################################### +# Set dotnet style options to: +# disable certain parent style options since they are not applicable to interop +############################################################################### +csharp_style_expression_bodied_methods = when_on_single_line:none +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:none +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:none +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:none +dotnet_style_prefer_conditional_expression_over_assignment = true:none +dotnet_style_prefer_conditional_expression_over_return = true:none +csharp_style_prefer_pattern_matching = true:none +csharp_style_var_elsewhere = true:none +csharp_style_var_for_built_in_types = true:none +csharp_style_var_when_type_is_apparent = true:none diff --git a/tests/ClangSharp.UnitTests/CXModuleMapDescriptorTest.cs b/tests/ClangSharp.UnitTests/CXModuleMapDescriptorTest.cs index 06e6d15f..6c68808b 100644 --- a/tests/ClangSharp.UnitTests/CXModuleMapDescriptorTest.cs +++ b/tests/ClangSharp.UnitTests/CXModuleMapDescriptorTest.cs @@ -4,28 +4,27 @@ using ClangSharp.Interop; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public class CXModuleMapDescriptorTest { - public class CXModuleMapDescriptorTest + [Test] + public void Basic() { - [Test] - public void Basic() - { - var contents = - "framework module TestFrame {\n" - + " umbrella header \"TestFrame.h\"\n" - + "\n" - + " export *\n" - + " module * { export * }\n" - + "}\n"; + var contents = + "framework module TestFrame {\n" + + " umbrella header \"TestFrame.h\"\n" + + "\n" + + " export *\n" + + " module * { export * }\n" + + "}\n"; - using var mmd = CXModuleMapDescriptor.Create(options: 0); - _ = mmd.SetFrameworkModuleName("TestFrame"); - _ = mmd.SetUmbrellaHeader("TestFrame.h"); + using var mmd = CXModuleMapDescriptor.Create(options: 0); + _ = mmd.SetFrameworkModuleName("TestFrame"); + _ = mmd.SetUmbrellaHeader("TestFrame.h"); - var buffer = mmd.WriteToBuffer(options: 0, errorCode: out _); - Assert.AreEqual(contents, buffer.AsString()); - buffer.ClangFree(); - } + var buffer = mmd.WriteToBuffer(options: 0, errorCode: out _); + Assert.AreEqual(contents, buffer.AsString()); + buffer.ClangFree(); } } diff --git a/tests/ClangSharp.UnitTests/CXTranslationUnitTest.cs b/tests/ClangSharp.UnitTests/CXTranslationUnitTest.cs index e24cb0f8..baf06e63 100644 --- a/tests/ClangSharp.UnitTests/CXTranslationUnitTest.cs +++ b/tests/ClangSharp.UnitTests/CXTranslationUnitTest.cs @@ -5,64 +5,63 @@ using ClangSharp.Interop; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +// This is not ported from libclangtest but instead created to test Unicode stuff +public class CXTranslationUnitTest { - // This is not ported from libclangtest but instead created to test Unicode stuff - public class CXTranslationUnitTest + [TestCase("basic")] + [TestCase("example with spaces")] + [TestCase("♫")] + public void Basic(string name) { - [TestCase("basic")] - [TestCase("example with spaces")] - [TestCase("♫")] - public void Basic(string name) - { - // Create a unique directory - var dir = Path.GetRandomFileName(); - _ = Directory.CreateDirectory(dir); + // Create a unique directory + var dir = Path.GetRandomFileName(); + _ = Directory.CreateDirectory(dir); - try - { - // Create a file with the right name - var file = new FileInfo(Path.Combine(dir, name + ".c")); - File.WriteAllText(file.FullName, "int main() { return 0; }"); + try + { + // Create a file with the right name + var file = new FileInfo(Path.Combine(dir, name + ".c")); + File.WriteAllText(file.FullName, "int main() { return 0; }"); - using var index = CXIndex.Create(); - using var translationUnit = CXTranslationUnit.Parse(index, file.FullName, Array.Empty(), Array.Empty(), CXTranslationUnit_Flags.CXTranslationUnit_None); - var clangFile = translationUnit.GetFile(file.FullName); - Assert.AreEqual(file.FullName, clangFile.Name.CString); - } - finally - { - Directory.Delete(dir, true); - } + using var index = CXIndex.Create(); + using var translationUnit = CXTranslationUnit.Parse(index, file.FullName, Array.Empty(), Array.Empty(), CXTranslationUnit_Flags.CXTranslationUnit_None); + var clangFile = translationUnit.GetFile(file.FullName); + Assert.AreEqual(file.FullName, clangFile.Name.CString); } - - [TestCase("basic")] - [TestCase("example with spaces")] - [TestCase("♫")] - public void BasicWrapper(string name) + finally { - // Create a unique directory - var dir = Path.GetRandomFileName(); - _ = Directory.CreateDirectory(dir); + Directory.Delete(dir, true); + } + } - try - { - // Create a file with the right name - var file = new FileInfo(Path.Combine(dir, name + ".c")); - File.WriteAllText(file.FullName, "int main() { return 0; }"); + [TestCase("basic")] + [TestCase("example with spaces")] + [TestCase("♫")] + public void BasicWrapper(string name) + { + // Create a unique directory + var dir = Path.GetRandomFileName(); + _ = Directory.CreateDirectory(dir); + + try + { + // Create a file with the right name + var file = new FileInfo(Path.Combine(dir, name + ".c")); + File.WriteAllText(file.FullName, "int main() { return 0; }"); - var index = CXIndex.Create(); - var translationUnit = CXTranslationUnit.Parse(index, file.FullName, Array.Empty(), Array.Empty(), CXTranslationUnit_Flags.CXTranslationUnit_None); - var clangFile = translationUnit.GetFile(file.FullName); - var clangFileName = clangFile.Name; - var clangFileNameString = clangFileName.CString; + var index = CXIndex.Create(); + var translationUnit = CXTranslationUnit.Parse(index, file.FullName, Array.Empty(), Array.Empty(), CXTranslationUnit_Flags.CXTranslationUnit_None); + var clangFile = translationUnit.GetFile(file.FullName); + var clangFileName = clangFile.Name; + var clangFileNameString = clangFileName.CString; - Assert.AreEqual(file.FullName, clangFileNameString); - } - finally - { - Directory.Delete(dir, true); - } + Assert.AreEqual(file.FullName, clangFileNameString); + } + finally + { + Directory.Delete(dir, true); } } } diff --git a/tests/ClangSharp.UnitTests/CXVirtualFileOverlayTest.cs b/tests/ClangSharp.UnitTests/CXVirtualFileOverlayTest.cs index 7c8b8f7a..63811443 100644 --- a/tests/ClangSharp.UnitTests/CXVirtualFileOverlayTest.cs +++ b/tests/ClangSharp.UnitTests/CXVirtualFileOverlayTest.cs @@ -5,367 +5,366 @@ using ClangSharp.Interop; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +// NOTE: To make those tests work on both Windows and *nix, +// begin any absolute path with "$ROOT$", which the TestVFO infra will replace +// with either "C:" (Windows) or nothing (*nix) so that clang understands the path. +// (Technically, /a/path/like/this is a path relative to the root of the current drive +// on Windows, but clang doesn't seem to support this) +public class CXVirtualFileOverlayTest { - // NOTE: To make those tests work on both Windows and *nix, - // begin any absolute path with "$ROOT$", which the TestVFO infra will replace - // with either "C:" (Windows) or nothing (*nix) so that clang understands the path. - // (Technically, /a/path/like/this is a path relative to the root of the current drive - // on Windows, but clang doesn't seem to support this) - public class CXVirtualFileOverlayTest + public class TestVFO : IDisposable { - public class TestVFO : IDisposable + public CXVirtualFileOverlay VFO; + + private readonly string _contents; + private bool _isDisposed = false; + + public TestVFO(string contents) { - public CXVirtualFileOverlay VFO; + VFO = CXVirtualFileOverlay.Create(options: 0); + _contents = Fix(contents); + } - private readonly string _contents; - private bool _isDisposed = false; + ~TestVFO() + { + Dispose(isDisposing: false); + } - public TestVFO(string contents) - { - VFO = CXVirtualFileOverlay.Create(options: 0); - _contents = Fix(contents); - } + public void Map(string vPath, string rPath) + { + vPath = Fix(vPath); + rPath = Fix(rPath); - ~TestVFO() - { - Dispose(isDisposing: false); - } + var err = VFO.AddFileMapping(vPath, rPath); + Assert.AreEqual(CXErrorCode.CXError_Success, err); + } - public void Map(string vPath, string rPath) - { - vPath = Fix(vPath); - rPath = Fix(rPath); + public void MapError(string vPath, string rPath, CXErrorCode expErr) + { + vPath = Fix(vPath); + rPath = Fix(rPath); - var err = VFO.AddFileMapping(vPath, rPath); - Assert.AreEqual(CXErrorCode.CXError_Success, err); - } + var err = VFO.AddFileMapping(vPath, rPath); + Assert.AreEqual(expErr, err); + } - public void MapError(string vPath, string rPath, CXErrorCode expErr) + private static string Fix(string text) + { + if (text is null) { - vPath = Fix(vPath); - rPath = Fix(rPath); - - var err = VFO.AddFileMapping(vPath, rPath); - Assert.AreEqual(expErr, err); + return null; } - private static string Fix(string text) - { - if (text is null) - { - return null; - } + var replacement = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:" : ""; + return text.Replace("$ROOT$", replacement); + } - var replacement = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:" : ""; - return text.Replace("$ROOT$", replacement); - } + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - public void Dispose() + protected virtual void Dispose(bool isDisposing) + { + if (_isDisposed) { - Dispose(true); - GC.SuppressFinalize(this); + return; } + _isDisposed = true; - protected virtual void Dispose(bool isDisposing) + if (_contents != null) { - if (_isDisposed) - { - return; - } - _isDisposed = true; - - if (_contents != null) - { - var buffer = VFO.WriteToBuffer(options: 0, errorCode: out _); - Assert.AreEqual(_contents, buffer.AsString()); - buffer.ClangFree(); - } - - VFO.Dispose(); + var buffer = VFO.WriteToBuffer(options: 0, errorCode: out _); + Assert.AreEqual(_contents, buffer.AsString()); + buffer.ClangFree(); } - } - [Test] - public void Basic() - { - var contents = - "{\n" - + " 'version': 0,\n" - + " 'roots': [\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/path/virtual\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"foo.h\",\n" - + " 'external-contents': \"$ROOT$/real/foo.h\"\n" - + " }\n" - + " ]\n" - + " }\n" - + " ]\n" - + "}\n"; - - using var t = new TestVFO(contents); - t.Map(@"$ROOT$/path/virtual/foo.h", @"$ROOT$/real/foo.h"); + VFO.Dispose(); } + } - [Test] - public void Unicode() - { - var contents = - "{\n" - + " 'version': 0,\n" - + " 'roots': [\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/path/\\u266B\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"\\u2602.h\",\n" - + " 'external-contents': \"$ROOT$/real/\\u2602.h\"\n" - + " }\n" - + " ]\n" - + " }\n" - + " ]\n" - + "}\n"; - - using var t = new TestVFO(contents); - t.Map("$ROOT$/path/♫/☂.h", "$ROOT$/real/☂.h"); - } + [Test] + public void Basic() + { + var contents = + "{\n" + + " 'version': 0,\n" + + " 'roots': [\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/path/virtual\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"foo.h\",\n" + + " 'external-contents': \"$ROOT$/real/foo.h\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + "}\n"; + + using var t = new TestVFO(contents); + t.Map(@"$ROOT$/path/virtual/foo.h", @"$ROOT$/real/foo.h"); + } - [Test] - public void InvalidArgs() - { - using var t = new TestVFO(null); - t.MapError("$ROOT$/path/./virtual/../foo.h", "$ROOT$/real/foo.h", - CXErrorCode.CXError_InvalidArguments); - } + [Test] + public void Unicode() + { + var contents = + "{\n" + + " 'version': 0,\n" + + " 'roots': [\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/path/\\u266B\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"\\u2602.h\",\n" + + " 'external-contents': \"$ROOT$/real/\\u2602.h\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + "}\n"; + + using var t = new TestVFO(contents); + t.Map("$ROOT$/path/♫/☂.h", "$ROOT$/real/☂.h"); + } - [Test] - public void RemapDirectories() - { - var contents = - "{\n" - + " 'version': 0,\n" - + " 'roots': [\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/another/dir\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"foo2.h\",\n" - + " 'external-contents': \"$ROOT$/real/foo2.h\"\n" - + " }\n" - + " ]\n" - + " },\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/path/virtual/dir\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"foo1.h\",\n" - + " 'external-contents': \"$ROOT$/real/foo1.h\"\n" - + " },\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"foo3.h\",\n" - + " 'external-contents': \"$ROOT$/real/foo3.h\"\n" - + " },\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"in/subdir\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"foo4.h\",\n" - + " 'external-contents': \"$ROOT$/real/foo4.h\"\n" - + " }\n" - + " ]\n" - + " }\n" - + " ]\n" - + " }\n" - + " ]\n" - + "}\n"; - - using var t = new TestVFO(contents); - t.Map("$ROOT$/path/virtual/dir/foo1.h", "$ROOT$/real/foo1.h"); - t.Map("$ROOT$/another/dir/foo2.h", "$ROOT$/real/foo2.h"); - t.Map("$ROOT$/path/virtual/dir/foo3.h", "$ROOT$/real/foo3.h"); - t.Map("$ROOT$/path/virtual/dir/in/subdir/foo4.h", "$ROOT$/real/foo4.h"); - } + [Test] + public void InvalidArgs() + { + using var t = new TestVFO(null); + t.MapError("$ROOT$/path/./virtual/../foo.h", "$ROOT$/real/foo.h", + CXErrorCode.CXError_InvalidArguments); + } - [Test] - public void CaseInsensitive() - { - var contents = - "{\n" - + " 'version': 0,\n" - + " 'case-sensitive': 'false',\n" - + " 'roots': [\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/path/virtual\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"foo.h\",\n" - + " 'external-contents': \"$ROOT$/real/foo.h\"\n" - + " }\n" - + " ]\n" - + " }\n" - + " ]\n" - + "}\n"; - - using var t = new TestVFO(contents); - t.Map("$ROOT$/path/virtual/foo.h", "$ROOT$/real/foo.h"); - _ = t.VFO.SetCaseSensitivity(false); - } + [Test] + public void RemapDirectories() + { + var contents = + "{\n" + + " 'version': 0,\n" + + " 'roots': [\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/another/dir\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"foo2.h\",\n" + + " 'external-contents': \"$ROOT$/real/foo2.h\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/path/virtual/dir\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"foo1.h\",\n" + + " 'external-contents': \"$ROOT$/real/foo1.h\"\n" + + " },\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"foo3.h\",\n" + + " 'external-contents': \"$ROOT$/real/foo3.h\"\n" + + " },\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"in/subdir\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"foo4.h\",\n" + + " 'external-contents': \"$ROOT$/real/foo4.h\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + "}\n"; + + using var t = new TestVFO(contents); + t.Map("$ROOT$/path/virtual/dir/foo1.h", "$ROOT$/real/foo1.h"); + t.Map("$ROOT$/another/dir/foo2.h", "$ROOT$/real/foo2.h"); + t.Map("$ROOT$/path/virtual/dir/foo3.h", "$ROOT$/real/foo3.h"); + t.Map("$ROOT$/path/virtual/dir/in/subdir/foo4.h", "$ROOT$/real/foo4.h"); + } - [Test] - public void SharedPrefix() - { - var contents = - "{\n" - + " 'version': 0,\n" - + " 'roots': [\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/path/foo\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"bar\",\n" - + " 'external-contents': \"$ROOT$/real/bar\"\n" - + " },\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"bar.h\",\n" - + " 'external-contents': \"$ROOT$/real/bar.h\"\n" - + " }\n" - + " ]\n" - + " },\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/path/foobar\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"baz.h\",\n" - + " 'external-contents': \"$ROOT$/real/baz.h\"\n" - + " }\n" - + " ]\n" - + " },\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/path\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"foobarbaz.h\",\n" - + " 'external-contents': \"$ROOT$/real/foobarbaz.h\"\n" - + " }\n" - + " ]\n" - + " }\n" - + " ]\n" - + "}\n"; - - using var t = new TestVFO(contents); - t.Map("$ROOT$/path/foo/bar.h", "$ROOT$/real/bar.h"); - t.Map("$ROOT$/path/foo/bar", "$ROOT$/real/bar"); - t.Map("$ROOT$/path/foobar/baz.h", "$ROOT$/real/baz.h"); - t.Map("$ROOT$/path/foobarbaz.h", "$ROOT$/real/foobarbaz.h"); - } + [Test] + public void CaseInsensitive() + { + var contents = + "{\n" + + " 'version': 0,\n" + + " 'case-sensitive': 'false',\n" + + " 'roots': [\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/path/virtual\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"foo.h\",\n" + + " 'external-contents': \"$ROOT$/real/foo.h\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + "}\n"; + + using var t = new TestVFO(contents); + t.Map("$ROOT$/path/virtual/foo.h", "$ROOT$/real/foo.h"); + _ = t.VFO.SetCaseSensitivity(false); + } - [Test] - public void AdjacentDirectory() - { - var contents = - "{\n" - + " 'version': 0,\n" - + " 'roots': [\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/path/dir1\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"foo.h\",\n" - + " 'external-contents': \"$ROOT$/real/foo.h\"\n" - + " },\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"subdir\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"bar.h\",\n" - + " 'external-contents': \"$ROOT$/real/bar.h\"\n" - + " }\n" - + " ]\n" - + " }\n" - + " ]\n" - + " },\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/path/dir2\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"baz.h\",\n" - + " 'external-contents': \"$ROOT$/real/baz.h\"\n" - + " }\n" - + " ]\n" - + " }\n" - + " ]\n" - + "}\n"; - - using var t = new TestVFO(contents); - t.Map("$ROOT$/path/dir1/foo.h", "$ROOT$/real/foo.h"); - t.Map("$ROOT$/path/dir1/subdir/bar.h", "$ROOT$/real/bar.h"); - t.Map("$ROOT$/path/dir2/baz.h", "$ROOT$/real/baz.h"); - } + [Test] + public void SharedPrefix() + { + var contents = + "{\n" + + " 'version': 0,\n" + + " 'roots': [\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/path/foo\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"bar\",\n" + + " 'external-contents': \"$ROOT$/real/bar\"\n" + + " },\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"bar.h\",\n" + + " 'external-contents': \"$ROOT$/real/bar.h\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/path/foobar\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"baz.h\",\n" + + " 'external-contents': \"$ROOT$/real/baz.h\"\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/path\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"foobarbaz.h\",\n" + + " 'external-contents': \"$ROOT$/real/foobarbaz.h\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + "}\n"; + + using var t = new TestVFO(contents); + t.Map("$ROOT$/path/foo/bar.h", "$ROOT$/real/bar.h"); + t.Map("$ROOT$/path/foo/bar", "$ROOT$/real/bar"); + t.Map("$ROOT$/path/foobar/baz.h", "$ROOT$/real/baz.h"); + t.Map("$ROOT$/path/foobarbaz.h", "$ROOT$/real/foobarbaz.h"); + } - [Test] - public void TopLevel() - { - var contents = - "{\n" - + " 'version': 0,\n" - + " 'roots': [\n" - + " {\n" - + " 'type': 'directory',\n" - + " 'name': \"$ROOT$/\",\n" - + " 'contents': [\n" - + " {\n" - + " 'type': 'file',\n" - + " 'name': \"foo.h\",\n" - + " 'external-contents': \"$ROOT$/real/foo.h\"\n" - + " }\n" - + " ]\n" - + " }\n" - + " ]\n" - + "}\n"; - - using var t = new TestVFO(contents); - t.Map("$ROOT$/foo.h", "$ROOT$/real/foo.h"); - } + [Test] + public void AdjacentDirectory() + { + var contents = + "{\n" + + " 'version': 0,\n" + + " 'roots': [\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/path/dir1\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"foo.h\",\n" + + " 'external-contents': \"$ROOT$/real/foo.h\"\n" + + " },\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"subdir\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"bar.h\",\n" + + " 'external-contents': \"$ROOT$/real/bar.h\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/path/dir2\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"baz.h\",\n" + + " 'external-contents': \"$ROOT$/real/baz.h\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + "}\n"; + + using var t = new TestVFO(contents); + t.Map("$ROOT$/path/dir1/foo.h", "$ROOT$/real/foo.h"); + t.Map("$ROOT$/path/dir1/subdir/bar.h", "$ROOT$/real/bar.h"); + t.Map("$ROOT$/path/dir2/baz.h", "$ROOT$/real/baz.h"); + } - [Test] - public void Empty() - { - var contents = - "{\n" - + " 'version': 0,\n" - + " 'roots': [\n" - + " ]\n" - + "}\n"; - - using var t = new TestVFO(contents); - } + [Test] + public void TopLevel() + { + var contents = + "{\n" + + " 'version': 0,\n" + + " 'roots': [\n" + + " {\n" + + " 'type': 'directory',\n" + + " 'name': \"$ROOT$/\",\n" + + " 'contents': [\n" + + " {\n" + + " 'type': 'file',\n" + + " 'name': \"foo.h\",\n" + + " 'external-contents': \"$ROOT$/real/foo.h\"\n" + + " }\n" + + " ]\n" + + " }\n" + + " ]\n" + + "}\n"; + + using var t = new TestVFO(contents); + t.Map("$ROOT$/foo.h", "$ROOT$/real/foo.h"); + } + + [Test] + public void Empty() + { + var contents = + "{\n" + + " 'version': 0,\n" + + " 'roots': [\n" + + " ]\n" + + "}\n"; + + using var t = new TestVFO(contents); } } diff --git a/tests/ClangSharp.UnitTests/CursorTests/DeclTest.cs b/tests/ClangSharp.UnitTests/CursorTests/DeclTest.cs index 426f6381..ec60c085 100644 --- a/tests/ClangSharp.UnitTests/CursorTests/DeclTest.cs +++ b/tests/ClangSharp.UnitTests/CursorTests/DeclTest.cs @@ -4,52 +4,52 @@ using ClangSharp.Interop; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public sealed class DeclTest : TranslationUnitTest { - public sealed class DeclTest : TranslationUnitTest + [TestCase("private", CX_CXXAccessSpecifier.CX_CXXPrivate)] + [TestCase("protected", CX_CXXAccessSpecifier.CX_CXXProtected)] + [TestCase("public", CX_CXXAccessSpecifier.CX_CXXPublic)] + public void AccessSpecDeclTest(string accessSpecifier, CX_CXXAccessSpecifier expectedAccessSpecifier) { - [TestCase("private", CX_CXXAccessSpecifier.CX_CXXPrivate)] - [TestCase("protected", CX_CXXAccessSpecifier.CX_CXXProtected)] - [TestCase("public", CX_CXXAccessSpecifier.CX_CXXPublic)] - public void AccessSpecDeclTest(string accessSpecifier, CX_CXXAccessSpecifier expectedAccessSpecifier) - { - var inputContents = $@"struct MyStruct + var inputContents = $@"struct MyStruct {{ {accessSpecifier}: }}; "; - using var translationUnit = CreateTranslationUnit(inputContents); + using var translationUnit = CreateTranslationUnit(inputContents); - var recordDecl = translationUnit.TranslationUnitDecl.Decls.OfType().Where((recordDecl) => recordDecl.Name == "MyStruct").Single(); - var accessSpecDecl = recordDecl.Decls.OfType().Single(); + var recordDecl = translationUnit.TranslationUnitDecl.Decls.OfType().Where((recordDecl) => recordDecl.Name == "MyStruct").Single(); + var accessSpecDecl = recordDecl.Decls.OfType().Single(); - Assert.AreEqual(expectedAccessSpecifier, accessSpecDecl.Access); - } + Assert.AreEqual(expectedAccessSpecifier, accessSpecDecl.Access); + } - [Test] - public void ClassTemplateDeclTest() - { - var inputContents = $@"template + [Test] + public void ClassTemplateDeclTest() + { + var inputContents = $@"template class MyClass {{ T value; }}; "; - using var translationUnit = CreateTranslationUnit(inputContents); + using var translationUnit = CreateTranslationUnit(inputContents); - var classTemplateDecl = translationUnit.TranslationUnitDecl.Decls.OfType().Single(); - Assert.AreEqual("MyClass", classTemplateDecl.Name); + var classTemplateDecl = translationUnit.TranslationUnitDecl.Decls.OfType().Single(); + Assert.AreEqual("MyClass", classTemplateDecl.Name); - var templateParameter = classTemplateDecl.TemplateParameters.Single(); - Assert.AreEqual("T", templateParameter.Name); - } + var templateParameter = classTemplateDecl.TemplateParameters.Single(); + Assert.AreEqual("T", templateParameter.Name); + } - [Test] - public void ClassTemplatePartialSpecializationDeclTest() - { - var inputContents = $@"template + [Test] + public void ClassTemplatePartialSpecializationDeclTest() + { + var inputContents = $@"template class MyClass {{ T value1; @@ -64,13 +64,12 @@ class MyClass }}; "; - using var translationUnit = CreateTranslationUnit(inputContents); + using var translationUnit = CreateTranslationUnit(inputContents); - var classTemplatePartialSpecializationDecl = translationUnit.TranslationUnitDecl.Decls.OfType().Single(); - Assert.AreEqual("MyClass", classTemplatePartialSpecializationDecl.Name); + var classTemplatePartialSpecializationDecl = translationUnit.TranslationUnitDecl.Decls.OfType().Single(); + Assert.AreEqual("MyClass", classTemplatePartialSpecializationDecl.Name); - var templateParameter = classTemplatePartialSpecializationDecl.TemplateParameters.Single(); - Assert.AreEqual("U", templateParameter.Name); - } + var templateParameter = classTemplatePartialSpecializationDecl.TemplateParameters.Single(); + Assert.AreEqual("U", templateParameter.Name); } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXCodeCompleteResultsTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXCodeCompleteResultsTests.cs index db75b412..4abca447 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXCodeCompleteResultsTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXCodeCompleteResultsTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXCodeCompleteResultsTests { - /// Provides validation of the struct. - public static unsafe partial class CXCodeCompleteResultsTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCodeCompleteResults))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCodeCompleteResults))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXCodeCompleteResults).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXCodeCompleteResults).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXCodeCompleteResults), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXCodeCompleteResults), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXCodeCompleteResults), Is.EqualTo(8)); - } + Assert.That(sizeof(CXCodeCompleteResults), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXCommentTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXCommentTests.cs index d2182d4a..641b9bde 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXCommentTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXCommentTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXCommentTests { - /// Provides validation of the struct. - public static unsafe partial class CXCommentTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXComment))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXComment))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXComment).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXComment).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXComment), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXComment), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXComment), Is.EqualTo(8)); - } + Assert.That(sizeof(CXComment), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXCompletionResultTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXCompletionResultTests.cs index 9f8da4ff..14a7fd54 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXCompletionResultTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXCompletionResultTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXCompletionResultTests { - /// Provides validation of the struct. - public static unsafe partial class CXCompletionResultTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCompletionResult))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCompletionResult))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXCompletionResult).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXCompletionResult).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXCompletionResult), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXCompletionResult), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXCompletionResult), Is.EqualTo(8)); - } + Assert.That(sizeof(CXCompletionResult), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXCursorAndRangeVisitorTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXCursorAndRangeVisitorTests.cs index 2b246065..93f48fdd 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXCursorAndRangeVisitorTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXCursorAndRangeVisitorTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXCursorAndRangeVisitorTests { - /// Provides validation of the struct. - public static unsafe partial class CXCursorAndRangeVisitorTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCursorAndRangeVisitor))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCursorAndRangeVisitor))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXCursorAndRangeVisitor).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXCursorAndRangeVisitor).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXCursorAndRangeVisitor), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXCursorAndRangeVisitor), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXCursorAndRangeVisitor), Is.EqualTo(8)); - } + Assert.That(sizeof(CXCursorAndRangeVisitor), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXCursorSetImplTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXCursorSetImplTests.cs index 6fdcdb42..b46e15e8 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXCursorSetImplTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXCursorSetImplTests.cs @@ -6,30 +6,29 @@ using NUnit.Framework; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXCursorSetImplTests { - /// Provides validation of the struct. - public static unsafe partial class CXCursorSetImplTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCursorSetImpl))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCursorSetImpl))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() - { - Assert.That(typeof(CXCursorSetImpl).IsLayoutSequential, Is.True); - } + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXCursorSetImpl).IsLayoutSequential, Is.True); + } - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() - { - Assert.That(sizeof(CXCursorSetImpl), Is.EqualTo(1)); - } + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + Assert.That(sizeof(CXCursorSetImpl), Is.EqualTo(1)); } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXCursorTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXCursorTests.cs index 4cfed460..ac3b36a1 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXCursorTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXCursorTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXCursorTests { - /// Provides validation of the struct. - public static unsafe partial class CXCursorTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCursor))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXCursor))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXCursor).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXCursor).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXCursor), Is.EqualTo(32)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXCursor), Is.EqualTo(32)); - } - else - { - Assert.That(sizeof(CXCursor), Is.EqualTo(20)); - } + Assert.That(sizeof(CXCursor), Is.EqualTo(20)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXFileUniqueIDTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXFileUniqueIDTests.cs index a52c936f..a6506fa4 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXFileUniqueIDTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXFileUniqueIDTests.cs @@ -6,30 +6,29 @@ using NUnit.Framework; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXFileUniqueIDTests { - /// Provides validation of the struct. - public static unsafe partial class CXFileUniqueIDTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXFileUniqueID))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXFileUniqueID))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() - { - Assert.That(typeof(CXFileUniqueID).IsLayoutSequential, Is.True); - } + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXFileUniqueID).IsLayoutSequential, Is.True); + } - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() - { - Assert.That(sizeof(CXFileUniqueID), Is.EqualTo(24)); - } + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + Assert.That(sizeof(CXFileUniqueID), Is.EqualTo(24)); } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxAttrInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxAttrInfoTests.cs index 3c5324b1..276244f3 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxAttrInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxAttrInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxAttrInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxAttrInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxAttrInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxAttrInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxAttrInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxAttrInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxAttrInfo), Is.EqualTo(64)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxAttrInfo), Is.EqualTo(64)); - } - else - { - Assert.That(sizeof(CXIdxAttrInfo), Is.EqualTo(36)); - } + Assert.That(sizeof(CXIdxAttrInfo), Is.EqualTo(36)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxBaseClassInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxBaseClassInfoTests.cs index a4556e1e..86819f94 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxBaseClassInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxBaseClassInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxBaseClassInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxBaseClassInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxBaseClassInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxBaseClassInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxBaseClassInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxBaseClassInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxBaseClassInfo), Is.EqualTo(64)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxBaseClassInfo), Is.EqualTo(64)); - } - else - { - Assert.That(sizeof(CXIdxBaseClassInfo), Is.EqualTo(36)); - } + Assert.That(sizeof(CXIdxBaseClassInfo), Is.EqualTo(36)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxCXXClassDeclInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxCXXClassDeclInfoTests.cs index 5af00d3f..0f30cffd 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxCXXClassDeclInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxCXXClassDeclInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxCXXClassDeclInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxCXXClassDeclInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxCXXClassDeclInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxCXXClassDeclInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxCXXClassDeclInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxCXXClassDeclInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxCXXClassDeclInfo), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxCXXClassDeclInfo), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXIdxCXXClassDeclInfo), Is.EqualTo(12)); - } + Assert.That(sizeof(CXIdxCXXClassDeclInfo), Is.EqualTo(12)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxContainerInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxContainerInfoTests.cs index d400cad9..d008b0cd 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxContainerInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxContainerInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxContainerInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxContainerInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxContainerInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxContainerInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxContainerInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxContainerInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxContainerInfo), Is.EqualTo(32)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxContainerInfo), Is.EqualTo(32)); - } - else - { - Assert.That(sizeof(CXIdxContainerInfo), Is.EqualTo(20)); - } + Assert.That(sizeof(CXIdxContainerInfo), Is.EqualTo(20)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxDeclInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxDeclInfoTests.cs index 69b36390..d94390c1 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxDeclInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxDeclInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxDeclInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxDeclInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxDeclInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxDeclInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxDeclInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxDeclInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxDeclInfo), Is.EqualTo(128)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxDeclInfo), Is.EqualTo(128)); - } - else - { - Assert.That(sizeof(CXIdxDeclInfo), Is.EqualTo(76)); - } + Assert.That(sizeof(CXIdxDeclInfo), Is.EqualTo(76)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxEntityInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxEntityInfoTests.cs index 64d87539..5b76839b 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxEntityInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxEntityInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxEntityInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxEntityInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxEntityInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxEntityInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxEntityInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxEntityInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxEntityInfo), Is.EqualTo(80)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxEntityInfo), Is.EqualTo(80)); - } - else - { - Assert.That(sizeof(CXIdxEntityInfo), Is.EqualTo(48)); - } + Assert.That(sizeof(CXIdxEntityInfo), Is.EqualTo(48)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxEntityRefInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxEntityRefInfoTests.cs index 2cc1099a..22c58435 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxEntityRefInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxEntityRefInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxEntityRefInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxEntityRefInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxEntityRefInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxEntityRefInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxEntityRefInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxEntityRefInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxEntityRefInfo), Is.EqualTo(96)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxEntityRefInfo), Is.EqualTo(96)); - } - else - { - Assert.That(sizeof(CXIdxEntityRefInfo), Is.EqualTo(52)); - } + Assert.That(sizeof(CXIdxEntityRefInfo), Is.EqualTo(52)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxIBOutletCollectionAttrInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxIBOutletCollectionAttrInfoTests.cs index c179126a..946d04bd 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxIBOutletCollectionAttrInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxIBOutletCollectionAttrInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxIBOutletCollectionAttrInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxIBOutletCollectionAttrInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxIBOutletCollectionAttrInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxIBOutletCollectionAttrInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxIBOutletCollectionAttrInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxIBOutletCollectionAttrInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxIBOutletCollectionAttrInfo), Is.EqualTo(72)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxIBOutletCollectionAttrInfo), Is.EqualTo(72)); - } - else - { - Assert.That(sizeof(CXIdxIBOutletCollectionAttrInfo), Is.EqualTo(40)); - } + Assert.That(sizeof(CXIdxIBOutletCollectionAttrInfo), Is.EqualTo(40)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxImportedASTFileInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxImportedASTFileInfoTests.cs index 653cb4ea..63d3a7ff 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxImportedASTFileInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxImportedASTFileInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxImportedASTFileInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxImportedASTFileInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxImportedASTFileInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxImportedASTFileInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxImportedASTFileInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxImportedASTFileInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxImportedASTFileInfo), Is.EqualTo(48)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxImportedASTFileInfo), Is.EqualTo(48)); - } - else - { - Assert.That(sizeof(CXIdxImportedASTFileInfo), Is.EqualTo(24)); - } + Assert.That(sizeof(CXIdxImportedASTFileInfo), Is.EqualTo(24)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxIncludedFileInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxIncludedFileInfoTests.cs index 9d448d53..d90eee9c 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxIncludedFileInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxIncludedFileInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxIncludedFileInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxIncludedFileInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxIncludedFileInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxIncludedFileInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxIncludedFileInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxIncludedFileInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxIncludedFileInfo), Is.EqualTo(56)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxIncludedFileInfo), Is.EqualTo(56)); - } - else - { - Assert.That(sizeof(CXIdxIncludedFileInfo), Is.EqualTo(32)); - } + Assert.That(sizeof(CXIdxIncludedFileInfo), Is.EqualTo(32)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxLocTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxLocTests.cs index d04b099a..a0f4b9e0 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxLocTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxLocTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxLocTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxLocTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxLoc))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxLoc))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxLoc).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxLoc).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxLoc), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxLoc), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXIdxLoc), Is.EqualTo(12)); - } + Assert.That(sizeof(CXIdxLoc), Is.EqualTo(12)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCCategoryDeclInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCCategoryDeclInfoTests.cs index 9b14cbd7..9faa6b86 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCCategoryDeclInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCCategoryDeclInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxObjCCategoryDeclInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxObjCCategoryDeclInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCCategoryDeclInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCCategoryDeclInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxObjCCategoryDeclInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxObjCCategoryDeclInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxObjCCategoryDeclInfo), Is.EqualTo(80)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxObjCCategoryDeclInfo), Is.EqualTo(80)); - } - else - { - Assert.That(sizeof(CXIdxObjCCategoryDeclInfo), Is.EqualTo(44)); - } + Assert.That(sizeof(CXIdxObjCCategoryDeclInfo), Is.EqualTo(44)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCContainerDeclInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCContainerDeclInfoTests.cs index 64631a01..e7fe51f9 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCContainerDeclInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCContainerDeclInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxObjCContainerDeclInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxObjCContainerDeclInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCContainerDeclInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCContainerDeclInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxObjCContainerDeclInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxObjCContainerDeclInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxObjCContainerDeclInfo), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxObjCContainerDeclInfo), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXIdxObjCContainerDeclInfo), Is.EqualTo(8)); - } + Assert.That(sizeof(CXIdxObjCContainerDeclInfo), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCInterfaceDeclInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCInterfaceDeclInfoTests.cs index dc4a9c90..266c2a42 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCInterfaceDeclInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCInterfaceDeclInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxObjCInterfaceDeclInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxObjCInterfaceDeclInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCInterfaceDeclInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCInterfaceDeclInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxObjCInterfaceDeclInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxObjCInterfaceDeclInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxObjCInterfaceDeclInfo), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxObjCInterfaceDeclInfo), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXIdxObjCInterfaceDeclInfo), Is.EqualTo(12)); - } + Assert.That(sizeof(CXIdxObjCInterfaceDeclInfo), Is.EqualTo(12)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCPropertyDeclInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCPropertyDeclInfoTests.cs index 528caade..ae4429bc 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCPropertyDeclInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCPropertyDeclInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxObjCPropertyDeclInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxObjCPropertyDeclInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCPropertyDeclInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCPropertyDeclInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxObjCPropertyDeclInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxObjCPropertyDeclInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxObjCPropertyDeclInfo), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxObjCPropertyDeclInfo), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXIdxObjCPropertyDeclInfo), Is.EqualTo(12)); - } + Assert.That(sizeof(CXIdxObjCPropertyDeclInfo), Is.EqualTo(12)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCProtocolRefInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCProtocolRefInfoTests.cs index 9b92ed8f..26c6dbe7 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCProtocolRefInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCProtocolRefInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxObjCProtocolRefInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxObjCProtocolRefInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCProtocolRefInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCProtocolRefInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxObjCProtocolRefInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxObjCProtocolRefInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxObjCProtocolRefInfo), Is.EqualTo(64)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxObjCProtocolRefInfo), Is.EqualTo(64)); - } - else - { - Assert.That(sizeof(CXIdxObjCProtocolRefInfo), Is.EqualTo(36)); - } + Assert.That(sizeof(CXIdxObjCProtocolRefInfo), Is.EqualTo(36)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCProtocolRefListInfoTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCProtocolRefListInfoTests.cs index 8bbf63fd..da91d7eb 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCProtocolRefListInfoTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXIdxObjCProtocolRefListInfoTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXIdxObjCProtocolRefListInfoTests { - /// Provides validation of the struct. - public static unsafe partial class CXIdxObjCProtocolRefListInfoTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCProtocolRefListInfo))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXIdxObjCProtocolRefListInfo))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXIdxObjCProtocolRefListInfo).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXIdxObjCProtocolRefListInfo).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXIdxObjCProtocolRefListInfo), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXIdxObjCProtocolRefListInfo), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXIdxObjCProtocolRefListInfo), Is.EqualTo(8)); - } + Assert.That(sizeof(CXIdxObjCProtocolRefListInfo), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXModuleMapDescriptorImplTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXModuleMapDescriptorImplTests.cs index 50853e48..28c2e1a0 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXModuleMapDescriptorImplTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXModuleMapDescriptorImplTests.cs @@ -6,30 +6,29 @@ using NUnit.Framework; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXModuleMapDescriptorImplTests { - /// Provides validation of the struct. - public static unsafe partial class CXModuleMapDescriptorImplTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXModuleMapDescriptorImpl))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXModuleMapDescriptorImpl))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() - { - Assert.That(typeof(CXModuleMapDescriptorImpl).IsLayoutSequential, Is.True); - } + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXModuleMapDescriptorImpl).IsLayoutSequential, Is.True); + } - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() - { - Assert.That(sizeof(CXModuleMapDescriptorImpl), Is.EqualTo(1)); - } + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + Assert.That(sizeof(CXModuleMapDescriptorImpl), Is.EqualTo(1)); } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXPlatformAvailabilityTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXPlatformAvailabilityTests.cs index 2d0de4e3..dd95fe43 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXPlatformAvailabilityTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXPlatformAvailabilityTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXPlatformAvailabilityTests { - /// Provides validation of the struct. - public static unsafe partial class CXPlatformAvailabilityTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXPlatformAvailability))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXPlatformAvailability))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXPlatformAvailability).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXPlatformAvailability).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXPlatformAvailability), Is.EqualTo(72)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXPlatformAvailability), Is.EqualTo(72)); - } - else - { - Assert.That(sizeof(CXPlatformAvailability), Is.EqualTo(56)); - } + Assert.That(sizeof(CXPlatformAvailability), Is.EqualTo(56)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXSourceLocationTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXSourceLocationTests.cs index 218e7908..98e3c3c0 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXSourceLocationTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXSourceLocationTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXSourceLocationTests { - /// Provides validation of the struct. - public static unsafe partial class CXSourceLocationTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXSourceLocation))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXSourceLocation))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXSourceLocation).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXSourceLocation).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXSourceLocation), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXSourceLocation), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXSourceLocation), Is.EqualTo(12)); - } + Assert.That(sizeof(CXSourceLocation), Is.EqualTo(12)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXSourceRangeListTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXSourceRangeListTests.cs index 399d1a5d..ba23ed7b 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXSourceRangeListTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXSourceRangeListTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXSourceRangeListTests { - /// Provides validation of the struct. - public static unsafe partial class CXSourceRangeListTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXSourceRangeList))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXSourceRangeList))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXSourceRangeList).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXSourceRangeList).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXSourceRangeList), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXSourceRangeList), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXSourceRangeList), Is.EqualTo(8)); - } + Assert.That(sizeof(CXSourceRangeList), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXSourceRangeTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXSourceRangeTests.cs index de960cbb..535b1615 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXSourceRangeTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXSourceRangeTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXSourceRangeTests { - /// Provides validation of the struct. - public static unsafe partial class CXSourceRangeTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXSourceRange))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXSourceRange))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXSourceRange).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXSourceRange).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXSourceRange), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXSourceRange), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXSourceRange), Is.EqualTo(16)); - } + Assert.That(sizeof(CXSourceRange), Is.EqualTo(16)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXStringSetTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXStringSetTests.cs index bb7c4439..ab5de4cc 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXStringSetTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXStringSetTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXStringSetTests { - /// Provides validation of the struct. - public static unsafe partial class CXStringSetTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXStringSet))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXStringSet))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXStringSet).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXStringSet).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXStringSet), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXStringSet), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXStringSet), Is.EqualTo(8)); - } + Assert.That(sizeof(CXStringSet), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXStringTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXStringTests.cs index 22e76b2b..ca69e3b6 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXStringTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXStringTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXStringTests { - /// Provides validation of the struct. - public static unsafe partial class CXStringTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXString))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXString))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXString).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXString).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXString), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXString), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXString), Is.EqualTo(8)); - } + Assert.That(sizeof(CXString), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXTUResourceUsageEntryTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXTUResourceUsageEntryTests.cs index c0ad8d4d..60c7bbb7 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXTUResourceUsageEntryTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXTUResourceUsageEntryTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXTUResourceUsageEntryTests { - /// Provides validation of the struct. - public static unsafe partial class CXTUResourceUsageEntryTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXTUResourceUsageEntry))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXTUResourceUsageEntry))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXTUResourceUsageEntry).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXTUResourceUsageEntry).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXTUResourceUsageEntry), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXTUResourceUsageEntry), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CXTUResourceUsageEntry), Is.EqualTo(8)); - } + Assert.That(sizeof(CXTUResourceUsageEntry), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXTUResourceUsageTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXTUResourceUsageTests.cs index 3b50e34b..99efff9b 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXTUResourceUsageTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXTUResourceUsageTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXTUResourceUsageTests { - /// Provides validation of the struct. - public static unsafe partial class CXTUResourceUsageTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXTUResourceUsage))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXTUResourceUsage))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXTUResourceUsage).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXTUResourceUsage).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXTUResourceUsage), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXTUResourceUsage), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXTUResourceUsage), Is.EqualTo(12)); - } + Assert.That(sizeof(CXTUResourceUsage), Is.EqualTo(12)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXTargetInfoImplTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXTargetInfoImplTests.cs index 9f7bec13..ed31e4f5 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXTargetInfoImplTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXTargetInfoImplTests.cs @@ -6,30 +6,29 @@ using NUnit.Framework; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXTargetInfoImplTests { - /// Provides validation of the struct. - public static unsafe partial class CXTargetInfoImplTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXTargetInfoImpl))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXTargetInfoImpl))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() - { - Assert.That(typeof(CXTargetInfoImpl).IsLayoutSequential, Is.True); - } + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXTargetInfoImpl).IsLayoutSequential, Is.True); + } - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() - { - Assert.That(sizeof(CXTargetInfoImpl), Is.EqualTo(1)); - } + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + Assert.That(sizeof(CXTargetInfoImpl), Is.EqualTo(1)); } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXTokenTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXTokenTests.cs index 71c74103..a02aaba4 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXTokenTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXTokenTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXTokenTests { - /// Provides validation of the struct. - public static unsafe partial class CXTokenTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXToken))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXToken))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXToken).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXToken).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXToken), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXToken), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXToken), Is.EqualTo(20)); - } + Assert.That(sizeof(CXToken), Is.EqualTo(20)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXTranslationUnitImplTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXTranslationUnitImplTests.cs index 4a53a907..9975adf3 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXTranslationUnitImplTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXTranslationUnitImplTests.cs @@ -6,30 +6,29 @@ using NUnit.Framework; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXTranslationUnitImplTests { - /// Provides validation of the struct. - public static unsafe partial class CXTranslationUnitImplTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXTranslationUnitImpl))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXTranslationUnitImpl))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() - { - Assert.That(typeof(CXTranslationUnitImpl).IsLayoutSequential, Is.True); - } + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXTranslationUnitImpl).IsLayoutSequential, Is.True); + } - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() - { - Assert.That(sizeof(CXTranslationUnitImpl), Is.EqualTo(1)); - } + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + Assert.That(sizeof(CXTranslationUnitImpl), Is.EqualTo(1)); } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXTypeTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXTypeTests.cs index 768b4027..ba7d78b7 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXTypeTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXTypeTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXTypeTests { - /// Provides validation of the struct. - public static unsafe partial class CXTypeTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXType))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXType))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXType).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXType).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXType), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXType), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXType), Is.EqualTo(12)); - } + Assert.That(sizeof(CXType), Is.EqualTo(12)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXUnsavedFileTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXUnsavedFileTests.cs index 88f440bb..f132fbf2 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXUnsavedFileTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXUnsavedFileTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXUnsavedFileTests { - /// Provides validation of the struct. - public static unsafe partial class CXUnsavedFileTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXUnsavedFile))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXUnsavedFile))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXUnsavedFile).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CXUnsavedFile).IsLayoutSequential, Is.True); + Assert.That(sizeof(CXUnsavedFile), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CXUnsavedFile), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CXUnsavedFile), Is.EqualTo(12)); - } + Assert.That(sizeof(CXUnsavedFile), Is.EqualTo(12)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXVersionTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXVersionTests.cs index 3ffbaa97..220c71f6 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXVersionTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXVersionTests.cs @@ -6,30 +6,29 @@ using NUnit.Framework; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXVersionTests { - /// Provides validation of the struct. - public static unsafe partial class CXVersionTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXVersion))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXVersion))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() - { - Assert.That(typeof(CXVersion).IsLayoutSequential, Is.True); - } + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXVersion).IsLayoutSequential, Is.True); + } - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() - { - Assert.That(sizeof(CXVersion), Is.EqualTo(12)); - } + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + Assert.That(sizeof(CXVersion), Is.EqualTo(12)); } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CXVirtualFileOverlayImplTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CXVirtualFileOverlayImplTests.cs index 55701bf0..b4c5366c 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CXVirtualFileOverlayImplTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CXVirtualFileOverlayImplTests.cs @@ -6,30 +6,29 @@ using NUnit.Framework; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CXVirtualFileOverlayImplTests { - /// Provides validation of the struct. - public static unsafe partial class CXVirtualFileOverlayImplTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXVirtualFileOverlayImpl))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CXVirtualFileOverlayImpl))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() - { - Assert.That(typeof(CXVirtualFileOverlayImpl).IsLayoutSequential, Is.True); - } + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CXVirtualFileOverlayImpl).IsLayoutSequential, Is.True); + } - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() - { - Assert.That(sizeof(CXVirtualFileOverlayImpl), Is.EqualTo(1)); - } + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + Assert.That(sizeof(CXVirtualFileOverlayImpl), Is.EqualTo(1)); } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateArgumentLocTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateArgumentLocTests.cs index f61c3078..dc808b2a 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateArgumentLocTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateArgumentLocTests.cs @@ -5,37 +5,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CX_TemplateArgumentLocTests { - /// Provides validation of the struct. - public static unsafe partial class CX_TemplateArgumentLocTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CX_TemplateArgumentLoc))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CX_TemplateArgumentLoc))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CX_TemplateArgumentLoc).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CX_TemplateArgumentLoc).IsLayoutSequential, Is.True); + Assert.That(sizeof(CX_TemplateArgumentLoc), Is.EqualTo(16)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CX_TemplateArgumentLoc), Is.EqualTo(16)); - } - else - { - Assert.That(sizeof(CX_TemplateArgumentLoc), Is.EqualTo(8)); - } + Assert.That(sizeof(CX_TemplateArgumentLoc), Is.EqualTo(8)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateArgumentTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateArgumentTests.cs index 2fa80dba..9725a23f 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateArgumentTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateArgumentTests.cs @@ -5,37 +5,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CX_TemplateArgumentTests { - /// Provides validation of the struct. - public static unsafe partial class CX_TemplateArgumentTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CX_TemplateArgument))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CX_TemplateArgument))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CX_TemplateArgument).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CX_TemplateArgument).IsLayoutSequential, Is.True); + Assert.That(sizeof(CX_TemplateArgument), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CX_TemplateArgument), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CX_TemplateArgument), Is.EqualTo(16)); - } + Assert.That(sizeof(CX_TemplateArgument), Is.EqualTo(16)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateNameTests.cs b/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateNameTests.cs index ce0e46d1..1c69dc98 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateNameTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/CX_TemplateNameTests.cs @@ -5,37 +5,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class CX_TemplateNameTests { - /// Provides validation of the struct. - public static unsafe partial class CX_TemplateNameTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CX_TemplateName))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(CX_TemplateName))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(CX_TemplateName).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(CX_TemplateName).IsLayoutSequential, Is.True); + Assert.That(sizeof(CX_TemplateName), Is.EqualTo(24)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(CX_TemplateName), Is.EqualTo(24)); - } - else - { - Assert.That(sizeof(CX_TemplateName), Is.EqualTo(12)); - } + Assert.That(sizeof(CX_TemplateName), Is.EqualTo(12)); } } } diff --git a/tests/ClangSharp.UnitTests/InteropTests/IndexerCallbacksTests.cs b/tests/ClangSharp.UnitTests/InteropTests/IndexerCallbacksTests.cs index ddd84678..ab17e840 100644 --- a/tests/ClangSharp.UnitTests/InteropTests/IndexerCallbacksTests.cs +++ b/tests/ClangSharp.UnitTests/InteropTests/IndexerCallbacksTests.cs @@ -7,37 +7,36 @@ using System; using System.Runtime.InteropServices; -namespace ClangSharp.Interop.UnitTests +namespace ClangSharp.Interop.UnitTests; + +/// Provides validation of the struct. +public static unsafe partial class IndexerCallbacksTests { - /// Provides validation of the struct. - public static unsafe partial class IndexerCallbacksTests + /// Validates that the struct is blittable. + [Test] + public static void IsBlittableTest() { - /// Validates that the struct is blittable. - [Test] - public static void IsBlittableTest() - { - Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(IndexerCallbacks))); - } + Assert.That(Marshal.SizeOf(), Is.EqualTo(sizeof(IndexerCallbacks))); + } - /// Validates that the struct has the right . - [Test] - public static void IsLayoutSequentialTest() + /// Validates that the struct has the right . + [Test] + public static void IsLayoutSequentialTest() + { + Assert.That(typeof(IndexerCallbacks).IsLayoutSequential, Is.True); + } + + /// Validates that the struct has the correct size. + [Test] + public static void SizeOfTest() + { + if (Environment.Is64BitProcess) { - Assert.That(typeof(IndexerCallbacks).IsLayoutSequential, Is.True); + Assert.That(sizeof(IndexerCallbacks), Is.EqualTo(64)); } - - /// Validates that the struct has the correct size. - [Test] - public static void SizeOfTest() + else { - if (Environment.Is64BitProcess) - { - Assert.That(sizeof(IndexerCallbacks), Is.EqualTo(64)); - } - else - { - Assert.That(sizeof(IndexerCallbacks), Is.EqualTo(32)); - } + Assert.That(sizeof(IndexerCallbacks), Is.EqualTo(32)); } } } diff --git a/tests/ClangSharp.UnitTests/TranslationUnitTest.cs b/tests/ClangSharp.UnitTests/TranslationUnitTest.cs index d52164b6..8f3500fa 100644 --- a/tests/ClangSharp.UnitTests/TranslationUnitTest.cs +++ b/tests/ClangSharp.UnitTests/TranslationUnitTest.cs @@ -5,54 +5,53 @@ using ClangSharp.Interop; using NUnit.Framework; -namespace ClangSharp.UnitTests +namespace ClangSharp.UnitTests; + +public abstract class TranslationUnitTest { - public abstract class TranslationUnitTest - { - protected const string DefaultInputFileName = "ClangUnsavedFile.h"; + protected const string DefaultInputFileName = "ClangUnsavedFile.h"; - protected const CXTranslationUnit_Flags DefaultTranslationUnitFlags = CXTranslationUnit_Flags.CXTranslationUnit_IncludeAttributedTypes // Include attributed types in CXType - | CXTranslationUnit_Flags.CXTranslationUnit_VisitImplicitAttributes; // Implicit attributes should be visited + protected const CXTranslationUnit_Flags DefaultTranslationUnitFlags = CXTranslationUnit_Flags.CXTranslationUnit_IncludeAttributedTypes // Include attributed types in CXType + | CXTranslationUnit_Flags.CXTranslationUnit_VisitImplicitAttributes; // Implicit attributes should be visited - protected static readonly string[] DefaultClangCommandLineArgs = new string[] - { - "-std=c++17", // The input files should be compiled for C++ 17 - "-xc++", // The input files are C++ - "-Wno-pragma-once-outside-header" // We are processing files which may be header files - }; + protected static readonly string[] DefaultClangCommandLineArgs = new string[] + { + "-std=c++17", // The input files should be compiled for C++ 17 + "-xc++", // The input files are C++ + "-Wno-pragma-once-outside-header" // We are processing files which may be header files + }; - protected static TranslationUnit CreateTranslationUnit(string inputContents) - { - Assert.True(File.Exists(DefaultInputFileName)); + protected static TranslationUnit CreateTranslationUnit(string inputContents) + { + Assert.True(File.Exists(DefaultInputFileName)); + + using var unsavedFile = CXUnsavedFile.Create(DefaultInputFileName, inputContents); + var unsavedFiles = new CXUnsavedFile[] { unsavedFile }; - using var unsavedFile = CXUnsavedFile.Create(DefaultInputFileName, inputContents); - var unsavedFiles = new CXUnsavedFile[] { unsavedFile }; + var index = CXIndex.Create(); + var translationUnit = CXTranslationUnit.Parse(index, DefaultInputFileName, DefaultClangCommandLineArgs, unsavedFiles, DefaultTranslationUnitFlags); - var index = CXIndex.Create(); - var translationUnit = CXTranslationUnit.Parse(index, DefaultInputFileName, DefaultClangCommandLineArgs, unsavedFiles, DefaultTranslationUnitFlags); + if (translationUnit.NumDiagnostics != 0) + { + var errorDiagnostics = new StringBuilder(); + _ = errorDiagnostics.AppendLine($"The provided {nameof(CXTranslationUnit)} has the following diagnostics which prevent its use:"); + var invalidTranslationUnitHandle = false; - if (translationUnit.NumDiagnostics != 0) + for (uint i = 0; i < translationUnit.NumDiagnostics; ++i) { - var errorDiagnostics = new StringBuilder(); - _ = errorDiagnostics.AppendLine($"The provided {nameof(CXTranslationUnit)} has the following diagnostics which prevent its use:"); - var invalidTranslationUnitHandle = false; + using var diagnostic = translationUnit.GetDiagnostic(i); - for (uint i = 0; i < translationUnit.NumDiagnostics; ++i) + if (diagnostic.Severity is CXDiagnosticSeverity.CXDiagnostic_Error or CXDiagnosticSeverity.CXDiagnostic_Fatal) { - using var diagnostic = translationUnit.GetDiagnostic(i); - - if (diagnostic.Severity is CXDiagnosticSeverity.CXDiagnostic_Error or CXDiagnosticSeverity.CXDiagnostic_Fatal) - { - invalidTranslationUnitHandle = true; - _ = errorDiagnostics.Append(' ', 4); - _ = errorDiagnostics.AppendLine(diagnostic.Format(CXDiagnosticDisplayOptions.CXDiagnostic_DisplayOption).ToString()); - } + invalidTranslationUnitHandle = true; + _ = errorDiagnostics.Append(' ', 4); + _ = errorDiagnostics.AppendLine(diagnostic.Format(CXDiagnosticDisplayOptions.CXDiagnostic_DisplayOption).ToString()); } - - Assert.False(invalidTranslationUnitHandle, errorDiagnostics.ToString()); } - return TranslationUnit.GetOrCreate(translationUnit); + Assert.False(invalidTranslationUnitHandle, errorDiagnostics.ToString()); } + + return TranslationUnit.GetOrCreate(translationUnit); } }