Dekiru.DtoGenerator 0.0.9

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Dekiru.DtoGenerator --version 0.0.9                
NuGet\Install-Package Dekiru.DtoGenerator -Version 0.0.9                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dekiru.DtoGenerator" Version="0.0.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dekiru.DtoGenerator --version 0.0.9                
#r "nuget: Dekiru.DtoGenerator, 0.0.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Dekiru.DtoGenerator as a Cake Addin
#addin nuget:?package=Dekiru.DtoGenerator&version=0.0.9

// Install Dekiru.DtoGenerator as a Cake Tool
#tool nuget:?package=Dekiru.DtoGenerator&version=0.0.9                

DTO Generator

A Source Generator that generates DTO classes from existing classes. Configuration is done via attributes, as described below. All generated code should be compatible with .NET Standard 2.0 or later.

The DTO generator will, by design, not include properties from any base class. If you have that need, generate a DTO from the base class and have your other DTO inherit from that one.

The DTO generator will also only include public instance properties.

Attributes

The following attributes are used to configure the DTO generator:

Class attributes

[Dto]

Marks a class for DTO generation. A class may have multiple DTOs generated for it, each with a different set of properties.

[Dto("Foo", "DtoNamespace")]
[Dto("Bar", "DtoNamespace2")]

Or

[Dto(["Foo", "Bar"], "DtoNamespace")]

The attribute has the following parameters:

  • name (string | string[]): The name of the DTO. This is used as the class name of the generated DTO. The $ variable can be used to reference the name of the source class.
  • namespace (string): The namespace of the generated DTO. The $ variable can be used to reference the namespace of the source class.
  • baseClass (string, optional): The base class of the generated DTO.
  • propertyStrategy (PropertyStrategy, optional): The strategy to use when generating properties. Default is PropertyStrategy.Implicit.
    • Implicit: Generate all properties that are not marked with [Dto.Exclude].
    • Explicit: Generate only properties that are marked with [Dto.Include].
[Using]

Adds any number of using directives to the generated code. This attribute must be in the same attribute group as a [Dto] attribute. The attribute has the following parameters:

  • namespaces (string[]): The namespaces to add.
  • appliesTo (params string[], optional): A list of DTO names to which the using directives apply.
[Partial]

Indicates that the generated DTO should be a partial class. The attribute has the following parameters:

  • appliesTo (params string[], optional): A list of DTO names to which the partial class attribute applies.

Property attributes

[Type]

Specifies a conversion function to use when copying a property. The attribute has the following parameters:

  • type (string): The type of the property in the generated DTO.
  • expression (string): An expression that converts the property value. The expression is evaluated in the context of the source object. The expression must return a value of the same type as the property. The expression may reference the property value using the $ variable.
  • appliesTo (params string[], optional): A list of DTO names to which the type conversion applies.
[Exclude]

Excludes a property from the generated DTO. This attribute has no effect when the property strategy is PropertyStrategy.Explicit. The attribute has the following parameters:

  • appliesTo (params string[], optional): A list of DTO names from which to exclude the property.
[Include]

Includes a property in the generated DTO. This attribute has no effect when the property strategy is PropertyStrategy.Implicit. The attribute has the following parameters:

  • appliesTo (params string[], optional): A list of DTO names to which to include the property.
[NoCopy]

The default behavior of the DTO generator is to copy all other attributes of a property to the generated DTO. This attribute prevents this behavior:

[NoCopy, JsonIgnore]

The attribute has the following parameters:

  • appliesTo (params string[], optional): A list of DTO names to which the no-copy attribute applies.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.10 40 11/18/2024
0.0.9 45 11/18/2024
0.0.8 80 11/12/2024
0.0.7 78 11/12/2024
0.0.6 80 11/11/2024
0.0.5 80 11/11/2024
0.0.4 79 11/8/2024
0.0.3 73 11/8/2024
0.0.2 74 11/8/2024
0.0.1 77 11/8/2024