diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
index 4079ca858..8afb852d7 100644
--- a/.github/copilot-instructions.md
+++ b/.github/copilot-instructions.md
@@ -20,10 +20,11 @@ in the **generator** instead — change the generator, then regenerate.
## Build / test (do this to validate every change)
-Requires the **.NET 10 SDK** (`global.json` pins `10.0.100-preview`, `allowPrerelease`). `dotnet` resolves it.
+Requires the **.NET 11 SDK** (`global.json` pins `11.0.100`). Projects target both `net11.0` and
+`net10.0`, with .NET 11 as the primary target.
- Build: `dotnet build -c Release` (root, builds `ClangSharp.slnx`). ~20s incremental, clean.
-- Test: `dotnet test -c Release --no-build` (~1 min; ~3760 tests: 3706 generator + interop on `net10.0`).
+- Test: `dotnet test -c Release --no-build` (runs the test projects on both `net11.0` and `net10.0`).
- `--no-build` requires a prior successful build; drop it if you changed code since the last build.
`TreatWarningsAsErrors=true`, `Nullable=enable`, `AnalysisLevel=latest-all`, and `EnforceCodeStyleInBuild=true`
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9e40d2810..ae0dc2697 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,10 +16,10 @@ jobs:
configuration: [ debug, release ]
os: [ windows ]
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
- run: ./scripts/cibuild.cmd -configuration ${{ matrix.configuration }} -architecture ${{ matrix.architecture }}
shell: cmd
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}
path: |
@@ -27,7 +27,7 @@ jobs:
./artifacts/log/**/*
./artifacts/tst/**/*
if-no-files-found: error
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}_pkg
path: |
@@ -41,10 +41,10 @@ jobs:
configuration: [ debug, release ]
os: [ windows ]
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
- run: ./scripts/cibuild.cmd -configuration ${{ matrix.configuration }} -architecture ${{ matrix.architecture }}
shell: cmd
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}
path: |
@@ -52,7 +52,7 @@ jobs:
./artifacts/log/**/*
./artifacts/tst/**/*
if-no-files-found: error
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}_pkg
path: |
@@ -66,10 +66,10 @@ jobs:
configuration: [ debug, release ]
os: [ ubuntu ]
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
- run: ./scripts/cibuild.sh --configuration ${{ matrix.configuration }} --architecture ${{ matrix.architecture }}
shell: bash
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}
path: |
@@ -77,7 +77,7 @@ jobs:
./artifacts/log/**/*
./artifacts/tst/**/*
if-no-files-found: error
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}_pkg
path: |
@@ -91,10 +91,10 @@ jobs:
configuration: [ debug, release ]
os: [ ubuntu ]
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
- run: ./scripts/cibuild.sh --configuration ${{ matrix.configuration }} --architecture ${{ matrix.architecture }}
shell: bash
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}
path: |
@@ -102,7 +102,7 @@ jobs:
./artifacts/log/**/*
./artifacts/tst/**/*
if-no-files-found: error
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}_pkg
path: |
@@ -116,10 +116,10 @@ jobs:
configuration: [ debug, release ]
os: [ macos ]
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
- run: ./scripts/cibuild.sh --configuration ${{ matrix.configuration }} --architecture ${{ matrix.architecture }}
shell: bash
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}
path: |
@@ -127,7 +127,7 @@ jobs:
./artifacts/log/**/*
./artifacts/tst/**/*
if-no-files-found: error
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: ${{ matrix.os }}_${{ matrix.configuration }}_${{ matrix.architecture }}_pkg
path: |
@@ -140,24 +140,24 @@ jobs:
permissions:
id-token: write
steps:
- - uses: actions/checkout@v4
- - uses: actions/download-artifact@v4
+ - uses: actions/checkout@v7
+ - uses: actions/download-artifact@v8
with:
merge-multiple: true
path: ./artifacts/pkg
pattern: "*_release_*_pkg"
- - uses: actions/setup-dotnet@v4
+ - uses: actions/setup-dotnet@v6
with:
global-json-file: ./global.json
- run: dotnet tool install --tool-path ./artifacts/tools --prerelease sign
- - uses: azure/login@v2
+ - uses: azure/login@v3
with:
allow-no-subscriptions: true
client-id: "${{ secrets.AZURE_CLIENT_ID }}"
tenant-id: "${{ secrets.AZURE_TENANT_ID }}"
- run: ./artifacts/tools/sign code azure-key-vault "**/*.nupkg" --base-directory "${{ github.workspace }}/artifacts/pkg" --file-list "${{ github.workspace }}/scripts/SignClientFileList.txt" --publisher-name ".NET Foundation" --description "ClangSharp" --description-url "https://github.com/dotnet/clangsharp" --azure-credential-type "azure-cli" --azure-key-vault-url "${{ secrets.KEY_VAULT_URL }}" --azure-key-vault-certificate "${{ secrets.KEY_VAULT_CERTIFICATE_ID }}"
shell: pwsh
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: sign_nuget
path: |
diff --git a/.github/workflows/regenerate-native.yml b/.github/workflows/regenerate-native.yml
index 52c626379..991757c07 100644
--- a/.github/workflows/regenerate-native.yml
+++ b/.github/workflows/regenerate-native.yml
@@ -44,7 +44,7 @@ jobs:
libclang: ${{ steps.detect.outputs.libclang }}
libclangsharp: ${{ steps.detect.outputs.libclangsharp }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
with:
fetch-depth: 0
- id: detect
@@ -77,8 +77,8 @@ jobs:
# bundled bsdtar handles .tar.xz) can produce every runtime's package.
runs-on: windows-latest
steps:
- - uses: actions/checkout@v4
- - uses: NuGet/setup-nuget@v2
+ - uses: actions/checkout@v7
+ - uses: NuGet/setup-nuget@v4
- name: Extract libclang and pack packages
shell: pwsh
run: |
@@ -93,7 +93,7 @@ jobs:
}
nuget pack "packages/libclang/libclang/libclang.nuspec" -OutputDirectory out
if ($LASTEXITCODE -ne 0) { throw "nuget pack failed for the libclang meta package" }
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: libclang-packages
path: out/*.nupkg
@@ -115,7 +115,7 @@ jobs:
- { rid: linux-arm64, os: ubuntu-24.04-arm }
- { rid: osx-arm64, os: macos-latest }
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v7
- name: Install LLVM dependencies (Windows)
if: runner.os == 'Windows'
shell: pwsh
@@ -135,7 +135,7 @@ jobs:
if: runner.os != 'Windows'
shell: bash
run: ./scripts/build.sh --regeneratenative --target libClangSharp --rid ${{ matrix.rid }}
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: libclangsharp-native-${{ matrix.rid }}
path: artifacts/native/${{ matrix.rid }}/*
@@ -146,9 +146,9 @@ jobs:
if: ${{ needs.detect.outputs.libclangsharp == 'true' }}
runs-on: windows-latest
steps:
- - uses: actions/checkout@v4
- - uses: NuGet/setup-nuget@v2
- - uses: actions/download-artifact@v4
+ - uses: actions/checkout@v7
+ - uses: NuGet/setup-nuget@v4
+ - uses: actions/download-artifact@v8
with:
pattern: libclangsharp-native-*
path: staging
@@ -162,7 +162,7 @@ jobs:
nuget pack "packages/libClangSharp/libClangSharp.runtime.${rid}/libClangSharp.runtime.${rid}.nuspec" -OutputDirectory out
done
nuget pack "packages/libClangSharp/libClangSharp/libClangSharp.nuspec" -OutputDirectory out
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: libClangSharp-packages
path: out/*.nupkg
@@ -184,24 +184,24 @@ jobs:
permissions:
id-token: write
steps:
- - uses: actions/checkout@v4
- - uses: actions/download-artifact@v4
+ - uses: actions/checkout@v7
+ - uses: actions/download-artifact@v8
with:
merge-multiple: true
path: ./artifacts/pkg
pattern: "lib*-packages"
- - uses: actions/setup-dotnet@v4
+ - uses: actions/setup-dotnet@v6
with:
global-json-file: ./global.json
- run: dotnet tool install --tool-path ./artifacts/tools --prerelease sign
- - uses: azure/login@v2
+ - uses: azure/login@v3
with:
allow-no-subscriptions: true
client-id: "${{ secrets.AZURE_CLIENT_ID }}"
tenant-id: "${{ secrets.AZURE_TENANT_ID }}"
- run: ./artifacts/tools/sign code azure-key-vault "**/*.nupkg" --base-directory "${{ github.workspace }}/artifacts/pkg" --file-list "${{ github.workspace }}/scripts/SignClientFileListNative.txt" --publisher-name ".NET Foundation" --description "ClangSharp" --description-url "https://github.com/dotnet/clangsharp" --azure-credential-type "azure-cli" --azure-key-vault-url "${{ secrets.KEY_VAULT_URL }}" --azure-key-vault-certificate "${{ secrets.KEY_VAULT_CERTIFICATE_ID }}"
shell: pwsh
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: sign_nuget_native
path: |
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 533b0b352..93c7e8b4e 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -14,9 +14,9 @@
-
-
-
+
+
+
diff --git a/README.md b/README.md
index fcecf56c0..898fdf5ca 100644
--- a/README.md
+++ b/README.md
@@ -57,7 +57,7 @@ See [LICENSE.md](LICENSE.md) in the repository root for more information.
### Building Managed
-ClangSharp requires the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) and can be built simply with `dotnet build -c Release`.
+ClangSharp requires the [.NET 11 SDK](https://dotnet.microsoft.com/download/dotnet/11.0) and can be built simply with `dotnet build -c Release`.
The managed libraries and generator target LLVM 23.1.5 and use the matching `libClang` 23.1.5 and `libClangSharp` 23.1.5.0 runtime packages.
@@ -277,7 +277,7 @@ Options:
# Mode Families (-c =)
- codegen= Which .NET/C# level to target: 'compatible' (.NET Standard 2.0), 'default' (current LTS; .NET 8/C# 12), 'latest' (current STS; .NET 10/C# 14), or 'preview'. Defaults to 'default'.
+ codegen= Which .NET/C# level to target: 'compatible' (.NET Standard 2.0), 'default' (current LTS; .NET 10/C# 14), 'latest' (current STS; .NET 11/C# 15), or 'preview'. Defaults to 'default'.
file= How output is split: 'single' (one output file; the default) or 'multi' (approximately one type per file).
types= Which platform defaults to assume: 'windows' or 'unix'. Defaults to the host platform.
vtbls= How VTBLs are generated: 'explicit' (a named field per entry), 'implicit' (the default; reduces metadata bloat), or 'trimmable' (defined but unused in helpers to reduce bloat when trimming).
diff --git a/docs/using-clangsharp-as-a-library.md b/docs/using-clangsharp-as-a-library.md
index 18124309a..95828509c 100644
--- a/docs/using-clangsharp-as-a-library.md
+++ b/docs/using-clangsharp-as-a-library.md
@@ -97,7 +97,7 @@ so the correct platform-specific runtime package is restored:
Exe
- net10.0
+ net11.0
enable
@@ -106,7 +106,7 @@ so the correct platform-specific runtime package is restored:
-
+
diff --git a/global.json b/global.json
index ff239fd96..18f080beb 100644
--- a/global.json
+++ b/global.json
@@ -1,7 +1,7 @@
{
"sdk": {
- "version": "10.0.100-preview",
- "allowPrerelease": true,
+ "version": "11.0.100",
+ "allowPrerelease": false,
"rollForward": "latestFeature"
}
}
diff --git a/scripts/build.ps1 b/scripts/build.ps1
index e8d82483c..8ddd5c9bf 100644
--- a/scripts/build.ps1
+++ b/scripts/build.ps1
@@ -544,7 +544,7 @@ try {
$DotNetInstallDirectory = Join-Path -Path $ArtifactsDir -ChildPath "dotnet"
Create-Directory -Path $DotNetInstallDirectory
- & $DotNetInstallScript -Channel 8.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture
+ & $DotNetInstallScript -Channel 11.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture
& $DotNetInstallScript -Channel 10.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture
$env:PATH="$DotNetInstallDirectory;$env:PATH"
diff --git a/scripts/build.sh b/scripts/build.sh
index 45f981738..c8e54f102 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -568,7 +568,7 @@ if [[ ! -z "$architecture" ]]; then
DotNetInstallDirectory="$ArtifactsDir/dotnet"
CreateDirectory "$DotNetInstallDirectory"
- . "$DotNetInstallScript" --channel 8.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture"
+ . "$DotNetInstallScript" --channel 11.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture"
. "$DotNetInstallScript" --channel 10.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture"
PATH="$DotNetInstallDirectory:$PATH:"
diff --git a/sources/ClangSharp.Interop/ClangSharp.Interop.csproj b/sources/ClangSharp.Interop/ClangSharp.Interop.csproj
index c8dd64519..50fb2c5b0 100644
--- a/sources/ClangSharp.Interop/ClangSharp.Interop.csproj
+++ b/sources/ClangSharp.Interop/ClangSharp.Interop.csproj
@@ -2,7 +2,7 @@
- net10.0
+ net11.0;net10.0
diff --git a/sources/ClangSharp.PInvokeGenerator/ClangSharp.PInvokeGenerator.csproj b/sources/ClangSharp.PInvokeGenerator/ClangSharp.PInvokeGenerator.csproj
index 6e3ab67ea..0aad9fe33 100644
--- a/sources/ClangSharp.PInvokeGenerator/ClangSharp.PInvokeGenerator.csproj
+++ b/sources/ClangSharp.PInvokeGenerator/ClangSharp.PInvokeGenerator.csproj
@@ -3,7 +3,7 @@
ClangSharp
- net10.0
+ net11.0;net10.0
diff --git a/sources/ClangSharp.PInvokeGenerator/Extensions/StringExtensions.cs b/sources/ClangSharp.PInvokeGenerator/Extensions/StringExtensions.cs
index c995e34ed..4a9ee944b 100644
--- a/sources/ClangSharp.PInvokeGenerator/Extensions/StringExtensions.cs
+++ b/sources/ClangSharp.PInvokeGenerator/Extensions/StringExtensions.cs
@@ -8,6 +8,7 @@ namespace ClangSharp;
internal static class StringExtensions
{
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1307:SpecifyStringComparison", Justification = "Single-character overloads use ordinal comparison.")]
public static string Unquote(this string str)
=> str.StartsWith('\"') && str.EndsWith('\"') && !str.EndsWith("\\\"", StringComparison.Ordinal)
? str[1..^1]
diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.Naming.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.Naming.cs
index 6b6a8bc1a..57b84cd53 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.Naming.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.Naming.cs
@@ -422,7 +422,7 @@ void AppendTemplateArguments(ClassTemplateSpecializationDecl classTemplateSpecia
var templateArgs = classTemplateSpecializationDecl.TemplateArgs;
- if (templateArgs.Any())
+ if (templateArgs.Count > 0)
{
AppendTemplateArgument(templateArgs[0], qualifiedName);
@@ -448,7 +448,7 @@ void AppendTemplateParameters(TemplateDecl templateDecl, StringBuilder qualified
var templateParameters = templateDecl.TemplateParameters;
- if (templateParameters.Any())
+ if (templateParameters.Count > 0)
{
_ = qualifiedName.Append(templateParameters[0].Name);
diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.Predicates.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.Predicates.cs
index 084bd8635..960c91787 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.Predicates.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.Predicates.cs
@@ -1688,6 +1688,7 @@ private bool IsUnsafe(NamedDecl namedDecl, Type type)
return remappedName.Contains('*', StringComparison.Ordinal);
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1307:SpecifyStringComparison", Justification = "The single-character overload uses ordinal comparison.")]
private static bool IsUnsigned(string typeName)
{
switch (typeName)
diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.TypeResolution.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.TypeResolution.cs
index 2426e529b..e65bc82fb 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.TypeResolution.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.TypeResolution.cs
@@ -119,6 +119,7 @@ private string GetTypeName(Cursor? cursor, Cursor? context, Type type, bool igno
}
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1307:SpecifyStringComparison", Justification = "The single-character overload uses ordinal comparison.")]
private string GetTypeName(Cursor? cursor, Cursor? context, Type rootType, Type type, bool ignoreTransparentStructsWhereRequired, bool isTemplate, out string nativeTypeName)
{
if (!_typeNames.TryGetValue((cursor, context, type), out var result))
@@ -770,6 +771,7 @@ private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref lon
GetTypeSize(cursor, type, ref alignment32, ref alignment64, ref has8BytePrimitiveField, out size32, out size64);
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1307:SpecifyStringComparison", Justification = "The single-character overload uses ordinal comparison.")]
private void GetTypeSize(Cursor cursor, Type type, ref long alignment32, ref long alignment64, ref bool has8BytePrimitiveField, out long size32, out long size64)
{
size32 = 0;
diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs
index 4d5502c11..a3e8cc0fc 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitDecl.cs
@@ -781,7 +781,7 @@ private void VisitFunctionDecl(FunctionDecl functionDecl)
_outputBuilder.EndParameter(in parameterDesc);
}
- if (functionDecl.Parameters.Any())
+ if (functionDecl.Parameters.Count > 0)
{
_outputBuilder.WriteParameterSeparator();
}
@@ -791,7 +791,7 @@ private void VisitFunctionDecl(FunctionDecl functionDecl)
if (functionDecl.IsVariadic)
{
- if (needsThis || functionDecl.Parameters.Any())
+ if (needsThis || functionDecl.Parameters.Count > 0)
{
_outputBuilder.WriteParameterSeparator();
}
@@ -877,7 +877,7 @@ private void VisitFunctionDecl(FunctionDecl functionDecl)
}
else
{
- var firstCtorInitializer = functionDecl.Parameters.Any() ? (functionDecl.CursorChildren.IndexOf(functionDecl.Parameters[functionDecl.Parameters.Count - 1]) + 1) : 0;
+ var firstCtorInitializer = functionDecl.Parameters.Count > 0 ? (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)
diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitRecordDecl.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitRecordDecl.cs
index b04e45dc6..caa40d4a0 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitRecordDecl.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitRecordDecl.cs
@@ -54,7 +54,7 @@ private void VisitRecordDecl(RecordDecl recordDecl)
}
var alignment = Math.Max(recordDecl.TypeForDecl.Handle.AlignOf, 1);
- var maxAlignm = recordDecl.Fields.Any() ? recordDecl.Fields.Max((fieldDecl) => Math.Max(fieldDecl.Type.Handle.AlignOf, 1)) : alignment;
+ var maxAlignm = recordDecl.Fields.Count > 0 ? recordDecl.Fields.Max((fieldDecl) => Math.Max(fieldDecl.Type.Handle.AlignOf, 1)) : alignment;
var isTopLevelStruct = _config.WithTypes.TryGetValue(StripNameEscape(name), out var withType) && withType.Equals("struct", StringComparison.Ordinal);
var generateTestsClass = !recordDecl.IsAnonymousStructOrUnion && recordDecl.DeclContext is not RecordDecl;
@@ -159,7 +159,7 @@ private void VisitRecordDecl(RecordDecl recordDecl)
}
string? nativeNameWithExtras = null, nativeInheritance = null;
- if ((cxxRecordDecl is not null) && cxxRecordDecl.Bases.Any())
+ if ((cxxRecordDecl is not null) && cxxRecordDecl.Bases.Count > 0)
{
var nativeTypeNameBuilder = new StringBuilder();
var baseTypeNamesBuilder = new List();
@@ -1868,7 +1868,7 @@ void VisitConstantOrIncompleteArrayFieldDecl(RecordDecl recordDecl, FieldDecl co
_outputBuilder.WriteDivider();
var alignment = Math.Max(recordDecl.TypeForDecl.Handle.AlignOf, 1);
- var maxAlignm = recordDecl.Fields.Any() ? recordDecl.Fields.Max((fieldDecl) => Math.Max(fieldDecl.Type.Handle.AlignOf, 1)) : alignment;
+ var maxAlignm = recordDecl.Fields.Count > 0 ? recordDecl.Fields.Max((fieldDecl) => Math.Max(fieldDecl.Type.Handle.AlignOf, 1)) : alignment;
var accessSpecifier = GetAccessSpecifier(constantOrIncompleteArray, matchStar: false);
var elementType = arrayType.ElementType;
diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs
index b8838b1d1..4dcfa407d 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.VisitStmt.cs
@@ -1349,6 +1349,7 @@ private void VisitExprWithCleanups(ExprWithCleanups exprWithCleanups)
Visit(exprWithCleanups.Objects);
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1307:SpecifyStringComparison", Justification = "The single-character overload uses ordinal comparison.")]
private void VisitFloatingLiteral(FloatingLiteral floatingLiteral)
{
var outputBuilder = StartCSharpCode();
diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs
index 6f450550b..2796115a6 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs
@@ -1701,7 +1701,7 @@ private bool HasBaseField(CXXRecordDecl cxxRecordDecl)
private bool HasField(RecordDecl recordDecl)
{
- var hasField = recordDecl.Fields.Any() || recordDecl.Decls.Any((decl) => (decl is RecordDecl nestedRecordDecl) && nestedRecordDecl.IsAnonymousStructOrUnion && HasField(nestedRecordDecl));
+ var hasField = recordDecl.Fields.Count > 0 || recordDecl.Decls.Any((decl) => (decl is RecordDecl nestedRecordDecl) && nestedRecordDecl.IsAnonymousStructOrUnion && HasField(nestedRecordDecl));
if (!hasField && (recordDecl is CXXRecordDecl cxxRecordDecl))
{
@@ -2828,6 +2828,7 @@ private string GetClass(string remappedName, bool disallowPrefixMatch = false)
return className;
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1307:SpecifyStringComparison", Justification = "The single-character overload uses ordinal comparison.")]
private bool TryGetClass(ReadOnlySpan remappedName, [MaybeNullWhen(false)] out string className, bool disallowPrefixMatch = false)
{
remappedName = StripNameEscape(remappedName);
diff --git a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs
index ec0bf9003..2678acf6b 100644
--- a/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs
+++ b/sources/ClangSharp.PInvokeGenerator/PInvokeGeneratorConfiguration.cs
@@ -1109,5 +1109,6 @@ private static void AddRange(HashSet hashSet, IEnumerable (ValueStartsWithAt(value.Name) ? value.Name[1..] : value.Name, value.Kind);
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1307:SpecifyStringComparison", Justification = "The single-character overload uses ordinal comparison.")]
private static bool ValueStartsWithAt(string value) => value.StartsWith('@');
}
diff --git a/sources/ClangSharp/ClangSharp.csproj b/sources/ClangSharp/ClangSharp.csproj
index 778545f61..7f5da4bd2 100644
--- a/sources/ClangSharp/ClangSharp.csproj
+++ b/sources/ClangSharp/ClangSharp.csproj
@@ -2,7 +2,7 @@
- net10.0
+ net11.0;net10.0
diff --git a/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj b/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj
index 62a74468f..bb450258a 100644
--- a/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj
+++ b/sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj
@@ -7,7 +7,7 @@
README.md
true
linux-arm64;linux-x64;osx-arm64;win-arm64;win-x64
- net10.0
+ net11.0
$(NoWarn);CA1303
diff --git a/sources/ClangSharpPInvokeGenerator/Program.Options.cs b/sources/ClangSharpPInvokeGenerator/Program.Options.cs
index 91757d0e8..a01c63038 100644
--- a/sources/ClangSharpPInvokeGenerator/Program.Options.cs
+++ b/sources/ClangSharpPInvokeGenerator/Program.Options.cs
@@ -216,7 +216,7 @@ internal static partial class Program
new HelpRow("# Mode Families (-c =)", ""),
new HelpRow("", ""),
- new HelpRow("codegen=", "Which .NET/C# level to target: 'compatible' (.NET Standard 2.0), 'default' (current LTS; .NET 8/C# 12), 'latest' (current STS; .NET 10/C# 14), or 'preview'. Defaults to 'default'."),
+ new HelpRow("codegen=", "Which .NET/C# level to target: 'compatible' (.NET Standard 2.0), 'default' (current LTS; .NET 10/C# 14), 'latest' (current STS; .NET 11/C# 15), or 'preview'. Defaults to 'default'."),
new HelpRow("file=", "How output is split: 'single' (one output file; the default) or 'multi' (approximately one type per file)."),
new HelpRow("types=", "Which platform defaults to assume: 'windows' or 'unix'. Defaults to the host platform."),
new HelpRow("vtbls=", "How VTBLs are generated: 'explicit' (a named field per entry), 'implicit' (the default; reduces metadata bloat), or 'trimmable' (defined but unused in helpers to reduce bloat when trimming)."),
diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj b/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj
index 5b1486ec0..cf86f2aaf 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
- net10.0
+ net11.0;net10.0
diff --git a/tests/ClangSharp.UnitTests/ClangSharp.UnitTests.csproj b/tests/ClangSharp.UnitTests/ClangSharp.UnitTests.csproj
index 6a7067c4e..198929126 100644
--- a/tests/ClangSharp.UnitTests/ClangSharp.UnitTests.csproj
+++ b/tests/ClangSharp.UnitTests/ClangSharp.UnitTests.csproj
@@ -2,7 +2,7 @@
- net10.0
+ net11.0;net10.0
diff --git a/tests/ClangSharpPInvokeGenerator.UnitTests/ClangSharpPInvokeGenerator.UnitTests.csproj b/tests/ClangSharpPInvokeGenerator.UnitTests/ClangSharpPInvokeGenerator.UnitTests.csproj
index 160a63ea7..0c058cbdc 100644
--- a/tests/ClangSharpPInvokeGenerator.UnitTests/ClangSharpPInvokeGenerator.UnitTests.csproj
+++ b/tests/ClangSharpPInvokeGenerator.UnitTests/ClangSharpPInvokeGenerator.UnitTests.csproj
@@ -3,7 +3,7 @@
ClangSharp.UnitTests
- net10.0
+ net11.0