From 15eb1eafe96c98524b5de5f7a1dadfe53b08e22a Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sat, 8 Jul 2023 11:20:56 -0700 Subject: [PATCH 1/4] Updating the repo to target the latest .NET 8 preview --- .editorconfig | 3 + ClangSharp.sln | 1 + Directory.Build.props | 8 +- Directory.Build.targets | 2 +- Directory.Packages.props | 1 - exclusion.dic | 223 ++++++ global.json | 2 +- scripts/build.ps1 | 3 +- scripts/build.sh | 3 +- .../ClangSharp.Interop.csproj | 5 +- sources/ClangSharp.Interop/Configuration.cs | 30 + .../Extensions/CXClientData.cs | 6 +- .../Extensions/CXCodeCompleteResults.cs | 4 +- .../Extensions/CXComment.cs | 66 +- .../Extensions/CXCompilationDatabase.cs | 10 +- .../Extensions/CXCompileCommand.cs | 20 +- .../Extensions/CXCompileCommands.cs | 18 +- .../Extensions/CXCompletionString.cs | 26 +- .../ClangSharp.Interop/Extensions/CXCursor.cs | 732 +++++++++--------- .../Extensions/CXCursorSet.cs | 10 +- .../Extensions/CXDiagnostic.cs | 32 +- .../Extensions/CXDiagnosticSet.cs | 18 +- .../Extensions/CXEvalResult.cs | 20 +- .../ClangSharp.Interop/Extensions/CXFile.cs | 16 +- .../Extensions/CXIdxClientASTFile.cs | 6 +- .../Extensions/CXIdxClientContainer.cs | 6 +- .../Extensions/CXIdxClientEntity.cs | 6 +- .../Extensions/CXIdxClientFile.cs | 6 +- .../Extensions/CXIdxEntityInfo.cs | 2 +- .../ClangSharp.Interop/Extensions/CXIdxLoc.cs | 4 +- .../ClangSharp.Interop/Extensions/CXIndex.cs | 12 +- .../Extensions/CXIndexAction.cs | 12 +- .../ClangSharp.Interop/Extensions/CXModule.cs | 22 +- .../Extensions/CXModuleMapDescriptor.cs | 12 +- .../Extensions/CXPrintingPolicy.cs | 10 +- .../Extensions/CXRemapping.cs | 10 +- .../Extensions/CXSourceLocation.cs | 22 +- .../Extensions/CXSourceRange.cs | 14 +- .../Extensions/CXSourceRangeList.cs | 2 +- .../ClangSharp.Interop/Extensions/CXString.cs | 6 +- .../Extensions/CXStringSet.cs | 2 +- .../Extensions/CXTUResourceUsage.cs | 4 +- .../Extensions/CXTUResourceUsageEntry.cs | 4 +- .../Extensions/CXTargetInfo.cs | 12 +- .../ClangSharp.Interop/Extensions/CXToken.cs | 14 +- .../Extensions/CXTranslationUnit.cs | 68 +- .../ClangSharp.Interop/Extensions/CXType.cs | 156 ++-- .../Extensions/CXUnsavedFile.cs | 4 +- .../Extensions/CXVirtualFileOverlay.cs | 12 +- .../Extensions/CX_TemplateArgument.cs | 30 +- .../Extensions/CX_TemplateArgumentLoc.cs | 16 +- .../Extensions/CX_TemplateName.cs | 2 +- .../Extensions/clang.ResolveLibrary.cs | 77 -- .../ILLink.Substitutions.xml | 10 + .../Internals/MarshaledString.cs | 4 +- .../Internals/MarshaledStringArray.cs | 4 +- sources/ClangSharp.Interop/clang.cs | 79 ++ sources/ClangSharp.Interop/clang/clang.cs | 2 +- .../Abstractions/EnumDesc.cs | 2 +- .../Abstractions/FunctionOrDelegateDesc.cs | 30 +- .../Abstractions/StructDesc.cs | 18 +- .../Abstractions/ValueDesc.cs | 8 +- .../CSharp/CSharpOutputBuilder.Visit.cs | 4 + .../CSharp/CSharpOutputBuilder.VisitDecl.cs | 2 +- .../ClangSharp.PInvokeGenerator.csproj | 2 +- .../ClangSharp.PInvokeGenerator/Diagnostic.cs | 13 +- .../PInvokeGenerator.VisitDecl.cs | 81 +- .../PInvokeGenerator.VisitStmt.cs | 16 +- .../PInvokeGenerator.cs | 263 ++----- .../PInvokeGeneratorConfiguration.cs | 34 +- .../XML/XmlOutputBuilder.VisitDecl.cs | 30 +- sources/ClangSharp/ClangSharp.csproj | 2 +- .../Cursors/Decls/CXXConstructorDecl.cs | 4 +- .../Cursors/Decls/LinkageSpecDecl.cs | 2 +- .../Cursors/Exprs/CompoundLiteralExpr.cs | 6 +- .../ClangSharp/Cursors/Stmts/CompoundStmt.cs | 18 +- .../ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs | 4 +- .../ClangSharpPInvokeGenerator.csproj | 2 +- .../CustomHelpBuilder.cs | 2 +- sources/ClangSharpPInvokeGenerator/Program.cs | 165 ++-- sources/Directory.Build.props | 8 +- .../Base/EnumDeclarationTest.cs | 2 + .../Base/FunctionDeclarationDllImportTest.cs | 2 + .../Base/StructDeclarationTest.cs | 3 + .../Base/UnionDeclarationTest.cs | 3 + .../Base/VarDeclarationTest.cs | 3 + .../EnumDeclarationTest.cs | 4 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../UnionDeclarationTest.cs | 7 +- .../VarDeclarationTest.cs | 7 +- .../EnumDeclarationTest.cs | 4 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../UnionDeclarationTest.cs | 7 +- .../VarDeclarationTest.cs | 8 +- .../CSharpDefaultUnix/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../CSharpDefaultUnix/UnionDeclarationTest.cs | 7 +- .../CSharpDefaultUnix/VarDeclarationTest.cs | 8 +- .../EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../UnionDeclarationTest.cs | 7 +- .../VarDeclarationTest.cs | 8 +- .../CSharpLatestUnix/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../CSharpLatestUnix/StructDeclarationTest.cs | 7 +- .../CSharpLatestUnix/UnionDeclarationTest.cs | 7 +- .../CSharpLatestUnix/VarDeclarationTest.cs | 8 +- .../EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../UnionDeclarationTest.cs | 7 +- .../CSharpLatestWindows/VarDeclarationTest.cs | 8 +- .../CSharpPreviewUnix/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../CSharpPreviewUnix/UnionDeclarationTest.cs | 7 +- .../CSharpPreviewUnix/VarDeclarationTest.cs | 8 +- .../EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../UnionDeclarationTest.cs | 7 +- .../VarDeclarationTest.cs | 8 +- ...angSharp.PInvokeGenerator.UnitTests.csproj | 2 +- .../XmlCompatibleUnix/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../XmlCompatibleUnix/UnionDeclarationTest.cs | 7 +- .../XmlCompatibleUnix/VarDeclarationTest.cs | 8 +- .../EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../UnionDeclarationTest.cs | 7 +- .../VarDeclarationTest.cs | 8 +- .../XmlDefaultUnix/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../XmlDefaultUnix/StructDeclarationTest.cs | 7 +- .../XmlDefaultUnix/UnionDeclarationTest.cs | 7 +- .../XmlDefaultUnix/VarDeclarationTest.cs | 8 +- .../XmlDefaultWindows/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../XmlDefaultWindows/UnionDeclarationTest.cs | 7 +- .../XmlDefaultWindows/VarDeclarationTest.cs | 8 +- .../XmlLatestUnix/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../XmlLatestUnix/StructDeclarationTest.cs | 7 +- .../XmlLatestUnix/UnionDeclarationTest.cs | 7 +- .../XmlLatestUnix/VarDeclarationTest.cs | 8 +- .../XmlLatestWindows/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../XmlLatestWindows/StructDeclarationTest.cs | 7 +- .../XmlLatestWindows/UnionDeclarationTest.cs | 7 +- .../XmlLatestWindows/VarDeclarationTest.cs | 8 +- .../XmlPreviewUnix/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../XmlPreviewUnix/StructDeclarationTest.cs | 7 +- .../XmlPreviewUnix/UnionDeclarationTest.cs | 7 +- .../XmlPreviewUnix/VarDeclarationTest.cs | 8 +- .../XmlPreviewWindows/EnumDeclarationTest.cs | 2 +- .../FunctionDeclarationDllImportTest.cs | 4 +- .../StructDeclarationTest.cs | 7 +- .../XmlPreviewWindows/UnionDeclarationTest.cs | 7 +- .../XmlPreviewWindows/VarDeclarationTest.cs | 8 +- .../ClangSharp.UnitTests.csproj | 2 +- 168 files changed, 1565 insertions(+), 1530 deletions(-) create mode 100644 exclusion.dic create mode 100644 sources/ClangSharp.Interop/Configuration.cs delete mode 100644 sources/ClangSharp.Interop/Extensions/clang.ResolveLibrary.cs create mode 100644 sources/ClangSharp.Interop/ILLink.Substitutions.xml create mode 100644 sources/ClangSharp.Interop/clang.cs diff --git a/.editorconfig b/.editorconfig index 3467ebf9..1909f880 100644 --- a/.editorconfig +++ b/.editorconfig @@ -21,6 +21,9 @@ end_of_line = lf insert_final_newline = true indent_style = space indent_size = 4 +spelling_error_severity = information +spelling_exclusion_path = exclusion.dic +spelling_languages = en-us tab_width = 4 trim_trailing_whitespace = true diff --git a/ClangSharp.sln b/ClangSharp.sln index 1516287e..22b11833 100644 --- a/ClangSharp.sln +++ b/ClangSharp.sln @@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets Directory.Packages.props = Directory.Packages.props + exclusion.dic = exclusion.dic global.json = global.json LICENSE.md = LICENSE.md NOTICE.md = NOTICE.md diff --git a/Directory.Build.props b/Directory.Build.props index b8e691a8..01e2980e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,7 +20,7 @@ true - preview + preview-all $(BaseArtifactsPath)obj/$(BaseArtifactsPathSuffix)/ embedded false @@ -42,10 +42,14 @@ $(BaseArtifactsPath)bin/$(BaseArtifactsPathSuffix)/ .NET Foundation true + true + true + true + true $(BaseArtifactsPath)pkg/$(Configuration)/ ClangSharp ClangSharp - 16.0.0 + 16.0.1 rc1 pr diff --git a/Directory.Build.targets b/Directory.Build.targets index ee04b707..c0804224 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -12,7 +12,7 @@ - $(NoWarn);AD0001 + $(NoWarn) diff --git a/Directory.Packages.props b/Directory.Packages.props index 44502178..70b0337b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -16,7 +16,6 @@ - diff --git a/exclusion.dic b/exclusion.dic new file mode 100644 index 00000000..b9f77547 --- /dev/null +++ b/exclusion.dic @@ -0,0 +1,223 @@ +accum +addr +addrspace +alignm +alignof +arglist +argv +assoc +assocs +attrs +autorelease +autoreleased +bicc +bitwidth +blittability +builtin +bycopy +byref +callconv +cdecl +clangsharp +cmse +coawait +comdat +constexpr +convs +coreturn +coyield +cref +cset +csharp +ctors +cxxmd +cx_attrkind_a +cx_attrkind_amdgpu +cx_attrkind_arm +cx_attrkind_avr +cx_attrkind_bpf +cx_attrkind_btf +cx_attrkind_c +cx_attrkind_cf +cx_attrkind_cfi +cx_attrkind_cmsens +cx_attrkind_cpu +cx_attrkind_cuda +cx_attrkind_dll +cx_attrkind_enforcetcb +cx_attrkind_firsthlsl +cx_attrkind_firstparameterabi +cx_attrkind_gnu +cx_attrkind_hip +cx_attrkind_hlsl +cx_attrkind_i +cx_attrkind_ib +cx_attrkind_lasthlsl +cx_attrkind_lastparameterabi +cx_attrkind_lto +cx_attrkind_mig +cx_attrkind_ms +cx_attrkind_msabi +cx_attrkind_ns +cx_attrkind_objc +cx_attrkind_objcgc +cx_attrkind_objcns +cx_attrkind_omp +cx_attrkind_opencl +cx_attrkind_os +cx_attrkind_pragmaclangbss +cx_attrkind_riscv +cx_attrkind_s +cx_attrkind_swiftobjc +cx_attrkind_sycl +cx_attrkind_sysvabi +cx_attrkind_tls +cx_attrkind_trivialabi +cx_attrkind_u +cx_attrkind_x +cx_ck_blockpointertoobjc +cx_ck_inttoocl +cx_ck_objc +cx_ck_zerotoocl +cx_cr_objc +cx_declkind_cxx +cx_declkind_externc +cx_declkind_firstcxx +cx_declkind_firstobjc +cx_declkind_hlsl +cx_declkind_lastcxx +cx_declkind_lastobjc +cx_declkind_ms +cx_declkind_objc +cx_declkind_omp +cx_sc_opencl +cx_stmtclass_c +cx_stmtclass_cuda +cx_stmtclass_cxx +cx_stmtclass_firstcxx +cx_stmtclass_firstomp +cx_stmtclass_gcc +cx_stmtclass_gnu +cx_stmtclass_lastcxx +cx_stmtclass_lastomp +cx_stmtclass_ms +cx_stmtclass_objc +cx_stmtclass_omp +cx_stmtclass_seh +cx_stmtclass_sycl +cx_stmtclass_va +cx_typeclass_btf +cx_typeclass_l +cx_typeclass_objc +cx_typeclass_r +cx_uett_openmp +decls +declspec +decltype +defs +depobj +descs +diag +diags +disp +dont +dtor +edouble +ehalf +entrypoint +enums +equad +equatable +esingle +exprs +fastcall +fnptr +funcs +gnuxx +imag +impl +impls +inits +inlined +inlining +inout +intptr +ivars +libclang +librarypath +llvm +locs +manglings +memberwise +membuffer +memcpy +memset +mips +nand +noattr +noexcept +nothrow +nrvo +nullptr +nunit +objc +oneway +opencl +parens +parm +pinvoke +pointee +ptrdiff +readwrite +redecl +redeclarable +relro +remappings +rodata +setlasterror +setslastsystemerror +simd +stackalloc +stdcall +stmt +stmts +streamin +streamout +stringify +subminor +subst +suppressgctransition +taskgroup +taskwait +taskyield +thiscall +thunks +trylock +typeid +typename +typestate +uintptr +undeduced +unix +unmarshal +unscoped +usings +usr_objc +uuid +uuidof +uuids +uwtable +varargs +vbase +vbases +vtbl +vtblindex +vtbls +vtor +wcslen +weakref +winapi +wsgct +wsle +xdata +xunit diff --git a/global.json b/global.json index 39280da2..d8833ada 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.100", + "version": "8.0.100-preview", "allowPrerelease": true, "rollForward": "latestFeature" } diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 61197fd6..5558ed50 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -172,8 +172,7 @@ try { $DotNetInstallDirectory = Join-Path -Path $ArtifactsDir -ChildPath "dotnet" Create-Directory -Path $DotNetInstallDirectory - & $DotNetInstallScript -Channel 6.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture - & $DotNetInstallScript -Channel 7.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture + & $DotNetInstallScript -Channel 8.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture $env:PATH="$DotNetInstallDirectory;$env:PATH" } diff --git a/scripts/build.sh b/scripts/build.sh index a7fbb8a7..c435695f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -204,8 +204,7 @@ if [[ ! -z "$architecture" ]]; then DotNetInstallDirectory="$ArtifactsDir/dotnet" CreateDirectory "$DotNetInstallDirectory" - . "$DotNetInstallScript" --channel 6.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture" - . "$DotNetInstallScript" --channel 7.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture" + . "$DotNetInstallScript" --channel 8.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture" PATH="$DotNetInstallDirectory:$PATH:" fi diff --git a/sources/ClangSharp.Interop/ClangSharp.Interop.csproj b/sources/ClangSharp.Interop/ClangSharp.Interop.csproj index 75455540..70d1f97a 100644 --- a/sources/ClangSharp.Interop/ClangSharp.Interop.csproj +++ b/sources/ClangSharp.Interop/ClangSharp.Interop.csproj @@ -2,11 +2,12 @@ - net6.0;net7.0;netstandard2.0 + $(NoWarn);CA1069 + net8.0;netstandard2.0 - + diff --git a/sources/ClangSharp.Interop/Configuration.cs b/sources/ClangSharp.Interop/Configuration.cs new file mode 100644 index 00000000..a7ba5829 --- /dev/null +++ b/sources/ClangSharp.Interop/Configuration.cs @@ -0,0 +1,30 @@ +// 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; + +namespace ClangSharp.Interop; + +internal static class Configuration +{ + private static readonly bool s_disableResolveLibraryHook = GetAppContextData("ClangSharp.Interop.DisableResolveLibraryHook", defaultValue: false); + + public static bool DisableResolveLibraryHook => s_disableResolveLibraryHook; + + private static bool GetAppContextData(string name, bool defaultValue) + { + object? data = AppContext.GetData(name); + + if (data is bool value) + { + return value; + } + else if ((data is string s) && bool.TryParse(s, out bool result)) + { + return result; + } + else + { + return defaultValue; + } + } +} \ No newline at end of file diff --git a/sources/ClangSharp.Interop/Extensions/CXClientData.cs b/sources/ClangSharp.Interop/Extensions/CXClientData.cs index f26edc2d..e044d9cf 100644 --- a/sources/ClangSharp.Interop/Extensions/CXClientData.cs +++ b/sources/ClangSharp.Interop/Extensions/CXClientData.cs @@ -21,9 +21,9 @@ public CXClientData(IntPtr 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 readonly bool Equals(object? obj) => (obj is CXClientData other) && Equals(other); - public bool Equals(CXClientData other) => this == other; + public readonly bool Equals(CXClientData other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXCodeCompleteResults.cs b/sources/ClangSharp.Interop/Extensions/CXCodeCompleteResults.cs index fdeb5de2..33713a49 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCodeCompleteResults.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCodeCompleteResults.cs @@ -60,7 +60,7 @@ public void Dispose() } } - public CXCursorKind GetContaininerKind(out bool isIncomplete) + public CXCursorKind GetContainerKind(out bool isIncomplete) { fixed (CXCodeCompleteResults* pThis = &this) { @@ -97,5 +97,5 @@ public uint GetNumFixIts(uint completionIndex) } } - public void Sort() => clang.sortCodeCompletionResults(Results, NumResults); + public readonly void Sort() => clang.sortCodeCompletionResults(Results, NumResults); } diff --git a/sources/ClangSharp.Interop/Extensions/CXComment.cs b/sources/ClangSharp.Interop/Extensions/CXComment.cs index 12a4e86a..26f03220 100644 --- a/sources/ClangSharp.Interop/Extensions/CXComment.cs +++ b/sources/ClangSharp.Interop/Extensions/CXComment.cs @@ -4,69 +4,69 @@ namespace ClangSharp.Interop; public partial struct CXComment { - public CXString BlockCommandComment_CommandName => clang.BlockCommandComment_getCommandName(this); + public readonly CXString BlockCommandComment_CommandName => clang.BlockCommandComment_getCommandName(this); - public uint BlockCommandComment_NumArgs => clang.BlockCommandComment_getNumArgs(this); + public readonly uint BlockCommandComment_NumArgs => clang.BlockCommandComment_getNumArgs(this); - public CXComment BlockCommandComment_Paragraph => clang.BlockCommandComment_getParagraph(this); + public readonly CXComment BlockCommandComment_Paragraph => clang.BlockCommandComment_getParagraph(this); - public CXString FullComment_AsHtml => clang.FullComment_getAsHTML(this); + public readonly CXString FullComment_AsHtml => clang.FullComment_getAsHTML(this); - public CXString FullComment_AsXml => clang.FullComment_getAsXML(this); + public readonly CXString FullComment_AsXml => clang.FullComment_getAsXML(this); - public uint HtmlStartTag_NumAttrs => clang.HTMLStartTag_getNumAttrs(this); + public readonly uint HtmlStartTag_NumAttrs => clang.HTMLStartTag_getNumAttrs(this); - public bool HtmlStartTagComment_IsSelfClosing => clang.HTMLStartTagComment_isSelfClosing(this) != 0; + public readonly bool HtmlStartTagComment_IsSelfClosing => clang.HTMLStartTagComment_isSelfClosing(this) != 0; - public CXString HtmlTagComment_AsString => clang.HTMLTagComment_getAsString(this); + public readonly CXString HtmlTagComment_AsString => clang.HTMLTagComment_getAsString(this); - public CXString HtmlTagComment_TagName => clang.HTMLTagComment_getTagName(this); + public readonly CXString HtmlTagComment_TagName => clang.HTMLTagComment_getTagName(this); - public CXString InlineCommandComment_CommandName => clang.InlineCommandComment_getCommandName(this); + public readonly CXString InlineCommandComment_CommandName => clang.InlineCommandComment_getCommandName(this); - public uint InlineCommandComment_NumArgs => clang.InlineCommandComment_getNumArgs(this); + public readonly uint InlineCommandComment_NumArgs => clang.InlineCommandComment_getNumArgs(this); - public CXCommentInlineCommandRenderKind InlineCommandComment_RenderKind => clang.InlineCommandComment_getRenderKind(this); + public readonly CXCommentInlineCommandRenderKind InlineCommandComment_RenderKind => clang.InlineCommandComment_getRenderKind(this); - public bool InlineContentComment_HasTrailingNewline => clang.InlineContentComment_hasTrailingNewline(this) != 0; + public readonly bool InlineContentComment_HasTrailingNewline => clang.InlineContentComment_hasTrailingNewline(this) != 0; - public bool IsWhitespace => clang.Comment_isWhitespace(this) != 0; + public readonly bool IsWhitespace => clang.Comment_isWhitespace(this) != 0; - public CXCommentKind Kind => clang.Comment_getKind(this); + public readonly CXCommentKind Kind => clang.Comment_getKind(this); - public uint NumChildren => clang.Comment_getNumChildren(this); + public readonly uint NumChildren => clang.Comment_getNumChildren(this); - public CXCommentParamPassDirection ParamCommandComment_Direction => clang.ParamCommandComment_getDirection(this); + public readonly CXCommentParamPassDirection ParamCommandComment_Direction => clang.ParamCommandComment_getDirection(this); - public bool ParamCommandComment_IsDirectionExplicit => clang.ParamCommandComment_isDirectionExplicit(this) != 0; + public readonly bool ParamCommandComment_IsDirectionExplicit => clang.ParamCommandComment_isDirectionExplicit(this) != 0; - public bool ParamCommandComment_IsParamIndexValid => clang.ParamCommandComment_isParamIndexValid(this) != 0; + public readonly bool ParamCommandComment_IsParamIndexValid => clang.ParamCommandComment_isParamIndexValid(this) != 0; - public uint ParamCommandComment_ParamIndex => clang.ParamCommandComment_getParamIndex(this); + public readonly uint ParamCommandComment_ParamIndex => clang.ParamCommandComment_getParamIndex(this); - public CXString ParamCommandComment_ParamName => clang.ParamCommandComment_getParamName(this); + public readonly CXString ParamCommandComment_ParamName => clang.ParamCommandComment_getParamName(this); - public CXString TextComment_Text => clang.TextComment_getText(this); + public readonly CXString TextComment_Text => clang.TextComment_getText(this); - public uint TParamCommandComment_Depth => clang.TParamCommandComment_getDepth(this); + public readonly uint TParamCommandComment_Depth => clang.TParamCommandComment_getDepth(this); - public CXString TParamCommandComment_ParamName => clang.TParamCommandComment_getParamName(this); + public readonly CXString TParamCommandComment_ParamName => clang.TParamCommandComment_getParamName(this); - public bool TParamCommandComment_IsParamPositionValid => clang.TParamCommandComment_isParamPositionValid(this) != 0; + public readonly bool TParamCommandComment_IsParamPositionValid => clang.TParamCommandComment_isParamPositionValid(this) != 0; - public CXString VerbatimBlockLineComment_Text => clang.VerbatimBlockLineComment_getText(this); + public readonly CXString VerbatimBlockLineComment_Text => clang.VerbatimBlockLineComment_getText(this); - public CXString VerbatimLineComment_Text => clang.VerbatimLineComment_getText(this); + public readonly CXString VerbatimLineComment_Text => clang.VerbatimLineComment_getText(this); - public CXString BlockCommandComment_GetArgText(uint index) => clang.BlockCommandComment_getArgText(this, index); + public readonly CXString BlockCommandComment_GetArgText(uint index) => clang.BlockCommandComment_getArgText(this, index); - public CXComment GetChild(uint index) => clang.Comment_getChild(this, index); + public readonly CXComment GetChild(uint index) => clang.Comment_getChild(this, index); - public CXString HtmlStartTag_GetAttrName(uint index) => clang.HTMLStartTag_getAttrName(this, index); + public readonly CXString HtmlStartTag_GetAttrName(uint index) => clang.HTMLStartTag_getAttrName(this, index); - public CXString HtmlStartTag_GetAttrValue(uint index) => clang.HTMLStartTag_getAttrValue(this, index); + public readonly CXString HtmlStartTag_GetAttrValue(uint index) => clang.HTMLStartTag_getAttrValue(this, index); - public CXString InlineCommandComment_GetArgText(uint index) => clang.InlineCommandComment_getArgText(this, index); + public readonly CXString InlineCommandComment_GetArgText(uint index) => clang.InlineCommandComment_getArgText(this, index); - public uint TParamCommandComment_GetIndex(uint depth) => clang.TParamCommandComment_getIndex(this, depth); + public readonly 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 f8f34eac..58cd8f36 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompilationDatabase.cs @@ -11,7 +11,7 @@ public CXCompilationDatabase(IntPtr handle) Handle = handle; } - public CXCompileCommands AllCompileCommands => (CXCompileCommands)clang.CompilationDatabase_getAllCompileCommands(this); + public readonly CXCompileCommands AllCompileCommands => (CXCompileCommands)clang.CompilationDatabase_getAllCompileCommands(this); public IntPtr Handle { get; set; } @@ -42,15 +42,15 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXCompilationDatabase other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXCompilationDatabase other) && Equals(other); - public bool Equals(CXCompilationDatabase other) => this == other; + public readonly bool Equals(CXCompilationDatabase other) => this == other; - public CXCompileCommands GetCompileCommands(string completeFileName) + public readonly CXCompileCommands GetCompileCommands(string completeFileName) { using var marshaledCompleteFileName = new MarshaledString(completeFileName); return (CXCompileCommands)clang.CompilationDatabase_getCompileCommands(this, marshaledCompleteFileName); } - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs b/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs index 7b0d1601..f09932a0 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompileCommand.cs @@ -11,15 +11,15 @@ public CXCompileCommand(IntPtr handle) Handle = handle; } - public CXString Directory => clang.CompileCommand_getDirectory(this); + public readonly CXString Directory => clang.CompileCommand_getDirectory(this); - public CXString Filename => clang.CompileCommand_getFilename(this); + public readonly CXString Filename => clang.CompileCommand_getFilename(this); public IntPtr Handle { get; set; } - public uint NumArgs => clang.CompileCommand_getNumArgs(this); + public readonly uint NumArgs => clang.CompileCommand_getNumArgs(this); - public uint NumMappedSources => clang.CompileCommand_getNumMappedSources(this); + public readonly uint NumMappedSources => clang.CompileCommand_getNumMappedSources(this); public static explicit operator CXCompileCommand(void* value) => new CXCompileCommand((IntPtr)value); @@ -29,15 +29,15 @@ public CXCompileCommand(IntPtr 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 readonly bool Equals(object? obj) => (obj is CXCompileCommand other) && Equals(other); - public bool Equals(CXCompileCommand other) => this == other; + public readonly bool Equals(CXCompileCommand other) => this == other; - public CXString GetArg(uint index) => clang.CompileCommand_getArg(this, index); + public readonly CXString GetArg(uint index) => clang.CompileCommand_getArg(this, index); - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public CXString GetMappedSourceContent(uint index) => clang.CompileCommand_getMappedSourceContent(this, index); + public readonly CXString GetMappedSourceContent(uint index) => clang.CompileCommand_getMappedSourceContent(this, index); - public CXString GetMappedSourcePath(uint index) => clang.CompileCommand_getMappedSourcePath(this, index); + public readonly 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 7c79b242..14b1dbd7 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompileCommands.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompileCommands.cs @@ -13,13 +13,13 @@ public CXCompileCommands(IntPtr handle) Handle = handle; } - public CXCompileCommand this[uint index] => GetCommand(index); + public readonly CXCompileCommand this[uint index] => GetCommand(index); - public int Count => (int)Size; + public readonly int Count => (int)Size; public IntPtr Handle { get; set; } - public uint Size => clang.CompileCommands_getSize(this); + public readonly uint Size => clang.CompileCommands_getSize(this); public static explicit operator CXCompileCommands(void* value) => new CXCompileCommands((IntPtr)value); @@ -38,13 +38,13 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXCompileCommands other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXCompileCommands other) && Equals(other); - public bool Equals(CXCompileCommands other) => this == other; + public readonly bool Equals(CXCompileCommands other) => this == other; - public CXCompileCommand GetCommand(uint index) => (CXCompileCommand)clang.CompileCommands_getCommand(this, index); + public readonly CXCompileCommand GetCommand(uint index) => (CXCompileCommand)clang.CompileCommands_getCommand(this, index); - public IEnumerator GetEnumerator() + public readonly IEnumerator GetEnumerator() { var count = Size; @@ -54,7 +54,7 @@ public IEnumerator GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs b/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs index 39aef731..908b96b8 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCompletionString.cs @@ -11,17 +11,17 @@ public CXCompletionString(IntPtr handle) Handle = handle; } - public CXAvailabilityKind Availability => clang.getCompletionAvailability(this); + public readonly CXAvailabilityKind Availability => clang.getCompletionAvailability(this); - public CXString BriefComment => clang.getCompletionBriefComment(this); + public readonly CXString BriefComment => clang.getCompletionBriefComment(this); public IntPtr Handle { get; set; } - public uint NumAnnotations => clang.getCompletionNumAnnotations(this); + public readonly uint NumAnnotations => clang.getCompletionNumAnnotations(this); - public uint NumChunks => clang.getNumCompletionChunks(this); + public readonly uint NumChunks => clang.getNumCompletionChunks(this); - public uint Priority => clang.getCompletionPriority(this); + public readonly uint Priority => clang.getCompletionPriority(this); public static explicit operator CXCompletionString(void* value) => new CXCompletionString((IntPtr)value); @@ -31,21 +31,21 @@ public CXCompletionString(IntPtr 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 readonly bool Equals(object? obj) => (obj is CXCompletionString other) && Equals(other); - public bool Equals(CXCompletionString other) => this == other; + public readonly bool Equals(CXCompletionString other) => this == other; - public CXString GetAnnotation(uint index) => clang.getCompletionAnnotation(this, index); + public readonly CXString GetAnnotation(uint index) => clang.getCompletionAnnotation(this, index); - public CXCompletionString GetChunkCompletionString(uint index) => (CXCompletionString)clang.getCompletionChunkCompletionString(this, index); + public readonly CXCompletionString GetChunkCompletionString(uint index) => (CXCompletionString)clang.getCompletionChunkCompletionString(this, index); - public CXCompletionChunkKind GetChunkKind(uint index) => clang.getCompletionChunkKind(this, index); + public readonly CXCompletionChunkKind GetChunkKind(uint index) => clang.getCompletionChunkKind(this, index); - public CXString GetChunkText(uint index) => clang.getCompletionChunkText(this, index); + public readonly CXString GetChunkText(uint index) => clang.getCompletionChunkText(this, index); - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public CXString GetParent(out CXCursorKind kind) + public readonly CXString GetParent(out CXCursorKind kind) { fixed (CXCursorKind* pKind = &kind) { diff --git a/sources/ClangSharp.Interop/Extensions/CXCursor.cs b/sources/ClangSharp.Interop/Extensions/CXCursor.cs index 35bf41b8..8febdfcc 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCursor.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCursor.cs @@ -17,17 +17,17 @@ public unsafe partial struct CXCursor : IEquatable { public static CXCursor Null => clang.getNullCursor(); - public CXType ArgumentType => clangsharp.Cursor_getArgumentType(this); + public readonly CXType ArgumentType => clangsharp.Cursor_getArgumentType(this); - public long ArraySize => clangsharp.Cursor_getArraySize(this); + public readonly long ArraySize => clangsharp.Cursor_getArraySize(this); - public CXCursor AsFunction => clangsharp.Cursor_getAsFunction(this); + public readonly CXCursor AsFunction => clangsharp.Cursor_getAsFunction(this); - public CX_AtomicOperatorKind AtomicOperatorKind => clangsharp.Cursor_getAtomicOpcode(this); + public readonly CX_AtomicOperatorKind AtomicOperatorKind => clangsharp.Cursor_getAtomicOpcode(this); - public CX_AttrKind AttrKind => clangsharp.Cursor_getAttrKind(this); + public readonly CX_AttrKind AttrKind => clangsharp.Cursor_getAttrKind(this); - public string AttrKindSpelling + public readonly string AttrKindSpelling { get { @@ -432,45 +432,45 @@ public string AttrKindSpelling } } - public CXAvailabilityKind Availability => clang.getCursorAvailability(this); + public readonly CXAvailabilityKind Availability => clang.getCursorAvailability(this); - public CX_BinaryOperatorKind BinaryOperatorKind => clangsharp.Cursor_getBinaryOpcode(this); + public readonly CX_BinaryOperatorKind BinaryOperatorKind => clangsharp.Cursor_getBinaryOpcode(this); - public CXString BinaryOperatorKindSpelling => clangsharp.Cursor_getBinaryOpcodeSpelling(BinaryOperatorKind); + public readonly CXString BinaryOperatorKindSpelling => clangsharp.Cursor_getBinaryOpcodeSpelling(BinaryOperatorKind); - public CXCursor BindingExpr => clangsharp.Cursor_getBindingExpr(this); + public readonly CXCursor BindingExpr => clangsharp.Cursor_getBindingExpr(this); - public CXCursor BitWidth => clangsharp.Cursor_getBitWidth(this); + public readonly CXCursor BitWidth => clangsharp.Cursor_getBitWidth(this); - public CXCursor BlockManglingContextDecl => clangsharp.Cursor_getBlockManglingContextDecl(this); + public readonly CXCursor BlockManglingContextDecl => clangsharp.Cursor_getBlockManglingContextDecl(this); - public int BlockManglingNumber => clangsharp.Cursor_getBlockManglingNumber(this); + public readonly int BlockManglingNumber => clangsharp.Cursor_getBlockManglingNumber(this); - public bool BlockMissingReturnType => clangsharp.Cursor_getBlockMissingReturnType(this) != 0; + public readonly bool BlockMissingReturnType => clangsharp.Cursor_getBlockMissingReturnType(this) != 0; - public CXCursor Body => clangsharp.Cursor_getBody(this); + public readonly CXCursor Body => clangsharp.Cursor_getBody(this); - public CXString BriefCommentText => clang.Cursor_getBriefCommentText(this); + public readonly CXString BriefCommentText => clang.Cursor_getBriefCommentText(this); - public CXType CallResultType => clangsharp.Cursor_getCallResultType(this); + public readonly CXType CallResultType => clangsharp.Cursor_getCallResultType(this); - public bool CanAvoidCopyToHeap => clangsharp.Cursor_getCanAvoidCopyToHeap(this) != 0; + public readonly bool CanAvoidCopyToHeap => clangsharp.Cursor_getCanAvoidCopyToHeap(this) != 0; - public CXCursor CanonicalCursor => clangsharp.Cursor_getCanonical(this); + public readonly CXCursor CanonicalCursor => clangsharp.Cursor_getCanonical(this); - public CXCursor CapturedDecl => clangsharp.Cursor_getCapturedDecl(this); + public readonly CXCursor CapturedDecl => clangsharp.Cursor_getCapturedDecl(this); - public CXCursor CapturedRecordDecl => clangsharp.Cursor_getCapturedRecordDecl(this); + public readonly CXCursor CapturedRecordDecl => clangsharp.Cursor_getCapturedRecordDecl(this); - public CX_CapturedRegionKind CapturedRegionKind => clangsharp.Cursor_getCapturedRegionKind(this); + public readonly CX_CapturedRegionKind CapturedRegionKind => clangsharp.Cursor_getCapturedRegionKind(this); - public CXCursor CapturedStmt => clangsharp.Cursor_getCapturedStmt(this); + public readonly CXCursor CapturedStmt => clangsharp.Cursor_getCapturedStmt(this); - public bool CapturesCXXThis => clangsharp.Cursor_getCapturesCXXThis(this) != 0; + public readonly bool CapturesCXXThis => clangsharp.Cursor_getCapturesCXXThis(this) != 0; - public CX_CastKind CastKind => clangsharp.Cursor_getCastKind(this); + public readonly CX_CastKind CastKind => clangsharp.Cursor_getCastKind(this); - public string CastKindSpelling + public readonly string CastKindSpelling { get { @@ -546,69 +546,69 @@ public string CastKindSpelling } } - public CX_CharacterKind CharacterLiteralKind => clangsharp.Cursor_getCharacterLiteralKind(this); + public readonly CX_CharacterKind CharacterLiteralKind => clangsharp.Cursor_getCharacterLiteralKind(this); - public uint CharacterLiteralValue => clangsharp.Cursor_getCharacterLiteralValue(this); + public readonly uint CharacterLiteralValue => clangsharp.Cursor_getCharacterLiteralValue(this); - public CXSourceRange CommentRange => clang.Cursor_getCommentRange(this); + public readonly CXSourceRange CommentRange => clang.Cursor_getCommentRange(this); - public CXCompletionString CompletionString => (CXCompletionString)clang.getCursorCompletionString(this); + public readonly CXCompletionString CompletionString => (CXCompletionString)clang.getCursorCompletionString(this); - public CXType ComputationLhsType => clangsharp.Cursor_getComputationLhsType(this); + public readonly CXType ComputationLhsType => clangsharp.Cursor_getComputationLhsType(this); - public CXType ComputationResultType => clangsharp.Cursor_getComputationResultType(this); + public readonly CXType ComputationResultType => clangsharp.Cursor_getComputationResultType(this); - public CXCursor ConstraintExpr => clangsharp.Cursor_getConstraintExpr(this); + public readonly CXCursor ConstraintExpr => clangsharp.Cursor_getConstraintExpr(this); - public CXCursor ConstructedBaseClass => clangsharp.Cursor_getConstructedBaseClass(this); + public readonly CXCursor ConstructedBaseClass => clangsharp.Cursor_getConstructedBaseClass(this); - public CXCursor ConstructedBaseClassShadowDecl => clangsharp.Cursor_getConstructedBaseClassShadowDecl(this); + public readonly CXCursor ConstructedBaseClassShadowDecl => clangsharp.Cursor_getConstructedBaseClassShadowDecl(this); - public CX_ConstructionKind ConstructionKind => clangsharp.Cursor_getConstructionKind(this); + public readonly CX_ConstructionKind ConstructionKind => clangsharp.Cursor_getConstructionKind(this); - public bool ConstructsVirtualBase => clangsharp.Cursor_getConstructsVirtualBase(this) != 0; + public readonly bool ConstructsVirtualBase => clangsharp.Cursor_getConstructsVirtualBase(this) != 0; - public CXCursor ContextParam => clangsharp.Cursor_getContextParam(this); + public readonly CXCursor ContextParam => clangsharp.Cursor_getContextParam(this); - public int ContextParamPosition => clangsharp.Cursor_getContextParamPosition(this); + public readonly int ContextParamPosition => clangsharp.Cursor_getContextParamPosition(this); - public CX_CXXAccessSpecifier CXXAccessSpecifier => clang.getCXXAccessSpecifier(this); + public readonly CX_CXXAccessSpecifier CXXAccessSpecifier => clang.getCXXAccessSpecifier(this); - public bool BoolLiteralValue => clangsharp.Cursor_getBoolLiteralValue(this) != 0; + public readonly bool BoolLiteralValue => clangsharp.Cursor_getBoolLiteralValue(this) != 0; - public bool CXXConstructor_IsConvertingConstructor => clang.CXXConstructor_isConvertingConstructor(this) != 0; + public readonly bool CXXConstructor_IsConvertingConstructor => clang.CXXConstructor_isConvertingConstructor(this) != 0; - public bool CXXConstructor_IsCopyConstructor => clang.CXXConstructor_isCopyConstructor(this) != 0; + public readonly bool CXXConstructor_IsCopyConstructor => clang.CXXConstructor_isCopyConstructor(this) != 0; - public bool CXXConstructor_IsDefaultConstructor => clang.CXXConstructor_isDefaultConstructor(this) != 0; + public readonly bool CXXConstructor_IsDefaultConstructor => clang.CXXConstructor_isDefaultConstructor(this) != 0; - public bool CXXConstructor_IsMoveConstructor => clang.CXXConstructor_isMoveConstructor(this) != 0; + public readonly bool CXXConstructor_IsMoveConstructor => clang.CXXConstructor_isMoveConstructor(this) != 0; - public bool CXXField_IsMutable => clang.CXXField_isMutable(this) != 0; + public readonly bool CXXField_IsMutable => clang.CXXField_isMutable(this) != 0; - public CXStringSet* CXXManglings => clang.Cursor_getCXXManglings(this); + public readonly CXStringSet* CXXManglings => clang.Cursor_getCXXManglings(this); - public bool CXXMethod_IsConst => clang.CXXMethod_isConst(this) != 0; + public readonly bool CXXMethod_IsConst => clang.CXXMethod_isConst(this) != 0; - public bool CXXMethod_IsCopyAssignmentOperator => clang.CXXMethod_isCopyAssignmentOperator(this) != 0; + public readonly bool CXXMethod_IsCopyAssignmentOperator => clang.CXXMethod_isCopyAssignmentOperator(this) != 0; - public bool CXXMethod_IsDefaulted => clang.CXXMethod_isDefaulted(this) != 0; + public readonly bool CXXMethod_IsDefaulted => clang.CXXMethod_isDefaulted(this) != 0; - public bool CXXMethod_IsMoveAssignmentOperator => clang.CXXMethod_isMoveAssignmentOperator(this) != 0; + public readonly bool CXXMethod_IsMoveAssignmentOperator => clang.CXXMethod_isMoveAssignmentOperator(this) != 0; - public bool CXXMethod_IsPureVirtual => clang.CXXMethod_isPureVirtual(this) != 0; + public readonly bool CXXMethod_IsPureVirtual => clang.CXXMethod_isPureVirtual(this) != 0; - public bool CXXMethod_IsStatic => clang.CXXMethod_isStatic(this) != 0; + public readonly bool CXXMethod_IsStatic => clang.CXXMethod_isStatic(this) != 0; - public bool CXXMethod_IsVirtual => clang.CXXMethod_isVirtual(this) != 0; + public readonly bool CXXMethod_IsVirtual => clang.CXXMethod_isVirtual(this) != 0; - public bool CXXRecord_IsAbstract => clang.CXXRecord_isAbstract(this) != 0; + public readonly bool CXXRecord_IsAbstract => clang.CXXRecord_isAbstract(this) != 0; - public CXType DeclaredReturnType => clangsharp.Cursor_getDeclaredReturnType(this); + public readonly CXType DeclaredReturnType => clangsharp.Cursor_getDeclaredReturnType(this); - public CX_DeclKind DeclKind => clangsharp.Cursor_getDeclKind(this); + public readonly CX_DeclKind DeclKind => clangsharp.Cursor_getDeclKind(this); - public string DeclKindSpelling + public readonly string DeclKindSpelling { get { @@ -769,409 +769,409 @@ public string DeclKindSpelling } } - public CXString DeclObjCTypeEncoding => clang.getDeclObjCTypeEncoding(this); + public readonly CXString DeclObjCTypeEncoding => clang.getDeclObjCTypeEncoding(this); - public CXCursor DecomposedDecl => clangsharp.Cursor_getDecomposedDecl(this); + public readonly CXCursor DecomposedDecl => clangsharp.Cursor_getDecomposedDecl(this); - public CXCursor DefaultArg => clangsharp.Cursor_getDefaultArg(this); + public readonly CXCursor DefaultArg => clangsharp.Cursor_getDefaultArg(this); - public CXType DefaultArgType => clangsharp.Cursor_getDefaultArgType(this); + public readonly CXType DefaultArgType => clangsharp.Cursor_getDefaultArgType(this); - public CXCursor Definition => clangsharp.Cursor_getDefinition(this); + public readonly CXCursor Definition => clangsharp.Cursor_getDefinition(this); - public CXCursor DependentLambdaCallOperator => clangsharp.Cursor_getDependentLambdaCallOperator(this); + public readonly CXCursor DependentLambdaCallOperator => clangsharp.Cursor_getDependentLambdaCallOperator(this); - public CXCursor DescribedCursorTemplate => clangsharp.Cursor_getDescribedCursorTemplate(this); + public readonly CXCursor DescribedCursorTemplate => clangsharp.Cursor_getDescribedCursorTemplate(this); - public CXCursor DescribedTemplate => clangsharp.Cursor_getDescribedTemplate(this); + public readonly CXCursor DescribedTemplate => clangsharp.Cursor_getDescribedTemplate(this); - public CXCursor Destructor => clangsharp.Cursor_getDestructor(this); + public readonly CXCursor Destructor => clangsharp.Cursor_getDestructor(this); - public CXString DisplayName => clang.getCursorDisplayName(this); + public readonly CXString DisplayName => clang.getCursorDisplayName(this); - public bool DoesNotEscape => clangsharp.Cursor_getDoesNotEscape(this) != 0; + public readonly bool DoesNotEscape => clangsharp.Cursor_getDoesNotEscape(this) != 0; - public bool DoesUsualArrayDeleteWantSize => clangsharp.Cursor_getDoesUsualArrayDeleteWantSize(this) != 0; + public readonly bool DoesUsualArrayDeleteWantSize => clangsharp.Cursor_getDoesUsualArrayDeleteWantSize(this) != 0; - public ulong EnumConstantDeclUnsignedValue => clang.getEnumConstantDeclUnsignedValue(this); + public readonly ulong EnumConstantDeclUnsignedValue => clang.getEnumConstantDeclUnsignedValue(this); - public long EnumConstantDeclValue => clang.getEnumConstantDeclValue(this); + public readonly long EnumConstantDeclValue => clang.getEnumConstantDeclValue(this); - public CXType EnumDecl_IntegerType => clang.getEnumDeclIntegerType(this); + public readonly CXType EnumDecl_IntegerType => clang.getEnumDeclIntegerType(this); - public bool EnumDecl_IsScoped => clang.EnumDecl_isScoped(this) != 0; + public readonly bool EnumDecl_IsScoped => clang.EnumDecl_isScoped(this) != 0; - public CXType EnumDecl_PromotionType => clangsharp.Cursor_getEnumDeclPromotionType(this); + public readonly CXType EnumDecl_PromotionType => clangsharp.Cursor_getEnumDeclPromotionType(this); - public CXEvalResult Evaluate => (CXEvalResult)clang.Cursor_Evaluate(this); + public readonly CXEvalResult Evaluate => (CXEvalResult)clang.Cursor_Evaluate(this); - public int ExceptionSpecificationType => clang.getCursorExceptionSpecificationType(this); + public readonly int ExceptionSpecificationType => clang.getCursorExceptionSpecificationType(this); - public CX_ExprDependence ExprDependence => clangsharp.Cursor_getExprDependence(this); + public readonly CX_ExprDependence ExprDependence => clangsharp.Cursor_getExprDependence(this); - public CXSourceRange Extent => clang.getCursorExtent(this); + public readonly CXSourceRange Extent => clang.getCursorExtent(this); - public CX_FloatingSemantics FloatingLiteralSemantics => clangsharp.Cursor_getFloatingLiteralSemantics(this); + public readonly CX_FloatingSemantics FloatingLiteralSemantics => clangsharp.Cursor_getFloatingLiteralSemantics(this); - public double FloatingLiteralValueAsApproximateDouble => clangsharp.Cursor_getFloatingLiteralValueAsApproximateDouble(this); + public readonly double FloatingLiteralValueAsApproximateDouble => clangsharp.Cursor_getFloatingLiteralValueAsApproximateDouble(this); - public int FieldDeclBitWidth => clang.getFieldDeclBitWidth(this); + public readonly int FieldDeclBitWidth => clang.getFieldDeclBitWidth(this); - public int FieldIndex => clangsharp.Cursor_getFieldIndex(this); + public readonly int FieldIndex => clangsharp.Cursor_getFieldIndex(this); - public CXCursor FoundDecl => clangsharp.Cursor_getFoundDecl(this); + public readonly CXCursor FoundDecl => clangsharp.Cursor_getFoundDecl(this); - public CXCursor FriendDecl => clangsharp.Cursor_getFriendDecl(this); + public readonly CXCursor FriendDecl => clangsharp.Cursor_getFriendDecl(this); - public int FunctionScopeDepth => clangsharp.Cursor_getFunctionScopeDepth(this); + public readonly int FunctionScopeDepth => clangsharp.Cursor_getFunctionScopeDepth(this); - public int FunctionScopeIndex => clangsharp.Cursor_getFunctionScopeIndex(this); + public readonly int FunctionScopeIndex => clangsharp.Cursor_getFunctionScopeIndex(this); - public Guid GuidValue => clangsharp.Cursor_getGuidValue(this); + public readonly Guid GuidValue => clangsharp.Cursor_getGuidValue(this); - public bool HadMultipleCandidates => clangsharp.Cursor_getHadMultipleCandidates(this) != 0; + public readonly bool HadMultipleCandidates => clangsharp.Cursor_getHadMultipleCandidates(this) != 0; - public bool HasAttrs => clang.Cursor_hasAttrs(this) != 0; + public readonly bool HasAttrs => clang.Cursor_hasAttrs(this) != 0; - public bool HasBody => clangsharp.Cursor_getHasBody(this) != 0; + public readonly bool HasBody => clangsharp.Cursor_getHasBody(this) != 0; - public bool HasDefaultArg => clangsharp.Cursor_getHasDefaultArg(this) != 0; + public readonly bool HasDefaultArg => clangsharp.Cursor_getHasDefaultArg(this) != 0; - public bool HasElseStorage => clangsharp.Cursor_getHasElseStorage(this) != 0; + public readonly bool HasElseStorage => clangsharp.Cursor_getHasElseStorage(this) != 0; - public bool HasExplicitTemplateArgs => clangsharp.Cursor_getHasExplicitTemplateArgs(this) != 0; + public readonly bool HasExplicitTemplateArgs => clangsharp.Cursor_getHasExplicitTemplateArgs(this) != 0; - public bool HasImplicitReturnZero => clangsharp.Cursor_getHasImplicitReturnZero(this) != 0; + public readonly bool HasImplicitReturnZero => clangsharp.Cursor_getHasImplicitReturnZero(this) != 0; - public bool HasInheritedDefaultArg => clangsharp.Cursor_getHasInheritedDefaultArg(this) != 0; + public readonly bool HasInheritedDefaultArg => clangsharp.Cursor_getHasInheritedDefaultArg(this) != 0; - public bool HasInit => clangsharp.Cursor_getHasInit(this) != 0; + public readonly bool HasInit => clangsharp.Cursor_getHasInit(this) != 0; - public bool HasInitStorage => clangsharp.Cursor_getHasInitStorage(this) != 0; + public readonly bool HasInitStorage => clangsharp.Cursor_getHasInitStorage(this) != 0; - public bool HasLeadingEmptyMacro => clangsharp.Cursor_getHasLeadingEmptyMacro(this) != 0; + public readonly bool HasLeadingEmptyMacro => clangsharp.Cursor_getHasLeadingEmptyMacro(this) != 0; - public bool HasLocalStorage => clangsharp.Cursor_getHasLocalStorage(this) != 0; + public readonly bool HasLocalStorage => clangsharp.Cursor_getHasLocalStorage(this) != 0; - public bool HasPlaceholderTypeConstraint => clangsharp.Cursor_getHasPlaceholderTypeConstraint(this) != 0; + public readonly bool HasPlaceholderTypeConstraint => clangsharp.Cursor_getHasPlaceholderTypeConstraint(this) != 0; - public uint Hash => clang.hashCursor(this); + public readonly uint Hash => clang.hashCursor(this); - public bool HasTemplateKeyword => clangsharp.Cursor_getHasTemplateKeyword(this) != 0; + public readonly bool HasTemplateKeyword => clangsharp.Cursor_getHasTemplateKeyword(this) != 0; - public bool HasUserDeclaredConstructor => clangsharp.Cursor_getHasUserDeclaredConstructor(this) != 0; + public readonly bool HasUserDeclaredConstructor => clangsharp.Cursor_getHasUserDeclaredConstructor(this) != 0; - public bool HasUserDeclaredCopyAssignment => clangsharp.Cursor_getHasUserDeclaredCopyAssignment(this) != 0; + public readonly bool HasUserDeclaredCopyAssignment => clangsharp.Cursor_getHasUserDeclaredCopyAssignment(this) != 0; - public bool HasUserDeclaredCopyConstructor => clangsharp.Cursor_getHasUserDeclaredCopyConstructor(this) != 0; + public readonly bool HasUserDeclaredCopyConstructor => clangsharp.Cursor_getHasUserDeclaredCopyConstructor(this) != 0; - public bool HasUserDeclaredDestructor => clangsharp.Cursor_getHasUserDeclaredDestructor(this) != 0; + public readonly bool HasUserDeclaredDestructor => clangsharp.Cursor_getHasUserDeclaredDestructor(this) != 0; - public bool HasUserDeclaredMoveAssignment => clangsharp.Cursor_getHasUserDeclaredMoveAssignment(this) != 0; + public readonly bool HasUserDeclaredMoveAssignment => clangsharp.Cursor_getHasUserDeclaredMoveAssignment(this) != 0; - public bool HasUserDeclaredMoveConstructor => clangsharp.Cursor_getHasUserDeclaredMoveConstructor(this) != 0; + public readonly bool HasUserDeclaredMoveConstructor => clangsharp.Cursor_getHasUserDeclaredMoveConstructor(this) != 0; - public bool HasUserDeclaredMoveOperation => clangsharp.Cursor_getHasUserDeclaredMoveOperation(this) != 0; + public readonly bool HasUserDeclaredMoveOperation => clangsharp.Cursor_getHasUserDeclaredMoveOperation(this) != 0; - public bool HasVarDeclExternalStorage => clang.Cursor_hasVarDeclExternalStorage(this) != 0; + public readonly bool HasVarDeclExternalStorage => clang.Cursor_hasVarDeclExternalStorage(this) != 0; - public bool HasVarDeclGlobalStorage => clang.Cursor_hasVarDeclGlobalStorage(this) != 0; + public readonly bool HasVarDeclGlobalStorage => clang.Cursor_hasVarDeclGlobalStorage(this) != 0; - public bool HasVarStorage => clangsharp.Cursor_getHasVarStorage(this) != 0; + public readonly bool HasVarStorage => clangsharp.Cursor_getHasVarStorage(this) != 0; - public CXType IBOutletCollectionType => clang.getIBOutletCollectionType(this); + public readonly CXType IBOutletCollectionType => clang.getIBOutletCollectionType(this); - public CXFile IncludedFile => (CXFile)clang.getIncludedFile(this); + public readonly CXFile IncludedFile => (CXFile)clang.getIncludedFile(this); - public CXCursor InClassInitializer => clangsharp.Cursor_getInClassInitializer(this); + public readonly CXCursor InClassInitializer => clangsharp.Cursor_getInClassInitializer(this); - public CXCursor InheritedConstructor => clangsharp.Cursor_getInheritedConstructor(this); + public readonly CXCursor InheritedConstructor => clangsharp.Cursor_getInheritedConstructor(this); - public bool InheritedFromVBase => clangsharp.Cursor_getInheritedFromVBase(this) != 0; + public readonly bool InheritedFromVBase => clangsharp.Cursor_getInheritedFromVBase(this) != 0; - public CXCursor InitExpr => clangsharp.Cursor_getInitExpr(this); + public readonly CXCursor InitExpr => clangsharp.Cursor_getInitExpr(this); - public CXType InjectedSpecializationType => clangsharp.Cursor_getInjectedSpecializationType(this); + public readonly CXType InjectedSpecializationType => clangsharp.Cursor_getInjectedSpecializationType(this); - public CXCursor InstantiatedFromMember => clangsharp.Cursor_getInstantiatedFromMember(this); + public readonly CXCursor InstantiatedFromMember => clangsharp.Cursor_getInstantiatedFromMember(this); - public long IntegerLiteralValue => clangsharp.Cursor_getIntegerLiteralValue(this); + public readonly long IntegerLiteralValue => clangsharp.Cursor_getIntegerLiteralValue(this); - public bool IsAllEnumCasesCovered => clangsharp.Cursor_getIsAllEnumCasesCovered(this) != 0; + public readonly bool IsAllEnumCasesCovered => clangsharp.Cursor_getIsAllEnumCasesCovered(this) != 0; - public bool IsAlwaysNull => clangsharp.Cursor_getIsAlwaysNull(this) != 0; + public readonly bool IsAlwaysNull => clangsharp.Cursor_getIsAlwaysNull(this) != 0; - public bool IsAnonymous => clang.Cursor_isAnonymous(this) != 0; + public readonly bool IsAnonymous => clang.Cursor_isAnonymous(this) != 0; - public bool IsAnonymousRecordDecl => clang.Cursor_isAnonymousRecordDecl(this) != 0; + public readonly bool IsAnonymousRecordDecl => clang.Cursor_isAnonymousRecordDecl(this) != 0; - public bool IsAnonymousStructOrUnion => clangsharp.Cursor_getIsAnonymousStructOrUnion(this) != 0; + public readonly bool IsAnonymousStructOrUnion => clangsharp.Cursor_getIsAnonymousStructOrUnion(this) != 0; - public bool IsArgumentType => clangsharp.Cursor_getIsArgumentType(this) != 0; + public readonly bool IsArgumentType => clangsharp.Cursor_getIsArgumentType(this) != 0; - public bool IsArrayForm => clangsharp.Cursor_getIsArrayForm(this) != 0; + public readonly bool IsArrayForm => clangsharp.Cursor_getIsArrayForm(this) != 0; - public bool IsArrayFormAsWritten => clangsharp.Cursor_getIsArrayFormAsWritten(this) != 0; + public readonly bool IsArrayFormAsWritten => clangsharp.Cursor_getIsArrayFormAsWritten(this) != 0; - public bool IsArrow => clangsharp.Cursor_getIsArrow(this) != 0; + public readonly bool IsArrow => clangsharp.Cursor_getIsArrow(this) != 0; - public bool IsAttribute => clang.isAttribute(Kind) != 0; + public readonly bool IsAttribute => clang.isAttribute(Kind) != 0; - public bool IsBitField => clang.Cursor_isBitField(this) != 0; + public readonly bool IsBitField => clang.Cursor_isBitField(this) != 0; - public bool IsCanonical => Equals(CanonicalCursor); + public readonly bool IsCanonical => Equals(CanonicalCursor); - public bool IsCBuffer => clangsharp.Cursor_getIsCBuffer(this) != 0; + public readonly bool IsCBuffer => clangsharp.Cursor_getIsCBuffer(this) != 0; - public bool IsClassExtension => clangsharp.Cursor_getIsClassExtension(this) != 0; + public readonly bool IsClassExtension => clangsharp.Cursor_getIsClassExtension(this) != 0; - public bool IsCompleteDefinition => clangsharp.Cursor_getIsCompleteDefinition(this) != 0; + public readonly bool IsCompleteDefinition => clangsharp.Cursor_getIsCompleteDefinition(this) != 0; - public bool IsConditionTrue => clangsharp.Cursor_getIsConditionTrue(this) != 0; + public readonly bool IsConditionTrue => clangsharp.Cursor_getIsConditionTrue(this) != 0; - public bool IsConstexpr => clangsharp.Cursor_getIsConstexpr(this) != 0; + public readonly bool IsConstexpr => clangsharp.Cursor_getIsConstexpr(this) != 0; - public bool IsConversionFromLambda => clangsharp.Cursor_getIsConversionFromLambda(this) != 0; + public readonly bool IsConversionFromLambda => clangsharp.Cursor_getIsConversionFromLambda(this) != 0; - public bool IsCopyOrMoveConstructor => clangsharp.Cursor_getIsCopyOrMoveConstructor(this) != 0; + public readonly bool IsCopyOrMoveConstructor => clangsharp.Cursor_getIsCopyOrMoveConstructor(this) != 0; - public bool IsCXXTry => clangsharp.Cursor_getIsCXXTry(this) != 0; + public readonly bool IsCXXTry => clangsharp.Cursor_getIsCXXTry(this) != 0; - public bool IsDeclaration => clang.isDeclaration(Kind) != 0; + public readonly bool IsDeclaration => clang.isDeclaration(Kind) != 0; - public bool IsDefined => clangsharp.Cursor_getIsDefined(this) != 0; + public readonly bool IsDefined => clangsharp.Cursor_getIsDefined(this) != 0; - public bool IsDefinition => clang.isCursorDefinition(this) != 0; + public readonly bool IsDefinition => clang.isCursorDefinition(this) != 0; - public bool IsDelegatingConstructor => clangsharp.Cursor_getIsDelegatingConstructor(this) != 0; + public readonly bool IsDelegatingConstructor => clangsharp.Cursor_getIsDelegatingConstructor(this) != 0; - public bool IsDeleted => clangsharp.Cursor_getIsDeleted(this) != 0; + public readonly bool IsDeleted => clangsharp.Cursor_getIsDeleted(this) != 0; - public bool IsDeprecated => clangsharp.Cursor_getIsDeprecated(this) != 0; + public readonly bool IsDeprecated => clangsharp.Cursor_getIsDeprecated(this) != 0; - public bool IsDynamicCall => clang.Cursor_isDynamicCall(this) != 0; + public readonly bool IsDynamicCall => clang.Cursor_isDynamicCall(this) != 0; - public bool IsElidable => clangsharp.Cursor_getIsElidable(this) != 0; + public readonly bool IsElidable => clangsharp.Cursor_getIsElidable(this) != 0; - public bool IsExplicitlyDefaulted => clangsharp.Cursor_getIsExplicitlyDefaulted(this) != 0; + public readonly bool IsExplicitlyDefaulted => clangsharp.Cursor_getIsExplicitlyDefaulted(this) != 0; - public bool IsExpression => clang.isExpression(Kind) != 0; + public readonly bool IsExpression => clang.isExpression(Kind) != 0; - public bool IsExternC => clangsharp.Cursor_getIsExternC(this) != 0; + public readonly bool IsExternC => clangsharp.Cursor_getIsExternC(this) != 0; - public bool IsExpandedParameterPack => clangsharp.Cursor_getIsExpandedParameterPack(this) != 0; + public readonly bool IsExpandedParameterPack => clangsharp.Cursor_getIsExpandedParameterPack(this) != 0; - public bool IsFileScope => clangsharp.Cursor_getIsFileScope(this) != 0; + public readonly bool IsFileScope => clangsharp.Cursor_getIsFileScope(this) != 0; - public bool IsFunctionInlined => clang.Cursor_isFunctionInlined(this) != 0; + public readonly bool IsFunctionInlined => clang.Cursor_isFunctionInlined(this) != 0; - public bool IsGlobal => clangsharp.Cursor_getIsGlobal(this) != 0; + public readonly bool IsGlobal => clangsharp.Cursor_getIsGlobal(this) != 0; - public bool IsInjectedClassName => clangsharp.Cursor_getIsInjectedClassName(this) != 0; + public readonly bool IsInjectedClassName => clangsharp.Cursor_getIsInjectedClassName(this) != 0; - public bool IsInlineNamespace => clang.Cursor_isInlineNamespace(this) != 0; + public readonly bool IsInlineNamespace => clang.Cursor_isInlineNamespace(this) != 0; - public bool IsIfExists => clangsharp.Cursor_getIsIfExists(this) != 0; + public readonly bool IsIfExists => clangsharp.Cursor_getIsIfExists(this) != 0; - public bool IsImplicit => clangsharp.Cursor_getIsImplicit(this) != 0; + public readonly bool IsImplicit => clangsharp.Cursor_getIsImplicit(this) != 0; - public bool IsIncomplete => clangsharp.Cursor_getIsIncomplete(this) != 0; + public readonly bool IsIncomplete => clangsharp.Cursor_getIsIncomplete(this) != 0; - public bool IsInheritingConstructor => clangsharp.Cursor_getIsInheritingConstructor(this) != 0; + public readonly bool IsInheritingConstructor => clangsharp.Cursor_getIsInheritingConstructor(this) != 0; - public bool IsInvalid => clang.isInvalid(Kind) != 0; + public readonly bool IsInvalid => clang.isInvalid(Kind) != 0; - public bool IsInvalidDeclaration => clang.isInvalidDeclaration(this) != 0; + public readonly bool IsInvalidDeclaration => clang.isInvalidDeclaration(this) != 0; - public bool IsListInitialization => clangsharp.Cursor_getIsListInitialization(this) != 0; + public readonly bool IsListInitialization => clangsharp.Cursor_getIsListInitialization(this) != 0; - public bool IsLocalVarDecl => clangsharp.Cursor_getIsLocalVarDecl(this) != 0; + public readonly bool IsLocalVarDecl => clangsharp.Cursor_getIsLocalVarDecl(this) != 0; - public bool IsLocalVarDeclOrParm => clangsharp.Cursor_getIsLocalVarDeclOrParm(this) != 0; + public readonly bool IsLocalVarDeclOrParm => clangsharp.Cursor_getIsLocalVarDeclOrParm(this) != 0; - public bool IsMacroBuiltIn => clang.Cursor_isMacroBuiltin(this) != 0; + public readonly bool IsMacroBuiltIn => clang.Cursor_isMacroBuiltin(this) != 0; - public bool IsMacroFunctionLike => clang.Cursor_isMacroFunctionLike(this) != 0; + public readonly bool IsMacroFunctionLike => clang.Cursor_isMacroFunctionLike(this) != 0; - public bool IsMemberSpecialization => clangsharp.Cursor_getIsMemberSpecialization(this) != 0; + public readonly bool IsMemberSpecialization => clangsharp.Cursor_getIsMemberSpecialization(this) != 0; - public bool IsNegative => clangsharp.Cursor_getIsNegative(this) != 0; + public readonly bool IsNegative => clangsharp.Cursor_getIsNegative(this) != 0; - public bool IsNonNegative => clangsharp.Cursor_getIsNonNegative(this) != 0; + public readonly bool IsNonNegative => clangsharp.Cursor_getIsNonNegative(this) != 0; - public bool IsNoReturn => clangsharp.Cursor_getIsNoReturn(this) != 0; + public readonly bool IsNoReturn => clangsharp.Cursor_getIsNoReturn(this) != 0; - public bool IsNothrow => clangsharp.Cursor_getIsNothrow(this) != 0; + public readonly bool IsNothrow => clangsharp.Cursor_getIsNothrow(this) != 0; - public bool IsNull => clang.Cursor_isNull(this) != 0; + public readonly bool IsNull => clang.Cursor_isNull(this) != 0; - public bool IsObjCOptional => clang.Cursor_isObjCOptional(this) != 0; + public readonly bool IsObjCOptional => clang.Cursor_isObjCOptional(this) != 0; - public bool IsOverloadedOperator => clangsharp.Cursor_getIsOverloadedOperator(this) != 0; + public readonly bool IsOverloadedOperator => clangsharp.Cursor_getIsOverloadedOperator(this) != 0; - public bool IsPackExpansion => clangsharp.Cursor_getIsPackExpansion(this) != 0; + public readonly bool IsPackExpansion => clangsharp.Cursor_getIsPackExpansion(this) != 0; - public bool IsParameterPack => clangsharp.Cursor_getIsParameterPack(this) != 0; + public readonly bool IsParameterPack => clangsharp.Cursor_getIsParameterPack(this) != 0; - public bool IsPartiallySubstituted => clangsharp.Cursor_getIsPartiallySubstituted(this) != 0; + public readonly bool IsPartiallySubstituted => clangsharp.Cursor_getIsPartiallySubstituted(this) != 0; - public bool IsPotentiallyEvaluated => clangsharp.Cursor_getIsPotentiallyEvaluated(this) != 0; + public readonly bool IsPotentiallyEvaluated => clangsharp.Cursor_getIsPotentiallyEvaluated(this) != 0; - public bool IsPreprocessing => clang.isPreprocessing(Kind) != 0; + public readonly bool IsPreprocessing => clang.isPreprocessing(Kind) != 0; - public bool IsPure => clangsharp.Cursor_getIsPure(this) != 0; + public readonly bool IsPure => clangsharp.Cursor_getIsPure(this) != 0; - public bool IsReference => clang.isReference(Kind) != 0; + public readonly bool IsReference => clang.isReference(Kind) != 0; - public bool IsResultDependent => clangsharp.Cursor_getIsResultDependent(this) != 0; + public readonly bool IsResultDependent => clangsharp.Cursor_getIsResultDependent(this) != 0; - public bool IsStdInitListInitialization => clangsharp.Cursor_getIsStdInitListInitialization(this) != 0; + public readonly bool IsStdInitListInitialization => clangsharp.Cursor_getIsStdInitListInitialization(this) != 0; - public bool IsSigned => clangsharp.Cursor_getIsSigned(this) != 0; + public readonly bool IsSigned => clangsharp.Cursor_getIsSigned(this) != 0; - public bool IsStatement => clang.isStatement(Kind) != 0; + public readonly bool IsStatement => clang.isStatement(Kind) != 0; - public bool IsStatic => clangsharp.Cursor_getIsStatic(this) != 0; + public readonly bool IsStatic => clangsharp.Cursor_getIsStatic(this) != 0; - public bool IsStaticDataMember => clangsharp.Cursor_getIsStaticDataMember(this) != 0; + public readonly bool IsStaticDataMember => clangsharp.Cursor_getIsStaticDataMember(this) != 0; - public bool IsStrictlyPositive => clangsharp.Cursor_getIsStrictlyPositive(this) != 0; + public readonly bool IsStrictlyPositive => clangsharp.Cursor_getIsStrictlyPositive(this) != 0; - public bool IsTemplated => clangsharp.Cursor_getIsTemplated(this) != 0; + public readonly bool IsTemplated => clangsharp.Cursor_getIsTemplated(this) != 0; - public bool IsThisDeclarationADefinition => clangsharp.Cursor_getIsThisDeclarationADefinition(this) != 0; + public readonly bool IsThisDeclarationADefinition => clangsharp.Cursor_getIsThisDeclarationADefinition(this) != 0; - public bool IsThrownVariableInScope => clangsharp.Cursor_getIsThrownVariableInScope(this) != 0; + public readonly bool IsThrownVariableInScope => clangsharp.Cursor_getIsThrownVariableInScope(this) != 0; - public bool IsTranslationUnit => clang.isTranslationUnit(Kind) != 0; + public readonly bool IsTranslationUnit => clang.isTranslationUnit(Kind) != 0; - public bool IsTransparent => clangsharp.Cursor_getIsTransparent(this) != 0; + public readonly bool IsTransparent => clangsharp.Cursor_getIsTransparent(this) != 0; - public bool IsTypeConcept => clangsharp.Cursor_getIsTypeConcept(this) != 0; + public readonly bool IsTypeConcept => clangsharp.Cursor_getIsTypeConcept(this) != 0; - public bool IsUnavailable => clangsharp.Cursor_getIsUnavailable(this) != 0; + public readonly bool IsUnavailable => clangsharp.Cursor_getIsUnavailable(this) != 0; - public bool IsUnconditionallyVisible => clangsharp.Cursor_getIsUnconditionallyVisible(this) != 0; + public readonly bool IsUnconditionallyVisible => clangsharp.Cursor_getIsUnconditionallyVisible(this) != 0; - public bool IsUnexposed => clang.isUnexposed(Kind) != 0; + public readonly bool IsUnexposed => clang.isUnexposed(Kind) != 0; - public bool IsUnnamedBitfield => clangsharp.Cursor_getIsUnnamedBitfield(this) != 0; + public readonly bool IsUnnamedBitfield => clangsharp.Cursor_getIsUnnamedBitfield(this) != 0; - public bool IsUnsigned => clangsharp.Cursor_getIsUnsigned(this) != 0; + public readonly bool IsUnsigned => clangsharp.Cursor_getIsUnsigned(this) != 0; - public bool IsUnsupportedFriend => clangsharp.Cursor_getIsUnsupportedFriend(this) != 0; + public readonly bool IsUnsupportedFriend => clangsharp.Cursor_getIsUnsupportedFriend(this) != 0; - public bool IsUserProvided => clangsharp.Cursor_getIsUserProvided(this) != 0; + public readonly bool IsUserProvided => clangsharp.Cursor_getIsUserProvided(this) != 0; - public bool IsVariadic => clangsharp.Cursor_getIsVariadic(this) != 0; + public readonly bool IsVariadic => clangsharp.Cursor_getIsVariadic(this) != 0; - public bool IsVirtualBase => clang.isVirtualBase(this) != 0; + public readonly bool IsVirtualBase => clang.isVirtualBase(this) != 0; - public CXCursorKind Kind => clang.getCursorKind(this); + public readonly CXCursorKind Kind => clang.getCursorKind(this); - public CXString KindSpelling => (kind != default) ? clang.getCursorKindSpelling(Kind) : default; + public readonly CXString KindSpelling => (kind != default) ? clang.getCursorKindSpelling(Kind) : default; - public CXCursor LambdaCallOperator => clangsharp.Cursor_getLambdaCallOperator(this); + public readonly CXCursor LambdaCallOperator => clangsharp.Cursor_getLambdaCallOperator(this); - public CXCursor LambdaContextDecl => clangsharp.Cursor_getLambdaContextDecl(this); + public readonly CXCursor LambdaContextDecl => clangsharp.Cursor_getLambdaContextDecl(this); - public CXCursor LambdaStaticInvoker => clangsharp.Cursor_getLambdaStaticInvoker(this); + public readonly CXCursor LambdaStaticInvoker => clangsharp.Cursor_getLambdaStaticInvoker(this); - public CXLanguageKind Language => clang.getCursorLanguage(this); + public readonly CXLanguageKind Language => clang.getCursorLanguage(this); - public CXCursor LexicalParent => clang.getCursorLexicalParent(this); + public readonly CXCursor LexicalParent => clang.getCursorLexicalParent(this); - public CXCursor LhsExpr => clangsharp.Cursor_getLhsExpr(this); + public readonly CXCursor LhsExpr => clangsharp.Cursor_getLhsExpr(this); - public CXLinkageKind Linkage => clang.getCursorLinkage(this); + public readonly CXLinkageKind Linkage => clang.getCursorLinkage(this); - public CXSourceLocation Location => clang.getCursorLocation(this); + public readonly CXSourceLocation Location => clang.getCursorLocation(this); - public CXString Mangling => clang.Cursor_getMangling(this); + public readonly CXString Mangling => clang.Cursor_getMangling(this); - public uint MaxAlignment => clangsharp.Cursor_getMaxAlignment(this); + public readonly uint MaxAlignment => clangsharp.Cursor_getMaxAlignment(this); - public CXModule Module => (CXModule)clang.Cursor_getModule(this); + public readonly CXModule Module => (CXModule)clang.Cursor_getModule(this); - public CXCursor MostRecentDecl => clangsharp.Cursor_getMostRecentDecl(this); + public readonly CXCursor MostRecentDecl => clangsharp.Cursor_getMostRecentDecl(this); - public CXString Name => clangsharp.Cursor_getName(this); + public readonly CXString Name => clangsharp.Cursor_getName(this); - public CXCursor NextDeclInContext => clangsharp.Cursor_getNextDeclInContext(this); + public readonly CXCursor NextDeclInContext => clangsharp.Cursor_getNextDeclInContext(this); - public CXCursor NextSwitchCase => clangsharp.Cursor_getNextSwitchCase(this); + public readonly CXCursor NextSwitchCase => clangsharp.Cursor_getNextSwitchCase(this); - public CXCursor NominatedBaseClass => clangsharp.Cursor_getNominatedBaseClass(this); + public readonly CXCursor NominatedBaseClass => clangsharp.Cursor_getNominatedBaseClass(this); - public CXCursor NominatedBaseClassShadowDecl => clangsharp.Cursor_getNominatedBaseClassShadowDecl(this); + public readonly CXCursor NominatedBaseClassShadowDecl => clangsharp.Cursor_getNominatedBaseClassShadowDecl(this); - public CXCursor NonClosureContext => clangsharp.Cursor_getNonClosureContext(this); + public readonly CXCursor NonClosureContext => clangsharp.Cursor_getNonClosureContext(this); - public int NumAssociatedConstraints => clangsharp.Cursor_getNumAssociatedConstraints(this); + public readonly int NumAssociatedConstraints => clangsharp.Cursor_getNumAssociatedConstraints(this); - public int NumArguments => clangsharp.Cursor_getNumArguments(this); + public readonly int NumArguments => clangsharp.Cursor_getNumArguments(this); - public int NumAssocs => clangsharp.Cursor_getNumAssocs(this); + public readonly int NumAssocs => clangsharp.Cursor_getNumAssocs(this); - public int NumAttrs => clangsharp.Cursor_getNumAttrs(this); + public readonly int NumAttrs => clangsharp.Cursor_getNumAttrs(this); - public int NumBases => clangsharp.Cursor_getNumBases(this); + public readonly int NumBases => clangsharp.Cursor_getNumBases(this); - public int NumBindings => clangsharp.Cursor_getNumBindings(this); + public readonly int NumBindings => clangsharp.Cursor_getNumBindings(this); - public int NumCaptures => clangsharp.Cursor_getNumCaptures(this); + public readonly int NumCaptures => clangsharp.Cursor_getNumCaptures(this); - public int NumChildren => clangsharp.Cursor_getNumChildren(this); + public readonly int NumChildren => clangsharp.Cursor_getNumChildren(this); - public int NumCtors => clangsharp.Cursor_getNumCtors(this); + public readonly int NumCtors => clangsharp.Cursor_getNumCtors(this); - public int NumDecls => clangsharp.Cursor_getNumDecls(this); + public readonly int NumDecls => clangsharp.Cursor_getNumDecls(this); - public int NumEnumerators => clangsharp.Cursor_getNumEnumerators(this); + public readonly int NumEnumerators => clangsharp.Cursor_getNumEnumerators(this); - public int NumExpansionTypes => clangsharp.Cursor_getNumExpansionTypes(this); + public readonly int NumExpansionTypes => clangsharp.Cursor_getNumExpansionTypes(this); - public int NumExprs => clangsharp.Cursor_getNumExprs(this); + public readonly int NumExprs => clangsharp.Cursor_getNumExprs(this); - public int NumExprsOther => clangsharp.Cursor_getNumExprsOther(this); + public readonly int NumExprsOther => clangsharp.Cursor_getNumExprsOther(this); - public int NumFields => clangsharp.Cursor_getNumFields(this); + public readonly int NumFields => clangsharp.Cursor_getNumFields(this); - public int NumFriends => clangsharp.Cursor_getNumFriends(this); + public readonly int NumFriends => clangsharp.Cursor_getNumFriends(this); - public int NumMethods => clangsharp.Cursor_getNumMethods(this); + public readonly int NumMethods => clangsharp.Cursor_getNumMethods(this); - public uint NumOverloadedDecls => clang.getNumOverloadedDecls(this); + public readonly uint NumOverloadedDecls => clang.getNumOverloadedDecls(this); - public int NumProtocols => clangsharp.Cursor_getNumProtocols(this); + public readonly int NumProtocols => clangsharp.Cursor_getNumProtocols(this); - public int NumSpecializations => clangsharp.Cursor_getNumSpecializations(this); + public readonly int NumSpecializations => clangsharp.Cursor_getNumSpecializations(this); - public int NumTemplateArguments => clangsharp.Cursor_getNumTemplateArguments(this); + public readonly int NumTemplateArguments => clangsharp.Cursor_getNumTemplateArguments(this); - public int NumTemplateParameterLists => clangsharp.Cursor_getNumTemplateParameterLists(this); + public readonly int NumTemplateParameterLists => clangsharp.Cursor_getNumTemplateParameterLists(this); - public int NumVBases => clangsharp.Cursor_getNumVBases(this); + public readonly int NumVBases => clangsharp.Cursor_getNumVBases(this); - public CXObjCDeclQualifierKind ObjCDeclQualifiers => (CXObjCDeclQualifierKind)clang.Cursor_getObjCDeclQualifiers(this); + public readonly CXObjCDeclQualifierKind ObjCDeclQualifiers => (CXObjCDeclQualifierKind)clang.Cursor_getObjCDeclQualifiers(this); - public CXStringSet* ObjCManglings => clang.Cursor_getObjCManglings(this); + public readonly CXStringSet* ObjCManglings => clang.Cursor_getObjCManglings(this); - public CXString ObjCPropertyGetterName => clang.Cursor_getObjCPropertyGetterName(this); + public readonly CXString ObjCPropertyGetterName => clang.Cursor_getObjCPropertyGetterName(this); - public CXString ObjCPropertySetterName => clang.Cursor_getObjCPropertySetterName(this); + public readonly CXString ObjCPropertySetterName => clang.Cursor_getObjCPropertySetterName(this); - public int ObjCSelectorIndex => clang.Cursor_getObjCSelectorIndex(this); + public readonly int ObjCSelectorIndex => clang.Cursor_getObjCSelectorIndex(this); - public long OffsetOfField => clang.Cursor_getOffsetOfField(this); + public readonly long OffsetOfField => clang.Cursor_getOffsetOfField(this); - public CXCursor OpaqueValue => clangsharp.Cursor_getOpaqueValue(this); + public readonly CXCursor OpaqueValue => clangsharp.Cursor_getOpaqueValue(this); - public CXType OriginalType => clangsharp.Cursor_getOriginalType(this); + public readonly CXType OriginalType => clangsharp.Cursor_getOriginalType(this); - public CX_OverloadedOperatorKind OverloadedOperatorKind => clangsharp.Cursor_getOverloadedOperatorKind(this); + public readonly CX_OverloadedOperatorKind OverloadedOperatorKind => clangsharp.Cursor_getOverloadedOperatorKind(this); - public ReadOnlySpan OverriddenCursors + public readonly ReadOnlySpan OverriddenCursors { get { @@ -1183,53 +1183,53 @@ public ReadOnlySpan OverriddenCursors } } - public int PackLength => clangsharp.Cursor_getPackLength(this); + public readonly int PackLength => clangsharp.Cursor_getPackLength(this); - public CXCursor ParentFunctionOrMethod => clangsharp.Cursor_getParentFunctionOrMethod(this); + public readonly CXCursor ParentFunctionOrMethod => clangsharp.Cursor_getParentFunctionOrMethod(this); - public CXComment ParsedComment => clang.Cursor_getParsedComment(this); + public readonly CXComment ParsedComment => clang.Cursor_getParsedComment(this); - public CXCursor PlaceholderTypeConstraint => clangsharp.Cursor_getPlaceholderTypeConstraint(this); + public readonly CXCursor PlaceholderTypeConstraint => clangsharp.Cursor_getPlaceholderTypeConstraint(this); - public CXCursor PreviousDecl => clangsharp.Cursor_getPreviousDecl(this); + public readonly CXCursor PreviousDecl => clangsharp.Cursor_getPreviousDecl(this); - public CXCursor PrimaryTemplate => clangsharp.Cursor_getPrimaryTemplate(this); + public readonly CXCursor PrimaryTemplate => clangsharp.Cursor_getPrimaryTemplate(this); - public CXPrintingPolicy PrintingPolicy => (kind != default) ? (CXPrintingPolicy)clang.getCursorPrintingPolicy(this) : default; + public readonly CXPrintingPolicy PrintingPolicy => (kind != default) ? (CXPrintingPolicy)clang.getCursorPrintingPolicy(this) : default; - public CXString RawCommentText => clang.Cursor_getRawCommentText(this); + public readonly CXString RawCommentText => clang.Cursor_getRawCommentText(this); - public CXType ReceiverType => !IsExpression ? default : clang.Cursor_getReceiverType(this); + public readonly CXType ReceiverType => !IsExpression ? default : clang.Cursor_getReceiverType(this); - public CXCursor RedeclContext => clangsharp.Cursor_getRedeclContext(this); + public readonly CXCursor RedeclContext => clangsharp.Cursor_getRedeclContext(this); - public CXCursor Referenced => clangsharp.Cursor_getReferenced(this); + public readonly CXCursor Referenced => clangsharp.Cursor_getReferenced(this); - public bool RequiresZeroInitialization => clangsharp.Cursor_getRequiresZeroInitialization(this) != 0; + public readonly bool RequiresZeroInitialization => clangsharp.Cursor_getRequiresZeroInitialization(this) != 0; - public int ResultIndex => clangsharp.Cursor_getResultIndex(this); + public readonly int ResultIndex => clangsharp.Cursor_getResultIndex(this); - public CXType ResultType => clang.getCursorResultType(this); + public readonly CXType ResultType => clang.getCursorResultType(this); - public CXType ReturnType => clangsharp.Cursor_getReturnType(this); + public readonly CXType ReturnType => clangsharp.Cursor_getReturnType(this); - public CXCursor RhsExpr => clangsharp.Cursor_getRhsExpr(this); + public readonly CXCursor RhsExpr => clangsharp.Cursor_getRhsExpr(this); - public CXCursor SemanticParent => clang.getCursorSemanticParent(this); + public readonly CXCursor SemanticParent => clang.getCursorSemanticParent(this); - public bool ShouldCopy => clangsharp.Cursor_getShouldCopy(this) != 0; + public readonly bool ShouldCopy => clangsharp.Cursor_getShouldCopy(this) != 0; - public CXSourceRange SourceRange => clangsharp.Cursor_getSourceRange(this); + public readonly CXSourceRange SourceRange => clangsharp.Cursor_getSourceRange(this); - public CXSourceRange SourceRangeRaw => clangsharp.Cursor_getSourceRangeRaw(this); + public readonly CXSourceRange SourceRangeRaw => clangsharp.Cursor_getSourceRangeRaw(this); - public CXCursor SpecializedCursorTemplate => clang.getSpecializedCursorTemplate(this); + public readonly CXCursor SpecializedCursorTemplate => clang.getSpecializedCursorTemplate(this); - public CXString Spelling => clang.getCursorSpelling(this); + public readonly CXString Spelling => clang.getCursorSpelling(this); - public CX_StmtClass StmtClass => clangsharp.Cursor_getStmtClass(this); + public readonly CX_StmtClass StmtClass => clangsharp.Cursor_getStmtClass(this); - public string StmtClassSpelling + public readonly string StmtClassSpelling { get { @@ -1530,69 +1530,69 @@ public string StmtClassSpelling } } - public CX_StorageClass StorageClass => clang.Cursor_getStorageClass(this); + public readonly CX_StorageClass StorageClass => clang.Cursor_getStorageClass(this); - public CXString StringLiteralValue => clangsharp.Cursor_getStringLiteralValue(this); + public readonly CXString StringLiteralValue => clangsharp.Cursor_getStringLiteralValue(this); - public CXCursor SubExpr => clangsharp.Cursor_getSubExpr(this); + public readonly CXCursor SubExpr => clangsharp.Cursor_getSubExpr(this); - public CXCursor SubExprAsWritten => clangsharp.Cursor_getSubExprAsWritten(this); + public readonly CXCursor SubExprAsWritten => clangsharp.Cursor_getSubExprAsWritten(this); - public CXCursor SubStmt => clangsharp.Cursor_getSubStmt(this); + public readonly CXCursor SubStmt => clangsharp.Cursor_getSubStmt(this); - public CXCursor TargetUnionField => clangsharp.Cursor_getTargetUnionField(this); + public readonly CXCursor TargetUnionField => clangsharp.Cursor_getTargetUnionField(this); - public CXCursorKind TemplateCursorKind => clang.getTemplateCursorKind(this); + public readonly CXCursorKind TemplateCursorKind => clang.getTemplateCursorKind(this); - public CXCursor TemplatedDecl => clangsharp.Cursor_getTemplatedDecl(this); + public readonly CXCursor TemplatedDecl => clangsharp.Cursor_getTemplatedDecl(this); - public CXCursor TemplateInstantiationPattern => clangsharp.Cursor_getTemplateInstantiationPattern(this); + public readonly CXCursor TemplateInstantiationPattern => clangsharp.Cursor_getTemplateInstantiationPattern(this); - public CX_TemplateSpecializationKind TemplateSpecializationKind => clangsharp.Cursor_getTemplateSpecializationKind(this); + public readonly CX_TemplateSpecializationKind TemplateSpecializationKind => clangsharp.Cursor_getTemplateSpecializationKind(this); - public int TemplateTypeParmDepth => clangsharp.Cursor_getTemplateTypeParmDepth(this); + public readonly int TemplateTypeParmDepth => clangsharp.Cursor_getTemplateTypeParmDepth(this); - public int TemplateTypeParmIndex => clangsharp.Cursor_getTemplateTypeParmIndex(this); + public readonly int TemplateTypeParmIndex => clangsharp.Cursor_getTemplateTypeParmIndex(this); - public int TemplateTypeParmPosition => clangsharp.Cursor_getTemplateTypeParmPosition(this); + public readonly int TemplateTypeParmPosition => clangsharp.Cursor_getTemplateTypeParmPosition(this); - public CXType ThisObjectType => clangsharp.Cursor_getThisObjectType(this); + public readonly CXType ThisObjectType => clangsharp.Cursor_getThisObjectType(this); - public CXType ThisType => clangsharp.Cursor_getThisType(this); + public readonly CXType ThisType => clangsharp.Cursor_getThisType(this); - public CXTLSKind TlsKind => clang.getCursorTLSKind(this); + public readonly CXTLSKind TlsKind => clang.getCursorTLSKind(this); - public CXCursor TrailingRequiresClause => clangsharp.Cursor_getTrailingRequiresClause(this); + public readonly CXCursor TrailingRequiresClause => clangsharp.Cursor_getTrailingRequiresClause(this); - public CXTranslationUnit TranslationUnit => clang.Cursor_getTranslationUnit(this); + public readonly CXTranslationUnit TranslationUnit => clang.Cursor_getTranslationUnit(this); - public CXType Type => clang.getCursorType(this); + public readonly CXType Type => clang.getCursorType(this); - public CXType TypeOperand => clangsharp.Cursor_getTypeOperand(this); + public readonly CXType TypeOperand => clangsharp.Cursor_getTypeOperand(this); - public CXType TypedefDeclUnderlyingType => clang.getTypedefDeclUnderlyingType(this); + public readonly CXType TypedefDeclUnderlyingType => clang.getTypedefDeclUnderlyingType(this); - public CXCursor TypedefNameForAnonDecl => clangsharp.Cursor_getTypedefNameForAnonDecl(this); + public readonly CXCursor TypedefNameForAnonDecl => clangsharp.Cursor_getTypedefNameForAnonDecl(this); - public CX_UnaryExprOrTypeTrait UnaryExprOrTypeTraitKind => clangsharp.Cursor_getUnaryExprOrTypeTraitKind(this); + public readonly CX_UnaryExprOrTypeTrait UnaryExprOrTypeTraitKind => clangsharp.Cursor_getUnaryExprOrTypeTraitKind(this); - public CX_UnaryOperatorKind UnaryOperatorKind => clangsharp.Cursor_getUnaryOpcode(this); + public readonly CX_UnaryOperatorKind UnaryOperatorKind => clangsharp.Cursor_getUnaryOpcode(this); - public CXString UnaryOperatorKindSpelling => clangsharp.Cursor_getUnaryOpcodeSpelling(UnaryOperatorKind); + public readonly CXString UnaryOperatorKindSpelling => clangsharp.Cursor_getUnaryOpcodeSpelling(UnaryOperatorKind); - public CXCursor UnderlyingDecl => clangsharp.Cursor_getUnderlyingDecl(this); + public readonly CXCursor UnderlyingDecl => clangsharp.Cursor_getUnderlyingDecl(this); - public CXCursor UninstantiatedDefaultArg => clangsharp.Cursor_getUninstantiatedDefaultArg(this); + public readonly CXCursor UninstantiatedDefaultArg => clangsharp.Cursor_getUninstantiatedDefaultArg(this); - public CXCursor UsedContext => clangsharp.Cursor_getUsedContext(this); + public readonly CXCursor UsedContext => clangsharp.Cursor_getUsedContext(this); - public CXString Usr => clang.getCursorUSR(this); + public readonly CXString Usr => clang.getCursorUSR(this); - public CXVisibilityKind Visibility => clang.getCursorVisibility(this); + public readonly CXVisibilityKind Visibility => clang.getCursorVisibility(this); - public long VtblIdx => clangsharp.Cursor_getVtblIdx(this); + public readonly long VtblIdx => clangsharp.Cursor_getVtblIdx(this); - internal string DebuggerDisplayString + internal readonly string DebuggerDisplayString { get { @@ -1634,7 +1634,7 @@ internal string DebuggerDisplayString 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 readonly bool CapturesVariable(CXCursor var) => clangsharp.Cursor_getCapturesVariable(this, var) != 0; public static void DisposeOverriddenCursors(ReadOnlySpan overridden) { @@ -1644,47 +1644,47 @@ public static void DisposeOverriddenCursors(ReadOnlySpan overridden) } } - public override bool Equals(object? obj) => (obj is CXCursor other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXCursor other) && Equals(other); - public bool Equals(CXCursor other) => this == other; + public readonly bool Equals(CXCursor other) => this == other; - public CXResult FindReferencesInFile(CXFile file, CXCursorAndRangeVisitor visitor) => clang.findReferencesInFile(this, file, visitor); + public readonly CXResult FindReferencesInFile(CXFile file, CXCursorAndRangeVisitor visitor) => clang.findReferencesInFile(this, file, visitor); - public CXCursor GetAssociatedConstraint(uint index) => clangsharp.Cursor_getAssociatedConstraint(this, index); + public readonly CXCursor GetAssociatedConstraint(uint index) => clangsharp.Cursor_getAssociatedConstraint(this, index); - public CXCursor GetArgument(uint index) => clangsharp.Cursor_getArgument(this, index); + public readonly CXCursor GetArgument(uint index) => clangsharp.Cursor_getArgument(this, index); - public CXCursor GetAttr(uint index) => clangsharp.Cursor_getAttr(this, index); + public readonly CXCursor GetAttr(uint index) => clangsharp.Cursor_getAttr(this, index); - public CXCursor GetBase(uint index) => clangsharp.Cursor_getBase(this, index); + public readonly CXCursor GetBase(uint index) => clangsharp.Cursor_getBase(this, index); - public CXCursor GetBindingDecl(uint index) => clangsharp.Cursor_getBindingDecl(this, index); + public readonly CXCursor GetBindingDecl(uint index) => clangsharp.Cursor_getBindingDecl(this, index); - public CXCursor GetCtor(uint index) => clangsharp.Cursor_getCtor(this, index); + public readonly CXCursor GetCtor(uint index) => clangsharp.Cursor_getCtor(this, index); - public CXCursor GetCaptureCopyExpr(uint index) => clangsharp.Cursor_getCaptureCopyExpr(this, index); + public readonly CXCursor GetCaptureCopyExpr(uint index) => clangsharp.Cursor_getCaptureCopyExpr(this, index); - public CXCursor GetCapturedVar(uint index) => clangsharp.Cursor_getCapturedVar(this, index); + public readonly CXCursor GetCapturedVar(uint index) => clangsharp.Cursor_getCapturedVar(this, index); - public CX_VariableCaptureKind GetCaptureKind(uint index) => clangsharp.Cursor_getCaptureKind(this, index); + public readonly CX_VariableCaptureKind GetCaptureKind(uint index) => clangsharp.Cursor_getCaptureKind(this, index); - public bool GetCaptureHasCopyExpr(uint index) => clangsharp.Cursor_getCaptureHasCopyExpr(this, index) != 0; + public readonly bool GetCaptureHasCopyExpr(uint index) => clangsharp.Cursor_getCaptureHasCopyExpr(this, index) != 0; - public bool GetCaptureIsByRef(uint index) => clangsharp.Cursor_getCaptureIsByRef(this, index) != 0; + public readonly bool GetCaptureIsByRef(uint index) => clangsharp.Cursor_getCaptureIsByRef(this, index) != 0; - public bool GetCaptureIsEscapingByRef(uint index) => clangsharp.Cursor_getCaptureIsEscapingByRef(this, index) != 0; + public readonly bool GetCaptureIsEscapingByRef(uint index) => clangsharp.Cursor_getCaptureIsEscapingByRef(this, index) != 0; - public bool GetCaptureIsNested(uint index) => clangsharp.Cursor_getCaptureIsNested(this, index) != 0; + public readonly bool GetCaptureIsNested(uint index) => clangsharp.Cursor_getCaptureIsNested(this, index) != 0; - public bool GetCaptureIsNonEscapingByRef(uint index) => clangsharp.Cursor_getCaptureIsNonEscapingByRef(this, index) != 0; + public readonly bool GetCaptureIsNonEscapingByRef(uint index) => clangsharp.Cursor_getCaptureIsNonEscapingByRef(this, index) != 0; - public CXCursor GetCaptureVariable(uint index) => clangsharp.Cursor_getCaptureVariable(this, index); + public readonly CXCursor GetCaptureVariable(uint index) => clangsharp.Cursor_getCaptureVariable(this, index); - public CXCursor GetChild(uint index) => clangsharp.Cursor_getChild(this, index); + public readonly CXCursor GetChild(uint index) => clangsharp.Cursor_getChild(this, index); - public CXCursor GetDecl(uint index) => clangsharp.Cursor_getDecl(this, index); + public readonly 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 readonly 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) @@ -1698,19 +1698,19 @@ public void GetDefinitionSpellingAndExtent(out string spelling, out uint startLi } } - public CXCursor GetEnumerator(uint index) => clangsharp.Cursor_getEnumerator(this, index); + public readonly CXCursor GetEnumerator(uint index) => clangsharp.Cursor_getEnumerator(this, index); - public CXType GetExpansionType(uint index) => clangsharp.Cursor_getExpansionType(this, index); + public readonly CXType GetExpansionType(uint index) => clangsharp.Cursor_getExpansionType(this, index); - public CXCursor GetExpr(uint index) => clangsharp.Cursor_getExpr(this, index); + public readonly CXCursor GetExpr(uint index) => clangsharp.Cursor_getExpr(this, index); - public CXCursor GetField(uint index) => clangsharp.Cursor_getField(this, index); + public readonly CXCursor GetField(uint index) => clangsharp.Cursor_getField(this, index); - public CXCursor GetFriend(uint index) => clangsharp.Cursor_getFriend(this, index); + public readonly CXCursor GetFriend(uint index) => clangsharp.Cursor_getFriend(this, index); - public override int GetHashCode() => (int)Hash; + public override readonly int GetHashCode() => (int)Hash; - public bool GetIsExternalSymbol(out CXString language, out CXString definedIn, out bool isGenerated) + public readonly bool GetIsExternalSymbol(out CXString language, out CXString definedIn, out bool isGenerated) { fixed (CXString* pLanguage = &language) fixed (CXString* pDefinedIn = &definedIn) @@ -1722,15 +1722,15 @@ public bool GetIsExternalSymbol(out CXString language, out CXString definedIn, o } } - public CXCursor GetMethod(uint index) => clangsharp.Cursor_getMethod(this, index); + public readonly CXCursor GetMethod(uint index) => clangsharp.Cursor_getMethod(this, index); - public int GetNumTemplateParameters(uint listIndex) => clangsharp.Cursor_getNumTemplateParameters(this, listIndex); + public readonly int GetNumTemplateParameters(uint listIndex) => clangsharp.Cursor_getNumTemplateParameters(this, listIndex); - public CXObjCPropertyAttrKind GetObjCPropertyAttributes(uint reserved) => (CXObjCPropertyAttrKind)clang.Cursor_getObjCPropertyAttributes(this, reserved); + public readonly CXObjCPropertyAttrKind GetObjCPropertyAttributes(uint reserved) => (CXObjCPropertyAttrKind)clang.Cursor_getObjCPropertyAttributes(this, reserved); - public CXCursor GetOverloadedDecl(uint index) => clang.getOverloadedDecl(this, index); + public readonly 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 readonly int GetPlatformAvailability(out bool alwaysDeprecated, out CXString deprecatedMessage, out bool alwaysUnavailable, out CXString unavailableMessage, Span availability) { fixed (CXString* pDeprecatedMessage = &deprecatedMessage) fixed (CXString* pUnavailableMessage = &unavailableMessage) @@ -1745,35 +1745,35 @@ public int GetPlatformAvailability(out bool alwaysDeprecated, out CXString depre } } - public CXString GetPrettyPrinted(CXPrintingPolicy policy) => clang.getCursorPrettyPrinted(this, policy); + public readonly CXString GetPrettyPrinted(CXPrintingPolicy policy) => clang.getCursorPrettyPrinted(this, policy); - public CXCursor GetProtocol(uint index) => clangsharp.Cursor_getProtocol(this, index); + public readonly CXCursor GetProtocol(uint index) => clangsharp.Cursor_getProtocol(this, index); - public CXSourceRange GetReferenceNameRange(CXNameRefFlags nameFlags, uint pieceIndex) => clang.getCursorReferenceNameRange(this, (uint)nameFlags, pieceIndex); + public readonly CXSourceRange GetReferenceNameRange(CXNameRefFlags nameFlags, uint pieceIndex) => clang.getCursorReferenceNameRange(this, (uint)nameFlags, pieceIndex); - public CXCursor GetSpecialization(uint index) => clangsharp.Cursor_getSpecialization(this, index); + public readonly CXCursor GetSpecialization(uint index) => clangsharp.Cursor_getSpecialization(this, index); - public CXSourceRange GetSpellingNameRange(uint pieceIndex, uint options) => clang.Cursor_getSpellingNameRange(this, pieceIndex, options); + public readonly CXSourceRange GetSpellingNameRange(uint pieceIndex, uint options) => clang.Cursor_getSpellingNameRange(this, pieceIndex, options); - public CXCursor GetSubDecl(uint i) => clangsharp.Cursor_getSubDecl(this, i); + public readonly CXCursor GetSubDecl(uint i) => clangsharp.Cursor_getSubDecl(this, i); - public CX_TemplateArgument GetTemplateArgument(uint index) => clangsharp.Cursor_getTemplateArgument(this, index); + public readonly CX_TemplateArgument GetTemplateArgument(uint index) => clangsharp.Cursor_getTemplateArgument(this, index); - public CX_TemplateArgumentLoc GetTemplateArgumentLoc(uint index) => clangsharp.Cursor_getTemplateArgumentLoc(this, index); + public readonly CX_TemplateArgumentLoc GetTemplateArgumentLoc(uint index) => clangsharp.Cursor_getTemplateArgumentLoc(this, index); - public CXCursor GetTemplateParameter(uint listIndex, uint parameterIndex) => clangsharp.Cursor_getTemplateParameter(this, listIndex, parameterIndex); + public readonly CXCursor GetTemplateParameter(uint listIndex, uint parameterIndex) => clangsharp.Cursor_getTemplateParameter(this, listIndex, parameterIndex); - public CXType GetTemplateArgumentType(uint i) => clang.Cursor_getTemplateArgumentType(this, i); + public readonly CXType GetTemplateArgumentType(uint i) => clang.Cursor_getTemplateArgumentType(this, i); - public ulong GetTemplateArgumentUnsignedValue(uint i) => clang.Cursor_getTemplateArgumentUnsignedValue(this, i); + public readonly ulong GetTemplateArgumentUnsignedValue(uint i) => clang.Cursor_getTemplateArgumentUnsignedValue(this, i); - public long GetTemplateArgumentValue(uint i) => clang.Cursor_getTemplateArgumentValue(this, i); + public readonly long GetTemplateArgumentValue(uint i) => clang.Cursor_getTemplateArgumentValue(this, i); - public CXCursor GetVBase(uint index) => clangsharp.Cursor_getVBase(this, index); + public readonly CXCursor GetVBase(uint index) => clangsharp.Cursor_getVBase(this, index); - public override string ToString() => Spelling.ToString(); + public override readonly string ToString() => Spelling.ToString(); - public CXChildVisitResult VisitChildren(CXCursorVisitor visitor, CXClientData clientData) + public readonly CXChildVisitResult VisitChildren(CXCursorVisitor visitor, CXClientData clientData) { var pVisitor = (delegate* unmanaged[Cdecl])Marshal.GetFunctionPointerForDelegate(visitor); var result = VisitChildren(pVisitor, clientData); @@ -1782,7 +1782,7 @@ public CXChildVisitResult VisitChildren(CXCursorVisitor visitor, CXClientData cl return result; } - public CXChildVisitResult VisitChildren(delegate* unmanaged[Cdecl] visitor, CXClientData clientData) + public readonly CXChildVisitResult VisitChildren(delegate* unmanaged[Cdecl] visitor, CXClientData clientData) { return (CXChildVisitResult)clang.visitChildren(this, visitor, clientData); } diff --git a/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs b/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs index f6f76b9c..1de69061 100644 --- a/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs +++ b/sources/ClangSharp.Interop/Extensions/CXCursorSet.cs @@ -23,7 +23,7 @@ public CXCursorSet(IntPtr handle) public static CXCursorSet Create() => clang.createCXCursorSet(); - public bool Contains(CXCursor cursor) => clang.CXCursorSet_contains(this, cursor) != 0; + public readonly bool Contains(CXCursor cursor) => clang.CXCursorSet_contains(this, cursor) != 0; public void Dispose() { @@ -34,11 +34,11 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXCursorSet other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXCursorSet other) && Equals(other); - public bool Equals(CXCursorSet other) => this == other; + public readonly bool Equals(CXCursorSet other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public bool Insert(CXCursor cursor) => clang.CXCursorSet_insert(this, cursor) != 0; + public readonly 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 e981b7bf..70ace825 100644 --- a/sources/ClangSharp.Interop/Extensions/CXDiagnostic.cs +++ b/sources/ClangSharp.Interop/Extensions/CXDiagnostic.cs @@ -13,23 +13,23 @@ public CXDiagnostic(IntPtr handle) public static CXDiagnosticDisplayOptions DefaultDisplayOptions => (CXDiagnosticDisplayOptions)clang.defaultDiagnosticDisplayOptions(); - public uint Category => clang.getDiagnosticCategory(this); + public readonly uint Category => clang.getDiagnosticCategory(this); - public CXString CategoryText => clang.getDiagnosticCategoryText(this); + public readonly CXString CategoryText => clang.getDiagnosticCategoryText(this); - public CXDiagnosticSet ChildDiagnostics => (CXDiagnosticSet)clang.getChildDiagnostics(this); + public readonly CXDiagnosticSet ChildDiagnostics => (CXDiagnosticSet)clang.getChildDiagnostics(this); public IntPtr Handle { get; set; } - public CXSourceLocation Location => clang.getDiagnosticLocation(this); + public readonly CXSourceLocation Location => clang.getDiagnosticLocation(this); - public uint NumFixIts => clang.getDiagnosticNumFixIts(this); + public readonly uint NumFixIts => clang.getDiagnosticNumFixIts(this); - public uint NumRanges => clang.getDiagnosticNumRanges(this); + public readonly uint NumRanges => clang.getDiagnosticNumRanges(this); - public CXDiagnosticSeverity Severity => clang.getDiagnosticSeverity(this); + public readonly CXDiagnosticSeverity Severity => clang.getDiagnosticSeverity(this); - public CXString Spelling => clang.getDiagnosticSpelling(this); + public readonly CXString Spelling => clang.getDiagnosticSpelling(this); public static explicit operator CXDiagnostic(void* value) => new CXDiagnostic((IntPtr)value); @@ -48,16 +48,16 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXDiagnostic other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXDiagnostic other) && Equals(other); - public bool Equals(CXDiagnostic other) => this == other; + public readonly bool Equals(CXDiagnostic other) => this == other; - public CXString Format(CXDiagnosticDisplayOptions options) => clang.formatDiagnostic(this, (uint)options); + public readonly CXString Format(CXDiagnosticDisplayOptions options) => clang.formatDiagnostic(this, (uint)options); [Obsolete("Use " + nameof(CategoryText) + " instead.")] public static CXString GetCategoryName(uint category) => clang.getDiagnosticCategoryName(category); - public CXString GetFixIt(uint fixIt, out CXSourceRange replacementRange) + public readonly CXString GetFixIt(uint fixIt, out CXSourceRange replacementRange) { fixed (CXSourceRange* pReplacementRange = &replacementRange) { @@ -65,9 +65,9 @@ public CXString GetFixIt(uint fixIt, out CXSourceRange replacementRange) } } - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public CXString GetOption(out CXString disable) + public readonly CXString GetOption(out CXString disable) { fixed (CXString* pDisable = &disable) { @@ -75,7 +75,7 @@ public CXString GetOption(out CXString disable) } } - public CXSourceRange GetRange(uint range) => clang.getDiagnosticRange(this, range); + public readonly CXSourceRange GetRange(uint range) => clang.getDiagnosticRange(this, range); - public override string ToString() => Spelling.ToString(); + public override readonly string ToString() => Spelling.ToString(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs b/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs index ba2df4ff..5d7b0775 100644 --- a/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs +++ b/sources/ClangSharp.Interop/Extensions/CXDiagnosticSet.cs @@ -24,13 +24,13 @@ public CXDiagnosticSet(IntPtr handle) Handle = handle; } - public CXDiagnostic this[uint index] => GetDiagnostic(index); + public readonly CXDiagnostic this[uint index] => GetDiagnostic(index); - public int Count => (int)NumDiagnostics; + public readonly int Count => (int)NumDiagnostics; public IntPtr Handle { get; set; } - public uint NumDiagnostics => clang.getNumDiagnosticsInSet(this); + public readonly uint NumDiagnostics => clang.getNumDiagnosticsInSet(this); public static explicit operator CXDiagnosticSet(void* value) => new CXDiagnosticSet((IntPtr)value); @@ -49,13 +49,13 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXDiagnosticSet other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXDiagnosticSet other) && Equals(other); - public bool Equals(CXDiagnosticSet other) => this == other; + public readonly bool Equals(CXDiagnosticSet other) => this == other; - public CXDiagnostic GetDiagnostic(uint index) => (CXDiagnostic)clang.getDiagnosticInSet(this, index); + public readonly CXDiagnostic GetDiagnostic(uint index) => (CXDiagnostic)clang.getDiagnosticInSet(this, index); - public IEnumerator GetEnumerator() + public readonly IEnumerator GetEnumerator() { var count = NumDiagnostics; @@ -65,7 +65,7 @@ public IEnumerator GetEnumerator() } } - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + readonly IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs b/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs index c4d1f55a..3660c27b 100644 --- a/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs +++ b/sources/ClangSharp.Interop/Extensions/CXEvalResult.cs @@ -12,13 +12,13 @@ public CXEvalResult(IntPtr handle) Handle = handle; } - public double AsDouble => (Kind == CXEval_Float) ? clang.EvalResult_getAsDouble(this) : 0; + public readonly double AsDouble => (Kind == CXEval_Float) ? clang.EvalResult_getAsDouble(this) : 0; - public int AsInt => (Kind == CXEval_Int) ? clang.EvalResult_getAsInt(this) : 0; + public readonly int AsInt => (Kind == CXEval_Int) ? clang.EvalResult_getAsInt(this) : 0; - public long AsLongLong => (Kind == CXEval_Int) ? clang.EvalResult_getAsLongLong(this) : 0; + public readonly long AsLongLong => (Kind == CXEval_Int) ? clang.EvalResult_getAsLongLong(this) : 0; - public string AsStr + public readonly string AsStr { get { @@ -33,13 +33,13 @@ public string AsStr } } - public ulong AsUnsigned => (Kind == CXEval_Int) ? clang.EvalResult_getAsUnsigned(this) : 0; + public readonly ulong AsUnsigned => (Kind == CXEval_Int) ? clang.EvalResult_getAsUnsigned(this) : 0; public IntPtr Handle { get; set; } - public bool IsUnsignedInt => (Kind == CXEval_Int) && (clang.EvalResult_isUnsignedInt(this) != 0); + public readonly bool IsUnsignedInt => (Kind == CXEval_Int) && (clang.EvalResult_isUnsignedInt(this) != 0); - public CXEvalResultKind Kind => clang.EvalResult_getKind(this); + public readonly CXEvalResultKind Kind => clang.EvalResult_getKind(this); public static explicit operator CXEvalResult(void* value) => new CXEvalResult((IntPtr)value); @@ -58,9 +58,9 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXEvalResult other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXEvalResult other) && Equals(other); - public bool Equals(CXEvalResult other) => this == other; + public readonly bool Equals(CXEvalResult other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXFile.cs b/sources/ClangSharp.Interop/Extensions/CXFile.cs index e6039773..2a829da2 100644 --- a/sources/ClangSharp.Interop/Extensions/CXFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXFile.cs @@ -13,9 +13,9 @@ public CXFile(IntPtr handle) public IntPtr Handle { get; set; } - public CXString Name => clang.getFileName(this); + public readonly CXString Name => clang.getFileName(this); - public long Time => clang.getFileTime(this); + public readonly long Time => clang.getFileTime(this); public static explicit operator CXFile(void* value) => new CXFile((IntPtr)value); @@ -25,15 +25,15 @@ public CXFile(IntPtr handle) 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 readonly bool Equals(object? obj) => (obj is CXFile other) && Equals(other); - public bool Equals(CXFile other) => this == other; + public readonly bool Equals(CXFile other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public override string ToString() => Name.ToString(); + public override readonly string ToString() => Name.ToString(); - public bool TryGetUniqueId(out CXFileUniqueID id) + public readonly bool TryGetUniqueId(out CXFileUniqueID id) { fixed (CXFileUniqueID* pId = &id) { @@ -41,5 +41,5 @@ public bool TryGetUniqueId(out CXFileUniqueID id) } } - public CXString TryGetRealPathName() => clang.File_tryGetRealPathName(this); + public readonly CXString TryGetRealPathName() => clang.File_tryGetRealPathName(this); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs index 2280b3b7..b951af6e 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientASTFile.cs @@ -21,9 +21,9 @@ public CXIdxClientASTFile(IntPtr 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 readonly bool Equals(object? obj) => (obj is CXIdxClientASTFile other) && Equals(other); - public bool Equals(CXIdxClientASTFile other) => this == other; + public readonly bool Equals(CXIdxClientASTFile other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs index d06146a9..65a95e5c 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientContainer.cs @@ -21,9 +21,9 @@ public CXIdxClientContainer(IntPtr 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 readonly bool Equals(object? obj) => (obj is CXIdxClientContainer other) && Equals(other); - public bool Equals(CXIdxClientContainer other) => this == other; + public readonly bool Equals(CXIdxClientContainer other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs index 10e6278b..8073dd9e 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientEntity.cs @@ -21,9 +21,9 @@ public CXIdxClientEntity(IntPtr 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 readonly bool Equals(object? obj) => (obj is CXIdxClientEntity other) && Equals(other); - public bool Equals(CXIdxClientEntity other) => this == other; + public readonly bool Equals(CXIdxClientEntity other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs b/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs index 77af0e53..c9be23c0 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxClientFile.cs @@ -21,9 +21,9 @@ public CXIdxClientFile(IntPtr 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 readonly bool Equals(object? obj) => (obj is CXIdxClientFile other) && Equals(other); - public bool Equals(CXIdxClientFile other) => this == other; + public readonly bool Equals(CXIdxClientFile other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxEntityInfo.cs b/sources/ClangSharp.Interop/Extensions/CXIdxEntityInfo.cs index 5f1c50fc..7161d5a0 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxEntityInfo.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxEntityInfo.cs @@ -23,5 +23,5 @@ public CXIdxClientEntity ClientEntity } } - public bool IsObjCContainer => clang.index_isEntityObjCContainerKind(kind) != 0; + public readonly bool IsObjCContainer => clang.index_isEntityObjCContainerKind(kind) != 0; } diff --git a/sources/ClangSharp.Interop/Extensions/CXIdxLoc.cs b/sources/ClangSharp.Interop/Extensions/CXIdxLoc.cs index 76aa7bd0..a431282f 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIdxLoc.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIdxLoc.cs @@ -4,9 +4,9 @@ namespace ClangSharp.Interop; public unsafe partial struct CXIdxLoc { - public CXSourceLocation SourceLocation => clang.indexLoc_getCXSourceLocation(this); + public readonly 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 readonly 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) diff --git a/sources/ClangSharp.Interop/Extensions/CXIndex.cs b/sources/ClangSharp.Interop/Extensions/CXIndex.cs index 6f23926e..249ea679 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIndex.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIndex.cs @@ -11,7 +11,7 @@ public CXIndex(IntPtr handle) Handle = handle; } - public CXGlobalOptFlags GlobalOptions + public readonly CXGlobalOptFlags GlobalOptions { get { @@ -36,15 +36,15 @@ public CXGlobalOptFlags GlobalOptions 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 readonly void Dispose() => clang.disposeIndex(this); - public override bool Equals(object? obj) => (obj is CXIndex other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXIndex other) && Equals(other); - public bool Equals(CXIndex other) => this == other; + public readonly bool Equals(CXIndex other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public void SetInvocationEmissionPathOption(string Path) + public readonly 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 75e6fa98..7f24dc25 100644 --- a/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs +++ b/sources/ClangSharp.Interop/Extensions/CXIndexAction.cs @@ -32,13 +32,13 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXIndexAction other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXIndexAction other) && Equals(other); - public bool Equals(CXIndexAction other) => this == other; + public readonly bool Equals(CXIndexAction other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly 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 readonly 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); @@ -53,7 +53,7 @@ public bool TryIndexSourceFile(CXClientData clientData, ReadOnlySpan indexCallbacks, CXIndexOptFlags indexOptions, string sourceFilename, ReadOnlySpan commandLineArgs, ReadOnlySpan unsavedFiles, out CXTranslationUnit tu, CXTranslationUnit_Flags tuOptions) + public readonly 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); @@ -68,7 +68,7 @@ public bool TryIndexSourceFileFullArgv(CXClientData clientData, ReadOnlySpan indexCallbacks, CXIndexOptFlags indexOptions, CXTranslationUnit tu) + public readonly bool TryIndexTranslationUnit(CXClientData clientData, ReadOnlySpan indexCallbacks, CXIndexOptFlags indexOptions, CXTranslationUnit tu) { fixed (IndexerCallbacks* pIndexCallbacks = indexCallbacks) { diff --git a/sources/ClangSharp.Interop/Extensions/CXModule.cs b/sources/ClangSharp.Interop/Extensions/CXModule.cs index 1b2f8925..0cc087dc 100644 --- a/sources/ClangSharp.Interop/Extensions/CXModule.cs +++ b/sources/ClangSharp.Interop/Extensions/CXModule.cs @@ -11,17 +11,17 @@ public CXModule(IntPtr handle) Handle = handle; } - public CXFile AstFile => (CXFile)clang.Module_getASTFile(this); + public readonly CXFile AstFile => (CXFile)clang.Module_getASTFile(this); - public CXString FullName => clang.Module_getFullName(this); + public readonly CXString FullName => clang.Module_getFullName(this); public IntPtr Handle { get; set; } - public bool IsSystem => clang.Module_isSystem(this) != 0; + public readonly bool IsSystem => clang.Module_isSystem(this) != 0; - public CXString Name => clang.Module_getName(this); + public readonly CXString Name => clang.Module_getName(this); - public CXModule Parent => (CXModule)clang.Module_getParent(this); + public readonly CXModule Parent => (CXModule)clang.Module_getParent(this); public static explicit operator CXModule(void* value) => new CXModule((IntPtr)value); @@ -31,15 +31,15 @@ public CXModule(IntPtr 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 readonly bool Equals(object? obj) => (obj is CXModule other) && Equals(other); - public bool Equals(CXModule other) => this == other; + public readonly bool Equals(CXModule other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public uint GetNumTopLevelHeaders(CXTranslationUnit translationUnit) => clang.Module_getNumTopLevelHeaders(translationUnit, this); + public readonly uint GetNumTopLevelHeaders(CXTranslationUnit translationUnit) => clang.Module_getNumTopLevelHeaders(translationUnit, this); - public CXFile GetTopLevelHeader(CXTranslationUnit translationUnit, uint index) => (CXFile)clang.Module_getTopLevelHeader(translationUnit, this, index); + public readonly CXFile GetTopLevelHeader(CXTranslationUnit translationUnit, uint index) => (CXFile)clang.Module_getTopLevelHeader(translationUnit, this, index); - public override string ToString() => FullName.ToString(); + public override readonly string ToString() => FullName.ToString(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs b/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs index bea305e2..2531311d 100644 --- a/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs +++ b/sources/ClangSharp.Interop/Extensions/CXModuleMapDescriptor.cs @@ -32,25 +32,25 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXModuleMapDescriptor other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXModuleMapDescriptor other) && Equals(other); - public bool Equals(CXModuleMapDescriptor other) => this == other; + public readonly bool Equals(CXModuleMapDescriptor other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public CXErrorCode SetFrameworkModuleName(string name) + public readonly CXErrorCode SetFrameworkModuleName(string name) { var marshaledName = new MarshaledString(name); return clang.ModuleMapDescriptor_setFrameworkModuleName(this, marshaledName); } - public CXErrorCode SetUmbrellaHeader(string name) + public readonly CXErrorCode SetUmbrellaHeader(string name) { using var marshaledName = new MarshaledString(name); return clang.ModuleMapDescriptor_setUmbrellaHeader(this, marshaledName); } - public Span WriteToBuffer(uint options, out CXErrorCode errorCode) + public readonly Span WriteToBuffer(uint options, out CXErrorCode errorCode) { sbyte* pBuffer; uint size; errorCode = clang.ModuleMapDescriptor_writeToBuffer(this, options, &pBuffer, &size); diff --git a/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs b/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs index a2414503..d4d6aa50 100644 --- a/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs +++ b/sources/ClangSharp.Interop/Extensions/CXPrintingPolicy.cs @@ -30,13 +30,13 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXPrintingPolicy other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXPrintingPolicy other) && Equals(other); - public bool Equals(CXPrintingPolicy other) => this == other; + public readonly bool Equals(CXPrintingPolicy other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public uint GetProperty(CXPrintingPolicyProperty property) => clang.PrintingPolicy_getProperty(this, property); + public readonly uint GetProperty(CXPrintingPolicyProperty property) => clang.PrintingPolicy_getProperty(this, property); - public void SetProperty(CXPrintingPolicyProperty property, uint value) => clang.PrintingPolicy_setProperty(this, property, value); + public readonly 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 bba0f1a4..6af3cc91 100644 --- a/sources/ClangSharp.Interop/Extensions/CXRemapping.cs +++ b/sources/ClangSharp.Interop/Extensions/CXRemapping.cs @@ -28,7 +28,7 @@ public static CXRemapping GetRemappingsFromFileList(ReadOnlySpan filePat public IntPtr Handle { get; set; } - public uint NumFiles => clang.remap_getNumFiles(this); + public readonly uint NumFiles => clang.remap_getNumFiles(this); public static explicit operator CXRemapping(void* value) => new CXRemapping((IntPtr)value); @@ -47,11 +47,11 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXRemapping other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXRemapping other) && Equals(other); - public bool Equals(CXRemapping other) => this == other; + public readonly bool Equals(CXRemapping other) => this == other; - public void GetFilenames(uint index, out CXString original, out CXString transformed) + public readonly void GetFilenames(uint index, out CXString original, out CXString transformed) { fixed (CXString* pOriginal = &original) fixed (CXString* pTransformed = &transformed) @@ -60,5 +60,5 @@ public void GetFilenames(uint index, out CXString original, out CXString transfo } } - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXSourceLocation.cs b/sources/ClangSharp.Interop/Extensions/CXSourceLocation.cs index 0feff371..ea9e6368 100644 --- a/sources/ClangSharp.Interop/Extensions/CXSourceLocation.cs +++ b/sources/ClangSharp.Interop/Extensions/CXSourceLocation.cs @@ -8,19 +8,19 @@ public unsafe partial struct CXSourceLocation : IEquatable { public static CXSourceLocation Null => clang.getNullLocation(); - public bool IsFromMainFile => clang.Location_isFromMainFile(this) != 0; + public readonly bool IsFromMainFile => clang.Location_isFromMainFile(this) != 0; - public bool IsInSystemHeader => clang.Location_isInSystemHeader(this) != 0; + public readonly 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 override bool Equals(object? obj) => (obj is CXSourceLocation other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXSourceLocation other) && Equals(other); - public bool Equals(CXSourceLocation other) => this == other; + public readonly bool Equals(CXSourceLocation other) => this == other; - public void GetExpansionLocation(out CXFile file, out uint line, out uint column, out uint offset) + public readonly void GetExpansionLocation(out CXFile file, out uint line, out uint column, out uint offset) { fixed (CXFile* pFile = &file) fixed (uint* pLine = &line) @@ -31,7 +31,7 @@ public void GetExpansionLocation(out CXFile file, out uint line, out uint column } } - public void GetFileLocation(out CXFile file, out uint line, out uint column, out uint offset) + public readonly void GetFileLocation(out CXFile file, out uint line, out uint column, out uint offset) { fixed (CXFile* pFile = &file) fixed (uint* pLine = &line) @@ -42,9 +42,9 @@ public void GetFileLocation(out CXFile file, out uint line, out uint column, out } } - public override int GetHashCode() => HashCode.Combine(ptr_data, int_data); + public override readonly int GetHashCode() => HashCode.Combine(ptr_data, int_data); - public void GetInstantiationLocation(out CXFile file, out uint line, out uint column, out uint offset) + public readonly void GetInstantiationLocation(out CXFile file, out uint line, out uint column, out uint offset) { fixed (CXFile* pFile = &file) fixed (uint* pLine = &line) @@ -55,7 +55,7 @@ public void GetInstantiationLocation(out CXFile file, out uint line, out uint co } } - public void GetPresumedLocation(out CXString fileName, out uint line, out uint column) + public readonly void GetPresumedLocation(out CXString fileName, out uint line, out uint column) { fixed (CXString* pFileName = &fileName) fixed (uint* pLine = &line) @@ -65,7 +65,7 @@ public void GetPresumedLocation(out CXString fileName, out uint line, out uint c } } - public void GetSpellingLocation(out CXFile file, out uint line, out uint column, out uint offset) + public readonly void GetSpellingLocation(out CXFile file, out uint line, out uint column, out uint offset) { fixed (CXFile* pFile = &file) fixed (uint* pLine = &line) @@ -76,7 +76,7 @@ public void GetSpellingLocation(out CXFile file, out uint line, out uint column, } } - public override string ToString() + public override readonly 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 cddc8587..4a23ec2a 100644 --- a/sources/ClangSharp.Interop/Extensions/CXSourceRange.cs +++ b/sources/ClangSharp.Interop/Extensions/CXSourceRange.cs @@ -8,11 +8,11 @@ public partial struct CXSourceRange : IEquatable { public static CXSourceRange Null => clang.getNullRange(); - public CXSourceLocation End => clang.getRangeEnd(this); + public readonly CXSourceLocation End => clang.getRangeEnd(this); - public bool IsNull => clang.Range_isNull(this) != 0; + public readonly bool IsNull => clang.Range_isNull(this) != 0; - public CXSourceLocation Start => clang.getRangeStart(this); + public readonly CXSourceLocation Start => clang.getRangeStart(this); public static bool operator ==(CXSourceRange left, CXSourceRange right) => Equals(left, right); @@ -22,11 +22,11 @@ public partial struct CXSourceRange : IEquatable 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 readonly bool Equals(object? obj) => (obj is CXSourceRange other) && Equals(other); - public bool Equals(CXSourceRange other) => this == other; + public readonly bool Equals(CXSourceRange other) => this == other; - public override int GetHashCode() => HashCode.Combine(ptr_data, begin_int_data, end_int_data); + public override readonly int GetHashCode() => HashCode.Combine(ptr_data, begin_int_data, end_int_data); - public override string ToString() => $"{Start} to {End}"; + public override readonly string ToString() => $"{Start} to {End}"; } diff --git a/sources/ClangSharp.Interop/Extensions/CXSourceRangeList.cs b/sources/ClangSharp.Interop/Extensions/CXSourceRangeList.cs index 475858ec..465260ab 100644 --- a/sources/ClangSharp.Interop/Extensions/CXSourceRangeList.cs +++ b/sources/ClangSharp.Interop/Extensions/CXSourceRangeList.cs @@ -10,7 +10,7 @@ public unsafe partial struct CXSourceRangeList : IDisposable, IReadOnlyCollectio { public unsafe CXSourceRange this[uint index] => ranges[index]; - public int Count => (int)count; + public readonly int Count => (int)count; public void Dispose() { diff --git a/sources/ClangSharp.Interop/Extensions/CXString.cs b/sources/ClangSharp.Interop/Extensions/CXString.cs index fbd33795..83d162ca 100644 --- a/sources/ClangSharp.Interop/Extensions/CXString.cs +++ b/sources/ClangSharp.Interop/Extensions/CXString.cs @@ -43,7 +43,7 @@ public static CXString ConstructUsr_ObjCProperty(string property, CXString class return clang.constructUSR_ObjCProperty(marshaledProperty, classUsr); } - public string CString + public readonly string CString { get { @@ -58,7 +58,7 @@ public string CString } } - public void Dispose() => clang.disposeString(this); + public readonly void Dispose() => clang.disposeString(this); - public override string ToString() => CString; + public override readonly string ToString() => CString; } diff --git a/sources/ClangSharp.Interop/Extensions/CXStringSet.cs b/sources/ClangSharp.Interop/Extensions/CXStringSet.cs index 9509db2e..f991e625 100644 --- a/sources/ClangSharp.Interop/Extensions/CXStringSet.cs +++ b/sources/ClangSharp.Interop/Extensions/CXStringSet.cs @@ -10,7 +10,7 @@ public unsafe partial struct CXStringSet : IDisposable, IReadOnlyCollection Strings[index]; - int IReadOnlyCollection.Count => (int)Count; + readonly int IReadOnlyCollection.Count => (int)Count; public void Dispose() { diff --git a/sources/ClangSharp.Interop/Extensions/CXTUResourceUsage.cs b/sources/ClangSharp.Interop/Extensions/CXTUResourceUsage.cs index ed272c9a..a1a39a79 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTUResourceUsage.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTUResourceUsage.cs @@ -10,9 +10,9 @@ public partial struct CXTUResourceUsage : IDisposable, IReadOnlyCollection entries[index]; - public int Count => (int)numEntries; + public readonly int Count => (int)numEntries; - public void Dispose() => clang.disposeCXTUResourceUsage(this); + public readonly void Dispose() => clang.disposeCXTUResourceUsage(this); public IEnumerator GetEnumerator() { diff --git a/sources/ClangSharp.Interop/Extensions/CXTUResourceUsageEntry.cs b/sources/ClangSharp.Interop/Extensions/CXTUResourceUsageEntry.cs index eb00a1b8..1ec24c02 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTUResourceUsageEntry.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTUResourceUsageEntry.cs @@ -4,7 +4,7 @@ namespace ClangSharp.Interop; public unsafe partial struct CXTUResourceUsageEntry { - public string Name + public readonly string Name { get { @@ -19,5 +19,5 @@ public string Name } } - public override string ToString() => Name; + public override readonly string ToString() => Name; } diff --git a/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs b/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs index 605f6f37..6ca98652 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTargetInfo.cs @@ -13,9 +13,9 @@ public CXTargetInfo(IntPtr handle) public IntPtr Handle { get; set; } - public int PointerWidth => clang.TargetInfo_getPointerWidth(this); + public readonly int PointerWidth => clang.TargetInfo_getPointerWidth(this); - public CXString Triple => clang.TargetInfo_getTriple(this); + public readonly CXString Triple => clang.TargetInfo_getTriple(this); public static implicit operator CXTargetInfo(CXTargetInfoImpl* value) => new CXTargetInfo((IntPtr)value); @@ -34,11 +34,11 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXTargetInfo other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXTargetInfo other) && Equals(other); - public bool Equals(CXTargetInfo other) => this == other; + public readonly bool Equals(CXTargetInfo other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public override string ToString() => Triple.ToString(); + public override readonly string ToString() => Triple.ToString(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXToken.cs b/sources/ClangSharp.Interop/Extensions/CXToken.cs index 62fcaf55..3ee5e844 100644 --- a/sources/ClangSharp.Interop/Extensions/CXToken.cs +++ b/sources/ClangSharp.Interop/Extensions/CXToken.cs @@ -6,7 +6,7 @@ namespace ClangSharp.Interop; public unsafe partial struct CXToken : IEquatable { - public CXTokenKind Kind => clang.getTokenKind(this); + public readonly CXTokenKind Kind => clang.getTokenKind(this); public static bool operator ==(CXToken left, CXToken right) { @@ -26,17 +26,17 @@ public unsafe partial struct CXToken : IEquatable (left.ptr_data != right.ptr_data); } - public override bool Equals(object? obj) => (obj is CXSourceRange other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXSourceRange other) && Equals(other); - public bool Equals(CXToken other) => this == other; + public readonly bool Equals(CXToken other) => this == other; - public CXSourceRange GetExtent(CXTranslationUnit translationUnit) => clang.getTokenExtent(translationUnit, this); + public readonly 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 CXSourceLocation GetLocation(CXTranslationUnit translationUnit) => clang.getTokenLocation(translationUnit, this); + public readonly CXSourceLocation GetLocation(CXTranslationUnit translationUnit) => clang.getTokenLocation(translationUnit, this); - public CXString GetSpelling(CXTranslationUnit translationUnit) => clang.getTokenSpelling(translationUnit, this); + public readonly CXString GetSpelling(CXTranslationUnit translationUnit) => clang.getTokenSpelling(translationUnit, this); - public override string ToString() => ""; + public override readonly string ToString() => ""; } diff --git a/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs b/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs index 7cfb391d..09739a27 100644 --- a/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs +++ b/sources/ClangSharp.Interop/Extensions/CXTranslationUnit.cs @@ -14,25 +14,25 @@ public CXTranslationUnit(IntPtr handle) public static CXTranslationUnit_Flags DefaultEditingOptions => (CXTranslationUnit_Flags)clang.defaultEditingTranslationUnitOptions(); - public CXSourceRangeList* AllSkippedRanges => clang.getAllSkippedRanges(this); + public readonly CXSourceRangeList* AllSkippedRanges => clang.getAllSkippedRanges(this); - public CXCursor Cursor => clang.getTranslationUnitCursor(this); + public readonly CXCursor Cursor => clang.getTranslationUnitCursor(this); - public CXReparse_Flags DefaultReparseOptions => (CXReparse_Flags)clang.defaultReparseOptions(this); + public readonly CXReparse_Flags DefaultReparseOptions => (CXReparse_Flags)clang.defaultReparseOptions(this); - public CXSaveTranslationUnit_Flags DefaultSaveOptions => (CXSaveTranslationUnit_Flags)clang.defaultSaveOptions(this); + public readonly CXSaveTranslationUnit_Flags DefaultSaveOptions => (CXSaveTranslationUnit_Flags)clang.defaultSaveOptions(this); - public CXDiagnosticSet DiagnosticSet => (CXDiagnosticSet)clang.getDiagnosticSetFromTU(this); + public readonly CXDiagnosticSet DiagnosticSet => (CXDiagnosticSet)clang.getDiagnosticSetFromTU(this); public IntPtr Handle { get; set; } - public uint NumDiagnostics => clang.getNumDiagnostics(this); + public readonly uint NumDiagnostics => clang.getNumDiagnostics(this); - public CXTUResourceUsage ResourceUsage => clang.getCXTUResourceUsage(this); + public readonly CXTUResourceUsage ResourceUsage => clang.getCXTUResourceUsage(this); - public CXString Spelling => clang.getTranslationUnitSpelling(this); + public readonly CXString Spelling => clang.getTranslationUnitSpelling(this); - public CXTargetInfo TargetInfo => clang.getTranslationUnitTargetInfo(this); + public readonly CXTargetInfo TargetInfo => clang.getTranslationUnitTargetInfo(this); public static implicit operator CXTranslationUnit(CXTranslationUnitImpl* value) => new CXTranslationUnit((IntPtr)value); @@ -112,7 +112,7 @@ public static CXErrorCode TryParseFullArgv(CXIndex index, string sourceFileName, } } - public void AnnotateTokens(ReadOnlySpan tokens, Span cursors) + public readonly void AnnotateTokens(ReadOnlySpan tokens, Span cursors) { fixed (CXToken* pTokens = tokens) fixed (CXCursor* pCursors = cursors) @@ -121,7 +121,7 @@ public void AnnotateTokens(ReadOnlySpan tokens, Span cursors) } } - public CXCodeCompleteResults* CodeCompleteAt(string completeFilename, uint completeLine, uint completeColumn, ReadOnlySpan unsavedFiles, CXCodeComplete_Flags options) + public readonly CXCodeCompleteResults* CodeCompleteAt(string completeFilename, uint completeLine, uint completeColumn, ReadOnlySpan unsavedFiles, CXCodeComplete_Flags options) { using var marshaledCompleteFilename = new MarshaledString(completeFilename); @@ -140,7 +140,7 @@ public void Dispose() } } - public void DisposeTokens(ReadOnlySpan tokens) + public readonly void DisposeTokens(ReadOnlySpan tokens) { fixed (CXToken* pTokens = tokens) { @@ -148,23 +148,23 @@ public void DisposeTokens(ReadOnlySpan tokens) } } - public override bool Equals(object? obj) => (obj is CXTranslationUnit other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXTranslationUnit other) && Equals(other); - public bool Equals(CXTranslationUnit other) => this == other; + public readonly bool Equals(CXTranslationUnit other) => this == other; - public CXResult FindIncludesInFile(CXFile file, CXCursorAndRangeVisitor visitor) => clang.findIncludesInFile(this, file, visitor); + public readonly CXResult FindIncludesInFile(CXFile file, CXCursorAndRangeVisitor visitor) => clang.findIncludesInFile(this, file, visitor); - public CXCursor GetCursor(CXSourceLocation location) => clang.getCursor(this, location); + public readonly CXCursor GetCursor(CXSourceLocation location) => clang.getCursor(this, location); - public CXDiagnostic GetDiagnostic(uint index) => (CXDiagnostic)clang.getDiagnostic(this, index); + public readonly CXDiagnostic GetDiagnostic(uint index) => (CXDiagnostic)clang.getDiagnostic(this, index); - public CXFile GetFile(string fileName) + public readonly CXFile GetFile(string fileName) { using var marshaledFileName = new MarshaledString(fileName); return GetFile(marshaledFileName.AsSpan()); } - public CXFile GetFile(ReadOnlySpan fileName) + public readonly CXFile GetFile(ReadOnlySpan fileName) { fixed (byte* pFileName = fileName) { @@ -172,7 +172,7 @@ public CXFile GetFile(ReadOnlySpan fileName) } } - public ReadOnlySpan GetFileContents(CXFile file, out UIntPtr size) + public readonly ReadOnlySpan GetFileContents(CXFile file, out UIntPtr size) { fixed (UIntPtr* pSize = &size) { @@ -181,33 +181,33 @@ public ReadOnlySpan GetFileContents(CXFile file, out UIntPtr size) } } - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public void GetInclusions(CXInclusionVisitor visitor, CXClientData clientData) + public readonly void GetInclusions(CXInclusionVisitor visitor, CXClientData clientData) { var pVisitor = (delegate* unmanaged[Cdecl])Marshal.GetFunctionPointerForDelegate(visitor); GetInclusions(pVisitor, clientData); GC.KeepAlive(visitor); } - public void GetInclusions(delegate* unmanaged[Cdecl] visitor, CXClientData clientData) + public readonly void GetInclusions(delegate* unmanaged[Cdecl] visitor, CXClientData clientData) { clang.getInclusions(this, visitor, clientData); } - public CXSourceLocation GetLocation(CXFile file, uint line, uint column) => clang.getLocation(this, file, line, column); + public readonly 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 readonly CXSourceLocation GetLocationForOffset(CXFile file, uint offset) => clang.getLocationForOffset(this, file, offset); - public CXModule GetModuleForFile(CXFile file) => (CXModule)clang.getModuleForFile(this, file); + public readonly CXModule GetModuleForFile(CXFile file) => (CXModule)clang.getModuleForFile(this, file); - public CXSourceRangeList* GetSkippedRanges(CXFile file) => clang.getSkippedRanges(this, file); + public readonly CXSourceRangeList* GetSkippedRanges(CXFile file) => clang.getSkippedRanges(this, file); - public CXToken* GetToken(CXSourceLocation sourceLocation) => clang.getToken(this, sourceLocation); + public readonly CXToken* GetToken(CXSourceLocation sourceLocation) => clang.getToken(this, sourceLocation); - public bool IsFileMultipleIncludeGuarded(CXFile file) => clang.isFileMultipleIncludeGuarded(this, file) != 0; + public readonly bool IsFileMultipleIncludeGuarded(CXFile file) => clang.isFileMultipleIncludeGuarded(this, file) != 0; - public CXErrorCode Reparse(ReadOnlySpan unsavedFiles, CXReparse_Flags options) + public readonly CXErrorCode Reparse(ReadOnlySpan unsavedFiles, CXReparse_Flags options) { fixed (CXUnsavedFile* pUnsavedFiles = unsavedFiles) { @@ -215,15 +215,15 @@ public CXErrorCode Reparse(ReadOnlySpan unsavedFiles, CXReparse_F } } - public CXSaveError Save(string fileName, CXSaveTranslationUnit_Flags options) + public readonly 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 readonly bool Suspend() => clang.suspendTranslationUnit(this) != 0; - public Span Tokenize(CXSourceRange sourceRange) + public readonly Span Tokenize(CXSourceRange sourceRange) { CXToken* pTokens; uint numTokens; clang.tokenize(this, sourceRange, &pTokens, &numTokens); @@ -243,5 +243,5 @@ public Span Tokenize(CXSourceRange sourceRange) #endif } - public override string ToString() => Spelling.ToString(); + public override readonly string ToString() => Spelling.ToString(); } diff --git a/sources/ClangSharp.Interop/Extensions/CXType.cs b/sources/ClangSharp.Interop/Extensions/CXType.cs index b99c833f..4430c0b7 100644 --- a/sources/ClangSharp.Interop/Extensions/CXType.cs +++ b/sources/ClangSharp.Interop/Extensions/CXType.cs @@ -11,123 +11,123 @@ namespace ClangSharp.Interop; [DebuggerDisplay("{DebuggerDisplayString,nq}")] public unsafe partial struct CXType : IEquatable { - public uint AddressSpace => (kind != CXType_Invalid) ? clang.getAddressSpace(this) : default; + public readonly uint AddressSpace => (kind != CXType_Invalid) ? clang.getAddressSpace(this) : default; - public CXCursor AddrSpaceExpr => clangsharp.Type_getAddrSpaceExpr(this); + public readonly CXCursor AddrSpaceExpr => clangsharp.Type_getAddrSpaceExpr(this); - public CXType AdjustedType => (kind != CXType_Invalid) ? clangsharp.Type_getAdjustedType(this) : default; + public readonly CXType AdjustedType => (kind != CXType_Invalid) ? clangsharp.Type_getAdjustedType(this) : default; - public long AlignOf => clang.Type_getAlignOf(this); + public readonly long AlignOf => clang.Type_getAlignOf(this); - public CXType ArrayElementType => clang.getArrayElementType(this); + public readonly CXType ArrayElementType => clang.getArrayElementType(this); - public long ArraySize => clang.getArraySize(this); + public readonly long ArraySize => clang.getArraySize(this); - public CX_AttrKind AttrKind => clangsharp.Type_getAttrKind(this); + public readonly CX_AttrKind AttrKind => clangsharp.Type_getAttrKind(this); - public CXType BaseType => clangsharp.Type_getBaseType(this); + public readonly CXType BaseType => clangsharp.Type_getBaseType(this); - public CXType CanonicalType => clang.getCanonicalType(this); + public readonly CXType CanonicalType => clang.getCanonicalType(this); - public CXType ClassType => clang.Type_getClassType(this); + public readonly CXType ClassType => clang.Type_getClassType(this); - public CXCursor ColumnExpr => clangsharp.Type_getColumnExpr(this); + public readonly CXCursor ColumnExpr => clangsharp.Type_getColumnExpr(this); - public CXRefQualifierKind CXXRefQualifier => clang.Type_getCXXRefQualifier(this); + public readonly CXRefQualifierKind CXXRefQualifier => clang.Type_getCXXRefQualifier(this); - public CXType DecayedType => clangsharp.Type_getDecayedType(this); + public readonly CXType DecayedType => clangsharp.Type_getDecayedType(this); - public CXCursor Declaration => (kind != CXType_Invalid) ? clangsharp.Type_getDeclaration(this) : default; + public readonly CXCursor Declaration => (kind != CXType_Invalid) ? clangsharp.Type_getDeclaration(this) : default; - public CXType DeducedType => (kind != CXType_Invalid) ? clangsharp.Type_getDeducedType(this) : default; + public readonly CXType DeducedType => (kind != CXType_Invalid) ? clangsharp.Type_getDeducedType(this) : default; - public int Depth => clangsharp.Type_getDepth(this); + public readonly int Depth => clangsharp.Type_getDepth(this); - public CXType Desugar => (kind != CXType_Invalid) ? clangsharp.Type_desugar(this) : default; + public readonly CXType Desugar => (kind != CXType_Invalid) ? clangsharp.Type_desugar(this) : default; - public CXType ElementType => (kind != CXType_Invalid) ? clangsharp.Type_getElementType(this) :default; + public readonly CXType ElementType => (kind != CXType_Invalid) ? clangsharp.Type_getElementType(this) :default; - public CXType EquivalentType => (kind != CXType_Invalid) ? clangsharp.Type_getEquivalentType(this) : default; + public readonly CXType EquivalentType => (kind != CXType_Invalid) ? clangsharp.Type_getEquivalentType(this) : default; - public CXCursor_ExceptionSpecificationKind ExceptionSpecificationType => (CXCursor_ExceptionSpecificationKind)clang.getExceptionSpecificationType(this); + public readonly CXCursor_ExceptionSpecificationKind ExceptionSpecificationType => (CXCursor_ExceptionSpecificationKind)clang.getExceptionSpecificationType(this); - public CXCallingConv FunctionTypeCallingConv => clang.getFunctionTypeCallingConv(this); + public readonly CXCallingConv FunctionTypeCallingConv => clang.getFunctionTypeCallingConv(this); - public int Index => clangsharp.Type_getIndex(this); + public readonly int Index => clangsharp.Type_getIndex(this); - public CXType InjectedSpecializationType => (kind != CXType_Invalid) ? clangsharp.Type_getInjectedSpecializationType(this) : default; + public readonly CXType InjectedSpecializationType => (kind != CXType_Invalid) ? clangsharp.Type_getInjectedSpecializationType(this) : default; - public CXType InjectedTST => (kind != CXType_Invalid) ? clangsharp.Type_getInjectedTST(this) : default; + public readonly CXType InjectedTST => (kind != CXType_Invalid) ? clangsharp.Type_getInjectedTST(this) : default; - public bool IsCanonical => Equals(CanonicalType); + public readonly bool IsCanonical => Equals(CanonicalType); - public bool IsConstQualified => clang.isConstQualifiedType(this) != 0; + public readonly bool IsConstQualified => clang.isConstQualifiedType(this) != 0; - public bool IsFunctionTypeVariadic => clang.isFunctionTypeVariadic(this) != 0; + public readonly bool IsFunctionTypeVariadic => clang.isFunctionTypeVariadic(this) != 0; - public bool IsPODType => clang.isPODType(this) != 0; + public readonly bool IsPODType => clang.isPODType(this) != 0; - public bool IsRestrictQualified => clang.isRestrictQualifiedType(this) != 0; + public readonly bool IsRestrictQualified => clang.isRestrictQualifiedType(this) != 0; - public bool IsSigned => clangsharp.Type_getIsSigned(this) != 0; + public readonly bool IsSigned => clangsharp.Type_getIsSigned(this) != 0; - public bool IsSugared => (kind != CXType_Invalid) && clangsharp.Type_getIsSugared(this) != 0; + public readonly bool IsSugared => (kind != CXType_Invalid) && clangsharp.Type_getIsSugared(this) != 0; - public bool IsTransparentTagTypedef => clang.Type_isTransparentTagTypedef(this) != 0; + public readonly bool IsTransparentTagTypedef => clang.Type_isTransparentTagTypedef(this) != 0; - public bool IsTypeAlias => clangsharp.Type_getIsTypeAlias(this) != 0; + public readonly bool IsTypeAlias => clangsharp.Type_getIsTypeAlias(this) != 0; - public bool IsUnsigned => clangsharp.Type_getIsUnsigned(this) != 0; + public readonly bool IsUnsigned => clangsharp.Type_getIsUnsigned(this) != 0; - public bool IsVolatileQualified => clang.isVolatileQualifiedType(this) != 0; + public readonly bool IsVolatileQualified => clang.isVolatileQualifiedType(this) != 0; - public CXString KindSpelling => clang.getTypeKindSpelling(kind); + public readonly CXString KindSpelling => clang.getTypeKindSpelling(kind); - public CXType ModifiedType => clangsharp.Type_getModifiedType(this); + public readonly CXType ModifiedType => clangsharp.Type_getModifiedType(this); - public CXType NamedType => clang.Type_getNamedType(this); + public readonly CXType NamedType => clang.Type_getNamedType(this); - public CXType NonReferenceType => (kind != CXType_Invalid) ? clang.getNonReferenceType(this) : default; + public readonly CXType NonReferenceType => (kind != CXType_Invalid) ? clang.getNonReferenceType(this) : default; - public CXTypeNullabilityKind Nullability => clang.Type_getNullability(this); + public readonly CXTypeNullabilityKind Nullability => clang.Type_getNullability(this); - public int NumArgTypes => clang.getNumArgTypes(this); + public readonly int NumArgTypes => clang.getNumArgTypes(this); - public int NumBits => clangsharp.Type_getNumBits(this); + public readonly int NumBits => clangsharp.Type_getNumBits(this); - public CXCursor NumBitsExpr => clangsharp.Type_getNumBitsExpr(this); + public readonly CXCursor NumBitsExpr => clangsharp.Type_getNumBitsExpr(this); - public int NumColumns => clangsharp.Type_getNumColumns(this); + public readonly int NumColumns => clangsharp.Type_getNumColumns(this); - public int NumElementsFlattened => clangsharp.Type_getNumElementsFlattened(this); + public readonly int NumElementsFlattened => clangsharp.Type_getNumElementsFlattened(this); - public int NumRows => clangsharp.Type_getNumRows(this); + public readonly int NumRows => clangsharp.Type_getNumRows(this); - public long NumElements => clang.getNumElements(this); + public readonly long NumElements => clang.getNumElements(this); - public uint NumObjCProtocolRefs => clang.Type_getNumObjCProtocolRefs(this); + public readonly uint NumObjCProtocolRefs => clang.Type_getNumObjCProtocolRefs(this); - public uint NumObjCTypeArgs => clang.Type_getNumObjCTypeArgs(this); + public readonly uint NumObjCTypeArgs => clang.Type_getNumObjCTypeArgs(this); - public int NumTemplateArguments => clang.Type_getNumTemplateArguments(this); + public readonly int NumTemplateArguments => clang.Type_getNumTemplateArguments(this); - public CXType ObjCObjectBaseType => clang.Type_getObjCObjectBaseType(this); + public readonly CXType ObjCObjectBaseType => clang.Type_getObjCObjectBaseType(this); - public CXType OriginalType => (kind != CXType_Invalid) ? clangsharp.Type_getOriginalType(this) : default; + public readonly CXType OriginalType => (kind != CXType_Invalid) ? clangsharp.Type_getOriginalType(this) : default; - public CXCursor OwnedTagDecl => (kind != CXType_Invalid) ? clangsharp.Type_getOwnedTagDecl(this) : default; + public readonly CXCursor OwnedTagDecl => (kind != CXType_Invalid) ? clangsharp.Type_getOwnedTagDecl(this) : default; - public CXType PointeeType => (kind != CXType_Invalid) ? clangsharp.Type_getPointeeType(this) : default; + public readonly CXType PointeeType => (kind != CXType_Invalid) ? clangsharp.Type_getPointeeType(this) : default; - public CXType ResultType => clang.getResultType(this); + public readonly CXType ResultType => clang.getResultType(this); - public CXCursor RowExpr => (kind != CXType_Invalid) ? clangsharp.Type_getRowExpr(this) : default; + public readonly CXCursor RowExpr => (kind != CXType_Invalid) ? clangsharp.Type_getRowExpr(this) : default; - public CXCursor SizeExpr => (kind != CXType_Invalid) ? clangsharp.Type_getSizeExpr(this) : default; + public readonly CXCursor SizeExpr => (kind != CXType_Invalid) ? clangsharp.Type_getSizeExpr(this) : default; - public long SizeOf => clang.Type_getSizeOf(this); + public readonly long SizeOf => clang.Type_getSizeOf(this); - public CXString Spelling => (kind != CXType_Invalid) ? clang.getTypeSpelling(this) : default; + public readonly CXString Spelling => (kind != CXType_Invalid) ? clang.getTypeSpelling(this) : default; public CX_TemplateName TemplateName { @@ -139,9 +139,9 @@ public CX_TemplateName TemplateName } } - public CX_TypeClass TypeClass => clangsharp.Type_getTypeClass(this); + public readonly CX_TypeClass TypeClass => clangsharp.Type_getTypeClass(this); - public string TypeClassSpelling + public readonly string TypeClassSpelling { get { @@ -210,47 +210,47 @@ public string TypeClassSpelling } } - public CXString TypedefName => (kind != CXType_Invalid) ? clang.getTypedefName(this) : default; + public readonly CXString TypedefName => (kind != CXType_Invalid) ? clang.getTypedefName(this) : default; - public CXCursor UnderlyingExpr => (kind != CXType_Invalid) ? clangsharp.Type_getUnderlyingExpr(this) : default; + public readonly CXCursor UnderlyingExpr => (kind != CXType_Invalid) ? clangsharp.Type_getUnderlyingExpr(this) : default; - public CXType UnderlyingType => (kind != CXType_Invalid) ? clangsharp.Type_getUnderlyingType(this) : default; + public readonly CXType UnderlyingType => (kind != CXType_Invalid) ? clangsharp.Type_getUnderlyingType(this) : default; - public CXType UnqualifiedType => (kind != CXType_Invalid) ? clang.getUnqualifiedType(this) : default; + public readonly CXType UnqualifiedType => (kind != CXType_Invalid) ? clang.getUnqualifiedType(this) : default; - public CXType ValueType => clang.Type_getValueType(this); + public readonly CXType ValueType => clang.Type_getValueType(this); - internal string DebuggerDisplayString => $"{TypeClassSpelling}: {this}"; + internal readonly 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 override bool Equals(object? obj) => (obj is CXType other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXType other) && Equals(other); - public bool Equals(CXType other) => this == other; + public readonly bool Equals(CXType other) => this == other; - public CXType GetArgType(uint i) => clang.getArgType(this, i); + public readonly CXType GetArgType(uint i) => clang.getArgType(this, i); public override int GetHashCode() => HashCode.Combine(kind, (IntPtr)data[0], (IntPtr)data[1]); - public CXString GetObjCEncoding() => clang.Type_getObjCEncoding(this); + public readonly CXString GetObjCEncoding() => clang.Type_getObjCEncoding(this); - public CXCursor GetObjCProtocolDecl(uint i) => clang.Type_getObjCProtocolDecl(this, i); + public readonly CXCursor GetObjCProtocolDecl(uint i) => clang.Type_getObjCProtocolDecl(this, i); - public CXType GetObjCTypeArg(uint i) => clang.Type_getObjCTypeArg(this, i); + public readonly CXType GetObjCTypeArg(uint i) => clang.Type_getObjCTypeArg(this, i); - public long GetOffsetOf(string s) + public readonly 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 readonly CX_TemplateArgument GetTemplateArgument(uint i) => clangsharp.Type_getTemplateArgument(this, i); - public override string ToString() => Spelling.ToString(); + public override readonly string ToString() => Spelling.ToString(); - public CXVisitorResult VisitFields(CXFieldVisitor visitor, CXClientData clientData) + public readonly CXVisitorResult VisitFields(CXFieldVisitor visitor, CXClientData clientData) { var pVisitor = (delegate* unmanaged[Cdecl])Marshal.GetFunctionPointerForDelegate(visitor); var result = VisitFields(pVisitor, clientData); @@ -259,7 +259,7 @@ public CXVisitorResult VisitFields(CXFieldVisitor visitor, CXClientData clientDa return result; } - public CXVisitorResult VisitFields(delegate* unmanaged[Cdecl] visitor, CXClientData clientData) + public readonly CXVisitorResult VisitFields(delegate* unmanaged[Cdecl] visitor, CXClientData clientData) { return (CXVisitorResult)clang.Type_visitFields(this, visitor, clientData); } diff --git a/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs b/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs index 2a14565b..77917126 100644 --- a/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs +++ b/sources/ClangSharp.Interop/Extensions/CXUnsavedFile.cs @@ -64,9 +64,9 @@ public void Dispose() } } - public ReadOnlySpan ContentsSpan => new ReadOnlySpan(Contents, (int)Length); + public readonly ReadOnlySpan ContentsSpan => new ReadOnlySpan(Contents, (int)Length); - public string FilenameString + public readonly string FilenameString { get { diff --git a/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs b/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs index 208737dd..bdf8c07c 100644 --- a/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs +++ b/sources/ClangSharp.Interop/Extensions/CXVirtualFileOverlay.cs @@ -23,7 +23,7 @@ public CXVirtualFileOverlay(IntPtr handle) public static CXVirtualFileOverlay Create(uint options) => clang.VirtualFileOverlay_create(options); - public CXErrorCode AddFileMapping(string? virtualPath, string? realPath) + public readonly CXErrorCode AddFileMapping(string? virtualPath, string? realPath) { using var marshaledVirtualPath = new MarshaledString(virtualPath); using var marshaledRealPath = new MarshaledString(realPath); @@ -39,15 +39,15 @@ public void Dispose() } } - public override bool Equals(object? obj) => (obj is CXVirtualFileOverlay other) && Equals(other); + public override readonly bool Equals(object? obj) => (obj is CXVirtualFileOverlay other) && Equals(other); - public bool Equals(CXVirtualFileOverlay other) => this == other; + public readonly bool Equals(CXVirtualFileOverlay other) => this == other; - public override int GetHashCode() => Handle.GetHashCode(); + public override readonly int GetHashCode() => Handle.GetHashCode(); - public CXErrorCode SetCaseSensitivity(bool caseSensitive) => clang.VirtualFileOverlay_setCaseSensitivity(this, caseSensitive ? 1 : 0); + public readonly CXErrorCode SetCaseSensitivity(bool caseSensitive) => clang.VirtualFileOverlay_setCaseSensitivity(this, caseSensitive ? 1 : 0); - public Span WriteToBuffer(uint options, out CXErrorCode errorCode) + public readonly Span WriteToBuffer(uint options, out CXErrorCode errorCode) { sbyte* pBuffer; uint size; errorCode = clang.VirtualFileOverlay_writeToBuffer(this, options, &pBuffer, &size); diff --git a/sources/ClangSharp.Interop/Extensions/CX_TemplateArgument.cs b/sources/ClangSharp.Interop/Extensions/CX_TemplateArgument.cs index 2dcf942e..c45baac1 100644 --- a/sources/ClangSharp.Interop/Extensions/CX_TemplateArgument.cs +++ b/sources/ClangSharp.Interop/Extensions/CX_TemplateArgument.cs @@ -6,33 +6,33 @@ namespace ClangSharp.Interop; public unsafe partial struct CX_TemplateArgument : IDisposable { - public CXCursor AsDecl => clangsharp.TemplateArgument_getAsDecl(this); + public readonly CXCursor AsDecl => clangsharp.TemplateArgument_getAsDecl(this); - public CXCursor AsExpr => clangsharp.TemplateArgument_getAsExpr(this); + public readonly CXCursor AsExpr => clangsharp.TemplateArgument_getAsExpr(this); - public long AsIntegral => clangsharp.TemplateArgument_getAsIntegral(this); + public readonly long AsIntegral => clangsharp.TemplateArgument_getAsIntegral(this); - public CX_TemplateName AsTemplate => clangsharp.TemplateArgument_getAsTemplate(this); + public readonly CX_TemplateName AsTemplate => clangsharp.TemplateArgument_getAsTemplate(this); - public CX_TemplateName AsTemplateOrTemplatePattern => clangsharp.TemplateArgument_getAsTemplateOrTemplatePattern(this); + public readonly CX_TemplateName AsTemplateOrTemplatePattern => clangsharp.TemplateArgument_getAsTemplateOrTemplatePattern(this); - public CXType AsType => clangsharp.TemplateArgument_getAsType(this); + public readonly CXType AsType => clangsharp.TemplateArgument_getAsType(this); - public CX_TemplateArgumentDependence Dependence => clangsharp.TemplateArgument_getDependence(this); + public readonly CX_TemplateArgumentDependence Dependence => clangsharp.TemplateArgument_getDependence(this); - public CXType IntegralType => clangsharp.TemplateArgument_getIntegralType(this); + public readonly CXType IntegralType => clangsharp.TemplateArgument_getIntegralType(this); - public CXType NonTypeTemplateArgumentType => clangsharp.TemplateArgument_getNonTypeTemplateArgumentType(this); + public readonly CXType NonTypeTemplateArgumentType => clangsharp.TemplateArgument_getNonTypeTemplateArgumentType(this); - public CXType NullPtrType => clangsharp.TemplateArgument_getNullPtrType(this); + public readonly CXType NullPtrType => clangsharp.TemplateArgument_getNullPtrType(this); - public int NumPackElements => clangsharp.TemplateArgument_getNumPackElements(this); + public readonly int NumPackElements => clangsharp.TemplateArgument_getNumPackElements(this); - public CX_TemplateArgument PackExpansionPattern => clangsharp.TemplateArgument_getPackExpansionPattern(this); + public readonly CX_TemplateArgument PackExpansionPattern => clangsharp.TemplateArgument_getPackExpansionPattern(this); - public CXType ParamTypeForDecl => clangsharp.TemplateArgument_getParamTypeForDecl(this); + public readonly CXType ParamTypeForDecl => clangsharp.TemplateArgument_getParamTypeForDecl(this); - public CX_TemplateArgument GetPackElement(uint i) => clangsharp.TemplateArgument_getPackElement(this, i); + public readonly CX_TemplateArgument GetPackElement(uint i) => clangsharp.TemplateArgument_getPackElement(this, i); - public void Dispose() => clangsharp.TemplateArgument_dispose(this); + public readonly 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 2b7e43af..d2d2373f 100644 --- a/sources/ClangSharp.Interop/Extensions/CX_TemplateArgumentLoc.cs +++ b/sources/ClangSharp.Interop/Extensions/CX_TemplateArgumentLoc.cs @@ -4,19 +4,19 @@ namespace ClangSharp.Interop; public unsafe partial struct CX_TemplateArgumentLoc { - public CX_TemplateArgument Argument => clangsharp.TemplateArgumentLoc_getArgument(this); + public readonly CX_TemplateArgument Argument => clangsharp.TemplateArgumentLoc_getArgument(this); - public CXSourceLocation Location => clangsharp.TemplateArgumentLoc_getLocation(this); + public readonly CXSourceLocation Location => clangsharp.TemplateArgumentLoc_getLocation(this); - public CXCursor SourceDeclExpression => clangsharp.TemplateArgumentLoc_getSourceDeclExpression(this); + public readonly CXCursor SourceDeclExpression => clangsharp.TemplateArgumentLoc_getSourceDeclExpression(this); - public CXCursor SourceExpression => clangsharp.TemplateArgumentLoc_getSourceExpression(this); + public readonly CXCursor SourceExpression => clangsharp.TemplateArgumentLoc_getSourceExpression(this); - public CXCursor SourceIntegralExpression => clangsharp.TemplateArgumentLoc_getSourceIntegralExpression(this); + public readonly CXCursor SourceIntegralExpression => clangsharp.TemplateArgumentLoc_getSourceIntegralExpression(this); - public CXCursor SourceNullPtrExpression => clangsharp.TemplateArgumentLoc_getSourceNullPtrExpression(this); + public readonly CXCursor SourceNullPtrExpression => clangsharp.TemplateArgumentLoc_getSourceNullPtrExpression(this); - public CXSourceRange SourceRange => clangsharp.TemplateArgumentLoc_getSourceRange(this); + public readonly CXSourceRange SourceRange => clangsharp.TemplateArgumentLoc_getSourceRange(this); - public CXSourceRange SourceRangeRaw => clangsharp.TemplateArgumentLoc_getSourceRangeRaw(this); + public readonly CXSourceRange SourceRangeRaw => clangsharp.TemplateArgumentLoc_getSourceRangeRaw(this); } diff --git a/sources/ClangSharp.Interop/Extensions/CX_TemplateName.cs b/sources/ClangSharp.Interop/Extensions/CX_TemplateName.cs index b2a35743..7545485c 100644 --- a/sources/ClangSharp.Interop/Extensions/CX_TemplateName.cs +++ b/sources/ClangSharp.Interop/Extensions/CX_TemplateName.cs @@ -5,5 +5,5 @@ namespace ClangSharp.Interop; public unsafe partial struct CX_TemplateName { - public CXCursor AsTemplateDecl => clangsharp.TemplateName_getAsTemplateDecl(this); + public readonly CXCursor AsTemplateDecl => clangsharp.TemplateName_getAsTemplateDecl(this); } diff --git a/sources/ClangSharp.Interop/Extensions/clang.ResolveLibrary.cs b/sources/ClangSharp.Interop/Extensions/clang.ResolveLibrary.cs deleted file mode 100644 index ef1759eb..00000000 --- a/sources/ClangSharp.Interop/Extensions/clang.ResolveLibrary.cs +++ /dev/null @@ -1,77 +0,0 @@ -// 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; - -public static unsafe partial class @clang -{ - public static event DllImportResolver? ResolveLibrary; - - static @clang() - { - NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), OnDllImport); - } - - private static IntPtr OnDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) - { - var result = 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; - - if (result == IntPtr.Zero) - { - Console.WriteLine(); - Console.WriteLine("*****IMPORTANT*****"); - Console.WriteLine($"Failed to resolve {libraryName}."); - Console.WriteLine("If you are running as a dotnet tool, you may need to manually copy the appropriate DLLs from NuGet due to limitations in the dotnet tool support. Please see https://github.com/dotnet/clangsharp for more details."); - Console.WriteLine("*****IMPORTANT*****"); - Console.WriteLine(); - } - return result; - } - - private static bool TryResolveClang(Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) - { - return (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libclang.so.16", assembly, searchPath, out nativeLibrary)) - || (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && NativeLibrary.TryLoad("libclang-16", 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 TryResolveLibrary(string libraryName, Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) - { - var resolveLibrary = ResolveLibrary; - - if (resolveLibrary != null) - { - var resolvers = resolveLibrary.GetInvocationList(); - - foreach (DllImportResolver resolver in resolvers.Cast()) - { - try - { - nativeLibrary = resolver(libraryName, assembly, searchPath); - } - catch - { - nativeLibrary = IntPtr.Zero; - } - - if (nativeLibrary != IntPtr.Zero) - { - return true; - } - } - } - - nativeLibrary = IntPtr.Zero; - return false; - } -} diff --git a/sources/ClangSharp.Interop/ILLink.Substitutions.xml b/sources/ClangSharp.Interop/ILLink.Substitutions.xml new file mode 100644 index 00000000..b68e458b --- /dev/null +++ b/sources/ClangSharp.Interop/ILLink.Substitutions.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sources/ClangSharp.Interop/Internals/MarshaledString.cs b/sources/ClangSharp.Interop/Internals/MarshaledString.cs index 919467d6..1d6c64dc 100644 --- a/sources/ClangSharp.Interop/Internals/MarshaledString.cs +++ b/sources/ClangSharp.Interop/Internals/MarshaledString.cs @@ -31,7 +31,7 @@ public MarshaledString(string? input) Value = (sbyte*)value; } - public ReadOnlySpan AsSpan() => new ReadOnlySpan(Value, Length); + public readonly ReadOnlySpan AsSpan() => new ReadOnlySpan(Value, Length); public int Length { get; private set; } @@ -49,7 +49,7 @@ public void Dispose() public static implicit operator sbyte*(in MarshaledString value) => value.Value; - public override string ToString() + public override readonly 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 7f20c70a..c0b74151 100644 --- a/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs +++ b/sources/ClangSharp.Interop/Internals/MarshaledStringArray.cs @@ -25,7 +25,7 @@ public MarshaledStringArray(ReadOnlySpan inputs) } } - public ReadOnlySpan Values => _values; + public readonly ReadOnlySpan Values => _values; public void Dispose() { @@ -40,7 +40,7 @@ public void Dispose() } } - public void Fill(sbyte** pDestination) + public readonly void Fill(sbyte** pDestination) { if (_values != null) { diff --git a/sources/ClangSharp.Interop/clang.cs b/sources/ClangSharp.Interop/clang.cs new file mode 100644 index 00000000..d82c9b45 --- /dev/null +++ b/sources/ClangSharp.Interop/clang.cs @@ -0,0 +1,79 @@ +// 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; + +public static unsafe partial class @clang +{ + public static event DllImportResolver? ResolveLibrary; + + static @clang() + { + if (!Configuration.DisableResolveLibraryHook) + { + NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), OnDllImport); + } + } + + private static IntPtr OnDllImport(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) + { + if (TryResolveLibrary(libraryName, assembly, searchPath, out var nativeLibrary)) + { + return nativeLibrary; + } + + if (libraryName.Equals("libclang") && TryResolveClang(assembly, searchPath, out nativeLibrary)) + { + return nativeLibrary; + } + + Console.WriteLine(); + Console.WriteLine("*****IMPORTANT*****"); + Console.WriteLine($"Failed to resolve {libraryName}."); + Console.WriteLine("If you are running as a dotnet tool, you may need to manually copy the appropriate DLLs from NuGet due to limitations in the dotnet tool support. Please see https://github.com/dotnet/clangsharp for more details."); + Console.WriteLine("*****IMPORTANT*****"); + Console.WriteLine(); + + return IntPtr.Zero; + } + + private static bool TryResolveClang(Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + return NativeLibrary.TryLoad("libclang.so.16", assembly, searchPath, out nativeLibrary) + || NativeLibrary.TryLoad("libclang-16", assembly, searchPath, out nativeLibrary) + || NativeLibrary.TryLoad("libclang.so.1", assembly, searchPath, out nativeLibrary); + } + + nativeLibrary = IntPtr.Zero; + return false; + } + + private static bool TryResolveLibrary(string libraryName, Assembly assembly, DllImportSearchPath? searchPath, out IntPtr nativeLibrary) + { + var resolveLibrary = ResolveLibrary; + + if (resolveLibrary is not null) + { + var resolvers = resolveLibrary.GetInvocationList().Cast(); + + foreach (DllImportResolver resolver in resolvers) + { + nativeLibrary = resolver(libraryName, assembly, searchPath); + + if (nativeLibrary != IntPtr.Zero) + { + return true; + } + } + } + + nativeLibrary = IntPtr.Zero; + return false; + } +} diff --git a/sources/ClangSharp.Interop/clang/clang.cs b/sources/ClangSharp.Interop/clang/clang.cs index c4539224..1cb1431d 100644 --- a/sources/ClangSharp.Interop/clang/clang.cs +++ b/sources/ClangSharp.Interop/clang/clang.cs @@ -151,7 +151,7 @@ public static unsafe partial class @clang public static extern uint getDiagnosticCategory([NativeTypeName("CXDiagnostic")] void* param0); [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticCategoryName", ExactSpelling = true)] - [Obsolete] + [Obsolete("https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#gaf3d608c7860a57ce6571a3b03b4ead33")] public static extern CXString getDiagnosticCategoryName([NativeTypeName("unsigned int")] uint Category); [DllImport("libclang", CallingConvention = CallingConvention.Cdecl, EntryPoint = "clang_getDiagnosticCategoryText", ExactSpelling = true)] diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumDesc.cs index 9dfd2cd7..57d5a8d2 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/EnumDesc.cs @@ -14,7 +14,7 @@ public struct EnumDesc public bool IsNested { - get + readonly get { return (Flags & EnumFlags.Nested) != 0; } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/FunctionOrDelegateDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/FunctionOrDelegateDesc.cs index 5bdbf137..555dae8f 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/FunctionOrDelegateDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/FunctionOrDelegateDesc.cs @@ -25,7 +25,7 @@ internal struct FunctionOrDelegateDesc public bool IsVirtual { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsVirtual) != 0; } @@ -38,7 +38,7 @@ public bool IsVirtual public bool IsDllImport { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsDllImport) != 0; } @@ -53,7 +53,7 @@ public bool IsDllImport public bool IsManualImport { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsManualImport) != 0; } @@ -68,7 +68,7 @@ public bool IsManualImport public bool HasFnPtrCodeGen { - get + readonly get { return (Flags & FunctionOrDelegateFlags.HasFnPtrCodeGen) != 0; } @@ -83,7 +83,7 @@ public bool HasFnPtrCodeGen public bool IsAggressivelyInlined { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsAggressivelyInlined) != 0; } @@ -98,7 +98,7 @@ public bool IsAggressivelyInlined public bool SetLastError { - get + readonly get { return (Flags & FunctionOrDelegateFlags.SetLastError) != 0; } @@ -113,7 +113,7 @@ public bool SetLastError public bool IsCxx { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsCxx) != 0; } @@ -126,7 +126,7 @@ public bool IsCxx public bool NeedsNewKeyword { - get + readonly get { return (Flags & FunctionOrDelegateFlags.NeedsNewKeyword) != 0; } @@ -141,7 +141,7 @@ public bool NeedsNewKeyword public bool IsUnsafe { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsUnsafe) != 0; } @@ -154,7 +154,7 @@ public bool IsUnsafe public bool IsCtxCxxRecord { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsCtxCxxRecord) != 0; } @@ -169,7 +169,7 @@ public bool IsCtxCxxRecord public bool IsCxxRecordCtxUnsafe { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsCxxRecordCtxUnsafe) != 0; } @@ -184,7 +184,7 @@ public bool IsCxxRecordCtxUnsafe public bool IsMemberFunction { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsMemberFunction) != 0; } @@ -199,7 +199,7 @@ public bool IsMemberFunction public bool? IsStatic { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsStatic) != 0 ? true @@ -219,7 +219,7 @@ public bool? IsStatic public bool NeedsReturnFixup { - get + readonly get { return (Flags & FunctionOrDelegateFlags.NeedsReturnFixup) != 0; } @@ -234,7 +234,7 @@ public bool NeedsReturnFixup public bool IsCxxConstructor { - get + readonly get { return (Flags & FunctionOrDelegateFlags.IsCxxConstructor) != 0; } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/StructDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/StructDesc.cs index a63b3c65..60357236 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/StructDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/StructDesc.cs @@ -20,7 +20,7 @@ internal struct StructDesc public bool IsNested { - get + readonly get { return (Flags & StructFlags.Nested) != 0; } @@ -33,7 +33,7 @@ public bool IsNested public bool IsUnsafe { - get + readonly get { return (Flags & StructFlags.Unsafe) != 0; } @@ -46,7 +46,7 @@ public bool IsUnsafe public bool HasVtbl { - get + readonly get { return (Flags & StructFlags.Vtbl) != 0; } @@ -59,7 +59,7 @@ public bool HasVtbl public bool IsUnion { - get + readonly get { return (Flags & StructFlags.Union) != 0; } @@ -73,7 +73,7 @@ public bool IsUnion public Action WriteCustomAttrs { get; set; } public object CustomAttrGeneratorData { get; set; } - public StructLayoutAttribute? LayoutAttribute + public readonly StructLayoutAttribute? LayoutAttribute { get { @@ -82,16 +82,10 @@ public StructLayoutAttribute? LayoutAttribute if (IsUnion) { Debug.Assert(layout.Kind == LayoutKind.Explicit); - - return new StructLayoutAttribute(layout.Kind); - } - - if (layout.Pack is not null) - { return new StructLayoutAttribute(layout.Kind); } - return null; + return layout.Pack is not null ? new StructLayoutAttribute(layout.Kind) : null; } } diff --git a/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueDesc.cs b/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueDesc.cs index a400e2db..60a96f2a 100644 --- a/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueDesc.cs +++ b/sources/ClangSharp.PInvokeGenerator/Abstractions/ValueDesc.cs @@ -17,10 +17,10 @@ internal struct ValueDesc 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 readonly bool HasInitializer => Flags.HasFlag(ValueFlags.Initializer); + public readonly bool IsArray => Flags.HasFlag(ValueFlags.Array); + public readonly bool IsConstant => Flags.HasFlag(ValueFlags.Constant); + public readonly bool IsCopy => Flags.HasFlag(ValueFlags.Copy); public Action WriteCustomAttrs { get; set; } public object CustomAttrGeneratorData { get; set; } } diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs index 8d3c31e6..c2f7a2fb 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs @@ -22,6 +22,10 @@ public void WriteCustomAttribute(string attribute, Action? callback = null) { AddUsingDirective("System.Diagnostics.CodeAnalysis"); } + else if (attribute.StartsWith("InlineArray(")) + { + AddUsingDirective("System.Runtime.CompilerServices"); + } else if (attribute.StartsWith("Guid(")|| attribute.Equals("Optional") || attribute.StartsWith("Optional, DefaultParameterValue(")) { AddUsingDirective("System.Runtime.InteropServices"); diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs index 1a321b09..b0970c64 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.VisitDecl.cs @@ -952,7 +952,7 @@ public void EndDereference() // nop, used only by XML } - private string GetAccessSpecifierString(AccessSpecifier accessSpecifier, bool isNested) + private static string GetAccessSpecifierString(AccessSpecifier accessSpecifier, bool isNested) { switch (accessSpecifier) { diff --git a/sources/ClangSharp.PInvokeGenerator/ClangSharp.PInvokeGenerator.csproj b/sources/ClangSharp.PInvokeGenerator/ClangSharp.PInvokeGenerator.csproj index 26e4eef3..d2790af9 100644 --- a/sources/ClangSharp.PInvokeGenerator/ClangSharp.PInvokeGenerator.csproj +++ b/sources/ClangSharp.PInvokeGenerator/ClangSharp.PInvokeGenerator.csproj @@ -3,7 +3,7 @@ ClangSharp - net6.0;net7.0 + net8.0 diff --git a/sources/ClangSharp.PInvokeGenerator/Diagnostic.cs b/sources/ClangSharp.PInvokeGenerator/Diagnostic.cs index 6b36ea35..be4ec421 100644 --- a/sources/ClangSharp.PInvokeGenerator/Diagnostic.cs +++ b/sources/ClangSharp.PInvokeGenerator/Diagnostic.cs @@ -41,20 +41,13 @@ public Diagnostic(DiagnosticLevel level, string message, string location) public bool Equals(Diagnostic? other) { - if (other is null) - { - return false; - } - - return (_level == other.Level) + return (other is not null) + && (_level == other.Level) && (_location == other.Location) && (_message == other.Message); } - public override int GetHashCode() - { - return HashCode.Combine(_level, _location, _message); - } + public override int GetHashCode() => HashCode.Combine(_level, _location, _message); public override string ToString() => string.IsNullOrWhiteSpace(_location) ? $"{_level}: {_message}" : $"{_level} ({_location}): {_message}"; } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs index 6f904350..dd21b195 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs @@ -8,6 +8,7 @@ using System.Runtime.InteropServices; using System.Text; using ClangSharp.Abstractions; +using ClangSharp.CSharp; using static ClangSharp.Interop.CX_CastKind; using static ClangSharp.Interop.CX_CharacterKind; using static ClangSharp.Interop.CX_DeclKind; @@ -140,7 +141,7 @@ private void VisitDecl(Decl decl) case CX_DeclKind_TypeAlias: { - VisitTypeAliasDecl((TypeAliasDecl)decl); + // Nothing to generate for type alias declarations break; } @@ -546,7 +547,8 @@ private void VisitFunctionDecl(FunctionDecl functionDecl) if (isManualImport && !_config.WithClasses.ContainsKey(name)) { - var firstParameter = functionDecl.Parameters.FirstOrDefault(); + var parameters = functionDecl.Parameters; + var firstParameter = (parameters.Count != 0) ? parameters[0] : null; 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); } @@ -756,7 +758,7 @@ private void VisitFunctionDecl(FunctionDecl functionDecl) } else { - var firstCtorInitializer = functionDecl.Parameters.Any() ? (functionDecl.CursorChildren.IndexOf(functionDecl.Parameters.Last()) + 1) : 0; + var firstCtorInitializer = functionDecl.Parameters.Any() ? (functionDecl.CursorChildren.IndexOf(functionDecl.Parameters[functionDecl.Parameters.Count - 1]) + 1) : 0; var lastCtorInitializer = (functionDecl.Body is not null) ? functionDecl.CursorChildren.IndexOf(functionDecl.Body) : functionDecl.CursorChildren.Count; if (functionDecl is CXXConstructorDecl cxxConstructorDecl) @@ -1191,7 +1193,7 @@ void ForFunctionDecl(ParmVarDecl parmVarDecl, FunctionDecl functionDecl) : null, Location = parmVarDecl.Location, WriteCustomAttrs = static context => { - (var parmVarDecl, var generator, var csharpOutputBuilder, var defaultArg) = ((ParmVarDecl, PInvokeGenerator, CSharp.CSharpOutputBuilder, Expr))context; + (var parmVarDecl, var generator, var csharpOutputBuilder, var defaultArg) = ((ParmVarDecl, PInvokeGenerator, CSharpOutputBuilder, Expr))context; generator.WithAttributes(parmVarDecl); generator.WithUsings(parmVarDecl); @@ -1208,7 +1210,7 @@ void ForFunctionDecl(ParmVarDecl parmVarDecl, FunctionDecl functionDecl) csharpOutputBuilder?.WriteCustomAttribute("Optional", null); } }, - CustomAttrGeneratorData = (parmVarDecl, this, null as CSharp.CSharpOutputBuilder, null as Expr), + CustomAttrGeneratorData = (parmVarDecl, this, null as CSharpOutputBuilder, null as Expr), IsForManualImport = isForManualImport }; @@ -1219,7 +1221,7 @@ void ForFunctionDecl(ParmVarDecl parmVarDecl, FunctionDecl functionDecl) { isExprDefaultValue = IsDefaultValue(parmVarDecl.DefaultArg); - if ((_outputBuilder is CSharp.CSharpOutputBuilder csharpOutputBuilder) && (_config.WithTransparentStructs.ContainsKey(typeName) || parameters.Skip(index).Any((parmVarDecl) => { + if ((_outputBuilder is 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); @@ -1469,7 +1471,7 @@ private void VisitRecordDecl(RecordDecl recordDecl) } nativeNameWithExtras = nativeTypeNameBuilder.ToString(); - nativeInheritance = GetCursorName(cxxRecordDecl.Bases.Last().Referenced); + nativeInheritance = GetCursorName(cxxRecordDecl.Bases[cxxRecordDecl.Bases.Count - 1].Referenced); baseTypeNames = baseTypeNamesBuilder.ToArray(); } @@ -1807,7 +1809,7 @@ private void VisitRecordDecl(RecordDecl recordDecl) Visit(recordDecl.Decls, excludedCursors); - foreach (var array in recordDecl.Fields.Where((field) => IsTypeConstantOrIncompleteArray(field))) + foreach (var array in recordDecl.Fields.Where(IsTypeConstantOrIncompleteArray)) { VisitConstantOrIncompleteArrayFieldDecl(recordDecl, array); } @@ -1830,7 +1832,7 @@ private void VisitRecordDecl(RecordDecl recordDecl) if (_config.GenerateMarkerInterfaces) { - if (_outputBuilder is CSharp.CSharpOutputBuilder csharpOutputBuilder) + if (_outputBuilder is CSharpOutputBuilder csharpOutputBuilder) { csharpOutputBuilder.NeedsNewline = true; } @@ -1842,7 +1844,7 @@ private void VisitRecordDecl(RecordDecl recordDecl) if (_config.GenerateExplicitVtbls || _config.GenerateTrimmableVtbls) { - if (_outputBuilder is CSharp.CSharpOutputBuilder csharpOutputBuilder) + if (_outputBuilder is CSharpOutputBuilder csharpOutputBuilder) { csharpOutputBuilder.NeedsNewline = true; } @@ -2843,12 +2845,14 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co var arraySize = Math.Max((arrayType as ConstantArrayType)?.Size ?? 0, 1); var totalSize = arraySize; + var totalSizeString = $"{arraySize}"; var sizePerDimension = new List<(long index, long size)>() {(0, arraySize) }; while (IsTypeConstantOrIncompleteArray(recordDecl, elementType, out var subArrayType)) { var subArraySize = Math.Max((subArrayType as ConstantArrayType)?.Size ?? 0, 1); totalSize *= subArraySize; + totalSizeString += $" * {subArraySize}"; sizePerDimension.Add((0, subArraySize)); elementType = subArrayType.ElementType; @@ -2880,19 +2884,25 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co Location = constantOrIncompleteArray.Location, IsNested = true, WriteCustomAttrs = static context => { - (var fieldDecl, var generator) = ((FieldDecl, PInvokeGenerator))context; + (var fieldDecl, var outputBuilder, var generator, var totalSizeString) = ((FieldDecl, IOutputBuilder, PInvokeGenerator, string))context; generator.WithAttributes(fieldDecl); generator.WithUsings(fieldDecl); + + if (generator.Config.GeneratePreviewCode) + { + outputBuilder.WriteCustomAttribute($"InlineArray({totalSizeString})"); + } }, - CustomAttrGeneratorData = (constantOrIncompleteArray, this), + CustomAttrGeneratorData = (constantOrIncompleteArray, _outputBuilder, this, totalSizeString), }; _outputBuilder.BeginStruct(in desc); var firstFieldName = ""; + var numFieldsToEmit = _config.GeneratePreviewCode ? Math.Min(totalSize, 1) : totalSize; - for (long i = 0; i < totalSize; i++) + for (long i = 0; i < numFieldsToEmit; i++) { var dimension = sizePerDimension[0]; var firstDimension = dimension.index++; @@ -2944,7 +2954,11 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co var generateCompatibleCode = _config.GenerateCompatibleCode; - if (generateCompatibleCode || isUnsafeElementType) + if (_config.GeneratePreviewCode) + { + // Nothing to emit + } + else if (generateCompatibleCode || isUnsafeElementType) { _outputBuilder.BeginIndexer(AccessSpecifier.Public, isUnsafe: generateCompatibleCode && !isUnsafeElementType, needsUnscopedRef: false); _outputBuilder.WriteIndexer($"ref {arrayTypeName}"); @@ -3074,11 +3088,6 @@ private void VisitTranslationUnitDecl(TranslationUnitDecl translationUnitDecl) Visit(translationUnitDecl.CursorChildren, translationUnitDecl.Decls); } - private void VisitTypeAliasDecl(TypeAliasDecl typeAliasDecl) - { - // Nothing to generate for type alias declarations - } - private void VisitTypedefDecl(TypedefDecl typedefDecl, bool onlyHandleRemappings) { ForUnderlyingType(typedefDecl, typedefDecl.UnderlyingType, onlyHandleRemappings); @@ -3299,14 +3308,7 @@ private void VisitVarDecl(VarDecl varDecl) case CX_CLK_Ascii: case CX_CLK_UTF8: { - if (flags.HasFlag(ValueFlags.Constant)) - { - typeName = "ReadOnlySpan"; - } - else - { - typeName = "byte[]"; - } + typeName = flags.HasFlag(ValueFlags.Constant) ? "ReadOnlySpan" : "byte[]"; break; } @@ -3331,14 +3333,7 @@ private void VisitVarDecl(VarDecl varDecl) case CX_CLK_UTF32: { - if (_config.GenerateLatestCode && flags.HasFlag(ValueFlags.Constant)) - { - typeName = "ReadOnlySpan"; - } - else - { - typeName = "uint[]"; - } + typeName = (_config.GenerateLatestCode && flags.HasFlag(ValueFlags.Constant)) ? "ReadOnlySpan" : "uint[]"; break; } @@ -3482,7 +3477,7 @@ void ForDeclStmt(VarDecl varDecl, DeclStmt declStmt) var name = GetRemappedCursorName(varDecl); var escapedName = EscapeName(name); - if (varDecl == declStmt.Decls.First()) + if (varDecl == declStmt.Decls[0]) { var type = varDecl.Type; var typeName = GetRemappedTypeName(varDecl, context: null, type, out _); @@ -3853,18 +3848,8 @@ private bool IsConstant(string targetTypeName, Expr initExpr) case CX_StmtClass_UnaryOperator: { var unaryOperator = (UnaryOperator)initExpr; - - if (!IsConstant(targetTypeName, unaryOperator.SubExpr)) - { - return false; - } - - if (unaryOperator.Opcode != CX_UO_Minus) - { - return true; - } - - return targetTypeName is not "IntPtr" and not "nint" and not "nuint" and not "UIntPtr"; + return IsConstant(targetTypeName, unaryOperator.SubExpr) + && ((unaryOperator.Opcode != CX_UO_Minus) || (targetTypeName is not "IntPtr" and not "nint" and not "nuint" and not "UIntPtr")); } // case CX_StmtClass_VAArgExpr: diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs index 86c374e3..7cde15d0 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs @@ -829,7 +829,7 @@ private void VisitDeclStmt(DeclStmt declStmt) } else { - Visit(declStmt.Decls.First()); + Visit(declStmt.Decls[0]); foreach (var decl in declStmt.Decls.Skip(1)) { @@ -1111,9 +1111,9 @@ private void VisitImplicitCastExpr(ImplicitCastExpr implicitCastExpr) default: { - if (IsStmtAsWritten(subExpr, out var declRefExpr, removeParens: true) && (declRefExpr.Decl is EnumConstantDecl enumConstantDecl)) + if (IsStmtAsWritten(subExpr, out var declRefExpr, removeParens: true) && (declRefExpr.Decl is EnumConstantDecl)) { - ForEnumConstantDecl(implicitCastExpr, enumConstantDecl); + ForEnumConstantDecl(implicitCastExpr); } else { @@ -1123,7 +1123,7 @@ private void VisitImplicitCastExpr(ImplicitCastExpr implicitCastExpr) } } - void ForEnumConstantDecl(ImplicitCastExpr implicitCastExpr, EnumConstantDecl enumConstantDecl) + void ForEnumConstantDecl(ImplicitCastExpr implicitCastExpr) { var subExpr = implicitCastExpr.SubExprAsWritten; @@ -1194,11 +1194,11 @@ private void VisitInitListExpr(InitListExpr initListExpr) } else if (IsType(initListExpr, out var builtinType)) { - ForBuiltinType(outputBuilder, initListExpr, builtinType); + ForBuiltinType(outputBuilder, initListExpr); } else if (IsType(initListExpr, out var pointerType)) { - ForPointerType(outputBuilder, initListExpr, pointerType); + ForPointerType(outputBuilder, initListExpr); } else if (IsType(initListExpr, out var recordType)) { @@ -1307,7 +1307,7 @@ void ForArrayType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr, } } - void ForBuiltinType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr, BuiltinType builtinType) + void ForBuiltinType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr) { var inits = initListExpr.Inits; @@ -1401,7 +1401,7 @@ void ForRecordType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr, } } - void ForPointerType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr, PointerType pointerType) + void ForPointerType(CSharpOutputBuilder outputBuilder, InitListExpr initListExpr) { var inits = initListExpr.Inits; diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index e557276e..e3fb5be6 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -31,8 +31,10 @@ namespace ClangSharp; 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 static readonly string[] s_doubleColonSeparator = new string[] { "::" }; + private static readonly char[] s_doubleQuoteSeparator = new char[] { '"' }; private const string ExpectedClangVersion = "version 16.0"; private const string ExpectedClangSharpVersion = "version 16.0"; @@ -79,10 +81,7 @@ public sealed partial class PInvokeGenerator : IDisposable public PInvokeGenerator(PInvokeGeneratorConfiguration config, Func? outputStreamFactory = null) { - if (config is null) - { - throw new ArgumentNullException(nameof(config)); - } + ArgumentNullException.ThrowIfNull(config); var clangVersion = clang.getClangVersion().ToString(); @@ -1768,15 +1767,9 @@ private void AddUsingDirective(IOutputBuilder? outputBuilder, string namespaceNa private void CloseOutputBuilder(Stream stream, IOutputBuilder outputBuilder, bool isMethodClass, bool leaveStreamOpen, bool emitNamespaceDeclaration) { - if (stream is null) - { - throw new ArgumentNullException(nameof(stream)); - } + ArgumentNullException.ThrowIfNull(stream); - if (outputBuilder is null) - { - throw new ArgumentNullException(nameof(outputBuilder)); - } + ArgumentNullException.ThrowIfNull(outputBuilder); using var sw = new StreamWriter(stream, s_defaultStreamWriterEncoding, DefaultStreamWriterBufferSize, leaveStreamOpen); sw.NewLine = "\n"; @@ -1903,7 +1896,7 @@ void ForCSharp(CSharpOutputBuilder csharpOutputBuilder) if (_topLevelClassAttributes.TryGetValue(nonTestName, out var withAttributes)) { - if (withAttributes.Any()) + if (withAttributes.Count != 0) { foreach (var attribute in withAttributes) { @@ -2235,18 +2228,9 @@ private AccessSpecifier GetAccessSpecifier(NamedDecl namedDecl, bool matchStar) private AccessSpecifier GetMethodClassAccessSpecifier(string name) { var accessMap = _config.WithAccessSpecifiers; - - if (accessMap.TryGetValue(name, out var accessSpecifier)) - { - return accessSpecifier; - } - - if (accessMap.TryGetValue("*", out accessSpecifier)) - { - return accessSpecifier; - } - - return AccessSpecifier.None; + return (accessMap.TryGetValue(name, out var accessSpecifier) || accessMap.TryGetValue("*", out accessSpecifier)) + ? accessSpecifier + : AccessSpecifier.None; } private static string GetAnonymousName(Cursor cursor, string kind) @@ -2447,11 +2431,9 @@ private CallingConvention GetCallingConvention(Cursor? cursor, Cursor? context, { case CXCallingConv_C: { - if ((cursor is CXXMethodDecl cxxMethodDecl) && cxxMethodDecl.IsInstance) - { - return CallingConvention.ThisCall; - } - return CallingConvention.Cdecl; + return ((cursor is CXXMethodDecl cxxMethodDecl) && cxxMethodDecl.IsInstance) + ? CallingConvention.ThisCall + : CallingConvention.Cdecl; } case CXCallingConv_X86StdCall: @@ -2654,7 +2636,7 @@ void AppendNamedDecl(NamedDecl namedDecl, string name, StringBuilder qualifiedNa } } - void AppendTemplateArgument(TemplateArgument templateArgument, Decl parentDecl, StringBuilder qualifiedName) + void AppendTemplateArgument(TemplateArgument templateArgument, StringBuilder qualifiedName) { switch (templateArgument.Kind) { @@ -2691,13 +2673,13 @@ void AppendTemplateArguments(ClassTemplateSpecializationDecl classTemplateSpecia if (templateArgs.Any()) { - AppendTemplateArgument(templateArgs[0], classTemplateSpecializationDecl, qualifiedName); + AppendTemplateArgument(templateArgs[0], qualifiedName); for (var i = 1; i < templateArgs.Count; i++) { _ = qualifiedName.Append(','); _ = qualifiedName.Append(' '); - AppendTemplateArgument(templateArgs[i], classTemplateSpecializationDecl, qualifiedName); + AppendTemplateArgument(templateArgs[i], qualifiedName); } } @@ -2806,10 +2788,7 @@ private CXXRecordDecl GetRecordDecl(CXXBaseSpecifier cxxBaseSpecifier) return (CXXRecordDecl)cxxBaseSpecifier.Referenced; } - private string GetRemappedCursorName(NamedDecl namedDecl) - { - return GetRemappedCursorName(namedDecl, out _, skipUsing: false); - } + private string GetRemappedCursorName(NamedDecl namedDecl) => GetRemappedCursorName(namedDecl, out _, skipUsing: false); private string GetRemappedCursorName(NamedDecl namedDecl, out string nativeTypeName, bool skipUsing) { @@ -2905,9 +2884,7 @@ private string GetRemappedCursorName(NamedDecl namedDecl, out string nativeTypeN } 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); - } + => GetRemappedName(name, cursor, tryRemapOperatorName, out wasRemapped, skipUsing, skipUsingIfNotRemapped: skipUsing); private string GetRemappedName(string name, Cursor? cursor, bool tryRemapOperatorName, out bool wasRemapped, bool skipUsing, bool skipUsingIfNotRemapped) { @@ -2962,7 +2939,7 @@ string AddUsingDirectiveIfNeeded(IOutputBuilder? outputBuilder, string remappedN { if (!skipUsing) { - if (s_needsSystemSupportRegex.IsMatch(remappedName)) + if (NeedsSystemSupportRegex().IsMatch(remappedName)) { outputBuilder?.EmitSystemSupport(); } @@ -3109,14 +3086,9 @@ private string GetTargetTypeName(Cursor cursor, out string nativeTypeName) { if (decl is EnumConstantDecl enumConstantDecl) { - 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); - } + targetTypeName = enumConstantDecl.DeclContext is EnumDecl enumDecl + ? GetRemappedTypeName(enumDecl, context: null, enumDecl.IntegerType, out nativeTypeName) + : GetRemappedTypeName(enumConstantDecl, context: null, enumConstantDecl.Type, out nativeTypeName); } else if (decl is TypeDecl previousTypeDecl) { @@ -3450,7 +3422,7 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type if (result.typeName.Contains("::")) { - result.typeName = result.typeName.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries).Last(); + result.typeName = result.typeName.Split(s_doubleColonSeparator, StringSplitOptions.RemoveEmptyEntries).Last(); result.typeName = GetRemappedName(result.typeName, cursor, tryRemapOperatorName: false, out _, skipUsing: true); } } @@ -4238,13 +4210,7 @@ private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref lon } private bool HasSuppressGCTransition(Cursor? cursor) - { - if (cursor is not NamedDecl namedDecl) - { - return false; - } - return HasRemapping(namedDecl, _config.WithSuppressGCTransitions); - } + => (cursor is NamedDecl namedDecl) && HasRemapping(namedDecl, _config.WithSuppressGCTransitions); private bool HasBaseField(CXXRecordDecl cxxRecordDecl) { @@ -4395,7 +4361,7 @@ bool IsExcludedByFile(Cursor cursor) { if (_outputBuilder != null) { - // We don't want to exclude by fileif we already have an active output builder as we + // We don't want to exclude by file if 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; @@ -4415,7 +4381,7 @@ bool IsExcludedByFile(Cursor cursor) declLocation.GetExpansionLocation(out var expansionFile, out var expansionLine, out var expansionColumn, out _); - if ((expansionFile == file) && (expansionLine == line) && (expansionColumn == column) && _config.TraversalNames.Any()) + if ((expansionFile == file) && (expansionLine == line) && (expansionColumn == column) && _config.TraversalNames.Count != 0) { // 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 @@ -4571,7 +4537,7 @@ bool IsExcludedByName(Cursor cursor, ref uint isExcludedValue) return true; } - if (_config.IncludedNames.Any() && !_config.IncludedNames.Contains(qualifiedName) + if (_config.IncludedNames.Count != 0 && !_config.IncludedNames.Contains(qualifiedName) && !_config.IncludedNames.Contains(dottedQualifiedName) && !_config.IncludedNames.Contains(qualifiedNameWithoutParameters) && !_config.IncludedNames.Contains(dottedQualifiedNameWithoutParameters) @@ -4617,7 +4583,7 @@ bool IsIncludedFileOrLocation(Cursor cursor, CXFile file, CXSourceLocation locat { return true; } - else if (!_config.TraversalNames.Any() && location.IsFromMainFile) + else if (_config.TraversalNames.Count == 0 && location.IsFromMainFile) { return true; } @@ -4634,11 +4600,13 @@ bool IsComProxy(FunctionDecl functionDecl, string name) name.EndsWith("_UserSize") || name.EndsWith("_UserSize64") || name.EndsWith("_UserUnmarshal") || name.EndsWith("_UserUnmarshal64")) { - parmVarDecl = functionDecl.Parameters.LastOrDefault(); + var parameters = functionDecl.Parameters; + parmVarDecl = (parameters.Count != 0) ? parameters[^1] : null; } else if (name.EndsWith("_Proxy") || name.EndsWith("_Stub")) { - parmVarDecl = functionDecl.Parameters.FirstOrDefault(); + var parameters = functionDecl.Parameters; + parmVarDecl = (parameters.Count != 0) ? parameters[0] : null; } if ((parmVarDecl is not null) && IsType(parmVarDecl, out var pointerType)) @@ -4747,7 +4715,7 @@ bool IsConflictingMethodDecl(CXXMethodDecl cxxMethodDeclToMatch, CXXMethodDecl c { // 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 + // So return true to report the declaration to match as the conflict return true; } else if (cxxMethodDeclToMatch.IsThisDeclarationADefinition != cxxMethodDecl.IsThisDeclarationADefinition) @@ -4763,7 +4731,7 @@ bool IsConflictingMethodDecl(CXXMethodDecl cxxMethodDeclToMatch, CXXMethodDecl c { // 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 + // So return true to report the declaration to match as the conflict return true; } } @@ -4778,7 +4746,7 @@ bool IsConflictingMethodDecl(CXXMethodDecl cxxMethodDeclToMatch, CXXMethodDecl c { // 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 + // So return true or false based on if we already encountered the declaration to match return !foundCxxMethodDeclToMatch; } @@ -4795,7 +4763,7 @@ bool IsEmptyRecord(RecordDecl recordDecl) return false; } - var field = recordDecl.Fields.First(); + var field = recordDecl.Fields[0]; if ((GetCursorName(field) != "unused") || !IsType(field, out var builtinType) || (builtinType.Kind != CXType_Int)) { @@ -4899,19 +4867,10 @@ private bool IsFixedSize(Cursor cursor, Type type) } } - private bool IsNativeTypeNameEquivalent(string nativeTypeName, string typeName) + private static 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; + return nativeTypeName.Equals(typeName, StringComparison.OrdinalIgnoreCase) + || nativeTypeName.Replace(" ", "").Equals(typeName, StringComparison.OrdinalIgnoreCase); } private bool IsPrevContextDecl([MaybeNullWhen(false)] out T cursor, out object? userData) @@ -5009,34 +4968,19 @@ private static bool IsStmtAsWritten(Stmt stmt, Stmt expectedStmt, bool removePar } private bool IsType(Expr expr) - where T : Type - { - return IsType(expr, out _); - } + where T : Type => IsType(expr, out _); private bool IsType(Expr expr, [MaybeNullWhen(false)] out T value) - where T : Type - { - return IsType(expr, expr.Type, out value); - } + where T : Type => IsType(expr, expr.Type, out value); private bool IsType(ValueDecl valueDecl) - where T : Type - { - return IsType(valueDecl, out _); - } + where T : Type => IsType(valueDecl, out _); private bool IsType(ValueDecl typeDecl, [MaybeNullWhen(false)] out T value) - where T : Type - { - return IsType(typeDecl, typeDecl.Type, out value); - } + where T : Type => IsType(typeDecl, typeDecl.Type, out value); private bool IsType(Cursor? cursor, Type type) - where T : Type - { - return IsType(cursor, type, out _); - } + where T : Type => IsType(cursor, type, out _); private bool IsType(Cursor? cursor, Type type, [MaybeNullWhen(false)] out T value) where T : Type @@ -5123,57 +5067,37 @@ private bool IsType(Cursor? cursor, Type type, [MaybeNullWhen(false)] out T v } private bool IsTypeConstantOrIncompleteArray(Expr expr) - { - return IsTypeConstantOrIncompleteArray(expr, out _); - } + => IsTypeConstantOrIncompleteArray(expr, out _); private bool IsTypeConstantOrIncompleteArray(Expr expr, [MaybeNullWhen(false)] out ArrayType arrayType) - { - return IsTypeConstantOrIncompleteArray(expr, expr.Type, out arrayType); - } + => IsTypeConstantOrIncompleteArray(expr, expr.Type, out arrayType); private bool IsTypeConstantOrIncompleteArray(ValueDecl valueDecl) - { - return IsTypeConstantOrIncompleteArray(valueDecl, out _); - } + => IsTypeConstantOrIncompleteArray(valueDecl, out _); private bool IsTypeConstantOrIncompleteArray(ValueDecl valueDecl, [MaybeNullWhen(false)] out ArrayType arrayType) - { - return IsTypeConstantOrIncompleteArray(valueDecl, valueDecl.Type, out arrayType); - } + => IsTypeConstantOrIncompleteArray(valueDecl, valueDecl.Type, out arrayType); private bool IsTypeConstantOrIncompleteArray(Cursor? cursor, Type type) - { - return IsTypeConstantOrIncompleteArray(cursor, type, out _); - } + => IsTypeConstantOrIncompleteArray(cursor, type, out _); private bool IsTypeConstantOrIncompleteArray(Cursor? cursor, Type type, [MaybeNullWhen(false)] out ArrayType arrayType) - { - return IsType(cursor, type, out arrayType) && - (arrayType is ConstantArrayType or IncompleteArrayType); - } + => IsType(cursor, type, out arrayType) + && (arrayType is ConstantArrayType or IncompleteArrayType); private bool IsTypePointerOrReference(Expr expr) - { - return IsTypePointerOrReference(expr, expr.Type); - } + => IsTypePointerOrReference(expr, expr.Type); private bool IsTypePointerOrReference(ValueDecl valueDecl) - { - return IsTypePointerOrReference(valueDecl, valueDecl.Type); - } + => IsTypePointerOrReference(valueDecl, valueDecl.Type); private bool IsTypePointerOrReference(Cursor? cursor, Type type) - { - return IsType(cursor, type) - || IsType(cursor, type); - } + => IsType(cursor, type) + || IsType(cursor, type); private bool IsTypeVoid(Cursor? cursor, Type type) - { - return IsType(cursor, type, out var builtinType) - && (builtinType.Kind == CXType_Void); - } + => IsType(cursor, type, out var builtinType) + && (builtinType.Kind == CXType_Void); internal static bool IsSupportedFixedSizedBufferType(string typeName) { @@ -5203,21 +5127,15 @@ internal static bool IsSupportedFixedSizedBufferType(string typeName) } private static bool IsTransparentStructBoolean(PInvokeGeneratorTransparentStructKind kind) - { - return kind == PInvokeGeneratorTransparentStructKind.Boolean; - } + => kind is PInvokeGeneratorTransparentStructKind.Boolean; private static bool IsTransparentStructHandle(PInvokeGeneratorTransparentStructKind kind) - { - return kind is PInvokeGeneratorTransparentStructKind.Handle - or PInvokeGeneratorTransparentStructKind.HandleWin32; - } + => kind is PInvokeGeneratorTransparentStructKind.Handle + or PInvokeGeneratorTransparentStructKind.HandleWin32; private static bool IsTransparentStructHexBased(PInvokeGeneratorTransparentStructKind kind) - { - return IsTransparentStructHandle(kind) - || (kind == PInvokeGeneratorTransparentStructKind.TypedefHex); - } + => IsTransparentStructHandle(kind) + || (kind == PInvokeGeneratorTransparentStructKind.TypedefHex); private bool IsUnchecked(string targetTypeName, Stmt stmt) { @@ -5710,7 +5628,7 @@ bool IsOverflow(BinaryOperator binaryOperator) } } - private bool IsUnchecked(string typeName, CXEvalResult evalResult) + private static bool IsUnchecked(string typeName, CXEvalResult evalResult) { if (evalResult.Kind != CXEval_Int) { @@ -5721,7 +5639,7 @@ private bool IsUnchecked(string typeName, CXEvalResult evalResult) return IsUnchecked(typeName, signedValue, signedValue < 0, isHex: false); } - private bool IsUnchecked(string typeName, long signedValue, bool isNegative, bool isHex) + private static bool IsUnchecked(string typeName, long signedValue, bool isNegative, bool isHex) { switch (typeName) { @@ -5790,7 +5708,7 @@ private bool IsUnsafe(FieldDecl fieldDecl) { var type = fieldDecl.Type; - if (IsType(fieldDecl, out var arrayType) && IsTypeConstantOrIncompleteArray(fieldDecl, type)) + if (IsType(fieldDecl, out _) && IsTypeConstantOrIncompleteArray(fieldDecl, type)) { var remappedName = GetRemappedTypeName(fieldDecl, context: null, type, out _, skipUsing: true, ignoreTransparentStructsWhereRequired: false); return IsSupportedFixedSizedBufferType(remappedName); @@ -6123,7 +6041,7 @@ private bool TryGetUuid(RecordDecl recordDecl, out Guid uuid) var uuidAttr = uuidAttrs.First(); var uuidAttrText = GetSourceRangeContents(recordDecl.TranslationUnit.Handle, uuidAttr.Extent); - var uuidText = uuidAttrText.Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries)[1]; + var uuidText = uuidAttrText.Split(s_doubleQuoteSeparator, StringSplitOptions.RemoveEmptyEntries)[1]; if (!Guid.TryParse(uuidText, out uuid)) { @@ -6560,13 +6478,9 @@ private string GetNamespace(string remappedName, NamedDecl? namedDecl = null) var parentName = GetRemappedCursorName(parentTypeDecl); namespaceName = $"{GetNamespace(parentName, parentTypeDecl)}.{parentName}"; } - else if (s_needsSystemSupportRegex.IsMatch(remappedName)) - { - namespaceName = "System"; - } else { - namespaceName = _config.DefaultNamespace; + namespaceName = NeedsSystemSupportRegex().IsMatch(remappedName) ? "System" : _config.DefaultNamespace; } } return namespaceName; @@ -6633,17 +6547,7 @@ private bool HasRemapping(NamedDecl namedDecl, IReadOnlyCollection entri name = name["ClangSharpMacro_".Length..]; } - if (entries.Contains(name)) - { - return true; - } - - if (matchStar && entries.Contains("*")) - { - return true; - } - - return false; + return entries.Contains(name) || (matchStar && entries.Contains("*")); } private bool TryGetRemappedValue(NamedDecl namedDecl, IReadOnlyDictionary remappings, [MaybeNullWhen(false)] out T value, bool matchStar = false) @@ -6879,32 +6783,35 @@ private string GetPlaceholderMacroType() } } + [GeneratedRegex(@"\b(?:Guid|IntPtr|UIntPtr)\b")] + private static partial Regex NeedsSystemSupportRegex(); + private static int ParseCxxStandard(string standard) { const string CxxStandard = "c++"; const string GnuxxStandard = "gnu++"; - if (standard.StartsWith(CxxStandard)) - { - return ParseCxxStandardVersion(standard.AsSpan()[CxxStandard.Length..]); - } - - if (standard.StartsWith(GnuxxStandard)) - { - return ParseCxxStandardVersion(standard.AsSpan()[GnuxxStandard.Length..]); - } - - return -1; + return standard.StartsWith(CxxStandard) ? ParseCxxStandardVersion(standard.AsSpan()[CxxStandard.Length..]) + : standard.StartsWith(GnuxxStandard) ? ParseCxxStandardVersion(standard.AsSpan()[GnuxxStandard.Length..]) + : -1; } private static int ParseCxxStandardVersion(ReadOnlySpan version) { // Maybe in the future we'll need to check for more c++ standard drafts, but atm this should work - if(version.EndsWith("a") || version.EndsWith("b")) + + if (version.EndsWith("a") || version.EndsWith("b")) + { + if (int.TryParse(version[..^1], out var draftStd)) + { + return draftStd * 10; + } + } + else if (int.TryParse(version, out var std)) { - return int.TryParse(version[..^1], out var draftStd) ? draftStd * 10 : -1; + return std; } - return int.TryParse(version, out var std) ? std : -1; + return -1; } } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs index 3b366c42..a662a949 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs @@ -577,34 +577,12 @@ public IReadOnlyDictionary WithPackings public static AccessSpecifier ConvertStringToAccessSpecifier(string input) { - 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 input.Equals("internal", StringComparison.OrdinalIgnoreCase) ? AccessSpecifier.Internal + : input.Equals("private", StringComparison.OrdinalIgnoreCase) ? AccessSpecifier.Private + : input.Equals("private protected", StringComparison.OrdinalIgnoreCase) ? AccessSpecifier.PrivateProtected + : input.Equals("protected", StringComparison.OrdinalIgnoreCase) ? AccessSpecifier.Protected + : input.Equals("protected internal", StringComparison.OrdinalIgnoreCase) ? AccessSpecifier.ProtectedInternal + : input.Equals("public", StringComparison.OrdinalIgnoreCase) ? AccessSpecifier.Public : AccessSpecifier.None; } private static void AddRange(SortedDictionary dictionary, IEnumerable>? keyValuePairs) diff --git a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs index af4684b9..cd32972d 100644 --- a/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/XML/XmlOutputBuilder.VisitDecl.cs @@ -34,18 +34,9 @@ public void EndUnchecked() public void BeginValue(in ValueDesc desc) { - if (desc.Kind == ValueKind.Enumerator) - { - _ = _sb.Append(""); @@ -70,18 +61,9 @@ public void EndValue(in ValueDesc desc) _ = _sb.Append(""); } - if (desc.Kind == ValueKind.Enumerator) - { - _ = _sb.Append(""); - } - else if (desc.IsConstant) - { - _ = _sb.Append(""); - } - else - { - _ = _sb.Append(""); - } + _ = (desc.Kind is ValueKind.Enumerator) ? _sb.Append("") + : desc.IsConstant ? _sb.Append("") + : _sb.Append(""); } public void BeginEnum(in EnumDesc desc) diff --git a/sources/ClangSharp/ClangSharp.csproj b/sources/ClangSharp/ClangSharp.csproj index efccad82..c0ffbb00 100644 --- a/sources/ClangSharp/ClangSharp.csproj +++ b/sources/ClangSharp/ClangSharp.csproj @@ -2,7 +2,7 @@ - net6.0;net7.0;netstandard2.0 + net8.0;netstandard2.0 diff --git a/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs b/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs index 680026fa..17b6bcdd 100644 --- a/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/CXXConstructorDecl.cs @@ -64,8 +64,8 @@ public CXXConstructorDecl? TargetConstructor return null; } - var e = InitExprs.FirstOrDefault()?.IgnoreImplicit; - + var initExprs = InitExprs; + var e = (initExprs.Count != 0) ? initExprs[0].IgnoreImplicit : null; return (e is CXXConstructExpr construct) ? construct.Constructor : null; } } diff --git a/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs b/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs index 07fb1094..76180d56 100644 --- a/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs +++ b/sources/ClangSharp/Cursors/Decls/LinkageSpecDecl.cs @@ -17,5 +17,5 @@ internal LinkageSpecDecl(CXCursor handle) : base(handle, handle.Kind, CX_DeclKin } } - public CXLanguageKind Langage => Handle.Language; + public CXLanguageKind Language => Handle.Language; } diff --git a/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs b/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs index 825918ea..5cb661d6 100644 --- a/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs +++ b/sources/ClangSharp/Cursors/Exprs/CompoundLiteralExpr.cs @@ -10,17 +10,17 @@ namespace ClangSharp; public sealed class CompoundLiteralExpr : Expr { - private readonly Lazy _typeSourceinfoType; + private readonly Lazy _typeSourceInfoType; internal CompoundLiteralExpr(CXCursor handle) : base(handle, CXCursor_CompoundLiteralExpr, CX_StmtClass_CompoundLiteralExpr) { Debug.Assert(NumChildren is 1); - _typeSourceinfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); + _typeSourceInfoType = new Lazy(() => TranslationUnit.GetOrCreate(Handle.TypeOperand)); } public bool IsFileScope => Handle.IsFileScope; public Expr Initializer => (Expr)Children[0]; - public Type TypeSourceInfoType => _typeSourceinfoType.Value; + public Type TypeSourceInfoType => _typeSourceInfoType.Value; } diff --git a/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs b/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs index 29d17a83..be7de161 100644 --- a/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/CompoundStmt.cs @@ -17,9 +17,23 @@ public CompoundStmt(CXCursor handle) : base(handle, CXCursor_CompoundStmt, CX_St public IReadOnlyList Body => Children; - public Stmt? BodyBack => Children.LastOrDefault(); + public Stmt? BodyBack + { + get + { + var children = Children; + return (children.Count != 0) ? children[^1] : null; + } + } - public Stmt? BodyFront => Children.FirstOrDefault(); + public Stmt? BodyFront + { + get + { + var children = Children; + return (children.Count != 0) ? children[0] : null; + } + } public uint Size => unchecked((uint)NumChildren); diff --git a/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs b/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs index e58417ea..84a0cd67 100644 --- a/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs +++ b/sources/ClangSharp/Cursors/Stmts/ObjCAtTryStmt.cs @@ -23,7 +23,7 @@ internal ObjCAtTryStmt(CXCursor handle) : base(handle, CXCursor_ObjCAtTryStmt, C var children = Children; var skipLast = 0; - if (children.Last() is ObjCAtFinallyStmt) { + if (children[children.Count - 1] is ObjCAtFinallyStmt) { skipLast++; } @@ -33,7 +33,7 @@ internal ObjCAtTryStmt(CXCursor handle) : base(handle, CXCursor_ObjCAtTryStmt, C _finallyStmt = new Lazy(() => { var children = Children; - return (children.Last() is ObjCAtFinallyStmt finallyStmt) ? finallyStmt : null; + return (children[children.Count - 1] is ObjCAtFinallyStmt finallyStmt) ? finallyStmt : null; }); } diff --git a/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj b/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj index 581529fd..fd0fedc6 100644 --- a/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj +++ b/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj @@ -6,7 +6,7 @@ true win-x64 - net6.0;net7.0 + net8.0 diff --git a/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs b/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs index 298066b8..92182781 100644 --- a/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs +++ b/sources/ClangSharpPInvokeGenerator/CustomHelpBuilder.cs @@ -1,7 +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. // Portions of this code are ported from https://github.com/dotnet/command-line-api -// The original source is Copyright © .NET Foundation and Contributor. All rigts reserved. Licensed under the MIT License (MIT). +// The original source is Copyright © .NET Foundation and Contributor. All rights reserved. Licensed under the MIT License (MIT). using System.CommandLine; using System.CommandLine.Help; diff --git a/sources/ClangSharpPInvokeGenerator/Program.cs b/sources/ClangSharpPInvokeGenerator/Program.cs index eb49016e..44327d70 100644 --- a/sources/ClangSharpPInvokeGenerator/Program.cs +++ b/sources/ClangSharpPInvokeGenerator/Program.cs @@ -62,7 +62,6 @@ public class Program private static readonly Option s_withUsingNameValuePairs; private static readonly Option s_withPackingNameValuePairs; - private static readonly TwoColumnHelpRow[] s_configOptions = new TwoColumnHelpRow[] { new TwoColumnHelpRow("?, h, help", "Show help and usage information for -c, --config"), @@ -87,7 +86,7 @@ public class Program // 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-com-proxies", "Types recognized as COM proxies should not have bindings generated. These are currently function declarations ending with _UserFree, _UserMarshal, _UserSize, _UserUnmarshal, _Proxy, or _Stub."), 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."), @@ -130,6 +129,43 @@ public class Program new TwoColumnHelpRow("log-visited-files", "A list of the visited files should be generated. This can help identify traversal issues."), }; + private static readonly string[] s_additionalOptionAliases = new string[] { "--additional", "-a" }; + private static readonly string[] s_configOptionAliases = new string[] { "--config", "-c" }; + private static readonly string[] s_defineMacroOptionAliases = new string[] { "--define-macro", "-D" }; + private static readonly string[] s_excludeOptionAliases = new string[] { "--exclude", "-e" }; + private static readonly string[] s_fileOptionAliases = new string[] { "--file", "-f" }; + private static readonly string[] s_fileDirectionOptionAliases = new string[] { "--file-directory", "-F" }; + private static readonly string[] s_headerOptionAliases = new string[] { "--headerFile", "-h" }; + private static readonly string[] s_includeOptionAliases = new string[] { "--include", "-i" }; + private static readonly string[] s_includeDirectoryOptionAliases = new string[] { "--include-directory", "-I" }; + private static readonly string[] s_languageOptionAliases = new string[] { "--language", "-x" }; + private static readonly string[] s_libraryOptionAliases = new string[] { "--libraryPath", "-l" }; + private static readonly string[] s_methodClassNameOptionAliases = new string[] { "--methodClassName", "-m" }; + private static readonly string[] s_namespaceOptionAliases = new string[] { "--namespace", "-n" }; + private static readonly string[] s_nativeTypeNamesStripOptionAliases = new string[] { "--nativeTypeNamesToStrip" }; + private static readonly string[] s_outputModeOptionAliases = new string[] { "--output-mode", "-om" }; + private static readonly string[] s_outputOptionAliases = new string[] { "--output", "-o" }; + private static readonly string[] s_prefixStripOptionAliases = new string[] { "--prefixStrip", "-p" }; + private static readonly string[] s_remapOptionAliases = new string[] { "--remap", "-r" }; + private static readonly string[] s_stdOptionAliases = new string[] { "--std", "-std" }; + private static readonly string[] s_testOutputOptionAliases = new string[] { "--test-output", "-to" }; + private static readonly string[] s_versionOptionAliases = new string[] { "--version", "-v" }; + private static readonly string[] s_traverseOptionAliases = new string[] { "--traverse", "-t" }; + private static readonly string[] s_withAccessSpecifierOptionAliases = new string[] { "--with-access-specifier", "-was" }; + private static readonly string[] s_withAttributeOptionAliases = new string[] { "--with-attribute", "-wa" }; + private static readonly string[] s_withCallConvOptionAliases = new string[] { "--with-callconv", "-wcc" }; + private static readonly string[] s_withClassOptionAliases = new string[] { "--with-class", "-wc" }; + private static readonly string[] s_withGuidOptionAliases = new string[] { "--with-guid", "-wg" }; + private static readonly string[] s_withLibraryPathOptionAliases = new string[] { "--with-librarypath", "-wlb" }; + private static readonly string[] s_withManualImportOptionAliases = new string[] { "--with-manual-import", "-wmi" }; + private static readonly string[] s_withNamespaceOptionAliases = new string[] { "--with-namespace", "-wn" }; + private static readonly string[] s_withSetLastErrorOptionAliases = new string[] { "--with-setlasterror", "-wsle" }; + private static readonly string[] s_withSuppressGCTransitionOptionAliases = new string[] { "--with-suppressgctransition", "-wsgct" }; + private static readonly string[] s_withTransparentStructOptionAliases = new string[] { "--with-transparent-struct", "-wts" }; + private static readonly string[] s_withTypeOptionAliases = new string[] { "--with-type", "-wt" }; + private static readonly string[] s_withUsingOptionAliases = new string[] { "--with-using", "-wu" }; + private static readonly string[] s_withPackingOptionAliases = new string[] { "--with-packing", "-wp" }; + static Program() { s_additionalOption = GetAdditionalOption(); @@ -291,7 +327,7 @@ public static void Run(InvocationContext context) var errorList = new List(); - if (!files.Any()) + if (files.Length == 0) { errorList.Add("Error: No input C/C++ files provided. Use --file or -f"); } @@ -653,7 +689,7 @@ public static void Run(InvocationContext context) return; } - if (errorList.Any()) + if (errorList.Count != 0) { context.Console.Error.Write($"Error in args for '{files.FirstOrDefault()}'"); context.Console.Error.Write(Environment.NewLine); @@ -671,23 +707,15 @@ public static void Run(InvocationContext context) return; } - string[] clangCommandLineArgs; - - 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 - }; - } + var clangCommandLineArgs = string.IsNullOrWhiteSpace(std) + ? 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 + } : 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 + }; clangCommandLineArgs = clangCommandLineArgs.Concat(includeDirectories.Select(x => "--include-directory=" + x)).ToArray(); clangCommandLineArgs = clangCommandLineArgs.Concat(defineMacros.Select(x => "--define-macro=" + x)).ToArray(); @@ -834,9 +862,9 @@ private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List keyValuePairs, List keyValuePairs, List keyValuePairs, List keyValuePairs, List()); + value = new List(); + result.Add(key, value); } - var list = (List)result[key]; + var list = (List)value; list.Add(parts[1].TrimStart()); } } @@ -971,7 +1000,7 @@ private static void ParseKeyValuePairs(IEnumerable keyValuePairs, List GetAdditionalOption() { return new Option( - aliases: new string[] { "--additional", "-a" }, + aliases: s_additionalOptionAliases, description: "An argument to pass to Clang when parsing the input files.", getDefaultValue: Array.Empty ) { @@ -982,7 +1011,7 @@ private static Option GetAdditionalOption() private static Option GetConfigOption() { return new Option( - aliases: new string[] { "--config", "-c" }, + aliases: s_configOptionAliases, description: "A configuration option that controls how the bindings are generated. Specify 'help' to see the available options.", getDefaultValue: Array.Empty ) { @@ -993,7 +1022,7 @@ private static Option GetConfigOption() private static Option GetDefineMacroOption() { return new Option( - aliases: new string[] { "--define-macro", "-D" }, + aliases: s_defineMacroOptionAliases, description: "Define to (or 1 if omitted).", getDefaultValue: Array.Empty ) { @@ -1004,7 +1033,7 @@ private static Option GetDefineMacroOption() private static Option GetExcludeOption() { return new Option( - aliases: new string[] { "--exclude", "-e" }, + aliases: s_excludeOptionAliases, description: "A declaration name to exclude from binding generation.", getDefaultValue: Array.Empty ) { @@ -1015,7 +1044,7 @@ private static Option GetExcludeOption() private static Option GetFileOption() { return new Option( - aliases: new string[] { "--file", "-f" }, + aliases: s_fileOptionAliases, description: "A file to parse and generate bindings for.", getDefaultValue: Array.Empty ) { @@ -1026,7 +1055,7 @@ private static Option GetFileOption() private static Option GetFileDirectoryOption() { return new Option( - aliases: new string[] { "--file-directory", "-F" }, + aliases: s_fileDirectionOptionAliases, description: "The base path for files to parse.", getDefaultValue: () => string.Empty ); @@ -1035,7 +1064,7 @@ private static Option GetFileDirectoryOption() private static Option GetHeaderOption() { return new Option( - aliases: new string[] { "--headerFile", "-h" }, + aliases: s_headerOptionAliases, description: "A file which contains the header to prefix every generated file with.", getDefaultValue: () => string.Empty ); @@ -1044,7 +1073,7 @@ private static Option GetHeaderOption() private static Option GetIncludeOption() { return new Option( - aliases: new string[] { "--include", "-i" }, + aliases: s_includeOptionAliases, description: "A declaration name to include in binding generation.", getDefaultValue: Array.Empty ) { @@ -1055,7 +1084,7 @@ private static Option GetIncludeOption() private static Option GetIncludeDirectoryOption() { return new Option( - aliases: new string[] { "--include-directory", "-I" }, + aliases: s_includeDirectoryOptionAliases, description: "Add directory to include search path.", getDefaultValue: Array.Empty ) { @@ -1066,7 +1095,7 @@ private static Option GetIncludeDirectoryOption() private static Option GetLanguageOption() { return new Option( - aliases: new string[] { "--language", "-x" }, + aliases: s_languageOptionAliases, description: "Treat subsequent input files as having type .", getDefaultValue: () => "c++" ).FromAmong("c", "c++"); @@ -1075,7 +1104,7 @@ private static Option GetLanguageOption() private static Option GetLibraryOption() { return new Option( - aliases: new string[] { "--libraryPath", "-l" }, + aliases: s_libraryOptionAliases, description: "The string to use in the DllImport attribute used when generating bindings.", getDefaultValue: () => string.Empty ); @@ -1084,7 +1113,7 @@ private static Option GetLibraryOption() private static Option GetMethodClassNameOption() { return new Option( - aliases: new string[] { "--methodClassName", "-m" }, + aliases: s_methodClassNameOptionAliases, description: "The name of the static class that will contain the generated method bindings.", getDefaultValue: () => "Methods" ); @@ -1093,7 +1122,7 @@ private static Option GetMethodClassNameOption() private static Option GetNamespaceOption() { return new Option( - aliases: new string[] { "--namespace", "-n" }, + aliases: s_namespaceOptionAliases, description: "The namespace in which to place the generated bindings.", getDefaultValue: () => string.Empty ); @@ -1102,7 +1131,7 @@ private static Option GetNamespaceOption() private static Option GetNativeTypeNamesStripOption() { return new Option( - aliases: new string[] { "--nativeTypeNamesToStrip" }, + aliases: s_nativeTypeNamesStripOptionAliases, description: "The contents to strip from the generated NativeTypeName attributes.", getDefaultValue: Array.Empty ) { @@ -1113,7 +1142,7 @@ private static Option GetNativeTypeNamesStripOption() private static Option GetOutputModeOption() { return new Option( - aliases: new string[] { "--output-mode", "-om" }, + aliases: s_outputModeOptionAliases, description: "The mode describing how the information collected from the headers are presented in the resultant bindings.", getDefaultValue: () => PInvokeGeneratorOutputMode.CSharp ); @@ -1122,7 +1151,7 @@ private static Option GetOutputModeOption() private static Option GetOutputOption() { return new Option( - aliases: new string[] { "--output", "-o" }, + aliases: s_outputOptionAliases, description: "The output location to write the generated bindings to.", getDefaultValue: () => string.Empty ); @@ -1131,7 +1160,7 @@ private static Option GetOutputOption() private static Option GetPrefixStripOption() { return new Option( - aliases: new string[] { "--prefixStrip", "-p" }, + aliases: s_prefixStripOptionAliases, description: "The prefix to strip from the generated method bindings.", getDefaultValue: () => string.Empty ); @@ -1140,7 +1169,7 @@ private static Option GetPrefixStripOption() private static Option GetRemapOption() { return new Option( - aliases: new string[] { "--remap", "-r" }, + aliases: s_remapOptionAliases, description: "A declaration name to be remapped to another name during binding generation.", getDefaultValue: Array.Empty ) { @@ -1151,7 +1180,7 @@ private static Option GetRemapOption() private static Option GetStdOption() { return new Option( - aliases: new string[] { "--std", "-std" }, + aliases: s_stdOptionAliases, description: "Language standard to compile for.", getDefaultValue: () => "" ); @@ -1160,7 +1189,7 @@ private static Option GetStdOption() private static Option GetTestOutputOption() { return new Option( - aliases: new string[] { "--test-output", "-to" }, + aliases: s_testOutputOptionAliases, description: "The output location to write the generated tests to.", getDefaultValue: () => string.Empty ); @@ -1169,7 +1198,7 @@ private static Option GetTestOutputOption() private static Option GetVersionOption() { return new Option( - aliases: new string[] { "--version", "-v" }, + aliases: s_versionOptionAliases, description: "Prints the current version information for the tool and its native dependencies." ) { Arity = ArgumentArity.Zero @@ -1179,7 +1208,7 @@ private static Option GetVersionOption() private static Option GetTraverseOption() { return new Option( - aliases: new string[] { "--traverse", "-t" }, + aliases: s_traverseOptionAliases, description: "A file name included either directly or indirectly by -f that should be traversed during binding generation.", getDefaultValue: Array.Empty ) { @@ -1190,7 +1219,7 @@ private static Option GetTraverseOption() private static Option GetWithAccessSpecifierOption() { return new Option( - aliases: new string[] { "--with-access-specifier", "-was" }, + aliases: s_withAccessSpecifierOptionAliases, description: "An access specifier to be used with the given qualified or remapped declaration name during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1201,7 +1230,7 @@ private static Option GetWithAccessSpecifierOption() private static Option GetWithAttributeOption() { return new Option( - aliases: new string[] { "--with-attribute", "-wa" }, + aliases: s_withAttributeOptionAliases, description: "An attribute to be added to the given remapped declaration name during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1212,7 +1241,7 @@ private static Option GetWithAttributeOption() private static Option GetWithCallConvOption() { return new Option( - aliases: new string[] { "--with-callconv", "-wcc" }, + aliases: s_withCallConvOptionAliases, description: "A calling convention to be used for the given declaration during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1223,7 +1252,7 @@ private static Option GetWithCallConvOption() private static Option GetWithClassOption() { return new Option( - aliases: new string[] { "--with-class", "-wc" }, + aliases: s_withClassOptionAliases, description: "A class to be used for the given remapped constant or function declaration name during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1234,7 +1263,7 @@ private static Option GetWithClassOption() private static Option GetWithGuidOption() { return new Option( - aliases: new string[] { "--with-guid", "-wg" }, + aliases: s_withGuidOptionAliases, description: "A GUID to be used for the given declaration during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1245,7 +1274,7 @@ private static Option GetWithGuidOption() private static Option GetWithLibraryPathOption() { return new Option( - aliases: new string[] { "--with-librarypath", "-wlb" }, + aliases: s_withLibraryPathOptionAliases, description: "A library path to be used for the given declaration during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1256,7 +1285,7 @@ private static Option GetWithLibraryPathOption() private static Option GetWithManualImportOption() { return new Option( - aliases: new string[] { "--with-manual-import", "-wmi" }, + aliases: s_withManualImportOptionAliases, description: "A remapped function name to be treated as a manual import during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1267,7 +1296,7 @@ private static Option GetWithManualImportOption() private static Option GetWithNamespaceOption() { return new Option( - aliases: new string[] { "--with-namespace", "-wn" }, + aliases: s_withNamespaceOptionAliases, description: "A namespace to be used for the given remapped declaration name during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1278,7 +1307,7 @@ private static Option GetWithNamespaceOption() private static Option GetWithSetLastErrorOption() { return new Option( - aliases: new string[] { "--with-setlasterror", "-wsle" }, + aliases: s_withSetLastErrorOptionAliases, description: "Add the SetLastError=true modifier or SetsSystemLastError attribute to a given DllImport or UnmanagedFunctionPointer. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1289,7 +1318,7 @@ private static Option GetWithSetLastErrorOption() private static Option GetWithSuppressGCTransitionOption() { return new Option( - aliases: new string[] { "--with-suppressgctransition", "-wsgct" }, + aliases: s_withSuppressGCTransitionOptionAliases, description: "Add the SuppressGCTransition calling convention to a given DllImport or UnmanagedFunctionPointer. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1300,7 +1329,7 @@ private static Option GetWithSuppressGCTransitionOption() private static Option GetWithTransparentStructOption() { return new Option( - aliases: new string[] { "--with-transparent-struct", "-wts" }, + aliases: s_withTransparentStructOptionAliases, description: "A remapped type name to be treated as a transparent wrapper during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1311,7 +1340,7 @@ private static Option GetWithTransparentStructOption() private static Option GetWithTypeOption() { return new Option( - aliases: new string[] { "--with-type", "-wt" }, + aliases: s_withTypeOptionAliases, description: "A type to be used for the given enum declaration during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1322,7 +1351,7 @@ private static Option GetWithTypeOption() private static Option GetWithUsingOption() { return new Option( - aliases: new string[] { "--with-using", "-wu" }, + aliases: s_withUsingOptionAliases, description: "A using directive to be included for the given remapped declaration name during binding generation. Supports wildcards.", getDefaultValue: Array.Empty ) { @@ -1333,7 +1362,7 @@ private static Option GetWithUsingOption() private static Option GetWithPackingOption() { return new Option( - aliases: new string[] { "--with-packing", "-wp" }, + aliases: s_withPackingOptionAliases, description: "Overrides the StructLayoutAttribute.Pack property for the given type. Supports wildcards.", getDefaultValue: Array.Empty ) { diff --git a/sources/Directory.Build.props b/sources/Directory.Build.props index abe39a9c..793d46d3 100644 --- a/sources/Directory.Build.props +++ b/sources/Directory.Build.props @@ -11,8 +11,10 @@ --> - true sources + true + true + 16.0.0 @@ -21,8 +23,4 @@ - - - - diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs index 00ff4fac..498e3e22 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs @@ -7,6 +7,8 @@ namespace ClangSharp.UnitTests; public abstract class EnumDeclarationTest : PInvokeGeneratorTest { + protected static readonly string[] ExcludeTestExcludedNames = new[] { "MyEnum" }; + [Test] public Task BasicTest() => BasicTestImpl(); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs index 8896767d..8f78cf03 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs @@ -7,6 +7,8 @@ namespace ClangSharp.UnitTests; public abstract class FunctionDeclarationDllImportTest : PInvokeGeneratorTest { + protected static readonly string[] TemplateTestExcludedNames = new[] { "MyTemplate" }; + [Test] public Task BasicTest() => BasicTestImpl(); diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs index 39155de9..7cbce4d0 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs @@ -7,6 +7,9 @@ namespace ClangSharp.UnitTests; public abstract class StructDeclarationTest : PInvokeGeneratorTest { + protected static readonly string[] ExcludeTestExcludedNames = new[] { "MyStruct" }; + protected static readonly string[] GuidTestExcludedNames = new[] { "DECLSPEC_UUID" }; + [TestCase("double", "double")] [TestCase("short", "short")] [TestCase("int", "int")] diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs index 0191a3db..11d52129 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs @@ -7,6 +7,9 @@ namespace ClangSharp.UnitTests; public abstract class UnionDeclarationTest : PInvokeGeneratorTest { + protected static readonly string[] ExcludeTestExcludedNames = new[] { "MyUnion" }; + protected static readonly string[] GuidTestExcludedNames = new[] { "DECLSPEC_UUID" }; + [TestCase("double", "double")] [TestCase("short", "short")] [TestCase("int", "int")] diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs index 2fe6cacc..709a29fa 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs @@ -7,6 +7,9 @@ namespace ClangSharp.UnitTests; public abstract class VarDeclarationTest : PInvokeGeneratorTest { + protected static readonly string[] GuidMacroTestExcludedNames = new[] { "GUID" }; + protected static readonly string[] UncheckedConversionMacroTest2ExcludedNames = new string[] { "MyMacro1", "MyMacro2" }; + [TestCase("double", "double")] [TestCase("short", "short")] [TestCase("int", "int")] diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs index 60f6421a..c098bea0 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs @@ -66,9 +66,7 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs index ca9f676d..592315f5 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs @@ -113,7 +113,7 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -140,7 +140,7 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs index 8a9fd693..4f239fec 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs @@ -575,9 +575,7 @@ 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); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -962,8 +960,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs index 7d6a226b..c5883599 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs @@ -332,9 +332,7 @@ 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); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -762,8 +760,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs index 7ee90959..fb6ef467 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs @@ -63,10 +63,8 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -313,8 +311,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs index 7d07fefd..882351dd 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs @@ -66,9 +66,7 @@ protected override Task ExcludeTestImpl() "; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs index 8844419b..3f17231e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs @@ -113,7 +113,7 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -140,7 +140,7 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs index e9e79608..9fcde0b3 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs @@ -583,9 +583,7 @@ 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); + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -970,8 +968,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs index 5ed70629..fca6d026 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs @@ -339,9 +339,7 @@ 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); + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -769,8 +767,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs index 334ecc34..52b39637 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs @@ -63,10 +63,9 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -309,8 +308,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs index 08b3d3a1..c0ac7b8f 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs @@ -68,7 +68,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs index ca78342c..a74e2fb0 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs @@ -112,7 +112,7 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -139,7 +139,7 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs index a8ec57bc..f3acf867 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs @@ -574,9 +574,7 @@ protected override Task ExcludeTestImpl() { var inputContents = "typedef struct MyStruct MyStruct;"; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -969,8 +967,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/UnionDeclarationTest.cs index 5f67e586..d0854cce 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/UnionDeclarationTest.cs @@ -333,9 +333,7 @@ protected override Task ExcludeTestImpl() { var inputContents = "typedef union MyUnion MyUnion;"; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -763,8 +761,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs index caaad11c..06f3d3ea 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs @@ -63,10 +63,9 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -309,8 +308,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs index 86e14c89..db8f2a1d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs @@ -68,7 +68,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs index 9f232de1..47930afd 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs @@ -112,7 +112,7 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -139,7 +139,7 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs index 584eb391..7b768210 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs @@ -582,9 +582,7 @@ protected override Task ExcludeTestImpl() { var inputContents = "typedef struct MyStruct MyStruct;"; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -977,8 +975,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/UnionDeclarationTest.cs index 91e9cda4..bd84ddb1 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/UnionDeclarationTest.cs @@ -339,9 +339,7 @@ protected override Task ExcludeTestImpl() { var inputContents = "typedef union MyUnion MyUnion;"; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -769,8 +767,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs index cacb1645..fc499a97 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs @@ -63,10 +63,9 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -309,8 +308,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs index 0b218d49..a2f127d9 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs @@ -68,7 +68,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs index 36c87a42..4559142b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs @@ -112,7 +112,7 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -139,7 +139,7 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs index a65a79b6..a102e3fe 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs @@ -574,9 +574,7 @@ 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); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -981,8 +979,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs index da4dd78f..2bafe36e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs @@ -333,9 +333,7 @@ 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); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -775,8 +773,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs index b7d911dd..c4b29661 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs @@ -63,10 +63,9 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -309,8 +308,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs index 56ec148d..e9b8862b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs @@ -68,7 +68,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs index e6c80b83..3d7e4ce4 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs @@ -112,7 +112,7 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -139,7 +139,7 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs index 2de9281d..3088228d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs @@ -582,9 +582,7 @@ 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); + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -989,8 +987,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs index 9ef30142..184553c2 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs @@ -339,9 +339,7 @@ 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); + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -781,8 +779,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs index e503534a..3c023101 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs @@ -63,10 +63,9 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -309,8 +308,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs index f83cbbe6..acdd787d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs @@ -68,7 +68,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs index 38c0367a..97491edb 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs @@ -112,7 +112,7 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -139,7 +139,7 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs index 088cfb2c..80fb8761 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs @@ -574,9 +574,7 @@ 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); + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -981,8 +979,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs index 02f15c2e..e94aa3a9 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs @@ -333,9 +333,7 @@ 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); + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -775,8 +773,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs index a78d4955..e16e43df 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs @@ -63,10 +63,9 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -309,8 +308,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs index d6fee03f..5b6dc595 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs @@ -68,7 +68,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs index 0bb5d394..7d50416b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs @@ -112,7 +112,7 @@ public static partial class Methods }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -139,7 +139,7 @@ public partial struct MyStruct }} "; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs index 3b3d23b6..cad963c8 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs @@ -582,9 +582,7 @@ 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); + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -989,8 +987,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs index 21aef7fc..ee01012c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs @@ -339,9 +339,7 @@ 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); + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -781,8 +779,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs index 4b4b42e4..3507ad83 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs @@ -63,10 +63,9 @@ public static partial class Methods }} }} "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -309,8 +308,7 @@ public static partial class Methods }} "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj b/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj index 9f83f9d7..cf071218 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj @@ -3,7 +3,7 @@ ClangSharp.UnitTests - net6.0;net7.0 + net8.0 diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs index e407bb54..34c5260c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs @@ -87,7 +87,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs index c7b729b8..ec3977ef 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs @@ -121,7 +121,7 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -148,7 +148,7 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs index 053976d8..9d411a3d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs @@ -511,9 +511,7 @@ 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); + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -964,8 +962,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs index baecdca6..bc3c897e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs @@ -278,9 +278,7 @@ 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); + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -730,8 +728,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs index 57829f28..59996e28 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs @@ -77,10 +77,9 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -416,8 +415,7 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs index 7dcc7ac9..5bb0fb96 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs @@ -87,7 +87,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs index e54c8233..6c6a5167 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs @@ -121,7 +121,7 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -148,7 +148,7 @@ struct MyStruct "; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs index 2585bc27..f7017030 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs @@ -523,9 +523,7 @@ 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); + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -976,8 +974,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs index cf417eca..8237d1ba 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs @@ -284,9 +284,7 @@ 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); + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -736,8 +734,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs index 5bee145b..b2b1ca53 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs @@ -77,10 +77,9 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -416,8 +415,7 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs index 4ca2096f..51bdffb6 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs @@ -87,7 +87,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs index 4adb4e9d..277216f6 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs @@ -121,7 +121,7 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -148,7 +148,7 @@ struct MyStruct "; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs index 85165aa8..18ce25e9 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs @@ -511,9 +511,7 @@ protected override Task ExcludeTestImpl() { var inputContents = "typedef struct MyStruct MyStruct;"; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -968,8 +966,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/UnionDeclarationTest.cs index 2a08ef18..eb9dcd5d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/UnionDeclarationTest.cs @@ -278,9 +278,7 @@ protected override Task ExcludeTestImpl() { var inputContents = "typedef union MyUnion MyUnion;"; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -734,8 +732,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs index 78c38723..0687fe3d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs @@ -77,10 +77,9 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -416,8 +415,7 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs index 901b3317..f4259061 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs @@ -87,7 +87,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs index 727ec4d0..fccbad41 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs @@ -121,7 +121,7 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -148,7 +148,7 @@ struct MyStruct "; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs index 8358a33f..3ab54e84 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs @@ -523,9 +523,7 @@ protected override Task ExcludeTestImpl() { var inputContents = "typedef struct MyStruct MyStruct;"; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyStruct" }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -980,8 +978,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/UnionDeclarationTest.cs index bd94f902..7d35930e 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/UnionDeclarationTest.cs @@ -284,9 +284,7 @@ protected override Task ExcludeTestImpl() { var inputContents = "typedef union MyUnion MyUnion;"; var expectedOutputContents = string.Empty; - - var excludedNames = new string[] { "MyUnion" }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -740,8 +738,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs index 6fa4d3c5..232fa3da 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs @@ -77,10 +77,9 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -416,8 +415,7 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs index cfb68edf..2fecdfa2 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs @@ -87,7 +87,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs index 3b673858..4b51102f 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs @@ -121,7 +121,7 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -148,7 +148,7 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs index 2739d2dc..1945c634 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs @@ -511,9 +511,7 @@ 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); + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -968,8 +966,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs index b79b4d57..2eb1c643 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs @@ -278,9 +278,7 @@ 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); + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -734,8 +732,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs index 802a1b04..369debcc 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs @@ -77,10 +77,9 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -416,8 +415,7 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs index d7a426b1..07eb0393 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs @@ -87,7 +87,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs index 464d5cc8..80d4336a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs @@ -121,7 +121,7 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -148,7 +148,7 @@ struct MyStruct "; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs index 5b4e994a..1b0f083b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs @@ -523,9 +523,7 @@ 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); + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -980,8 +978,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs index 44326474..e03bb56a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs @@ -284,9 +284,7 @@ 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); + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -740,8 +738,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs index 44835beb..84ca154a 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs @@ -78,10 +78,9 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -417,8 +416,7 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs index 9d6ce193..d4470508 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs @@ -87,7 +87,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs index bfb100c0..0932e32b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs @@ -121,7 +121,7 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -148,7 +148,7 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs index e15378b3..deb6c8db 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs @@ -511,9 +511,7 @@ 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); + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -968,8 +966,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs index 40a4eb9a..ccf5d9e7 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs @@ -278,9 +278,7 @@ 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); + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -734,8 +732,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs index 0ea9ba3b..612618a0 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs @@ -77,10 +77,9 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -416,8 +415,7 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs index 4334e19e..9dac6dbe 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs @@ -87,7 +87,7 @@ protected override Task ExcludeTestImpl() var expectedOutputContents = string.Empty; var excludedNames = new string[] { "MyEnum" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs index 4c946dfc..6688ab81 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs @@ -121,7 +121,7 @@ protected override Task TemplateParameterTestImpl(string nativeType, bool expect "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task TemplateMemberTestImpl() @@ -148,7 +148,7 @@ struct MyStruct "; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: new[] { "MyTemplate" }); + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); } protected override Task NoLibraryPathTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs index 662d71cb..858fd9e4 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs @@ -523,9 +523,7 @@ 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); + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -980,8 +978,7 @@ struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task InheritanceTestImpl() diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs index 4acc9f60..1eb96666 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs @@ -284,9 +284,7 @@ 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); + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); } protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) @@ -740,8 +738,7 @@ union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 "; - var excludedNames = new string[] { "DECLSPEC_UUID" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); } protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs index be1232b1..b81a2c91 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs @@ -77,10 +77,9 @@ protected override Task GuidMacroTestImpl() "; - var excludedNames = new string[] { "GUID" }; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames, remappedNames: remappedNames); + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); } protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) @@ -416,8 +415,7 @@ protected override Task UncheckedConversionMacroTest2Impl() "; - var excludedNames = new string[] { "MyMacro1", "MyMacro2" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: excludedNames); + return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); } protected override Task UncheckedPointerMacroTestImpl() diff --git a/tests/ClangSharp.UnitTests/ClangSharp.UnitTests.csproj b/tests/ClangSharp.UnitTests/ClangSharp.UnitTests.csproj index 3b69112c..809e4542 100644 --- a/tests/ClangSharp.UnitTests/ClangSharp.UnitTests.csproj +++ b/tests/ClangSharp.UnitTests/ClangSharp.UnitTests.csproj @@ -2,7 +2,7 @@ - net6.0;net7.0 + net8.0 From e386195fab6517b494912c14d2f63766c9db0fa9 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sat, 8 Jul 2023 11:47:01 -0700 Subject: [PATCH 2/4] Update the CompatibilitySuppressions.xml --- Directory.Build.props | 1 + .../CompatibilitySuppressions.xml | 58 +++++++++++++++++++ .../CompatibilitySuppressions.xml | 12 ++++ .../ClangSharp/CompatibilitySuppressions.xml | 25 ++++++++ sources/Directory.Build.props | 1 - 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 sources/ClangSharp.Interop/CompatibilitySuppressions.xml create mode 100644 sources/ClangSharp.PInvokeGenerator/CompatibilitySuppressions.xml create mode 100644 sources/ClangSharp/CompatibilitySuppressions.xml diff --git a/Directory.Build.props b/Directory.Build.props index 01e2980e..91d6fd50 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -47,6 +47,7 @@ true true $(BaseArtifactsPath)pkg/$(Configuration)/ + 16.0.0 ClangSharp ClangSharp 16.0.1 diff --git a/sources/ClangSharp.Interop/CompatibilitySuppressions.xml b/sources/ClangSharp.Interop/CompatibilitySuppressions.xml new file mode 100644 index 00000000..3d1754f1 --- /dev/null +++ b/sources/ClangSharp.Interop/CompatibilitySuppressions.xml @@ -0,0 +1,58 @@ + + + + CP0002 + M:ClangSharp.Interop.clang.add_ResolveLibrary(System.Runtime.InteropServices.DllImportResolver) + lib/net6.0/ClangSharp.Interop.dll + lib/netstandard2.0/ClangSharp.Interop.dll + true + + + CP0002 + M:ClangSharp.Interop.clang.remove_ResolveLibrary(System.Runtime.InteropServices.DllImportResolver) + lib/net6.0/ClangSharp.Interop.dll + lib/netstandard2.0/ClangSharp.Interop.dll + true + + + CP0002 + M:ClangSharp.Interop.CXCodeCompleteResults.GetContaininerKind(System.Boolean@) + lib/net6.0/ClangSharp.Interop.dll + lib/netstandard2.0/ClangSharp.Interop.dll + true + + + CP0002 + M:ClangSharp.Interop.clang.add_ResolveLibrary(System.Runtime.InteropServices.DllImportResolver) + lib/net7.0/ClangSharp.Interop.dll + lib/netstandard2.0/ClangSharp.Interop.dll + true + + + CP0002 + M:ClangSharp.Interop.clang.remove_ResolveLibrary(System.Runtime.InteropServices.DllImportResolver) + lib/net7.0/ClangSharp.Interop.dll + lib/netstandard2.0/ClangSharp.Interop.dll + true + + + CP0002 + M:ClangSharp.Interop.CXCodeCompleteResults.GetContaininerKind(System.Boolean@) + lib/net7.0/ClangSharp.Interop.dll + lib/netstandard2.0/ClangSharp.Interop.dll + true + + + CP0002 + M:ClangSharp.Interop.CXCodeCompleteResults.GetContaininerKind(out bool) + lib/netstandard2.0/ClangSharp.Interop.dll + lib/netstandard2.0/ClangSharp.Interop.dll + + + CP0002 + M:ClangSharp.Interop.CXCodeCompleteResults.GetContaininerKind(System.Boolean@) + lib/netstandard2.0/ClangSharp.Interop.dll + lib/netstandard2.0/ClangSharp.Interop.dll + true + + diff --git a/sources/ClangSharp.PInvokeGenerator/CompatibilitySuppressions.xml b/sources/ClangSharp.PInvokeGenerator/CompatibilitySuppressions.xml new file mode 100644 index 00000000..c4d13736 --- /dev/null +++ b/sources/ClangSharp.PInvokeGenerator/CompatibilitySuppressions.xml @@ -0,0 +1,12 @@ + + + + + PKV006 + net6.0 + + + PKV006 + net7.0 + + \ No newline at end of file diff --git a/sources/ClangSharp/CompatibilitySuppressions.xml b/sources/ClangSharp/CompatibilitySuppressions.xml new file mode 100644 index 00000000..f13ca720 --- /dev/null +++ b/sources/ClangSharp/CompatibilitySuppressions.xml @@ -0,0 +1,25 @@ + + + + + CP0002 + M:ClangSharp.LinkageSpecDecl.get_Langage + lib/net6.0/ClangSharp.dll + lib/netstandard2.0/ClangSharp.dll + true + + + CP0002 + M:ClangSharp.LinkageSpecDecl.get_Langage + lib/net7.0/ClangSharp.dll + lib/netstandard2.0/ClangSharp.dll + true + + + CP0002 + M:ClangSharp.LinkageSpecDecl.get_Langage + lib/netstandard2.0/ClangSharp.dll + lib/netstandard2.0/ClangSharp.dll + true + + \ No newline at end of file diff --git a/sources/Directory.Build.props b/sources/Directory.Build.props index 793d46d3..6f7f4210 100644 --- a/sources/Directory.Build.props +++ b/sources/Directory.Build.props @@ -14,7 +14,6 @@ sources true true - 16.0.0 From d4282a140465a7083efd69fb105f7b40fd3f6e40 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Sat, 8 Jul 2023 11:58:29 -0700 Subject: [PATCH 3/4] Ensure the failed to resolve message only prints where relevant --- sources/ClangSharp.Interop/clang.cs | 7 ---- .../PInvokeGenerator.cs | 36 +++++++++++++++++-- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/sources/ClangSharp.Interop/clang.cs b/sources/ClangSharp.Interop/clang.cs index d82c9b45..47baef81 100644 --- a/sources/ClangSharp.Interop/clang.cs +++ b/sources/ClangSharp.Interop/clang.cs @@ -31,13 +31,6 @@ private static IntPtr OnDllImport(string libraryName, Assembly assembly, DllImpo return nativeLibrary; } - Console.WriteLine(); - Console.WriteLine("*****IMPORTANT*****"); - Console.WriteLine($"Failed to resolve {libraryName}."); - Console.WriteLine("If you are running as a dotnet tool, you may need to manually copy the appropriate DLLs from NuGet due to limitations in the dotnet tool support. Please see https://github.com/dotnet/clangsharp for more details."); - Console.WriteLine("*****IMPORTANT*****"); - Console.WriteLine(); - return IntPtr.Zero; } diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs index e3fb5be6..dd3bbfb0 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs @@ -83,14 +83,46 @@ public PInvokeGenerator(PInvokeGeneratorConfiguration config, Func Date: Sat, 8 Jul 2023 12:30:29 -0700 Subject: [PATCH 4/4] Don't include the WIP InlineArray functionality --- .../CSharp/CSharpOutputBuilder.Visit.cs | 4 ---- .../PInvokeGenerator.VisitDecl.cs | 13 ++----------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs index c2f7a2fb..8d3c31e6 100644 --- a/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs +++ b/sources/ClangSharp.PInvokeGenerator/CSharp/CSharpOutputBuilder.Visit.cs @@ -22,10 +22,6 @@ public void WriteCustomAttribute(string attribute, Action? callback = null) { AddUsingDirective("System.Diagnostics.CodeAnalysis"); } - else if (attribute.StartsWith("InlineArray(")) - { - AddUsingDirective("System.Runtime.CompilerServices"); - } else if (attribute.StartsWith("Guid(")|| attribute.Equals("Optional") || attribute.StartsWith("Optional, DefaultParameterValue(")) { AddUsingDirective("System.Runtime.InteropServices"); diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs index dd21b195..3d39598f 100644 --- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs +++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs @@ -2888,11 +2888,6 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co generator.WithAttributes(fieldDecl); generator.WithUsings(fieldDecl); - - if (generator.Config.GeneratePreviewCode) - { - outputBuilder.WriteCustomAttribute($"InlineArray({totalSizeString})"); - } }, CustomAttrGeneratorData = (constantOrIncompleteArray, _outputBuilder, this, totalSizeString), }; @@ -2900,7 +2895,7 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co _outputBuilder.BeginStruct(in desc); var firstFieldName = ""; - var numFieldsToEmit = _config.GeneratePreviewCode ? Math.Min(totalSize, 1) : totalSize; + var numFieldsToEmit = totalSize; for (long i = 0; i < numFieldsToEmit; i++) { @@ -2954,11 +2949,7 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co var generateCompatibleCode = _config.GenerateCompatibleCode; - if (_config.GeneratePreviewCode) - { - // Nothing to emit - } - else if (generateCompatibleCode || isUnsafeElementType) + if (generateCompatibleCode || isUnsafeElementType) { _outputBuilder.BeginIndexer(AccessSpecifier.Public, isUnsafe: generateCompatibleCode && !isUnsafeElementType, needsUnscopedRef: false); _outputBuilder.WriteIndexer($"ref {arrayTypeName}");