Skip to content

type providers#469

Merged
ignatandrei merged 3 commits intomainfrom
Maestria.TypeProviders
Apr 7, 2026
Merged

type providers#469
ignatandrei merged 3 commits intomainfrom
Maestria.TypeProviders

Conversation

@ignatandrei
Copy link
Copy Markdown
Owner

@ignatandrei ignatandrei commented Apr 7, 2026

Summary by CodeRabbit

  • Documentation
    • Added a new example project demonstrating how to load Excel data and access it through strongly-typed C# classes using Maestria.TypeProviders, including custom methods for data transformation and output.

Copilot AI review requested due to automatic review settings April 7, 2026 17:13
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A new complete example project for Maestria.TypeProviders is added, demonstrating source code generation for Excel-to-typed-code workflows. The example includes configuration metadata, solution/project files, partial class definitions with an ExcelProvider attribute, and a console application that loads and displays Excel data.

Changes

Cohort / File(s) Summary
Configuration & Metadata
description.json, src/DemoExcel.slnx
Added metadata describing the generator (name, NuGet package, GitHub links, author) and solution file declaring the DemoExcel project reference.
Project Setup
src/DemoExcel/DemoExcel.csproj
New SDK project targeting net10.0 with ClosedXML, Maestria.Extensions, and Maestria.TypeProviders dependencies; configures Excel file copy and compiler-generated output paths.
Source Code
src/DemoExcel/MyExcelPerson.cs, src/DemoExcel/Person.cs, src/DemoExcel/Program.cs
Added partial MyExcelPerson class with FullName() method, decorated Person class with [ExcelProvider] attribute for RSCG, and console entry point demonstrating loading and iterating Excel data.

Sequence Diagram

sequenceDiagram
    participant Program as Program.Main()
    participant Factory as MyExcelPersonFactory
    participant ExcelFile as MyExcel.xlsx
    participant PersonList as Person[] (In-Memory)
    participant Console as Console Output

    Program->>Factory: Load("MyExcel.xlsx")
    Factory->>ExcelFile: Read Excel data
    ExcelFile-->>Factory: Row data (ID, FirstName, LastName)
    Factory->>PersonList: Materialize to array
    PersonList-->>Program: Person[] collection

    loop For each person
        Program->>Program: person.FullName()
        Program->>Console: Print ID + FullName
        Console-->>Program: Output displayed
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A spreadsheet tale, now typed with care,
Excel rows transformed through the air,
With Maestria's magic, names align,
Each person's fullness perfectly defined,
From XLSX to code, a bunny's delight! 📊✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'type providers' is vague and generic, lacking specificity about what is being added or changed within this changeset. Provide a more descriptive title that clarifies the main contribution, such as 'Add Maestria.TypeProviders example with Excel-to-code generation' or 'Add DemoExcel type provider example project'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Maestria.TypeProviders

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ignatandrei ignatandrei merged commit 35351f0 into main Apr 7, 2026
4 of 5 checks passed
@ignatandrei ignatandrei deleted the Maestria.TypeProviders branch April 7, 2026 17:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Maestria.TypeProviders example demonstrating generating strongly-typed accessors from an Excel template and consuming the generated factory/type in a small console app.

Changes:

  • Added a DemoExcel console project that loads MyExcel.xlsx via the generated MyExcelPersonFactory and prints the results.
  • Added a partial MyExcelPerson type with an [ExcelProvider] template annotation and a FullName() helper.
  • Added the Excel template file and example metadata (description.json) for the generator showcase.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
v2/rscg_examples/Maestria.TypeProviders/src/DemoExcel/Program.cs Demo entry point that loads data from the generated factory and prints it.
v2/rscg_examples/Maestria.TypeProviders/src/DemoExcel/Person.cs Declares the annotated partial model for Excel-driven codegen.
v2/rscg_examples/Maestria.TypeProviders/src/DemoExcel/MyExcelPerson.cs Adds a convenience FullName() method to the generated model.
v2/rscg_examples/Maestria.TypeProviders/src/DemoExcel/MyExcel.xlsx Excel template used by the type provider and runtime loader.
v2/rscg_examples/Maestria.TypeProviders/src/DemoExcel/DemoExcel.csproj Project configuration + package references + copies the template to output.
v2/rscg_examples/Maestria.TypeProviders/src/DemoExcel.slnx Solution wrapper for the new demo project.
v2/rscg_examples/Maestria.TypeProviders/description.json Example metadata describing this generator demo.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


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.
Comment on lines +2 to +4

Console.WriteLine("Hello, World!");
var persons = MyExcelPersonFactory.Load("MyExcel.xlsx").ToArray();
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.
Comment on lines +1 to +6
using System;
using System.Collections.Generic;
using System.Text;

namespace DemoExcel;

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.
namespace DemoExcel;

[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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants