Fix removal of Windows Forms <SubType>Form</SubType> in project file by error, or intention, causing form Solution Explorer icon to change
When a class is declared in the same file (Form1.cs by default), in the same namespace as the forms class, but PRECEDING the partial forms class, it causes Visual Studio to believe that the Forms class is no longer of SubType Form in the Solution Explorer, causing the project file to be updated and access to the designer to be lost for that form.
When the other class is commented out, the SubType returns to normal.
I do not know if this is a feature or a bug.
If you insert the commented-out code into your Forms class and uncomment it, you should see the icon in the Solution Explorer change to the one for C# code files, and your project file will be updated, and likewise if you comment it out again, it will be changed back to the Windows Forms icon and the SubType in the project file will be set to Form again.
//demonstration of the designer-breaking bug, or feature
//this will cause the Solution Explorer icon for the form to change to the one
//for a code file, and the project file to update as such, and when commented back out, it will be set to a Form again
//public class TestClass
public partial class MainForm : Form
Stephen Cohen commented
Only tested in VS 2017 Pro, and VS 2017 Enterprise Preview