2021-08-20

Published on Friday, 20 August 2021

主なトピックス

今週は .NET 6 Preview 7 と Visual Studio 2022 のフォローアップがメインです。

Performance Improvements in .NET 6 | .NET Blog はなかなかボリュームのある形で .NET 6 でのパフォーマンス改善についてベンチマークやアセンブリを見せながら説明されています。

.NET のリポジトリがそろそろ .NET 7 に向けて準備を始めていることもちらほら見えています。

ヘッドライン

Breaking change with string.IndexOf(string) from .NET Core 3.0 -> .NET 5.0 · Issue #43736 · dotnet/runtime

https://github.com/dotnet/runtime/issues/43736

.NET 5 でグローバリゼーションのライブラリが NLS から ICU へと変わった結果、Windows 上で IndexOf, LastIndexOf, IsSuffix, IsPrefix といった文字列比較の結果が以前と変化した。例えば "\r\n".IndexOf("\n")-1 となってしまったので ICU の Break Iterator をカスタマイズすることで従来の振る舞いになるように修正された。

Main is now targeting .NET 7 · Issue #198 · dotnet/announcements

https://github.com/dotnet/announcements/issues/198

.NET 6 RC1 以降各種 dotnet のリポジトリの main ブランチが .NET 7 をターゲットにするように。

.NET Core 2.1 container images will be deleted from Docker Hub | .NET Blog

https://devblogs.microsoft.com/dotnet/net-core-2-1-container-images-will-be-deleted-from-docker-hub/

.NET Core 2.1 のサポートが2021年8月21日で終了することに伴い Docker Hub から .NET Core 2.1 のコンテナーイメージを削除。継続してイメージを利用したい場合は MCR (mcr.microsoft.com) でホストされるものへの移行が必要。

Fluent Assertions 6.0, the biggest release ever

https://ddoomen.medium.com/fluent-assertions-6-0-the-biggest-release-ever-5086a7bfa13e

Fluent Assertions 6.0 がリリース。

.NET Framework 4.5, .NET Standard 1.3, 1.6 および MSTest, NSpec v1 and 2, xUnit 1, Gallio, MBUnit のサポートが削除。async 関連の改善が多く行われた。マイグレーションについてはガイドを参照

BufferedStream, TaskCompletionSource<T>, enum, IReadOnlyDictionary<K, V> のサポートの追加。構造的な等価アサーションの改善など。

Version 6.0.0-preview7 of #npgsql and the #efcore provider for #postgres are now available on nuget.org.

https://twitter.com/shayrojansky/status/1427264414093299715

Npgsql と Npgsql Entity Framework Core Provider の 6.0.0-preview 7 がリリース。

Release EF Core 5.0.9 · dotnet/efcore

https://github.com/dotnet/efcore/releases/tag/v5.0.9

Entity Framework Core 5.0.9 がリリース。いくつかのバグ修正。

MVVM Light is not maintained anymore.

https://github.com/lbugnion/mvvmlight

MVVM Light Toolkit がライブラリメンテナンス終了のアナウンス。今後は Windows Community ToolkitMicrosoft MVVM Toolkit の利用を推奨。

Introducing DevOps-friendly EF Core Migration Bundles | .NET Blog

https://devblogs.microsoft.com/dotnet/introducing-devops-friendly-ef-core-migration-bundles/

Entity Framework Core 6.0.0-preview7 で利用可能になった migration bundle について。

support --prerelease for dotnet tool by wli3 · Pull Request #19646 · dotnet/sdk

https://github.com/dotnet/sdk/pull/19646

.NET Global/Local Tools でインストールするパッケージとして prerelease としてマークされているものをインストールできるようにするフラグが追加(今までは NuGet パッケージにはあったが .NET Tools にはなかった)。

アーティクル

Performance Improvements in .NET 6 | .NET Blog

https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-6/

[あとで書く]

Understanding the cost of C# delegates | .NET Blog

https://devblogs.microsoft.com/dotnet/understanding-the-cost-of-csharp-delegates/

デリゲートのインスタンスのコスト、ラムダ式を使った際に発生するインスタンス生成について。

Revamped Project Properties UI | Visual Studio Blog

https://devblogs.microsoft.com/visualstudio/revamped-project-properties-ui/

Visual Studio 2022 でのプロジェクトプロパティ画面の刷新されることの解説。Visual Studio のテーマに応じた外観、設定項目の検索、プロパティの評価値のプレビューなど。

Flexible theming capabilities for Visual Studio | Visual Studio Blog

https://devblogs.microsoft.com/visualstudio/flexible-theming-visual-studio/

Visual Studio 2022 のテーマについて。システムのテーマ (Windows の Dark / Light モード) に合わせて変更する設定が追加。

Debugging External Sources with Visual Studio | Visual Studio Blog

https://devblogs.microsoft.com/visualstudio/debugging-external-sources-with-visual-studio/

Visual Studio 2022 Preview 3 で追加された External Source についての解説。

.NET の BCL や Newtonsoft.Json, CsvHelper, xUnit.net などのような Source Link や Symbol Server にアップロードされているソースコードを読み込み、Solution Explorer 上で展開してデバッグできる機能。

Improving developer security with Visual Studio 2022 | Visual Studio Blog

https://devblogs.microsoft.com/visualstudio/improving-developer-security-with-visual-studio-2022/

Visual Studio 2022 で強化されるソリューションの読み込み時のセキュリティ機能について。デザインタイムビルドによってセキュリティ侵害が発生する可能性があるため、以前からプロジェクトを開く際に確認する仕組みが Visual Studio にはありその機能の刷新。

Visual Studio Code の Workspace Trust と似た機能で、フォルダー、git リポジトリ、リポジトリオーナーを Trusted Location に指定して信頼するか、信頼しない Restrict モードを選択する。Restrict モードではデザインタイムビルド (Analyzer やソース生成など) が機能しないようになる。ただし現時点の Preview ではまだ利用できない。

最初の C# プログラム(.NET 6 新テンプレート)

https://ufcpp.net/blog/2021/8/newprojecttemplate/

.NET 6 から使用される新しいプロジェクトテンプレートについて。DisableImplicitNamespaceImports/ImplicitUsings ディレクティブのような Preview 7 と RC 1 以降での違いについても。

Rider 2021.3 Roadmap | The .NET Tools Blog

https://blog.jetbrains.com/dotnet/2021/08/18/rider-2021-3-roadmap/

Rider 2021.3 のロードマップ。C# 10 や .NET 6 対応、次期 OS やApple Silicon 対応、Multiple Startup Projects、MAUI など。

ReSharper 2021.3 Roadmap | The .NET Tools Blog

https://blog.jetbrains.com/dotnet/2021/08/18/resharper-2021-3-roadmap/

ReSharper 2021.3 のロードマップ。Visual Studio 2022 や C# 10 対応、LINQ Visualizer など。

Blazor WebAssemblyとAuth0でユーザー認証

https://zenn.dev/kaorumori/articles/b9f67f1e8946c2

Blazor WebAssembly と Auth0 を組み合わせてユーザー認証を組み込む手順の解説。

ライブラリ、リポジトリ、ツールなど

spectreconsole/spectre.console: A .NET library that makes it easier to create beautiful console applications.

https://github.com/spectreconsole/spectre.console

コマンドラインアプリケーションの実装に関連するオールインワンライブラリー。

コマンドラインパーサーからカラーリング、テーブル、入力補助などリッチなコンソールアプリケーションを実装できる。

サイト、ドキュメントなど

Various goodies from Dotnetos!

https://goodies.dotnetos.org/

.NET の診断、async、メモリに関するポスター画像や、スライド。

ConfigureAwait と Deadlock に関する図やメモリレイアウトに関する図など。

Awesome Blazor Browser

https://jsakamoto.github.io/awesome-blazor-browser/

awesome-blazor をカテゴリごとに絞り込んだり検索できるようにしたサイト。

Visual Studio Extensibility Cookbook

https://www.vsixcookbook.com/

Visual Studio の拡張 VSIX を作るためのクックブック。拡張や開発の初めかたの手順などがまとまっている。

ツイート

I have been open here with all of my work for the past decade, and I will be about leaving Stack Overflow as well. Here is what I sent to friends and family here at Stack, a place I will forever love and still highly recommend to any developer looking to improve the world: pic.twitter.com/E4Zxs6xDqF— Nick Craver (@Nick_Craver) August 16, 2021

https://twitter.com/nick_craver/status/1427323097380794371

Nick Craver さんが Stack Exchange を離れることに。

ReadAtLeastAsync is one of my new favorite APIs in the latest version of System.IO.Pipelines. Makes reading length prefixed protocols a breeze. #dotnet pic.twitter.com/jNe1j04hbx— David Fowler 🇧🇧💉💉 (@davidfowl) August 15, 2021

https://twitter.com/davidfowl/status/1426719909971521536

.NET 6 の System.IO.Pipelines から使用できる、最小限必要な長さを指定して読み出す PipeReader.ReadAtLeastAsync メソッド について。

We migrated Stack Overflow's ad server from .NET 4.6.2 to .NET 5.0 and we are testing it on a canary server in production. We are seeing big improvements in memory usage and in server response times. It wasn't the main goal of the migration, but definitely a nice to have. pic.twitter.com/Z1dkKfYQWp— Juan Rodríguez (@juanrodriguezce) August 18, 2021

https://twitter.com/juanrodriguezce/status/1428070925698805771

Stack Overflow の広告サーバーを .NET 4.6.2 から .NET 5.0 に移行して、本番環境でのカナリアテストを行ったところメモリ使用量とレスポンスタイムが改善された。

Deep Dive

More LoggerMessageAttribute by pranavkm · Pull Request #35368 · dotnet/aspnetcore

https://github.com/dotnet/aspnetcore/pull/35368

ASP.NET Core のロガーを LoggerMessage を使う形から Source Generator によって生成するようにする PR。

Use PoolingAsyncValueTaskMethodBuilder on various ReadAsync methods. by adityamandaleeka · Pull Request #35011 · dotnet/aspnetcore · GitHub

https://github.com/dotnet/aspnetcore/pull/35011

Kestrel のボディの読み取りメソッドに PoolingAsyncValueTaskMethodBuilder を使用することでアロケーションを抑える PR。