Skip to content

Instantly share code, notes, and snippets.

bitbonk bitbonk

Block or report user

Report or block bitbonk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bitbonk
bitbonk / Program.cs
Last active Feb 8, 2019
System.Threading.Channels (C# 8)
View Program.cs
namespace ChannelTest
{
using System;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
class Program
{
public static async Task Main(string[] args)
@bitbonk
bitbonk / NETClassic.json
Last active Jan 21, 2019
JSON Deserailization .NET Core vs. .NET Classic
View NETClassic.json
{
"$type": "MyNamespace.Dto`6[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.DateTime, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], NETClassicApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"StringProp": "my string",
"DoubleProp": 123.0,
"FloatProp": 345.0,
"ByteArrayProp": {
"$type": "System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"$value": "AQID"
},
"UriProp": "http://localhost:80",
@bitbonk
bitbonk / Program.cs
Created Jan 19, 2019
Hello World System.Threading.Channels
View Program.cs
using System;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
class Program
{
public static async Task Main(string[] args)
{
var channel =
@bitbonk
bitbonk / Clients.cs
Created Nov 6, 2018
very simple signalr server + client
View Clients.cs
class Program
{
static async Task Main(string[] args)
{
var connection = new HubConnectionBuilder().WithUrl("http://localhost:19715/chat")
.Build();
await connection.StartAsync();
var receiveCounter = 0;
var isReceiver = args.Length < 1 || args[0].ToLower() != "sender";
@bitbonk
bitbonk / deploy.ps1
Created Jan 10, 2017
deploy something but exclude some stuff
View deploy.ps1
<#
.SYNOPSIS
Copies the files that belong to a deployment to a target folder.
.PARAMETER Source
The path of the source folder.
.PARAMETER Target
The path of the target folder.
#>
[CmdletBinding(SupportsShouldProcess=$True)]
@bitbonk
bitbonk / List.cs
Created Nov 25, 2016
ctor geruden von ToList()
View List.cs
public List(IEnumerable<T> collection)
{
if (collection == null)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection);
ICollection<T> objs = collection as ICollection<T>;
if (objs != null)
{
int count = objs.Count;
if (count == 0)
{
@bitbonk
bitbonk / Test.cs
Last active Feb 5, 2016
slow assertion
View Test.cs
// The Property Culture is of type CultureInfo
enumarableOfComplexObject.ShouldAllBeEquivalentTo(
new[]
{
new { RefText = "Ref1", Culture = Invariant, Text = "Ref1 en", Component = string.Empty },
new { RefText = "Ref3", Culture = Invariant, Text = "Ref3 en", Component = string.Empty },
new { RefText = "Ref1", Culture = German, Text = "Ref1 de", Component = string.Empty },
new { RefText = "Ref3", Culture = German, Text = "Ref3 de", Component = string.Empty },
new { RefText = "Ref1", Culture = English, Text = "Ref1 en", Component = string.Empty },
new { RefText = "Ref3", Culture = English, Text = "Ref3 en", Component = string.Empty },
@bitbonk
bitbonk / PareserTests.cs
Last active Nov 30, 2015
Can I have one Should() instead of two?
View PareserTests.cs
using System;
using System.Collections;
using System.Linq;
using FluentAssertions;
using Xunit;
public class ParserTests
{
[Theory,
InlineData(DataType.String, "foo", "foo"),
View gist:9b0d0b76e661f0f5e43c
[TestMethod]
public void AssertNestedInnerException()
{
var expectedExcpetion = new Exception();
new Action(
() =>
{
throw new InvalidOperationException("", new KeyNotFoundException("", expectedExcpetion));
})
View gist:9c465185c8fa186ab16c
[TestMethod]
public void AssertNestedInnerException()
{
var expectedExcpetion = new Exception();
new Action(
() =>
{
throw new InvalidOperationException("", new KeyNotFoundException("", expectedExcpetion));
})
You can’t perform that action at this time.