Migrated to .NET 6.0

- Switched to file-scoped namespaces
- Enabled Implicit Usings and Nullable

Kernal was migrated too but is unusable, at the moment. Stick with developing or testing from the terminal emulator.
This commit is contained in:
Tony Bark 2021-11-22 17:48:50 -05:00
parent 4f0863f429
commit bdbd8572ea
19 changed files with 233 additions and 264 deletions

View file

@ -13,7 +13,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
dotnet: ["3.1.x", "5.0.x"] dotnet: ["6.0.x"]
os: [windows-latest, ubuntu-latest, macOS-latest] os: [windows-latest, ubuntu-latest, macOS-latest]
steps: steps:

View file

@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16 # Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97 VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Kernel", "Tomas.Kernel\Tomas.Kernel.csproj", "{AF6338C3-342A-4A12-A25C-2D53C5568DA8}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tomas.Kernel", "Tomas.Kernel\Tomas.Kernel.csproj", "{AF6338C3-342A-4A12-A25C-2D53C5568DA8}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tomas.Common", "Tomas.Common\Tomas.Common.csproj", "{C50F3A6F-CFF4-4725-A1A5-21C5A2BC3321}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tomas.Common", "Tomas.Common\Tomas.Common.csproj", "{C50F3A6F-CFF4-4725-A1A5-21C5A2BC3321}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{59C9B3FC-B1EE-4C23-9BD9-D33074BF1334}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{59C9B3FC-B1EE-4C23-9BD9-D33074BF1334}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject

View file

@ -1,15 +1,14 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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 namespace Tomas.Common;
{
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}"; public struct ComConsts
public static string VersionGit = $"{Version}-{ThisAssembly.Git.Commit}"; {
} /// <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}";
public const string VersionGit = $"{Version}-{ThisAssembly.Git.Commit}";
}

View file

@ -1,14 +1,12 @@
using System;
using Tomas.Interface; 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,17 +1,15 @@
using System;
using Tomas.Interface; 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,18 +1,17 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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; using Tomas.Interface;
namespace Tomas.Common.Programs namespace Tomas.Common.Programs;
{
public class FenSay : IProgram
{
/// <summary> public class FenSay : IProgram
/// Fennec art by Todd Vargo {
/// </summary>
const string _fennec = @" \/ /// <summary>
/// Fennec art by Todd Vargo
/// </summary>
const string _fennec = @" \/
/\ /\ /\ /\
//\\_//\\ ____ //\\_//\\ ____
\_ _/ / / \_ _/ / /
@ -23,20 +22,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,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -9,7 +11,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="GitInfo" Version="2.1.2"> <PackageReference Include="GitInfo" Version="2.2.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View file

@ -1,15 +1,14 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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.Interface namespace Tomas.Interface;
public interface IProgram
{ {
public interface IProgram /// <summary>
{ /// The program's main entry point. Boolean behaves as an exit point.
/// <summary> /// True and False are the equivalent to C's 0 and 1, i.e. "Success" and "Failure," respectfully.
/// The program's main entry point. Boolean behaves as an exit point. /// </summary>
/// True and False are the equivalent to C's 0 and 1, i.e. "Success" and "Failure," respectfully. /// <param name="shell">Allows the program to interact with the shell.</param>
/// </summary> /// <returns>Exit back to shell.</returns>
/// <param name="shell">Allows the program to interact with the shell.</param> bool Run(IShell shell);
/// <returns>Exit back to shell.</returns> }
bool Run(IShell shell);
}
}

View file

@ -1,14 +1,10 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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.Interface;
using System.Collections.Generic; public interface IShell
namespace Tomas.Interface
{ {
public interface IShell string ReadLine { get; }
{
string ReadLine { get; }
Dictionary<string, IProgram> Programs { get; } Dictionary<string, IProgram> Programs { get; }
} }
}

View file

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

View file

@ -1,66 +1,63 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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 Tomas.Common; using Tomas.Common;
using Sys = Cosmos.System; using Sys = Cosmos.System;
namespace Tomas.Kernel namespace Tomas.Kernel;
public class Kernel : Sys.Kernel
{ {
public class Kernel : Sys.Kernel protected override void BeforeRun()
{ {
protected override void BeforeRun() try
{ {
Sys.PCSpeaker.Beep();
TomFS.Initialize();
}
catch
{
Sys.PCSpeaker.Beep();
Console.WriteLine("File system failed to load! Not all functions will work.");
}
Console.WriteLine($"{ComConsts.NAME} v{ComConsts.VersionGit} Booted successfully.");
}
protected override void Run()
{
while (true)
{
var shell = new Shell();
var command = shell.ReadLine;
if (!OSConsts.Programs.TryGetValue(command, out var program))
{
Console.WriteLine("Command Unknown.");
continue;
}
try try
{ {
Sys.PCSpeaker.Beep(); var start = program.Run(shell);
TomFS.Initialize(); switch (start)
{
case true:
continue;
case false:
Console.WriteLine("Program closed unexpectedly.");
continue;
}
} }
catch catch (Exception err)
{ {
Sys.PCSpeaker.Beep(); Console.WriteLine(err.Message);
Console.WriteLine("File system failed to load! Not all functions will work.");
} }
Console.WriteLine($"{ComConsts.NAME} v{ComConsts.VersionGit} Booted successfully.");
}
protected override void Run()
{
while (true)
{
var shell = new Shell();
var command = shell.ReadLine;
if (!OSConsts.Programs.TryGetValue(command, out var program))
{
Console.WriteLine("Command Unknown.");
continue;
}
try
{
var start = program.Run(shell);
switch (start)
{
case true:
continue;
case false:
Console.WriteLine("Program closed unexpectedly.");
continue;
}
}
catch (Exception err)
{
Console.WriteLine(err.Message);
}
}
}
protected override void AfterRun()
{
Console.WriteLine($"{ComConsts.NAME} is shutting down.");
} }
} }
protected override void AfterRun()
{
Console.WriteLine($"{ComConsts.NAME} is shutting down.");
}
} }

View file

@ -1,23 +1,20 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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;
using Tomas.Interface; using Tomas.Interface;
namespace Tomas.Kernel.Programs namespace Tomas.Kernel.Programs;
{
public class About : IProgram
{
public bool Run(IShell shell)
{
Console.WriteLine($"{ComConsts.NAME} v{ComConsts.VersionGit}{Environment.NewLine}"
+ "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework.");
var progs = shell.Programs;
foreach (var commands in progs.Keys)
Console.WriteLine(commands);
return true; public class About : IProgram
} {
public bool Run(IShell shell)
{
Console.WriteLine($"{ComConsts.NAME} v{ComConsts.VersionGit}{Environment.NewLine}"
+ "TOMAS (Tony's Managed Operating System) is a operating system written in C# using the COSMOS framework.");
var progs = shell.Programs;
foreach (var commands in progs.Keys)
Console.WriteLine(commands);
return true;
} }
} }

View file

@ -1,19 +1,17 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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 Tomas.Common.Programs; using Tomas.Common.Programs;
using Tomas.Interface; using Tomas.Interface;
using Tomas.Kernel.Programs; using Tomas.Kernel.Programs;
using Sys = Cosmos.System; using Sys = Cosmos.System;
namespace Tomas.Kernel namespace Tomas.Kernel;
{
public class Shell : IShell
{
const char SYMBOL = '$';
public Dictionary<string, IProgram> Programs => new Dictionary<string, IProgram>() public class Shell : IShell
{
const char SYMBOL = '$';
public Dictionary<string, IProgram> Programs => new Dictionary<string, IProgram>()
{ {
{"about", new About()}, {"about", new About()},
{"fensay", new FenSay()}, {"fensay", new FenSay()},
@ -21,14 +19,13 @@ namespace Tomas.Kernel
{"commands", new Commands()} {"commands", new Commands()}
}; };
public string ReadLine public string ReadLine
{
get
{ {
get Console.Write(SYMBOL);
{ var readl = Console.ReadLine();
Console.Write(SYMBOL); return readl;
var readl = Console.ReadLine();
return readl;
}
} }
} }
} }

View file

@ -1,51 +1,48 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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;
namespace Tomas.Kernel namespace Tomas.Kernel;
class TomFS
{ {
class TomFS public const string ROOT_DIR = "0:\\";
public static string SYSTEM_DIR = $"{ROOT_DIR}\\SYSTEM\\";
public static void Initialize()
{ {
public const string ROOT_DIR = "0:\\"; try
public static string SYSTEM_DIR = $"{ROOT_DIR}\\SYSTEM\\";
public static void Initialize()
{ {
try var fs = new CosmosVFS();
{ VFSManager.RegisterVFS(fs);
var fs = new CosmosVFS(); fs.CreateDirectory(SYSTEM_DIR);
VFSManager.RegisterVFS(fs); Console.WriteLine("Creating system files.");
fs.CreateDirectory(SYSTEM_DIR); fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine("Creating system files."); Console.WriteLine("Setting system preferences.");
fs.CreateFile($"{SYSTEM_DIR}sysinfo.txt"); File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{OSConsts.NAME}, {OSConsts.VersionGit}");
Console.WriteLine("Setting system preferences."); Console.WriteLine("File system loaded sucesfully.");
File.WriteAllText($"{SYSTEM_DIR}sysinfo.txt", $"{OSConsts.NAME}, {OSConsts.VersionGit}"); var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine("File system loaded sucesfully."); Console.WriteLine(intro);
var intro = File.ReadAllText($"{SYSTEM_DIR}sysinfo.txt");
Console.WriteLine(intro);
}
catch
{
Console.WriteLine("File system failed to load! Not all functions will work.");
}
} }
catch
public static string[] ListDirectories(string path)
{ {
try Console.WriteLine("File system failed to load! Not all functions will work.");
{ }
var dirs = Directory.GetDirectories(path); }
return dirs;
} public static string[] ListDirectories(string path)
catch {
{ try
Console.WriteLine("Failed to find any directories."); {
throw; var dirs = Directory.GetDirectories(path);
} return dirs;
}
catch
{
Console.WriteLine("Failed to find any directories.");
throw;
} }
} }
} }

View file

@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RuntimeIdentifier>cosmos</RuntimeIdentifier> <RuntimeIdentifier>cosmos</RuntimeIdentifier>
<SelfContained>True</SelfContained> <SelfContained>True</SelfContained>
<BinFormat>ELF</BinFormat> <BinFormat>ELF</BinFormat>

View file

@ -1,42 +1,34 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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.Terminal;
namespace Tomas.Terminal while (true)
{ {
class Program var shell = new Shell();
var command = shell.ReadLine;
var programs = shell.Programs;
if (!programs.TryGetValue(command, out var program))
{ {
static void Main() Console.WriteLine("Command Not Found.");
continue;
}
try
{
var start = program.Run(shell);
switch (start)
{ {
while (true) case true:
{ continue;
var shell = new Shell(); case false:
var command = shell.ReadLine; Console.WriteLine("Program closed unexpectedly.");
var programs = shell.Programs; continue;
if (!programs.TryGetValue(command, out var program))
{
Console.WriteLine("Command Not Found.");
continue;
}
try
{
var start = program.Run(shell);
switch (start)
{
case true:
continue;
case false:
Console.WriteLine("Program closed unexpectedly.");
continue;
}
}
catch (Exception err)
{
Console.WriteLine(err.Message);
}
}
} }
} }
catch (Exception err)
{
Console.WriteLine(err.Message);
}
} }

View file

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

View file

@ -1,33 +1,30 @@
// I license this project under the GPL 3.0 license. // I license this project under the GPL 3.0 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 Tomas.Common.Programs; using Tomas.Common.Programs;
using Tomas.Interface; using Tomas.Interface;
using Tomas.Terminal.Programs; using Tomas.Terminal.Programs;
namespace Tomas.Terminal namespace Tomas.Terminal;
public class Shell : IShell
{ {
public class Shell : IShell const char SYMBOL = '$';
public Dictionary<string, IProgram> Programs => new()
{ {
const char SYMBOL = '$'; { "about", new About() },
{ "fensay", new FenSay() },
{ "clear", new Clear() },
{ "commands", new Commands() }
};
public Dictionary<string, IProgram> Programs => new Dictionary<string, IProgram>() public string ReadLine
{
get
{ {
{"about", new About()}, Console.Write(SYMBOL);
{"fensay", new FenSay()}, var readl = Console.ReadLine();
{"clear", new Clear()}, return readl!;
{"commands", new Commands()}
};
public string ReadLine
{
get
{
Console.Write(SYMBOL);
var readl = Console.ReadLine();
return readl;
}
} }
} }
} }

View file

@ -2,9 +2,9 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<LangVersion>8</LangVersion> <Nullable>enable</Nullable>
<Nullable>warnings</Nullable> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>