Skip to content

Instantly share code, notes, and snippets.

Write-Output "Pulling in latest changes for all repositories..."
# Find all git repositories and update it to the master latest revision
Get-ChildItem -Directory -Recurse -Force -Filter ".git" | ForEach-Object {
Write-Output "Checking " $_.FullName
Push-Location -Path $_
# We have to go to the .git parent directory to call the pull command
Set-Location ..
@skolima
skolima / Directory.Build.props
Created May 4, 2020 09:47
Publishing valid SourceLink via GitHub Actions: best practices Directory.Build.props
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<!-- SourceLink starts here -->
<PropertyGroup>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
using System;
using System.Collections.Generic;
using NodaTime;
using NodaTime.Extensions;
using Xunit;
namespace DaylightSavingTimeTests
{
public class DstCalculationsTests
{
using System;
using System.Collections.Generic;
using Xunit;
namespace DaylightSavingTimeTests
{
public class DstCalculationsTests
{
[Theory]
[MemberData(nameof(DstTestCases))]
@skolima
skolima / dotnet-test-and-publish.yml
Last active March 20, 2020 16:12
Run dotnet test; if on branch master, also build and publish NuGet package to GitHub Package Registry
name: Run .NET Core tests
on: [push]
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
- run: dotnet test
@skolima
skolima / dotnet-publish-nuget.yml
Last active March 20, 2020 16:11
Build and publish NuGet package to GitHub Package Registry
name: Build and publish NuGet package to GPR
on: [push]
jobs:
nuget-publish:
name: Publish package to GPR
runs-on: ubuntu-latest
steps:
- uses: einaregilsson/build-number@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
@skolima
skolima / dotnet-tests.yml
Last active March 20, 2020 16:08
Build and run tests for .NET Core project using GitHub Actions
name: Run .NET Core tests
on: [push]
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
- run: dotnet test
@skolima
skolima / ShortestBase64Encoder.cs
Created October 18, 2018 18:23
Create shortest possible base64 url safe representation of a 64 bit number
namespace XUnitTestProject1
{
using System;
using Xunit;
using Microsoft.AspNetCore.WebUtilities;
// https://tools.ietf.org/html/rfc4648#page-7 Base64 URL-safe Alphabet
// uses Microsoft.AspNetCore.WebUtilities.Base64UrlTextEncoder from
// https://www.nuget.org/packages/Microsoft.AspNetCore.WebUtilities
// the same implementation also exists as Microsoft.IdentityModel.Tokens.Base64UrlEncoder,
namespace System.Collections.Generic
{
using Collections;
using Linq;
public static class EnumerableExtension
{
public static IEnumerable EmptyIfNull(this IEnumerable enumerable) => enumerable ?? Enumerable.Empty<object>();
public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T> enumerable) => enumerable ?? Enumerable.Empty<T>();