Skip to content

Instantly share code, notes, and snippets.

View Mike-E-angelo's full-sized avatar

Mike-E Mike-E-angelo

View GitHub Profile
@Mike-E-angelo
Mike-E-angelo / CastingBenchmarks.cs
Created April 12, 2017 10:48
Basic benchmarks on casting, including with access from a dictionary.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
namespace ClassLibrary1
{
public class CastingBenchmarks
{
readonly private static Type Key = typeof(int);
@Mike-E-angelo
Mike-E-angelo / ImplicitCastingBenchmarks.cs
Created April 13, 2017 06:20
Basic benchmarks around implicit/explicit contra/covariant casting.
using BenchmarkDotNet.Attributes;
namespace ClassLibrary1
{
public class ImplicitCastingBenchmarks
{
readonly private IInterface<string> _sut = new Implementation();
readonly private IInterface<object> _obj;
public ImplicitCastingBenchmarks()
{
namespace Government
{
class America { }
class Citizen : America
{
const string TaxReturns = "Release us FFS!!!";
private int trumpEmotionalIQ = 0, trumpTolerance = 0;
private float trumpExperience = .03f;
@Mike-E-angelo
Mike-E-angelo / MetricTonOfCode.cs
Created April 15, 2018 20:42
Xunit2 Demystify Support
[assembly: TestFramework("AssemblyName.Namespace.TestFramework", "AssemblyName")]
public sealed class TestFramework : XunitTestFramework
{
public TestFramework(IMessageSink messageSink) : base(messageSink) {}
protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyName)
=> new Executor(assemblyName, SourceInformationProvider, DiagnosticMessageSink);
}
@Mike-E-angelo
Mike-E-angelo / Empty
Last active September 8, 2018 16:44
Hashing out Empty
// Re: https://medium.com/@antao.almada/enumeration-in-net-iii-enumerable-empty-t-1bfcd53739a7
// Decompiled with JetBrains decompiler
// Type: System.Linq.Enumerable
// Assembly: System.Linq, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 27FAC526-A042-4B73-AEC3-616A6586AC97
// Assembly location: c:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.3\System.Linq.dll
namespace System.Linq
{
@Mike-E-angelo
Mike-E-angelo / BasicAsynchronousInterface.cs
Created May 27, 2019 07:22
Basic Asynchronous Interface
public interface IHelloWorldAsync
{
Task<string> SayHelloAsync(string message);
}
@Mike-E-angelo
Mike-E-angelo / BasicInterface.cs
Last active May 27, 2019 07:32
Basic Interface
public interface IHelloWorld
{
string SayHello(string message);
}
@Mike-E-angelo
Mike-E-angelo / CSharpish.cs
Last active June 12, 2019 09:57
Razor C# Example
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.RenderTree;
namespace Presentation.Elements
{
public abstract class ElementBase : ComponentBase
{
readonly string _name;
protected ElementBase(string name) => _name = name;