Skip to content

Commit 651cfdb

Browse files
lonesomegeeklonesomegeek
and
lonesomegeek
authored
Version/5.0.0 (#146)
* first draft, remove all <> * rework unit tests to work with new structure * Work/22 (#104) * remove sync methods from service layer * remove useless tests * cleanup in sonar cube things (#105) * Work/duge/85 (#106) * massive cleanup of previous samples * adding new samples structure * Work/duge/86 (#115) * massive cleanup of previous samples * adding new samples structure * remove extension project * Work/duge/85 (#116) * massive cleanup of previous samples * adding new samples structure * remove extension project * cleanup in sonar cube things (#117) * clean up nonasync things (#118) * Work/duge/88 (#119) * adding new build file * default netcore * ignore unsupported projects * Update azure-pipelines.yml for Azure Pipelines * adding pack and publish * adding pack and publish * adding pack and publish * adding pack and publish * adding pack and publish * adding pack and publish * adding pack and publish * adding pack and publish * Update azure-pipelines.yml for Azure Pipelines * adding pack and publish * adding pack and publish * inject nuget api key from variable group * inject nuget api key from variable group * inject nuget api key from variable group * inject nuget api key from variable group * inject nuget api key from variable group * add environment * adding environment deployment * adding environment deployment * adding environment deployment * adding environment deployment * adding environment deployment * adding build directory * adding build directory * adding build directory * adding build directory * adding build directory * adding build directory * adding build directory * adding build directory * adding build directory * Update azure-pipelines.yml * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * Update build.yml * Update build.yml * Update build.yml * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * refactor release and build * interface cleanup begun (#120) * interface cleanup begun * cleanup done * create an injectable option object for service layer (#121) * create an injectable option object for service layer * extra line cleanup * Work/duge/99 (#122) * create an injectable option object for service layer * extra line cleanup * adding files ready for netcore 3.1 (#123) * rework base classes and cleanup (#132) * Work/duge/97 (#133) * bug in master branch * adding benchmark files * Work/duge/95 (#134) * adding material to test IEntity vs BaseEntity * cleanup in samples * putting in on track * whant ignoring fields from changeset, ICreated and IModified is working * working version with context and ignoreinchangeset attribute@ * Work/duge/94 (#137) * adding files before waiting for the samples * 2 different service layers * ability to inject by model * adding more documentation on custom layers * adding more documentation * adding initial sequence diagrams * adding more doc on custom layers * adding new version of sequence diagram * Update sequence.drawio * Update sequence.drawio * Update sequence.drawio * test before odata: * updated sequence diagram * adding PNG printouts of the schemas * more sequence diagrams and docs Co-authored-by: lonesomegeek <[email protected]> * Work/duge/94 (#138) * adding files before waiting for the samples * 2 different service layers * ability to inject by model * adding more documentation on custom layers * adding more documentation * adding initial sequence diagrams * adding more doc on custom layers * adding new version of sequence diagram * Update sequence.drawio * Update sequence.drawio * Update sequence.drawio * test before odata: * updated sequence diagram * adding PNG printouts of the schemas * more sequence diagrams and docs * adding some docs in the main readme file@ * before merging with yden063 commit * adding last doc for now Co-authored-by: lonesomegeek <[email protected]> * changing the commit mode of crud dto service layer (without historical crud) * Work/duge/92 (#140) * before merging with default vanilla project * working version bug outdated * working version with ng8, ag-grid and netcore3.1 * adding database location and themes to aggrid * tests with wsl2 * adding new docker commands for wsl * adding babel to let ng build complete, bug documented here: angular/angular-cli#17262 * working version with vscode debugger * adding objects and shares controller * adding contact controller * remove item controller, new tables * working objects FE and BE * adding generic crud historical, missing generic service layer * adding release notes and breaking changes * merge conflict Co-authored-by: lonesomegeek <[email protected]> * adjusting unit tests to new v5 structure (#141) Co-authored-by: lonesomegeek <[email protected]> * Work/duge/102 (#142) * rework tutorials * change samples * move files to a more structure folder structure * more doc * more doc * move files to new folders * enough doc for samples Co-authored-by: lonesomegeek <[email protected]> * Work/duge/102 (#143) * rework tutorials * change samples * move files to a more structure folder structure * more doc * more doc * move files to new folders * enough doc for samples Co-authored-by: lonesomegeek <[email protected]> * Work/duge/92 (#144) * before merging with default vanilla project * working version bug outdated * working version with ng8, ag-grid and netcore3.1 * adding database location and themes to aggrid * tests with wsl2 * adding new docker commands for wsl * adding babel to let ng build complete, bug documented here: angular/angular-cli#17262 * working version with vscode debugger * adding objects and shares controller * adding contact controller * remove item controller, new tables * working objects FE and BE * adding generic crud historical, missing generic service layer * adding release notes and breaking changes * merge conflict * rework classes * reverting items to normal crud * put back on track shares controller * adding contributor * all working endpoints without dto for now * working version of generic components * working with sub component * historical crud component ready, missing dynamic form * dynamic listing and form * adding showHistory * little cleanup * adding the other entities * before cleanup in crud components * refactoring in components * adding blog posts * move files * adding sample database project * adding contributor about page * almost done for the v1 of the UI * change naming of services in dto lib * putting in place de dto layers * Adding dependencies * converting to json * users with dto * blog post with DTO * update to existing tables * hooks online * Change log level * adding production setup for SQL * docker build image * remove trigger Co-authored-by: lonesomegeek <[email protected]> * Work/duge/93 (#145) * cleanup + doc * cleanup * adding doc * working links * good dockerfile * minor corrections Co-authored-by: lonesomegeek <[email protected]> * ready for beta1 * adjust project definitions * adding old sample links * adding release notes * minor modifications * minor modifications * adding benchmark project launcher * cleanup * cleanup in docs * minor modifications * minor modifications * prepare for v5 Co-authored-by: lonesomegeek <[email protected]>
1 parent 8a3bb8a commit 651cfdb

File tree

365 files changed

+18395
-6250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

365 files changed

+18395
-6250
lines changed

LSG.GenericCrud.Benchmark/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BenchmarkDotNet.Artifacts
2+
results
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": ".NET Core Launch (console)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/LSG.GenericCrud.Benchmark.dll",
13+
"args": [],
14+
"cwd": "${workspaceFolder}",
15+
"console": "internalConsole",
16+
"stopAtEntry": false
17+
},
18+
{
19+
"name": ".NET Core Attach",
20+
"type": "coreclr",
21+
"request": "attach",
22+
"processId": "${command:pickProcess}"
23+
}
24+
]
25+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/LSG.GenericCrud.Benchmark.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/LSG.GenericCrud.Benchmark.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"${workspaceFolder}/LSG.GenericCrud.Benchmark.csproj",
36+
"/property:GenerateFullPaths=true",
37+
"/consoleloggerparameters:NoSummary"
38+
],
39+
"problemMatcher": "$msCompile"
40+
}
41+
]
42+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<ApplicationIcon />
7+
<StartupObject />
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
12+
<PackageReference Include="Bogus" Version="28.4.4" />
13+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.1" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ProjectReference Include="..\LSG.GenericCrud\LSG.GenericCrud.csproj" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using LSG.GenericCrud.Models;
2+
using LSG.GenericCrud.Repositories;
3+
using Microsoft.EntityFrameworkCore;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Text;
7+
8+
namespace LSG.GenericCrud.Benchmark.Models
9+
{
10+
public class BenchmarkingContext :
11+
BaseDbContext,
12+
IDbContext
13+
{
14+
public BenchmarkingContext(DbContextOptions options, IServiceProvider serviceProvider) : base(options, serviceProvider)
15+
{
16+
}
17+
18+
public DbSet<Item> Items { get; set; }
19+
public DbSet<HistoricalEvent> Events { get; set; }
20+
public DbSet<HistoricalChangeset> Changesets { get; set; }
21+
}
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using LSG.GenericCrud.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace LSG.GenericCrud.Benchmark.Models
7+
{
8+
public class Item :
9+
IEntity<Guid>
10+
{
11+
public Guid Id { get; set; }
12+
public string Name { get; set; }
13+
}
14+
}

LSG.GenericCrud.Benchmark/Program.cs

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
using BenchmarkDotNet.Attributes;
2+
using BenchmarkDotNet.Configs;
3+
using BenchmarkDotNet.Engines;
4+
using BenchmarkDotNet.Running;
5+
using Bogus;
6+
using LSG.GenericCrud.Benchmark.Models;
7+
using LSG.GenericCrud.Controllers;
8+
using LSG.GenericCrud.Repositories;
9+
using LSG.GenericCrud.Services;
10+
using Microsoft.AspNetCore.Mvc;
11+
using Microsoft.EntityFrameworkCore;
12+
using System;
13+
using System.Collections.Generic;
14+
using System.Linq;
15+
using System.Threading.Tasks;
16+
17+
namespace LSG.GenericCrud.Benchmark
18+
{
19+
public class MyController :
20+
ControllerBase,
21+
ICrudController<Guid, Item>
22+
{
23+
private readonly ICrudController<Guid, Item> _controller;
24+
25+
public MyController(ICrudController<Guid, Item> controller)
26+
{
27+
28+
_controller = controller;
29+
}
30+
31+
public Task<ActionResult<Item>> Create([FromBody] Item entity) => _controller.Create(entity);
32+
33+
public Task<ActionResult<Item>> Delete(Guid id) => _controller.Delete(id);
34+
35+
public Task<ActionResult<IEnumerable<Item>>> GetAll() => _controller.GetAll();
36+
37+
public Task<ActionResult<Item>> GetById(Guid id) => _controller.GetById(id);
38+
39+
public Task<IActionResult> HeadById(Guid id) => _controller.HeadById(id);
40+
41+
public Task<IActionResult> Update(Guid id, [FromBody] Item entity) => _controller.Update(id, entity);
42+
}
43+
[MemoryDiagnoser]
44+
[MinColumn, MaxColumn, MeanColumn, MedianColumn]
45+
[SimpleJob(RunStrategy.Throughput, launchCount: 2, warmupCount: 1, targetCount: 5)]
46+
[RPlotExporter]
47+
public class CrudBenchmark
48+
{
49+
private readonly ICrudController<Guid, Item> _controller;
50+
private readonly ICrudRepository _repository;
51+
private readonly ICrudService<Guid, Item> _service;
52+
private readonly IDbContext _context;
53+
private readonly List<Item> _entities;
54+
private readonly Item _entity;
55+
56+
public CrudBenchmark()
57+
{
58+
var optionsBuilder = new DbContextOptionsBuilder()
59+
.UseInMemoryDatabase("test");
60+
//.UseSqlServer("server=(localdb)\\mssqllocaldb;Initial Catalog=BenchmarkDb");
61+
_context = new BenchmarkingContext(optionsBuilder.Options, null);
62+
((DbContext)_context).Database.EnsureCreated();
63+
_repository = new CrudRepository(_context);
64+
_service = new CrudServiceBase<Guid, Item>(_repository);
65+
_controller = new CrudControllerBase<Guid, Item>(_service);
66+
67+
var entityFaker = new Faker<Item>().
68+
RuleFor(_ => _.Id, Guid.NewGuid()).
69+
RuleFor(_ => _.Name, _ => _.Lorem.Word());
70+
_entities = entityFaker.Generate(5);
71+
_entity = entityFaker.Generate();
72+
}
73+
74+
[Benchmark]
75+
public async Task Create() => await _controller.Create(new Item());
76+
[Benchmark]
77+
public async Task Read() => await _controller.GetById(Guid.NewGuid());
78+
[Benchmark]
79+
public async Task ReadAll() => await _controller.GetAll();
80+
[Benchmark]
81+
public async Task Update() => await _controller.Update(Guid.NewGuid(), new Item());
82+
[Benchmark]
83+
public async Task Delete() => await _controller.Delete(Guid.NewGuid());
84+
[Benchmark]
85+
public async Task CreateAndRead()
86+
{
87+
var createdEntityResult = await _controller.Create(new Item());
88+
var createdEntity = ((Item)((CreatedAtActionResult)createdEntityResult.Result).Value);
89+
await _controller.GetById(createdEntity.Id);
90+
}
91+
[Benchmark]
92+
public async Task CreateAndDelete()
93+
{
94+
var createdEntityResult = await _controller.Create(new Item());
95+
var createdEntity = ((Item)((CreatedAtActionResult)createdEntityResult.Result).Value);
96+
await _controller.Delete(createdEntity.Id);
97+
}
98+
[Benchmark]
99+
public async Task CreateAndUpdate()
100+
{
101+
var createdEntityResult = await _controller.Create(new Item());
102+
var createdEntity = ((Item)((CreatedAtActionResult)createdEntityResult.Result).Value);
103+
createdEntity.Name = "Modified Value";
104+
var updatedEntityResult = await _controller.Update(createdEntity.Id, createdEntity);
105+
}
106+
}
107+
108+
[MemoryDiagnoser]
109+
[MinColumn, MaxColumn, MeanColumn, MedianColumn]
110+
[SimpleJob(RunStrategy.Throughput, launchCount: 2, warmupCount: 1, targetCount: 5)]
111+
[RPlotExporter]
112+
public class HistoricalCrudBenchmark
113+
{
114+
private readonly ICrudController<Guid, Item> _controller;
115+
private readonly ICrudRepository _repository;
116+
private readonly ICrudService<Guid, Item> _service;
117+
private readonly IDbContext _context;
118+
private readonly List<Item> _entities;
119+
private readonly Item _entity;
120+
121+
public HistoricalCrudBenchmark()
122+
{
123+
var optionsBuilder = new DbContextOptionsBuilder()
124+
.UseInMemoryDatabase("test");
125+
//.UseSqlServer("server=(localdb)\\mssqllocaldb;Initial Catalog=BenchmarkDb");
126+
_context = new BenchmarkingContext(optionsBuilder.Options, null);
127+
((DbContext)_context).Database.EnsureCreated();
128+
_repository = new CrudRepository(_context);
129+
_service = new HistoricalCrudServiceBase<Guid, Item>(
130+
new CrudServiceBase<Guid, Item>(_repository),
131+
_repository,
132+
null,
133+
null,
134+
null);
135+
_controller = new HistoricalCrudControllerBase<Guid, Item>(
136+
new CrudControllerBase<Guid, Item>(new CrudServiceBase<Guid, Item>(_repository)),
137+
(IHistoricalCrudService<Guid, Item>)_service);
138+
139+
var entityFaker = new Faker<Item>().
140+
RuleFor(_ => _.Id, Guid.NewGuid()).
141+
RuleFor(_ => _.Name, _ => _.Lorem.Word());
142+
_entities = entityFaker.Generate(5);
143+
_entity = entityFaker.Generate();
144+
}
145+
146+
[Benchmark]
147+
public async Task Create() => await _controller.Create(new Item());
148+
[Benchmark]
149+
public async Task Read() => await _controller.GetById(Guid.NewGuid());
150+
[Benchmark]
151+
public async Task ReadAll() => await _controller.GetAll();
152+
[Benchmark]
153+
public async Task Update() => await _controller.Update(Guid.NewGuid(), new Item());
154+
[Benchmark]
155+
public async Task Delete() => await _controller.Delete(Guid.NewGuid());
156+
[Benchmark]
157+
public async Task CreateAndRead()
158+
{
159+
var createdEntityResult = await _controller.Create(new Item());
160+
var createdEntity = ((Item)((CreatedAtActionResult)createdEntityResult.Result).Value);
161+
await _controller.GetById(createdEntity.Id);
162+
}
163+
[Benchmark]
164+
public async Task CreateAndDelete()
165+
{
166+
var createdEntityResult = await _controller.Create(new Item());
167+
var createdEntity = ((Item)((CreatedAtActionResult)createdEntityResult.Result).Value);
168+
await _controller.Delete(createdEntity.Id);
169+
}
170+
[Benchmark]
171+
public async Task CreateAndUpdate()
172+
{
173+
var createdEntityResult = await _controller.Create(new Item());
174+
var createdEntity = ((Item)((CreatedAtActionResult)createdEntityResult.Result).Value);
175+
createdEntity.Name = "Modified Value";
176+
var updatedEntityResult = await _controller.Update(createdEntity.Id, createdEntity);
177+
}
178+
}
179+
class Program
180+
{
181+
// static void Main(string[] args)
182+
// {
183+
// var summary = BenchmarkRunner
184+
// .Run<HistoricalCrudBenchmark>(/*new DebugInProcessConfig()*/);
185+
// BenchmarkRunner.Run<CrudBenchmark>();
186+
// //.Run<IntroSetupCleanupIteration>(/*new DebugInProcessConfig()*/);
187+
// Console.WriteLine(summary);
188+
// }
189+
190+
public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
191+
192+
}
193+
}

LSG.GenericCrud.Dto/Helpers/ServiceHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public static class ServiceHelpers
1414
/// <param name="services">The services.</param>
1515
public static void AddCrudDto(this IServiceCollection services)
1616
{
17-
services.AddScoped(typeof(CrudService<,,>));
18-
services.AddScoped(typeof(HistoricalCrudService<,,>));
17+
services.AddScoped(typeof(CrudServiceBase<,,>));
18+
services.AddScoped(typeof(HistoricalCrudServiceBase<,,>));
1919
}
2020
}
2121
}

LSG.GenericCrud.Dto/LSG.GenericCrud.Dto.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<Version>4.1.1</Version>
4+
<TargetFramework>netstandard2.1</TargetFramework>
5+
<Version>5.0.0</Version>
66
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
77
<PackageId>LSG.GenericCrud.Dto</PackageId>
88
<Authors>lonesomegeek</Authors>
@@ -15,7 +15,7 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="AutoMapper" Version="6.1.1" />
18+
<PackageReference Include="AutoMapper" Version="9.0.0" />
1919
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
2020
</ItemGroup>
2121

0 commit comments

Comments
 (0)