From 269b07ee4e7db3e3b752092bacca1ed8950a40d9 Mon Sep 17 00:00:00 2001 From: Guilherme Werner Date: Wed, 22 Jan 2025 09:00:05 -0300 Subject: [PATCH] Add dotnet-utils submodule --- .gitmodules | 3 + Tribufu.sln => Tribufu.Sdk.sln | 8 +-- .../EnumMemberConverter.cs | 30 -------- src/Tribufu.ComponentModel/README.md | 1 - .../Tribufu.ComponentModel.csproj | 16 ----- .../DecimalStringConverter.cs | 21 ------ .../LongStringConverter.cs | 21 ------ .../README.md | 1 - .../Tribufu.Serialization.Newtonsoft.csproj | 19 ----- .../DecimalStringConverter.cs | 22 ------ .../LongStringConverter.cs | 22 ------ src/Tribufu.Serialization/README.md | 1 - .../Tribufu.Serialization.csproj | 16 ----- src/Tribufu.Utils/README.md | 1 - src/Tribufu.Utils/Tribufu.Utils.csproj | 18 ----- src/Tribufu.Utils/TribufuAppContext.cs | 72 ------------------- vendor/dotnet-utils | 1 + 17 files changed, 8 insertions(+), 265 deletions(-) create mode 100644 .gitmodules rename Tribufu.sln => Tribufu.Sdk.sln (84%) delete mode 100644 src/Tribufu.ComponentModel/EnumMemberConverter.cs delete mode 100644 src/Tribufu.ComponentModel/README.md delete mode 100644 src/Tribufu.ComponentModel/Tribufu.ComponentModel.csproj delete mode 100644 src/Tribufu.Serialization.Newtonsoft/DecimalStringConverter.cs delete mode 100644 src/Tribufu.Serialization.Newtonsoft/LongStringConverter.cs delete mode 100644 src/Tribufu.Serialization.Newtonsoft/README.md delete mode 100644 src/Tribufu.Serialization.Newtonsoft/Tribufu.Serialization.Newtonsoft.csproj delete mode 100644 src/Tribufu.Serialization/DecimalStringConverter.cs delete mode 100644 src/Tribufu.Serialization/LongStringConverter.cs delete mode 100644 src/Tribufu.Serialization/README.md delete mode 100644 src/Tribufu.Serialization/Tribufu.Serialization.csproj delete mode 100644 src/Tribufu.Utils/README.md delete mode 100644 src/Tribufu.Utils/Tribufu.Utils.csproj delete mode 100644 src/Tribufu.Utils/TribufuAppContext.cs create mode 160000 vendor/dotnet-utils diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f131e31 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/dotnet-utils"] + path = vendor/dotnet-utils + url = https://github.com/tribufu/dotnet-utils diff --git a/Tribufu.sln b/Tribufu.Sdk.sln similarity index 84% rename from Tribufu.sln rename to Tribufu.Sdk.sln index 997c7df..1f89370 100644 --- a/Tribufu.sln +++ b/Tribufu.Sdk.sln @@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Native", "src\Tribufu.Native\Tribufu.Native.csproj", "{C66D6B57-324D-EAF2-3B65-75C9A7C35054}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Serialization", "src\Tribufu.Serialization\Tribufu.Serialization.csproj", "{322FE36B-9E9B-9E66-678F-36C4D3BAC0CE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Serialization", "vendor\dotnet-utils\src\Tribufu.Serialization\Tribufu.Serialization.csproj", "{322FE36B-9E9B-9E66-678F-36C4D3BAC0CE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Serialization.Newtonsoft", "src\Tribufu.Serialization.Newtonsoft\Tribufu.Serialization.Newtonsoft.csproj", "{B7019B7B-A352-86BD-CCB6-747FB8661927}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Serialization.Newtonsoft", "vendor\dotnet-utils\src\Tribufu.Serialization.Newtonsoft\Tribufu.Serialization.Newtonsoft.csproj", "{B7019B7B-A352-86BD-CCB6-747FB8661927}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu", "src\Tribufu\Tribufu.csproj", "{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Utils", "src\Tribufu.Utils\Tribufu.Utils.csproj", "{8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Utils", "vendor\dotnet-utils\src\Tribufu.Utils\Tribufu.Utils.csproj", "{8F16FBBB-199E-4EE3-BFF3-31DD6F84DCD0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.ComponentModel", "src\Tribufu.ComponentModel\Tribufu.ComponentModel.csproj", "{3DFBC35E-62A7-4CB0-81D9-5E7AA1882557}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.ComponentModel", "vendor\dotnet-utils\src\Tribufu.ComponentModel\Tribufu.ComponentModel.csproj", "{3DFBC35E-62A7-4CB0-81D9-5E7AA1882557}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Tribufu.ComponentModel/EnumMemberConverter.cs b/src/Tribufu.ComponentModel/EnumMemberConverter.cs deleted file mode 100644 index 38d62e3..0000000 --- a/src/Tribufu.ComponentModel/EnumMemberConverter.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -using System; -using System.ComponentModel; -using System.Globalization; -using System.Runtime.Serialization; - -namespace Tribufu.ComponentModel -{ - public class EnumMemberConverter : EnumConverter - { - public EnumMemberConverter(Type type) : base(type) { } - - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - var type = typeof(T); - - foreach (var field in type.GetFields()) - { - if (Attribute.GetCustomAttribute(field, typeof(EnumMemberAttribute)) is EnumMemberAttribute attribute && value is string enumValue && attribute.Value == enumValue) - { - return field.GetValue(null); - } - } - - return base.ConvertFrom(context, culture, value); - } - } -} diff --git a/src/Tribufu.ComponentModel/README.md b/src/Tribufu.ComponentModel/README.md deleted file mode 100644 index 54c1ab5..0000000 --- a/src/Tribufu.ComponentModel/README.md +++ /dev/null @@ -1 +0,0 @@ -# Tribufu diff --git a/src/Tribufu.ComponentModel/Tribufu.ComponentModel.csproj b/src/Tribufu.ComponentModel/Tribufu.ComponentModel.csproj deleted file mode 100644 index c2368b5..0000000 --- a/src/Tribufu.ComponentModel/Tribufu.ComponentModel.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - Tribufu.ComponentModel - Tribufu Component Model Helpers - README.md - - - Library - Properties - netstandard2.0;net45;net5.0 - true - - - - - diff --git a/src/Tribufu.Serialization.Newtonsoft/DecimalStringConverter.cs b/src/Tribufu.Serialization.Newtonsoft/DecimalStringConverter.cs deleted file mode 100644 index ba22445..0000000 --- a/src/Tribufu.Serialization.Newtonsoft/DecimalStringConverter.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -using System; -using Newtonsoft.Json; - -namespace Tribufu.Serialization.Newtonsoft -{ - public class DecimalStringConverter : JsonConverter - { - public override decimal ReadJson(JsonReader reader, Type objectType, decimal existingValue, bool hasExistingValue, JsonSerializer serializer) - { - return decimal.Parse(reader.ToString()); - } - - public override void WriteJson(JsonWriter writer, decimal value, JsonSerializer serializer) - { - writer.WriteValue(value.ToString()); - } - } -} diff --git a/src/Tribufu.Serialization.Newtonsoft/LongStringConverter.cs b/src/Tribufu.Serialization.Newtonsoft/LongStringConverter.cs deleted file mode 100644 index 417af47..0000000 --- a/src/Tribufu.Serialization.Newtonsoft/LongStringConverter.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -using System; -using Newtonsoft.Json; - -namespace Tribufu.Serialization.Newtonsoft -{ - public class LongStringConverter : JsonConverter - { - public override ulong ReadJson(JsonReader reader, Type objectType, ulong existingValue, bool hasExistingValue, JsonSerializer serializer) - { - return ulong.Parse(reader.ToString()); - } - - public override void WriteJson(JsonWriter writer, ulong value, JsonSerializer serializer) - { - writer.WriteValue(value.ToString()); - } - } -} diff --git a/src/Tribufu.Serialization.Newtonsoft/README.md b/src/Tribufu.Serialization.Newtonsoft/README.md deleted file mode 100644 index 54c1ab5..0000000 --- a/src/Tribufu.Serialization.Newtonsoft/README.md +++ /dev/null @@ -1 +0,0 @@ -# Tribufu diff --git a/src/Tribufu.Serialization.Newtonsoft/Tribufu.Serialization.Newtonsoft.csproj b/src/Tribufu.Serialization.Newtonsoft/Tribufu.Serialization.Newtonsoft.csproj deleted file mode 100644 index 0d33420..0000000 --- a/src/Tribufu.Serialization.Newtonsoft/Tribufu.Serialization.Newtonsoft.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - Tribufu.Serialization.Newtonsoft - Tribufu Serialization Helpers for Newtonsoft.Json - README.md - - - Library - Properties - netstandard2.0;net45;net5.0 - true - - - - - - - - diff --git a/src/Tribufu.Serialization/DecimalStringConverter.cs b/src/Tribufu.Serialization/DecimalStringConverter.cs deleted file mode 100644 index d610ae5..0000000 --- a/src/Tribufu.Serialization/DecimalStringConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Tribufu.Serialization -{ - public class DecimalStringConverter : JsonConverter - { - public override decimal Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - return Convert.ToUInt64(reader.GetString()); - } - - public override void Write(Utf8JsonWriter writer, decimal value, JsonSerializerOptions options) - { - writer.WriteStringValue(value.ToString()); - } - } -} diff --git a/src/Tribufu.Serialization/LongStringConverter.cs b/src/Tribufu.Serialization/LongStringConverter.cs deleted file mode 100644 index e7f335a..0000000 --- a/src/Tribufu.Serialization/LongStringConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Tribufu.Serialization -{ - public class LongStringConverter : JsonConverter - { - public override ulong Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - return Convert.ToUInt64(reader.GetString()); - } - - public override void Write(Utf8JsonWriter writer, ulong value, JsonSerializerOptions options) - { - writer.WriteStringValue(value.ToString()); - } - } -} diff --git a/src/Tribufu.Serialization/README.md b/src/Tribufu.Serialization/README.md deleted file mode 100644 index 54c1ab5..0000000 --- a/src/Tribufu.Serialization/README.md +++ /dev/null @@ -1 +0,0 @@ -# Tribufu diff --git a/src/Tribufu.Serialization/Tribufu.Serialization.csproj b/src/Tribufu.Serialization/Tribufu.Serialization.csproj deleted file mode 100644 index 8efd520..0000000 --- a/src/Tribufu.Serialization/Tribufu.Serialization.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - Tribufu.Serialization - Tribufu Serialization Helpers - README.md - - - Library - Properties - net5.0 - true - - - - - diff --git a/src/Tribufu.Utils/README.md b/src/Tribufu.Utils/README.md deleted file mode 100644 index 54c1ab5..0000000 --- a/src/Tribufu.Utils/README.md +++ /dev/null @@ -1 +0,0 @@ -# Tribufu diff --git a/src/Tribufu.Utils/Tribufu.Utils.csproj b/src/Tribufu.Utils/Tribufu.Utils.csproj deleted file mode 100644 index 026c17d..0000000 --- a/src/Tribufu.Utils/Tribufu.Utils.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - Tribufu.Utils - Tribufu Utils - README.md - - - Library - Properties - net5.0 - true - - - - - - - diff --git a/src/Tribufu.Utils/TribufuAppContext.cs b/src/Tribufu.Utils/TribufuAppContext.cs deleted file mode 100644 index 1939059..0000000 --- a/src/Tribufu.Utils/TribufuAppContext.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Tribufu. All Rights Reserved. -// SPDX-License-Identifier: MIT - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Tribufu.Utils -{ - public static class TribufuAppContext - { - public static string GetBaseDirectory() - { - string defaultBaseDirectory = AppContext.BaseDirectory; - string baseDirectory; - - if (defaultBaseDirectory.Contains("Debug") || defaultBaseDirectory.Contains("Release")) - { - baseDirectory = Path.Combine(defaultBaseDirectory, "..", "..", "..", "..", ".."); - } - else - { - baseDirectory = Path.Combine(defaultBaseDirectory, "..", ".."); - } - - baseDirectory = Path.GetFullPath(baseDirectory); - - return baseDirectory; - } - - public static string GetBinDirectory() - { - var binDirectory = Path.Combine(GetBaseDirectory(), "bin"); - - if (!string.IsNullOrEmpty(RuntimeInformation.RuntimeIdentifier)) - { - binDirectory = Path.Combine(binDirectory, RuntimeInformation.RuntimeIdentifier); - } - else - { - binDirectory = Path.Combine(binDirectory, "dotnet"); - } - - return binDirectory; - } - - public static string GetConfigDirectory() - { - return Path.Combine(GetBaseDirectory(), "config"); - } - - public static string GetAssetsDirectory() - { - return Path.Combine(GetBaseDirectory(), "assets"); - } - - public static string GetSavedDirectory() - { - return Path.Combine(GetBaseDirectory(), "saved"); - } - - public static string GetCacheDirectory() - { - return Path.Combine(GetSavedDirectory(), "cache"); - } - - public static string GetLogsDirectory() - { - return Path.Combine(GetSavedDirectory(), "logs"); - } - } -} diff --git a/vendor/dotnet-utils b/vendor/dotnet-utils new file mode 160000 index 0000000..04d7271 --- /dev/null +++ b/vendor/dotnet-utils @@ -0,0 +1 @@ +Subproject commit 04d72716ef79a22bd678dc75b6c7cd92233b128c