kurtzace / diary2023

0 stars 0 forks source link

DotNet Bangalore Meetup #23 Saturday, April 8, 2023 at 10:30 AM to Saturday, April 8, 2023 at 5:00 PM IST at DevOn Software Embassy Tech Villasge 1 Block-2a Hibiscus · Bengaluru, Ka #6

Open kurtzace opened 1 year ago

kurtzace commented 1 year ago

Group photo

image

Event link

link

Agenda

11:00 AM - Dependency Injection in .net by Mithun Shanbhag 12:15 PM - What's new with C# by Rohit Tiwari 1:15 PM - Lunch and quiz 2:30 PM - Measure application performance using BenchmarkDotNet by Vikram Chaudhary

Notes

Dependency Injection in .net

git repo

IEnumerable<IWeatherService> weatherServices can be injected and can be accessed using
weatherServices.Single(w => w.GetType() == typeof(WeatherService));

need to inject using

    services.AddTransient<IWeatherService, WeatherService>();
   services.AddTransient<IWeatherService, BetterWeatherService>();

Explored tryadd

Explored abstract validators of media r

C# 11 new features

can replace

public class Friend
{
    public Friend(string firstName, string lastName)
    {
        FirstName = firstName;
        LastName = lastName;
    }

    public string FirstName { get; }
    public string LastName { get; }
}

- New `and`, `or`, and `not` Keywords for Pattern Matching
- [switch as got case guards](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/switch-expression)
- Relationship pattern 

=> c is >='a' and <= 'z' or ...


### Measure application performance using BenchmarkDotNet
[author's page](https://www.dotnetforall.com/)

- tracks performance of methods at runtime (not like Sonar which is static analysis)

- see https://github.com/dotnet/BenchmarkDotNet
- annotate your method with [Benchmark] - can also feed multiple args like [Arguments(10,100)]
- properties can be annotated with [Param(0,5)]
- annotate your class with [MemoryDiagnoser]
- init code with 

[GlobalSetup] public void GlobalSetup() { //Write your initialization code here }

- to execute the benchmark

BenchmarkRunner.Run();



[also see](https://www.codemag.com/Article/2209061/Benchmarking-.NET-6-Applications-Using-BenchmarkDotNet-A-Deep-Dive)

## Build event upcoming
[Microsoft Build, happening May 23-24, 2023](https://build.microsoft.com/en-US/home?wt.mc_ID=Build2023_esc_corp_bn_oo_bn_Docs_banner_pre_event)