主なトピックス
paint.net 4.3 alpha がリリースされ、α版ですが比較的有名なデスクトップアプリケーションの .NET 5 への移行が実現しています。
ヘッドライン
paint.net 4.3 alpha (build 7894) – paint.net blog
https://blog.getpaint.net/2021/08/11/paint-net-4-3-alpha-build-7894/
paint.net 4.3 alpha がリリース。
このバージョンで .NET Framework から .NET 5 への移行が行われた。ユーザーからは表面上変化が見えない形での移行。
.NET 5 へと移行したことに伴い self-contained deployment により .NET のインストールが不要になり、パフォーマンスも向上。起動時間は AOT の効果で 5% 程度短くなる、ARM64 ビルドの提供も可能となった、など。
Update implicit global usings feature to address issues · Issue #19521 · dotnet/sdk
https://github.com/dotnet/sdk/issues/19521
Preview 7 で導入した暗黙の global usings でいくつか問題が出たので C# プロジェクトでは明示的に指定しない限り有効とならないようにするよう挙動の変更。SDK 6.0.100-rc.1 にて入る予定。
- C# プロジェクトでは
DisableImplicitNamespaceImports
MSBuild プロパティをImplicitUsings
プロパティに変更- Visual Basic のプロジェクトでは引き続き
DisableImplicitNamespaceImports
- Visual Basic のプロジェクトでは引き続き
ImplictUsings
プロパティがenable
またはtrue
と定義されている場合のみ暗黙の using が使われる- それに伴い .NET 6 プロジェクトのテンプレートでは
<ImplicitUsings>enable</ImplicitUsings>
が含まれてデフォルト有効化される形となる
[API proposal] Attribute for passing caller identity implicitly · Issue #4984 · dotnet/csharplang
https://github.com/dotnet/csharplang/issues/4984
CallerMemberNameAttribute
属性などと同様にメソッドの引数に呼び出し元のアセンブリ、型、メソッドをコンパイル時に差し込むための属性の提案。Assembly.GetCallingAssembly
の AOT セーフで高速な代替として。
[API Proposal]: RegexOptions.Constrained · Issue #57891 · dotnet/runtime
https://github.com/dotnet/runtime/issues/57891
.NET 7 で正規表現エンジンに DFA モードをオプトインで追加することを検討しているので、そのためのフラグを追加する提案。
User Story: .NET 7.0 developers can verify more APIs for correct usage to speed up their development #57797
https://github.com/dotnet/runtime/issues/57797
.NET 5 から組み込み Roslyn Analyzer が導入されたので .NET ベースライブラリの使用方法を支援するためにアナライザーを拡充しようという話の .NET 7 向けの話。
Big-endian platforms not supported · Issue #35709 · dotnet/aspnetcore · GitHub
https://github.com/dotnet/aspnetcore/issues/35709
ASP.NET Core の様々な個所でビッグエンディアンを考慮していないため、IBM Z (s390x) で動作しないという Issue と Pull requests。
.NET 6 からターゲットアーキテクチャに s390x (linux-s390x) が追加され、ベースライブラリや CoreCLR へのパッチなどが入っている。現時点では CoreCLR ではなく Mono ランタイムを使用するとのこと。
- Add public Architecture enum value for s390x · Issue #52909 · dotnet/runtime
- is:pr s390x is:closed · Pull requests · dotnet/runtime
- Build support for s390x: installers and packages by uweigand · Pull Request #53950 · dotnet/runtime
アーティクル、スライドなど
The Journey to Accessible Apps: Making Visual Text Accessible | Xamarin Blog
https://devblogs.microsoft.com/xamarin/the-journey-to-accessible-apps-making-visual-text-accessible/
モバイルアプリで目に見える文字をアクセシブルにするときに考慮する点やテスト方法などについて。
Google App Engine で .NET 5 を動かす
https://zenn.dev/shimat/articles/4c4e292646f32e
Google App Engine Flexible (GAE) では.NET Core 3.1 までしかコンテナーイメージがないため .NET 5 のコンテナーをビルドする方法について。
How to build an interactive command-line application in .NET
https://dev.to/shibayan/how-to-build-an-interactive-command-line-application-in-net-4oic
Sharprompt を使用して質問や選択などの入力をもつインタラクティブなコマンドラインアプリケーションの作り方。
Flavours of rounding
https://dev.to/semuserable/flavours-of-rounding-42e0
.NET を含む、いろいろな言語やランタイムでの丸め (例:Math.Round
) の例。
[CEDEC 2021] 運用中タイトルでも怖くない! 『メルクストーリア』におけるハイパフォーマンス・ローコストなリアルタイム通信技術の導入事例
https://www.slideshare.net/NaoyaKishimoto/cedec-2021
MagicOnion (gRPC ベースの C# RPC フレームワーク) を使用した ASP.NET Core サーバー、Unity クライアントでのリアルタイム通信技術を Kubernetes 環境に Agones とともに構築した事例。
15 Tips and Tricks to Increase Your Productivity in Visual Studio 2019
Visual Studio 2019 で便利な小ネタ15選の紹介。
In C#, how do I get the descriptive text for an HRESULT? | The Old New Thing
https://devblogs.microsoft.com/oldnewthing/20210826-00/?p=105609
COM の HRESULT に対応する文字列を簡単に取得する方法。Marshal.GetExceptionForHR
メソッドで Exception を作成して Message を取り出す。
6 Hidden Productivity Gems in Resharper and Rider - Michael's Coding Spot
https://michaelscodingspot.com/productivity-in-resharper-and-rider/
ReSharper と Rider の目立たない便利機能6選の紹介。
Bite-Size C# 10 - Semi-Auto Properties and 'field' Keyword
https://exceptionnotfound.net/bite-size-csharp-10-semi-auto-properties-using-field-keyword/
C# 10 からプロパティのバッキングフィールドにアクセスする field
キーワードが追加されるので半自動実装プロパティが実現できるという話。
ライブラリ、リポジトリ、ツールなど
philippseith/signalr: SignalR server and client in go
https://github.com/philippseith/signalr
Go による SignalR のサーバーとクライアント実装。
サイト、ドキュメントなど
ツイート
Not sure when it happened but Visual Studio 2019 is now in the Microsoft Store on Windows 11 :D pic.twitter.com/hHElUUZ5yz— Zac Bowden (@zacbowden) August 24, 2021
https://twitter.com/zacbowden/status/1430183656677683219
Visual Studio 2019 が Microsoft Store (Windows 11 のストア)から入手可能に。
IL Language view has been improved by showing opcode bytes (for next release) pic.twitter.com/iljS3gcyA1— ILSpy Team (@ilspy) August 26, 2021
https://twitter.com/ilspy/status/1430882132596072451?s=12
ILSpy の時期リリースで IL Language ビューにオペコードバイト列も表示されるように。
Deep Dive
Enable SocketHttpHandler to decompress zlib or deflate by stephentoub · Pull Request #57862 · dotnet/runtime
https://github.com/dotnet/runtime/pull/57862
従来 SocketsHttpHandler では Content-Encoding: deflate
を DeflateStream で展開していたところ、deflate
の圧縮は zlib 形式で互換性がないことがあったので .NET 6 で ZLibStream クラスを新たに用意してそちらを使用するようにしたが、実際はどちらのパターンもあるので自動でスイッチするようにするという PR。
- [release/6.0-rc1] Enable SocketHttpHandler to decompress zlib or deflate by github-actions · Pull Request #57940 · dotnet/runtime
- HttpClient doesn't decompress "deflate" correctly · Issue #38022 · dotnet/runtime
- Implement ZLibStream and fix SocketsHttpHandler deflate support by stephentoub · Pull Request #42717 · dotnet/runtime
- HttpClient deflate decompression error · Issue #57604 · dotnet/runtime
Update Components to use LoggerMessage by pranavkm · Pull Request #35585 · dotnet/aspnetcore
https://github.com/dotnet/aspnetcore/pull/35585
ASP.NET Core での Source Generator を使用したロガーへの置き換えの PR。
Use lambda expression and method group signature in type inference by cston · Pull Request #55786 · dotnet/roslyn · GitHub
https://github.com/dotnet/roslyn/pull/55786
ラムダ式の型推論の強化の PR。
Migrate LoggerMessageGenerator to IIncrementalGenerator by eerhardt · Pull Request #58068 · dotnet/runtime
https://github.com/dotnet/runtime/pull/58068
ロガーのコード生成を行う Source Generator である LoggerMessageGenerator を新しい仕組みの IIncrementalGenerator に移行したいという PR。
Web Relax the induced GC strategy in ServerDispatcher by sharwell · Pull Request #55814 · dotnet/roslyn
https://github.com/dotnet/roslyn/pull/55814
VBCSCompiler (コンパイラーサーバー) がクリーンナップのために定期的に GC を実行するが、何度も実行する形になっていて CPU を消費しているので GC.GetTotalMemory(forceFullCollection: true);
一回で終わらせるようにする PR。
元々は VBCSCompiler がメモリリークしている(ように見えているだけ)という強いフィードバックがあり、見かけ上減らしたかったためこのようなコードを実行していた。この処理を行うことでのパフォーマンス上のインパクトは大きくないかあるいは WeakReference が回収される分悪くなる可能性もある。なお GC を11回実行していたのは実験した結果、GC 中の Finalizer などで生き残ってしまうものも含めて処理するにはそれぐらいが良かったからとのこと。
GC.GetTotalMemory(forceFullCollection: true)
では同様に繰り返し GC を呼び出して縮めるがある程度効果のあるまでという仕組みになっている。
https://github.com/dotnet/runtime/blob/7994e5940d8e093e6a7a6008358b539f9d8a352d/src/coreclr/System.Private.CoreLib/src/System/GC.cs#L331-L353
Automatically provide global using by kzu · Pull Request #516 · spectreconsole/spectre.console
https://github.com/spectreconsole/spectre.console/pull/516
パッケージに .props を入れておくことで global usings を有効にする方法を使った例