Maestria.TypeProviders 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Maestria.TypeProviders --version 1.1.0                
NuGet\Install-Package Maestria.TypeProviders -Version 1.1.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="Maestria.TypeProviders" Version="1.1.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.
paket add Maestria.TypeProviders --version 1.1.0                
#r "nuget: Maestria.TypeProviders, 1.1.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.
// Install Maestria.TypeProviders as a Cake Addin
#addin nuget:?package=Maestria.TypeProviders&version=1.1.0

// Install Maestria.TypeProviders as a Cake Tool
#tool nuget:?package=Maestria.TypeProviders&version=1.1.0                

Maestria.Type.Providers

Build status NuGet MyGet Apimundo

Build History

donate

What is Maestria.Type.Providers?

Source Generator pack to increase productivity and improve source code writing.

How install and configure package?

First, install Maestria.Type.Providers from the dotnet cli command line:

dotnet add package Maestria.TypeProviders

Providers x Dependencies

This package does not include dependencies references when installed on your project, its only generate source code files.
You need install thirds dependencies to compile your project according to the features used, bellow instructions of source generator providers:

  • ExcelProvider: Generated strong data sctruct and factory class to load xls/xlsx data.
  • OpenApiProvider: Generate HTTP client from OpenApi / Swagger specification.

ExcelProvider

Generate strong data struct and class factory to load excel data from xls/xlsx template.

Attribute: ExcelProvider

Dependencies

Dependencies install

dotnet add package Maestria.FluentCast
dotnet add package ClosedXML

Source code sample

Use case sample

// The relative path is based at the source code file location.
// In this example the first page was used as none were explicitly entered.
[ExcelProvider(TemplatePath = @"../../resources/Excel.xlsx")]
public partial class MyExcelData
{
}

var data = MyExcelDataFactory.Load(filePath);
foreach (var item in data)
  // Access strong typing by "item.<field-name>"

Use case sample two

// The relative path is based at the source code file location.
// Loadind data struct from second page
[ExcelProvider(TemplatePath = @"../../resources/Excel.xlsx", SheetName = "Plan2")]
public partial class MyExcelData
{
}

var data = MyExcelDataFactory.Load(filePath, "Plan2");
foreach (var item in data)
  // Access strong typing by "item.<field-name>"

Generator engine:

  • Nullable types: To create a nullable property, seed excel template file with one row cell empty, and another not empty.
  • Decimal types: To create decimal property, seed one row of cell with floating point value.

Good practices: Don't use big file by template, this file is used always you need recreated source code. Big file impact is slow build time.


OpenApiProvider

Provider to generate source code HTTP client from OpenApi / Swagger specification.

It's planned used NSwagStudio engine with .NET 5 source generator.
This package allows automatized generation code.

...As soon as possible


Troubleshooting

Optional configuration in VS Code: To view the automatically generated codes it is necessary to indicate to write it to disk with the configuration in the .csproj file.
On CompilerGeneratedFilesOutputPath property its configured with /../generated/$(MSBuildProjectName). This folder is one level above of file project on this sample.
This mode allow see generated files, but not works go to navigation feature of VS Code.


<PropertyGroup>
    <CompilerGeneratedFilesOutputPath>$(MSBuildProjectDirectory)/../generated/$(MSBuildProjectName)</CompilerGeneratedFilesOutputPath>
    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>

Optional configuration in VS Code: To allow go to navigation feature you need write files at solution level.

Problem's: The source code generated will be used on next build, to solve problems of duplicated classes, it's need removed generated files before build.
On next build, if there was no change on yout source code used by generators, the files has no generated. You need force a rebuild with dotnet build --no-incremental <args> to regenerate files.


<PropertyGroup>
    <CompilerGeneratedFilesOutputPath>$(MSBuildProjectDirectory)/generated/$(MSBuildProjectName)</CompilerGeneratedFilesOutputPath>
    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>


<Target Name="ExcludeGenerated" BeforeTargets="AssignTargetPaths">
    <ItemGroup>
        <Generated Include="/generated/**/*.cs" />
        <Compile Remove="@(Generated)" />
    </ItemGroup>
    <Delete Files="@(Generated)" />
</Target>

Sample of .csproj file


buy-me-a-coffee smile.png

If my contributions helped you, please help me buy a coffee 😄

donate

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
1.1.2 456 8/27/2022
1.1.1 404 8/27/2022
1.1.0 396 8/27/2022
1.0.10 395 8/27/2022
1.0.8 445 5/11/2022
1.0.7 370 7/26/2021
1.0.6 378 6/23/2021
1.0.5 366 6/7/2021
1.0.4 317 5/20/2021
1.0.2 341 5/20/2021
1.0.1 332 5/20/2021
1.0.0 342 5/19/2021
0.0.14 369 5/10/2021