Closed JasonBock closed 2 years ago
Thank you so much! Merged.. and I'll set up some directions on the README as well as a publish to NuGet
Awesome!
In the future, if there are any features being added, we just need to make sure they're done with both the Reflection and SG approaches. I'll try to stay on top of the SG side.
I've added two projects:
Fritz.InstantAPIs.Generators
- This contains a generator that looks for class definitions that derive fromDbContext
and creates an extension method forWebApplication
to createMap...
methods. I named the project this way because there might be a need to create other generators that look for different data source types and build extension methods for those approaches.Fritz.InstantAPIs.Generators.Tests
- This contains tests for the generator.The approach I look to generate the extension method can be changed. For the MVP, I decided to just look for
DbContext
derived classes. Maybe we change that to have an additional file that specifies which contexts should be mapped. Or, we create an attribute that the developer has to put on the context, though I think that's probably not the right place for the attribute. Meaning, you may be defining the context in a library, and you reference that library from the web project. Rather, we'd have an assembly-level attribute that would say something like[assembly: InstantAPIs(typeof(MyContext))]
(and with the potential of generic attributes in C# in the future, we could make that attribute a generic).I have comments in
Program.cs
that describes how you can switch to the source generator approach. Let me know what you think!