SourceGenerator.Fluent 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SourceGenerator.Fluent --version 0.2.0
                    
NuGet\Install-Package SourceGenerator.Fluent -Version 0.2.0
                    
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="SourceGenerator.Fluent" Version="0.2.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SourceGenerator.Fluent" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SourceGenerator.Fluent">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SourceGenerator.Fluent --version 0.2.0
                    
#r "nuget: SourceGenerator.Fluent, 0.2.0"
                    
#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.
#addin nuget:?package=SourceGenerator.Fluent&version=0.2.0
                    
Install SourceGenerator.Fluent as a Cake Addin
#tool nuget:?package=SourceGenerator.Fluent&version=0.2.0
                    
Install SourceGenerator.Fluent as a Cake Tool

Build status

Fluent.Generator

This tool generates design classes of ftl files. It creates boilerplate code to use with Fluent.Net

Getting Started

Install the nuget package, add an FTL file to your project, set it as additonal file.

<ItemGroup>
    <AdditionalFiles Include="**/*.ftl" />
</ItemGroup>

Having a file like this named TestFtl.ftl:

# Simple things are simple.
hello-world = Hello, world!


# Complex things are possible.
shared-photos =
    {$userName} {$photoCount ->
        [one] added a new photo
       *[other] added {$photoCount} new photos
    } to {$userGender ->
        [male] his stream
        [female] her stream
       *[other] their stream
    }.  


And you can access the translations in code using

var firstString = TestFtl.HelloWorld;
var seccondString = TestFtl.SharedPhotos[userName:"Bob", photoCount:3, userGender:"male"];

Parameter Type

Fluent.Generator trys to guess the type of parameters.

# $duration (Number) - The duration in seconds.
time-elapsed = Time elapsed: { $duration }s.

will result in

public string this[System.Double duration]
            {
                get
                {
                    return this.messageContext.Format(this.messageContext.GetMessage("time-elapsed"), new Dictionary<string, object>{{"duration", duration}});
                }
            }

In order to get correct types, you need to document those in the comments. If a line in the comments start with $<variable name> followed by the type in round parenthise () followed by a dash - and the variable exists we'll set the parameter type to the provided. You can use .Net types and the string Number which will interpreted as double.

You can ommit the type and the parethisees. In that case the object type is used.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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.3.2 475 3/24/2025
0.3.1 394 3/24/2025
0.3.0 387 3/24/2025
0.2.2 133 3/20/2025
0.2.1 135 3/20/2025
0.2.0 141 3/19/2025