Category: .NET

NetCoreUsefullEndpoints–part 6–passing to .NET 7

So  .NET 7 has appeared and I decided to pass NetCoreUsefullEndpoints to .NET 7 .

Also, for RateLimiter , I have considered that is good to know if the request is local or remote … so I decided to add connection ( remote IP, local IP, and more details) to the nuget package.

So I have created for .NET 6 this :

So , first things first : modify the version from  6.2022.1203.1551 to  7.2022.1203.1551 ( my versioning scheme is .NETCore version compliant of the package.year.MMdd.HHmm  – pretty stable and easy to decide what package you should add)

Then I want to profit to show in swagger the return type with TypedResults – so , as an example , I have modified from

route.MapGet(“api/usefull/httpContext/Connection”, (HttpContext httpContext) =>
var con = httpContext.Connection;
if (con == null)
     return Results.NoContent();
var conSerialize = new
     LocalIpAddress = con.LocalIpAddress?.ToString(),
     RemoteIpAddress = con.RemoteIpAddress?.ToString(),
return Results.Ok(conSerialize);




Results<NoContent, Ok<object>>
(HttpContext httpContext) =>
var con = httpContext.Connection;
if (con == null)
     return TypedResults.NoContent();
var conSerialize = new
     LocalIpAddress = con.LocalIpAddress?.ToString(),
     RemoteIpAddress = con.RemoteIpAddress?.ToString(),
return TypedResults.Ok((object)conSerialize);

As you see , a pretty easy modification – indicating the INesteHttpResult Results<NoContent, Ok<object>>  ( so the swagger understand the 2 different return types )  and returning TypedResults instead of Results

Also the github ci must add the .NET Core and Azure App Service should be going to .NET 7 STS


Now to see how to handle FrontEnd routing ( From Backend it is simple – just transfer to index.html and React will handle it )

The long established in React world seems to be . There is a new kid , – that uses hooks. However, the documentation says:

This project is not and will not be written in typescript.

So back to the old react router.

To register you need:

  1. Some routes
<Route path="/" element={<PublicTilts />} />
<Route path="/public/:id" element={<OnePublicTiltComponent />} />
{/* <Route path="*" element={<NotFound />} /> */}
  1. And intercept
function OnePublicTiltComponent() : JSX.Element{

    let { id } = useParams();

However, when I look to Angular and React, the code in React ( with Hooks) seems more clean and usable. Just the render and the functions.

Vintage Development part 2 si RX

Pe   13 septembrie 2022, ora 19:30 ,  va fi un nou meetup ADCES despre

“Vintage Development part 2 si RX”


Prezentare 1:
Vintage development part 2 – VB6.0, Classic ASP, Windows NT Server, Visual SourceSafe
Prezentator: Julian Atanasoae,

Prezentare 2:
Reactive Extensions in .NET si JavaScript cu multe exemple in Angular
Prezentator: Andrei Ignat,
Descriere: In cadrul prezentarii o sa fie

  1. o introducere in Reactive Extensions

  2. citeva exemple despre ce inseamna Observables si cum se combina ele
  3. Va arata citeva exemple practice despre cum va ajuta Reactive Extensions sa programati mai usor call-urile de API
  4. Site-uri utile ( unul in Azure ) unde puteti incerca marbles

Va astept aici:  , 13 septembrie 2022, ora 19:30

[NuGet]: Transplator

This is a Nuget that it is what Razor should have been. It is a Roslyn Source Code Generator that transforms template into code.



What it does:  Takes a template and generates source code for outputting anything inside.


Somewhere in the csproj:

   <CompilerVisibleProperty Include=”DebugTransplator” />
   <CompilerVisibleItemMetadata Include=”AdditionalFiles” MetadataName=”SourceItemType” />
   <CompilerVisibleItemMetadata Include=”AdditionalFiles” MetadataName=”Name” />
   <AdditionalFiles Include=”ASM.txt” SourceItemType=”Transplate” KeepMetadata=”Name” />


Somewhere in a .cs file

var response = new ASMTemplate().Render();

And the template

partial class ASMTemplate
     StringBuilder sb = new StringBuilder();
     public void WriteText(string text)
     public void WriteValue(int text)
     public void WriteValue(int? text)
         if(text != null)
             sb.AppendLine(“” + text);
     public void WriteValue(DateTime text)
         sb.AppendLine(text.ToString(“yyyy MMMM dd HH:mm:ss”));
     public void WriteValue(string text)
     public string Render()
         return sb.ToString();

RSCG Example – Tiny Types – Part 23



name BaseTypes

author Andreas Dorfer

Generated tiny types from any value type

The code that you start with is

    [Int] public partial record DepartmentId;

    public Employee GetFromId(int idDepartment, int idEmployee)



        return new Employee()


            ID = idEmployee,

            DepartmentId = idDepartment,

            Name = "Andrei " + idEmployee




    public Employee GetFromId(DepartmentId departmentId,  EmployeeId employeeId)


        return GetFromId(departmentId, employeeId);


The code that you will use is

    e.GetFromId(10, 34);

    e.GetFromId(new DepartmentId(34), new EmployeeId(10));


The code that is generated is

    [System.ComponentModel.TypeConverter(typeof(AD.BaseTypes.Converters.BaseTypeTypeConverter<DepartmentId, int>))]

    [System.Text.Json.Serialization.JsonConverter(typeof(AD.BaseTypes.Json.BaseTypeJsonConverter<DepartmentId, int>))]

    sealed partial record DepartmentId : System.IComparable<DepartmentId>, System.IComparable, AD.BaseTypes.IBaseType<int>


        public DepartmentId(int value)


            this.Value = value;


        public int Value { get; }

        public override string ToString() => Value.ToString();

        public int CompareTo(object? obj) => CompareTo(obj as DepartmentId);

        public int CompareTo(DepartmentId? other) => other is null ? 1 : System.Collections.Generic.Comparer<int>.Default.Compare(Value, other.Value);

        public static implicit operator int(DepartmentId item) => item.Value;

        public static DepartmentId Create(int value) => new(value);


Example Code:


NrBlog Post
1RSCG–part 1
2RSCG- AppVersion–part 2
4RSGC-JSON to Class- part 4
5RSGC-Constructor – Deconstructor – part 5
6RSGC – DTO Mapper – part 6
7RSGC – Skinny Controllers- part 7
8RSGC-Builder Design Pattern – part 8
9RSGC- MetadataFromObject – part 9
10RSGC- Dynamic Mock – part 10
11RSCG- Method Decorator – part 11
12RSCG – Curry – Partial function – part 12
13RSCG- part 13 – IFormattable
14RSCG- part 14 – DP_Decorator
15RSCG- part 15 – Expression Generator
16RSCG- part 16 – Many Others
17RSCG- the book
18RSCG–Template Rendering- part 17
19CI Version
21Query from database
Roslyn Source Code Generators

RecordVisitors- BDD–part 9

It is recommended to have tests. And better is to  see the output of the tests in some readable format .

On other hand, I do not like full BDD   frameworks as SpecFlow – I think that are too overkill in order to achieve less.

So – something like seems to fit the bill.

After you read the documentation, it is not so difficult. You transform test from

public async void TestFakeUser()

    // Arrange
    var client = _factory.CreateClient();

    // Act
    var response = await client.GetStringAsync("/recordVisitors/AllVisitors5Min");

    // Assert
    var str = "JeanIrvine";
    Assert.True(response.Contains(str), $"{response} must contain {str}");



HttpClient client;
string response;
private void Given_The_Application_Starts()
  StepExecution.Current.Comment("!!!Start application!!!!");
  client = _factory.CreateClient();

private async Task When_The_User_Access_The_Url(string url)
    response = await client.GetStringAsync(url);
private void Then_The_Response_Should_Contain(string str)
    Assert.True(response.Contains(str), $"{response} must contain {str}");

public async void TestFakeUser()
    await Runner
            _ => When_The_User_Access_The_Url("/recordVisitors/AllVisitors5Min")
            _ => Then_The_Response_Should_Contain("JeanIrvine")


Yes, it seems some more code – but you can re-use the functions and , more, the documentation looks great!

The results can bee seen at

AutoActions for Skinny controllers–custom template

Now I want to let the user make his own template. For this, I have enriched the attribute AutoActionsAttribute with a

public string CustomTemplateFileName { get; set; }


The code was pretty easy, just reading from GeneratorExecutionContext . AdditionalFiles instead of reading from the template in the dll


switch (templateId)

case TemplateIndicator.None:
	context.ReportDiagnostic(DoDiagnostic(DiagnosticSeverity.Info, $"class {myController.Name} has no template "));
case TemplateIndicator.CustomTemplateFile:

	var file = context.AdditionalFiles.FirstOrDefault(it => it.Path.EndsWith(templateCustom));
	if (file == null)
		context.ReportDiagnostic(DoDiagnostic(DiagnosticSeverity.Error, $"cannot find {templateCustom} for  {myController.Name} . Did you put in AdditionalFiles in csproj ?"));
	post = file.GetText().ToString();

	using (var stream = executing.GetManifestResourceStream($"SkinnyControllersGenerator.templates.{templateId}.txt"))
		using var reader = new StreamReader(stream);
		post = reader.ReadToEnd();



There are 2 small catches

1 see the EndsWith  ? The GeneratorExecutionContext . AdditionalFiles  gives you the full path

2. the additional files should be registered in the .csproj

<AdditionalFiles Include=”Controllers\CustomTemplate1.txt” />


Now the user can define his own template for the controller like this

[AutoActions(template = TemplateIndicator.CustomTemplateFile, FieldsName = new[] { "*" } ,CustomTemplateFileName = "Controllers\\CustomTemplate1.txt")]
    public partial class CustomTemplateController : ControllerBase
        private readonly RepositoryWF repository;

        public CustomTemplateController ()
            //do via DI
            repository = new RepositoryWF();


And this is all ! ( ok. some documentation should be involved)

[ADCES] Presentation about .NET 5

My presentation were about EFCore, RoslynGenerators, Breaking Changes and ClickOnce.

Code and presentation at .

Next presentation will be

De la Multinationala la Startup & Filbo – Technical Stack

Tuesday, Jan 12, 2021, 7:30 PM

Online event

19 Members Attending

Prezentare 1 : De la multinationala la startup si freelancer – sau cum sa iti parasesti cariera bine platita pentru alta Speaker: Daniel Tila, Descriere: Aventurile unui programator in cautarea businessului Prezentare 2: Filbo – Technical Stack Speaker: Adrian Nasui,…

Check out this Meetup →

[ADCES].NET 5 What’s new and awesome

Daniel Costea , Andrei Ignat si Dan Patrascu-Baba si o sa faca demo practice despre

1. C# – What’s new

2. ASP.NET Core – What’s new

3. EF Core – What’s new

4. Auto-Update de aplicatii Asp.NET Core si WPF prin ClickOnce

5. Roslyn Generators pentru code

6. Breaking changes

7 What’s new in Blazor on .NET 5?

Speaker: Dan Patrascu-Baba,

Description: .NET 5 is probably one of the most important milestones in the history of .NET. Everybody is excited about the new release and we have plenty of reasons to be as a bunch o new features and improvements have been announced. In this talk we’ll dive deeper in the new Blazor features released with .NET 5, both for Blazor Server and Blazor WebAssembly. We’ll tackle concepts like CSS and JS isolation, lazy loading, secure local storage interactions and much more.

Va astept la !
( Acest eveniment este in colaborare cu .NET Romania )

SideCarCLI–looking at past and at future

Summary links SideCarCLI

NoName + Link 
3Refactor specifications and code
4Create Release
5Finish interceptors
6Send part of command to interceptors
7Line Interceptors
8Finish process after some time
9Documetation Diagram
10Technical Summary
11Create dotnet tool
( Description : SideCar for CLI applications. Interceptors for Line, Finish, Timer . See Code )

It was interesting to develop the project for command line same as for cloud design pattern, .

The problem were more about

  1. architecture
  2. organizing features to be easy understandable
  3. , testing the application
  4. writing about


rather than  technical, about how to make the application.

Other , it was a pretty simple project , that can be useful in  CI / CD operations.

It remains :

Make a dot net tool –

Compiling as Windows and Linux

Make documentation with use case –

Make Tests

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.