如何快速创建 Visual Studio 代码片段?
使用 Visual Studio 的代码片段功能,我们可以快速根据已有模板创建出大量常用的代码出来。ReSharper 已经自带了一份非常好用的代码片段工具,不过使用 ReSharper 创建出来的代码片段只能用在 ReSharper 插件中。如果团队当中有一些小伙伴没有 ReSharper(毕竟很贵),那么也可以使用到 Visual Studio 原生的代码片段。
Visual Studio 的官方文档有演示如何创建 Visual Studio 的代码片段,不过上手成本真的很高。本文介绍如何快速创建 Visual Studio 代码片段,并不需要那么麻烦。
Reading the Source Code of Microsoft.NET.Sdk, Writing the Creative Extension of Compiling
Project
node starts to support the Sdk
attribute since MSBuild release the 15.0 version which is embedded in Visual Studio 2017. For the Sdk
attribute, the C# project file whose file extension is csproj becomes much more powerful and extensible.
We’ll try to read the source code of Microsoft.NET.Sdk
which is the default Sdk value of C#.NET project and try to write some creative extension of compiling.
App will crash when using the when keyword in a catch expression
We know that we can add a when
keyword after a catch
filter. But if there is another exception happened in the when
expression, the app will totally crash.
This happens in .NET Framework 4.8 but in .NET Core 3.0, it works correctly as the document says.
Maybe this is a bug in the .NET Framework 4.8 CLR.