mirror of
https://github.com/Cardidi/ca2d-unity-toolkit.git
synced 2025-12-20 01:06:03 +08:00
Add Ahead-of-time compiler confuser (AotHelper).
This commit is contained in:
parent
9942e6d97f
commit
f320b479ea
26
Assets/Toolkit/Toolkit/Scripts/AotHelper.cs
Normal file
26
Assets/Toolkit/Toolkit/Scripts/AotHelper.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Toolkit/Toolkit/Scripts/AotHelper.cs.meta
Normal file
3
Assets/Toolkit/Toolkit/Scripts/AotHelper.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 880dab2141004ae2a8c6793e186f211d
|
||||
timeCreated: 1719155856
|
||||
Loading…
x
Reference in New Issue
Block a user