Visual Studio 2022 17.5 has just been released and one of my favourite new features is the INTEGRATED HTTP CLIENT.
It's not a Postman killer yet but it so awesome to be able to both send and debug REST requests directly from within
#visualstudio
❤ ...
#dotnet
Primary Constructors in .NET 8 ⬇
A lot less boilerplate.
What do you think?
Thanks to Steven Giesel on LinkedIn for the original image ->
#dotnet
#csharp
There's a huge abstraction fetish in
#dotnet
I've found.
In a system I worked on in the not too distant past, I estimated I could remove 60-70% of the code AND the system would do the exact same thing. Full of abstractions, indirection, pass through layers, 'just in case'
How to find slow queries in Entity Framework ⬇
By using Entity Frameworks interceptor system and hooking into the ReaderExecuted event we can see exactly how long queries are taking to execute.
Bookmark it!
#dotnet
#efcore
Amend default debugging view for a class ⬇
I learnt something new recently, we can change the standard debugging view for a C# class by using the DebuggerDisplay attribute.
#dotnet
C# LINQ Mind Map ⬇
What a great infographic.
Bookmark it for future reference.
Thanks to Steven Giesel on LinkedIn for the original image ->
#dotnet
#csharp
Paste JSON As Classes in Visual Studio ⬇
Not a lot of devs are aware of this feature in VS but it's super useful.
It's available from the Edit menu.
Have you used this functionality before?
#dotnet
#csharp
C# Explicit Operator simple example
In .NET we have plenty of ways to map objects to one another. Below is an example of using the Explicit operator to do this.
#dotnet
Entity Framework Query Plan Visualizer ⬇
This new Visual Studio extension by
@GioDalakishvili
looks like it could be a game changer. It enables us to view the query plan of our queries directly inside VS.
#dotnet
ASP .NET Core Best Practices 💡
Nice article providing guidelines from Microsoft for maximizing performance and reliability of ASP .NET Core apps.
Which of these techniques are you using in your apps right now?
Link in 2nd tweet below.
#dotnet
LINQ Mind Map ⬇
What a great infographic.
Perfect for beginners trying to get a handle on all of the amazing possibilities that LINQ offers in .NET.
Bookmark it for future reference.
Thanks to Steven Giesel on LinkedIn for the image ->
#dotnet
Visual Studio Endpoints Explorer 💡
The Endpoints Explorer window allows us to see an overview of all endpoints in a solution.
We can also navigate directly to the code for an endpoint and generate a .http file request stub for it.
To open it select View > Other Windows >
.NET LINQ Skip and Take visualized ⬇ ...
Includes range and indices syntax new since C# 8.
Thanks to Steven Giesel for the original post -> .
#dotnet
#csharp
How to find slow queries in Entity Framework ⬇
By using Entity Frameworks interceptor system and hooking into the ReaderExecuted event we can see exactly how long queries are taking to execute.
Bookmark it!
#dotnet
#efcore
Deep .NET with Scott Hanselman and Stephen Toub
YouTube playlist featuring all five awesome deep dive sessions on various .NET topics with Scott Hanselman and Stephen Toub.
Devs asked for some more 'advanced' level content and this series is really delivering so far, thank you
.NET 8 v .NET 9 Exception Handling benchmarks
Have just ran these on preview 3, wow ❤.
76% faster handling in .NET 9 for the benchmark code I ran (in the 2nd tweet below).
#dotnet
Entity Framework SQL Query Plan Visualizer 👏🏻
The EFCore.Visualizer Visual Studio extension looks like it could be a game changer.
It allows us to view the query plan of our SQL queries directly inside VS.
Will you try it?
#dotnet
LINQ methods in C# cheatsheet ⬇ ...
Bookmark this post and revisit it anytime you need a quick refresher of LINQ methods!
Thanks to Georgios Petas for the original post ->
#dotnet
#csharp
.NET 8 v .NET 9 exception handling benchmarks
76% faster handling in .NET 9 for the benchmark code I ran (in the 1st comment below).
Should we use exceptions for control flow now?
Still no 😉
#dotnet
.NET 9 LINQ Mind Map 🔥
Includes the three new LINQ methods coming in .NET 9:
"Index," "CountBy," and "AggregateBy".
Thanks to Steven Giesel on LinkedIn for the image ->
#dotnet
C# unit test with Builder Pattern example
Who is using the builder pattern to help setup their test data?
In what situations is the extra maintenance overhead justified? When is it not justified?
#dotnet
I'm hearing a lot about reduced build times in Visual Studio due to the new BUILD ACCELERATION feature in VS 2022 17.5.
The example below goes from 26 to 1.5 seconds 🚀...
Remember it's opt-in.
Set AccelerateBuildsInVisualStudio to use it.
#visualstudio
#dotnet
#csharp
Just tested the new build acceleration in latest
@VisualStudio
and holy crap the impact is gigantic. 🚀
30 project solution with millions LOC.
Previously:
-Build Solution: ~ 26 seconds
-Change something in a low-level project
-Build: ~ 26 seconds
With build acceleration👇
Amend default debugging view for a class ⬇
Did you know we can change the standard debugging view for a C# class by using the DebuggerDisplay attribute?
Thanks to Adem Sahin on LinkedIn for the image ->
#dotnet
𝐈𝐝𝐞𝐧𝐭𝐢𝐭𝐲 𝐢𝐧 𝐀𝐒𝐏 .𝐍𝐄𝐓 𝐂𝐨𝐫𝐞 𝟴 🔥🔥🔥
Have you looked at the new Identity API in .NET 8 yet?
Thanks to Nabi Karampoor on LinkedIn for the original image ->
#csharp
#dotnet
Built-in OpenAPI doc generation in .NET 9 ❤
ASP .NET Preview 4 will have OpenAPI doc generation capabilities. Swashbuckle is awesome but it's nice to have this built in now.
What do you think?
#dotnet
.NET devs, for those that are not using tooling,
how are you doing manual object - object mapping?
and why this approach? 🤔
I've put five examples of common approaches in this thread, starting with extension methods below.
#dotnet
Which .NET mocking library syntax do you prefer from the below test examples?
Moq?
NSubstitute?
FakeItEasy?
... and which library do you use and why?
#dotnet
#csharp
Accepted into Microsoft MVP Program 🎉
I'm so happy and proud to say that this week I was presented with the Microsoft Most Valuable Professional (MVP) award in recognition of my 'outstanding contributions to the technical community' in these areas ...
.NET
Developer Tools
It
C# Access Modifiers summary table
I got this summary table from MS learn.
It's definitely worth a bookmark.
Note the file access modifier is new from C# 11.
#dotnet
In .NET how do you like to convert objects from one type to another? AutoMapper? Mapster? Plain left-right assignment perhaps using the Explicit Operator or Extension methods?
Example of explicit operator below 👇🏻 ...
#dotnet
#csharp
#chatgpt
#visualstudio
#automapper
Build asych from scratch in C# with Stephen Toub
To explain how asych/await works in .NET in this video Stephen builds his own async/await implementation completely from scratch and explains throughout the way.
Such an insightful video.
#dotnet
Why use collections in the new System.Collections.Frozen namespace in .NET 8 versus the existing ones in System.Collections.Immutable?
Good clarity on the differences from Stephen Toub on the MS blog the other day 👇 ...
#dotnet
#csharp
Dev Tunnels in Visual Studio 💡
Devs tunnels allow us to expose (and debug) our localhost APIs via remote URLs.
Previously when integrating into a third party service provider which had webhooks or callbacks to notify our apps that some event has happened we needed a
In .NET we have plenty of ways to map objects to one another ...
Below is an example (courtesy of ChatGPT) of using the EXPLICIT OPERATOR 👇🏻 ...
How do you like to map objects?
#dotnet
#csharp
LINQ changed to use is null consistently ⬇
Looks like I'm not the only one who prefers is null instead of == null. This 75 file PR was merged yesterday.
For me I just think is null reads more like English so is more natural.
Which approach do you prefer?
#dotnet
Paste JSON As Classes in Visual Studio ⬇
Not a lot of devs are aware of this feature in VS but it's super useful.
It's available from the Edit menu.
Have you used this functionality before?
#dotnet
#csharp
New Guard Clauses coming in .NET 8 👇🏻 ....
These can really help clean up our code ❤ ...
What do you think?
Will you use these new clauses?
#dotnet
#csharp
𝗘𝘃𝗼𝗹𝘂𝘁𝗶𝗼𝗻 𝗼𝗳 𝗖# ⬇
C# 12 will be officially launched today 👏🏻 ...
Here's a nice recap of the major items included in each version.
Thanks to Aram Tchekrekjian on LinkedIn for the image ->
#dotnet
Amend default debugging view for a class ⬇
I learnt something new today, we can change the standard debugging view for a C# class by using the DebuggerDisplay attribute.
Thanks to Adem Sahin on LinkedIn for the image ->
#dotnet
.NET 9 will have a new Lock() type 🔒
Great to have a dedicated lock type as it gives us a way to express the intent of our code more clearly.
Thanks to Steven Giesel on LinkedIn for the image ->
#dotnet
Visual Studio 17.12 Preview 3 will
display method return values inline 💖
Have always been a fan of intermediary variables as a way to reduce cognitive load for devs for method return values but I think this changes the game 👋🏻
#dotnet
Visual Studio 17.12 Preview 3 is now available to download. It's packed with great new features including displaying method return values and the ability to copy files between instances of VS.
.NET 9 will have a new Lock() type 🔒
Great to have a dedicated lock type as it gives us a way to express the intent of our code more clearly.
Thanks to Steven Giesel for the image ->
#dotnet
The SOLID PRINCIPLES are great but I cringe every time I hear a dev say something is a 'violation' of one of them as if they are laws that MUST be abided by all the time ...
What do you think?
Are we too eager to apply SOLID to everything?
#dotnet
#devlife
#SoftwareEngineering
Paste JSON As Classes in Visual Studio ⬇
Not a lot of devs are aware of this feature in VS but it's super useful.
It's available from the Edit menu.
Have you used this functionality before?
#dotnet
Returning multiple values from a method in C# ? ⬇
Consider ValueTuples (C# 7) as a lightweight alternative to strongly typed classes when you only need to return a small number of values from a method.
What do you think?
Do you use ValueTuples often?
#dotnet
#csharp
C# client side GUIDs sortable in SQL Server ⬇
When we need a GUID generated on the client side using Entity Frameworks SequentialGuidValueGenerator method creates GUIDs which are sortable on SQL Server.
Note that GUIDs created with the built in C# Guid.NewGuid() method are
Four awesome Visual Studio features
... you might not be aware of!
+ HTTP files
+ Endpoints Explorer
+ Dev Tunnels
+ Paste Json as Classes
Scroll the thread for details ...
#dotnet
@VisualStudio
StringSyntax attribute example 💡
The StringSyntax Attribute (.NET 7+) allows us to tell Visual Studio what kind of string (e.g. regex, datetime format, JSON etc.) we are working with in order to get correct intellisense and highlighting.
Have you used it yet?
#dotnet
15 Design Patterns in simple words ⬇
What a great infographic.
Bookmark it for future reference.
Thanks to Keivan Damirchi on LinkedIn for the original image ->
#devlife
#SoftwareEngineering
.NET built-in IValidatableObject example ⬇
I love FluentValidation, but the built-in IValidatableObject does the job for me most of the times when I'm building ASP .NET MVC apps.
Have you used it?
How are you validating input from the UI or API?
#dotnet
It's amazing to see the performance improvements of String.Replace across multiple versions of .NET🚀...
When you have such a big improvement from 5 -> 6, you think most possibilities for further optimization are gone, but no in .NET 7 perf improves again💪🏻...
#dotnet
#csharp
New Visual Studio Solution format 👏🏻
Readability and mergeability is massively improved.
The example below shows the new format at the bottom.
Turn it on from from Visual Studio 2022 v17.10 via Preview Features -> Use Solution File Persistence Model and then save your
How to find slow queries in Entity Framework ⬇
By using Entity Frameworks interceptor system and hooking into the ReaderExecuted event we can see exactly how long queries are taking to execute.
Bookmark it!
#dotnet
.NET LINQ expressions now supported in
Visual Studio IEnumerable Visualizer
From Visual Studio 2022 Version 17.11.1, while visualizing a collection, we can now modify the expressions textbox with a LINQ query. The visualizer updates in real-time, reflecting the data change
Discriminated unions in C# 🥳
Looks like this is now an official proposal.
It might actually be happening.
Proposal link in 2nd tweet below ⬇️
#dotnet
#csharp
C# unit test with Builder Pattern example ⬇
Who is using the builder pattern to help setup their test data?
In what situations is the extra maintenance overhead justified? When is it not justified?
I want your opinion, there is no 'right' / 'wrong' answers.
#dotnet
Paste JSON As Classes in Visual Studio ⬇
Not a lot of devs are aware of this feature in VS but it's super useful.
It's available from the Edit menu.
Have you used this functionality before?
#dotnet
𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲 𝗯𝗲𝘁𝘄𝗲𝗲𝗻 𝗰𝗼𝗻𝘀𝘁 & 𝗿𝗲𝗮𝗱𝗼𝗻𝗹𝘆 𝗶𝗻 𝗖#? ⬇
The main diff between const & readonly is that consts are initialized 𝗮𝘁 𝗰𝗼𝗺𝗽𝗶𝗹𝗲 𝘁𝗶𝗺𝗲, while readonly variables can be initialized either at compile time or runtime.
#dotnet
#csharp
C# Tip 💡 - Get method CALLER info ...
Did you know we can get info about the caller of a method using
#csharp
(5+) info attributes?
Below is a simple example ...
What do you think?
Have you use info attributes before?
#dotnet
LINQ methods in C# cheatsheet ⬇
Bookmark this post and revisit it anytime you need a quick refresher of LINQ methods!
Thanks to Georgios Petas on LinkedIn for the image ->
#dotnet
#csharp
Vertical Slice Architecture example ⬇
This is just one way to approach VSA but the type of code structure below is IMHO a dream to work with.
Controller (single action only), ViewModel(s) and MediatR Request and Request Hander in the same file.
The view is obviously separate
It's 2023 and I still hate 'clean' architecture. It hurts my brain and makes me have to 'think' too much. Why spread code related to a single use case across 4,5,6 projects?
Vertical slice architecture on the other hand ❤❤❤
#dotnet
#SoftwareEngineering
#softwaredevelopment
.NET 9 - new LINQ Index operator ⬇
This allows us to get the index of the current iteration. This is already possible using Select but the new operator is a little more explicit and has a nicer API IMHO.
What do you think?
Thanks to Steve Giesel on LinkedIn for the image ->