question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnicodeData class is not working without reflection

See original GitHub issue

Simple 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:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
Sergio0694commented, Jun 19, 2022

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 👍

2reactions
Sergio0694commented, Jun 19, 2022

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 the AdditionalFiles 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 🙂

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found