Coder Social home page Coder Social logo

sillsdev / libpalaso Goto Github PK

View Code? Open in Web Editor NEW
43.0 21.0 50.0 32.11 MB

Palaso Library: A set of .Net libraries useful for developers of Language Software.

License: MIT License

C# 98.21% Shell 0.02% XSLT 0.91% HTML 0.64% Python 0.11% Makefile 0.01% Batchfile 0.11%
linux windows languages linguistics hacktoberfest

libpalaso's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libpalaso's Issues

Improve how SLDR downloads langtag.json file

When SLDR is initialized, it currently does a synchronous request to download the langtags.json file and this request can be slow on machines with slow internet connections.

It would be better if the download of the langtags.json file could be separated out from the initialization code and allow applications to decide when to make the call.

Also, the SLDR code currently uses the IF-MODIFIED-SINCE header and for a while this was broken on the server. It is working now, but WSTech would like us to switch to using the ETag method instead since this is now more common. They gave this as a reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

Create and use nuget packages in libpalaso and related projects

("packaging" below means creating the Debian packages)

  • Create and use nuget packages in the following projects

  • Verify that using the designer for winforms projects is still possible on Windows

    • test using the designer with VS 2019 16.8 in the projects
    • remove separate Designer projects that were added as a hack
    • test building on Linux
    • libpalaso
    • chorus (sillsdev/chorus#224 currently fails on AppVeyor, maybe because it doesn't yet have the current VS version available) (#1002)
    • flexbridge (#1003)
    • liblcm (#1004)
    • FieldWorks (#1005)
  • update flexbridge installer/packaging - adjust build scripts (sillsdev/flexbridge#289) (#1006)

    • Windows installer
    • Linux packaging
  • update/test LfMerge packaging (#1007)

  • update/test FieldWorks packaging (#1008)

  • document developing/debugging a project with dependencies that are now nuget packages (#1009)

  • update and make available documentation of what changed and how things work now with the nuget packages (#1010)

  • update documentation with release process

  • make the feature/nuget branch the main development branch

    • merge master into feature/nuget again on the different projects
    • announce that the merge of the feature/nuget branch will be made the main development branch
    • merge feature/nuget into master on the different projects. Doing this requires adjusting the path to the CHANGELOG.md file in the .csproj as well as adjusting GitVersion.yml (removing settings for feature/nuget branch).
    • create a release of the nuget packages on each project, and use these released nuget packages in the other projects. Note: also create releases for other projects like L10NSharp that still have a pre-release version number (#1018).

BetterLabel in Writing System Dialog throwing "Cannot access a disposed object" error

Reported by Jonathan Coombs:

I did go ahead and create a sample project that illustrates the problem (attached): you can use the first "Set..." button as many times as you like, but the second button (which relies on a persistent _wsModel) will only work the first time you click it. It's simply the difference between this (which works)...

        IWritingSystemRepository store = AppWritingSys.WritingSystems;
        WritingSystemSetupModel wsModel = new WritingSystemSetupModel(store);
        wsModel.SetCurrentIndexFromRfc46464(textBoxWs.Text);
        using (var d = new WritingSystemSetupDialog(wsModel))
        {
            d.ShowDialog(wsModel.CurrentRFC4646);
            this.textBoxWs.Text = wsModel.CurrentRFC4646;

and this (which crashes on second run, once you click a WS):

        _store = _store ?? AppWritingSys.WritingSystems;
        _wsModel = _wsModel ?? new WritingSystemSetupModel(_store);
        using (var d = new WritingSystemSetupDialog(_wsModel))
        {
            d.ShowDialog(_wsModel.CurrentRFC4646);
            this.textBoxWs.Text = _wsModel.CurrentRFC4646;

On the Palaso end of things, these two BetterLabels in WritingSystemSetupView are ending up getting disposed too early:

    private Palaso.UI.WindowsForms.Widgets.BetterLabel _rfc4646;
    private Palaso.UI.WindowsForms.Widgets.BetterLabel _languageName;

It seems that either the WS dialog is damaging the passed-in _wsModel, or gets it partly unwired on closing the dialog the first time. (I'm suspicious of BindToModel(), and of LocalizationHelper.OnControlDisposed() but don't really know.) My workaround in Solid has been to make sure that I use the first approach above.

Also, while debugging I noticed some excessive event ping-ponging between methods in BetterLabel, which could be reduced by swapping these lines in BetterLabel_SizeChanged() to:
_previousWidth = Width;
DetermineHeight();


Jonathan also sent around a zip of a project that reproduces the problem. The core is here:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Palaso.UI.WindowsForms.WritingSystems;
using Palaso.WritingSystems;

namespace TestPalaso
{
    public partial class FormTestWs : Form
    {
        public FormTestWs()
        {
            InitializeComponent();
        }

        IWritingSystemRepository _store;
        WritingSystemSetupModel _wsModel;


        //Works: Totally non-persistent, other than putting a string value into a textbox.
        private void buttonOpenWsDialog_Click(object sender, EventArgs e)
        {
            IWritingSystemRepository store = AppWritingSys.WritingSystems;
            WritingSystemSetupModel wsModel = new WritingSystemSetupModel(store);
            wsModel.SetCurrentIndexFromRfc46464(textBoxWs.Text);
            using (var d = new WritingSystemSetupDialog(wsModel))
            {
                d.ShowDialog(wsModel.CurrentRFC4646);
                this.textBoxWs.Text = wsModel.CurrentRFC4646;
            }

        }

        // Crashes on second launch, once you click on a WS:
        private void buttonOpenWsDialogPersistent_Click(object sender, EventArgs e)
        {
            _store = _store ?? AppWritingSys.WritingSystems;
            _wsModel = _wsModel ?? new WritingSystemSetupModel(_store);
            using (var d = new WritingSystemSetupDialog(_wsModel))
            {
                d.ShowDialog(_wsModel.CurrentRFC4646);
                string s = _wsModel.CurrentRFC4646;
                this.textBoxWs.Text = s;
                _wsModel.SetCurrentIndexFromRfc46464(s); //prob redundant
            }
        }


    }
}

Test output on stderr is treated as an error iff Verbose flag is on

In this section of TestTask.cs, the Verbose flag causes anything on stderr to be logged as an error. This is causing build failures like this one where GDK warnings that were logged to stderr are being treated (incorrectly) as errors and causing a build failure when there's no actual problem with the build.

A lot of Linux software treats stderr not as a place to print error messages, but as a place to print any notification that is meant for the user to see even though he might be redirecting stdout. E.g., progress messages, and so on. We should change the logic in TestTask.cs to not consider stderr output as an error.

Also, the Verbose flag is documented as "If true print the output of NUnit immediately, otherwise print it ater [sic] NUnit finished". Yet it's the Verbose flag that's being used to treat stderr output as an error, which means it changes the semantics of how stderr is treated. This made it rather hard to track down this issue, as it's not at all obvious from that documentation that Verbose is going to change the behavior of the TestTask class.

SIL.FwBuildTasks: make the feature/nuget branch the main development branch

  • merge master into feature/nuget again
  • announce that the merge of the feature/nuget branch will be made the main development branch
  • create a git tag on master (pre-nuget ?) before doing the merge
  • merge feature/nuget into master. Doing this requires adjusting the path to the CHANGELOG.md file in the .csproj as well as adjusting GitVersion.yml (removing settings for feature/nuget branch).
  • create a release of the nuget packages, and use these released nuget packages in the other projects.

Improve VerseRef.TrySetVerseUnicode by handling non-decimal numerals and surrogate pair numerals.

This change would allow applications to more easily and broadly use vernacular versification.

The methods char.IsDigit and char.GetNumericValue (used in VerseRef.TryGetVerseNum) only handle base-10, non-surrogate numerals (Complete list here). A broader alternative to these methods would have to be found or made.

The value calculation in TrySetVerseUnicode also currently assumes a decimal base:
vNum = (short)(vNum * 10 + (romanOnly ? ch - '0' : char.GetNumericValue(ch)));
This would have to be changed.

See discussion on #999 for additional context and (ignored) test cases.

Fix nuget symbol packages for SIL.Windows.Forms.*

The upload and validation of the symbol packages for SIL.Windows.Forms.dll and SIL.Windows.Forms.Keyboarding.dll fails. The reason is that both projects use ILRepack to merge with some non-strongnamed assemblies. Using ILRepack removes the necessary debug sections from the PE file.
A solution would be to create/update nuget packages for the assemblies that are not strong-named and remove ILRepack. For the Interop dlls we might want to include them in the SIL.Windows* nuget package.

Nuget packages that have to be strong-named:

  • DialogAdapters
  • MarkdownDeep.Patched
  • Sign the assemblies included in lib

SIL.Windows.Forms.Keyboarding is missing Keyman10Interop dll

This leads to a crash:

Msg: Could not load file or assembly 'Keyman10Interop, Version=10.0.0.0, Culture=neutral, PublicKeyToken=e33b67d3bb5581e4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Class: System.IO.FileLoadException
Source: SIL.Windows.Forms.Keyboarding
Assembly: SIL.Windows.Forms.Keyboarding, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cab3c8c5232dfcf2
Stack:    at SIL.Windows.Forms.Keyboarding.Windows.KeymanKeyboardAdaptor.GetInstalledKeymanVersion()
  at SIL.Windows.Forms.Keyboarding.KeyboardController.SetDefaultKeyboardAdaptors()
  at SIL.Windows.Forms.Keyboarding.KeyboardController.Initialize(IKeyboardRetrievingAdaptor[] adaptors)
  at SIL.Transcelerator.TxlPlugin.<>c__DisplayClass9_0.<Run>b__0() in C:\Projects\Transcelerator\Transcelerator\TxlPlugin.cs:line 151
  at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
  at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
  at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
  at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
  at System.Threading.ThreadHelper.ThreadStart()
Thread: Transcelerator
Thread UI culture: en-US
Exception: System.IO.FileLoadException
--Error Reporting Properties--
Version: 1.3.0.0 (apparent build date: 9/25/2019)
CommandLine: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\AddInProcess32.exe" /guid:9733f9a6-c557-4203-b92b-d21dcaec29b6 /pid:21204
CurrentDirectory: C:\Program Files (x86)\Paratext 9
MachineName: SWD-BOGLE-LT
OSVersion: Windows 10
DotNetVersion: 4.0.30319.42000
WorkingSet: 23691264
UserDomainName: WAXHAW
UserName: Bogle
Culture: en-US
Plugin Name: Transcelerator
Host Application: Paratext 9.0.63.5

SelectProjectDlgBase should not access abstract properties in the constructor.

There's no actual need to initialize m_fileDialog (etc.) until we actually get ready to show the dialog for the first time. By accessing abstract properties in the constructor, it prevents Subclasses from having arguments passed in to their constructors that might be needed to implement the abstract members. In this case, there are times when subclasses might need to have a more meaningful Title based on something that is not static.

[WritingSystems] alltags renamed to langtags

The alltags.json file is now langtags.json in the upstream WS Tech sldr repo
The update url for alltags.json

The cached file in SIL.WritingSystems/Resources needs to be changed and in LanguageRegistryResources
The code in SIL.WritingSystems/Sldr.cs needs to be updated to update the new file
plus any comments that refer to alltags

Can navigate on SILAboutBox and ShowReleaseNotesDialog dialogs

When the HTML code that gets displayed in the SILAboutBox or ShowReleaseNotesDialog contains links, the user can click on the link and the new page loads in the dialog. This happens on both WinForms and Gecko browsers, and is independent of the AllowNavigation setting. Clicking on a link should open the link in an external web browser (e.g. call Process.Start with the URL).

From the MSDN documentation it sounds like setting AllowNavigation to false should do what we want, but it doesn't seem to work.

Linefeed problem for Linux

LoadIanaSubtags() in StandardTags.cs is using "\r\n" to split tags. This fails on Linux which uses "\n" for a linefeed only. There are other instances of "\r\n" being used in the Palaso Library for linefeeds and these may also cause problems on Linux. Error can be recreated using test console app below.

using System;
using Palaso.IO;
using Palaso.Reporting;
using Palaso.UI.WindowsForms.WritingSystems;

namespace Palaso_LookupIsoCodeModel_test
{
class MainClass
{
public static void Main (string[] args)
{
LookupIsoCodeModel _lookupIsoCode = new LookupIsoCodeModel();
}
}
}

FileLocationUtilities.GetFileDistributedWithApplication does not work when running tests under Visual Studio Test Platform

If we can figure out an appropriate way in ReflectionHelper to detect that we're running under Visual Studio Test Platform, it should be possible to change the logic to return the executing assembly. Then maybe in FileLocationUtilities.GetFileDistributedWithApplication, we could note that we're running from inside a package location and search within the package contents to find the desired "distfile."
This issue came up because required distfiles were added to GlyssenEngine (for use in Vessel), but when running unit tests using microsoft.testplatform.testhost, it works very differently from nunit, and it cannot locate those files.

[linux] Crash in keyboarding code on Ubuntu 20.04

The recent changes to the keyboard switching code (#953) causes a crash on Ubuntu 20.04 because it's using a different version of libgnome-desktop-3 (libgnome-desktop-3.so.19 instead of libgnome-desktop-3.so.17).

This only happens on the feature/nuget branch.

flexbridge: make the feature/nuget branch the main development branch

  • merge master into feature/nuget again
  • announce that the merge of the feature/nuget branch will be made the main development branch
  • create a git tag on master (pre-nuget ?) before doing the merge
  • merge feature/nuget into master. Doing this requires adjusting the path to the CHANGELOG.md file in the .csproj as well as adjusting GitVersion.yml (removing settings for feature/nuget branch).
  • create a release of the nuget packages, and use these released nuget packages in the other projects.

Corruption in Windows language leads to a crash

WritingSystemFromWindowsLocaleProvider:GetLanguageAndKeyboardCombinations() can crash here:

yield return Tuple.Create(cleaner.GetCompleteTag(), language.LayoutName);

with

Object reference not set to an instance of an object. Source: System.Windows.Forms Assembly: System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Stack: at System.Windows.Forms.InputLanguage.get_LayoutName() at Palaso.UI.WindowsForms.WritingSystems.WritingSystemFromWindowsLocaleProvider.<GetLanguageAndKeyboardCombinations>d__4.MoveNext() in

We cannot reproduce this, but a user is getting it. Presumably he has something corrupt in his languages installation on Windows. At the very least, we could improve the error message to list the name of the language and suggest that it may be corrupt on his machine.

liblcm: make the feature/nuget branch the main development branch

  • merge master into feature/nuget again
  • announce that the merge of the feature/nuget branch will be made the main development branch
  • create a git tag on master (pre-nuget ?) before doing the merge
  • merge feature/nuget into master. Doing this requires adjusting the path to the CHANGELOG.md file in the .csproj as well as adjusting GitVersion.yml (removing settings for feature/nuget branch).
  • create a release of the nuget packages, and use these released nuget packages in the other projects.

Additional attachments are ignored when sending email

If you add multiple attachments to an IEmailMessage and send that email, all except the first attachment are silently and unexpectedly ignored by most implemented email providers although at least some of underlying email systems accept multiple attachments.

AcquireToken will never acquire if the token isn't immediately available

AcquireToken tries to get the token, then tries repeatedly over a number of seconds while saying "waiting". However, when the other app closes, no matter how long you wait, it never acquires the token, always gives up.

The reason is cleare: AcquireTokenQuietly(), which is calls repeatedly, starts with

if (s_fileLock != null)
      return false;

libpalaso: make the feature/nuget branch the main development branch

  • merge master into feature/nuget again
  • announce that the merge of the feature/nuget branch will be made the main development branch
  • create a git tag on master (pre-nuget ?) before doing the merge
  • merge feature/nuget into master. Doing this requires adjusting the path to the CHANGELOG.md file in the .csproj as well as adjusting GitVersion.yml (removing settings for feature/nuget branch).
  • create a release of the nuget packages, and use these released nuget packages in the other projects.

GlobalMutex.LinuxGlobalMutexAdapter fails to handle EINTR

While debugging a failing unit test in the LfMerge project, I got the following exception:

SIL.PlatformUtilities.NativeException : An error with the number, 4, ocurred.
  at SIL.Threading.GlobalMutex+LinuxGlobalMutexAdapter.Wait () [0x0002d] in /var/lib/TeamCity/agent/work/60b6a3b495b7759c/SIL.Core/Threading/GlobalMutex.cs:208 
  at SIL.Threading.GlobalMutex+LinuxGlobalMutexAdapter.Init (Boolean initiallyOwned) [0x0007a] in /var/lib/TeamCity/agent/work/60b6a3b495b7759c/SIL.Core/Threading/GlobalMutex.cs:198 
  at SIL.Threading.GlobalMutex.InitializeAndLock (System.Boolean& createdNew) [0x00006] in /var/lib/TeamCity/agent/work/60b6a3b495b7759c/SIL.Core/Threading/GlobalMutex.cs:98 
  at SIL.FieldWorks.FDO.Infrastructure.Impl.SharedXMLBackendProvider.StartupInternal (Int32 currentModelVersion) [0x00000] in <filename unknown>:0 
  at SIL.FieldWorks.FDO.Infrastructure.Impl.FDOBackendProvider.StartupInternalWithDataMigrationIfNeeded (IThreadedProgress progressDlg) [0x00000] in <filename unknown>:0 
  at SIL.FieldWorks.FDO.Infrastructure.Impl.FDOBackendProvider.StartupExtantLanguageProject (IProjectIdentifier projectId, Boolean fBootstrapSystem, IThreadedProgress progressDlg) [0x00000] in <filename unknown>:0

The error number in SIL.PlatformUtilities.NativeException comes from Marshal.GetLastWin32Error(), which on Linux returns the latest value of errno, the Unix C library's all-purpose error number. http://www.virtsync.com/c-error-codes-include-errno lists errno code 4 as EINTR, "Interrupted system call". According to this SO question, this blog post, and this libc manual entry, the right thing to do when EINTR is received is usually to restart the interrupted system call. (If EINTR was received because the user hit Ctrl-C or ran kill (your process ID), then your code should already be handling that signal elsewhere and shutting down the program.)

In this case, that's certainly the right approach. The LinuxGlobalMutexAdapter needs to check for EINTR and handle it by retrying the appropriate system call, up to small number of times (say, 5). I don't currently have time to work on a patch for this, but I will have some time next month if nobody gets to this issue before then.

Can't load any file in GeckoFxWebBrowserAdapter if AllowNavigation == false

It looks like GeckoFxWebBrowserAdapter.AllowNavigation is implemented incorrectly. If AllowNavigation == false then no page can be loaded at all. If AllowNavigation == true the page loads, but it also allows to navigate on that page.

MSDN states that WebBrowser.AllowNavigation indicates whether the control can navigate to another page after its initial page has been loaded. GeckoFxWebBrowserAdapter.AllowNavigation should behave identical.

The behaviour can be observed by opening the SILAboutBox with geckofx from the PalasoUIWinForms test app. The browser will only show an empty browser control on the right side.

LfMerge: make the feature/nuget branch the main development branch

  • merge master into feature/nuget again
  • announce that the merge of the feature/nuget branch will be made the main development branch
  • merge feature/nuget into master. Doing this requires adjusting the path to the CHANGELOG.md file in the .csproj as well as adjusting GitVersion.yml (removing settings for feature/nuget branch).

Use nuget packages in FieldWorks

The current work is in https://gerrit.lsdev.sil.org/c/FieldWorks/+/7869

Build succeeds (at least on my machine on Linux, haven't checked on Windows), but some test failures.

lfmerge-autosrtests: make the feature/nuget branch the main development branch

  • merge master into feature/nuget again
  • announce that the merge of the feature/nuget branch will be made the main development branch
  • merge feature/nuget into master. Doing this requires adjusting the path to the CHANGELOG.md file in the .csproj as well as adjusting GitVersion.yml (removing settings for feature/nuget branch).
  • create a release of the nuget packages, and use these released nuget packages in the other projects.

chorus: make the feature/nuget branch the main development branch

  • merge master into feature/nuget again
  • announce that the merge of the feature/nuget branch will be made the main development branch
  • create a git tag on master (pre-nuget ?) before doing the merge
  • merge feature/nuget into master. Doing this requires adjusting the path to the CHANGELOG.md file in the .csproj as well as adjusting GitVersion.yml (removing settings for feature/nuget branch).
  • create a release of the nuget packages, and use these released nuget packages in the other projects.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.