UnicodeData class is not working without reflection
See original GitHub issueSimple call to UnicodeData.GetBidiData
produce error in NativeAOT reflection-free mode. Even reflection-free mode is niche, would be good somehow provide workaround for these scenarios.
Underlying issues is https://github.com/SixLabors/Fonts/blob/034a440aece357341fcc6b02db58ffbe153e54ef/src/SixLabors.Fonts/Unicode/UnicodeData.cs#L45-L48
Embedded resources unlikely will even work in reflection-free mode for NativeAOT so maybe would be possible provide some additional API which provide additional sources for these data, maybe from extenally supplied Stream
?
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Why doesn't unicodedata recognise certain characters?
The unicodedata.name() lookup relies on column 2 of the UnicodeData.txt database in the standard (Python 2.7 uses Unicode 5.2.0).
Read more >unicodedata — Unicode Database
This module provides access to the Unicode Character Database (UCD) which defines character properties for all Unicode characters. The data contained in ...
Read more >Unicode & Character Encodings in Python: A Painless Guide
Watch it together with the written tutorial to deepen your understanding: Unicode in Python: Working With Character Encodings. Handling character encodings ...
Read more >Zero reflection usage · Issue #2359 · AvaloniaUI/Avalonia
I'd like to completely remove reflection usage from Avalonia. We should be able to run with CoreRT without additional .rd.xml files and with ......
Read more >Reading and Writing Unicode Data in .NET
This article is for beginners about writing and reading Unicode data from various data sources, including text files, user input and ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I can probably help with the source generator part. Happy to put together a small prototype if you need 🙂 To save the unpacking time though you’d also need to find a way to precompute the data you need somewhat, so that there’d be less work to load it after getting the embedded binary blobs. That’s orthogonal though, so the two problems can be tackled separately. Even just doing this embedded resource trick alone would at least fix the issue related to reflection 👍
Not as nice to work with, but it should be possible to just embed these files directly in the assembly as
ReadOnlySpan<byte>
(so they just get embedded in the .data section and are free and with no reflection). I could see hacking together either a small script to generate this, or maybe a source generator to annotate files in the project and have it generate the properties for you (ie. use theAdditionalFiles
provider from Roslyn, get the list of files à la CsWin32, read, emit the binary blob in some target class). That’d solve the issue mentioned here, especially given all these files are known at build time in this case 🙂