-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved WithObject to generated code, added FromTemplate (#43)
* Releasing v2.4-alpha * Refactored template storage * Refactores DTO mechanism * Moved license file * Added Directory.Build.props file
- Loading branch information
Showing
77 changed files
with
1,271 additions
and
515 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Contributing | ||
|
||
This project welcomes issues and pull requests, although it is an opinionated project. There are many ways to approach this particular problem, and I (Mel Grubb) captured my own preferences when I started this project. | ||
|
||
# Building | ||
|
||
# Testing | ||
|
||
There are currently five test projects. | ||
- BuilderGenerator.Tests.Core: Defines the domain objects used by other test projects. | ||
- BuilderGenerator.Tests.Unit: Directly exercises the builder mechanism to provide fast feedback and verification. | ||
- BuilderGenerator.Tests.Integration.Net60: Uses the builder generator in a more real-world way to create builders for a sample Net 6 library project. | ||
- BuilderGenerator.Tests.Integration.Net70: Same thing, but targeting .Net 7 | ||
- BuilderGenerator.Tests.Integration.Net80: Same thing, but targeting .Net 8 |
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
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
11 changes: 0 additions & 11 deletions
11
src/BuilderGenerator.IntegrationTests.Core/Models/Entities/README.md
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
src/BuilderGenerator.IntegrationTests.Core/Models/Entities/_ReadMe.md
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/BuilderGenerator.IntegrationTests.Net60/Builders/CollectionTypeSampleBuilder.cs
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...s.Core/Models/Entities/AuditableEntity.cs → ...s.Core/Models/Entities/AuditableEntity.cs
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
2 changes: 1 addition & 1 deletion
2
.../Models/Entities/CollectionTypesSample.cs → .../Models/Entities/CollectionTypesSample.cs
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
2 changes: 1 addition & 1 deletion
2
...ationTests.Core/Models/Entities/Entity.cs → ...ator.Tests.Core/Models/Entities/Entity.cs
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
4 changes: 2 additions & 2 deletions
4
...rationTests.Core/Models/Entities/Order.cs → ...rator.Tests.Core/Models/Entities/Order.cs
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
2 changes: 1 addition & 1 deletion
2
...onTests.Core/Models/Entities/OrderItem.cs → ...r.Tests.Core/Models/Entities/OrderItem.cs
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
10 changes: 2 additions & 8 deletions
10
...grationTests.Core/Models/Entities/User.cs → ...erator.Tests.Core/Models/Entities/User.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace BuilderGenerator.IntegrationTests.Core.Models.Entities; | ||
namespace BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
public partial class User : AuditableEntity | ||
public class User : AuditableEntity | ||
{ | ||
public string FirstName { get; set; } | ||
public string LastName { get; set; } | ||
public string? MiddleName { get; set; } | ||
Check warning on line 9 in src/BuilderGenerator.Tests.Core/Models/Entities/User.cs GitHub Actions / build
|
||
} | ||
|
||
public partial class User | ||
{ | ||
public ICollection<Order> Orders { get; set; } = new List<Order>(); | ||
} |
2 changes: 1 addition & 1 deletion
2
...ionTests.Core/Models/Enums/OrderStatus.cs → ...or.Tests.Core/Models/Enums/OrderStatus.cs
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
2 changes: 1 addition & 1 deletion
2
...Generator.IntegrationTests.Core/README.md → src/BuilderGenerator.Tests.Core/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# BuilderGenerator.Core # | ||
# BuilderGenerator.Tests.Core | ||
|
||
This project defines the object model used in the other framework-specific tests. It is defined as a netstandard2.0 library so that it can be used with the widest variety of consuming projects. |
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
8 changes: 8 additions & 0 deletions
8
src/BuilderGenerator.Tests.Integration.Net60/Builders/CollectionTypeSampleBuilder.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
namespace BuilderGenerator.Tests.Integration.Net60.Builders; | ||
|
||
[BuilderFor(typeof(CollectionTypesSample))] | ||
public partial class CollectionTypeSampleBuilder | ||
{ | ||
} |
4 changes: 2 additions & 2 deletions
4
...ationTests.Net60/Builders/OrderBuilder.cs → ...ntegration.Net60/Builders/OrderBuilder.cs
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
4 changes: 2 additions & 2 deletions
4
...nTests.Net60/Builders/OrderItemBuilder.cs → ...ration.Net60/Builders/OrderItemBuilder.cs
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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...rationTests.Net60/Builders/UserBuilder.cs → ...Integration.Net60/Builders/UserBuilder.cs
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
4 changes: 2 additions & 2 deletions
4
...enerator.IntegrationTests.Net60/README.md → ...nerator.Tests.Integration.Net60/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# BuilderGenerator.Sample.Net60.FromProject | ||
# BuilderGenerator.Sample.Net70.FromProject | ||
|
||
This project provides tests the BuilderGenerator package being used in a .Net 6.0 project using a simple series of inter-related classes defined in the BuiderGenerator.Test.Core project. | ||
This project provides tests the BuilderGenerator package being used in a .Net 7.0 project using a simple series of inter-related classes defined in the BuiderGenerator.Test.Core project. | ||
|
||
The reference to the BuilderGenerator is a direct project reference, so it can be used to rapidly check the results of changes, but does not represent the real-world usage of the generator. It tests the functionality of the builder, but not the deployment mechanism. |
6 changes: 3 additions & 3 deletions
6
...egrationTests.Net60/Tests/BuilderTests.cs → ...s.Integration.Net60/Tests/BuilderTests.cs
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
8 changes: 4 additions & 4 deletions
8
...ionTests.Net60/Tests/OrderBuilderTests.cs → ...egration.Net60/Tests/OrderBuilderTests.cs
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
6 changes: 3 additions & 3 deletions
6
...tionTests.Net60/Tests/UserBuilderTests.cs → ...tegration.Net60/Tests/UserBuilderTests.cs
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
19 changes: 19 additions & 0 deletions
19
src/BuilderGenerator.Tests.Integration.Net70/BuilderGenerator.Tests.Integration.Net70.csproj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\BuilderGenerator.Tests.Core\BuilderGenerator.Tests.Core.csproj" /> | ||
<ProjectReference Include="..\BuilderGenerator.Tests.Unit\BuilderGenerator.Tests.Unit.csproj" /> | ||
<ProjectReference Include="..\BuilderGenerator\BuilderGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" /> | ||
<PackageReference Include="NUnit" Version="3.13.3" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> | ||
<PackageReference Include="Shouldly" Version="4.2.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
8 changes: 8 additions & 0 deletions
8
src/BuilderGenerator.Tests.Integration.Net70/Builders/CollectionTypeSampleBuilder.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
namespace BuilderGenerator.Tests.Integration.Net70.Builders; | ||
|
||
[BuilderFor(typeof(CollectionTypesSample))] | ||
public partial class CollectionTypeSampleBuilder | ||
{ | ||
} |
29 changes: 29 additions & 0 deletions
29
src/BuilderGenerator.Tests.Integration.Net70/Builders/OrderBuilder.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
namespace BuilderGenerator.Tests.Integration.Net70.Builders; | ||
|
||
[BuilderFor(typeof(Order), true)] | ||
public partial class OrderBuilder | ||
{ | ||
public static OrderBuilder Simple() | ||
{ | ||
var builder = new OrderBuilder() | ||
.WithId(Guid.NewGuid); | ||
|
||
return builder; | ||
} | ||
|
||
public static OrderBuilder Typical() | ||
{ | ||
var builder = Simple() | ||
.WithItems( | ||
() => new List<OrderItem> | ||
{ | ||
OrderItemBuilder.Simple().Build(), | ||
}); | ||
|
||
return builder; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/BuilderGenerator.Tests.Integration.Net70/Builders/OrderItemBuilder.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using BuilderGenerator.Tests.Core.Models.Entities; | ||
|
||
namespace BuilderGenerator.Tests.Integration.Net70.Builders; | ||
|
||
[BuilderFor(typeof(OrderItem))] | ||
public partial class OrderItemBuilder | ||
{ | ||
public static OrderItemBuilder Simple() | ||
{ | ||
var builder = new OrderItemBuilder() | ||
.WithId(Guid.NewGuid); | ||
|
||
return builder; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/BuilderGenerator.Tests.Integration.Net70/Builders/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Partial Builders # | ||
|
||
This folder contains the hand-written half of any builders. Create static factory methods for each well-known or named object instance you want to create. | ||
|
||
## Suggestions ## | ||
|
||
In addition to specific factory methods, you should define some general-purpose methods such as: | ||
|
||
### Simple/Minimal ### | ||
|
||
Creates the simplest, most minimal instance that will pass validation. Only fill in the required fields, and leave everything else at their default values. This can serve as the starting point for other, more specific factory methods. For instance, a minimal Customer may be missing address information, and would have no orders. | ||
|
||
### Typical ### | ||
|
||
This method should return a "typical" example of the class. For a Customer entity, this might mean that the shipping and billing addresses are filled in, and the Customer has multiple orders in various states. |
Oops, something went wrong.