.NET 6 quality of life changes to Tomas.Common

- Split and simplified version details
- Raw commit hash is now a build number based on that hash
This commit is contained in:
Tony Bark 2023-01-06 20:39:31 -05:00
parent 69fcc9c776
commit a029d8d4d9
13 changed files with 81 additions and 79 deletions

View file

@ -1,15 +1,29 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
namespace Tomas.Common using System.Text;
{
public struct ComConsts
{
/// <summary>
/// Name of the operating system
/// </summary>
public const string NAME = "TOMAS";
public static string Version = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}"; namespace Tomas.Common;
public static string VersionGit = $"{Version}-{ThisAssembly.Git.Commit}";
} public struct ComConsts
{
/// <summary>
/// Name of the operating system
/// </summary>
public const string NAME = "TOMAS";
public const string VERSION = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}";
[SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible")]
public static string BuildNumber = $"Build {BuildFromCommit}";
/// <summary>
/// Generate the build number from the commit hash.
/// </summary>
static uint BuildFromCommit
{
get
{
var commit = Encoding.UTF8.GetBytes(ThisAssembly.Git.Commit);
return BitConverter.ToUInt32(commit, 0) % 1000000;
}
}
} }

View file

@ -0,0 +1,2 @@
global using System.Diagnostics.CodeAnalysis;
global using Tomas.Interface;

View file

@ -1,16 +1,13 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause 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 Tomas.Interface;
namespace Tomas.Common.Programs namespace Tomas.Common.Programs;
public class Clear : IProgram
{ {
public class Clear : IProgram public bool Run(IShell shell)
{ {
public bool Run(IShell shell) Console.Clear();
{ return true;
Console.Clear(); }
return true;
}
}
} }

View file

@ -1,19 +1,16 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause 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 Tomas.Interface;
namespace Tomas.Common.Programs namespace Tomas.Common.Programs;
public class Commands : IProgram
{ {
public class Commands : IProgram public bool Run(IShell shell)
{ {
public bool Run(IShell shell) Console.WriteLine($"Commands:");
{ var progs = shell.Programs;
Console.WriteLine($"Commands:"); foreach (var commands in progs.Keys)
var progs = shell.Programs; Console.WriteLine(commands);
foreach (var commands in progs.Keys) return true;
Console.WriteLine(commands); }
return true;
}
}
} }

View file

