Category: roslyn
-
RSCG – CommunityToolkit.Mvvm
name CommunityToolkit.Mvvm nuget https://www.nuget.org/packages/CommunityToolkit.Mvvm link https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/generators/overview author Microsoft Shows how to implement INotifyPropertyChanged,ObservableProperty and RelayCommand Unfortunately,not yet a separate package just for those. Also,this show that RSCG could generate multiple partial declarations This is how you can use CommunityToolkit.Mvvm . The code that you start with is The code that you will use is…
-
RSCG – RSCG_Static
name RSCG_Static nuget https://www.nuget.org/packages/RSCG_Static/ link https://github.com/ignatandrei/RSCG_Static author Andrei Ignat Generate interfaces and classes from static classes This is how you can use RSCG_Static . The code that you start with is The code that you will use is The code that is generated is Code and pdf at https://ignatandrei.github.io/RSCG_Examples/v2/docs/RSCG_Static
-
File to CSharp Const
I was getting tired how many times I am reading from embedded resources – and finding it over and over the same code. So – what if I will transform the file into C# text ? Seems a work for Roslyn Source Code Generator – and the new one IIncrementalGenerator https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.md,not the old ISourceGenerator https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview…
-
TILT-Server Timing in Browser-part 19
For see fast what is happening with your server,you can use the Server Timing API. One of the implementations for .NET is https://github.com/tpeczek/Lib.AspNetCore.ServerTiming . Not a big deal – implemented separately with AOPMethodsCommon – but I think it is a good idea to use it. The implementation was straightforward builder.Services.AddScoped<ServerTiming>(); var app = builder.Build(); app.UseServerTiming();…
-
DIForFunctions–improving generating of a constructor for a existing class with Roslyn
It is not so difficult to generate a new constructor for a existing class with Roslyn – however,there are some difficulties: 1. The original class must be declared “partial” – you cannot declare the second as partial if the first was not 2. The new class must be in the same namespace ( or without…
-
DIForFunctions – Improving constructor–part 5
I have received a suggestion : what if we just put into constructor what we need,and everything else ( such as ILogger ) are into fields ? The Roslyn Source Code Generator will generate a constructor that calls the this constructor and will assign fields needed. Let’s give an example : We wrote public partial…
-
DIForFunctions–what it does- part 4
You can find a demo at https://github.com/ignatandrei/FunctionsDI/tree/main/src/FunctionsWithDI – see TestCOnsoleAPP. But let’s write here also Generate (constructor) and functions calls similar with ASP.NET Core WebAPI ( [FromServices] will be provided by DI ) Also,verifies for null . Usage Reference into the csproj <ItemGroup> <PackageReference Include=”RSCG_FunctionsWithDI” Version=”2022.6.19.1605″ ReferenceOutputAssembly=”false” OutputItemType=”Analyzer” /> <PackageReference Include=”RSCG_FunctionsWithDI_Base” Version=”2022.6.19.1605″ /> </ItemGroup> Then…
-
DI for Functions- work–part 2
Let’s begin with tests – we need to have a class with multiple functions that have multiple [FromServices} parameter. Like public bool TestMyFunc1([FromServices] TestDI1 t1,[FromServices] TestDI2 t2,int x,int y) { return true; } public bool TestMyFunc2([FromServices] TestDI1 t12, int x,int y) { return true; } // more others Because there are multiple functions,I need to…
-
Templating Roslyn Source Code Generators
I want that,when I generate code with Roslyn,to have a template that I can easy modify to generate code . Also,I want to let the user ( the programmer,in this case) modify this template – maybe he has better ideas than me. For reading from the RSCG,is pretty simple: Make as an embedded resource and…
-
[RSCG]–About My Software
I have made a new improvement to my Roslyn Source Code Generator,AMS . Until now it just said the time and the commit date in a CI scenario ( Git ( GitLab,GitHub),Azure …) Now – what if it can list all the merge requests between 2 dates ,so you can see what is new ? Now…