AMA.NET

In fiecare joi, la ora 21, o sa tin o sesiune de AMANET – intrebati-ma orice despre .NET .  De preferinta, .NET Core – dar merge si .NET Framework, arhitectura, backend, Razor, MVC, orice care are legatura cu C# . Linkul  pentru video este  https://meet.google.com/idm-gcxj-enb  si cel de la google https://calendar.google.com/event?action=TEMPLATE&tmeid=MTdhZTVnOWZvdTk3ZTJzMjVzMW41bnI5c2FfMjAyMTA4MDVUMTgwMDAwWiBpZ25hdC5hbmRyZWlAbQ&tmsrc=ignat.andrei%40gmail.com&scp=ALL .

Va astept !

Friday Links 434

  • Monitoring demystified: A guide for logging, tracing, metrics | TechBeacon
  • 3 =��chy Open-Source Projects. One of the reasons why I like& | by Nishant Mendiratta | Frontend Weekly | Jul, 2020 | Medium
  • How I Build Scalable Modern Web Applications for Real Users | by Trey Huffine | Aug, 2020 | Level Up Coding
  • Enforcing asynchronous code good practices using a Roslyn analyzer – Meziantou’s blog
  • TikTok and the Sorting Hat Remains of the Day
  • adoconnection/RazorEngineCore: ASP.NET Core 3.1.5 Razor Template Engine
  • chowderman/xp-paint: A web version of MS Paint from Windows XP
  • C# MSConnectionCS DLL using Mailslots for Inter-process Communication – CodeProject
  • The 10 best Angular tips selected by the community – Angular inDepth
  • .NET Application Architecture Guides
  • Dear Google Cloud: Your Deprecation Policy is Killing You | by Steve Yegge | Aug, 2020 | Medium
  • Permissions and Security in Dynamic Data Masking – Step 4 of the Stairway to Dynamic Data Masking SQLServerCentral
  • Production post-mortem: Too much RAM and the unstable cluster | RavenDB NoSQL
  • Top 10 Open Source NuGet Tools for .NET Development – Ozcode
  • Raise less money – Aaron’s Blog
  • Layout Shift GIF Generator – Cumulative Layout Shift (CLS) Visualiser.
  • awaescher/RepoZ: A zero-conf git repository hub for Windows and macOS with Windows Explorer- & CLI-enhancements
  • Goodbye Microservices: From 100s of problem children to 1 superstar | Segment Blog
  • Centrifuge: a reliable system for delivering billions of events per day | Segment Blog
  • 1.1 Billion Taxi Rides using OmniSciDB and a MacBook Pro
  • RSCG Example–CI Version–part 18

     

    name RSCG_AMS
    nuget https://www.nuget.org/packages/AMS_Base
    https://www.nuget.org/packages/AMSWebAPI
    https://www.nuget.org/packages/RSCG_AMS
    link https://github.com/ignatandrei/RSCG_AMS
    author Andrei Ignat

    The AMS will add in the CI the version and creator to your project.See https://netcoreblockly.herokuapp.com/ams for an example   The code that you start with is

    
        <packagereference include="AMS_Base">
    
        <packagereference include="AMSWebAPI">
    
        <packagereference include="RSCG_AMS" outputitemtype="Analyzer" referenceoutputassembly="false">
    
    
    

    The code that you will use is

    
    
        app.UseEndpoints(endpoints =&gt;
    
        {
    
            endpoints.MapControllers();
    
            endpoints.UseAMS();
    
        });
    
    

    The code that is generated is

    
        using System;
    
        using AMS_Base;
    
        namespace AMSExample { 
    
            /// <summary>
    
            /// this is the About My Software for 65788572124102115119116110
    
            /// </summary>
    
            public class XAboutMySoftware_65788572124102115119116110 :AboutMySoftware {
    
                /// <summary>
    
                /// starts when this module is loaded and 
    
                /// add the AMS tot the 
    
                /// </summary>
    
                [System.Runtime.CompilerServices.ModuleInitializer]
    
                public static void Add_AboutMySoftware_65788572124102115119116110(){
    
                    AboutMySoftware.AddDefinition("AMSExample",new  XAboutMySoftware_65788572124102115119116110());  
    
                }
    
                /// <summary>
    
                /// constructor
    
                /// for AMS 65788572124102115119116110
    
                /// </summary>
    
                public XAboutMySoftware_65788572124102115119116110(){
    
                    AssemblyName ="AMSExample" ; 
    
                    DateGenerated = DateTime.ParseExact("20210717034910", "yyyyMMddHHmmss", null); 
    
                    CommitId  = "not in a CI run" ; 
    
                    RepoUrl ="https://ignatandrei.github.io/RSCG_AMS/runtimeMessages/NotFound.md" ; 
    
                    CISourceControl = "not in a CI run" ; 
    
                    SourceCommit = "https://ignatandrei.github.io/RSCG_AMS/runtimeMessages/NotFound.md" ; 
    
                    Authors= "";
    
                    Version= "";  
    
                    User = "Surface1";
    
                }
    
                
    
            }
    
               
    
        }
    
    

    Example Code: https://github.com/ignatandrei/RSCG_Examples/tree/main/CI_Version

    All RSCG

    NrBlog Post
    1RSCG–part 1
    2RSCG- AppVersion–part 2
    3http://msprogrammer.serviciipeweb.ro/2021/02/17/rsgc-enum-part-3/
    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
    Roslyn Source Code Generators

    RSCG-Integrating with CI Only – part 10

    The integration with CI providers is enough straightforward – just see what environments variable those providers have. GitLab and Github has enough documentation – at https://docs.gitlab.com/ee/ci/variables/ and https://docs.github.com/en/actions/reference/environment-variables 

    What I have forgot is that there are also CI providers without having necessary source control.

    For example AzureDevOps can execute code taken from GitHub

    More than that  Heroku stack , that has not source control , have dispersed info – see https://devcenter.heroku.com/changelog-items/630 about SOURCE_VERSION – and no more else about the what other variables it has. I have obtained those via RSCG – but no indication about what is the source control comes.

    What can I do ? The solution is to avert the users – I have created https://ignatandrei.github.io/RSCG_AMS/runtimeMessages/NotFound.md .

    RSCG–Template Rendering- part 17

     

    name Transplator
    nuget https://www.nuget.org/packages/Transplator/
    link https://github.com/atifaziz/Transplator/
    author Atif Aziz

    The Transplator is a small fast rendering engine to allow you to make rendering from any class instance.   The code that you start with is

    
        {%
    
        using System.Collections.Generic;
    
        using System.Linq;
    
        using System.Text;
    
        using Rendering;
    
        
    
        static partial class EmployeeRendering
    
        {
    
            public static string Render(params Employee[] employees)
    
            {
    
                var sb = new StringBuilder();
    
                int i= 0;
    
        -%}
    
        Number Employees: {% employees?.Length %}
    
            {%~ foreach (var emp in employees) { 
    
            i++;
    
            ~%}
    
            {% i %}. {% emp.Name %}  it is in {% emp.Department?.Name %}
    
            {%~ } ~%}
    
        {%
    
                return sb.ToString();
    
        
    
                void WriteText(string value) =&gt; sb.Append(value);
    
                void WriteValue(object value) =&gt; sb.Append(value);
    
            }
    
        }
    
        ~%}
    
    
    

    The code that you will use is

    
    
        var IT = new Department();
    
        IT.Name = "IT";
    
        var e = new Employee();
    
        e.ID = 10;
    
        e.Name = "Andrei Ignat";
    
        e.Department = IT;
    
        var render = EmployeeRendering.Render(e);
    
        Console.WriteLine(render);
    
    

    The code that is generated is

    
        using System.Collections.Generic;
    
        using System.Linq;
    
        using System.Text;
    
        using Rendering;
    
        
    
        static partial class EmployeeRendering
    
        {
    
            public static string Render(params Employee[] employees)
    
            {
    
                var sb = new StringBuilder();
    
                int i= 0;
    
        WriteText(@"Number Employees: ");
    
        WriteValue(employees?.Length);
    
        WriteText(@"
    
        ");
    
        foreach (var emp in employees) { 
    
            i++;
    
           WriteText(@"    ");
    
        WriteValue(i);
    
        WriteText(@". ");
    
        WriteValue(emp.Name);
    
        WriteText(@"  it is in ");
    
        WriteValue(emp.Department?.Name);
    
        WriteText(@"
    
        ");
    
        }
    
                return sb.ToString();
    
        
    
                void WriteText(string value) =&gt; sb.Append(value);
    
                void WriteValue(object value) =&gt; sb.Append(value);
    
            }
    
        }
    
    

    Example Code: https://github.com/ignatandrei/RSCG_Examples/tree/main/TemplateRender

    All RSCG

    NrBlog Post
    1RSCG–part 1
    2RSCG- AppVersion–part 2
    3http://msprogrammer.serviciipeweb.ro/2021/02/17/rsgc-enum-part-3/
    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
    Roslyn Source Code Generators

    RSCG–Advice- part 8

    If you create a Roslyn Source Code Generator that uses inside a base class or a static class, the best way, in my opinion , is to create 2 separate nuget packages : one for the code generated and one for the base class. This way the project that will use your RSCG will use just the nuget package that have the base class and get rid of the generator . More, you can add a third project to register some extensions to Web project .

    Let’s see in practice with RSCG_AMS :

    I have a NuGet package with the base class AboutMySoftware –  https://www.nuget.org/packages/AMS_Base/

    The RSCG generates derived classes of AboutMySoftware  – has a dependency in the AMS_Base   –  the name is RSCG_AMS : https://www.nuget.org/packages/RSCG_AMS/ . This will generate code during the build and will not be included in the output.

    Finally, I have an extension for WebAPI – AMSWebAPI – that registers the  endpoint in the Web Project to display /ams url .

    I think that this is a normal organization of RSCG projects.

     

    Also, add documentation  for each class / public item generated. There can be projects that will require this ( as a compiler/ property flag )

    RSCG–AMS – About My software –Documentation– part 7

    Now it is time to let others know about the project. And the first step is to make documentation. And , because a picture is worth many words, here is the picture:

    Also, instructions about how to use will help the programmers:

    For a DLL it is simple :

    <ItemGroup>
        <PackageReference Include="AMS_Base" Version="2021.6.29.1820" />
        <PackageReference Include="RSCG_AMS" Version="2021.6.29.1820" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
      </ItemGroup>

    For an ASP.NET Core application:

      <PackageReference Include="AMSWebAPI" Version="2021.6.29.1820" />
        <PackageReference Include="AMS_Base" Version="2021.6.29.1820" />
        <PackageReference Include="RSCG_AMS" Version="2021.6.29.1820" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />

    and the code will be

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllers();
        endpoints.UseAMS();
    });

    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.