Skip to content

Instantly share code, notes, and snippets.

View sonnemaf's full-sized avatar

Fons Sonnemans sonnemaf

View GitHub Profile
@sonnemaf
sonnemaf / NavigateBackAction.cs
Created October 13, 2015 08:56
NavigateBackAction XAML Behavior for Blend
public class NavigateBackAction : DependencyObject, IAction {
/// <summary>
/// Navigate the Frame back
/// </summary>
/// <param name="sender"></param>
/// <param name="parameter"></param>
/// <returns>True if navigated</returns>
public object Execute(object sender, object parameter) {
@sonnemaf
sonnemaf / gist:0001b88db198be33d83f346a47ad874f
Created December 14, 2017 21:02
InParameterOnNonReadonlyStructAnalyzer
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@sonnemaf
sonnemaf / MainPage.xaml
Last active April 5, 2018 08:39
RequiredHeaderTemplate and BoldHeaderTemplate for XAML #UWP
<Page x:Class="App18.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App18"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<FontWeight x:Key="HeaderFontWeight">Medium</FontWeight>
@sonnemaf
sonnemaf / MainPage.xaml
Created June 18, 2018 08:26
UnderlinedRadioButtonStyle
<Page x:Class="App34.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App34"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
RequestedTheme="Dark"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
@sonnemaf
sonnemaf / .editorconfig
Last active June 28, 2020 11:12
My personal EditorConfig file
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4
using System;
using System.Runtime.InteropServices;
namespace Linq4Span {
// QUESTION: Does LINQ for ReadOnlySpan<T> make sense or is the extra Closure class a showstopper?
// QUESTION: Should it only support ReadOnlySpan<T> and not Span<T>
// QUESTION: What about Memory<T> and ReadonlyMemory<T>
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp39 {
class Program {
static void Main(string[] args) {
int total = 0;
var sw = Stopwatch.StartNew();
@sonnemaf
sonnemaf / delegate_invoke_benchmark.cs
Created February 18, 2020 09:03
Source used in a tweet
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Linq;
public class Program {
static void Main(string[] args) => BenchmarkRunner.Run(typeof(Program));
private Func<int, int> _delegateToStaticMethod;
private Func<int, int> _delegateToInstanceMethod;
@sonnemaf
sonnemaf / profiles.json
Created March 17, 2020 17:09
Windows Terminal Profile
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles": [
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Microsoft.Toolkit.HighPerformance.Helpers;
using System;
using System.Threading.Tasks;
namespace ToolkitHighPerformanceBM {
class Program {
static void Main(string[] args) {
BenchmarkRunner.Run<BM>();