Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix invalid Uri error when running in a Single file application #201

Merged
merged 2 commits into from
Jul 4, 2024

Conversation

hahn-kev
Copy link
Collaborator

@hahn-kev hahn-kev commented Jul 2, 2024

When publishing a Single file application we would get an error when trying to initlize Icu. This PR fixes that issue.

To test run the following in the TestHelper project

dotnet publish -r win-x64 --property:PublishSingleFile=true --framework net8.0

the resulting exe can be found in icu-dotnet\output\Release\TestHelper\net8.0\win-x64\publish, copy in the native ICU dlls to that folder and run that with the following (numbers being the icu version range)

 .\TestHelper.exe 70 72

before this PR you would get this exception:

Unhandled exception. System.TypeInitializationException: The type initializer for 'Icu.NativeMethods' threw an exception.
 ---> System.UriFormatException: Invalid URI: The URI is empty.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at Icu.NativeMethods.get_DirectoryOfThisAssembly() in C:\dev\icu-dotnet\source\icu.net\NativeMethods\NativeMethods.cs:line 175
   at Icu.NativeMethodsHelper.TryGetPathFromAssemblyDirectory() in C:\dev\icu-dotnet\source\icu.net\NativeMethods\NativeMethodsHelper.cs:line 145
   at Icu.NativeMethodsHelper.GetIcuVersionInfoForNetCoreOrWindows() in C:\dev\icu-dotnet\source\icu.net\NativeMethods\NativeMethodsHelper.cs:line 65
   at Icu.NativeMethods.ResetIcuVersionInfo() in C:\dev\icu-dotnet\source\icu.net\NativeMethods\NativeMethods.cs:line 466
   at Icu.NativeMethods..cctor() in C:\dev\icu-dotnet\source\icu.net\NativeMethods\NativeMethods.cs:line 73
   --- End of inner exception stack trace ---
   at Icu.NativeMethods.SetMinMaxIcuVersions(Int32 minVersion, Int32 maxVersion) in C:\dev\icu-dotnet\source\icu.net\NativeMethods\NativeMethods.cs:line 37
   at Icu.Wrapper.ConfineIcuVersions(Int32 minIcuVersion, Int32 maxIcuVersion) in C:\dev\icu-dotnet\source\icu.net\IcuWrapper.cs:line 81
   at Icu.Tests.TestHelper.Main(String[] args) in C:\dev\icu-dotnet\source\TestHelper\TestHelper.cs:line 40

this is because Assembly.Location returns an empty string. Per the warning, I'm using AppContext.BaseDirectory when location returns an empty string.

It would be nice to have an automated test for this, but doing that would require doing something similar to above where we publish a SingleFile project and run it, not sure if that's worth it.

…n attempting to determine the location of the icu.net assembly. Assembly.Location will be an empty string when publishing SingleFile.
Copy link

github-actions bot commented Jul 2, 2024

Test Results

       5 files  ±0     403 suites  ±0   6s ⏱️ -1s
   431 tests ±0     427 ✔️ ±0    4 💤 ±0  0 ±0 
2 193 runs  ±0  2 095 ✔️ ±0  98 💤 ±0  0 ±0 

Results for commit c39404e. ± Comparison against base commit 9bce747.

♻️ This comment has been updated with latest results.

hahn-kev added a commit to sillsdev/languageforge-lexbox that referenced this pull request Jul 2, 2024
@hahn-kev hahn-kev merged commit b7b0666 into sillsdev:master Jul 4, 2024
7 checks passed
hahn-kev added a commit to sillsdev/languageforge-lexbox that referenced this pull request Jul 5, 2024
* define parts of speech models in MiniLcm, implement tests and updates for the FwDataBridge

pull part of speech helper methods into their own utility class

rewrite semantic domain implementation to support them being objects that are referenced, instead of just being a string.

prevent json patch changes from having index references, this will avoid conflicts where the index changes due to merges.

introduce json patch rewriting to convert patches into specific changes.
Rewrite changes to Sense.PartOfSpeechId into SetPartOfSpeechChange.

allow creating parts of speech as CRDTs and setup a PoC of pre seeding them.

allow creating semantic domains and referencing them in senses, rewrite json patch to change semantic domains of senses. Add tests for creating senses with and without semantic domains, and with and without part of speeches.

* remove duplicate field, fix overloaded GetEntries function causing build error due to 2 overloads not requiring parameters.

* add WritingSystemTests.cs, and make the project loader fixture a collection fixture so it's shared by all tests in the project.

* reduce allocations in ContributeExemplars by ~50% by using spans of chars instead of strings.

* use string contains with StringComparison instead of calling ToLowerInvariant on each string.

* optimize ws lookup when populating exemplars by using a frozen dictionary, and set the MultiString capacity when converting a LcmMultiString to a MiniLcmMultiString

* Populate UI with parts-of-speech

* Search improvements

* Index dictionary by first grapheme instead of first char

* Revert "Index dictionary by first grapheme instead of first char", because first-char sounds like a better way to go (https://sil-lt.slack.com/archives/C806BLR42/p1718797173733449)

This reverts commit 614dbd5.

* Fix exemplar lookup not always working

* Add loading indicators

* Improve index character overlay size

* Option type cleanup

* Add Sandbox to reproduce open bug

* Populate semantic domain dropdown (WIP)

* Make entry list always fully visible.

* Prevent unnecessary change events

* Fix type error

* Use less peculiar icon

* Display search keyboard shortcut

* Redesign home page

* Resize keys

* Fix Part of speech changes not being persisted

* Uppercase index exemplars to prevent duplicates

* Store selected-entry, selected-index-char and search in URL

* Add transition so increased debounce is not so noticeable.

* Add save status indicator

* Layout and mobile fixes

* Cheap fix for semantic domain list being way to big

* Format selected semantic domains

* gracefully handle null order by text

* rework CrdtMultiOptionField to support editing object lists

* add parts of speech to CrdtLexboxApi.cs to fix failing tests

* add parts of speech and semantic domains to the lf classic api

* disable server garbage collection to reduce memory usage. Disable single file until sillsdev/icu-dotnet#201 is merged.

* apply some suggested feedback from review.

* normalize exemplar to NFD before using it for comparison

---------

Co-authored-by: Tim Haasdyk <tim_haasdyk@sil.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants