Skip to content

Instantly share code, notes, and snippets.

Avatar

Fons Sonnemans sonnemaf

View GitHub Profile
@sonnemaf
sonnemaf / NavigateBackAction.cs
Created Oct 13, 2015
NavigateBackAction XAML Behavior for Blend
View NavigateBackAction.cs
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 Dec 14, 2017
InParameterOnNonReadonlyStructAnalyzer
View gist:0001b88db198be33d83f346a47ad874f
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 Apr 5, 2018
RequiredHeaderTemplate and BoldHeaderTemplate for XAML #UWP
View MainPage.xaml
<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 Jun 18, 2018
UnderlinedRadioButtonStyle
View MainPage.xaml
<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>
View Linq4Span.cs
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>
View PrimesPerfTest
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();
View delegate_invoke_benchmark.cs
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 Mar 17, 2020
Windows Terminal Profile
View profiles.json
// 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": [
@sonnemaf
sonnemaf / .editorconfig
Last active Jun 28, 2020
My personal EditorConfig file
View .editorconfig
# 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
View ToolkitHighPerformanceBM.cs
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>();