seperate redux ui impl into FrontendCore project
This commit is contained in:
54
Il2CppInspector.Redux.FrontendCore/Extensions.cs
Normal file
54
Il2CppInspector.Redux.FrontendCore/Extensions.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Il2CppInspector.Redux.FrontendCore;
|
||||||
|
|
||||||
|
public static class Extensions
|
||||||
|
{
|
||||||
|
internal static bool GetAsBooleanOrDefault(this Dictionary<string, string> dict, string key, bool defaultValue)
|
||||||
|
{
|
||||||
|
if (dict.TryGetValue(key, out var value) && bool.TryParse(value, out var boolResult))
|
||||||
|
return boolResult;
|
||||||
|
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static T GetAsEnumOrDefault<T>(this Dictionary<string, string> dict, string key, T defaultValue)
|
||||||
|
where T : struct, Enum
|
||||||
|
{
|
||||||
|
if (dict.TryGetValue(key, out var value) && Enum.TryParse<T>(value, true, out var enumResult))
|
||||||
|
return enumResult;
|
||||||
|
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string? GetAssemblyVersion(this Assembly assembly)
|
||||||
|
=> assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
||||||
|
|
||||||
|
public static WebApplication MapFrontendCore(this WebApplication app)
|
||||||
|
{
|
||||||
|
app.MapHub<Il2CppHub>("/il2cpp");
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddFrontendCore(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddSignalR(config =>
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
config.EnableDetailedErrors = true;
|
||||||
|
#endif
|
||||||
|
});
|
||||||
|
|
||||||
|
return services.AddCors(options =>
|
||||||
|
{
|
||||||
|
options.AddDefaultPolicy(policy =>
|
||||||
|
{
|
||||||
|
policy.SetIsOriginAllowed(origin =>
|
||||||
|
origin.StartsWith("http://localhost") || origin.StartsWith("http://tauri.localhost"))
|
||||||
|
.AllowAnyHeader()
|
||||||
|
.WithMethods("GET", "POST")
|
||||||
|
.AllowCredentials();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI;
|
namespace Il2CppInspector.Redux.FrontendCore;
|
||||||
|
|
||||||
[JsonSerializable(typeof(string))]
|
[JsonSerializable(typeof(string))]
|
||||||
[JsonSerializable(typeof(List<string>))]
|
[JsonSerializable(typeof(List<string>))]
|
||||||
[JsonSerializable(typeof(Dictionary<string, string>))]
|
[JsonSerializable(typeof(Dictionary<string, string>))]
|
||||||
internal partial class AppJsonSerializerContext : JsonSerializerContext;
|
public partial class FrontendCoreJsonSerializerContext : JsonSerializerContext;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI;
|
namespace Il2CppInspector.Redux.FrontendCore;
|
||||||
|
|
||||||
internal class Il2CppHub : Hub
|
internal class Il2CppHub : Hub
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Bin2Object\Bin2Object\Bin2Object.csproj" />
|
||||||
|
<ProjectReference Include="..\Il2CppInspector.Common\Il2CppInspector.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Il2CppInspector.Redux.GUI;
|
namespace Il2CppInspector.Redux.FrontendCore;
|
||||||
|
|
||||||
public class LoadingSession : IAsyncDisposable
|
public class LoadingSession : IAsyncDisposable
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Il2CppInspector.Model;
|
using Il2CppInspector.Model;
|
||||||
using Il2CppInspector.Outputs;
|
using Il2CppInspector.Outputs;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI.Outputs;
|
namespace Il2CppInspector.Redux.FrontendCore.Outputs;
|
||||||
|
|
||||||
public class CSharpStubOutput : IOutputFormatProvider
|
public class CSharpStubOutput : IOutputFormatProvider
|
||||||
{
|
{
|
||||||
@@ -3,7 +3,7 @@ using Il2CppInspector.Cpp.UnityHeaders;
|
|||||||
using Il2CppInspector.Model;
|
using Il2CppInspector.Model;
|
||||||
using Il2CppInspector.Outputs;
|
using Il2CppInspector.Outputs;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI.Outputs;
|
namespace Il2CppInspector.Redux.FrontendCore.Outputs;
|
||||||
|
|
||||||
public class CppScaffoldingOutput : IOutputFormatProvider
|
public class CppScaffoldingOutput : IOutputFormatProvider
|
||||||
{
|
{
|
||||||
@@ -3,7 +3,7 @@ using Il2CppInspector.Cpp.UnityHeaders;
|
|||||||
using Il2CppInspector.Model;
|
using Il2CppInspector.Model;
|
||||||
using Il2CppInspector.Outputs;
|
using Il2CppInspector.Outputs;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI.Outputs;
|
namespace Il2CppInspector.Redux.FrontendCore.Outputs;
|
||||||
|
|
||||||
public class DisassemblerMetadataOutput : IOutputFormatProvider
|
public class DisassemblerMetadataOutput : IOutputFormatProvider
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Il2CppInspector.Model;
|
using Il2CppInspector.Model;
|
||||||
using Il2CppInspector.Outputs;
|
using Il2CppInspector.Outputs;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI.Outputs;
|
namespace Il2CppInspector.Redux.FrontendCore.Outputs;
|
||||||
|
|
||||||
public class DummyDllOutput : IOutputFormatProvider
|
public class DummyDllOutput : IOutputFormatProvider
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Il2CppInspector.Model;
|
using Il2CppInspector.Model;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI.Outputs;
|
namespace Il2CppInspector.Redux.FrontendCore.Outputs;
|
||||||
|
|
||||||
public interface IOutputFormat
|
public interface IOutputFormat
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Il2CppInspector.Redux.GUI.Outputs;
|
namespace Il2CppInspector.Redux.FrontendCore.Outputs;
|
||||||
|
|
||||||
public static class OutputFormatRegistry
|
public static class OutputFormatRegistry
|
||||||
{
|
{
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Il2CppInspector.Model;
|
using Il2CppInspector.Model;
|
||||||
using Il2CppInspector.Outputs;
|
using Il2CppInspector.Outputs;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI.Outputs;
|
namespace Il2CppInspector.Redux.FrontendCore.Outputs;
|
||||||
|
|
||||||
public class VsSolutionOutput : IOutputFormatProvider
|
public class VsSolutionOutput : IOutputFormatProvider
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Il2CppInspector.Redux.GUI;
|
namespace Il2CppInspector.Redux.FrontendCore;
|
||||||
|
|
||||||
public static class PathHeuristics
|
public static class PathHeuristics
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Il2CppInspector.Redux.FrontendCore": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": false,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"applicationUrl": "https://localhost:43298;http://localhost:43299"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI;
|
namespace Il2CppInspector.Redux.FrontendCore;
|
||||||
|
|
||||||
public class UiClient(ISingleClientProxy client)
|
public class UiClient(ISingleClientProxy client)
|
||||||
{
|
{
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Il2CppInspector.Cpp.UnityHeaders;
|
using Il2CppInspector.Cpp.UnityHeaders;
|
||||||
using Il2CppInspector.Model;
|
using Il2CppInspector.Model;
|
||||||
using Il2CppInspector.Redux.GUI.Outputs;
|
using Il2CppInspector.Redux.FrontendCore.Outputs;
|
||||||
using Il2CppInspector.Reflection;
|
using Il2CppInspector.Reflection;
|
||||||
using Inspector = Il2CppInspector.Il2CppInspector;
|
using Inspector = Il2CppInspector.Il2CppInspector;
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI;
|
namespace Il2CppInspector.Redux.FrontendCore;
|
||||||
|
|
||||||
public class UiContext
|
public class UiContext
|
||||||
{
|
{
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace Il2CppInspector.Redux.GUI;
|
|
||||||
|
|
||||||
public static class Extensions
|
|
||||||
{
|
|
||||||
public static bool GetAsBooleanOrDefault(this Dictionary<string, string> dict, string key, bool defaultValue)
|
|
||||||
{
|
|
||||||
if (dict.TryGetValue(key, out var value) && bool.TryParse(value, out var boolResult))
|
|
||||||
return boolResult;
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T GetAsEnumOrDefault<T>(this Dictionary<string, string> dict, string key, T defaultValue)
|
|
||||||
where T : struct, Enum
|
|
||||||
{
|
|
||||||
if (dict.TryGetValue(key, out var value) && Enum.TryParse<T>(value, true, out var enumResult))
|
|
||||||
return enumResult;
|
|
||||||
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string? GetAssemblyVersion(this Assembly assembly)
|
|
||||||
=> assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
|
||||||
}
|
|
||||||
@@ -11,11 +11,6 @@
|
|||||||
<PublishSingleFile>true</PublishSingleFile>
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Bin2Object\Bin2Object\Bin2Object.csproj" />
|
|
||||||
<ProjectReference Include="..\Il2CppInspector.Common\Il2CppInspector.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<!-- todo: this needs to be adjusted for multiplatform support -->
|
<!-- todo: this needs to be adjusted for multiplatform support -->
|
||||||
<Target Name="BuildTauriFrontend" BeforeTargets="BeforeBuild" Condition="'$(Configuration)' == 'Release'">
|
<Target Name="BuildTauriFrontend" BeforeTargets="BeforeBuild" Condition="'$(Configuration)' == 'Release'">
|
||||||
<Exec Command="pnpm tauri build --no-bundle" WorkingDirectory="..\Il2CppInspector.Redux.GUI.UI" />
|
<Exec Command="pnpm tauri build --no-bundle" WorkingDirectory="..\Il2CppInspector.Redux.GUI.UI" />
|
||||||
@@ -23,5 +18,8 @@
|
|||||||
<EmbeddedResource Include="..\Il2CppInspector.Redux.GUI.UI\src-tauri\target\release\il2cppinspectorredux.exe" />
|
<EmbeddedResource Include="..\Il2CppInspector.Redux.GUI.UI\src-tauri\target\release\il2cppinspectorredux.exe" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Il2CppInspector.Redux.FrontendCore\Il2CppInspector.Redux.FrontendCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Il2CppInspector.Redux.FrontendCore;
|
||||||
using Il2CppInspector.Redux.GUI;
|
using Il2CppInspector.Redux.GUI;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
@@ -5,40 +6,23 @@ var builder = WebApplication.CreateSlimBuilder(args);
|
|||||||
|
|
||||||
builder.Services.ConfigureHttpJsonOptions(options =>
|
builder.Services.ConfigureHttpJsonOptions(options =>
|
||||||
{
|
{
|
||||||
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
|
options.SerializerOptions.TypeInfoResolverChain.Insert(0, FrontendCoreJsonSerializerContext.Default);
|
||||||
});
|
|
||||||
|
|
||||||
builder.Services.AddSignalR(config =>
|
|
||||||
{
|
|
||||||
#if DEBUG
|
|
||||||
config.EnableDetailedErrors = true;
|
|
||||||
#endif
|
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.Configure<JsonHubProtocolOptions>(options =>
|
builder.Services.Configure<JsonHubProtocolOptions>(options =>
|
||||||
{
|
{
|
||||||
options.PayloadSerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
|
options.PayloadSerializerOptions.TypeInfoResolverChain.Insert(0, FrontendCoreJsonSerializerContext.Default);
|
||||||
});
|
|
||||||
|
|
||||||
builder.Services.AddCors(options =>
|
|
||||||
{
|
|
||||||
options.AddDefaultPolicy(policy =>
|
|
||||||
{
|
|
||||||
policy.SetIsOriginAllowed(origin => origin.StartsWith("http://localhost") || origin.StartsWith("http://tauri.localhost"))
|
|
||||||
.AllowAnyHeader()
|
|
||||||
.WithMethods("GET", "POST")
|
|
||||||
.AllowCredentials();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.AddFrontendCore();
|
||||||
builder.Services.AddSingleton<UiProcessService>();
|
builder.Services.AddSingleton<UiProcessService>();
|
||||||
builder.Services.AddSingleton<IHostedService>(p => p.GetRequiredService<UiProcessService>());
|
builder.Services.AddHostedService(p => p.GetRequiredService<UiProcessService>());
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
app.UseCors();
|
app.UseCors();
|
||||||
|
|
||||||
app.MapHub<Il2CppHub>("/il2cpp");
|
app.MapFrontendCore();
|
||||||
|
|
||||||
await app.StartAsync();
|
await app.StartAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public class UiProcessService(IHostApplicationLifetime lifetime) : BackgroundSer
|
|||||||
using var executable =
|
using var executable =
|
||||||
typeof(UiProcessService).Assembly.GetManifestResourceStream(
|
typeof(UiProcessService).Assembly.GetManifestResourceStream(
|
||||||
$"{typeof(UiProcessService).Namespace!}.{UiExecutableName}");
|
$"{typeof(UiProcessService).Namespace!}.{UiExecutableName}");
|
||||||
|
|
||||||
if (executable == null)
|
if (executable == null)
|
||||||
throw new FileNotFoundException("Failed to open resource as stream.");
|
throw new FileNotFoundException("Failed to open resource as stream.");
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VersionedSerialization.Gene
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Il2CppInspector.Redux.GUI", "Il2CppInspector.Redux.GUI\Il2CppInspector.Redux.GUI.csproj", "{CB6CE40B-0805-49B1-82DD-4CAAE58F9D6E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Il2CppInspector.Redux.GUI", "Il2CppInspector.Redux.GUI\Il2CppInspector.Redux.GUI.csproj", "{CB6CE40B-0805-49B1-82DD-4CAAE58F9D6E}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Il2CppInspector.Redux.FrontendCore", "Il2CppInspector.Redux.FrontendCore\Il2CppInspector.Redux.FrontendCore.csproj", "{D80D0FCE-4C9C-4BF1-8936-71DFB0B2D86A}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -82,6 +84,10 @@ Global
|
|||||||
{CB6CE40B-0805-49B1-82DD-4CAAE58F9D6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{CB6CE40B-0805-49B1-82DD-4CAAE58F9D6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{CB6CE40B-0805-49B1-82DD-4CAAE58F9D6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{CB6CE40B-0805-49B1-82DD-4CAAE58F9D6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{CB6CE40B-0805-49B1-82DD-4CAAE58F9D6E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{CB6CE40B-0805-49B1-82DD-4CAAE58F9D6E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D80D0FCE-4C9C-4BF1-8936-71DFB0B2D86A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D80D0FCE-4C9C-4BF1-8936-71DFB0B2D86A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D80D0FCE-4C9C-4BF1-8936-71DFB0B2D86A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D80D0FCE-4C9C-4BF1-8936-71DFB0B2D86A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user