Fix source only package issue in nuget

This commit is contained in:
2026-02-22 12:36:51 +09:00
parent 49dc44605b
commit ffac1c643e
35 changed files with 69 additions and 8 deletions

View File

@@ -13,7 +13,8 @@
<RepositoryUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</RepositoryUrl> <RepositoryUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</RepositoryUrl>
<IncludeSymbols>true</IncludeSymbols> <IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat> <SymbolPackageFormat>snupkg</SymbolPackageFormat>
<developmentDependency>true</developmentDependency> <IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>contentFiles</ContentTargetFolders>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -30,15 +31,19 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="*.cs" Pack="true" PackagePath="contentFiles/cs/net10.0/Misaki.HighPerformance.LowLevel/" /> <Content Include="contentFiles\cs\any\**\*.cs">
<Pack>true</Pack>
<PackagePath>contentFiles\cs\any\</PackagePath>
<BuildAction>Compile</BuildAction>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="Collections\FixedString.tt"> <None Update="contentFiles\cs\any\Collections\FixedString.tt">
<Generator>TextTemplatingFileGenerator</Generator> <Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>FixedString.gen.cs</LastGenOutput> <LastGenOutput>FixedString.gen.cs</LastGenOutput>
</None> </None>
<None Update="Collections\FixedText.tt"> <None Update="contentFiles\cs\any\Collections\FixedText.tt">
<Generator>TextTemplatingFileGenerator</Generator> <Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>FixedText.gen.cs</LastGenOutput> <LastGenOutput>FixedText.gen.cs</LastGenOutput>
</None> </None>
@@ -49,12 +54,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Collections\FixedString.gen.cs"> <Compile Update="contentFiles\cs\any\Collections\FixedString.gen.cs">
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>FixedString.tt</DependentUpon> <DependentUpon>FixedString.tt</DependentUpon>
</Compile> </Compile>
<Compile Update="Collections\FixedText.gen.cs"> <Compile Update="contentFiles\cs\any\Collections\FixedText.gen.cs">
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>FixedText.tt</DependentUpon> <DependentUpon>FixedText.tt</DependentUpon>

View File

@@ -1,7 +1,5 @@
using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
namespace Misaki.HighPerformance.LowLevel.Utilities; namespace Misaki.HighPerformance.LowLevel.Utilities;
@@ -25,7 +23,11 @@ public static unsafe partial class MemoryUtility
{ {
try try
{ {
#if NET6_0_OR_GREATER
return NativeMemory.Alloc(size); return NativeMemory.Alloc(size);
#else
return Marshal.AllocHGlobal((IntPtr)size).ToPointer();
#endif
} }
catch (Exception) catch (Exception)
{ {
@@ -43,7 +45,13 @@ public static unsafe partial class MemoryUtility
{ {
try try
{ {
#if NET6_0_OR_GREATER
return NativeMemory.AllocZeroed(size); return NativeMemory.AllocZeroed(size);
#else
var ptr = Marshal.AllocHGlobal((IntPtr)size).ToPointer();
Unsafe.InitBlock(ptr, 0, (uint)size);
return ptr;
#endif
} }
catch (Exception) catch (Exception)
{ {
@@ -62,7 +70,11 @@ public static unsafe partial class MemoryUtility
{ {
try try
{ {
#if NET6_0_OR_GREATER
return NativeMemory.AlignedAlloc(size, alignment); return NativeMemory.AlignedAlloc(size, alignment);
#else
return Marshal.AllocHGlobal((IntPtr)(size + alignment - 1)).ToPointer();
#endif
} }
catch (Exception) catch (Exception)
{ {
@@ -81,7 +93,11 @@ public static unsafe partial class MemoryUtility
{ {
try try
{ {
#if NET6_0_OR_GREATER
return NativeMemory.Realloc(ptr, size); return NativeMemory.Realloc(ptr, size);
#else
return Marshal.ReAllocHGlobal((IntPtr)ptr, (IntPtr)size).ToPointer();
#endif
} }
catch (Exception) catch (Exception)
{ {
@@ -102,7 +118,23 @@ public static unsafe partial class MemoryUtility
{ {
try try
{ {
#if NET6_0_OR_GREATER
return NativeMemory.AlignedRealloc(ptr, size, alignment); return NativeMemory.AlignedRealloc(ptr, size, alignment);
#else
var newPtr = Marshal.AllocHGlobal((IntPtr)(size + alignment - 1)).ToPointer();
if (newPtr == null)
{
return null;
}
if (ptr != null)
{
Unsafe.CopyBlock(newPtr, ptr, (uint)size);
Marshal.FreeHGlobal((IntPtr)ptr);
}
return newPtr;
#endif
} }
catch (Exception) catch (Exception)
{ {
@@ -117,7 +149,11 @@ public static unsafe partial class MemoryUtility
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Free(void* ptr) public static void Free(void* ptr)
{ {
#if NET6_0_OR_GREATER
NativeMemory.Free(ptr); NativeMemory.Free(ptr);
#else
Marshal.FreeHGlobal((IntPtr)ptr);
#endif
} }
/// <summary> /// <summary>
@@ -128,7 +164,11 @@ public static unsafe partial class MemoryUtility
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void AlignedFree(void* ptr) public static void AlignedFree(void* ptr)
{ {
#if NET6_0_OR_GREATER
NativeMemory.AlignedFree(ptr); NativeMemory.AlignedFree(ptr);
#else
Marshal.FreeHGlobal((IntPtr)ptr);
#endif
} }
/// <summary> /// <summary>
@@ -140,7 +180,11 @@ public static unsafe partial class MemoryUtility
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MemClear(void* ptr, nuint size) public static void MemClear(void* ptr, nuint size)
{ {
#if NET6_0_OR_GREATER
NativeMemory.Clear(ptr, size); NativeMemory.Clear(ptr, size);
#else
Unsafe.InitBlock(ptr, 0, (uint)size);
#endif
} }
/// <summary> /// <summary>
@@ -152,7 +196,11 @@ public static unsafe partial class MemoryUtility
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MemSet(void* ptr, byte value, nuint size) public static void MemSet(void* ptr, byte value, nuint size)
{ {
#if NET6_0_OR_GREATER
NativeMemory.Fill(ptr, size, value); NativeMemory.Fill(ptr, size, value);
#else
Unsafe.InitBlock(ptr, value, (uint)size);
#endif
} }
/// <summary> /// <summary>
@@ -164,7 +212,11 @@ public static unsafe partial class MemoryUtility
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MemCpy(void* destination, void* source, nuint size) public static void MemCpy(void* destination, void* source, nuint size)
{ {
#if NET6_0_OR_GREATER
NativeMemory.Copy(source, destination, size); NativeMemory.Copy(source, destination, size);
#else
Unsafe.CopyBlock(destination, source, (uint)size);
#endif
} }
/// <summary> /// <summary>
@@ -176,8 +228,12 @@ public static unsafe partial class MemoryUtility
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MemMove(void* destination, void* source, nuint size) public static void MemMove(void* destination, void* source, nuint size)
{ {
#if NET6_0_OR_GREATER
// NativeMemory.Copy use memmove internally. // NativeMemory.Copy use memmove internally.
NativeMemory.Copy(source, destination, size); NativeMemory.Copy(source, destination, size);
#else
Unsafe.CopyBlock(destination, source, (uint)size);
#endif
} }
/// <summary> /// <summary>