Category: roslyn
-
RSCG – System.Runtime.InteropServices
RSCG – System.Runtime.InteropServices name System.Runtime.InteropServices nuget https://www.nuget.org/packages/System.Runtime.InteropServices/ link https://learn.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke-source-generation author Microsoft Generate PInvoke calls This is how you can use System.Runtime.InteropServices . 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/System.Runtime.InteropServices
-
RSCG – AutoDeconstruct
name AutoDeconstruct nuget https://www.nuget.org/packages/AutoDeconstruct link https://github.com/JasonBock/AutoDeconstruct/blob/main/docs/Overview.md author Jason Bock Automatically add deconstruct for all types in an assembly This is how you can use AutoDeconstruct . 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/AutoDeconstruct
-
RSCG – RSCG_AMS
name RSCG_AMS nuget https://www.nuget.org/packages/RSCG_AMS/ link https://github.com/ignatandrei/RSCG_AMS author Ignat Andrei Automatically registering the version,ci,commit id This is how you can use RSCG_AMS . 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_AMS
-
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…