This file contains hidden or 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
#!/bin/sh | |
# | |
# post-commit hook to keep only the last N commits individually | |
# WARNING: rewrites history! Pushes will require --force | |
# | |
if [ "$SKIP_POST_COMMIT" = "1" ]; then | |
exit 0 | |
fi |
This file contains hidden or 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 MediatR; | |
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
public abstract class AbstractRequestHandler<TRequest> : IRequestHandler<TRequest, Response> | |
where TRequest : IRequest<Response> | |
{ | |
internal abstract Task<Response> ExecuteAsync(Response response, TRequest request, CancellationToken cancellationToken); | |
internal virtual Task<Response> HandleErrorAsync(Response response, Exception exception) => Task.FromResult(response.AddError(exception)); |
This file contains hidden or 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
public static class ClassTools | |
{ | |
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); |
This file contains hidden or 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
public static class IEnumerableExtensions | |
{ | |
public static IEnumerable<IEnumerable<T>> MakeGroupsOf<T>(this IEnumerable<T> source, int take) | |
{ | |
var grouping = new List<T>(); | |
foreach ( var item in source) | |
{ | |
grouping.Add(item); | |
if (grouping.Count == take) |
This file contains hidden or 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
public static class ConfigurationFactory | |
{ | |
public static IConfiguration GetConfiguration(string file = null) | |
{ | |
var configuration = new ConfigurationBuilder() | |
.AddJsonFile(file ?? "appsettings.json") | |
.Build(); | |
return configuration; | |
} |
This file contains hidden or 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
public static class FilterExtensions | |
{ | |
public static DynamicFilterBuilder<T> Filter<T>(this T sourceEntity, Action<DynamicFilterBuilder<T>> filter) | |
{ | |
var filterBuilder = new DynamicFilterBuilder<T>(); | |
return filterBuilder.And(filter); | |
} | |
public static Expression<Func<T, bool>> Build<T>(this DynamicFilterBuilder<T> filterBuilder) |
This file contains hidden or 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 Microsoft.EntityFrameworkCore; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Reflection.Metadata; | |
using System.Threading.Tasks; | |
namespace BaseRepository | |
{ |
This file contains hidden or 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
--------------- dependencies | |
dotnet tool install --global dotnet-sonarscanner --version 5.2.0 | |
dotnet tool update dotnet-reportgenerator-globaltool -g --version 4.8.7 | |
--------------- runsonnar.bat | |
dotnet sonarscanner begin /k:"<project name>" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="<login>" /d:sonar.coverageReportPaths=".\sonarqubecoverage\SonarQube.xml" | |
dotnet build | |
dotnet test --no-build --collect:"XPlat Code Coverage" |
This file contains hidden or 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 Microsoft.Extensions.DependencyInjection; | |
using Moq; | |
using System; | |
namespace ServiceProviderFactory | |
{ | |
public static class ServiceProviderFactory | |
{ | |
public static Mock<IServiceProvider> GetServiceProvider(params (Type @interface, object service)[] services) | |
{ |
This file contains hidden or 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
public class PrivateObject<T> | |
{ | |
private object o; | |
public PrivateObject(object o) | |
{ | |
this.o = o; | |
} | |
public object Invoke(string methodName, params object[] args) |
NewerOlder