Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider replacing the use of BinaryFormatter at all in WinForms. #10911

Closed
AraHaan opened this issue Feb 20, 2024 · 4 comments
Closed

Consider replacing the use of BinaryFormatter at all in WinForms. #10911

AraHaan opened this issue Feb 20, 2024 · 4 comments
Labels
area-Serialization-BinaryFormatter-FeatureWork Feature work under the general area of BinaryFormatter related serialization area-Serialization-Resx tenet-localization Suggested translations of resources; notification requiring translations; internationalization

Comments

@AraHaan
Copy link
Member

AraHaan commented Feb 20, 2024

.NET version

I will investigate a way to be able to parse the types from Resx without the security issues from BinaryFormatter inside of the winforms codebase in the next few weeks. Because .NET 9 will entirely remove them by default and that I FEEL LIKE being REQUIRED to reference an external nuget package because I set "Localizable" to true on a form should not justify a possible security hole in people's applications. That is not acceptable.

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes, but BinaryFormatter was deprecated. Now in .NET 9 it will throw an exception on all of it's APIs, and will have the real code in a nuget package. Although best option here is to look into other means of doing the same thing from within the Windows Forms repository. But first I will write code separate from it to test and then copy paste it all into the Windows Forms codebase to be used internally as an implementation detail.

Issue description

BinaryFormatter should be avoided entirely, I know there are other ways of the same thing, perhaps serialize the types as json instead and store said json strings inside of the resx and deserialize that instead at runtime? Would still need code in the designer for that however to migrate the format of those strings in the resx files to json form but it can be done like that as well. Also System.Text.Json is part of the main shared framework and so it should be no problems depending on it.

Steps to reproduce

  • Create a new winforms project in .NET 8 or 9 Preview SDK (dotnet new winforms)
  • open the project in Visual Studio 2022
  • set the main form to be "Localizable".
  • Build and get warnings from each item added to the resx file from the designer itself.
@AraHaan AraHaan added the untriaged The team needs to look at this issue in the next triage label Feb 20, 2024
@AraHaan
Copy link
Member Author

AraHaan commented Feb 20, 2024

https://github.com/search?q=repo%3Adotnet%2Fwinforms%20BinaryFormatter&type=code for where it is used in the code today.

@elachlan elachlan added tenet-localization Suggested translations of resources; notification requiring translations; internationalization area-Serialization-Resx area-Serialization-BinaryFormatter-FeatureWork Feature work under the general area of BinaryFormatter related serialization labels Feb 20, 2024
@elachlan
Copy link
Contributor

@lonitra I think has been working on this area.

@AraHaan
Copy link
Member Author

AraHaan commented Feb 20, 2024

I see, I think it is best to see what they have in mind then as well.

@merriemcgaw
Copy link
Member

Thank you for filing this issue! I'm going to consider this a duplicate of the epic that @lonitra and @JeremyKuhne are working on #6267

@dotnet-policy-service dotnet-policy-service bot removed the untriaged The team needs to look at this issue in the next triage label Feb 20, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Serialization-BinaryFormatter-FeatureWork Feature work under the general area of BinaryFormatter related serialization area-Serialization-Resx tenet-localization Suggested translations of resources; notification requiring translations; internationalization
Projects
None yet
Development

No branches or pull requests

3 participants