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
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
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>();
public record Person(string FirstName, string LastName);
Possess a readonly and struct spin too
init only property
this simple line
public string FirstName { get; init; } = "Thomas";
can replace
public class Friend
{
public Friend(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
public string FirstName { get; }
public string LastName { get; }
}
with expression - Nondestructive mutation creates a new object with modified properties
var p1 = new NamedPoint("A", 0, 0);
var p2 = p1 with { Name = "B", X = 5 };
- 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
}
Group photo
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
Explored tryadd
Explored abstract validators of media r
C# 11 new features
global usings
implicit usings
no need of nested namespace braces with file scoped namespaces
Record data types - single line - without get;set
init only property this simple line
can replace
=> c is >='a' and <= 'z' or ...
[GlobalSetup] public void GlobalSetup() { //Write your initialization code here }
BenchmarkRunner.Run();