This release drops .NET Standard in favor of .NET 6.

There are a lot of significant under the hood changes with the release. See the change log for details.
This commit is contained in:
Tony Bark 2021-11-19 13:52:26 -05:00
parent ceebb00314
commit 229ab4f0ad
12 changed files with 179 additions and 186 deletions

View file

@ -10,8 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet: ["3.1.404", "5.0.101"]
dotnet: ["6.0.x"]
steps:
- uses: actions/checkout@v2
- name: Setup .NET

View file

@ -9,11 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.404
dotnet-version: "6.0.x"
- name: Install dependencies
run: dotnet restore
- name: Package

View file

@ -14,15 +14,13 @@ See [usage.md](./usage.md).
## Known issues
- Skipping comments is a little buggy.
- Skipping comments is a little unpredictable.
## Requirements
### Prerequisites
- [.NET](https://dotnet.microsoft.com/download) 5+ or Core 3.1
- [.NET Interactive](https://github.com/dotnet/interactive/blob/main/README.md) for notebooks
- [VSCode Extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode) (does not require Jupyter)
- [nteract](https://nteract.io/) (requires Jupyter)
- [.NET](https://dotnet.microsoft.com/download) 6+.
- [.NET Interactive](https://github.com/dotnet/interactive/blob/main/README.md) for notebooks (optional).
- [VSCode Extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode) or [nteract](https://nteract.io/)
## License

View file

@ -0,0 +1,3 @@
// This project is licensed under the MIT license.
// See the LICENSE file in the project root for more information.
global using Xunit;

View file

@ -1,10 +1,8 @@
// This project is licensed under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using Xunit;
namespace Sixam.CST.Tests
{
namespace Sixam.CST.Tests;
public class MultilineTests
{
[Fact]
@ -25,4 +23,3 @@ namespace Sixam.CST.Tests
Assert.Equal(expected, actual);
}
}
}

View file

@ -1,9 +1,8 @@
// This project is licensed under the MIT license.
// See the LICENSE file in the project root for more information.
using Xunit;
namespace Sixam.CST.Tests
{
namespace Sixam.CST.Tests;
public class SingleLineTests
{
[Theory]
@ -25,4 +24,3 @@ namespace Sixam.CST.Tests
Assert.Equal(expected, actual);
}
}
}

View file

@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

View file

@ -1,11 +1,8 @@
// This project is licensed under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Sixam.CST
{
namespace Sixam.CST;
public class CaretSeparatedText
{
const char CARET = '^';
@ -81,10 +78,3 @@ namespace Sixam.CST
return "***MISSING***";
}
}
}
namespace CSTNet
{
[Obsolete("Use the Sixam.CST namespace instead.")]
public class CaretSeparatedText : Sixam.CST.CaretSeparatedText { }
}

View file

@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.1.100</Version>
<TargetFramework>net6.0</TargetFramework>
<Version>1.2.100</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>Tony Bark, Sixam Software</Authors>
<PackageDescription>
Caret-Separated Text (or CST) is a key-value pair format represented by digits or words as keys and the value as text enclosed between carets. ([key] ^[value]^)

View file

@ -1,10 +1,8 @@
// This project is licensed under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
namespace Sixam.CST
{
namespace Sixam.CST;
public class UIText
{
string Language { get; set; } = "english";
@ -54,4 +52,3 @@ namespace Sixam.CST
return "***MISSING***";
}
}
}

View file

@ -1,5 +1,19 @@
# Change Log
## 1.2.100
This version removes support for .NET Standard 2.0 in favor of .NET 6 and brings with it (much needed) quality of life changes to the project. Apart from the removal of the ``CSTNet`` namespace, nothing has changed to the API itself and you can continue to use to 1.1.100 on all platforms where .NET Standard 2.0 is [supported](https://dotnet.microsoft.com/platform/dotnet-standard).
From 1.2 onward, Sixam.CST will only target LTS releases. This is why .NET 5 was skipped, despite the initial platform unification.
### Project Changes
With the move to .NET 6.0, this version brings with it a lot of quality of life changes to the project. This includes file-scoped namespaces, implicit and global usings. For a full list of language changes see [Welcome to C# 10](https://devblogs.microsoft.com/dotnet/welcome-to-csharp-10/).
### Nullable Reference Types
The only significant architectural change that was finally enabled with this release is [nullable reference types](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/nullable-reference-types). This feature was introduced in .NET Core 3.0 and .NET Standard 2.1, respectfully, but not the .NET Framework. Nullable values are already taken care of by the library. The reason why I never switched to 2.1 before was because the Sims community has historically targeted the .NET Framework, and that doesn't support 2.1.
## 1.1.100
- Switched to Sixam.CST namespace and marked CSTNet namespace as obsolete.

View file

@ -7,9 +7,7 @@
```
```csharp
#r "nuget:Sixam.CST,1.1"
using System;
using System.IO;
#r "nuget:Sixam.CST,1.1.100" // If using notebooks
using Sixam.CST;
var file = File.ReadAllText("example.cst");
@ -18,31 +16,29 @@ var example = CaretSeparatedText.Parse(file, 1);
Console.WriteLine(example);
```
See working example on [.NET Fiddle](https://dotnetfiddle.net/ecKb2h).
## Complex Scenarios
In production, CST files were used in The Sims Online (TSO) to provide translations. It was required that they were prefixed with numbers enclosed in underscores, known as the ID. The IDs were used to locate the right file without knowing it's name. Meanwhile, each translation was split into their respective ``uitext/<languae>.dir`` directories:
In production, CST files were used in The Sims Online to provide translations It was required that they were prefixed with numbers enclosed in underscores, known as the ID. The IDs were used to locate the right file without knowing it's name. Meanwhile, each translation was split into their respective ``uitext/<languae>.dir`` directories:
- ``uitext/english.dir/_154_miscstrings.cst``
- ``uitext/swedish.dir/_154_miscstrings.cst``[^1]
- ``uitext/swedish.dir/_154_miscstrings.cst``
Starting with 1.1, the UIText class provides methods that directorly map to these directories relative to the application's.
```csharp
#r "nuget:Sixam.CST,1.1"
#r "nuget:Sixam.CST,1.1.100"
using Sixam.CST;
var english = new UIText(); // UIText assumes English
var swedish = new UIText("swedish");
var engExample = english.GetText(101, 1); // english.dir/_101_example.cst
var sweExample = swedish.GetText(101, 1); // swedish.dir/_101_example.cst
var engExample = english.GetText(152, 1); // english.dir/_154_miscstrings.cst
var sweExample = swedish.GetText(152, 1); // swedish.dir/_154_miscstrings.cst
Console.WriteLine(engExample);
Console.WriteLine(sweExample);
```
Note that GetText() remains unchanged because the translation is expected to be same id and key, despite being in a different directory.
Note that the IDs and keys in both ``GetText()`` examples remains the same. This is because it was historically assumed that the English and translations files were identical. However, the original never saw any new languages added.
### Changing base directories
@ -57,5 +53,3 @@ var example = new UIText()
BasePath = new[] { "gamedata", "uitext" },
};
```
[^1]: TSO only supported English.