View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Diagnostics.Runtime; | |
using System; | |
using System.Linq; | |
namespace ExtractDynamicMethod | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ |
View Benchmark.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[MemoryDiagnoser] | |
public class EmptyEnumerator | |
{ | |
[Benchmark(Baseline = true)] public bool ArrayEmpty() => Array.Empty<string>().GetEnumerator().MoveNext(); | |
[Benchmark] public bool ArrayEmptyAsEnumerable() => ((IEnumerable<string>)Array.Empty<string>()).GetEnumerator().MoveNext(); | |
[Benchmark] public bool ArrayEmptyForEach() | |
{ | |
foreach (var _ in Array.Empty<string>()) |
View ClrmdAsyncLocal.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading; | |
using Microsoft.Diagnostics.Runtime; | |
namespace ClrmdAsyncLocal | |
{ | |
internal class Program | |
{ |
View IsEvenSourceGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Microsoft.CodeAnalysis; | |
using Microsoft.CodeAnalysis.CSharp.Syntax; | |
using Microsoft.CodeAnalysis.Text; | |
namespace IsEvenSourceGenerator | |
{ | |
[Generator] |
View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.CompilerServices; | |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
namespace BenchmarkCore | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
View ApiWebRequestFactoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// This test ensures that the ApiWebRequestFactory behaves correctly when | |
/// a different type of WebRequest is assigned to the http:// prefix | |
/// </summary> | |
[Fact] | |
public void OverrideHttpPrefix() | |
{ | |
// Couldn't find a way to "officially" unregister a prefix but that shouldn't stop us | |
var prefixListProperty = typeof(WebRequest).GetProperty("PrefixList", BindingFlags.Static | BindingFlags.NonPublic); | |
var oldPrefixList = prefixListProperty.GetValue(null); |
View ApiWebRequestFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class ApiWebRequestFactory : IApiRequestFactory | |
{ | |
public IApiRequest Create(Uri endpoint) | |
{ | |
return new ApiWebRequest(WebRequest.CreateHttp(endpoint)); | |
} | |
} |
View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WebRequest.RegisterPrefix("http://", new CustomWebRequestFactory()); |
View ApiWebRequestFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class ApiWebRequestFactory : IApiRequestFactory | |
{ | |
public IApiRequest Create(Uri endpoint) | |
{ | |
return new ApiWebRequest((HttpWebRequest)WebRequest.Create(endpoint)); | |
} | |
} |
View StartupAssemblyLoadContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StartupAssemblyLoadContext : AssemblyLoadContext | |
{ | |
private readonly AssemblyDependencyResolver _resolver; | |
public StartupAssemblyLoadContext() | |
{ | |
_resolver = new AssemblyDependencyResolver(Assembly.GetExecutingAssembly().Location); | |
} | |
protected override Assembly Load(AssemblyName assemblyName) |
NewerOlder