1 From f4c599a48d153d15ccb1879ff511617c8e310515 Mon Sep 17 00:00:00 2001
2 From: David McFarland <corngood@gmail.com>
3 Date: Sat, 10 Aug 2024 23:14:12 -0300
4 Subject: [PATCH 1/2] use files for unicode character database
7 .../BiDiClassTestDataGenerator.cs | 1 -
8 .../TextFormatting/BiDiTestDataGenerator.cs | 1 -
9 .../GraphemeBreakClassTrieGenerator.cs | 1 -
10 .../GraphemeBreakTestDataGenerator.cs | 1 -
11 .../LineBreakEnumuratorTests.cs | 1 -
12 .../TextFormatting/UnicodeDataGenerator.cs | 28 +++++++++++++++++--
13 .../TextFormatting/UnicodeEnumsGenerator.cs | 1 -
14 7 files changed, 26 insertions(+), 8 deletions(-)
16 diff --git a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/BiDiClassTestDataGenerator.cs b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/BiDiClassTestDataGenerator.cs
17 index f6b01d737..bc7278ef8 100644
18 --- a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/BiDiClassTestDataGenerator.cs
19 +++ b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/BiDiClassTestDataGenerator.cs
21 using System.Collections.Generic;
24 -using System.Net.Http;
25 using Avalonia.Base.UnitTests.Media.TextFormatting;
27 namespace Avalonia.Visuals.UnitTests.Media.TextFormatting
28 diff --git a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/BiDiTestDataGenerator.cs b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/BiDiTestDataGenerator.cs
29 index 28d37130a..5e26edf49 100644
30 --- a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/BiDiTestDataGenerator.cs
31 +++ b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/BiDiTestDataGenerator.cs
33 using System.Collections.Generic;
36 -using System.Net.Http;
37 using Avalonia.Base.UnitTests.Media.TextFormatting;
38 using Avalonia.Media.TextFormatting.Unicode;
40 diff --git a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakClassTrieGenerator.cs b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakClassTrieGenerator.cs
41 index 1a8d41caa..185b6ea62 100644
42 --- a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakClassTrieGenerator.cs
43 +++ b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakClassTrieGenerator.cs
46 using System.Collections.Generic;
48 -using System.Net.Http;
49 using System.Text.RegularExpressions;
50 using Avalonia.Media.TextFormatting.Unicode;
52 diff --git a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakTestDataGenerator.cs b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakTestDataGenerator.cs
53 index 029f8e236..44c2aaf6a 100644
54 --- a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakTestDataGenerator.cs
55 +++ b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/GraphemeBreakTestDataGenerator.cs
57 using System.Collections.Generic;
60 -using System.Net.Http;
61 using Avalonia.Base.UnitTests.Media.TextFormatting;
63 namespace Avalonia.Visuals.UnitTests.Media.TextFormatting
64 diff --git a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/LineBreakEnumuratorTests.cs b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/LineBreakEnumuratorTests.cs
65 index 3db9a32b6..b8df1f446 100644
66 --- a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/LineBreakEnumuratorTests.cs
67 +++ b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/LineBreakEnumuratorTests.cs
69 using System.Collections.Generic;
72 -using System.Net.Http;
73 using Avalonia.Media.TextFormatting;
74 using Avalonia.Media.TextFormatting.Unicode;
76 diff --git a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/UnicodeDataGenerator.cs b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/UnicodeDataGenerator.cs
77 index f05a1e574..7e698ae0a 100644
78 --- a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/UnicodeDataGenerator.cs
79 +++ b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/UnicodeDataGenerator.cs
82 using System.Collections.Generic;
84 -using System.Net.Http;
85 using System.Text.RegularExpressions;
86 +using System.Threading.Tasks;
87 using Avalonia.Media.TextFormatting.Unicode;
90 namespace Avalonia.Base.UnitTests.Media.TextFormatting
92 + class HttpContent : IDisposable {
93 + readonly string url;
94 + public HttpContent(string url) => this.url = url;
96 + public void Dispose() {}
97 + public Task<Stream> ReadAsStreamAsync() =>
98 + Task.FromResult<Stream>(File.OpenRead(url));
101 + class HttpResponseMessage : IDisposable {
102 + HttpContent content;
103 + public HttpResponseMessage(string url) => Content = new(url);
105 + public void Dispose() {}
106 + public bool IsSuccessStatusCode => true;
107 + public HttpContent Content { get; init; }
110 + class HttpClient : IDisposable {
111 + public void Dispose() {}
112 + public Task<HttpResponseMessage> GetAsync(string url) =>
113 + Task.FromResult<HttpResponseMessage>(new (url));
116 internal static class UnicodeDataGenerator
118 - public const string Ucd = "https://www.unicode.org/Public/15.0.0/ucd/";
119 + public static readonly string Ucd = Environment.GetEnvironmentVariable("UNICODE_CHARACTER_DATABASE");
121 public static UnicodeTrie GenerateBiDiTrie(out BiDiDataEntries biDiDataEntries, out Dictionary<int, BiDiDataItem> biDiData)
123 diff --git a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/UnicodeEnumsGenerator.cs b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/UnicodeEnumsGenerator.cs
124 index 110e57cbd..7073ea508 100644
125 --- a/tests/Avalonia.Base.UnitTests/Media/TextFormatting/UnicodeEnumsGenerator.cs
126 +++ b/tests/Avalonia.Base.UnitTests/Media/TextFormatting/UnicodeEnumsGenerator.cs
128 using System.Collections.Generic;
131 -using System.Net.Http;
133 namespace Avalonia.Base.UnitTests.Media.TextFormatting