Skip to content

Instantly share code, notes, and snippets.

View kzu's full-sized avatar

Daniel Cazzulino kzu

View GitHub Profile
@kzu
kzu / vsmef.linq
Created July 8, 2016 15:58
VSMEF Components
var xmlns = new XmlNamespaceManager(new NameTable());
xmlns.AddNamespace("vsx10", "http://schemas.microsoft.com/developer/vsx-schema/2010");
xmlns.AddNamespace("vsx11", "http://schemas.microsoft.com/developer/vsx-schema/2011");
var vsix = from file in Directory.EnumerateFiles(@"C:\Program Files (x86)\Microsoft Visual Studio 14.0", "extension.vsixmanifest", SearchOption.AllDirectories)
where File.ReadAllLines(file)[0].StartsWith("<")
select file;
var mef = vsix
.Select(x => XDocument.Load(x))
@kzu
kzu / ProjectCapabilities.txt
Created November 23, 2016 13:32
ProjectCapabilities
AllTargetOutputGroups => C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\JavaScript\Microsoft.VisualStudio.JavaScript.Common.targets
AllTargetOutputGroups => C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.targets
AllTargetOutputGroups => C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\JavaScript\Microsoft.VisualStudio.WJProject.targets
AllTargetOutputGroups => C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\JavaScript\Microsoft.CodeSharing.JavaScript.targets
AllTargetOutputGroups => C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.DesignTime.targets
AllTargetOutputGroups => C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.targets
AllTargetOutputGroups => C:\Program Files (x86)\MSBuild\1
<VSDIR>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7@%(Dev.Identity).0)</VSDIR>
<VSDIR Condition="'$(VSDIR)' == ''">$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7@%(Dev.Identity).0)</VSDIR>
@kzu
kzu / blob
Last active June 30, 2018 22:54
See code in GitHub blobs in full screen width with Stylebot
/*
url: github.com/*/*/blob/**
stylebot does not support comments, so, set the
url of the style (in Options) and remove this
whole comment
*/
.repository-with-sidebar .repository-content {
width: calc(100% - 50px);
@kzu
kzu / home-end.ahk
Created February 2, 2018 06:38
Home/End AutoHotKey remap
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#InstallKeybdHook
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
; NoTrayIcon
; OPTIONAL: For those who use Home/End more than PgUp/PgDown, this flips their use with the Fn key.
; If you want the buttons to function as they are, add a semicolon (;) to the beginning of each line below.
Home::PgUp
End::PgDn
PgUp::Home
@kzu
kzu / ObservableExtensions.cs
Created February 21, 2018 15:38
ObservableExtensions
public static class ObservableExtensions
{
static readonly Action<Exception> rethrow = e => ExceptionDispatchInfo.Capture(e).Throw();
static readonly Action nop = () => { };
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext)
=> Subscribe(source, onNext, rethrow, nop);
public static IDisposable Subscribe<T>(this IObservable<T> source, Action<T> onNext, Action<Exception> onError)
=> Subscribe(source, onNext, onError, nop);
# Add to your profile so you can run `Cleanup-VS` from any PS prompt
Function Cleanup-VS
{
$script = (Split-Path -parent $PSCommandPath) + "\vscleanup.ps1"
&$script
}
@kzu
kzu / AutoFix.feature
Created September 15, 2018 06:59
Automatically applying Roslyn code fixes during build
Feature: AutoFix
Applies code fixes during build
Scenario: Can apply StyleCop code fix automatically
Given Foo.csproj =
"""
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>Latest</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
@kzu
kzu / report.ps1
Last active September 24, 2018 18:36
Cross-platform GitHub status reporting powershell script for VSTS
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$statusUrl = '$(GitHub.StatusUrl)'
$token = '$(GitHub.Token)'
if ($env:FIXEDSOURCEVERSION -eq $true) { return; }
# When the commit that triggered the build/release is a PR merge commit,
# this task will adjust the Build.SourceVersion to the original commit, not the
# merge commit
@kzu
kzu / FormsTests.cs
Created October 18, 2018 18:04
Mocking Xamarin.Forms
public abstract class FormsTests
{
static FormsTests()
{
// Force loading of XAML assembly.
Debug.WriteLine(typeof(XamlCompilationAttribute).FullName);
var mock = new Mock<IPlatformServices> { DefaultValue = DefaultValue.Mock };
mock.Setup(x => x.BeginInvokeOnMainThread(It.IsAny<Action>()))
.Callback<Action>(action => action());