Skip to content

Commit 2c11a79

Browse files
feat:
+support NativeAOT: .NET 6+
1 parent 8a50dc6 commit 2c11a79

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Src/StringBuilderArray/StringBuilderArray.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ public StringBuilderArray Clear()
171171

172172
public override string ToString()
173173
{
174+
#if NET6_0_OR_GREATER
175+
var newStr = string.Create<object>(Length, null, (_, _) => {});
176+
#else
174177
var newStr = StringHelper.FastAllocateString(Length);
178+
#endif
175179
int offset = newStr.Length;
176180
var destBytes = newStr.Length * sizeof(char);
177181
var current = this;

Src/StringBuilderArray/StringBuilderArray.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<PropertyGroup>
77
<PackageId>StringBuilderArray</PackageId>
8-
<PackageVersion>1.1.0.0</PackageVersion>
8+
<PackageVersion>1.1.1.0</PackageVersion>
99
<Authors>Brevnov Vyacheslav Sergeevich</Authors>
1010
<RepositoryUrl>https://github.com/SoftStoneDevelop/StringBuilderArray</RepositoryUrl>
1111
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>

Src/StringBuilderArray/StringHelper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace StringBuilderArray
55
{
6+
#if NET6_0_OR_GREATER
7+
#else
68
public static class StringHelper
79
{
810
public static readonly Func<int, string> FastAllocateString =
@@ -11,4 +13,5 @@ public static class StringHelper
1113
.CreateDelegate(typeof(Func<int, string>))
1214
;
1315
}
16+
#endif
1417
}

0 commit comments

Comments
 (0)