Skip to content

Instantly share code, notes, and snippets.

View akeit0's full-sized avatar

akeit0 akeit0

  • Tokyo
  • 00:58 (UTC +09:00)
View GitHub Profile
using System;
using System.Runtime.CompilerServices;
public static class Program {
public unsafe static void Main() {
var array=new int[1000];
var c=new C();
var header=Unsafe.Subtract(ref c.Field,2);
var typeHandle=Unsafe.Subtract(ref c.Field,1);
var data=new CData(){Header=header,Handle=typeHandle,Field=4ul};
var dataPtr=&data.Handle;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if UNITY_EDITOR
using Mono.Cecil;
using Mono.Cecil.Cil;
public static class ByRefGen {
public static void RemoveByRefType(string src, string dst) {
ModuleDefinition moduleDefinition = AssemblyDefinition.ReadAssembly(src).MainModule;
@akeit0
akeit0 / NewHelper.cs
Created December 1, 2023 08:37
Fast new T() for Unity Mono/IL2CPP (Full generic sharing available version is recommended)
#if UNITY_EDITOR
#define EDITOR
#endif
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace ReflectionUtils {
public delegate void RefDelegate(ref byte t);
public delegate void StructConstructorDelegate<T,in TArg0>(ref T t,TArg0 arg0);
using System;
using SharpLab.Runtime;
using System.Runtime.CompilerServices;
object boxedManagedData=new ManagedData("");
object boxedUnManagedData=new UnManagedData(1);
unsafe {
Inspect.Heap(boxedManagedData);
var p=Unsafe.AsPointer(ref ManagedData.StaticData);
foreach(var b in BitConverter.GetBytes(((ulong*)p)[-1])){
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
PArray<int> pArray=[1,2,3,4];
pArray[1..3]=[0,0];
/*
SharpLab tools in Run mode:
• value.Inspect()
• Inspect.Heap(object)
• Inspect.Stack(value)
• Inspect.MemoryGraph(value1, value2, …)
*/
using System;
using System.Collections;
using System.Linq;
@akeit0
akeit0 / DefaultInterpolatedStringHandler.NonGeneric.cs
Last active August 10, 2024 05:12
DefaultInterpolatedStringHandler for .netstandard2.1
namespace System.Runtime.CompilerServices
{
public ref partial struct DefaultInterpolatedStringHandler
{
public void AppendFormatted(float value)=> AppendFormatted(value, null);
public void AppendFormatted(int value)=> AppendFormatted(value, null);
public void AppendFormatted(double value)=> AppendFormatted(value, null);
@akeit0
akeit0 / DefaultInterpolatedStringHandler.cs
Last active November 1, 2025 10:05
DefaultInterpolatedStringHandler for .netstandard2.1
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#nullable enable
using System.Buffers;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
namespace System.Runtime.CompilerServices
@akeit0
akeit0 / UnityConsoleRedirect.cs
Created August 10, 2024 08:30
ConsoleRedirect
//License
//These codes are licensed under CC0.
using System.IO;
using System.Text;
using UnityEngine;
static class ConsoleRedirect
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
static void ConsoleInit()
@akeit0
akeit0 / RomajiReader.cs
Last active August 15, 2024 00:22
RomajiReader Windowsの入力はおそらく全対応
//These codes are licensed under CC0.
using System;
using System.Collections.Generic;
//using RomajiReader;
// var reader = Reader.Default;
// Console.WriteLine(reader.Convert("shinkyoku"));//しゅんきょく
// Console.WriteLine(reader.Convert("kappa"));//かっぱ
// Console.WriteLine(reader.Convert("cinkya"));//しんきゃ
// Console.WriteLine(reader.Convert("rweqqap"));//rうぇっくぁp
// Console.WriteLine(reader.Convert("RWEQQAP"));//RうぇっくぁP