Skip to content

Instantly share code, notes, and snippets.

View aalmada's full-sized avatar
🏠
Working from home

Antão Almada aalmada

🏠
Working from home
View GitHub Profile
BenchmarkDotNet=v0.11.4, OS=macOS Mojave 10.14.4 (18E226) [Darwin 18.5.0]
Intel Core i5-7360U CPU 2.30GHz (Kaby Lake), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=3.0.100-preview4-011223
  [Host]     : .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT
  DefaultJob : .NET Core 2.1.6 (CoreCLR 4.6.27019.06, CoreFX 4.6.27019.05), 64bit RyuJIT

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using System;
namespace Benchmarks
{
[MemoryDiagnoser]
[MarkdownExporterAttribute.GitHub]
public class ValueEnumerableBenchmarks2
{
@aalmada
aalmada / Singleton.cs
Last active August 30, 2019 10:45
Singleton base MonoBehaviour implementation. Based on the one on Unity Community Wiki but with fixes and using modern C#.
using UnityEngine;
/// <summary>
/// Inherit from this base class to create a singleton.
/// e.g. public class MyClassName : Singleton<MyClassName> {}
/// </summary>
public abstract class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
// Check to see if we're about to be destroyed.
static bool shuttingDown = false;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace HeadTail
{
[MemoryDiagnoser]
using System;
using System.Diagnostics.Contracts;
namespace NetFabric.Hyperlinq
{
public static class Option
{
[Pure]
public static NoneOption None { get; } = new NoneOption();
using System;
using System.Diagnostics.Contracts;
namespace NetFabric.Hyperlinq
{
public static class Result
{
[Pure]
public static DelayedOk<TOk> Ok<TOk>(TOk ok)
=> new DelayedOk<TOk>(ok);
[TestMethod]
public void TestMethod2()
{
var test = @"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
public class AssignmentBoxingTests : DiagnosticVerifier
{
protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer() =>
new AssignmentBoxingAnalyzer();
[Theory]
[InlineData("TestData/HLQ001/NoDiagnostic/FieldDeclaration.cs")]
[InlineData("TestData/HLQ001/NoDiagnostic/FieldDeclaration.Async.cs")]
[InlineData("TestData/HLQ001/NoDiagnostic/PropertyDeclaration.cs")]
[InlineData("TestData/HLQ001/NoDiagnostic/PropertyDeclaration.Async.cs")]
<ItemGroup>
<Compile Update="TestData\**\*.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Remove="TestData\**\*.Fix.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="TestData\**\*.Fix.cs">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>