C# 8 Interfaces: Dangerous Assumptions in Default Implementation ⚠️
One of the features that is being promoted about C# 8 interfaces is that we can add members to an interface without breaking existing implementers. ✅
But we can cause a lot of pain if we aren't careful. 🤷🏻♂️
Let's look at some code that makes bad assumptions so that we can understand the importance of avoiding these problems. ⛔️
[ Article ] : kutt.it/csdif
〰️〰️〰️〰️〰️〰️
#CSharp #Interfaces
@ProgrammingTip
One of the features that is being promoted about C# 8 interfaces is that we can add members to an interface without breaking existing implementers. ✅
But we can cause a lot of pain if we aren't careful. 🤷🏻♂️
Let's look at some code that makes bad assumptions so that we can understand the importance of avoiding these problems. ⛔️
[ Article ] : kutt.it/csdif
〰️〰️〰️〰️〰️〰️
#CSharp #Interfaces
@ProgrammingTip
Telegram
Programming Tips Resources
Using the ReferenceAssemblies NuGet package to build .NET Framework libraries on Linux, without installing Mono 💎
In this post I show how you can build .NET projects that target .NET Framework versions on Linux, without using Mono! 🤷🏻♂️
By using the new Microsoft.NETFramework.ReferenceAssemblies NuGet packages from Microsoft you don't need to install anything more than the .NET Core SDK! 🔥
[ Article ] : kutt.it/coremono
〰️〰️〰️〰️〰️〰️
#CSharp #DotNet #AspCore #NetCore
@ProgrammingTip
In this post I show how you can build .NET projects that target .NET Framework versions on Linux, without using Mono! 🤷🏻♂️
By using the new Microsoft.NETFramework.ReferenceAssemblies NuGet packages from Microsoft you don't need to install anything more than the .NET Core SDK! 🔥
[ Article ] : kutt.it/coremono
〰️〰️〰️〰️〰️〰️
#CSharp #DotNet #AspCore #NetCore
@ProgrammingTip
Telegram
Programming Tips Resources
EasyCompressor 📦
EasyCompressor is an open-source compression abstraction library that supports and implements many compression algorithms such as Zstd, LZMA, LZ4, Snappy, Brotli, GZip and Deflate. 🗂
It is very useful for using along with Distributed Caching or storing files in database. ✅
[ GitHub ] : github.com/mjebrahimi/EasyCompressor
〰️〰️〰️〰️〰️〰️
#Compression #CSharp #DotNet
@ProgrammingTip
EasyCompressor is an open-source compression abstraction library that supports and implements many compression algorithms such as Zstd, LZMA, LZ4, Snappy, Brotli, GZip and Deflate. 🗂
It is very useful for using along with Distributed Caching or storing files in database. ✅
[ GitHub ] : github.com/mjebrahimi/EasyCompressor
〰️〰️〰️〰️〰️〰️
#Compression #CSharp #DotNet
@ProgrammingTip
Telegram
Programming Tips Resources
What is .NET❓
What's C# and F#❔
What's the .NET Ecosystem❓
What can .NET build❔
Learn what is .NET from Scott Hanselman! ✅
[ Youtube ] : https://www.youtube.com/watch?v=bEfBfBQq7EE
〰️〰️〰️〰️〰️〰️
#DotNet #CSharp
@ProgrammingTip
What's C# and F#❔
What's the .NET Ecosystem❓
What can .NET build❔
Learn what is .NET from Scott Hanselman! ✅
[ Youtube ] : https://www.youtube.com/watch?v=bEfBfBQq7EE
〰️〰️〰️〰️〰️〰️
#DotNet #CSharp
@ProgrammingTip
YouTube
What is .NET? What's C# and F#? What's the .NET Ecosystem? .NET Core Explained, what can .NET build?
What is .NET? What is C# and F#? What is .NET Core? What's the .NET Ecosystem? What can you build? You have questions and we have answers. More videos at http://dot.net/videos
Working with Expression Trees in C# 🗂
Expression trees is an obscure, although very interesting feature in .NET. Most people probably think of it as something synonymous with object-relational mapping frameworks, but despite being its most common use case, it’s not the only one. There are a lot of creative things you can do with expression trees, including code generation, transpilation, metaprogramming, and more.
In this article I will give an overview of what expression trees are and how to work with them, as well as show some interesting scenarios where I’ve seen them used to great effect. ✅
[ Article ] : kutt.it/exptree
〰️〰️〰️〰️〰️〰️
#CSharp #Expressions
@ProgrammingTip
Expression trees is an obscure, although very interesting feature in .NET. Most people probably think of it as something synonymous with object-relational mapping frameworks, but despite being its most common use case, it’s not the only one. There are a lot of creative things you can do with expression trees, including code generation, transpilation, metaprogramming, and more.
In this article I will give an overview of what expression trees are and how to work with them, as well as show some interesting scenarios where I’ve seen them used to great effect. ✅
[ Article ] : kutt.it/exptree
〰️〰️〰️〰️〰️〰️
#CSharp #Expressions
@ProgrammingTip
Telegram
Programming Tips Resources
Proto.Actor 💎
Cross-platform actors for .NET, Go, Java and Kotlin. ⚡️
The Actor Model provides a higher level of abstraction for writing concurrent and distributed systems. It alleviates the developer from having to deal with explicit locking and thread management, making it easier to write correct concurrent and parallel systems. ✨
Features ✅:
• Simple Concurrency & Distribution
• Extreme Performance
• Resilient by Design
• Built on standards
• Virtual Actors
• Distributed by Default
• Supervision & monitoring
• Communications on gRPC
[ Website ] : https://proto.actor
[ Github ] : https://github.com/AsynkronIT/protoactor-dotnet
〰️〰️〰️〰️〰️〰️
#Actor #ActorModel #CSharp #Go #Kotlin
@ProgrammingTip
Cross-platform actors for .NET, Go, Java and Kotlin. ⚡️
The Actor Model provides a higher level of abstraction for writing concurrent and distributed systems. It alleviates the developer from having to deal with explicit locking and thread management, making it easier to write correct concurrent and parallel systems. ✨
Features ✅:
• Simple Concurrency & Distribution
• Extreme Performance
• Resilient by Design
• Built on standards
• Virtual Actors
• Distributed by Default
• Supervision & monitoring
• Communications on gRPC
[ Website ] : https://proto.actor
[ Github ] : https://github.com/AsynkronIT/protoactor-dotnet
〰️〰️〰️〰️〰️〰️
#Actor #ActorModel #CSharp #Go #Kotlin
@ProgrammingTip
Telegram
Programming Tips Resources
Lowering in C#: What's really going on in your code? 👾
If you're attending NDC you probably think you know what a foreach loop does - it iterates over a collection, right? ✅
BUT do you know how? Do you know what the C# compiler does when you write a foreach loop? What about a lambda expression? Or the re-entrant magic that is a yield return statement❓
In this session we'll dive into Roslyn, the C# compiler, and learn about lowering and how it helps the compiler do its job, and what it does to your code. In the process you'll gain the skills to identify some of the common performance pitfalls of .NET, as well as just get a deeper understanding of what the code you write really does. 💎
[ YouTube ] : https://youtu.be/gc1AxbNybvw
〰️〰️〰️〰️〰️〰️
#CSharp #LowLevel #Compiler #Roslyn
@ProgrammingTip
If you're attending NDC you probably think you know what a foreach loop does - it iterates over a collection, right? ✅
BUT do you know how? Do you know what the C# compiler does when you write a foreach loop? What about a lambda expression? Or the re-entrant magic that is a yield return statement❓
In this session we'll dive into Roslyn, the C# compiler, and learn about lowering and how it helps the compiler do its job, and what it does to your code. In the process you'll gain the skills to identify some of the common performance pitfalls of .NET, as well as just get a deeper understanding of what the code you write really does. 💎
[ YouTube ] : https://youtu.be/gc1AxbNybvw
〰️〰️〰️〰️〰️〰️
#CSharp #LowLevel #Compiler #Roslyn
@ProgrammingTip
Telegram
Programming Tips Resources
Nuke Build 🗂
As C# developers, we are spoiled with a great language and awesome IDEs.
Why do most automation systems never really match the level of convenience and integration that we're used to?
NUKE is different. 💎
It is fully based on C# console applications and uses the type system to its full extent.
You want your auto-completion, package management, debugging, refactorings, formatting, and navigation back? It’s available right there❗️
[ Website ] : https://nuke.build/
[ GitHub ] : github.com/nuke-build/nuke
〰️〰️〰️〰️〰️〰️
#CSharp #Dotnet #BuildSystem
@ProgrammingTip
As C# developers, we are spoiled with a great language and awesome IDEs.
Why do most automation systems never really match the level of convenience and integration that we're used to?
NUKE is different. 💎
It is fully based on C# console applications and uses the type system to its full extent.
You want your auto-completion, package management, debugging, refactorings, formatting, and navigation back? It’s available right there❗️
[ Website ] : https://nuke.build/
[ GitHub ] : github.com/nuke-build/nuke
〰️〰️〰️〰️〰️〰️
#CSharp #Dotnet #BuildSystem
@ProgrammingTip
Telegram
Programming Tips Resources
Source Link 🐞
Source Link is a language- and source-control agnostic system for providing first-class source debugging experiences for binaries.
The goal of the project is to enable anyone building NuGet libraries to provide source debugging for their users with almost no effort.
Microsoft libraries, such as .NET Core and Roslyn have enabled Source Link.
Source Link is supported by Microsoft. ✅
〰️〰️〰️〰️〰️〰️
#DotNet #CSharp #Debugging
@ProgrammingTip
Source Link is a language- and source-control agnostic system for providing first-class source debugging experiences for binaries.
The goal of the project is to enable anyone building NuGet libraries to provide source debugging for their users with almost no effort.
Microsoft libraries, such as .NET Core and Roslyn have enabled Source Link.
Source Link is supported by Microsoft. ✅
〰️〰️〰️〰️〰️〰️
#DotNet #CSharp #Debugging
@ProgrammingTip
Telegram
Programming Tips Resources
aspnetcore-developer-roadmap.png
606.9 KB
ASP.NET Core Developer Roadmap in 2023 🔝
Roadmap to becoming an ASP.NET Core developer in 2023 🚀
[ GitHub ] : https://github.com/MoienTajik/AspNetCore-Developer-Roadmap
〰️〰️〰️〰️〰️〰️
#AspNetCore #DotNet #DotNetCore #CSharp
@ProgrammingTip
Roadmap to becoming an ASP.NET Core developer in 2023 🚀
[ GitHub ] : https://github.com/MoienTajik/AspNetCore-Developer-Roadmap
〰️〰️〰️〰️〰️〰️
#AspNetCore #DotNet #DotNetCore #CSharp
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
WireMock.NET 😮
WireMock.NET is a .NET library for stubbing and mocking HTTP services. With WireMock.NET, you can define the expected responses for particular requests, and the library will intercept and manage those requests for you.✔️
This allows for easy testing of the code that makes HTTP requests, without having to rely on the actual external service being available and without hacking HttpClient.🆒
Sample code snippet:
〰️〰️〰️〰️〰️〰️
#UnitTest #DotNet #CSharp
@ProgrammingTip
WireMock.NET is a .NET library for stubbing and mocking HTTP services. With WireMock.NET, you can define the expected responses for particular requests, and the library will intercept and manage those requests for you.
This allows for easy testing of the code that makes HTTP requests, without having to rely on the actual external service being available and without hacking HttpClient.
Sample code snippet:
[Test][ Blog ] : https://cezarypiatek.github.io/post/mocking-outgoing-http-requests-p1
public async Task sample_WireMock_usage()
{
// Setup WireMock.Net server
using var wireMock = WireMockServer.StartWithAdminInterface(port: 1080, ssl: false);
// Setup WebApplicationFactory
await using var appFactory = new WebApplicationFactory<Program>().WithWebHostBuilder(builder =>
{
builder.ConfigureAppConfiguration(configurationBuilder =>
{
// Override downstream service addresses pointing to WireMock address
configurationBuilder.AddInMemoryCollection(new Dictionary<string, string>
{
["ExternalServices:WeatherService"] = "http://localhost:1080"
});
});
});
// Prepare stub for outgoing request
wireMock
.Given(
Request.Create()
.WithPath("/api/v1.0/weather")
.WithParam("lat", "10.99")
.WithParam("lon", "44.34")
.UsingGet()
)
.RespondWith(
Response.Create()
.WithStatusCode(200)
.WithHeader("Content-Type", "application/json; charset=utf-8")
.WithBodyAsJson(new
{
temp = 298.48,
feels_like = 298.74,
temp_min = 297.56,
temp_max = 300.05,
pressure = 1015,
humidity = 64
})
);
// Automate tested app
}
〰️〰️〰️〰️〰️〰️
#UnitTest #DotNet #CSharp
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Telegram
Programming Tips Resources
Check out new C# 12 preview features! ⚡️
Three new features for C# 12😮 :
1️⃣ - Primary constructors for non-record classes and structs :
2️⃣ - Using aliases for any type:
3️⃣ - Default values for lambda expression parameters:
〰️〰️〰️〰️〰️〰️
#CSharp #DotNet
@ProgrammingTip
Three new features for C# 12
public class Student(int id, string name, IEnumerable<decimal> grades)
{
public Student(int id, string name) : this(id, name, Enumerable.Empty<decimal>()) { }
public int Id => id;
public string Name { get; set; } = name.Trim();
public decimal GPA => grades.Any() ? grades.Average() : 4.0m;
}
using Measurement = (string, int);
public void F(Measurement x)
{ }
var addWithDefault = (int addTo = 2) => addTo + 1;
addWithDefault(); // 3
addWithDefault(5); // 6
[ Article ] : https://devblogs.microsoft.com/dotnet/check-out-csharp-12-preview〰️〰️〰️〰️〰️〰️
#CSharp #DotNet
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Telegram
Programming Tips Resources
.NET 8 - Keyed service dependency injection container support 🔝
Keyed services are useful when you have an interface/service with multiple implementations that you want to use in your app. What's more, you need to use each of those implementations in different places in your app.☄️
Sample:
〰️〰️〰️〰️〰️〰️
#DotNet #DotNetCore #AspNetCore #CSharp
@ProgrammingTip
Keyed services are useful when you have an interface/service with multiple implementations that you want to use in your app. What's more, you need to use each of those implementations in different places in your app.
Sample:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddKeyedSingleton<INotificationService, SmsNotificationService>("sms");
builder.Services.AddKeyedSingleton<INotificationService, EmailNotificationService>("email");
builder.Services.AddKeyedSingleton<INotificationService, PushNotificationService>("push");
[ Article ] : https://andrewlock.net/exploring-the-dotnet-8-preview-keyed-services-dependency-injection-support〰️〰️〰️〰️〰️〰️
#DotNet #DotNetCore #AspNetCore #CSharp
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Telegram
Programming Tips Resources
Introducing .NET Aspire: Simplifying Cloud-Native Development with .NET 8 🔥
.NET Aspire is an opinionated stack for building resilient, observable, and configurable cloud-native applications with .NET. It includes a curated set of components enhanced for cloud-native by including service discovery, telemetry, resilience, and health checks by default.👍
Sample Usage:
[ Article ] : https://devblogs.microsoft.com/dotnet/introducing-dotnet-aspire-simplifying-cloud-native-development-with-dotnet-8
〰️〰️〰️〰️〰️〰️
#DotNET #AspNetCore #CSharp #Aspire
@ProgrammingTip
.NET Aspire is an opinionated stack for building resilient, observable, and configurable cloud-native applications with .NET. It includes a curated set of components enhanced for cloud-native by including service discovery, telemetry, resilience, and health checks by default.
Sample Usage:
var builder = DistributedApplication.CreateBuilder(args);
var cache = builder.AddRedisContainer("cache");
var apiservice = builder.AddProject<Projects.AspireApp_ApiService>("apiservice");
builder.AddProject<Projects.AspireApp_Web>("webfrontend")
.WithReference(cache)
.WithReference(apiservice);
builder.Build().Run();
[ Article ] : https://devblogs.microsoft.com/dotnet/introducing-dotnet-aspire-simplifying-cloud-native-development-with-dotnet-8
〰️〰️〰️〰️〰️〰️
#DotNET #AspNetCore #CSharp #Aspire
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Microsoft News
Introducing .NET Aspire: Simplifying Cloud-Native Development with .NET 8
Introducing .NET Aspire: A cloud ready stack for building observable, production ready, distributed applications