Skip to content

Instantly share code, notes, and snippets.

@bruno-garcia
bruno-garcia / MongoClientReconnectIssue.cs
Created August 25, 2016 11:29
MongoDB C# Driver reconnection issue
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Driver;
namespace MongoClientReconnectIssue
{
@bruno-garcia
bruno-garcia / Reproducing MongoDB C# driver issue
Created August 25, 2016 12:52
Reproducing MongoDB C# driver issue
> rs.status()
{
"set" : "ReplicaSet",
"date" : ISODate("2016-08-23T17:30:34Z"),
"myState" : 2,
"syncingTo" : "abc-mdb-node1:27017",
"members" : [
{
"_id" : 0,
@bruno-garcia
bruno-garcia / XGH - PT-BR.txt
Created November 16, 2016 12:06 — forked from banaslee/XGH - en.txt
eXtreme Go-Horse Process
Fonte: http://gohorseprocess.wordpress.com
1- Pensou, não é XGH.
XGH não pensa, faz a primeira coisa que vem à mente. Não existe
segunda opção, a única opção é a mais rápida.
2- Existem 3 formas de se resolver um problema, a correta, a errada e
a XGH, que é igual à errada, só que mais rápida.
@bruno-garcia
bruno-garcia / .travis.yml
Created December 1, 2017 19:03
.NET Core Travis-CI build configuration (Greentube.Messaging)
language: csharp
sudo: false
mono: none
os:
- linux
- osx
osx_image: xcode8.1
dotnet: 2.0.0
dist: trusty
env:
@bruno-garcia
bruno-garcia / .appveyor.yml
Created December 1, 2017 19:16
.NET Core AppVeyor build configuration (Greentube.Messaging)
version: '1.0.0-alpha-{build}'
init:
- git config --global core.autocrlf true
# If there's a tag, use that as the version.
- ps: >-
if($env:APPVEYOR_REPO_TAG -eq "true"){Update-AppveyorBuild -Version "$env:APPVEYOR_REPO_TAG_NAME"}
# Will build dependencies in release (optimize and portable pdbs) mode:
build_script:
- cmd: for /f %%a in ('dir /b test') do dotnet test -c Release test/%%a/%%a.csproj
after_build:
@bruno-garcia
bruno-garcia / coverage.ps1
Created December 2, 2017 12:03
.NET Core Open Cover powershell script
Param (
[switch] $generateReport,
[switch] $uploadCodecov
)
$currentPath = Split-Path $MyInvocation.MyCommand.Path
$coverageOutputDirectory = Join-Path $currentPath "coverage"
$coverageFile = "coverage-results.xml"
Remove-Item $coverageOutputDirectory -Force -Recurse -ErrorAction SilentlyContinue
@bruno-garcia
bruno-garcia / iserializer-span-of-t.cs
Last active December 3, 2017 23:06
ISerializer with ReadOnlySpan<T>
public interface ISerializer
{
ReadOnlySpan<byte> Serialize<T>(T @object);
object Deserialize(Type type, ReadOnlySpan<byte> bytes);
}
[Fact]
public void Serialize_NullObject_ThrowsNullArgument()
{
var sut = new MessagePackSerializer(new MessagePackOptions());
Assert.Throws<ArgumentNullException>(() => sut.Serialize((object) null));
}
[Fact]
public void Serialize_NullObject_ThrowsNullArgument()
{
var sut = new MessagePackSerializer(new MessagePackOptions());
Assert.Throws<ArgumentNullException>(() => { sut.Serialize((object) null); });
}
class Program
{
static void Main()
{
var a = 1;
ref var b = ref Increment(ref a);
b++;
var c = Increment(ref b);
c++;
System.Console.WriteLine($@"a: {a}