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

FixFwData now does real work #1159

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions backend/FixFwData/FixFwData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<Target Name="CreateExe" AfterTargets="Build" Condition="Exists('$(OutputPath)/FixFwData') And !Exists('$(OutputPath)/FixFwData.exe')">
<Message Text="Creating FixFwData.exe in $(OutputPath) on Linux since FLExBridge requires the .exe extension" />
<Exec Command="ln FixFwData FixFwData.exe"
WorkingDirectory="$(OutputPath)" />
</Target>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageReference Include="SIL.LCModel.FixData" Version="11.0.0-beta0109" />
</ItemGroup>
</Project>
71 changes: 69 additions & 2 deletions backend/FixFwData/Program.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
1 change: 1 addition & 0 deletions backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<SelfContained>true</SelfContained>
<EnableWindowsTargeting Condition="$([MSBuild]::IsOSPlatform('linux'))">true</EnableWindowsTargeting>

<!-- controls display name in Package.appxmanifest -->
<ApplicationTitle>FieldWorks Lite</ApplicationTitle>
Expand Down
2 changes: 1 addition & 1 deletion backend/Testing/Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<PackageReference Include="Moq.Contrib.HttpClient" Version="1.4.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="SIL.ChorusPlugin.LfMergeBridge" Version="4.1.0" />
<PackageReference Include="SIL.Core" Version="13.0.0-beta0074" />
<PackageReference Include="SIL.Core" Version="14.2.0-*" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading