This commit is contained in:
Timerix22 2022-12-06 17:19:44 +06:00
parent 276aae2ff6
commit 869bb1dea2
13 changed files with 180 additions and 106 deletions

2
.gitignore vendored
View File

@ -8,6 +8,7 @@
[Oo]ut/
[Ll]og/
[Ll]ogs/
nuget/
# IDE files
.vs/
@ -16,6 +17,7 @@
.idea/
.editorconfig
*.user
*.DotSettings
#backups
.old*/

View File

@ -1,44 +1,48 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net48;netstandard2.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<!--package info-->
<PackageId>DTLib.Dtsod</PackageId>
<Version>1.0.0</Version>
<Authors>Timerix</Authors>
<Description>Definitely not json</Description>
<RepositoryType>GIT</RepositoryType>
<RepositoryUrl>https://github.com/Timerix22/DTLib</RepositoryUrl>
<Configuration>Release</Configuration>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!--compilation properties-->
<TargetFrameworks>net6.0;netstandard2.0;net48</TargetFrameworks>
<DebugType>embedded</DebugType>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU;x64;x86;arm64</Platforms>
<!--language features-->
<LangVersion>10</LangVersion>
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<!--external dependencies-->
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="System.Dynamic" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<!--DTLib dependencies-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<Compile Remove="V30\**" />
<PackageReference Include="DTLib" Version="1.0.0" />
</ItemGroup>
<!--project files-->
<ItemGroup>
<None Update="Dependencies\**\*">
<Content Include="runtimes\**\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInPackage>true</IncludeInPackage>
</None>
<Compile Remove="Experimental/**/*"/>
<None Include="Experimental/**/*"/>
<Pack>true</Pack>
<PackagePath>runtimes/</PackagePath>
</Content>
<Compile Remove="Experimental/**/*" />
<None Include="Experimental/**/*" />
</ItemGroup>
<ItemGroup>
<Folder Include="Experimental" />
</ItemGroup>
</Project>

View File

@ -12,7 +12,7 @@ public static class DtsodConverter
DtsodVersion.V23 => new DtsodV23(src.ToDictionary()),
DtsodVersion.V24 => new DtsodV24(src.ToDictionary()),
#if DEBUG
DtsodVersion.V30 => new DtsodV30(src.ToDictionary()),
//DtsodVersion.V30 => new DtsodV30(src.ToDictionary()),
#endif
_ => throw new Exception($"DtsodConverter.Convert() error: unknown target version <{targetVersion}>"),
};

View File

@ -1,22 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net48;netstandard2.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!--package info-->
<PackageId>DTLib.Logging</PackageId>
<Version>1.0.0</Version>
<Authors>Timerix</Authors>
<Description>Loggers with dependency injection</Description>
<RepositoryType>GIT</RepositoryType>
<RepositoryUrl>https://github.com/Timerix22/DTLib</RepositoryUrl>
<Configuration>Release</Configuration>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!--compilation properties-->
<TargetFrameworks>net6.0;netstandard2.0;net48</TargetFrameworks>
<DebugType>embedded</DebugType>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU;x64;x86;arm64</Platforms>
<!--language features-->
<LangVersion>10</LangVersion>
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
<!--external dependencies-->
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DTLib\DTLib.csproj" />
<ProjectReference Include="..\DTLib.Ben.Demystifier\DTLib.Ben.Demystifier.csproj" />
<!--DTLib dependencies-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<ProjectReference Include="..\DTLib\DTLib.csproj" />
<ProjectReference Include="..\DTLib.Ben.Demystifier\DTLib.Ben.Demystifier.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib" Version="1.0.0"/>
<PackageReference Include="DTLib.Ben.Demystifier" Version="1.0.0"/>
</ItemGroup>
</Project>

View File

@ -1,25 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net48;netstandard2.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<!--package info-->
<PackageId>DTLib.Network</PackageId>
<Version>1.0.0</Version>
<Authors>Timerix</Authors>
<Description>Some sick network protocols</Description>
<RepositoryType>GIT</RepositoryType>
<RepositoryUrl>https://github.com/Timerix22/DTLib</RepositoryUrl>
<Configuration>Release</Configuration>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!--compilation properties-->
<TargetFrameworks>net6.0;netstandard2.0;net48</TargetFrameworks>
<DebugType>embedded</DebugType>
<Configurations>Debug;Release;Release-net48</Configurations>
<Platforms>AnyCPU;x64;x86;arm64</Platforms>
<!--language features-->
<LangVersion>10</LangVersion>
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DTLib.Dtsod\DTLib.Dtsod.csproj" />
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<!--external dependencies-->
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<!--DTLib dependencies-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<ProjectReference Include="..\DTLib\DTLib.csproj" />
<ProjectReference Include="..\DTLib.Dtsod\DTLib.Dtsod.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib.Dtsod" Version="1.0.0"/>
</ItemGroup>
</Project>

View File

