System extensions

June 19, 2026 ยท View on GitHub

Extension methods for .NET types in FronkonGames.GameWork.Foundation. Import the namespace and call methods on the extended type.

See also: Unity extensions.


Collections and LINQ

ClassHighlights
ArrayExtensionsAppend, Remove, Shuffle, Sub, Random, FindClosestIndex, Exclude
ListExtensionsList helpers and mutations
IListExtensionsIList<T> utilities
EnumerableExtensionsBuffer, RollingWindow, TryPullFromDictionary, SelectWhere, Count
DictionaryExtensionsSelectDictionary, Normalize, SumTogether, RandomKey, GetKeysByValue
HashSetExtensionsSet operations
EnumeratorExtensionsToEnumerable
using FronkonGames.GameWork.Foundation;

int[][] chunks = playerIds.Buffer(size: 4).ToArray();

Dictionary<string, float> weights = lootTable.Normalize();

IEnumerable<int> values = keys.TryPullFromDictionary(keyList, lookup);

Primitives

ClassHighlights
IntExtensionsClamping, snapping, range checks
FloatExtensionsNearlyEquals, Snap, Remap, angle helpers
DoubleExtensionsIsBetween, ApproximatelyEquals, Normalize, ToRadians
LongExtensionsLong integer helpers
ByteExtensionsIsBitSet, SetBit, ToggleBit, ToBinaryString
ComparableExtensionsGeneric comparison helpers

Strings

StringExtensions, parsing, formatting, validation, and path helpers.

AreaMethods
ParsingToInt, ToFloat, ToVector2/3/4, ToColor, ToQuaternion, ToBoolean
ValidationIsValidIdentifier, IsValidEmail, IsValidLatinUsername
SubstringsGetSubstringBefore/After/BeforeLast/AfterLast
PathsToAbsolutePath, ToRelativePath, RemoveInvalidFileCharacters
EncodingToBase64, FromBase64, ToMD5, Compress, Decompress, Encrypt, Decrypt
FormattingCapitalized, ToCamelCase, ToTitleCase, ToWords, Similarity
Vector3 spawn = "1.0,2.0,3.0".ToVector3();

if (fieldName.IsValidIdentifier() == true)
  GenerateProperty(fieldName);

Enums

EnumExtensions, enum utilities and random selection (uses Rand).

  • GetValues<T>, ToInt, ToUInt, GetMaxValue
  • HasAnyFlag, HasNoneOfFlags
  • PickRandom<T>, PickWeighted<T>, PickBetween<T>, PickUpTo<T>
Difficulty diff = EnumExtensions.PickWeighted<Difficulty>(new[] { 0.6f, 0.3f, 0.1f });

Reflection and types

ClassHighlights
ReflectionExtensionsGetFieldAtPath, GetFieldRecursive, GetSerializedFields, HasAttribute<T>
TypeExtensionsIsUnitySerializable, IsSubclassOfRawGeneric, InheritsFrom, IsNullable, IsEmpty, GetShortAssemblyName
ObjectExtensionsGeneral object helpers
FieldInfo field = target.GetFieldAtPath("stats.health.max");
bool serializable = typeof(PlayerData).IsUnitySerializable();

Functional and objects

ClassHighlights
FunctionalExtensionsFunctional composition helpers
ActionExtensionsDelegate utilities
KeyValuePairExtensionsPair helpers

Async and cancellation

ClassHighlights
TaskExtensionsTask chaining and utilities
CancellationTokenSourceExtensionsCTS helpers

Disposables

DisposableExtensions, RAII-style cleanup via using statements.

MethodEffect
AsDisposable(Action)Wrap an action as IDisposable
DestroyOnDisposeDestroy Object or collections on dispose
EnableThenDisableTemporarily enable a GameObject
DisposeTemporaryTextureReturn a RenderTexture to the pool
DisposeAllDispose arrays or lists of IDisposable
using (gameObject.EnableThenDisable())
{
  preview.SetActive(true);
  BakeMesh();
}

Date and time

ClassHighlights
DateTimeExtensionsToUnixEpoch, ToUnixEpochMillis
TimeSpanExtensionsTimeSpan formatting and math

Tests

Unit tests live under Test/Extensions.