Skip to content

Instantly share code, notes, and snippets.

@TIHan
TIHan / scoped_closure_experiment.cs
Created January 25, 2024 19:28
scoped closure?
using System.Runtime.CompilerServices;
namespace ConsoleApp2
{
internal unsafe class Program
{
class A
{
public int X = 123;
public object o = new object();
@TIHan
TIHan / unsafe_finder.cs
Created November 17, 2023 21:26
Simple tool that uses roslyn to gather information regarding unsafe usage
using System.IO;
using System.Runtime.Intrinsics;
using System.Collections.Concurrent;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
using System.Diagnostics;
using System.Text.Json.Serialization;
using System.Text.Json;
@TIHan
TIHan / asmdiffs1.md
Created November 16, 2022 21:54
asmdiffs1

Diffs are based on 1,350,756 contexts (345,093 MinOpts, 1,005,663 FullOpts).

MISSED contexts: base: 32,380, diff: 32,380

Overall (-6,265 bytes)
Collection Base size (bytes) Diff size (bytes)
@TIHan
TIHan / gist:50701d8d8ae801a008d63f99c9745623
Created November 10, 2022 20:46
Before Dump on IsBuffering
****** START compiling B:get_IsBuffering():bool:this (MethodHash=30e43e07)
Generating code for Windows x64
OPTIONS: compCodeOpt = BLENDED_CODE
OPTIONS: compDbgCode = false
OPTIONS: compDbgInfo = true
OPTIONS: compDbgEnC = false
OPTIONS: compProcedureSplitting = false
OPTIONS: compProcedureSplittingEH = false
OPTIONS: No PGO data
IL to import:
@TIHan
TIHan / gist:172948e61df0bdfdd33fc025a7b0b686
Last active November 10, 2022 20:38
Dump for IsBuffering
****** START compiling B:get_IsBuffering():bool:this (MethodHash=30e43e07)
Generating code for Windows x64
OPTIONS: compCodeOpt = BLENDED_CODE
OPTIONS: compDbgCode = false
OPTIONS: compDbgInfo = true
OPTIONS: compDbgEnC = false
OPTIONS: compProcedureSplitting = false
OPTIONS: compProcedureSplittingEH = false
OPTIONS: No PGO data
IL to import:
@TIHan
TIHan / SuperFileCheck.cs
Last active August 30, 2022 21:23
SuperFileCheck - wrapper around LLVM FileCheck that allows writing .NET Core JIT tests easier in C#
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System.Text;
@TIHan
TIHan / AsyncLazy.fs
Created May 28, 2021 21:08
Port of Roslyn's AsyncLazy in F#
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
module internal rec FSharp.Compiler.AsyncLazy
// This is a port of AsyncLazy from Roslyn.
open System
open System.Threading
open System.Threading.Tasks
open System.Diagnostics

WIP F# 5.x Proposal Main Theme - Struct, ByRef, and Span updates

Language

  • Implicit conversion to inref<_> on method calls
  • Static local functions via static let
  • Local functions can have a byref-like parameter type
  • Unmanaged constraint relaxation
  • Add implicit conversion of types to Span / ReadOnlySpan on method calls. - needs proposal
  • Function pointer (delegate pointer) support - needs proposal - needed to support native and C# interop - might require FSharp.Core additions
@TIHan
TIHan / lexer.fs
Created January 24, 2020 23:52
Lexer Api
module Lexer =
open System.Threading
open FSharp.Compiler.UnicodeLexing
open FSharp.Compiler.Range
open FSharp.Compiler.Ast
open FSharp.Compiler.Text
open FSharp.Compiler.Features
open FSharp.Compiler.Parser
open FSharp.Compiler.Lexhelp
@TIHan
TIHan / process.fs
Created November 11, 2018 04:52
F# Process - Kill Child when Parent Dies
/// https://stackoverflow.com/questions/3342941/kill-child-process-when-parent-process-is-killed
module WindowsHelpers =
open System.Runtime.InteropServices
open FSharp.NativeInterop
type JobObjectInfoType =
| AssociateCompletionPortInformation = 7
| BasicLimitInformation = 2
| BasicUIRestrictions = 4
| EndOfJobTimeInformation = 6