This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace A.B.C; | |
using System; | |
using System.Net; | |
using System.Runtime.Serialization; | |
[Serializable] | |
public class MyException : Exception | |
{ | |
public MyException(HttpStatusCode statusCode, string? message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net; | |
using System.Net.Sockets; | |
public static class FreePortLocator | |
{ | |
private static readonly IPEndPoint _defaultLoopbackEndpoint = new(IPAddress.Loopback, port: 0); | |
public static int GetAvailablePort() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TaskUtils; | |
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
public static class TaskExtensions | |
{ | |
/// <summary> | |
/// See for more information: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$userPath = $env:USERPROFILE | |
$pathExclusions = New-Object System.Collections.ArrayList | |
$processExclusions = New-Object System.Collections.ArrayList | |
$pathExclusions.Add('C:\Windows\Microsoft.NET') > $null | |
$pathExclusions.Add('C:\Windows\assembly') > $null | |
$pathExclusions.Add($userPath + '\AppData\Local\Microsoft\VisualStudio') > $null | |
$pathExclusions.Add('C:\ProgramData\Microsoft\VisualStudio\Packages') > $null | |
$pathExclusions.Add('C:\Program Files (x86)\MSBuild') > $null | |
$pathExclusions.Add('C:\Program Files (x86)\Microsoft Visual Studio 14.0') > $null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using NLog; | |
using NLog.Targets; | |
using NUnit.Framework; // Using NUnit but any other unit test framework will do | |
namespace com.github.gist.coenm.Test | |
{ | |
public class Xyz | |
{ | |
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.Owin; | |
using NLog; // Using NLog in this example | |
namespace com.github.gist.coenm | |
{ | |
public static class LogRequestResponseHelper | |
{ | |
public static void LogDebugResponse(Logger logger, IOwinResponse response) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
namespace com.github.coenm | |
{ | |
public static class NonPublicMethodsHelper | |
{ | |
public static MethodInfo GetNonPublicMethod(object instance, string methodName) | |
{ | |
var instanceType = instance.GetType(); |