Repository navigation
Closed
Description
Visual Studio Version:
Version 16.8.0 Preview 3.1
Summary:
If you open a Form with a reference to a UserControl in Design view, make no changes and close the Designer. all the UserControl properties that are set in Designer are deleted (everything except the first and last line below)
The first and last line are changed to add the Namespace from the project file which caused the fill namespace to be DefaultNameSpace.DefaultNameSpace
Me.LineNumbersForConversionInput = New DefaultNameSpace.LineNumbersForRichTextBox()
'
'LineNumbersForConversionInput
'
Me.LineNumbersForConversionInput.BackgroundGradientAlphaColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer))
Me.LineNumbersForConversionInput.BorderLinesThickness = 1.0!
Me.LineNumbersForConversionInput.Dock = System.Windows.Forms.DockStyle.Left
Me.LineNumbersForConversionInput.GridLinesThickness = 1.0!
Me.LineNumbersForConversionInput.LineNrsOffset = New System.Drawing.Size(0, 0)
Me.LineNumbersForConversionInput.Location = New System.Drawing.Point(0, 0)
Me.LineNumbersForConversionInput.Margin = New System.Windows.Forms.Padding(0)
Me.LineNumbersForConversionInput.MarginLinesThickness = 1.0!
Me.LineNumbersForConversionInput.Name = "LineNumbersForConversionInput"
Me.LineNumbersForConversionInput.Padding = New System.Windows.Forms.Padding(0, 0, 2, 0)
Me.LineNumbersForConversionInput.ParentRichTextBox = Me.ConversionInput
Me.LineNumbersForConversionInput.Size = New System.Drawing.Size(23, 491)
Me.LineNumbersForConversionInput.TabIndex = 23
Me.LineNumbersForConversionInput.Visible = False
Friend WithEvents LineNumbersForConversionInput As DefaultNameSpace.LineNumbersForRichTextBoxSteps to Reproduce:
- Add a UserControl to a Form in Framework
- Open in Core 3.1 or 5.0 RC
A sample is here
https://github.com/paul1956/CSharpToVB/blob/master/CSharpToVB/Forms/Form1.Designer.vb
Expected Behavior:
The designer file should not change or the file should not open in designer YET.
Actual Behavior:
File is corrupted
User Impact:
Accidently opening a Form with UserControls corrupts the document, this is a silent change which makes it very bad.
Metadata
Metadata
Assignees
Labels
area-VSDesignerWindows Forms out-of-proc designer related issues
Activity
davkean commentedon Sep 29, 2020
I've moved this over to the Windows Forms repro for now for first look. @KlausLoeffelmann @merriemcgaw
merriemcgaw commentedon Sep 29, 2020
@Olina-Zhang can you confirm whether this is a VB.NET only issue, or C# too.
KlausLoeffelmann commentedon Sep 29, 2020
Thanks @davkean, will take a look!
paul1956 commentedon Sep 29, 2020
Two separate issue, the extra addition of the NameSpace is different in C# and VB and happens then the VB project has a RootNamespace. I did not try it with C# having a RootNameSpace (not sure that is even supported), without a RootNameSpace this issue does not happen in either language.
The C# Form will not allow me to add the user control and after the error below the Form is unchanged

davkean commentedon Sep 29, 2020
File the other one as a separate bug under this repo with a repro project.
Zheng-Li01 commentedon Sep 29, 2020
@paul1956, failed to reproduce the issue, please check below reproduce steps & GIF to point out if missed anything on there.
Repro Steps:
Everything seems working well.

paul1956 commentedon Sep 29, 2020
@Zheng-Li01 clone https://github.com/paul1956/CSharpToVB, open Form1 in designer, close Form1 and save and you will see all the issues. My controls inherit from "Control" not UserControl. and all the forms in this project works correctly in Framework.
Form1 before opening in designer
Errors after opening in designer

Lines deleted after opening Form1 in designer
Amy-Li03 commentedon Sep 30, 2020
@paul1956 after clone the solution: https://github.com/paul1956/CSharpToVB, we can reproduce this issue. Open the Form1 designer, then close it and save, the codes about LineNumbersForConversionInput and LineNumbersForConversionOutput are missing. Also we found that when drag and drop the LineNumbersForRichTextBox from toolbox to form1 designer, an error dialog will pop up as you mentioned above.

