From 0b35ea197080e00ee2642f745f0e6a5181749e24 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Fri, 25 Oct 2024 08:52:07 +0700 Subject: [PATCH 1/3] FixFwData now does real work --- backend/FixFwData/FixFwData.csproj | 11 +++-- backend/FixFwData/Program.cs | 71 +++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 8 deletions(-) diff --git a/backend/FixFwData/FixFwData.csproj b/backend/FixFwData/FixFwData.csproj index 687b8f4cf..7c217f173 100644 --- a/backend/FixFwData/FixFwData.csproj +++ b/backend/FixFwData/FixFwData.csproj @@ -7,10 +7,9 @@ enable - - - - - + + + + + diff --git a/backend/FixFwData/Program.cs b/backend/FixFwData/Program.cs index 42431536a..e403836fe 100644 --- a/backend/FixFwData/Program.cs +++ b/backend/FixFwData/Program.cs @@ -1,2 +1,69 @@ -bool doNothing; // Basic FixFwData program that does nothing -doNothing = true; +// Copyright (c) 2011-2024 SIL International +// This software is licensed under the LGPL, version 2.1 or later +// (http://www.gnu.org/licenses/lgpl-2.1.html) + +using System.ComponentModel; +using Microsoft.Extensions.Logging; +using SIL.LCModel.FixData; +using SIL.LCModel.Utils; + +namespace FixFwData; + +internal class Program +{ + private static int Main(string[] args) + { + using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); + logger = loggerFactory.CreateLogger("FixFwData"); + var pathname = args[0]; + var prog = new LoggingProgress(logger); + var data = new FwDataFixer(pathname, prog, logError, getErrorCount); + data.FixErrorsAndSave(); + return errorsOccurred ? 1 : 0; + } + + private static bool errorsOccurred = false; + private static int errorCount = 0; + private static ILogger? logger; + + private static void logError(string description, bool errorFixed) + { + logger?.LogError(description); + + errorsOccurred = true; + if (errorFixed) + ++errorCount; + } + + private static int getErrorCount() + { + return errorCount; + } + + private sealed class LoggingProgress(ILogger logger) : IProgress + { + public string Message { get => ""; set => logger.LogInformation(value); } + + #region Do-nothing implementation of IProgress GUI methods + // IProgress methods required by the interface that don't make sense in a console app + public event CancelEventHandler? Canceling; + public void Step(int amount) + { + if (Canceling != null) + { + // don't do anything -- this just shuts up the compiler about the + // event handler never being used. + } + } + + public string Title { get => ""; set { } } + public int Position { get; set; } + public int StepSize { get; set; } + public int Minimum { get; set; } + public int Maximum { get; set; } + public ISynchronizeInvoke? SynchronizeInvoke { get => null; private set { } } + public bool IsIndeterminate { get => false; set { } } + public bool AllowCancel { get => false; set { } } + #endregion + } +} From b27c9c32860b6e6fb239602f65d1cbb86bd6d2a1 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Fri, 25 Oct 2024 11:06:10 +0700 Subject: [PATCH 2/3] Allow `dotnet restore LexBox.sln` to run on Linux When running `dotnet restore` on Linux against the whole solution, it fails with the following error message: error NETSDK1100: To build a project targeting Windows on this operating system, set the EnableWindowsTargeting property to true. We don't want to set EnableWindowsTargeting on Mac, so we'll use a condition to only set it when building on Linux. --- backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj b/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj index ffd98f458..043dacd5d 100644 --- a/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj +++ b/backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj @@ -22,6 +22,7 @@ enable enable true + true FieldWorks Lite From 02b7bfca3ce157eefa2d6b8ac67fde8d9efb47bb Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Fri, 25 Oct 2024 11:07:38 +0700 Subject: [PATCH 3/3] FixFwData needs version 14 of SIL.Core FixFwData uses the latest version of liblcm, which needs a later SIL.Core release than the one Testing.csproj is currently targeting. --- backend/Testing/Testing.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/Testing/Testing.csproj b/backend/Testing/Testing.csproj index 797c22891..04fa2ae8c 100644 --- a/backend/Testing/Testing.csproj +++ b/backend/Testing/Testing.csproj @@ -38,7 +38,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive