Skip to content

Instantly share code, notes, and snippets.

@markrendle
markrendle / abstract.md
Created Feb 2, 2017
.NET Core, The Universe, and Everything
View abstract.md

.NET Core, The Universe and Everything

.NET Core finally brings a fully-supported, open-source version of the framework cross-platform, and with the 2.0 release due in Spring, it's really ready for prime-time. While C# and .NET are familiar, the new ecosystem in which whey find themselves is bigger and more open than ever before, and the design and architecture of the systems you can build is very different from the "ASP.NET hosted in IIS" model you're used to.

Join Mark as he shares some of what he's learned from working with ASP.NET Core since the very first preview release of Project K through to version 1.1, including:

@markrendle
markrendle / Pilates.md
Last active Dec 19, 2016
The 9 Arbitrary Rules Of Object Pilates
View Pilates.md

Object Pilates outlines 9 completely arbitrary and hopelessly unrealistic rules to apply when performing the exercise:

  • One primitive parameter per method.
  • Don't use the subtract operator.
  • Wrap all increment operations in static methods.
  • Singly-linked lists.
  • One underscore per file.
  • Don't loop.
  • Keep all solutions less than 529 lines.
  • No methods with more than two callers.
View msbuild.md

Thoughts on project files

I missed last night's ASP.NET Community Standup on account of being shattered after a long day and falling asleep. Then I checked Twitter on the train this morning and discovered that the .NET world had, apparently, been burned to the ground by marauding Microsofties (again). It seemed to have something to do with project files, JSON vs XML, and suchlike.

Finally, lunchtime happened and I could watch the recording of the standup, and I got to understand what everyone was on about. In case you've missed it:

The TL;DR history

  1. In the beginning, there was make, and Gates did not own make, so Gates said "Let there be MSBuild" and there was MSBuild.
  2. And MSBuild used the *.*proj files from Visual Studio as its inputs, which were formed of terrible XML, and verily it was impossible to use without a Visual Studio license.
View Whatever.cs
public class Whatever
{
public async Task<int> Something()
{
await Task.Delay(1).ConfigureAwait(false);
await Task.Delay(1).ConfigureAwait(true);
return 0;
}
}
@markrendle
markrendle / dockdnx.sh
Created Feb 22, 2016
Docker script to run `dnx` commands using CoreCLR
View dockdnx.sh
#! /usr/bin/env bash
WORKDIR=''
PROJECTDIR=$PWD
while [ ! -f "${PROJECTDIR}/global.json" ] ; do
WORKDIR="/$(basename $PROJECTDIR)${WORKDIR}"
PROJECTDIR=$(dirname $PROJECTDIR)
if [ $PROJECTDIR == '/' ] ; then
echo No global.json found in any parent directories. Aborting.
exit 1
@markrendle
markrendle / gulpfile.js
Created Nov 5, 2015
Pass an argument to Gulp to only run a subset of Specs
View gulpfile.js
"use strict";
const gulp = require('gulp'),
mocha = require('gulp-mocha'),
minimist = require('minimist');
const knownOptions = {
string: 'spec',
default: { spec: '*' }
};
View ClaimsPrincipalBuilder.cs
public class ClaimsPrincipalBuilder
{
public static ClaimsPrincipal FromDictionary(IDictionary<string, string> source)
{
var claims = source.Select(pair => new Claim(pair.Key, pair.Value));
var identity = new ClaimsIdentity(claims);
return new ClaimsPrincipal(identity);
}
}
View ClaimsMiddleware.cs
using System.Linq;
using Microsoft.AspNet.Builder;
namespace StealthProject.Mvc
{
public static class AuthenticationMiddleware
{
private static readonly char[] Eq = { '=' };
public static IApplicationBuilder UseHeaderClaims(this IApplicationBuilder app)
@markrendle
markrendle / Gulpfile.js
Created Jun 25, 2015
Gulp to copy js plus minified version
View Gulpfile.js
var gulp = require('gulp'),
hint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename');
gulp.task('lint', function() {
return gulp.src(['Scripts/**/*.js'])
.pipe(hint());
});
@markrendle
markrendle / Person.cs
Created Jun 3, 2015
Backwards compatibility is hard
View Person.cs
namespace PersonApp
{
public class Person
{
public Person()
{
}
private Person(string firstName, string lastName)
You can’t perform that action at this time.