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

Adding Framework 4.8 and .NET8 to targets. #118

Merged
merged 19 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
16 changes: 3 additions & 13 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ jobs:

build-and-test:
name: "Build and Test"
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
runs-on: windows-latest

steps:
- name: Checkout
Expand All @@ -34,19 +31,13 @@ jobs:
- name: Install .NET Core
uses: actions/setup-dotnet@c0d4ad69d8bd405d234f1c9166d383b7a4f69ed8 # v2.1.0
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Build and Pack
run: dotnet build --configuration Release

- name: Test (Ubuntu)
run: dotnet test --configuration Release --no-build --filter TestCategory!=RequiresDisplay -- NUnit.TestOutputXml=TestResults
if: matrix.os == 'ubuntu-latest'

- name: Test (Windows)
# specify path to test assembly as workaround for https://github.com/nunit/nunit3-vs-adapter/issues/1040
run: dotnet test --configuration Release --no-build output\Release\net461\*Tests.dll -- NUnit.TestOutputXml=TestResults
if: matrix.os != 'ubuntu-latest'
run: dotnet test --configuration Release --no-build -- NUnit.TestOutputXml=TestResults

- name: Upload Test Results
if: always()
Expand All @@ -62,7 +53,6 @@ jobs:
path: |
output/*.nupkg
output/*.snupkg
if: matrix.os == 'ubuntu-latest'

publish-nuget:
name: "Publish NuGet package"
Expand Down
4 changes: 3 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>
<TargetFrameworks>net461;net481;net8.0-windows</TargetFrameworks>
<Company>SIL</Company>
<Authors>SIL International</Authors>
<Product>L10NSharp</Product>
Expand All @@ -24,6 +24,8 @@ See full changelog at https://github.com/sillsdev/l10nsharp/blob/master/CHANGELO
</AppendToReleaseNotesProperty>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
<UseWindowsForms>true</UseWindowsForms>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>
<ItemGroup>
<!-- Without this line some projects fail to build on TC with "error : SourceRoot items
Expand Down
4 changes: 2 additions & 2 deletions src/CheckOrFixXliff/CheckOrFixXliff.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/sillsdev/l10nsharp/tree/master/src/CheckOrFixXliff</PackageProjectUrl>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<NoWarn>$(NoWarn);NU5128</NoWarn>
<NoWarn>$(NoWarn);NU5128;NU5118</NoWarn>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net481' ">
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/CheckOrFixXliff/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private static bool CheckForWellFormedXml(string filename)
private static bool ValidateXliffAgainstSchema(string filename)
{
bool valid = true;
var installedXliffDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
var installedXliffDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).LocalPath);
var schemaLocation = Path.Combine(installedXliffDir, "xliff-core-1.2-transitional.xsd");
var schemas = new XmlSchemaSet();
using (var reader = XmlReader.Create(schemaLocation))
Expand Down
4 changes: 2 additions & 2 deletions src/ExtractXliff/ExtractXliff.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<PackageId>L10NSharp.ExtractXliff</PackageId>
<PackageProjectUrl>https://github.com/sillsdev/l10nsharp/tree/master/src/ExtractXliff</PackageProjectUrl>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<NoWarn>$(NoWarn);NU5128</NoWarn>
<NoWarn>$(NoWarn);NU5128;NU5118</NoWarn>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net481' ">
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion src/L10NSharp/L10NCultureInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ public L10NCultureInfo(string name)
{
RawCultureInfo = null;
}
if (RawCultureInfo == null || RawCultureInfo.EnglishName.StartsWith("Unknown Language"))

// Windows 10 changed the behavior of CultureInfo, in that unknown cultures no longer return a RawCultureInfo containing an "Unknown Language" indication.
// The proper way to detect fully unknown cultures (for Windows 10 and prior) is to:
// 1. Check for the custom culture flag
// 2. Check if the three-letter language name is set to default
// Source: https://stackoverflow.com/a/71388328/1964319
var isFullyUnknown = RawCultureInfo.CultureTypes.HasFlag(CultureTypes.UserCustomCulture) && RawCultureInfo.ThreeLetterWindowsLanguageName == "ZZZ";
if (RawCultureInfo == null || isFullyUnknown)
{
Name = name;
IsNeutralCulture = !Name.Contains("-");
Expand Down
8 changes: 6 additions & 2 deletions src/L10NSharp/L10NSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>L10NSharp</RootNamespace>
<Description>L10NSharp is a .NET localization library for Windows Forms applications. It collects strings which need localization when your application first runs and saves them in a XLIFF file. It can also dynamically collect strings at runtime.</Description>
<AssemblyTitle>L10NSharp</AssemblyTitle>
<PackageId>L10NSharp</PackageId>
<PackageProjectUrl>https://github.com/sillsdev/l10nsharp</PackageProjectUrl>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net481' ">
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0-windows' ">
<PackageReference Include="System.ServiceModel.Http" Version="6.2.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.2.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="5.11.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
Expand Down
3 changes: 2 additions & 1 deletion src/L10NSharpTests/L10NCultureInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void L10NCultureInfo_TestPbu()
else if (pbuci.RawCultureInfo != null)
{
Assert.AreEqual("pbu", pbuci.RawCultureInfo.Name);
Assert.AreEqual("Unknown Language (pbu)", pbuci.RawCultureInfo.EnglishName);
Assert.IsTrue(pbuci.RawCultureInfo.CultureTypes.HasFlag(CultureTypes.UserCustomCulture));
Assert.AreEqual("ZZZ", pbuci.RawCultureInfo.ThreeLetterWindowsLanguageName);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/L10NSharpTests/L10NSharpTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.2" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net481' ">
<Reference Include="System.Windows.Forms" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/L10NSharpTests/TempFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public TempFolder(): this(TestContext.CurrentContext.Test.Name)
public TempFolder(string testName)
{
testName = System.IO.Path.GetInvalidPathChars().Aggregate(testName,
(current, c) => current.Replace(c, '_')).Replace('`', '_');
(current, c) => current.Replace(c, '_')).Replace('`', '_').Replace('"', '_');
_path = System.IO.Path.Combine(BasePath, testName);
if(Directory.Exists(_path))
{
Expand Down
4 changes: 3 additions & 1 deletion src/L10NSharpTests/XLiffSchemaValidationTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017 SIL International
// Copyright (c) 2017 SIL International
// This software is licensed under the MIT License (http://opensource.org/licenses/MIT)

using System;
Expand All @@ -18,7 +18,7 @@
{
get
{
var dir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

Check warning on line 21 in src/L10NSharpTests/XLiffSchemaValidationTests.cs

View workflow job for this annotation

GitHub Actions / Build and Test

'Assembly.CodeBase' is obsolete: 'Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location.' (https://aka.ms/dotnet-warnings/SYSLIB0012)
var installedXliffDir = "../../../src/L10NSharpTests/TestXliff";

var schemaLocation = Path.Combine(dir, installedXliffDir,
Expand All @@ -42,6 +42,7 @@
Directory.CreateDirectory(folder.Path);
new XLiffLocalizationManagerTests().SetupManager(folder);

AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);
var schemas = new XmlSchemaSet();
using (var reader = XmlReader.Create(SchemaLocation))
{
Expand Down Expand Up @@ -88,6 +89,7 @@
Directory.CreateDirectory(folder.Path);
new XLiffLocalizationManagerTests().SetupManager(folder);

AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);
var schemas = new XmlSchemaSet();
using (var reader = XmlReader.Create(SchemaLocation))
{
Expand Down
2 changes: 1 addition & 1 deletion src/SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyTitle>SampleApp</AssemblyTitle>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net481' ">
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading