From 321ab409d678c844a069c36ab87e0c0ad038d482 Mon Sep 17 00:00:00 2001 From: Albie Spriddell Date: Tue, 19 Dec 2023 11:22:04 +0000 Subject: [PATCH] add roslyn readme --- .../DragonFruit.Data.Roslyn.csproj | 3 +++ DragonFruit.Data.Roslyn/readme.md | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 DragonFruit.Data.Roslyn/readme.md diff --git a/DragonFruit.Data.Roslyn/DragonFruit.Data.Roslyn.csproj b/DragonFruit.Data.Roslyn/DragonFruit.Data.Roslyn.csproj index 72dac23..46a706b 100644 --- a/DragonFruit.Data.Roslyn/DragonFruit.Data.Roslyn.csproj +++ b/DragonFruit.Data.Roslyn/DragonFruit.Data.Roslyn.csproj @@ -27,6 +27,9 @@ + + + diff --git a/DragonFruit.Data.Roslyn/readme.md b/DragonFruit.Data.Roslyn/readme.md new file mode 100644 index 0000000..1b8ed44 --- /dev/null +++ b/DragonFruit.Data.Roslyn/readme.md @@ -0,0 +1,24 @@ +# DragonFruit.Data.Roslyn +A Roslyn source-generator and code-analyzer for DragonFruit.Data + +[![Latest Nuget](https://img.shields.io/nuget/v/DragonFruit.Data.Roslyn?label=DragonFruit.Data.Roslyn&logo=nuget)](https://nuget.org/packages/DragonFruit.Data.Roslyn) +[![DragonFruit Discord](https://img.shields.io/discord/482528405292843018?label=Discord&style=popout)](https://discord.gg/VA26u5Z) + +## Overview +DragonFruit.Data.Roslyn is a source-generator and code-analyzer for DragonFruit.Data that allows the request-building logic for `ApiRequest` classes to be generated at compile-time, rather than at runtime for each request. +It also provides code-analysis to ensure attributes are applied correctly and design rules are followed. + +## Usage/Getting Started +**Note: while semantic versioning is used, it is best to ensure the versions of `DragonFruit.Data` and `DragonFruit.Data.Roslyn` are the same.** + +The easiest way to get started is to install the [NuGet package](https://nuget.org/packages/DragonFruit.Data.Roslyn) alongside `DragonFruit.Data` and start writing `ApiRequest` classes. +The analyzer will inform you of any issues through your IDE. + +Because the source generator writes code that is written at compile time, additional constraints are applied to `ApiRequest` classes: + +- Classes must be marked with the `partial` keyword +- Classes must not be nested within another class +- Members cannot be marked as `private` or `internal` (only `public` and `protected` and `internal protected` are allowed) + +Additionally, if a library uses the source generator, it must be added to all consumers unless all requests are `sealed`. +This is due to how the source generator works in combination with how DragonFruit.Data prioritises source-generated request builders. \ No newline at end of file