From 2c788c87773b5fc9d73d85d180af808ce52f13b0 Mon Sep 17 00:00:00 2001 From: james Date: Sun, 9 Mar 2025 17:16:12 +0100 Subject: [PATCH 1/2] set basic README.md --- DtoGenerator/DtoGenerator.csproj | 2 +- README.md | 63 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/DtoGenerator/DtoGenerator.csproj b/DtoGenerator/DtoGenerator.csproj index 00e74ef..05384cb 100644 --- a/DtoGenerator/DtoGenerator.csproj +++ b/DtoGenerator/DtoGenerator.csproj @@ -15,7 +15,7 @@ readme.md true https://github.com/Ten-James/DtoGenerator/blob/master/LICENSE.md - james-dto-generator-library + TenJames.DtoGenerator diff --git a/README.md b/README.md index cdace5c..e068d12 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,66 @@ Stop writing boilerplate code for your DTOs. This package will generate them for you. +# Introduction + +Since its generator library, and it works on compile time you have to set the output type, for the dependency, + +```xml + +``` + +# Example + +```csharp + +[GenerateDto(DtoType.All)] +class User +{ + [MapTo(typeof(string), "src.ToString()")] + [DtoVisibility(DtoType.AllRead | DtoType.Update)] + public Guid Id { get; set; } + + public string Name { get; set; } + + [DtoIgnore] + public string Password { get; set; } + +} + + +// will generate the following DTOs + +class UserReadDto +{ + [Required] public string Id { get; set; } + [Required] public string Name { get; set; } +} + +class UserReadDetailDto +{ + [Required] public string Id { get; set; } + [Required] public string Name { get; set; } +} + +class UserCreateDto +{ + [Required] public string Name { get; set; } +} + +class UserUpdateDto +{ + [Required] public string Name { get; set; } +} + + + +``` + +# Attributes + +Main usage ate defined with attrubutes. The following attributes are available: + +- `GenerateDtoAttribute`: Entry point for the generator. It will generate a DTO for the class where it is defined. +- `DtoIgnoreAttribute`: Ignore a property from the DTO generation. +- `MapToAttribute`: Mapping a property with function to the DTO (read and detail) +- `MapFromAttribute`: Mapping a property with function from the DTO (write) From 13bf53fd3eeee5db505710911d5f673f4b90177e Mon Sep 17 00:00:00 2001 From: james Date: Sun, 9 Mar 2025 17:18:44 +0100 Subject: [PATCH 2/2] fix pipeline --- .github/workflows/publish.yml | 10 ++++++---- DtoGenerator/DtoGenerator.csproj | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 343e176..e9b29e7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -34,11 +34,13 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 + - run: dotnet build --configuration Release + # Create the NuGet package in the folder from the environment variable NuGetDirectory - run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} # Publish the NuGet package as an artifact, so they can be used in the following jobs - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: nuget if-no-files-found: error @@ -54,7 +56,7 @@ jobs: uses: actions/setup-dotnet@v4 # Download the NuGet package created in the previous job - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: nuget path: ${{ env.NuGetDirectory }} @@ -67,7 +69,7 @@ jobs: # If some rules are not applicable, you can disable them # using the --excluded-rules or --excluded-rule-ids option - name: Validate package - run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg") + run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg") --excluded-rules Symbols,IconMustBeSet,LicenseMustBeSet run_test: runs-on: ubuntu-latest @@ -87,7 +89,7 @@ jobs: needs: [ validate_nuget, run_test ] steps: # Download the NuGet package created in the previous job - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: nuget path: ${{ env.NuGetDirectory }} diff --git a/DtoGenerator/DtoGenerator.csproj b/DtoGenerator/DtoGenerator.csproj index 05384cb..cb8c137 100644 --- a/DtoGenerator/DtoGenerator.csproj +++ b/DtoGenerator/DtoGenerator.csproj @@ -16,6 +16,12 @@ true https://github.com/Ten-James/DtoGenerator/blob/master/LICENSE.md TenJames.DtoGenerator + MIT + Generator DTO WebApi + + + + bin\Release\DtoGenerator.xml