That's potentially risky move on real codebases, but that's not captured anywhere in tests, so I will move ahead with a change.
Would be good if somebody test that on some larger codebase and check how it works for them.
Most other changes is only in testing infra. I take liberty and do following change operating from following premises.
- there only 2 radically different output formats: CSharp and Xml
- Most codegeneration would be platform neutral.
- You will need to override tests based on platform needs (like it is right now)
I do trying not create sets of identical tests for each platform, since it's a bit boring and timeconsuming to validate. For example using existing approach not clear what's platform-independent behaviour and what is OS specific behavior of ClangSharp. After this change all platform independent tests may sit in Base folder, and additional tests and/or augmentations will be in same location as it is now.
Fixes#357
* Refactoring how the calling convention is looked up for a given cursor or type
* Ensure that non-char based string literals don't assert with debug clang
* Ensure that managled names are correctly represented in DllImport
* Ensure creating a span over a pointer works on netstandard
* Don't include the underscore prefix on the entry point name for simple C exports
* Ensure ObjCProtocol creates an ObjCProtocolDecl
* Ensure the number of indirections for function pointer typedefs is correct
* Handle type prefixes in C
* Add basic handling for VarDecl and OffsetOfExpr
* Allow specifying just `-x c` on the command line
* Fix the C test on Unix
* Updating Clang/LLVM to 12.0.0
* Splitting the main project into ClangSharp and ClangSharp.Interop
* Enable long file paths before cloning win32metadata
* Add ClangSharpPInvokeGenerator to the path when testing win32metadata
* Introduce EnumDesc, add ability to output source location attribute
* Expose config flag and add struct+field test
* Add method+parameter test
* Update PInvokeGeneratorConfigurationOptions to use bit shifting
Previously, all conditionals were marked as not constant. However, if the Cond, LHS and RHS are all constant, the ternary can be marked constant as well
* Adjusting how the index is retrieved for call expressions
* Allow getting the current contents of the C# output builder
* Better handle getting the cursor qualified name when DeclContext is null
* Handle IntegerLiteral where the kind is a named constant
* Ensure the checks in Type.CastAs and Type.GetAs are correct
* Fallback to ThisObjectType.AsCXXRecordDecl when CXXMethodDecl.Parent is null
* Better support generating names for template types
* Handle call expressions that don't have a declaration
* Don't try to directly visit a virtual destructor declaration
* Correctly handle argument counts for instance CXXOperatorCallExpr
* Don't use Finalize for destructors as it is reserved
* Adding basic support for CXXNewExpr
* Adding basic support for CXXDefaultArgExpr
* Adding basic support for SubstNonTypeTemplateParmExpr
* Adding support for builtin and pointer init list expressions
* Handle FriendDecl and TemplateSpecializationType
* Adding basic support for ExprWithCleanups
* Ensure existing expression types are handled by IsChecked and IsConstant
* Updating GetRemappedName to respect remappings to the same name
* Resolving analyzer diagnostics
* Adding basic support for handling class and function template declarations
* Don't emit NativeTypeNameAttribute when the names only differ by whitespace
* Don't double count anonymous record decls when computing size
* Handle label declarations
* Respect an existing type name remapping
* Ensure we don't traverse too far up for indirect field decl context parts
* Ensure ArraySubscriptExpr differentiates LHS vs RHS
* Ensure we still do the nativeTypeName == remappedName check in all paths
* Collect artifacts from the win32metadata test
* Fixing an issue with the "exclude function bodies" logic
* Don't process template decls without explicit opt-in
* Ensure GetTypeSize doesn't end up with an alignment of -1
* Catch exceptions and return them as a trailing error diagnostic
* Handle null statements
* Ensure nested anonymous records get the correct name
* Adding tests to cover remapping nested type names
* Ensure remapping works for either A::B or A.B
* Adding an option for generating a VtblIndex attribute
* Adding tests validating the VtblIndexAttribute, NativeInheritanceAttribute, and explicit vtbl generation
* Move fnptr and nint codegen to be part of latest by default
* Ensure multi-dimensional fixed-sized buffers use the correct name for the first field
* Ensure multi-dimensional buffers are correctly handled for variable declarations
* Ensure we use main and beta3 in our CI and versions
* Ensure vtbl indices are properly accounted for.
* Updating Stmts to use Stmt.Children where possible
* Expanding support for Expr in libClangSharp
* Expanding support for Decl in libClangSharp
* Ensure that the P/Invoke Generator works with libClangSharp changes
* Ensure ObjC and AtomicExpr expose their members
* Switch to ConcurrentDictionary to better handle parallel translation unit creation/destruction
* Ensure we aren't taking the address of an rvalue
* Ensure the right vtbl indices are picked for Unix vs Windows
* Updating libClangSharp to beta2
* Ensure tests run for Latest vs Compat and Unix vs Window modes
* Ensure \n is used in the xml generator
* Fixing up some running on unix vs windows test differences
* Start of XML output
* Continuation of XML output
* Add Rider stuff to the .gitignore
* Start breaking the ice on COM
* Finished(?) structs with COM helpers
* It builds!
* Change to om
* Fix NRE
* Initial set of fixes
* C# fixes
* XML fixes
* Internalise
* Internalise OutputBuilderFactory
* Fix some tests
* Be more stern with our dividers
* Continued
* Revert "Continued"
This reverts commit ae28f46a35.
* Try hacking something together
* Move
* Try again
* Boolean logic is failing me
* Somewhat hacky fix but it makes sense
* ConstantDesc
* FieldDesc
* Flags
* Update FunctionOrDelegateDesc.cs
* Update FunctionOrDelegateDesc.cs
* Update StructDesc.cs
* Accessibility enums?
* Calling convention enum
* Set vtbl methods as unsafe by default
* Ensure "unsafe" is inserted for standalone delegates
* Ensure unsafe isn't emitted on the method class due to vtbl helper methods
Co-authored-by: Tanner Gooding <tagoo@outlook.com>
* Add the libClangSharp files as solution items
* Updating to support .NET 5 and to use Open.snk
* Don't set RuntimeIdentifier at the solution level
* Don't build ClangSharpPInvokeGenerator for net461 since that blocks packing as a tool
* Adding a job to build the release nuget packages
* Simplifying several of the local functions to implicitly capture `this`
* Adding support for aggressively inlining helper functions
* Simplifying the outputBuilder calls
* Optimize exclusion checks
* Fixing the location of AggressiveInlining attributes
* Simplifying the test helper method for validating generated bindings
* Fixing OutputVtblHelperMethod to correctly track the index even when excluding
* Better handle emitting the qualified name for nested anonymous records
* Ensure fixed sized buffers defined via typedefs are emitted properly.
* Better handle fixed sized buffers in anonymous records for compat mode
* Automatically handle uuid attributes
* Don't emit EntryPoint if unnecessary
* Automatically generate IID_RecordName variables for uuid attributes
* Track struct inheritance in the NativeTypeName attribute
* Traverse namespace declarations and perform better statement lookthrough for parentheses
* Fixing a check in IsEnumOperator
* Skip the GuidTest on Unix
* Adding support for automatically excluding com proxies, certain conflicting method declarations, empty records, and enum operators
* Improve generated code for a number of scenarios
* Exposing additional information about types
* Don't pack as tool for local builds
* Handle Enum as the backing bitfield type
* Handle CXXUuidofExpr
* Handle arrays with a size of 0
* Adding support for alignof UnaryExprOrTypeTraitExpr
* Adding support for GotoStmt and LabelStmt
* Ensure the number of template arguments is correctly returned
* Escape string literals
* Cleaning up how semicolons are emitted and statement bodies are visited
* Upgrading libClangSharp to 10.0.2-beta2
* Adding Microsoft.SourceLink.GitHub
* Fixing the handling of while statement bodies
* Handle some explicit integer literal suffixes
* Changing macro binding support to parse at most one additional translation unit
* Ensure UnaryExprOrTypeTraitExpr doesn't crash
* Better handle insertion of unchecked for explicit and implicit casts over integer literals
* Ensure nested anonymous structs have the right name
* Removing unnecessary IsExcluded checks
* Updating anonymous unions to generate ref helpers for more natural access
* Adding minimal support for handling macro definition records
* Adding minimal handling for multi-line macro definition records
* Adding minimal handling for string literals
* Adding dedicated support for Guid constants
* Handle floating-point constants ending with just . or .f
* Cleaning up how the cursor parent is tracked so items can be lazily created
* Use WeakReference to help with memory for large ASTs
* Ensure LinkageSpecDecl children are still visited
* Regenerate libClang bindings
* Fixing a test to expect =>
* Fixing the handling for nested anonymous bitfield declarations
* Don't exclude VarDecl created for a MacroDefinitionRecord
* Expanding the support for declarations
* Expanding the support for expressions and statements
* Ensure all cursors are traversed up front so the hiearchy is correct.
* Fixing a build warning
* Updating libClangSharp nuspecs to 10.0.0-beta2
* Updating ClangSharp to be 10.0.0-beta2
* Regenerating the interop bindings for libClangSharp
* Removing a duplicated file
* Fixing some issues in libClangSharp
* Updating ClangSharp to account for libClangSharp changes
* Updating libClangSharp to 10.0.1-beta2
* Fixing the CLANGSHARP_LINKAGE definition on Windows
* Fixing up how function pointer signatures are emitted for VTBLs
* Add a new config option for generating explicit vs implicit vtbls and make implicit the default.
* Adding basic support for generating tests
* Adding basic sanity tests for the interop structs
* Adding a missing parenthese
* Fixing a test to assert the correct size on 32-bit vs 64-bit
* Add a DebuggerDisplay attribute to Cursor and Type
* Ensure we insert unchecked casts for certain implicit conversions
* Adding some more members to Cursors/Preprocessings/*
* Allow more members to be excluded and to be excluded via the fully qualified name
* Adding a switch to log declarations which get excluded and why
* Adjusting the declaration exclusion check to include the file check and support logging visited files
* Adding functionality to get the argument type or expression from a UnaryExprOrTypeTraitExpr
* Don't return a void expression
* Allow folding away a sizeof for an optional argument expression when the size is fixed
* Ensure we ignore prior visitations for decl statements
* Partially handle class template specializations in the qualified name logic
* Include nothrow in the method qualified name
* Handle bool and packing
* Handle UnaryExprOrTypeTraitExpr which have a Ref child
* Avoid a warning for Linux/macOS in the enum declaration tests
* Enable better default handling of anonymous names
* Add a --with-librarypath option
* Use a case insensitive comparison on Windows
* Don't emit the calling convention for Winapi
* Don't add extra quotes around the older --libraryPath option
* Removing dependency on Microsoft.Net.Compilers.Toolset
* Updating dependencies to their latest versions
* Removing a System.CommandLine workaround for the argument arity
* Make the --library optional
* Adding support for with-setlasterror
* Fixing function pointers to not unnecessarily add an indirection
* Ensure ReferenceTypes are dereferenced using ->
* Don't use pointers for the fixed sized-buffer ref codegen
* Work around a limitation in System.CommandLine
* Normalize paths when checking for files to traverse
* Ensure we traverse LinkageSpecDecls so that extern "C" { #include <file> } isn't missed
* Normalize the native type name when it contains a path
* Normalizing paths when printing diagnostics
* Handling visiting typedefs to attributed types
* Handle empty return statements
* Adding handling for anonymous field declarations
* Add support for generating nint/nuint as a preview feature
* Add support for generating fnptrs as a preview feature
* Don't mark the Vtbl field as readonly
* Fixing up the tests to not require `readonly Vtbl`
* Updating the version to 10.0.0
* Updating dependencies to their latest stable versions
* Upgrading to .NET Core 3.1
* Resolving issues from upgrading System.CommandLine
* Switching the launchSettings.json to use rsp files
* Fixing up the libClangSharp helper library for 10.0.0
* Regenerating the ClangSharp bindings for 10.0.0
* Fixing up the Interop.Extensions
* Fixing up the managed API
* Updating the Linux rid to ubuntu.18.04-x64
* Upgrade the unit test projects to netcoreapp3.1
* Support InitListExpr
* Support CXXConversionDecl
* Fixing spacing of VarDecls and trim unnecessary literal specifiers
* Print a diagnostic when encountering a function template
* Handle non-virtual method declarations from base classes
* Take LValueReferenceType transformations into account when visiting AddrOf unary operators
* Provide a more fine-tuned way to exclude methods and change --with-namespace to be called --with-using
* Ensure base types with fields are handled
* Ensure using declarations are handled
* Fixing how "new" is applied to the member names
* Handle typedefs to references
* Handle character literals
* Adding tests covering more optional parameter types
* Changing the visitation logic to only track visited declarations
* Handle the common case of implicit conversion from 0 to nullptr
* Handle cxx named cast expressions
* Ensure that static using directives are printed when there are no regular using directives
* Adding support for array subscript expressions
* Updating BinaryOperator and CallExpr to use explicit indices
* Handle conditional operators
* Handle member expressions
* Handle cxx this expressions
* Adding support for declaration statements
* Updating OutputBuilder to directly track and handle additional newline requirements
* Handle if/then/else statements
* Fixing VisitDeclStmt to need a newline unless the previous statement was also a DeclStmt
* Adding some logic for better handling semicolons and newlines in statements
* Adding support for do and while statements
* Adding support for for statements
* Adding support for switch, case, default, break, and continue statements
* Adding support for CXXMemberCallExpr
* Support CXXConstructorDecl and CXXDestructorDecl
* Adding support for binding and calling operators
* Ensure multidimensional constant arrays work as expected
* Support adding the "new" keyword when required for certain member names.
* Fixing the vtbl binding generation to account for conflicting names.
* Ensure the expansion location is taken into account for all declaration traversals
* Provide a mechanism for providing additional attributes and using directives for declarations