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

Windows Forms templates should carry proj.user with SubType already set #3510

Closed
davkean opened this issue Jun 26, 2020 · 6 comments · Fixed by #3527
Closed

Windows Forms templates should carry proj.user with SubType already set #3510

davkean opened this issue Jun 26, 2020 · 6 comments · Fixed by #3527
Assignees

Comments

@davkean
Copy link
Member

davkean commented Jun 26, 2020

Problem description:

To detect that a Forms is openable by the designer (and gets the icon), Roslyn asynchronously reads the attributes of a type's base types and pushes a "SubType" if the right attribute is present to the project system. Which in turn, causes the designer paths to light up.

This is a slow and asynchronous process and cannot be blocked on, and causes additional evaluations and design-time builds to kicked off after Roslyn sets the subtype.

To side step this whole process, and improve the speed for opening the designer and to reduce the number of design-builds that are needed for File -> New, the templates should carry this information and have the project system automatically recognize that this project contains a designable file.

To do that, carry a UTF8-with BOM file alongside the project called "[Project].csproj.user"

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <Compile Update="Form1.cs">
      <SubType>Form</SubType>
    </Compile>
  </ItemGroup>
</Project>
@Shyam-Gupta Shyam-Gupta self-assigned this Jun 26, 2020
@weltkante
Copy link
Contributor

weltkante commented Jun 26, 2020

Does this really make any difference? VS ignores *.csproj.user files by default when checking in to source control (at least for GIT and TFS) - so this only marginally improves performance when creating a brand new project, checking out from source control would not benefit, and in my experience this is the much more common operation. Classic projects stored this setting in the project file so they didn't have this problem.

Can't this be stored somewhere that is persisted properly? Its not really a user setting ...

@davkean
Copy link
Member Author

davkean commented Jun 26, 2020

Yes it makes a difference in this scenario, hence why I filed this.

@weltkante
Copy link
Contributor

weltkante commented Jun 27, 2020

I'd argue a solution that works more than once would be better. This suggestion just works at project creation and never again for anyone else who starts working on the project. So it makes a difference for one person one time, not really a difference in the long term.

(I'm not going to keep arguing, just my opinion here, to suggest considering alternatives.)

@davkean
Copy link
Member Author

davkean commented Jun 27, 2020

Legacy does the same thing with its templates (carries subtype), so regardless of whether there is a better solution to putting subtype in the user file, we are still going to be carrying it in the template.

RussKie added a commit to RussKie/winforms that referenced this issue Jun 28, 2020
To detect that a Forms is openable by the designer (and gets the icon),
Roslyn asynchronously reads the attributes of a type's base types and
pushes a "SubType" if the right attribute is present to the project system.
Which in turn, causes the designer paths to light up.

This is a slow and asynchronous process and cannot be blocked on, and
causes additional evaluations and design-time builds to kicked off after
Roslyn sets the subtype.

To side step this whole process, and improve the speed for opening the
designer and to reduce the number of design-builds that are needed for
File -> New, the templates should carry this information and have the
project system automatically recognize that this project contains a
designable file.

Resolves dotnet#3510
@ghost ghost added 🚧 work in progress Work that is current in progress and removed 🚧 work in progress Work that is current in progress labels Jun 28, 2020
@ghost ghost added the 🚧 work in progress Work that is current in progress label Jul 2, 2020
@merriemcgaw merriemcgaw added this to the 5.0 milestone Jul 2, 2020
@ghost ghost removed the 🚧 work in progress Work that is current in progress label Jul 6, 2020
@RussKie RussKie removed this from the 5.0 milestone Jul 6, 2020
@Zheng-Li01
Copy link
Member

Zheng-Li01 commented Jul 15, 2020

Verified the issue with latest .NET 5.0 SDK, the Form1.cs[Design] page is opened directly and have the below code section generated in the .csproj.user file. see below GIF. however noticed that the spending time to open Form1.cs[Design] is still longer than Framework project.
Code section:
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <Compile Update="Form1.cs"> <SubType>Form</SubType> </Compile> </ItemGroup> </Project>

UpdateCoreIssue

@davkean
Copy link
Member Author

davkean commented Jul 15, 2020

It takes longer because it performs a NuGet restore, which legacy does not.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants