Skip to content

Commit

Permalink
Adding Framework 4.8 and .NET8 to targets. (#118)
Browse files Browse the repository at this point in the history
* Adding Framework 4.8.1 and .NET8 to targets.
  • Loading branch information
josephmyers authored Jun 4, 2024
1 parent 5545cb6 commit f0bbbd9
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 21 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,19 @@ 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
- name: Test (Framework 4.6.1)
run: dotnet test --configuration Release --no-build output\Release\net461\*Tests.dll -- NUnit.TestOutputXml=TestResults
if: matrix.os != 'ubuntu-latest'

- name: Test (Framework and .NET latest)
run: dotnet test --configuration Release --no-build -- NUnit.TestOutputXml=TestResults
if: matrix.os != 'ubuntu-latest'

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
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;net48;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)' == 'net48' ">
<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)' == '' ">
<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 11 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)' == 'net48' ">
<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)' == 'net48' ">
<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 Down Expand Up @@ -42,6 +42,7 @@ public void ValidateInFoldersAgainstSchema()
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 @@ public void ValidateFlatFilesAgainstSchema()
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)' == 'net48' ">
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit f0bbbd9

Please sign in to comment.