mirror of
https://github.com/tonytins/cstdotnet.git
synced 2025-03-23 00:32:20 +00:00
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:
parent
ceebb00314
commit
229ab4f0ad
12 changed files with 179 additions and 186 deletions
3
.github/workflows/dotnet.yml
vendored
3
.github/workflows/dotnet.yml
vendored
|
@ -10,8 +10,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
dotnet: ["3.1.404", "5.0.101"]
|
dotnet: ["6.0.x"]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
|
|
3
.github/workflows/pkgrelease.yml
vendored
3
.github/workflows/pkgrelease.yml
vendored
|
@ -9,11 +9,10 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup dotnet
|
- name: Setup dotnet
|
||||||
uses: actions/setup-dotnet@v1
|
uses: actions/setup-dotnet@v1
|
||||||
with:
|
with:
|
||||||
dotnet-version: 3.1.404
|
dotnet-version: "6.0.x"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: dotnet restore
|
run: dotnet restore
|
||||||
- name: Package
|
- name: Package
|
||||||
|
|
10
README.md
10
README.md
|
@ -14,15 +14,13 @@ See [usage.md](./usage.md).
|
||||||
|
|
||||||
## Known issues
|
## Known issues
|
||||||
|
|
||||||
- Skipping comments is a little buggy.
|
- Skipping comments is a little unpredictable.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
- [.NET](https://dotnet.microsoft.com/download) 5+ or Core 3.1
|
- [.NET](https://dotnet.microsoft.com/download) 6+.
|
||||||
- [.NET Interactive](https://github.com/dotnet/interactive/blob/main/README.md) for notebooks
|
- [.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) (does not require Jupyter)
|
- [VSCode Extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode) or [nteract](https://nteract.io/)
|
||||||
- [nteract](https://nteract.io/) (requires Jupyter)
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
3
Sixam.CST.Tests/GlobalUsings.cs
Normal file
3
Sixam.CST.Tests/GlobalUsings.cs
Normal 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;
|
|
@ -1,10 +1,8 @@
|
||||||
// This project is licensed under the MIT license.
|
// This project is licensed under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// 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
|
public class MultilineTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -25,4 +23,3 @@ namespace Sixam.CST.Tests
|
||||||
Assert.Equal(expected, actual);
|
Assert.Equal(expected, actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
// This project is licensed under the MIT license.
|
// This project is licensed under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace Sixam.CST.Tests
|
namespace Sixam.CST.Tests;
|
||||||
{
|
|
||||||
public class SingleLineTests
|
public class SingleLineTests
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
|
@ -25,4 +24,3 @@ namespace Sixam.CST.Tests
|
||||||
Assert.Equal(expected, actual);
|
Assert.Equal(expected, actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
// This project is licensed under the MIT license.
|
// This project is licensed under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// 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
|
public class CaretSeparatedText
|
||||||
{
|
{
|
||||||
const char CARET = '^';
|
const char CARET = '^';
|
||||||
|
@ -81,10 +78,3 @@ namespace Sixam.CST
|
||||||
return "***MISSING***";
|
return "***MISSING***";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
namespace CSTNet
|
|
||||||
{
|
|
||||||
[Obsolete("Use the Sixam.CST namespace instead.")]
|
|
||||||
public class CaretSeparatedText : Sixam.CST.CaretSeparatedText { }
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<Version>1.1.100</Version>
|
<Version>1.2.100</Version>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Authors>Tony Bark, Sixam Software</Authors>
|
<Authors>Tony Bark, Sixam Software</Authors>
|
||||||
<PackageDescription>
|
<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]^)
|
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]^)
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
// This project is licensed under the MIT license.
|
// This project is licensed under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// 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
|
public class UIText
|
||||||
{
|
{
|
||||||
string Language { get; set; } = "english";
|
string Language { get; set; } = "english";
|
||||||
|
@ -54,4 +52,3 @@ namespace Sixam.CST
|
||||||
return "***MISSING***";
|
return "***MISSING***";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
14
changelog.md
14
changelog.md
|
@ -1,5 +1,19 @@
|
||||||
# Change Log
|
# 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
|
## 1.1.100
|
||||||
|
|
||||||
- Switched to Sixam.CST namespace and marked CSTNet namespace as obsolete.
|
- Switched to Sixam.CST namespace and marked CSTNet namespace as obsolete.
|
||||||
|
|
20
usage.md
20
usage.md
|
@ -7,9 +7,7 @@
|
||||||
```
|
```
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
#r "nuget:Sixam.CST,1.1"
|
#r "nuget:Sixam.CST,1.1.100" // If using notebooks
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using Sixam.CST;
|
using Sixam.CST;
|
||||||
|
|
||||||
var file = File.ReadAllText("example.cst");
|
var file = File.ReadAllText("example.cst");
|
||||||
|
@ -18,31 +16,29 @@ var example = CaretSeparatedText.Parse(file, 1);
|
||||||
Console.WriteLine(example);
|
Console.WriteLine(example);
|
||||||
```
|
```
|
||||||
|
|
||||||
See working example on [.NET Fiddle](https://dotnetfiddle.net/ecKb2h).
|
|
||||||
|
|
||||||
## Complex Scenarios
|
## 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/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.
|
Starting with 1.1, the UIText class provides methods that directorly map to these directories relative to the application's.
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
#r "nuget:Sixam.CST,1.1"
|
#r "nuget:Sixam.CST,1.1.100"
|
||||||
using Sixam.CST;
|
using Sixam.CST;
|
||||||
|
|
||||||
var english = new UIText(); // UIText assumes English
|
var english = new UIText(); // UIText assumes English
|
||||||
var swedish = new UIText("swedish");
|
var swedish = new UIText("swedish");
|
||||||
var engExample = english.GetText(101, 1); // english.dir/_101_example.cst
|
var engExample = english.GetText(152, 1); // english.dir/_154_miscstrings.cst
|
||||||
var sweExample = swedish.GetText(101, 1); // swedish.dir/_101_example.cst
|
var sweExample = swedish.GetText(152, 1); // swedish.dir/_154_miscstrings.cst
|
||||||
|
|
||||||
Console.WriteLine(engExample);
|
Console.WriteLine(engExample);
|
||||||
Console.WriteLine(sweExample);
|
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
|
### Changing base directories
|
||||||
|
|
||||||
|
@ -57,5 +53,3 @@ var example = new UIText()
|
||||||
BasePath = new[] { "gamedata", "uitext" },
|
BasePath = new[] { "gamedata", "uitext" },
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
[^1]: TSO only supported English.
|
|
Loading…
Add table
Reference in a new issue