Visual Studio 17.5 (미리보기 3 이후부터) 부터 윈폼의 디자이너 코드의 처리가 Roslyn으로 대체된 것으로 보입니다! 지금은 작은 변화 (사용자 입장에서는 변화가 없는!) 이지만 Microsoft 개발 팀이 계속해서 윈폼에 투자하고 있다는 점이 고무적이네요.
# Modernization of code-behind in WinForms OOP designer
## Background
The WinForms designer saves visual representations of user controls or forms on the design surface to code-behind file (`Form1.Designer.cs` or `Form1.Designer.vb`). Control instances that developer sees on the design surface are represented as a CodeDOM tree (see [Using the CodeDOM](https://learn.microsoft.com/dotnet/framework/reflection-and-codedom/using-the-codedom)), that tree is saved to the generated code-behind file in the `InitializeComponent` method. We call this feature design time serialization.
Previously COM-based [CodeModel interface](https://learn.microsoft.com/dotnet/api/envdte.codemodel?view=visualstudiosdk-2022) was used to write code into the editor's buffer as well as to generate CodeDOM tree from the source code when designer was loading. This COM object was accessible from the main thread only, which prevented parallelization in source code processing. Also, being more than 20 years old, it did not support some of the newer language features, for example the `nameof()` expression.
## What's different
Starting with [Visual Studio 2022 v17.5 Preview 3](https://visualstudio.microsoft.com/vs/preview/), the WinForms out-of-process designer uses [Roslyn](https://github.com/dotnet/roslyn) for design time serialization.
In Preview 3, designer serializes more modern code into `InitializeComponent`. We have worked hard to ensure that you can take projects between this version of Visual Studio and earlier versions. Someday in the future, we may build on the improvements in our serialization to enable performance enhancements and use newer language features. These potential future investments may break the backwards compatibility with earlier VS versions - but we will be sure to inform our developers well ahead of such changes so that you can prepare.
## Why change it
* The use of Roslyn unblocks multithreaded serialization and deserialization to solve performance delays in designer load and unload scenarios.
* Code-behind generation now respects `.editorconfig` settings and thus matches code style in the source files.
* If implicit usings feature is enabled in project properties, global namespaces are not repeated in type names.
* Further modernization of code-behind is unblocked.
This file has been truncated. show original
When you design a WinForms Form, it gets generated into a method called InitializeComponent. When you reopen that Form, it gets recreated by interpreting that code. In Visual Studio 2022 17.5, we've modernized the code generation process. And made...
5개의 좋아요