In addition, if we create a winforms core project, add a customer control which inherited from Control to the same solution, customer control can be dragged to the form designer correctly and no codes missing. (C# & VB core project have the same result)
paul1956 commentedon Sep 30, 2020
@Amy-Li03 does that mean there is an issue or not? All the forms and controls came from a framework project and all work as expected there with the same version of VS. I think it has something to do with the explicate RootNameSpace which does not exist in C#. Also just adding a user control is not enough you need to set some properties in the designer (and the look to see that they are deleted) to non-default values.
merriemcgaw commentedon Oct 2, 2020
At first glance it seems like you're right, that the RootNameSpace might be playing a role here. @KlausLoeffelmann will take a look and see what the cause might be and whether there's a workaround we can recommend for the time being.
kirsan31 commentedon Oct 5, 2020
Can confirm for c# - V.S. 16.8 P. 3.2 remove all code related to
DataVisualization.Charting.Chartfrom*.Designer.csafter opening form with Chart in designer...3 remaining items
Amy-Li03 commentedon Oct 13, 2020
@kirsan31 we add a custom control and define some property, then do the same operation in C# project as VB, cannot repro this issue, do you mean we should add Chart in designer to repro this issue?
kirsan31 commentedon Oct 13, 2020
@Amy-Li03 I switched our project from 3.1 to 5.0 and from every form that contains chart control - all code related to it was removed after opening in designer.
I will try to create a repro then...
kirsan31 commentedon Oct 13, 2020
@Amy-Li03 No need to switch to 5.0. New designer doesn't see chart at all even on 3.1 (VS 16.8-16.9p1):
Repro:
Designer_Chart_test.zip
May be we need to adopt some how
DataVisualization.Charting.Chartto work with new designer? But as weltkante mentioned there no public info about it :( And such behavior (silently removing all code) - not good any way.paul1956 commentedon Oct 13, 2020
I think there are 2 different issues here in priority order
merriemcgaw commentedon Oct 13, 2020
@KlausLoeffelmann is taking a look at this issue. It should be working, so we'll take care of it.
KlausLoeffelmann commentedon Oct 20, 2020
Hey @paul1956 - I will take a look as soon as I get a couple of other pressuring things of my plate. Hang in there!
paul1956 commentedon Oct 20, 2020
@KlausLoeffelmann, thinks for the update, I posted additional details on the Documentation Repo by mistake. I posted a complete very small repo at
https://github.com/paul1956/AdvanceRichTextBox that shows designer issues. Open AdvancedRichTextBox and just try to change properties on LineNumbersForRichTextBox, some work, some give dialog https://user-images.githubusercontent.com/12789369/96519756-8e44e580-1222-11eb-8b20-6aa0a938bafc.png and it doesn't matter if you use property window or designer. If you open Form1 in designer you will see Handles clauses deleted in Form1, and sections deleted from designer.vb.
paul1956 commentedon Mar 5, 2021
@KlausLoeffelmann This seems to be fixed in 16.9 and I believe it should be closed. I did not make any changes and it no longer corrupts my files.
KlausLoeffelmann commentedon Mar 6, 2021
Do you happen to have 16.10 Preview 1 installed?
We just had a fix around resources, which regressed again in 16.10 (also with a code loss scenario), and although I cannot really see how these things could be related, I just would like to check this before closing it.
paul1956 commentedon Mar 6, 2021
Yes but my code will not run at all, it looks like VB code generators are broken and there are other issues so I stopped using it. 16.9 settings is still broken in VS UI.
paul1956 commentedon Mar 7, 2021
@KlausLoeffelmann It is also fixed in 16.10 Preview 1, I am not seeing any corruption and in 16.10 Preview 1 even the resources work.

paul1956 commentedon Mar 8, 2021
@KlausLoeffelmann after doing a Git Clean and restarted VS, the problem is fixed in both 16.9 and Preview 1, I have tried opening all my forms and closing them and there are no changes, though Git does show a red check box, Git Compare with Unmodified shows no changes.
KlausLoeffelmann commentedon Mar 8, 2021
Super! Thanks a lot - closing this.