Cleanup some of the types and project files
This commit is contained in:
Родитель
d4a4966f53
Коммит
554dfc2285
|
@ -101,7 +101,7 @@ jobs:
|
|||
- uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
global-json-file: ./global.json
|
||||
- run: dotnet tool install --tool-path ./artifacts/tools sign --version 0.9.1-beta.23530.1
|
||||
- run: dotnet tool install --tool-path ./artifacts/tools sign --version 0.9.1-beta.24170.3
|
||||
- run: ./artifacts/tools/sign code azure-key-vault "**/*.nupkg" --timestamp-url "http://timestamp.digicert.com" --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-key-vault-certificate "${{ secrets.SC_KEY_VAULT_CERTIFICATE_ID }}" --azure-key-vault-client-id "${{ secrets.SC_AZURE_CLIENT_ID }}" --azure-key-vault-client-secret "${{ secrets.SC_AZURE_CLIENT_SECRET }}" --azure-key-vault-tenant-id "${{ secrets.SC_AZURE_TENANT_ID }}" --azure-key-vault-url "${{ secrets.SC_KEY_VAULT_URL }}"
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
@ -142,7 +142,7 @@ jobs:
|
|||
- uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
global-json-file: ./global.json
|
||||
- run: dotnet tool install --tool-path ./artifacts/tools sign --version 0.9.1-beta.23530.1
|
||||
- run: dotnet tool install --tool-path ./artifacts/tools sign --version 0.9.1-beta.24170.3
|
||||
- run: ./artifacts/tools/sign code azure-key-vault "**/*.nupkg" --timestamp-url "http://timestamp.digicert.com" --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-key-vault-certificate "${{ secrets.SC_KEY_VAULT_CERTIFICATE_ID }}" --azure-key-vault-client-id "${{ secrets.SC_AZURE_CLIENT_ID }}" --azure-key-vault-client-secret "${{ secrets.SC_AZURE_CLIENT_SECRET }}" --azure-key-vault-tenant-id "${{ secrets.SC_AZURE_TENANT_ID }}" --azure-key-vault-url "${{ secrets.SC_KEY_VAULT_URL }}"
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
@ -161,7 +161,7 @@ jobs:
|
|||
path: ./artifacts
|
||||
- uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
dotnet-version: '8.0.x'
|
||||
source-url: https://pkgs.clangsharp.dev/index.json
|
||||
env:
|
||||
NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_PAT }}
|
||||
|
@ -177,5 +177,5 @@ jobs:
|
|||
path: ./artifacts
|
||||
- uses: actions/setup-dotnet@v3
|
||||
with:
|
||||
dotnet-version: '6.0.x'
|
||||
dotnet-version: '8.0.x'
|
||||
- run: dotnet nuget push "./artifacts/pkg/Release/*.nupkg" --source https://nuget.pkg.github.com/dotnet/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
<NoWarn>$(NoWarn);CA1003;CA1008;CA1027;CA1034;CA1041;CA1051;CA1069;CA1305;CA1508;CA1707;CA1708;CA1710;CA1711;CA1712;CA1720;CA1721;CA1724;CA1815;CA2225</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="ILLink.Substitutions.xml" LogicalName="ILLink.Substitutions.xml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="libClang" />
|
||||
<PackageReference Include="libClangSharp" />
|
||||
|
|
|
@ -32,7 +32,7 @@ public unsafe partial struct CXToken : IEquatable<CXToken>
|
|||
|
||||
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 override readonly int GetHashCode() => HashCode.Combine(int_data[0], int_data[1], int_data[2], int_data[3], (IntPtr)ptr_data);
|
||||
|
||||
public readonly CXSourceLocation GetLocation(CXTranslationUnit translationUnit) => clang.getTokenLocation(translationUnit, this);
|
||||
|
||||
|
|
|
@ -10,41 +10,39 @@ public unsafe partial struct CXUnsavedFile : IDisposable
|
|||
{
|
||||
public static CXUnsavedFile Create(string filename, string contents)
|
||||
{
|
||||
IntPtr pFilename, pContents;
|
||||
int filenameLength, contentsLength;
|
||||
sbyte* pFilename, pContents;
|
||||
nuint contentsLength;
|
||||
|
||||
if ((filename is null) || (filename.Length == 0))
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
{
|
||||
pFilename = IntPtr.Zero;
|
||||
pFilename = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var filenameBytes = Encoding.UTF8.GetBytes(filename);
|
||||
filenameLength = filenameBytes.Length;
|
||||
pFilename = Marshal.AllocHGlobal(filenameLength + 1);
|
||||
Marshal.Copy(filenameBytes, 0, pFilename, filenameLength);
|
||||
Marshal.WriteByte(pFilename, filenameLength, 0);
|
||||
var maxFilenameLength = Encoding.UTF8.GetMaxByteCount(filename.Length);
|
||||
pFilename = (sbyte*)NativeMemory.Alloc((uint)maxFilenameLength + 1);
|
||||
var filenameLength = (uint)Encoding.UTF8.GetBytes(filename, new Span<byte>(pFilename, maxFilenameLength));
|
||||
pFilename[filenameLength] = 0;
|
||||
}
|
||||
|
||||
if ((contents is null) || (contents.Length == 0))
|
||||
if (string.IsNullOrEmpty(contents))
|
||||
{
|
||||
contentsLength = 0;
|
||||
pContents = IntPtr.Zero;
|
||||
pContents = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var contentsBytes = Encoding.UTF8.GetBytes(contents);
|
||||
contentsLength = contentsBytes.Length;
|
||||
pContents = Marshal.AllocHGlobal(contentsLength + 1);
|
||||
Marshal.Copy(contentsBytes, 0, pContents, contentsLength);
|
||||
Marshal.WriteByte(pContents, contentsLength, 0);
|
||||
var maxContentsLength = Encoding.UTF8.GetMaxByteCount(contents.Length);
|
||||
pContents = (sbyte*)NativeMemory.Alloc((uint)maxContentsLength + 1);
|
||||
contentsLength = (uint)Encoding.UTF8.GetBytes(contents, new Span<byte>(pContents, maxContentsLength));
|
||||
pContents[contentsLength] = 0;
|
||||
}
|
||||
|
||||
return new CXUnsavedFile()
|
||||
{
|
||||
Filename = (sbyte*)pFilename,
|
||||
Contents = (sbyte*)pContents,
|
||||
Length = (UIntPtr)contentsLength
|
||||
Filename = pFilename,
|
||||
Contents = pContents,
|
||||
Length = contentsLength
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -52,15 +50,15 @@ public unsafe partial struct CXUnsavedFile : IDisposable
|
|||
{
|
||||
if (Filename != null)
|
||||
{
|
||||
Marshal.FreeHGlobal((IntPtr)Filename);
|
||||
NativeMemory.Free(Filename);
|
||||
Filename = null;
|
||||
}
|
||||
|
||||
if (Contents != null)
|
||||
{
|
||||
Marshal.FreeHGlobal((IntPtr)Contents);
|
||||
NativeMemory.Free(Contents);
|
||||
Contents = null;
|
||||
Length = (UIntPtr)0;
|
||||
Length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,25 +10,38 @@ public unsafe struct MarshaledString : IDisposable
|
|||
{
|
||||
public MarshaledString(string? input)
|
||||
{
|
||||
int length;
|
||||
IntPtr value;
|
||||
int valueLength;
|
||||
sbyte* pValue;
|
||||
|
||||
if (input is null)
|
||||
{
|
||||
length = 0;
|
||||
value = IntPtr.Zero;
|
||||
valueLength = 0;
|
||||
pValue = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var valueBytes = (input.Length != 0) ? Encoding.UTF8.GetBytes(input) : [];
|
||||
length = valueBytes.Length;
|
||||
value = Marshal.AllocHGlobal(length + 1);
|
||||
Marshal.Copy(valueBytes, 0, value, length);
|
||||
Marshal.WriteByte(value, length, 0);
|
||||
var maxValueLength = Encoding.UTF8.GetMaxByteCount(input.Length);
|
||||
pValue = (sbyte*)NativeMemory.Alloc((uint)maxValueLength + 1);
|
||||
valueLength = Encoding.UTF8.GetBytes(input, new Span<byte>(pValue, maxValueLength));
|
||||
pValue[valueLength] = 0;
|
||||
}
|
||||
|
||||
Length = length;
|
||||
Value = (sbyte*)value;
|
||||
Length = valueLength;
|
||||
Value = pValue;
|
||||
}
|
||||
|
||||
public MarshaledString(ReadOnlySpan<char> input)
|
||||
{
|
||||
int valueLength;
|
||||
sbyte* pValue;
|
||||
|
||||
var maxValueLength = Encoding.UTF8.GetMaxByteCount(input.Length);
|
||||
pValue = (sbyte*)NativeMemory.Alloc((uint)maxValueLength + 1);
|
||||
valueLength = Encoding.UTF8.GetBytes(input, new Span<byte>(pValue, maxValueLength));
|
||||
pValue[valueLength] = 0;
|
||||
|
||||
Length = valueLength;
|
||||
Value = pValue;
|
||||
}
|
||||
|
||||
public readonly ReadOnlySpan<byte> AsSpan() => new ReadOnlySpan<byte>(Value, Length);
|
||||
|
@ -41,7 +54,7 @@ public unsafe struct MarshaledString : IDisposable
|
|||
{
|
||||
if (Value != null)
|
||||
{
|
||||
Marshal.FreeHGlobal((IntPtr)Value);
|
||||
NativeMemory.Free(Value);
|
||||
Value = null;
|
||||
Length = 0;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ public unsafe ref struct MarshaledStringArray
|
|||
}
|
||||
}
|
||||
|
||||
public readonly int Count => Values.Length;
|
||||
|
||||
public readonly ReadOnlySpan<MarshaledString> Values => _values;
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// 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.IO;
|
||||
using ClangSharp.Interop;
|
||||
using NUnit.Framework;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// 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.IO;
|
||||
using System.Text;
|
||||
using ClangSharp.Interop;
|
||||
using NUnit.Framework;
|
||||
|
|
Загрузка…
Ссылка в новой задаче