Skip to content

Instantly share code, notes, and snippets.

ejsmith / Program.cs
Created Sep 15, 2021
Rosyln .NET 6 RC1 bug
View Program.cs
using System.Linq.Expressions;
using System.Reflection;
SomeMethod((Employee e) => e.Name);
void SomeMethod(Field field) {}
public record Employee(string Name);
public class Field
View migrate.ps1
function CopyPackageReferences($project, $packagesConfigPath) {
$packagesConfig = [xml](Get-Content $packagesConfigPath -Encoding UTF8)
$itemGroup = $project.CreateElement("ItemGroup")
$project.Project.AppendChild($itemGroup) | Out-Null
Write-Verbose "Found $($packagesConfig.packages.package.Length) packages to copy"
ejsmith /
Created Oct 25, 2016
Benefits of using Docker Containers
  • Package format that not only contains our code, but also the entire definition of the OS that runs the code which means you get guaranteed consistency in your deployments
  • Easy deployments
    • Just tell docker to run an image from our build artifact registry
  • Simple build promotion
  • Easy scaling
  • Run console workers that will automatically be restarted based on a restart policy
  • Cheaper because we can pack more services onto a box and utilize resources more efficiently while still providing isolation and cpu / memory constraints
  • Can scale each worker independently
View gist:7beddda6eb23a55aa66122ffa08572b9
log : Restoring packages for /Users/ejsmith/.vscode-insiders/extensions/ms-vscode.csharp-1.0.1-rc2/coreclr-debug/project.json...
info : Committing restore...
log : Writing lock file to disk. Path: /Users/ejsmith/.vscode-insiders/extensions/ms-vscode.csharp-1.0.1-rc2/coreclr-debug/project.lock.json
log : /Users/ejsmith/.vscode-insiders/extensions/ms-vscode.csharp-1.0.1-rc2/coreclr-debug/project.json
log : Restore completed in 918ms.
NuGet Config files used:
Feeds used:
View gist:1b5f03f676fcd539f6cd
Session Tracking
Exceptionless can also track user sessions which enables powerful application analytics.
Session tracking can be enabled by simply adding this line to the startup of your application:
View Exceptionless.json
"title": "Exceptionless",
"services": {
"query": {
"list": {
"0": {
"id": 0,
"color": "#7EB26D",
"alias": "",
"pin": false,
ejsmith / EmptyCollectionContractResolver.cs
Created Aug 6, 2014
View EmptyCollectionContractResolver.cs
class EmptyCollectionContractResolver : DefaultContractResolver {
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
JsonProperty property = base.CreateProperty(member, memberSerialization);
Predicate<object> shouldSerialize = property.ShouldSerialize;
property.ShouldSerialize = obj => (shouldSerialize == null || shouldSerialize(obj)) && !IsEmptyCollection(property, obj);
return property;
private bool IsEmptyCollection(JsonProperty property, object target) {
ejsmith / Program.cs
Last active Aug 29, 2015
Examples of using the Exceptionless 2.0 client
View Program.cs
var client = new ExceptionlessClient(config => {
// Set your API key.
config.ApiKey = "API_KEY_HERE";
// Send events to your own free Exceptionless server install.
config.ServerUrl = "";
// Read config settings from attributes.
View project.json
"version": "0.1-alpha-*",
"compilationOptions": {
"warningsAsErrors": true
"dependencies": {
"Microsoft.AspNet.Http": "0.1-alpha-*",
"Microsoft.AspNet.Mvc.Common": "",
"Microsoft.AspNet.Mvc.ModelBinding": "",
"Microsoft.AspNet.Routing": "0.1-alpha-*",
View Bootstrap.cs
Bootstrap.Run(config => {
config.UseAutoMapper(mapper => mapper.UseSomeOption());
Bootstrap.Run(config =>