Category: .NET Core

AutoActions for Skinny controllers–idea

How you generate actions in controllers ? Usually, you create a Business Logic class and then you expose via a controller in a WebAPI . And, if you are very careful, then you use the Skinny controllers concept  ( read more about it at 3 ways to keep your asp.net mvc controllers thin (jonhilton.net) ).

So this implies usually repeating code in order to call the functions / methods from the business logic class.  I can give an example:

public class RepositoryWF
     {
         private static readonly string[] Summaries = new[]
{
             “Freezing”, “Bracing”, “Chilly”, “Cool”, “Mild”, “Warm”, “Balmy”, “Hot”, “Sweltering”, “Scorching”
         };
         public WeatherForecast[] DataToDo(int i)
         {
             var rng = new Random();
             return Enumerable.Range(1, i).Select(index => new WeatherForecast
             {
                 Date = DateTime.Now.AddDays(index),
                 TemperatureC = rng.Next(-20, 55),
                 Summary = Summaries[rng.Next(Summaries.Length)]
             })
             .ToArray();

        }
     // more methods / actions

and the controller

[ApiController]
     [Route(“[controller]/[action]”)]
     public partial class WeatherForecastController : ControllerBase
     {

        private readonly ILogger<WeatherForecastController> _logger;

       
         private readonly RepositoryWF repository;
        
         public WeatherForecastController(ILogger<WeatherForecastController> logger, RepositoryWF repository)
         {
             _logger = logger;
             this.repository = repository;
            
         }

        [HttpGet()]
         public WeatherForecast[] DataToDo(int i)
         {
             return repository.DataToDo(i);
         }

    }

What if , instead of the writing code , we will auto – generate the actions ?

For this I was thinking that was fun to use Source Generators – https://devblogs.microsoft.com/dotnet/new-c-source-generator-samples/

The code should read like this:

[ApiController]
     [Route(“[controller]/[action]”)]
     public partial class WeatherForecastController : ControllerBase
     {

        private readonly ILogger<WeatherForecastController> _logger;

        [AutoActions]
         private readonly RepositoryWF repository;
        
         public WeatherForecastController(ILogger<WeatherForecastController> logger, RepositoryWF repository)
         {
             _logger = logger;
             this.repository = repository;
            
         }

    

    }

So the only thing that you should do is annotate your class with

        [AutoActions]
         private readonly RepositoryWF repository;

and the actions will be generated for you!

[ADCES] Presentation about .NET 5

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

Code and presentation at https://ignatandrei.github.io/Presentations/NET5prez.html .

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, https://automationpill.com/ Descriere: Aventurile unui programator in cautarea businessului Prezentare 2: Filbo – Technical Stack Speaker: Adrian Nasui, https://www.linkedin.com/in/adrian-nasui-b887a5a9/…

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, http://danpatrascu.com/

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 https://www.meetup.com/Bucharest-A-D-C-E-S-Meetup/events/273633735/ !
( Acest eveniment este in colaborare cu .NET Romania )

Console2SAAS – what I learned from third chapter

The third chapter of the mini-e-book Console2SAAS shows me that I should not re-invent the wheel. Of course, it is easy to make a code that reads settings – but why do it so if there are libraries already in the framework  ?

Also, even a such simple task ( reading the setting) , in order to do properly, there is some amount of work and priorities involved – the application can read from environment variables, command line, configuration file, code … plenty of options – and what if the user mix and match those ? What you pick first ?

You can read online at https://github.com/ignatandrei/console_to_saas/tree/master/Chapter03

Blog posts about this topic

Console2SAAS

A mini-e-book about how to transform a Console to a SAAS application
Download the book for free from https://ignatandrei.github.io/console_to_saas/consoleToSaas.pdf.html
Buy the book from Amazon , if you want to support me : https://www.amazon.com/dp/B08N56SD4D
NoBlog 
1Introduction
2Technical Details
3Console2SAAS-Chapter1
4Console2SAAS-Chapter2
5Console2SAAS-Chapter3
6Console2SAAS-Chapter4
7Console2SAAS-Chapter5
8Console2SAAS-Chapter6
9Console2SAAS-Chapter7
10Console2SAAS-PM

Console2SAAS – what I learned from second chapter

The second chapter of Console2SAAS is very short. I realized that , as soon that you have the software , you want to have an ecosystem around it – version control, automatic CI . Also, if the software is released even to beta testers, you should have some refactoring done in order to have the solution structured properly for modifications.

You can find the second chapter at https://github.com/ignatandrei/console_to_saas/tree/master/Chapter02

Blog posts about this topic

Console2SAAS

A mini-e-book about how to transform a Console to a SAAS application
Download the book for free from https://ignatandrei.github.io/console_to_saas/consoleToSaas.pdf.html
Buy the book from Amazon , if you want to support me : https://www.amazon.com/dp/B08N56SD4D
NoBlog 
1Introduction
2Technical Details
3Console2SAAS-Chapter1
4Console2SAAS-Chapter2
5Console2SAAS-Chapter3
6Console2SAAS-Chapter4
7Console2SAAS-Chapter5
8Console2SAAS-Chapter6
9Console2SAAS-Chapter7
10Console2SAAS-PM

Book – Console 2 SAAS

I have a passion to read – also a passion to teach . And to reach others, what is best than a book ?

The idea of the book is how to pass from a Console application to a SAAS application –  with clear examples in .NET .

I have written the book with the help of Daniel Tila.

I will quote from the introduction of the book , because it is comprehensive:

<<

This book will guide you step-by-step to build a scalable product from a proof of concept to production-ready SAAS. Any development done will start from a business need: this will make things clear for the team what is the impact of the delivery.

You will see different architecture patterns for separation of concerns and why some of them fit well and some of them not. Everything will happen incrementally and the product development history will be easy to be seen by analyzing commits.

Every chapter is a progressive journey with some specific challenges that will be overcome by specific programming best practices.

This can be considered as a .NET tutorial, that demonstrates the versatility of the platform to create different types of applications (CLI, Desktop & Website).

>>

All examples in the book are in .NET Core

The book is free to download and read . What you can do:

  1. Download the book from https://ignatandrei.github.io/console_to_saas/consoleToSaas.pdf.html 
  2. Contribute to the book by modifying and submit a PR ( see https://github.com/ignatandrei/console_to_saas). We have already a contributor, Daniel Costea, http://apexcode.ro/about/
  3. Buy the book from Amazon , if you want to support me : https://www.amazon.com/dp/B08N56SD4D 

Blog posts about this topic

Console2SAAS

A mini-e-book about how to transform a Console to a SAAS application
Download the book for free from https://ignatandrei.github.io/console_to_saas/consoleToSaas.pdf.html
Buy the book from Amazon , if you want to support me : https://www.amazon.com/dp/B08N56SD4D
NoBlog 
1Introduction
2Technical Details
3Console2SAAS-Chapter1
4Console2SAAS-Chapter2
5Console2SAAS-Chapter3
6Console2SAAS-Chapter4
7Console2SAAS-Chapter5
8Console2SAAS-Chapter6
9Console2SAAS-Chapter7
10Console2SAAS-PM

SideCarCLI- console to dot net tool

Summary links SideCarCLI

NoName + Link 
1Description
2Specifications
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 )

To create a .NET Tool, please read first https://docs.microsoft.com/en-us/dotnet/core/tools/global-tools-how-to-create 

Of course , all the  nuget additional formats for csproj apply: read https://docs.microsoft.com/en-us/dotnet/core/tools/csproj . Of course, the easy way to in Visual Studio to right click the project, properties, Package.

This is the final xml from .csproj:

<PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp3.1</TargetFramework>
     <RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
     <PackAsTool>true</PackAsTool>
     <ToolCommandName>sidecarcli</ToolCommandName>
     <Title>SideCarCLI</Title>
    
     <PackageOutputPath>./nupkg</PackageOutputPath>
     <PackageId>sidecarcli</PackageId>
     <Version>2020.111.104</Version>
     <Authors>Andrei Ignat</Authors>
     <Company>AOM</Company>
     <Product>sidecarcli</Product>
     <Description>A SideCar for Command Line Applications. Read http://msprogrammer.serviciipeweb.ro/category/sidecar/ . Code source at https://github.com/ignatandrei/sidecarcli</Description>
     <PackageLicenseExpression>MIT</PackageLicenseExpression>
     <PackageProjectUrl>http://msprogrammer.serviciipeweb.ro/category/sidecar/</PackageProjectUrl>
     <RepositoryUrl>https://github.com/ignatandrei/SideCarCLI/</RepositoryUrl>
     <RepositoryType>GIT</RepositoryType>
     <PackageTags>SideCarCLI;Side Car; Command Line</PackageTags>
     <PackageReleaseNotes>First version. Read http://msprogrammer.serviciipeweb.ro/category/sidecar/</PackageReleaseNotes>
   </PropertyGroup>

 

You can create the project with

dotnet pack

command

Now go to https://www.nuget.org/packages/manage/upload and upload the project.

You can find the final result at https://www.nuget.org/packages/sidecarcli/  and you can install it

And this concludes the work for https://github.com/ignatandrei/SideCarCLI/issues/10 .

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.