maestrianet - Maestria.TypeProviders 1.1.2

.NET Source Generator for Excel.

PM> Install-Package Maestria.TypeProviders -Version 1.1.2 -Source https://www.myget.org/F/maestrianet/api/v3/index.json

Copy to clipboard

> nuget.exe install Maestria.TypeProviders -Version 1.1.2 -Source https://www.myget.org/F/maestrianet/api/v3/index.json

Copy to clipboard

> dotnet add package Maestria.TypeProviders --version 1.1.2 --source https://www.myget.org/F/maestrianet/api/v3/index.json

Copy to clipboard
<PackageReference Include="Maestria.TypeProviders" Version="1.1.2" />
Copy to clipboard
source https://www.myget.org/F/maestrianet/api/v3/index.json

nuget Maestria.TypeProviders  ~> 1.1.2
Copy to clipboard

> choco install Maestria.TypeProviders --version 1.1.2 --source https://www.myget.org/F/maestrianet/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "maestrianet" -SourceLocation "https://www.myget.org/F/maestrianet/api/v2"
Install-Module -Name "Maestria.TypeProviders" -RequiredVersion "1.1.2" -Repository "maestrianet" 
Copy to clipboard

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.Extensions.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.

<!-- Enable source disk file write to correct IDE's works -->
<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.

<!-- Enable source disk file write to correct IDE's works -->
<PropertyGroup>
    <CompilerGeneratedFilesOutputPath>$(MSBuildProjectDirectory)/generated/$(MSBuildProjectName)</CompilerGeneratedFilesOutputPath>
    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>

<!-- Remove files on build start to solve recreate bug message "alwaready exists" -->
<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 :D

donate

Owners

Fábio Naspolini

Authors

Fábio Monteiro Naspolini

Project URL

https://github.com/MaestriaNet/TypeProviders

License

Unknown

Tags

SourceGenerator Source Generator Excel Helper Extension Extensions Productivity Maestria Mastery C# .NET CSharp

Info

26 total downloads
2 downloads for version 1.1.2
Download (18.45 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.1.2 18.45 KB Sat, 27 Aug 2022 05:01:34 GMT 2
1.1.1 18.44 KB Sat, 27 Aug 2022 04:58:32 GMT 2
1.1.0 18.35 KB Sat, 27 Aug 2022 04:39:34 GMT 2
1.0.10 17.65 KB Sat, 27 Aug 2022 04:10:01 GMT 2
1.0.8 2.22 MB Wed, 11 May 2022 14:31:15 GMT 2
1.0.7 2.22 MB Mon, 09 Aug 2021 00:14:52 GMT 2
1.0.6 2.21 MB Mon, 26 Jul 2021 00:45:50 GMT 2
1.0.5 2.21 MB Mon, 07 Jun 2021 00:58:38 GMT 2
1.0.4 2.21 MB Fri, 04 Jun 2021 01:27:26 GMT 2
1.0.2 2.21 MB Thu, 20 May 2021 23:00:34 GMT 2
1.0.1 2.21 MB Thu, 20 May 2021 21:22:12 GMT 2
1.0.0 2.21 MB Wed, 19 May 2021 00:18:51 GMT 2
0.0.14 2.21 MB Wed, 19 May 2021 00:03:39 GMT 2