Skip to content

Instantly share code, notes, and snippets.

@shadow-cs
shadow-cs / LambdaVsMethod.cs
Created Aug 20, 2021
A benchmark for using various methods of passing a delegate
View LambdaVsMethod.cs
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
BenchmarkRunner.Run<Benchmark>();
[MemoryDiagnoser]
public class Benchmark
{
private static int Executor(Func<int> a) => a();
@shadow-cs
shadow-cs / JsonSchemaLoader.cs
Created Sep 30, 2020
Loading external $ref schemas using json-everything
View JsonSchemaLoader.cs
// See https://github.com/gregsdennis/json-everything/issues/8
public class JsonSchemaLoader
{
private static JsonSchema Load(string schemaFile, ValidationOptions options)
{
var schemaFullPath = Path.GetFullPath(schemaFile);
var schemaUri = new Uri(schemaFullPath);
var json = File.ReadAllText(schemaFile);
return Load(schemaUri, json, options);
@shadow-cs
shadow-cs / NetMQTest.csproj
Last active Feb 13, 2020
NetMQ async exceptions
View NetMQTest.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
@shadow-cs
shadow-cs / Counter.cs
Created Nov 9, 2019
Blazor Code behind
View Counter.cs
namespace CodeBehindTest.Pages
{
public partial class Counter
{
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
@shadow-cs
shadow-cs / Items.targets
Last active Nov 18, 2021
MSBuild: Selecting first and last items in an ItemGroup
View Items.targets
<Project DefaultTargets="Default">
<ItemGroup>
<Items Include="One;Two;Three;Four;Five" />
</ItemGroup>
<Target Name="Default">
<ItemGroup>
<Reversed Include="@(Items->Reverse())" />
</ItemGroup>