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

View File

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

View File

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

View File

@ -1,22 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6.0;net48;netstandard2.0</TargetFrameworks> <!--package info-->
<LangVersion>10</LangVersion> <PackageId>DTLib.Logging</PackageId>
<ImplicitUsings>disable</ImplicitUsings> <Version>1.0.0</Version>
<Nullable>disable</Nullable> <Authors>Timerix</Authors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <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> <DebugType>embedded</DebugType>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <!--language features-->
<Configurations>Debug;Release</Configurations> <LangVersion>10</LangVersion>
<Platforms>AnyCPU;x64;x86;arm64</Platforms> <Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<!--external dependencies-->
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DTLib\DTLib.csproj" /> <!--DTLib dependencies-->
<ProjectReference Include="..\DTLib.Ben.Demystifier\DTLib.Ben.Demystifier.csproj" /> <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> </ItemGroup>
</Project> </Project>

View File

@ -1,25 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6.0;net48;netstandard2.0</TargetFrameworks> <!--package info-->
<LangVersion>preview</LangVersion> <PackageId>DTLib.Network</PackageId>
<ImplicitUsings>disable</ImplicitUsings> <Version>1.0.0</Version>
<Nullable>disable</Nullable> <Authors>Timerix</Authors>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <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> <DebugType>embedded</DebugType>
<Configurations>Debug;Release;Release-net48</Configurations> <!--language features-->
<Platforms>AnyCPU;x64;x86;arm64</Platforms> <LangVersion>10</LangVersion>
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <!--external dependencies-->
<ProjectReference Include="..\DTLib.Dtsod\DTLib.Dtsod.csproj" />
<ProjectReference Include="..\DTLib\DTLib.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' "> <ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="System.Net" /> <Reference Include="System.Net" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
</ItemGroup> </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> </Project>

View File

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

View File

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

View File

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

View File

@ -1,26 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6.0;net48;netstandard2.0</TargetFrameworks> <!--package info-->
<LangVersion>preview</LangVersion> <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> <ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
<AssemblyName>DTLib</AssemblyName>
<!--xxhash uses arithmetic overflow-->
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>embedded</DebugType>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU;x64;x86;arm64</Platforms>
</PropertyGroup> </PropertyGroup>
<!--external dependencies-->
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' "> <ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="System.Net" /> <Reference Include="System.Net" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Dynamic" /> <Reference Include="System.Dynamic" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
</ItemGroup> </ItemGroup>
<!--project files-->
<ItemGroup Condition=" '$(Configuration)' != 'Debug' "> <ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<Compile Remove="Experimental\**" /> <Compile Remove="Experimental\**" />
</ItemGroup> </ItemGroup>

View File

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