Vogen Help

Installing Vogen

dotnet add package Vogen --version 4.0.14

NuGet\Install-Package Vogen -Version 4.0.14

<PackageReference Include="Vogen" Version="4.0.14" />

When added to your project, the source generator generates the wrappers for your primitives and the code analyzer will let you know if you try to create invalid Value Objects.

Vogen consists of two dlls:

  1. Vogen.dll - this is the source generator and analyzers and is not needed at runtime

  2. Vogen.SharedTypes.dll - this contains the types that are referenced at runtime, e.g. ValueObjectValidationException and ValueObjectOrError which is used by the TryFrom method.

Unlike using some other source generators, specifying PrivateAssets="all" ExcludeAssets="runtime" with Vogen will cause exceptions at runtime because of missing types.

Vogen.SharedTypes.dll is about 18KB, so will add little to your application's size. It is referenced on its own. Here is a snippet from a deps.json file with it specified:

"Vogen/4.0.14": { "runtime": { "lib/net8.0/Vogen.SharedTypes.dll": { "assemblyVersion": "4.0.0.0", "fileVersion": "4.0.14" } }
Last modified: 23 November 2024