@ -1,17 +1,15 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause 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 Tomas.Interface;
namespace Tomas.Common.Programs namespace Tomas.Common.Programs;
public class FenSay : IProgram
{ {
public class FenSay : IProgram
{
/// <summary> /// <summary>
/// Fennec art by Todd Vargo /// Fennec art by Todd Vargo
/// </summary> /// </summary>
const string _fennec = @" \/ const string _fennec = @" \/
/\ /\ /\ /\
//\\_//\\ ____ //\\_//\\ ____
\_ _/ / / \_ _/ / /
@ -22,20 +20,19 @@ namespace Tomas.Common.Programs
[ [ / \/ _/ [ [ / \/ _/
_[ [ \ /_/"; _[ [ \ /_/";
readonly string[] _phrases = readonly string[] _phrases =
{ {
"[SCREAMS IN FENNEC]", "[SCREAMS IN FENNEC]",
"Some people call me a coffee fox.", "Some people call me a coffee fox.",
"Drink Soda. It makes you see faster.", "Drink Soda. It makes you see faster.",
"10/10, Wouldn't Recommend." "10/10, Wouldn't Recommend."
}; };
public bool Run(IShell shell) public bool Run(IShell shell)
{ {
var rng = new Random(); var rng = new Random();
var phrases = _phrases[rng.Next(_phrases.Length)]; var phrases = _phrases[rng.Next(_phrases.Length)];
Console.WriteLine($"{phrases}{Environment.NewLine}{_fennec}"); Console.WriteLine($"{phrases}{Environment.NewLine}{_fennec}");
return true; return true;
} }
}
} }

View file

@ -1,18 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Tomas.Interface\Tomas.Interface.csproj" /> <ProjectReference Include="..\Tomas.Interface\Tomas.Interface.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="GitInfo" Version="2.1.2"> <PackageReference Include="GitInfo" Version="2.1.2">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -1,5 +1,4 @@
global using Tomas.Common.Programs; global using Tomas.Common.Programs;
global using Tomas.Interface; global using Tomas.Interface;
global using Tomas.Kernel;
global using Tomas.Kernel.Programs; global using Tomas.Kernel.Programs;
global using Os = Cosmos.System; global using Os = Cosmos.System;

View file

@ -1,6 +1,5 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause 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;
namespace Tomas.Kernel; namespace Tomas.Kernel;

View file

@ -1,6 +1,5 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause 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 Tomas.Common; using Tomas.Common;
namespace Tomas.Kernel.Programs; namespace Tomas.Kernel.Programs;
@ -9,7 +8,7 @@ public class About : IProgram
{ {
public bool Run(IShell shell) public bool Run(IShell shell)
{ {
Console.WriteLine($"TOMAS v{ComConsts.VersionGit} is a hobby operating system written in C# using the COSMOS framework.{Environment.NewLine}Commands:"); Console.WriteLine($"TOMAS v{ComConsts.VERSION} ({ComConsts.BuildNumber}) is a hobby operating system written in C# using the COSMOS framework.{Environment.NewLine}Commands:");
var progs = shell.Programs; var progs = shell.Programs;
foreach (var commands in progs.Keys) foreach (var commands in progs.Keys)
Console.WriteLine(commands); Console.WriteLine(commands);

View file

@ -1,7 +1,5 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause 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;
namespace Tomas.Kernel; namespace Tomas.Kernel;

View file

@ -1,7 +1,5 @@
// I license this project under the BSD 3-Clause license. // I license this project under the BSD 3-Clause 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;
using Cosmos.System.FileSystem; using Cosmos.System.FileSystem;
using Cosmos.System.FileSystem.VFS; using Cosmos.System.FileSystem.VFS;
using Tomas.Common; using Tomas.Common;
@ -23,7 +21,7 @@ class TomFS
Console.WriteLine("Creating system files."); Console.WriteLine("Creating system files.");
fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt"); fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine("Setting system preferences."); Console.WriteLine("Setting system preferences.");
File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{ComConsts.NAME}, {ComConsts.VersionGit}"); File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{ComConsts.NAME}, {ComConsts.BuildNumber}");
Console.WriteLine("File system loaded sucesfully."); Console.WriteLine("File system loaded sucesfully.");
var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt"); var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine(intro); Console.WriteLine(intro);

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -6,6 +6,7 @@
<Platform>cosmos</Platform> <Platform>cosmos</Platform>
<SupportsX86Intrinsics>false</SupportsX86Intrinsics> <SupportsX86Intrinsics>false</SupportsX86Intrinsics>
<SelfContained>True</SelfContained> <SelfContained>True</SelfContained>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@ -26,8 +27,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Tomas.Common\Tomas.Common.csproj" /> <ProjectReference Include="..\Tomas.Common\Tomas.Common.csproj" />
<ProjectReference Include="..\Tomas.Interface\Tomas.Interface.csproj" /> <ProjectReference Include="..\Tomas.Interface\Tomas.Interface.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -8,7 +8,7 @@ public class About : IProgram
{ {
public bool Run(IShell shell) public bool Run(IShell shell)
{ {
Console.WriteLine($"{ComConsts.NAME} Terminal Emulator v{ComConsts.VersionGit}{Environment.NewLine}" Console.WriteLine($"{ComConsts.NAME} Terminal Emulator v{ComConsts.BuildNumber}{Environment.NewLine}"
+ "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework."); + "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework.");
return true; return true;
} }