Skip to content

Commit f89ccf9

Browse files
authored
Update package Cysharp.ZString to v2.5.1 (#368)
1 parent 8757a34 commit f89ccf9

File tree

51 files changed

+360
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+360
-160
lines changed

src/SmartFormat.ZString/SmartFormat.ZString.csproj

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

33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0;netstandard2.1;net461</TargetFrameworks>
5-
<!-- Current Cysharp.ZString release version is 2.5.0 -->
5+
<!-- Current Cysharp.ZString release version is 2.5.1 -->
66
<RootNamespace>SmartFormat.ZString</RootNamespace>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>

src/SmartFormat.ZString/repo/.github/workflows/build-debug.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,23 @@ jobs:
2626
strategy:
2727
matrix:
2828
unity: ["2021.3.11f1"]
29-
include:
30-
- unity: 2021.3.11f1
31-
license: UNITY_LICENSE_2021
3229
runs-on: ubuntu-latest
3330
timeout-minutes: 15
3431
steps:
3532
- uses: actions/checkout@v3
3633
# Execute scripts: Export Package
3734
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export
38-
- name: Export unitypackage
39-
uses: game-ci/unity-builder@v2
35+
- name: Build Unity (.unitypacakge)
36+
uses: Cysharp/Actions/.github/actions/unity-builder@main
4037
env:
41-
UNITY_LICENSE: ${{ secrets[matrix.license] }}
38+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
39+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
40+
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
4241
with:
4342
projectPath: src/ZString.Unity
4443
unityVersion: ${{ matrix.unity }}
4544
targetPlatform: StandaloneLinux64
4645
buildMethod: PackageExporter.Export
47-
versioning: None
4846

4947
- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
5048
with:

src/SmartFormat.ZString/repo/.github/workflows/build-release.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ jobs:
5252
strategy:
5353
matrix:
5454
unity: ["2021.3.11f1"]
55-
include:
56-
- unity: 2021.3.11f1
57-
license: UNITY_LICENSE_2021
5855
runs-on: ubuntu-latest
5956
timeout-minutes: 15
6057
steps:
@@ -63,17 +60,18 @@ jobs:
6360
ref: ${{ needs.update-packagejson.outputs.sha }}
6461
# Execute scripts: Export Package
6562
# /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export
66-
- name: Export unitypackage
67-
uses: game-ci/unity-builder@v2
63+
- name: Build Unity (.unitypacakge)
64+
uses: Cysharp/Actions/.github/actions/unity-builder@main
6865
env:
69-
UNITY_LICENSE: ${{ secrets[matrix.license] }}
66+
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
67+
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
68+
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
7069
UNITY_PACKAGE_VERSION: ${{ env.GIT_TAG }}
7170
with:
7271
projectPath: src/ZString.Unity
7372
unityVersion: ${{ matrix.unity }}
7473
targetPlatform: StandaloneLinux64
7574
buildMethod: PackageExporter.Export
76-
versioning: None
7775

7876
- uses: Cysharp/Actions/.github/actions/check-metas@main # check meta files
7977
with:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Prevent github change
2+
on:
3+
pull_request:
4+
paths:
5+
- ".github/**/*.yaml"
6+
- ".github/**/*.yml"
7+
8+
jobs:
9+
detect:
10+
uses: Cysharp/Actions/.github/workflows/prevent-github-change.yaml@main

src/SmartFormat.ZString/repo/README.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Related project for loggin using with ZString, [Cysharp/ZLogger](https://github.
4040
- [Getting Started](#getting-started)
4141
- [Reference](#reference)
4242
- [Unity](#unity)
43-
- [Install via git URL](#install-via-git-url)
4443
- [Advanced Tips](#advanced-tips)
4544
- [License](#license)
4645

@@ -197,29 +196,15 @@ It's important to make sure the writer is always properly disposed.
197196

198197
Unity
199198
---
200-
In Unity, if you encount the following error
199+
Install via UPM git URL package or asset package(ZString...*.unitypackage) available in [ZString/releases](https://github.com/Cysharp/ZString/releases) page.
201200

202-
```
203-
The type 'Unsafe' exists in both 'System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
204-
```
205-
206-
This is caused from dll conflict, for example `Unity Collections` package includes `System.Runtime.CompilerServices.Unsafe.dll` but ZString provides `System.Runtime.CompilerServices.Unsafe.dll` to `Plugins`.
207-
208-
Detail of issue in Unity Forum - [[Bug 1214643][2019.3.0f5] System.Runtime.CompilerServices.Unsafe clashes with imported dll](https://forum.unity.com/threads/bug-1214643-2019-3-0f5-system-runtime-compilerservices-unsafe-clashes-with-imported-dll.816426/)
209-
210-
Workround:
211-
- Copy Collections from Library/PackageCache to %Project Folder%/Packages
212-
- Remove CompilerServices.Unsafe dll from said folder
213-
214-
### Install via git URL
215-
216-
You can add `https://github.com/Cysharp/ZString.git?path=src/ZString.Unity/Assets/Scripts/ZString` to Package Manager.
201+
* `https://github.com/Cysharp/ZString.git?path=src/ZString.Unity/Assets/Scripts/ZString`
217202

218-
You can install managed DLL from package mangers's samples Import button.
203+
If you want to set a target version, ZString uses the `*.*.*` release tag so you can specify a version like #2.4.0. For example `https://github.com/Cysharp/ZString.git?path=src/ZString.Unity/Assets/Scripts/ZString#2.4.0`.
219204

220-
![image](https://user-images.githubusercontent.com/46207/113681776-56145f00-96fd-11eb-8227-560da9c1a092.png)
205+
Supporting minimum Unity version is 2021.3. The dependency managed DLL `System.Runtime.CompilerServices.Unsafe/6.0.0` is included with unitypackage. For git references, you will need to add them in another way as they are not included to avoid unnecessary dependencies; either extract the dll from unitypackage or download it from the [NuGet page](https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/6.0.0).
221206

222-
If you want to set a target version, ZString uses the *.*.* release tag so you can specify a version like #2.4.0. For example https://github.com/Cysharp/ZString.git?path=src/ZString.Unity/Assets/Scripts/ZString#2.4.0.
207+
TextMeshPro support is automatically enabled when importing the `com.unity.textmeshpro` package from package manager. (If you do not use the package manager, define the scripting define symbol `ZSTRING_TEXTMESHPRO_SUPPORT` to enable it.)
223208

224209
Advanced Tips
225210
---

src/SmartFormat.ZString/repo/sandbox/ConsoleApp/ConsoleApp.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
<SignAssembly>true</SignAssembly>
77
<AssemblyOriginatorKeyFile>../../opensource.snk</AssemblyOriginatorKeyFile>
88
<IsPackable>false</IsPackable>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
1213
<PackageReference Include="System.Text.Json" Version="4.7.1" />
13-
<ProjectReference Include="..\..\src\ZString\ZString.csproj" />
14+
<ProjectReference Include="..\..\src\ZString\ZString.csproj">
15+
<SetTargetFramework>TargetFramework=netstandard2.1</SetTargetFramework>
16+
</ProjectReference>
1417
</ItemGroup>
1518

1619
</Project>

src/SmartFormat.ZString/repo/sandbox/ConsoleApp/Program.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
using Cysharp.Text;
22
using System;
3-
using System.Buffers;
4-
using System.Collections.Concurrent;
5-
using System.Linq;
63
using System.Text;
7-
// using System.Text.Formatting;
8-
using System.Text.Json;
9-
using System.Threading;
10-
using System.Threading.Tasks;
4+
using BenchmarkDotNet.Attributes;
5+
using BenchmarkDotNet.Running;
116

127
namespace ConsoleApp
138
{
@@ -20,19 +15,34 @@ class Program
2015
{
2116
static void Main(string[] args)
2217
{
18+
// BenchmarkRunner.Run<JoinBenchmark>();
2319
Run();
2420
}
2521

2622
static void Run()
2723
{
24+
ZString.Join(",", "a", "b");
2825
TimeSpan span = new TimeSpan(12, 34, 56);
2926
Console.WriteLine($"string.Format: {string.Format(@"{0:h\,h\:mm\:ss}", span)}");
30-
31-
3227
Console.WriteLine($"ZString.Format: {ZString.Format(@"{0:h\,h\:mm\:ss}", span)}");
28+
}
29+
}
30+
31+
public class JoinBenchmark
32+
{
33+
public string[] Source = new []{ "111", "222", "333"};
34+
public const string Sp = ",";
3335

36+
[Benchmark]
37+
public string StringJoin()
38+
{
39+
return string.Join(Sp, Source);
40+
}
3441

35-
42+
[Benchmark]
43+
public string ZStringJoin()
44+
{
45+
return ZString.Join(Sp, Source);
3646
}
3747
}
3848

src/SmartFormat.ZString/repo/src/ZString.Unity/Assets/Scripts/ZString/EnumUtil.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ internal static class EnumUtil<T>
1616
static EnumUtil()
1717
{
1818
var enumNames = Enum.GetNames(typeof(T));
19-
var values = Enum.GetValues(typeof(T));
19+
var values =
20+
#if NET7_0_OR_GREATER
21+
Enum.GetValuesAsUnderlyingType(typeof(T));
22+
#else
23+
Enum.GetValues(typeof(T));
24+
#endif
2025
names = new Dictionary<T, string>(enumNames.Length);
2126
utf8names = new Dictionary<T, byte[]>(enumNames.Length);
2227
for (int i = 0; i < enumNames.Length; i++)

src/SmartFormat.ZString/repo/src/ZString.Unity/Assets/Scripts/ZString/Unity/TextMeshProExtensions.SetStringBuilder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
#if ZSTRING_TEXTMESHPRO_SUPPORT
2+
using System;
23
using TMPro;
34

45
namespace Cysharp.Text
@@ -12,3 +13,4 @@ public static void SetText(this TMP_Text text, Utf16ValueStringBuilder stringBui
1213
}
1314
}
1415
}
16+
#endif

src/SmartFormat.ZString/repo/src/ZString.Unity/Assets/Scripts/ZString/Unity/TextMeshProExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
#if ZSTRING_TEXTMESHPRO_SUPPORT
2+
using System;
23
using TMPro;
34

45
namespace Cysharp.Text
@@ -193,3 +194,4 @@ public static void SetTextFormat<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T1
193194

194195
}
195196
}
197+
#endif

0 commit comments

Comments
 (0)