Moved the valve parsers to their own library.

This commit is contained in:
That_One_Nerd 2023-05-09 19:55:13 -04:00
parent 856811687e
commit 3c0c3068a4
42 changed files with 390 additions and 31 deletions

1
.gitignore vendored
View File

@ -1,7 +1,6 @@
# Visual Studio stuff
.vs/
SrcMod/.vs/
*.sln
# Compiled Files
SrcMod/Compiled

View File

@ -7,7 +7,6 @@ global using SrcMod.Shell.Extensions;
global using SrcMod.Shell.Interop;
global using SrcMod.Shell.Modules.ObjectModels;
global using SrcMod.Shell.ObjectModels;
global using SrcMod.Shell.Valve;
global using System;
global using System.Collections;
global using System.Collections.Generic;
@ -21,4 +20,5 @@ global using System.Reflection;
global using System.Runtime.InteropServices;
global using System.Text;
global using System.Threading;
global using Valve.Vkv;
global using static SrcMod.Shell.Tools;

View File

@ -16,16 +16,6 @@
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
<WarningLevel>9999</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
<WarningLevel>9999</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Content Include="Logo.ico" />
</ItemGroup>
@ -36,4 +26,8 @@
<PackageReference Include="SharpCompress" Version="0.33.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Valve.NET\Valve.NET.csproj" />
</ItemGroup>
</Project>

View File

@ -1,8 +0,0 @@
using SrcMod.Shell.Valve.Vkv;
namespace SrcMod.Shell.Valve.Vkv.ObjectModels;
public interface IVkvConvertible
{
public VkvNode ToNodeTree();
}

View File

@ -1,3 +0,0 @@
namespace SrcMod.Shell.Valve.Vkv;
public abstract class VkvNode { }

31
SrcMod/SrcMod.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shell", "Shell\Shell.csproj", "{6EC87235-F2A5-4313-A6DE-A4EE7CB7B341}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Valve.NET", "Valve.NET\Valve.NET.csproj", "{8FC96202-2F7E-4FBE-B08E-FCC38AA62D96}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6EC87235-F2A5-4313-A6DE-A4EE7CB7B341}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6EC87235-F2A5-4313-A6DE-A4EE7CB7B341}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EC87235-F2A5-4313-A6DE-A4EE7CB7B341}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EC87235-F2A5-4313-A6DE-A4EE7CB7B341}.Release|Any CPU.Build.0 = Release|Any CPU
{8FC96202-2F7E-4FBE-B08E-FCC38AA62D96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8FC96202-2F7E-4FBE-B08E-FCC38AA62D96}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8FC96202-2F7E-4FBE-B08E-FCC38AA62D96}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8FC96202-2F7E-4FBE-B08E-FCC38AA62D96}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4E25AC28-DD70-4BB6-9083-07D6371DECCF}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,16 @@
global using System;
global using System.Collections;
global using System.Collections.Generic;
global using System.ComponentModel;
global using System.Diagnostics;
global using System.Formats.Tar;
global using System.IO;
global using System.IO.Compression;
global using System.Linq;
global using System.Reflection;
global using System.Runtime.InteropServices;
global using System.Text;
global using System.Threading;
global using Valve;
global using Valve.Miscellaneous;
global using Valve.Vkv;

View File

