Skip to content

Instantly share code, notes, and snippets.

Avatar
🏖️
On Vacation

David Fowler davidfowl

🏖️
On Vacation
View GitHub Profile
View Deadlock.cs
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
namespace ConsoleApp38
{
class Program
{
[ThreadStatic]
@davidfowl
davidfowl / linker.xml
Created Aug 2, 2020
Linker root file for empty web project
View linker.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- See: https://github.com/mono/linker/blob/master/src/linker/README.md#syntax-of-xml-descriptor -->
<linker>
<assembly fullname="Microsoft.Extensions.Hosting">
<type fullname="Microsoft.Extensions.Hosting.Internal.ApplicationLifetime" />
<type fullname="Microsoft.Extensions.Hosting.Internal.ConsoleLifetime" />
<type fullname="Microsoft.Extensions.Hosting.ConsoleLifetimeOptions" />
<type fullname="Microsoft.Extensions.Hosting.Internal.Host" />
<type fullname="Microsoft.Extensions.Hosting.HostOptions" />
</assembly>
View lookbrad.cs
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp25
{
class Program
{
static async Task Main(string[] args)
View oidc.cs
services.AddOptions<OpenIdConnectOptions>()
.Configure<IOIDCPipelineStore, IHttpContextAccessor>((oidcPipelineStore, accessor, options) =>
{
options.ProtocolValidator = new MyOpenIdConnectProtocolValidator(oidcPipelineStore, accessor)
{
RequireTimeStampInNonce = false,
RequireStateValidation = false,
RequireNonce = true,
NonceLifetime = TimeSpan.FromMinutes(15)
};
View TestCrash.cs
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using UnitTestingDiagnostics;
using Xunit;
namespace XUnitTestProject1
{
public class OtherComponent
View ModelBinding.cs
using System;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore.Builder
{
public static class RequestDelegateExtensions
{
@davidfowl
davidfowl / IsPalindrome.cs
Created Feb 2, 2020
Works for surrogate pairs
View IsPalindrome.cs
static bool IsPalin(string s)
{
var bi = s.Length - 1;
foreach (var r in s.EnumerateRunes())
{
if (!Rune.TryGetRuneAt(s, bi - (r.Utf16SequenceLength - 1), out var b) || !r.Equals(b))
{
return false;
}
View SequenceReader_bug.cs
using System;
using System.Buffers;
namespace ConsoleApp91
{
class Program
{
static void Main(string[] args)
{
var segment = new Segment(new byte[] { 1, 2, 3 });
@davidfowl
davidfowl / PeekJsonToken.cs
Last active Jan 21, 2020
Peeking at a JSON token using a PipeReader in the ASP.NET Core request pipeline
View PeekJsonToken.cs
using System;
using System.Buffers;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@davidfowl
davidfowl / PureDI.cs
Last active Sep 22, 2020
DI under the hood. This is what DI containers automate for you
View PureDI.cs
using System;
using System.Threading;
namespace PureDI
{
class Program
{
static void Main(string[] args)
{
// Create the singletons once
You can’t perform that action at this time.