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

Support for copy/paste of controls in WinForms Designer #10055

Open
Leon99 opened this issue Oct 6, 2023 · 11 comments
Open

Support for copy/paste of controls in WinForms Designer #10055

Leon99 opened this issue Oct 6, 2023 · 11 comments

Comments

@Leon99
Copy link

Leon99 commented Oct 6, 2023

Environment

N/A

.NET version

.NET 6

Did this work in a previous version of Visual Studio and/or previous .NET release?

.NET Framework

Issue description

According to #1831, there were changes in .NET 6 that broke the copy/paste support. However, I couldn't find anything like "copy/paste is no longer supported in .NET Core" in the official documentation. Is there any other recommended way to implement it, or it's an omission from the documentation and there won't be any support for copy/paste now?

Steps to reproduce

N/A

Diagnostics

No response

@Leon99 Leon99 added the untriaged The team needs to look at this issue in the next triage label Oct 6, 2023
@elachlan
Copy link
Contributor

elachlan commented Oct 6, 2023

.NET deprecated the binary formatter due to fundamental security issues with it. This among other things has lead the team to refactor the winforms interop layer to add better support for COM Wrappers to enable better copy paste support. It's still ongoing and it looks like better support will be added in .NET9.

See #6269

@elachlan
Copy link
Contributor

elachlan commented Oct 9, 2023

Cc: @JeremyKuhne

@lonitra
Copy link
Member

lonitra commented Oct 31, 2023

@Leon99 Could you clarify your scenario here? Is copy and paste not working for you in the designer? If BinaryFormatter is enabled, copy and paste should be working

@lonitra lonitra added the 📭 waiting-author-feedback The team requires more information from the author label Oct 31, 2023
@Leon99
Copy link
Author

Leon99 commented Oct 31, 2023

copy and paste not working for you in the designer

Correct

Is copy and paste not working for you in the designer? If BinaryFormatter is enabled, copy and paste should be working

#1831 explains the reason why it doesn't work.

@ghost ghost removed the 📭 waiting-author-feedback The team requires more information from the author label Oct 31, 2023
@lonitra lonitra added the area-VSDesigner Windows Forms out-of-proc designer related issues label Nov 1, 2023
@JeremyKuhne
Copy link
Member

@Leon99 to be super explicit here, is CodeDomSerializationStore the one you are referring to? If you can give us a detailed repro we will be better able to give you guidance.

Copy/paste still work in general, we removed [Serializable] from a few types as part of the greater effort to reduce exposure to security issues with arbitrary object binary serialization.

@JeremyKuhne JeremyKuhne added the 📭 waiting-author-feedback The team requires more information from the author label Nov 2, 2023
@Leon99
Copy link
Author

Leon99 commented Nov 2, 2023

@JeremyKuhne, yes, CodeDomSerializationStore is the type responsible for the serialization/deserialization of controls, which is essential to copy/paste. I'm not sure what you mean by "Copy/paste still work in general", given that it requires serialization/deserialization of controls to get the data to be placed on the clipboard, which doesn't work anymore.

We solved the issue, but it took lots of effort as it involved switching to another serializer that doesn't require [Serializable] and supports all the involved types, and modification of a whole bunch of WinForms types, as most of the involved infrastructure is internal.

@ghost ghost removed the 📭 waiting-author-feedback The team requires more information from the author label Nov 2, 2023
@elachlan
Copy link
Contributor

elachlan commented Nov 3, 2023

Also related: #9110

@JeremyKuhne
Copy link
Member

I'm not sure what you mean by "Copy/paste still work in general"

@Leon99 Copy and paste still works for standard scenarios (say, string). In order for us to follow up on your specific scenario we need an explicit repro (code) to fully understand our options here and to give you clear answers. You've also stated that you have a workaround, is this actually a blocker?

@Tanya-Solyanik had marked this type as being only used for internal scenarios but clearly this isn't true.

I'm not specifically opposed to putting the attribute back, but:

  1. We would need to have clear details on what is blocked so we determine where this work falls in the backlog
  2. As mentioned, the BinaryFormatter is depreciated and will likely be disabled by default for WinForms projects in .NET 9 (it already is disabled by default for other .NET 8 projects)

@JeremyKuhne
Copy link
Member

Also related: #9110

We're unlikely to make this particular type work without the BinaryFormatter. It appears to not have constraints on the data that is being serialized. #9110 is for adding handling for types that we know the full closure of.

@JeremyKuhne JeremyKuhne added the 📭 waiting-author-feedback The team requires more information from the author label Nov 3, 2023
@Leon99
Copy link
Author

Leon99 commented Nov 3, 2023

We would need to have clear details on what is blocked

Copy/paste of controls in the WinForms designer.

You've also stated that you have a workaround, is this actually a blocker?

We're not blocked anymore, but the workaround is not particularly maintainable.
Besides, given that it's clearly a functional regression, and the workaround involves messing with many internal to base .NET library types, would be nice to see something like "copy/paste of controls in WinForms designer is no longer officially supported in .NET Core" in the documentation so people considering migration know what to expect.

@ghost ghost removed the 📭 waiting-author-feedback The team requires more information from the author label Nov 3, 2023
@RussKie
Copy link
Member

RussKie commented Nov 7, 2023

dotnet/announcements#284

@merriemcgaw merriemcgaw added area-DesignerSupport and removed untriaged The team needs to look at this issue in the next triage area-VSDesigner Windows Forms out-of-proc designer related issues labels Nov 8, 2023
@merriemcgaw merriemcgaw added this to the Future milestone Nov 8, 2023
@Leon99 Leon99 changed the title Support for copy/paste Support for copy/paste of controls in WinForms Designer Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants