Skip to content

Instantly share code, notes, and snippets.

View richlander's full-sized avatar

Rich Lander richlander

View GitHub Profile
@richlander
richlander / adaptive-csharp-winrt.cs
Created July 30, 2015 17:10
Adaptive C# code for WinRT
async Task SetupAsync()
{
if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
{
await StatusBar.GetForCurrentView().HideAsync();
}
}
@richlander
richlander / expression-tree.cs
Created September 28, 2015 15:18
Expression tree code that required (and got) a fix with .NET Native
Expression<Func<int>> e = () => 1;
e = e.Update(Expression.Constant(2), null);
int i = e.Compile().Invoke(); // should return "2"
@richlander
richlander / Inline-host-hookup.cs
Last active November 18, 2015 19:16
Inline ASP.NET 5 Host Hookup
public static void Main(string[] args)
{
// code here will run before the host.
// this is the host call.
WebApplication.Run<Startup>(args);
}
@richlander
richlander / simple-host-hookup.cs
Created November 17, 2015 23:02
Default ASP.NET 5 Hookup
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
@richlander
richlander / AsyncLocal.cs
Created July 17, 2015 20:57
AsyncLocal<T> sample
using System;
using System.Threading;
using System.Threading.Tasks;
class AsyncLocal
{
static AsyncLocal<string> _asyncLocalString = new AsyncLocal<string>();
static ThreadLocal<string> _threadLocalString = new ThreadLocal<string>();
static async Task AsyncMethodA()
@richlander
richlander / project.json
Created October 25, 2016 15:32
.NET Core 1.1 Prevew 1 project.json
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
@richlander
richlander / project.json
Created October 25, 2016 20:57
.NET Standard Library 1.6 Preview 1
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable"
},
"dependencies": {},
"frameworks": {
"netstandard1.6": {
"dependencies": {
"NETStandard.Library": "1.6.1-preview1-24530-04"
@richlander
richlander / project.json
Created November 7, 2016 07:15
.NET Core 1.1 Project file
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true
},
"dependencies": {},
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
@richlander
richlander / migrated.csproj
Created November 16, 2016 17:44
.NET Core project file - default project.json migrated to csproj
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>hw-test</AssemblyName>
<OutputType>Exe</OutputType>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
</PropertyGroup>
@richlander
richlander / global.json
Created November 16, 2016 17:46
global.json that contrains dotnet to using the project.json-based preview 2 tools
{
"sdk": {
"version": "1.0.0-preview2-003131"
}
}