Add Ahead-of-time compiler confuser (AotHelper).

This commit is contained in:
Ca2didi 2024-06-23 23:23:36 +08:00
parent 9942e6d97f
commit f320b479ea
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,26 @@
using System;
namespace Ca2d.Toolkit
{
public static class AotHelper
{
private static DateTime alwayasFalseSource = DateTime.UtcNow;
/// <summary>
/// Utility to provide a must be false option for Ahead-of-time compiler.
/// </summary>
/// <returns>False</returns>
public static bool AlwaysFalseProvider()
{
return alwayasFalseSource.Year < 0;
}
/// <summary>
/// Create ahead-of-time info for compile while you can never successfully call given action at runtime.
/// </summary>
public static void Ensure(Action call)
{
if (AlwaysFalseProvider()) call?.Invoke();
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 880dab2141004ae2a8c6793e186f211d
timeCreated: 1719155856