@ -1,18 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!--compilation properties-->
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net48;netstandard2.0</TargetFrameworks>
<LangVersion>10</LangVersion>
<ImplicitUsings>false</ImplicitUsings>
<Nullable>disable</Nullable>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<TargetFrameworks>net6.0;netstandard2.0;net48</TargetFrameworks>
<DebugType>embedded</DebugType>
<Configurations>Debug;Release;Release-net48</Configurations>
<Platforms>AnyCPU;x64;x86;arm64</Platforms>
<!--language features-->
<LangVersion>10</LangVersion>
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<!--external dependencies-->
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
@ -20,15 +19,20 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<!--DTLib dependencies-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<ProjectReference Include="..\DTLib.Logging\DTLib.Logging.csproj" />
<ProjectReference Include="..\DTLib.Network\DTLib.Network.csproj" />
<ProjectReference Include="..\DTLib.Dtsod\DTLib.Dtsod.csproj" />
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Dtsod\TestResources\**\*" CopyToOutputDirectory="Always" />
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib.Network" Version="1.0.0"/>
<PackageReference Include="DTLib.Logging" Version="1.0.0"/>
</ItemGroup>
<!--project files-->
<ItemGroup>
<None Update="Dtsod\TestResources\**\*" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>

View File

@ -14,7 +14,7 @@ public static class TestPInvoke
TestMarshalling();
}
static public void TestUTF8()
public static void TestUTF8()
{
OldLogger.Log("c", "--------[TestPInvoke/TestUTF8]--------", "b", "");
IntPtr ptr;

View File

@ -21,6 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
.gitmodules = .gitmodules
LICENSE = LICENSE
nuget.config = nuget.config
pack.sh = pack.sh
EndProjectSection
EndProject
Global

View File

@ -1,19 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net48;netstandard2.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
<!--package info-->
<PackageId>DTLib</PackageId>
<Version>1.0.0</Version>
<Authors>Timerix</Authors>
<Description>Library for all my C# projects</Description>
<RepositoryType>GIT</RepositoryType>
<RepositoryUrl>https://github.com/Timerix22/DTLib</RepositoryUrl>
<Configuration>Release</Configuration>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!--compilation properties-->
<TargetFrameworks>net6.0;netstandard2.0;net48</TargetFrameworks>
<!--Platforms>AnyCPU;x64;x86;arm64</Platforms-->
<!--Configurations>Debug;Release</Configurations-->
<DebugType>embedded</DebugType>
<!--language features-->
<LangVersion>10</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<AssemblyName>DTLib</AssemblyName>
<!--xxhash uses arithmetic overflow-->
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>embedded</DebugType>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU;x64;x86;arm64</Platforms>
</PropertyGroup>
<!--external dependencies-->
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
@ -21,6 +30,7 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<!--project files-->
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<Compile Remove="Experimental\**" />
</ItemGroup>

View File

@ -1,36 +1,52 @@
using System.Runtime.InteropServices;
using System.Threading;
namespace DTLib;
public static class DependencyResolver
{
private static bool DepsCopied=false;
private static object locker = new object();
private static bool DepsCopied = false;
public static void CopyLibs()
{
if(DepsCopied) return;
string depsdir = $"Dependencies{Path.Sep}";
depsdir += Environment.OSVersion.Platform switch
lock (locker)
{
PlatformID.Unix => "linux",
PlatformID.Win32NT => "windows",
_=> throw new Exception($"unsupported os {Environment.OSVersion.Platform}")
};
depsdir += Path.Sep;
depsdir += RuntimeInformation.ProcessArchitecture switch
{
Architecture.X64 => "x64",
Architecture.X86 => "x86",
Architecture.Arm64 => "arm64",
Architecture.Arm => "arm",
_=> throw new Exception($"unsupported platform {RuntimeInformation.ProcessArchitecture}")
};
foreach (var file in Directory.GetAllFiles(depsdir))
{
var extracted = file.Substring(file.LastIndexOf(Path.Sep) + 1);
File.Copy(file,extracted, true);
Log("g",$"{extracted} copied");
if (DepsCopied) return;
var os = Environment.OSVersion.Platform switch
{
PlatformID.Unix => "linux",
PlatformID.Win32NT => "win",
_ => throw new Exception($"unsupported os {Environment.OSVersion.Platform}")
};
var arch = RuntimeInformation.ProcessArchitecture switch
{
Architecture.X64 => "x64",
Architecture.X86 => "x86",
Architecture.Arm64 => "arm64",
Architecture.Arm => "arm",
_ => throw new Exception($"unsupported platform {RuntimeInformation.ProcessArchitecture}")
};
string[] possibleLibDirs =
{
Path.Concat("runtimes", $"{os}"),
Path.Concat("runtimes", $"{os}", "native"),
Path.Concat("runtimes", $"{os}-{arch}"),
Path.Concat("runtimes", $"{os}-{arch}", "native")
};
foreach (string dir in possibleLibDirs)
if (Directory.Exists(dir))
foreach (var file in Directory.GetFiles(dir))
{
var extracted = file.Substring(file.LastIndexOf(Path.Sep) + 1);
File.Copy(file, extracted, true);
Log("g", $"{file} extracted");
}
DepsCopied = true;
}
DepsCopied = true;
}
}

6
nuget.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="DTLib local" value="./nuget/" />
</packageSources>
</configuration>

6
pack.sh Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/bash
set -ex
rm -rf nuget
dotnet pack -o ./nuget/
rm ./nuget/DTLib.Tests.*
ls nuget