Skip to content

Instantly share code, notes, and snippets.

[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.5.6+bf9b858c26 (64-bit .NET 8.0.26)
[xUnit.net 00:00:00.09] Discovering: SixLabors.ImageSharp.Tests (method display = Method, method display options = None)
[xUnit.net 00:00:02.23] Discovered: SixLabors.ImageSharp.Tests (found 1452 test cases)
[xUnit.net 00:00:02.23] Starting: SixLabors.ImageSharp.Tests (parallel test collections = on [16 threads], stop on fail = off)
[xUnit.net 00:00:11.59] CreateRegion_NestedRegionsAndStateIsolation_MatchesDefaultOutput<Rgba32>(provider: Solid320x220_(255,255,255,255)[Rgba32]) [FAIL]
[xUnit.net 00:00:11.59] SixLabors.ImageSharp.Drawing.Tests.TestUtilities.ImageComparison.ImageDifferenceIsOverThresholdException : Image difference is over threshold!
[xUnit.net 00:00:11.59] Report ImageFrame 0:
[xUnit.net 00:00:11.59] Total difference: 0.0004%
[xUnit.net 00:00:11.59] [Δ(-257,-257,-257,0) @ (300,20)];
[xUnit.net 00:00:11.59] [Δ(0,-257,0,0) @ (57,26)];
<html xmlns:tp="http://schemas.datacontract.org/2004/07/Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger.ObjectModel" xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<body>
<h1>Test run details</h1>
<div class="summary">
<div class="block"><span>Total tests</span><div class="total-tests">1452</div><br></div>
<div class="block"><span>Passed  : </span><span class="passedTests">1424</span><br><span>Failed  : </span><span class="failedTests">19</span><br><span>Skipped : </span><span class="skippedTests">9</span><br></div>
<div class="block"><span>Pass percentage</span><div class="pass-percentage">98 %</div><br></div>
<div class="block"><span>Run duration</span><div class="test-run-time">20s 765ms</div><br></div><br></div>
<h2>Failed Results</h2><details open=""><summary>C:\dev\ImageSharp.Drawing\artifacts\bin\tests\ImageSharp.Drawing.Tests\Release\net8.0\SixLabors.ImageSharp.Tests.dll</summary><div cla
@antonfirsov
antonfirsov / LoadPreservedPixelType.cs
Created March 26, 2026 16:13
LoadPreservedPixelType
static Image LoadPreservePixelType(string path)
{
var info = Image.Identify(path);
var format = info.Metadata.DecodedImageFormat;
// PNG: PngColorType fully describes the pixel layout including alpha
if (format is PngFormat) return LoadPng(path, info);
// BMP, TGA: native channel order is BGR/BGRA
if (format is BmpFormat) return LoadBmp(path, info);
@antonfirsov
antonfirsov / day11_backtrack.rs
Last active December 16, 2025 23:27
Advent of Code 2025 day11: nonrecursive DFS, skipping parsing and other boilerplate
// struct Node {
// descendants: Vec<usize>,
// }
// struct Graph {
// nodes: Vec<Node>,
// }
struct Backtrack<'g> {
g: &'g Graph,
current_path: Vec<usize>,
@antonfirsov
antonfirsov / Program.cs
Last active July 3, 2025 20:59
Replace Dangerous Characters Benchmark
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Buffers;
using System.Text;
BenchmarkRunner.Run<HeaderDecoder>();
public class HeaderDecoder
{
private static readonly SearchValues<char> s_dangerousCharacters = SearchValues.Create('\0', '\r', '\n');
@antonfirsov
antonfirsov / command.cmd
Last active June 17, 2025 19:06
Benchmark-runtime-PR-116319
crank --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/build/ci.profile.yml --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/grpc.benchmarks.yml --scenario grpcaspnetcoreserver-grpcnetclient --profile intel-lin-app --profile intel-load-load --variable scenario=serverstreaming --variable requestSize=0 --variable responseSize=0 --variable streams=70 --variable connections=20 --variable threads=20 --variable protocol=h3 --application.framework net9.0 --load.framework net10.0 --load.options.outputFiles <reporoot>\artifacts\bin\System.Net.Http\Release\net10.0-linux\System.Net.Http.dll
@antonfirsov
antonfirsov / Program.cs
Last active February 21, 2025 18:00
HttpHandlerDiagnosticListener duplicate event repro
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Net;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
class Program
{
@antonfirsov
antonfirsov / SocketOptionMappingGenerator.cs
Last active February 5, 2025 17:36
SocketOptionMappingGenerator
using System.Net.Sockets;
using System.Text;
// Relevant option names and values taken from Windows headers.
(string Name, int Value)[] ipOptions = [
("IP_TOS", 3),
("IP_TTL", 4),
];
(string Name, int Value)[] ipv6Options = [
@antonfirsov
antonfirsov / MemoryTrackingAllocatorDemo.cs
Created October 30, 2024 02:28
MemoryTrackingAllocator
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Memory;
using System.Buffers;
using System.Runtime.CompilerServices;
if (!File.Exists("./img.jpg"))
{
using HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("User-Agent", "Markus Moller's super cool bot");
Console.WriteLine("Downloading image...");
@antonfirsov
antonfirsov / HttpClient-Telemetry-Breaking.MD
Created October 1, 2024 12:49
Telemetry Breaking changes

[Breaking Change]: HttpTelemetry Redacts Query Strings by Default Description: In .NET 9, the default behavior of HttpTelemetry (EventSource "System.Net.Http") has been modified to redact query strings. This change is aimed at enhancing security by preventing the logging of potentially sensitive information contained in query strings. The same opt-out mechanism used for distributed tracing (Activity) and HttpClientFactory logging is applied here. For scenarios where logging query strings is necessary and deemed safe, this behavior can be overridden by enabling the System.Net.Http.DisableUriRedaction AppContext switch or by setting the DOTNET_SYSTEM_NET_HTTP_DISABLEURIREDACTION environment variable. Previous Behavior: Previously, HttpTelemetry logs included query strings by default, which could inadvertently expose sensitive information. New Behavior: With the new change, query strings are redacted from HttpTelemetry logs by default. Developers can enable query string logging global