Skip to content

Commit

Permalink
Write RuntimeFeatures at launch
Browse files Browse the repository at this point in the history
Diagnostics yiddy yadda
  • Loading branch information
bagusnl committed Oct 27, 2024
1 parent 433b5bf commit f5b6b5b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
1 change: 0 additions & 1 deletion CollapseLauncher/CollapseLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
<!-- DO NOT FORGET TO UPDATE THE DEFINECONSTANTS IN THE PUBLISH PROFILE(S) AS WELL -->
<DefineConstants>DISABLE_XAML_GENERATED_MAIN;USEVELOPACK;USENEWZIPDECOMPRESS;ENABLEHTTPREPAIR;DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION;PREVIEW;DUMPGIJSON;SIMULATEGIHDR;GSPBYPASSGAMERUNNING;MHYPLUGINSUPPORT</DefineConstants>
<TrimMode>full</TrimMode>
<PublishAot>true</PublishAot>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<!-- !! IMPORTANT !!-->
Expand Down
29 changes: 27 additions & 2 deletions CollapseLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
using Velopack;
#endif
using System;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using WinRT;
using static CollapseLauncher.ArgumentParser;
using static CollapseLauncher.InnerLauncherConfig;
Expand Down Expand Up @@ -130,6 +132,7 @@ public static void Main(params string[] args)
}

_ = Helper.Database.DbHandler.Init();
CheckRuntimeFeatures();

AppDomain.CurrentDomain.ProcessExit += OnProcessExit!;

Expand Down Expand Up @@ -319,15 +322,15 @@ public static void TryCleanupFallbackUpdate(SemanticVersion newVersion)
}
catch (Exception ex)
{
Logger.LogWriteLine($"[TryCleanupFallbackUpdate] Failed while operating clean-up routines...\r\n{ex}");
LogWriteLine($"[TryCleanupFallbackUpdate] Failed while operating clean-up routines...\r\n{ex}");
}

void RemoveSquirrelFilePath(string filePath)
{
if (File.Exists(filePath))
{
File.Delete(filePath);
Logger.LogWriteLine($"[TryCleanupFallbackUpdate] Removed old squirrel executables: {filePath}!", LogType.Default, true);
LogWriteLine($"[TryCleanupFallbackUpdate] Removed old squirrel executables: {filePath}!", LogType.Default, true);
}
}
}
Expand All @@ -349,6 +352,28 @@ public static string FindCollapseStubPath()
LogType.Default, true);
return collapseMainPath;
}

private static async void CheckRuntimeFeatures()
{
try
{
await Task.Run(() =>
{
// RuntimeFeature docs https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.runtimefeature?view=net-9.0
LogWriteLine($"Available Runtime Features:\r\n\t" +
$"PortablePdb: {RuntimeFeature.IsSupported(RuntimeFeature.PortablePdb)}\r\n\t" +
$"IsDynamicCodeCompiled: {RuntimeFeature.IsDynamicCodeCompiled}\r\n\t" +
$"IsDynamicCodeSupported: {RuntimeFeature.IsDynamicCodeSupported}\r\n\t" +
$"UnmanagedSignatureCallingConventions: {RuntimeFeature.IsSupported(RuntimeFeature.UnmanagedSignatureCallingConvention)}",
LogType.Debug, true);
}
);
}
catch (Exception ex)
{
LogWriteLine($"[CheckRuntimeFeatures] Failed when enumerating available runtime features!\r\n{ex}", LogType.Error, true);
}
}

private static void InitializeAppSettings()
{
Expand Down

0 comments on commit f5b6b5b

Please sign in to comment.