Layered Architecture
flowchart TD
subgraph FEATURES
Presentation --> Application
Application --> Domain
Domain --> Infrastructure
Infrastructure --> Database
end
[RankColumn] | |
[HideColumns(new string[] { "Job" })] | |
[MemoryDiagnoser(false)] | |
[SimpleJob(RuntimeMoniker.Net60)] | |
[SimpleJob(RuntimeMoniker.Net70)] | |
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByMethod)] | |
public class Benchmark | |
{ | |
// ... start from here | |
} |
var options = new JsonSerializerOptions | |
{ | |
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, | |
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, | |
ReferenceHandler = ReferenceHandler.IgnoreCycles, | |
WriteIndented = true | |
} | |
var json = JsonSerializer.Serialize(state, options); |
/* required nugets | |
<ItemGroup> | |
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" /> | |
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" /> | |
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" /> | |
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" /> | |
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" /> | |
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" /> | |
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="7.0.0" /> | |
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" /> |
<Project> | |
<PropertyGroup> | |
<!-- <LangVersion>latest</LangVersion> --> | |
<!--<LangVersion>preview</LangVersion>--> | |
<LangVersion>8</LangVersion> | |
</PropertyGroup> | |
</Project> |
{ | |
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", | |
"methodDisplay": "method", | |
"methodDisplayOptions": "all" | |
} |
public static class TaskHelper | |
{ | |
/// <summary> | |
/// Runs a TPL Task fire-and-forget style, the right way - in the | |
/// background, separate from the current thread, with no risk | |
/// of it trying to rejoin the current thread. | |
/// </summary> | |
public static void RunBg(Func<Task> fn) => Task.Run(fn).ConfigureAwait(false); | |
/// <summary> |
public static class AsyncHelpers | |
{ | |
/// <summary> | |
/// Executes an async Task<T> method which has a void return value synchronously | |
/// </summary> | |
/// <param name="task">Task<T> method to execute</param> | |
public static void RunSync(Func<Task> task) | |
{ | |
var oldContext = SynchronizationContext.Current; | |
var synch = new ExclusiveSynchronizationContext(); |
flowchart TD
subgraph FEATURES
Presentation --> Application
Application --> Domain
Domain --> Infrastructure
Infrastructure --> Database
end
public class TaskExtended | |
{ | |
public static async Task<IEnumerable<T>> WhenAll<T>(params Task<T>[] tasks) | |
{ | |
var allTasks = Task.WhenAll(tasks); | |
try | |
{ | |
return await allTasks; | |
} |
root = true | |
# Remove the line below if you want to inherit .editorconfig settings from higher directories | |
[*.json] | |
indent_size = 4 | |
indent_style = space | |
tab_width = 4 | |
# C# files | |
[*.cs] |