Skip to content

Instantly share code, notes, and snippets.

View grgoncal's full-sized avatar

Guilherme Rocha Goncalves grgoncal

  • Growin -> Engie
  • Brussels, Belgium
View GitHub Profile
@grgoncal
grgoncal / BuildEvents.sh
Created November 30, 2022 23:46
Build events for publishing libraries using Visual Studio
// Pre build events
if $(ConfigurationName) == Release (
del *.nupkg
echo "[PRE-BUILD] Deleted old *.nupkg"
)
// Post Build events
echo "[POST-BUILD] Started"
@grgoncal
grgoncal / BaseMock.cs
Last active December 7, 2022 18:10
BaseMock class for unit testing
using Moq;
namespace BaseMock
{
public partial class BaseMock<TInterface, TAdapter>
where TInterface : class
where TAdapter : class, new()
{
protected readonly Mock<TInterface> mock = new();
@grgoncal
grgoncal / ClassTools.cs
Last active December 15, 2023 08:17
A simple get property value snippet to retrieve a class property using a string as an input. Use dots to access properties from child classes (e.g. Child.Property1).
public static class ClassUtils
{
private static List<string> Enumerables = new List<string>() { "IList", "ICollection", "IEnumerable", "IReadOnlyList", "IReadOnlyCollection" };
public static object GetPropertyValue<T>(T source, string property)
{
if (!property.Contains("."))
return GetProperty(source, property);
var path = property.Split(new[] { '.' }, 2);
@grgoncal
grgoncal / AbstractHandler.cs
Created September 19, 2022 19:06
A quick gist with generic methods for encapsulating try catch blocks and/or polly sync or async calls.
using Polly;
using Polly.Contrib.WaitAndRetry;
namespace CSharp.Tools
{
public abstract class AbstractHandler
{
/// <summary>
/// Regular "do work"
/// </summary>