Skip to content

Instantly share code, notes, and snippets.

View safern's full-sized avatar
🤑
Focusing

Santiago Fernandez Madero safern

🤑
Focusing
View GitHub Profile
@safern
safern / repro.cs
Created November 18, 2021 04:19
RoundImageDrawing
// See https://aka.ms/new-console-template for more information
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
string imageBase64 = "iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAScSURBVGhD1Zp7qBVVFIdvZdlbK7ESisogzUiTBKm/CsRCMqMgkswHSmGBGoKSIj6QyvSPSHpgQglikYFGYhQFGYpEopgFPlJE1MjsaWkv7fvGWXQ4zpw7l+7xbH/wcc5es+fMntl7r73WntOWkLrkn2ecLoOLT37Nvm+Gb+BuDWeKHoffYT8Mhk/gRM7fMA3OgqQ1C6LRcjz/PAAL4K+8/A5cAElqEthIn/pEWJGX5TlQQ+AwaPsMukNSuhf+AXtgtAbk8HkWam9G202wL7dtgSshCV0L8ZSna6jTBIgh9RacD9fBrty2DS6FlmsV2KB3oWwS22O/gPUcUlfAnXlZ7oKW6lawIT9CTw0NdBvoyay/Hb7Kv78HZ0NL9SjYmGPwgIZ2dA1sBc+Rr+ESaLnOgTfBRumtxkB76gYfgecchbHQcjknXoF4wnqtqdCefAB6sTjvNTgPWqZozBF4FWIBnAdVpKu2VzznCxgIp11OdNcOXWt4HYdJuNpFUCUUGQR7wXMcnvaOc+m0yR7w4suy0n8aAX+Cx17UUEGuIy+DD8bzdB7+votnU+V4jkXwdg11egR8uh6fraGibgHXpbghP52DTdP94IW+zErFGgcxZ6Zo6ID6QMRqP2lolj6EKg3Ug1lPHHIdkb/teUYMTZFDySf9M7gmlMmJbiPiR
@safern
safern / ApiCompatBenchmarks.cs
Last active April 28, 2021 22:49
Api compat benchmarks (optimizing for multiple rights for the same left)
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Microsoft.CodeAnalysis;
using Microsoft.DotNet.ApiCompatibility;
using Microsoft.DotNet.ApiCompatibility.Abstractions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace apicompatbenchmarks
@safern
safern / how-to-debug-dump.md
Created March 5, 2021 21:04
How to debug dump multiple dumps

Get the Helix payload

Runfo helps get information about helix test runs and azure devops builds. We will use it to download the payload and symbols (recommended version 0.6.4 or later):

dotnet tool install --global runfo
dotnet tool update --global runfo

If prompted, open a new command prompt to pick up the updated PATH.

# On Windows
@safern
safern / QuarantinedFactDemo.cs
Last active January 14, 2021 21:57
Custom xunit fact attribute to skip quarantined tests
namespace XunitExtensions
{
public class QuarantineDiscoverer : IXunitTestCaseDiscoverer
{
public QuarantineDiscoverer(IMessageSink diagnosticMessageSink)
{
DiagnosticMessageSink = diagnosticMessageSink;
}
public IMessageSink DiagnosticMessageSink { get; }
@safern
safern / AssemblyLoader.cs
Created August 29, 2020 05:46
APICompat Loader with Roslyn
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
@safern
safern / GenAPINullability.md
Created May 3, 2019 01:07
This samples the input and output of GenAPI after adding nullability support

INPUT

namespace tmp
{
    public class Program
    {
        public delegate string? SampleEventHandler(object? sender, string e);
        public event SampleEventHandler? Event;
        public string?[] A1()
        {
@safern
safern / PriorityQueue.cs
Last active September 22, 2020 17:19
PriorityQueue api surface
namespace System.Collections.Generic
{
class PriorityQueue<T> : ICollection<T>
{
#region Constructors
public PriorityQueue() { }
public PriorityQueue(IComparer<T> comparer) { }
public PriorityQueue(IEnumerable<T> items) { }
public PriorityQueue(IEnumerable<T> items, IComparer<T> comparer) { }
#endregion