Add dotnet-utils submodule

This commit is contained in:
2025-01-22 09:00:05 -03:00
parent 06f60eec10
commit 269b07ee4e
17 changed files with 8 additions and 265 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "vendor/dotnet-utils"]
path = vendor/dotnet-utils
url = https://github.com/tribufu/dotnet-utils

View File

@ -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

View File

@ -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<T> : 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);
}
}
}

View File

@ -1 +0,0 @@
# Tribufu

View File

@ -1,16 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.ComponentModel</PackageId>
<Description>Tribufu Component Model Helpers</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>

View File

@ -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<decimal>
{
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());
}
}
}

View File

@ -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<ulong>
{
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());
}
}
}

View File

@ -1 +0,0 @@
# Tribufu

View File

@ -1,19 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.Serialization.Newtonsoft</PackageId>
<Description>Tribufu Serialization Helpers for Newtonsoft.Json</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworks>netstandard2.0;net45;net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>
</Project>

View File

@ -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<decimal>
{
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());
}
}
}

View File

@ -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<ulong>
{
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());
}
}
}

View File

@ -1 +0,0 @@
# Tribufu

View File

@ -1,16 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.Serialization</PackageId>
<Description>Tribufu Serialization Helpers</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworks>net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>

View File

@ -1 +0,0 @@
# Tribufu

View File

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>Tribufu.Utils</PackageId>
<Description>Tribufu Utils</Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFrameworks>net5.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
</Project>

View File

@ -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");
}
}
}

1
vendor/dotnet-utils vendored Submodule

Submodule vendor/dotnet-utils added at 04d72716ef