Skip to content

Instantly share code, notes, and snippets.

View paulomorgado's full-sized avatar

Paulo Morgado paulomorgado

View GitHub Profile
@karenpayneoregon
karenpayneoregon / someprojectfile.csproj
Last active February 7, 2024 19:33
reduced source path
<PropertyGroup>
<PathMap>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))=./</PathMap>
</PropertyGroup>
@FriedrichWeinmann
FriedrichWeinmann / Get-UserInput.ps1
Created May 25, 2021 08:48
Get userinput and validate it
function Get-UserInput {
<#
.SYNOPSIS
Asks for user input, then validates response.
.DESCRIPTION
Asks for user input, then validates response.
.PARAMETER Prompt
The message to show to the user as input prompt.
using System;
using System.Threading.Tasks;
namespace System.Collections.Concurrent
{
public static class ConcurrentDictionaryExtensions
{
/// <summary>
/// Provides an alternative to <see cref="ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/> that disposes values that implement <see cref="IDisposable"/>.
/// </summary>
@davidfowl
davidfowl / ModuleLoader.cs
Last active March 5, 2023 19:21
ModuleLoader: This handles concurrent requests adding modules and duplicates
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Infrastructure;
@richlander
richlander / modernizing-csharp9.md
Last active May 2, 2023 11:36
Modernizing a codebase for C# 9

Modernizing a codebase for C# 9

There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull example requires it.

Use the property pattern to replace IsNullorEmpty

Consider adopting the new property pattern, wherever you use IsNullOrEmpty.

string? hello = "hello world";