Skip to content

Instantly share code, notes, and snippets.

View richlander's full-sized avatar

Rich Lander richlander

View GitHub Profile
@richlander
richlander / vb-read-only-auto-properties.vb
Created July 20, 2015 17:49
VB Read-only Auto-Properties
Public Class Customer
Public ReadOnly Property First As String = "Jane"
Public ReadOnly Property Last As String = "Doe"
End Class
@richlander
richlander / csharp-string-interpolation.cs
Created July 20, 2015 17:52
C# 6 String Interpolation
var s = $"{p.Name} is {p.Age} year{{s}} old";
@richlander
richlander / vb-string-interpolation.vb
Created July 20, 2015 17:54
VB String Interpolation
Dim s = $"{p.Name} is {p.Age} year{{s}} old"
@richlander
richlander / csharp-null-conditional-operator.cs
Created July 20, 2015 17:56
Null-Conditional operator (?.)
int length = customers?.Length ?? 0; // 0 if customers is null
@richlander
richlander / vb-null-conditional-operator.vb
Created July 20, 2015 17:57
Null-Conditional operator (?.)
Dim length As Integer = If(customers?.Length, 0) ' 0 if customers is null
@richlander
richlander / csharp-nameof-operator.cs
Created July 20, 2015 17:57
C# 6 NameOf operator
if (x == null) throw new ArgumentNullException(nameof(x));
@richlander
richlander / vb-nameof-operator.vb
Created July 20, 2015 17:58
VB NameOf operator
If x Is Nothing Then Throw New ArgumentNullException(NameOf(x))
@richlander
richlander / csharp-read-only-auto-properties.cs
Created July 20, 2015 19:06
C# 6 Read-only Auto-Properties
public class Customer
{
public string First { get; } = "Jane";
public string Last { get; } = "Doe";
}
@richlander
richlander / fsharp-tail-call.fs
Created July 28, 2015 18:00
F# repro code for RyuJit tail call issue.
open System
type T() =
member __.F1(arg1 : string byref, arg2, arg3 : Nullable<int>, arg4 : bool) =
arg1 <- arg1
__.F2(arg1, arg2, arg3, arg4)
member __.F2(_ : string, _ : obj, arg : Nullable<int>, _ : bool) =
Console.WriteLine("{0}", arg) // prints "random" number
@richlander
richlander / ryujit-tail-call.cs
Created July 28, 2015 22:06
Annotated C# repro code for RyuJit tail call issue
// This repro documents a minimal example of the RyuJIT tail call issue (July 2015).
// All of the characteristics described in the repro need to be present to trigger the bad codegen.
using System;
// Simple struct containing two integers (size 8).
struct MyStruct
{
public MyStruct(int a, int b)
{
A = a;