Skip to content

Commit 3854bf2

Browse files
committed
Allow the libraries, but not the tool, to multi-target .NET 8
1 parent c8b9fb2 commit 3854bf2

File tree

10 files changed

+22
-6
lines changed

10 files changed

+22
-6
lines changed

scripts/build.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ try {
182182
$DotNetInstallDirectory = Join-Path -Path $ArtifactsDir -ChildPath "dotnet"
183183
Create-Directory -Path $DotNetInstallDirectory
184184

185+
& $DotNetInstallScript -Channel 8.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture
185186
& $DotNetInstallScript -Channel 10.0 -Version latest -InstallDir $DotNetInstallDirectory -Architecture $architecture
186187

187188
$env:PATH="$DotNetInstallDirectory;$env:PATH"

scripts/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ if [[ ! -z "$architecture" ]]; then
222222
DotNetInstallDirectory="$ArtifactsDir/dotnet"
223223
CreateDirectory "$DotNetInstallDirectory"
224224

225+
. "$DotNetInstallScript" --channel 8.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture"
225226
. "$DotNetInstallScript" --channel 10.0 --version latest --install-dir "$DotNetInstallDirectory" --architecture "$architecture"
226227

227228
PATH="$DotNetInstallDirectory:$PATH:"

sources/ClangSharp.Interop/ClangSharp.Interop.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33

44
<PropertyGroup>
5-
<TargetFrameworks>net10.0</TargetFrameworks>
5+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
66
</PropertyGroup>
77

88
<PropertyGroup>

sources/ClangSharp.PInvokeGenerator/ClangSharp.PInvokeGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<PropertyGroup>
55
<RootNamespace>ClangSharp</RootNamespace>
6-
<TargetFrameworks>net10.0</TargetFrameworks>
6+
<TargetFramework>net10.0</TargetFramework>
77
</PropertyGroup>
88

99
<PropertyGroup>

sources/ClangSharp/ClangSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33

44
<PropertyGroup>
5-
<TargetFrameworks>net10.0</TargetFrameworks>
5+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
66
</PropertyGroup>
77

88
<PropertyGroup>

sources/ClangSharp/Cursors/Decls/FieldDecl.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ private protected FieldDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX
4343
name = name[anonymousNameStartIndex..];
4444
}
4545

46+
#if NET8_0
47+
if (name.StartsWith("("))
48+
#else
4649
if (name.StartsWith('('))
50+
#endif
4751
{
4852
Debug.Assert(name.StartsWith("(anonymous enum at ", StringComparison.Ordinal) ||
4953
name.StartsWith("(anonymous struct at ", StringComparison.Ordinal) ||
@@ -52,7 +56,12 @@ private protected FieldDecl(CXCursor handle, CXCursorKind expectedCursorKind, CX
5256
name.StartsWith("(unnamed struct at ", StringComparison.Ordinal) ||
5357
name.StartsWith("(unnamed union at ", StringComparison.Ordinal) ||
5458
name.StartsWith("(unnamed at ", StringComparison.Ordinal));
59+
60+
#if NET8_0
61+
Debug.Assert(name.EndsWith(")"));
62+
#else
5563
Debug.Assert(name.EndsWith(')'));
64+
#endif
5665

5766
return true;
5867
}

sources/ClangSharp/TranslationUnit.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ namespace ClangSharp;
1515
public sealed unsafe class TranslationUnit : IDisposable, IEquatable<TranslationUnit>
1616
{
1717
private static readonly ConcurrentDictionary<CXTranslationUnit, WeakReference<TranslationUnit>> s_createdTranslationUnits = new ConcurrentDictionary<CXTranslationUnit, WeakReference<TranslationUnit>>();
18+
19+
#if NET8_0
20+
private static readonly object s_createTranslationUnitLock = new object();
21+
#else
1822
private static readonly Lock s_createTranslationUnitLock = new Lock();
23+
#endif
1924

2025
private readonly Dictionary<CXCursor, WeakReference<Cursor>> _createdCursors;
2126
private readonly Dictionary<CX_TemplateArgument, WeakReference<TemplateArgument>> _createdTemplateArguments;

sources/ClangSharpPInvokeGenerator/ClangSharpPInvokeGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<PackAsTool>true</PackAsTool>
77
<PublishAot>true</PublishAot>
88
<RuntimeIdentifiers>linux-arm64;linux-x64;osx-arm64;win-arm64;win-x64</RuntimeIdentifiers>
9-
<TargetFrameworks>net10.0</TargetFrameworks>
9+
<TargetFramework>net10.0</TargetFramework>
1010
</PropertyGroup>
1111

1212
<PropertyGroup Condition="'$(Configuration)' != 'Debug'">

tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<PropertyGroup>
55
<RootNamespace>ClangSharp.UnitTests</RootNamespace>
6-
<TargetFrameworks>net10.0</TargetFrameworks>
6+
<TargetFramework>net10.0</TargetFramework>
77
</PropertyGroup>
88

99
<PropertyGroup>

tests/ClangSharp.UnitTests/ClangSharp.UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33

44
<PropertyGroup>
5-
<TargetFrameworks>net10.0</TargetFrameworks>
5+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
66
</PropertyGroup>
77

88
<PropertyGroup>

0 commit comments

Comments
 (0)