镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ 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: |
./artifacts/bin/**/*
./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: |
Expand All @@ -41,18 +41,18 @@ 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: |
./artifacts/bin/**/*
./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: |
Expand All @@ -66,18 +66,18 @@ 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: |
./artifacts/bin/**/*
./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: |
Expand All @@ -91,18 +91,18 @@ 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: |
./artifacts/bin/**/*
./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: |
Expand All @@ -116,18 +116,18 @@ 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: |
./artifacts/bin/**/*
./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: |
Expand All @@ -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: |
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/regenerate-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}/*
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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: |
Expand Down
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<ItemGroup>
<PackageVersion Include="libClang" Version="23.1.5" />
<PackageVersion Include="libClangSharp" Version="23.1.5.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="NUnit" Version="4.4.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.1.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageVersion Include="NUnit" Version="5.0.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.3.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -277,7 +277,7 @@ Options:

# Mode Families (-c <name>=<value>)

codegen=<value> 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=<value> 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=<value> How output is split: 'single' (one output file; the default) or 'multi' (approximately one type per file).
types=<value> Which platform defaults to assume: 'windows' or 'unix'. Defaults to the host platform.
vtbls=<value> 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).
Expand Down
4 changes: 2 additions & 2 deletions docs/using-clangsharp-as-a-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ so the correct platform-specific runtime package is restored:

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<TargetFramework>net11.0</TargetFramework>
<Nullable>enable</Nullable>

<!-- Required so the platform-specific libClang/libClangSharp runtime package is restored -->
Expand All @@ -106,7 +106,7 @@ so the correct platform-specific runtime package is restored:

<ItemGroup>
<!-- The native libClang/libClangSharp runtimes come in transitively -->
<PackageReference Include="ClangSharp" Version="21.1.8.4" />
<PackageReference Include="ClangSharp" Version="23.1.5" />
</ItemGroup>

</Project>
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "10.0.100-preview",
"allowPrerelease": true,
"version": "11.0.100",
"allowPrerelease": false,
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down
2 changes: 1 addition & 1 deletion sources/ClangSharp.Interop/ClangSharp.Interop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<TargetFrameworks>net11.0;net10.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<PropertyGroup>
<RootNamespace>ClangSharp</RootNamespace>
<TargetFramework>net10.0</TargetFramework>
<TargetFrameworks>net11.0;net10.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void AppendTemplateArguments(ClassTemplateSpecializationDecl classTemplateSpecia

var templateArgs = classTemplateSpecializationDecl.TemplateArgs;

if (templateArgs.Any())
if (templateArgs.Count > 0)
{
AppendTemplateArgument(templateArgs[0], qualifiedName);

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down
Loading
Loading