@ -0,0 +1,39 @@
namespace Valve.Miscellaneous;
internal static class TypeParsers
{
public static bool CanParse(object? obj) => obj is not null && obj is sbyte or byte or short or ushort or int
or uint or long or ulong or Int128 or UInt128 or nint or nuint or Half or float or double or decimal
or char or DateOnly or DateTime or DateTimeOffset or Guid or TimeOnly or TimeSpan;
public static object ParseAll(string msg)
{
if (TryParse(msg, out sbyte int8)) return int8;
if (TryParse(msg, out byte uInt8)) return uInt8;
if (TryParse(msg, out short int16)) return int16;
if (TryParse(msg, out ushort uInt16)) return uInt16;
if (TryParse(msg, out int int32)) return int32;
if (TryParse(msg, out uint uInt32)) return uInt32;
if (TryParse(msg, out long int64)) return int64;
if (TryParse(msg, out ulong uInt64)) return uInt64;
if (TryParse(msg, out Int128 int128)) return int128;
if (TryParse(msg, out UInt128 uInt128)) return uInt128;
if (TryParse(msg, out nint intPtr)) return intPtr;
if (TryParse(msg, out nuint uIntPtr)) return uIntPtr;
if (TryParse(msg, out Half float16)) return float16;
if (TryParse(msg, out float float32)) return float32;
if (TryParse(msg, out double float64)) return float64;
if (TryParse(msg, out decimal float128)) return float128;
if (TryParse(msg, out char resChar)) return resChar;
if (TryParse(msg, out DateOnly dateOnly)) return dateOnly;
if (TryParse(msg, out DateTime dateTime)) return dateTime;
if (TryParse(msg, out DateTimeOffset dateTimeOffset)) return dateTimeOffset;
if (TryParse(msg, out Guid guid)) return guid;
if (TryParse(msg, out TimeOnly timeOnly)) return timeOnly;
if (TryParse(msg, out TimeSpan timeSpan)) return timeSpan;
return msg;
}
public static bool TryParse<T>(string msg, out T? result) where T : IParsable<T>
=> T.TryParse(msg, null, out result);
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>valve.net</AssemblyName>
<RootNamespace>Valve</RootNamespace>
<OutputPath>../Compiled/Valve.NET</OutputPath>
<Title>Valve.NET</Title>
<Authors>That_One_Nerd</Authors>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,6 @@
namespace Valve.Vkv.ObjectModels;
public interface IVkvConvertible
{
public VkvNode ToNodeTree();
}

View File

@ -1,4 +1,4 @@
namespace SrcMod.Shell.Valve.Vkv.ObjectModels;
namespace Valve.Vkv.ObjectModels;
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class VkvIgnoreAttribute : Attribute { }

View File

@ -1,4 +1,4 @@
namespace SrcMod.Shell.Valve.Vkv.ObjectModels;
namespace Valve.Vkv.ObjectModels;
public class VkvSerializationException : Exception
{

View File

@ -1,6 +1,6 @@
using SrcMod.Shell.Valve.Vkv.ObjectModels;
using Valve.Vkv.ObjectModels;
namespace SrcMod.Shell.Valve.Vkv;
namespace Valve.Vkv;
public static class VkvConvert
{

View File

@ -0,0 +1,3 @@
namespace Valve.Vkv;
public abstract class VkvNode { }

View File

@ -1,4 +1,4 @@
namespace SrcMod.Shell.Valve.Vkv;
namespace Valve.Vkv;
public record class VkvOptions
{

View File

@ -1,4 +1,4 @@
namespace SrcMod.Shell.Valve.Vkv;
namespace Valve.Vkv;
public class VkvSerializer
{

View File

@ -1,4 +1,4 @@
namespace SrcMod.Shell.Valve.Vkv;
namespace Valve.Vkv;
public class VkvSingleNode : VkvNode
{

View File

@ -1,4 +1,4 @@
namespace SrcMod.Shell.Valve.Vkv;
namespace Valve.Vkv;
public class VkvTreeNode : VkvNode, IEnumerable<KeyValuePair<string, VkvNode?>>
{

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]

View File

@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("That_One_Nerd")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("valve.net")]
[assembly: System.Reflection.AssemblyTitleAttribute("valve.net")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -0,0 +1 @@
8384044beff55be9a171a490a3f710f4f9552cee

View File

@ -0,0 +1,11 @@
is_global = true
build_property.TargetFramework = net7.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Valve
build_property.ProjectDir = C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\

Binary file not shown.

View File

@ -0,0 +1 @@
78977cdcf4d04d878ec8161bd57fe5f8f0d3f8af

View File

@ -0,0 +1,12 @@
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\obj\Debug\Valve.NET.csproj.AssemblyReference.cache
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\obj\Debug\Valve.NET.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\obj\Debug\Valve.NET.AssemblyInfoInputs.cache
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\obj\Debug\Valve.NET.AssemblyInfo.cs
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\obj\Debug\Valve.NET.csproj.CoreCompileInputs.cache
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Compiled\Valve.NET\valve.net.deps.json
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Compiled\Valve.NET\valve.net.dll
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Compiled\Valve.NET\valve.net.pdb
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\obj\Debug\valve.net.dll
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\obj\Debug\refint\valve.net.dll
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\obj\Debug\valve.net.pdb
C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\obj\Debug\ref\valve.net.dll

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v7.0", FrameworkDisplayName = ".NET 7.0")]

View File

@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Valve.NET")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Valve.NET")]
[assembly: System.Reflection.AssemblyTitleAttribute("Valve.NET")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -0,0 +1 @@
ebac0703b803bca2e82867dfb1a594d2351f56a0

View File

@ -0,0 +1,11 @@
is_global = true
build_property.TargetFramework = net7.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = Valve.NET
build_property.ProjectDir = C:\Users\kyley\Desktop\GitHub\SrcMod\SrcMod\Valve.NET\

View File

@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,67 @@
{
"format": 1,
"restore": {
"C:\\Users\\kyley\\Desktop\\GitHub\\SrcMod\\SrcMod\\Valve.NET\\Valve.NET.csproj": {}
},
"projects": {
"C:\\Users\\kyley\\Desktop\\GitHub\\SrcMod\\SrcMod\\Valve.NET\\Valve.NET.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\kyley\\Desktop\\GitHub\\SrcMod\\SrcMod\\Valve.NET\\Valve.NET.csproj",
"projectName": "valve.net",
"projectPath": "C:\\Users\\kyley\\Desktop\\GitHub\\SrcMod\\SrcMod\\Valve.NET\\Valve.NET.csproj",
"packagesPath": "C:\\Users\\kyley\\.nuget\\packages\\",
"outputPath": "C:\\Users\\kyley\\Desktop\\GitHub\\SrcMod\\SrcMod\\Valve.NET\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\kyley\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.102\\RuntimeIdentifierGraph.json"
}
}
}
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\kyley\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.4.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\kyley\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

View File

@ -0,0 +1,73 @@
{
"version": 3,
"targets": {
"net7.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
"net7.0": []
},
"packageFolders": {
"C:\\Users\\kyley\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\kyley\\Desktop\\GitHub\\SrcMod\\SrcMod\\Valve.NET\\Valve.NET.csproj",
"projectName": "valve.net",
"projectPath": "C:\\Users\\kyley\\Desktop\\GitHub\\SrcMod\\SrcMod\\Valve.NET\\Valve.NET.csproj",
"packagesPath": "C:\\Users\\kyley\\.nuget\\packages\\",
"outputPath": "C:\\Users\\kyley\\Desktop\\GitHub\\SrcMod\\SrcMod\\Valve.NET\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\kyley\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net7.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net7.0": {
"targetAlias": "net7.0",
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.102\\RuntimeIdentifierGraph.json"
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"version": 2,
"dgSpecHash": "VNCH38jqwFWTxqqhzzVLR2Jf7UiV9/z5LUDVmpzOUafOLLW71x935fAZ5UA8qi4cycxqviPPFxSNjR5kf0EesQ==",
"success": true,
"projectFilePath": "C:\\Users\\kyley\\Desktop\\GitHub\\SrcMod\\SrcMod\\Valve.NET\\Valve.NET.csproj",
"expectedPackageFiles": [],
"logs": []
}