Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions v2/rscg_examples/Maestria.TypeProviders/description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"generator":{
"name":"Maestria.TypeProviders",
"nuget":[
"https://www.nuget.org/packages/Maestria.TypeProviders/"
],
"link":"https://github.com/MaestriaNet/TypeProviders",
"author":"Fábio Monteiro Naspolini",
"source":"https://github.com/MaestriaNet/TypeProviders"
},
"data":{
"goodFor":["Generating strong typed code from Excel."],
"csprojDemo":"DemoExcel.csproj",
"csFiles":["Program.cs","MyExcelPerson.cs","Person.cs"],
"excludeDirectoryGenerated":[""],
"includeAdditionalFiles":[""]
},
"links":{
"blog":"",
"video":""
}
}
3 changes: 3 additions & 0 deletions v2/rscg_examples/Maestria.TypeProviders/src/DemoExcel.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="DemoExcel/DemoExcel.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClosedXML" Version="0.105.0" />
<PackageReference Include="Maestria.Extensions" Version="3.7.2.0" />
<PackageReference Include="Maestria.TypeProviders" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<None Update="MyExcel.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace DemoExcel;

public partial class MyExcelPerson
{
public string FullName() => $"{FirstName} {LastName}";
}
10 changes: 10 additions & 0 deletions v2/rscg_examples/Maestria.TypeProviders/src/DemoExcel/Person.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace DemoExcel;

Comment on lines +1 to +6
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The System, System.Collections.Generic, and System.Text usings are currently unused in this file. Removing them avoids unnecessary clutter and prevents unused-using warnings in stricter build configurations.

Suggested change
using System;
using System.Collections.Generic;
using System.Text;
namespace DemoExcel;
namespace DemoExcel;

Copilot uses AI. Check for mistakes.
[ExcelProvider(TemplatePath = @"MyExcel.xlsx")]
public partial class MyExcelPerson
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file name Person.cs defines MyExcelPerson. Renaming the file to match the type (or vice versa) would make the demo easier to navigate and avoid confusion when multiple models are added later.

Suggested change
public partial class MyExcelPerson
public partial class Person

Copilot uses AI. Check for mistakes.
{
}
10 changes: 10 additions & 0 deletions v2/rscg_examples/Maestria.TypeProviders/src/DemoExcel/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using DemoExcel;

Console.WriteLine("Hello, World!");
var persons = MyExcelPersonFactory.Load("MyExcel.xlsx").ToArray();
Comment on lines +2 to +4
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MyExcel.xlsx is loaded via a relative path. If the app is executed with a working directory different from the output folder, this will fail to find the file even though it is copied to the output. Consider building the path from AppContext.BaseDirectory (or similar) so the demo runs reliably regardless of the current directory.

Suggested change
Console.WriteLine("Hello, World!");
var persons = MyExcelPersonFactory.Load("MyExcel.xlsx").ToArray();
using System.IO;
Console.WriteLine("Hello, World!");
var excelPath = Path.Combine(AppContext.BaseDirectory, "MyExcel.xlsx");
var persons = MyExcelPersonFactory.Load(excelPath).ToArray();

Copilot uses AI. Check for mistakes.

foreach (var person in persons)
{
Console.WriteLine(person.ID + person.FullName());
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output concatenates person.ID and person.FullName() without any delimiter, which makes the demo output hard to read (e.g., 1John Doe). Consider using string interpolation / formatting to include a separator (space, :, etc.) between the fields.

Suggested change
Console.WriteLine(person.ID + person.FullName());
Console.WriteLine($"{person.ID}: {person.FullName()}");

Copilot uses AI. Check for mistakes.

}
Loading