Skip to content

Instantly share code, notes, and snippets.

View kzu's full-sized avatar

Daniel Cazzulino kzu

View GitHub Profile
@kzu
kzu / X.Y.Z.Sources.csproj
Last active May 20, 2020 21:28 — forked from attilah/X.Y.Z.Sources.csproj
X.Y.Z.Sources nuget package
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<IsPackable>true</IsPackable>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>contentFiles</ContentTargetFolders>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
@kzu
kzu / IncludePackageReferenceInVSIX.targets
Last active November 28, 2019 17:25
Include nuget package reference assets in VSIX
<Project>
<Target Name="IncludePackageReferenceInVSIX"
Condition="$(CI)"
Inputs="@(PackageReference -> WithMetadataValue('IncludeInVSIX', 'true'))"
Outputs="%(PackageReference.Identity)"
DependsOnTargets="ResolvePackageAssets"
AfterTargets="ResolveReferences">
<PropertyGroup>
<IncludeInVSIXPackageId>%(PackageReference.Identity)</IncludeInVSIXPackageId>
</PropertyGroup>
@kzu
kzu / Program.cs
Last active October 31, 2019 17:49
Using SymSpell to detect 1-char misspellings without hardcoding gazzillion misspellings
// Requires package reference to https://www.nuget.org/packages/symspell
using System;
using System.IO;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
@kzu
kzu / ok
Created March 19, 2019 18:33
ok
@kzu
kzu / query
Created January 18, 2019 00:34
Query package dependencies
query {
organization(login: "moq") {
repository(name: "moq") {
dependencyGraphManifests(withDependencies: true) {
nodes {
filename
dependencies {
nodes {
packageManager
packageName
@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());
@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 / 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>
# 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 / 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);