1
0
mirror of synced 2025-12-19 18:06:02 -05:00
Files
core/release-notes/10.0/preview/preview1/winforms.md
James Montemagno 811a2d949f .NET 10 Preview 1 - Release Notes (#9708)
* Add .NET 10 P1 release note base files

* add get started

* add base binary file

* revert links for build

* fix links

* update last link

* Apply suggestions from code review

Co-authored-by: Rich Lander <rlander@microsoft.com>

* Fix linter errors

* add languages

* add ef core 10 documentation

* add more efcore release notes

* fix lint issue in ef docs

* update efcore

* Preview 1 F# release notes (#9737)

* Initial F# entry with links-needs cleanup

* Remove template comments from F# release notes

* Apply suggestions from code review

Thanks! All these changes are great.

Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>

* a bit of consistency here to jump down layers

* Fix typo in F# release notes

---------

Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
Co-authored-by: James Montemagno <james.montemagno@gmail.com>

* Update release-notes/10.0/get-started.md

Co-authored-by: Jon Galloway <jongalloway@gmail.com>

* Update release-notes/10.0/preview/preview1/10.0.0-preview.1.md

Co-authored-by: Jon Galloway <jongalloway@gmail.com>

* update wpf

* C# and VB release notes for Preview 1 (#9739)

* First draft of C# and VB release notes

* Apply suggestions from code review

Co-authored-by: Martin Costello <martin@martincostello.com>

* Update release-notes/10.0/preview/preview1/visualbasic.md

Co-authored-by: Kathleen Dollard <kathleen.dollard@microsoft.com>

* Add additional features

My first draft had missed a few features.

* Apply suggestions from code review

Co-authored-by: Kathleen Dollard <kathleen.dollard@microsoft.com>

* Update release-notes/10.0/preview/preview1/csharp.md

---------

Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: James Montemagno <james.montemagno@gmail.com>
Co-authored-by: Kathleen Dollard <kathleen.dollard@microsoft.com>

* .NET 10 Preview 1 - WinForms Release Notes (#9722)

* First draft

First draft of release nites

* Added AI message

I did use AI to translate to markdown from docx formats.

* Update release-notes/10.0/preview/preview1/winforms.md

Co-authored-by: Loni Tra <lonitra@microsoft.com>

* Applying feedback

Applying the latest feedback and correcting a couple mistakes.

* Applying final feedback

Adding a few tweaks based on Tanya's feedback.

* Best Practices

* Final round of feedback

* Update release-notes/10.0/preview/preview1/winforms.md

* a bit of cleanup

* Update winforms.md

Duplicated text.

* duplicated content

---------

Co-authored-by: Loni Tra <lonitra@microsoft.com>
Co-authored-by: Rich Lander <rich@lander.ca>
Co-authored-by: Rich Lander <rlander@microsoft.com>
Co-authored-by: Tanya Solyanik <tanyaso@microsoft.com>
Co-authored-by: James Montemagno <james.montemagno@gmail.com>

* small tweaks to ef preview 1 release notes

* one more tiny tweak to ef core notes

* release notes for PrunePackageReferences (#9744)

* Fix markdown lint

* Add containers release notes for .NET 10 Preview 1 (#9746)

* Update containers section on main 10p1 readme

* Add release notes for containers

* Change Docker to container

Co-authored-by: Matt Thalman <mthalman@microsoft.com>

* Put Ubuntu announcement first

* Apply suggestions from code review

Co-authored-by: Rich Lander <rlander@microsoft.com>

* Remove extra newlines

* Update haedings and links

---------

Co-authored-by: Matt Thalman <mthalman@microsoft.com>
Co-authored-by: Rich Lander <rlander@microsoft.com>

* .NET 10 P1 -- Runtime and Libraries changes (#9715)

* Create runtime branch

* Add cryptography notes

* Fix typo

* Add ISOWeek overloads for DateOnly type

* ZipArchive

* Remove duplicate ISOWeek method overloads section

* Add String Normalization APIs for Span<char>

* Fix formatting in String Normalization APIs section

* Fix formatting for String Normalization APIs section

* Fix formatting for String Normalization APIs section

* Update String Normalization APIs section

* Update String Normalization APIs section

* Doc formatting fix

* Adding TimeSpan note

* Add JIT notes

* Convert tabs to spaces

* Better ZipArchive stats

* Fix stack allocation description

* Feedback

Co-authored-by: Andy Ayers <andya@microsoft.com>

* Add AVX10.2 experimental note, and feedback

* "C-style" -> "typical"

Co-authored-by: Rich Lander <rlander@microsoft.com>

* Add stack allocation example

* Numeric ordering, ordered dictionary, json options, matrix operations

* Apply suggestions from code review

* Update release-notes/10.0/preview/preview1/libraries.md

Apply Rich's suggestion

Co-authored-by: Rich Lander <rlander@microsoft.com>

* Update release-notes/10.0/preview/preview1/libraries.md

* Fix linter issues

---------

Co-authored-by: Jeremy Barton <jbarton@microsoft.com>
Co-authored-by: Tarek Mahmoud Sayed <10833894+tarekgh@users.noreply.github.com>
Co-authored-by: carlossanlop <1175054+carlossanlop@users.noreply.github.com>
Co-authored-by: Aman Khalid <amankhalid@microsoft.com>
Co-authored-by: Andy Ayers <andya@microsoft.com>
Co-authored-by: Pranav Senthilnathan <pranas@microsoft.com>

* Add ASP.NET Core release notes for .NET 10 Preview 1 (#9740)

* Remove extra line in release notes.

* Add link to install packages on Chiseled images

* Update C# 14 release notes

* Remove extra newlines in release notes.

* update md

* .NET MAUI in .NET 10 Preview 1 (#9727)

* [Draft] .NET MAUI in .NET 10 Preview 1

* Update release-notes/10.0/preview/preview1/dotnetmaui.md

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>

* Update release-notes/10.0/preview/preview1/dotnetmaui.md

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>

* Apply suggestions from code review

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>

* cleanup

* add info about handlers

* Update dotnetmaui.md

added Android notes

* Update dotnetmaui.md

removed community contributions section since we don't have any yet.

* cleanup

* add ios information

---------

Co-authored-by: James Montemagno <james.montemagno@gmail.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>

* update md

* trailing

* Update wpf.md

* Update release-notes/10.0/preview/preview1/10.0.0-preview.1.md

Co-authored-by: Jon Galloway <jongalloway@gmail.com>

* Update release-notes/10.0/preview/preview1/README.md

Co-authored-by: Jon Galloway <jongalloway@gmail.com>

* updates

* Call out pruning warnings in P1 release notes (#9752)

* Call out pruning warnings

* Update release-notes/10.0/preview/preview1/sdk.md

Co-authored-by: Martin Costello <martin@martincostello.com>

* Update release-notes/10.0/preview/preview1/sdk.md

---------

Co-authored-by: Martin Costello <martin@martincostello.com>

* Update 10.0.0-preview.1.md

* Add files via upload

* Update releases-index.json

* Add files via upload

* Update release-notes/10.0/preview/preview1/10.0.0-preview.1.md

Co-authored-by: Logan Bussell <loganbussell@microsoft.com>

---------

Co-authored-by: Jon Galloway <jongalloway@gmail.com>
Co-authored-by: Rich Lander <rlander@microsoft.com>
Co-authored-by: Rich Lander <rich@lander.ca>
Co-authored-by: maumar <maumar@microsoft.com>
Co-authored-by: Kathleen Dollard <kdollard@microsoft.com>
Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Kathleen Dollard <kathleen.dollard@microsoft.com>
Co-authored-by: Merrie McGaw <mmcgaw@microsoft.com>
Co-authored-by: Loni Tra <lonitra@microsoft.com>
Co-authored-by: Tanya Solyanik <tanyaso@microsoft.com>
Co-authored-by: Chet Husk <baronfel@users.noreply.github.com>
Co-authored-by: Logan Bussell <loganbussell@microsoft.com>
Co-authored-by: Matt Thalman <mthalman@microsoft.com>
Co-authored-by: Jeremy Barton <jbarton@microsoft.com>
Co-authored-by: Tarek Mahmoud Sayed <10833894+tarekgh@users.noreply.github.com>
Co-authored-by: carlossanlop <1175054+carlossanlop@users.noreply.github.com>
Co-authored-by: Aman Khalid <amankhalid@microsoft.com>
Co-authored-by: Andy Ayers <andya@microsoft.com>
Co-authored-by: Pranav Senthilnathan <pranas@microsoft.com>
Co-authored-by: Daniel Roth <daroth@microsoft.com>
Co-authored-by: David Ortinau <david.ortinau@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Nikolche Kolev <nikolev@microsoft.com>
Co-authored-by: Rahul Bhandari <rbhanda@microsoft.com>
2025-02-25 10:19:24 -08:00

8.3 KiB
Raw Blame History

Windows Forms in .NET 10 Preview 1 - Release Notes

.NET 10 Preview 1 includes new Windows Forms features & enhancements:

Windows Forms updates in .NET 10

WinForms continues to ease the pain of migrating away from BinaryFormatter in .NET 10 Preview 1 by simplifying Clipboard serialization for certain custom types. In .NET 9, calls to BinaryFormatter to perform serialization were updated to throw PlatformNotSupportedException if the developer did not reference an unsupported compatibility package and enable BinaryFormatter via an application configuration switch (see more). Clipboard and Drag/Drop scenarios which use custom types, as of .NET 9, require the developer to either enable BinaryFormatter or explicitly take action to use JSON serialization (or similar) to succeed. For additional details about migrating WinForms application away from BinaryFormatter see the Windows Forms migration guide for BinaryFormatter. In .NET 10 Preview 1 WinForms is adding several APIs to enable developers to more easily use JSON serliaization in while using the Clipboard. Additionally, developers can now more easily specify expected types when getting data from the Clipboard.

For in-depth discussion of the APIs involved, and usage examples, please see the original API Proposal in the WinForms repo.

Obsoleted Clipboard APIs

In .NET 10, WinForms has marked as obsolete the following APIs to help warn developers that BinaryFormatter may be used to deserialize data.

Clipboard:

  • public static object? GetData(string format)

DataObject:

  • public virtual object? GetData(string format)
  • public virtual object? GetData(string format, bool autoConvert)
  • public virtual object? GetData(Type format)

ClipboardProxy (VisualBasic wrapper for WinForms Clipboard):

  • public object GetData(string format)

Weve introduced the following APIs in Windows Forms for .NET 10 Preview 1:

Clipboard:

  • public static void SetDataAsJson<T>(string format, T data)
  • public static bool TryGetData<T>(string format, out T data)
  • public static bool TryGetData<T>(string format, Func<TypeName, Type> resolver, out T data)

DataObject:

  • public void SetDataAsJson<T>(T data)
  • public void SetDataAsJson<T>(string format, T data)
  • public void SetDataAsJson<T>(string format, bool autoConvert, T data)
  • public bool TryGetData<T>(out T data);
  • public bool TryGetData<T>(string format, out T data);
  • public bool TryGetData<T>(string format, bool autoConvert, out T data);
  • public bool TryGetData<T>(string format, Func<TypeName, Type> resolver, bool autoConvert, out T data);
  • protected virtual bool TryGetDataCore<T>(string format, Func<TypeName, Type> resolver, bool autoConvert, out T data)

ITypedDataObject:

  • public bool TryGetData<T>(out T data);
  • public bool TryGetData<T>(string format, out T data);
  • public bool TryGetData<T>(string format, bool autoConvert, out T data);
  • public bool TryGetData<T>(string format, Func<TypeName, Type> resolver, bool autoConvert, out T data);

DataObjectExtensions:

  • public static bool TryGetData<T>(this IDataObject dataObject, out T data)
  • public static bool TryGetData<T>(this IDataObject dataObject, string format, out T data)
  • public static bool TryGetData<T>(this IDataObject dataObject, string format, bool autoConvert, out T data)
  • public static bool TryGetData<T>(this IDataObject dataObject, string format, Func<TypeName, Type> resolver, bool autoConvert, out T data)

ClipboardProxy:

  • public void SetDataAsJson<T>(T data)
  • public void SetDataAsJson<T>(string format, T data)
  • public bool TryGetData<T>(string format, out T data)
  • public bool TryGetData<T>(string format, Func<TypeName, Type> resolver, out T data)

New Clipboard compatibility configuration switch:

  • Windows.ClipboardDragDrop.EnableUnsafeBinaryFormatterSerialization

Considerations for BinaryFormatter usage with the Clipboard

Scenarios that work without any added reference to BinaryFormatter

Applications that use the new .NET Clipboard APIs for standard data types or explicitly use JSON serialization will work without needing any reference to BinaryFormatter. For instance, the new APIs like SetDataAsJson and TryGetData<T> are designed to handle common .NET types such as primitive types and System.Drawing.Bitmap without relying on BinaryFormatter. These APIs ensure type safety and provide mechanisms to constrain incoming data, making them suitable for most scenarios where data exchange is straightforward and does not involve complex types. Serialization using these methods is considered best practice, and developers are strongly encouraged to move in this direction.

Scenarios that require a reference to BinaryFormatter

For applications that still rely on BinaryFormatter for custom format serialization or need to maintain complete compatibility with .NET Framework applications, a reference to the out-of-band, unsupported System.Runtime.Serialization.Formatters package and the corresponding AppContext switch is required as detailed here. This is particularly necessary for scenarios where complex types are involved, and the application cannot migrate to the new JSON-based APIs. In such cases, developers must explicitly opt-in to enable BinaryFormatter serialization and deserialization by setting the Windows.ClipboardDragDrop.EnableUnsafeBinaryFormatterSerialization switch to true in the configuration file in addition to System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization switch to true. The advantage to this approach is that BinaryFormatter can be explicitly disabled for Clipboard scenarios, while still being allowed in other parts of the application. This ensures that the application can continue to function while gradually transitioning to safer alternatives.

Best practices to consider when migrating to the new Clipboard APIs

  1. Replace obsolete APIs Start by replacing the obsolete GetData methods with the new TryGetData<T>. This ensures type safety and avoids the risks associated with unbounded deserialization.
  2. Use JSON Serialization: For complex types, use JSON serialization instead of BinaryFormatter. The new APIs like SetDataAsJson and TryGetData<T> are designed to handle common .NET types and JSON serialization.
  3. Constrain incoming data: The new APIs provide ways to ensure that only expected types are deserialized, reducing the risk of deserialization attacks.
  4. Opt-In only for compatibility: If your application still relies on BinaryFormatter for custom format serialization or needs to maintain compatibility with .NET Framework applications, use the configuration switch to enable BinaryFormatter serialization and deserialization. This should be done cautiously and only when necessary. Separately enable BinaryFormatter support during Clipboard serialization and dersialization with the new configuration switch.
  5. Use simple types for data exchange: Re-design your application to use simple types that have no inheritance hierarchies and have only primitive types as data fields.

Note: AI-assisted content. This article was partially created with the help of AI. An author reviewed and revised the content as needed. Learn more