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

SubType Designer is randomly added in csproj files #3186

Closed
rainersigwald opened this issue Jan 25, 2018 · 31 comments
Closed

SubType Designer is randomly added in csproj files #3186

rainersigwald opened this issue Jan 25, 2018 · 31 comments
Labels
Area-External Owned by another feature area and not this repo. Likely be closed in lieu of issue against it. Bug This is a functional issue in already written code. Feature-Project-File-Editing Editing the project either while open in Visual Studio, or via other mechanism. Resolution-Fixed The bug has been fixed, refer to the milestone to see in which release it was fixed.
Milestone

Comments

@rainersigwald
Copy link
Member

From @EnCey on January 18, 2018 15:31

Steps to reproduce

Edit a csproj file and save it. A Subtype tag with Designer as content is randomly added.

<ItemGroup>
    <None Include="App.config">
        <SubType>Designer</SubType>
    </None>
    <None Include="packages.config">
        <SubType>Designer</SubType>
    </None>
</ItemGroup>

Here is a Microsoft Connect issue that describes this exact problem.

Here is a nearly a decade old StackOverflow question that describes this problem. According to an answer there, this issue has been present since Visual Studio 2008.

Copied from original issue: dotnet/msbuild#2876

@rainersigwald
Copy link
Member Author

From @KirillOsenkov on January 25, 2018 4:55

I wonder if it's MSBuild or it should go to https://github.com/dotnet/project-system.

cc @Pilchie

@rainersigwald
Copy link
Member Author

From @KirillOsenkov on January 25, 2018 4:56

P.S. Let's fix this, this has annoyed me for years.

@rainersigwald
Copy link
Member Author

The only place I can see where we'd add this is in the pre-MSBuild-to-msbuild converter code, which should never be called:

https://github.com/Microsoft/msbuild/blob/419c6d8e55c9c8181da2ce8d0ef6f951fdfe08a3/src/Deprecated/Conversion/ProjectFileConverter.cs#L576-L578

I think this is a project system bug.

@Pilchie
Copy link
Member

Pilchie commented Feb 1, 2018

Hmm - I know how this process works for Compile items, but not for .config files.

@Pilchie Pilchie added Bug This is a functional issue in already written code. Feature-Project-File-Editing Editing the project either while open in Visual Studio, or via other mechanism. labels Feb 1, 2018
@Pilchie Pilchie added this to the Unknown milestone Feb 1, 2018
@davkean
Copy link
Member

davkean commented Feb 27, 2018

@EnCey Can you expand on the repro steps? Which project type in particular? Can you provide the project, or record the steps that you take to reproduce this?

In .NET Framework based projects, the sub type is added for anything "designable" (Forms, Pages, Components, etc). This is being tracked by #182. You should not hit for app.config or packages.config, that looks like a bug.

In the new project system, we do not currently add sub type unless an external component asks for it. The repro steps will help me understand what you are hitting here. Just reply to the thread with more information and I'll reopen it. Thanks!

@davkean davkean added the Resolution-No-Repro We cannot reproduce the bug. We need more information, clearer repro steps or a sample project. label Feb 27, 2018
@davkean davkean closed this as completed Feb 27, 2018
@EnCey
Copy link

EnCey commented Feb 27, 2018

Sorry @davkean for not providing more steps. I encountered the issue while I was upgrading all projects of a solution to .NET v4.6.2 (from 4.6).
During my investigation I found the already mentioned StackOverflow question, in which people report this problem since Visual Studio 2008 (and still present in VS 2017). I thus thought that it would be a known issue, especially considering there's also a Microsoft Connect issue for it, which is sadly unreachable now.

In the SO question there's a link to this MSDN forum question in which people report the issue for all kinds of project files. In my case, the sub type was definitely added to .config files as my example shows.

I do not have a working repro and don't remember in which project exactly the issue occurred, but isn't a decade of reports evidence enough for your Q&A team to at least look into this? Perhaps the existing reports already contain enough information for you to identify the root cause.

When I run into the problem again I will post steps here, but for now I'm afraid I can't provide more details.

@davkean
Copy link
Member

davkean commented Feb 27, 2018

I've pulled the connect repro steps because Connect has been retired:

Repro Steps: 
1. Open attached project 
2. Go to solution explorer 
3. Double click on XML file 
4. Close solution. 
5. Nothing changes. 
6. Open attached project 
7. Go to solution explorer 
8. Right-click on XML file and select "View code" 
9. Close solution 
10. You're prompted to save changes to the project file 
11. Save the changes 
12. Project file now has needless SubType Designer decoration 

Actual Results: 
If no designer functionality is available, my project file isn't modified. 

Expected Results: 
My project is modified, causing needless version control churn.

Looking through all of the links you posted, there's 2, possibly 3 separate issues:

  1. Project system is adding SubType to designable files. This behavior is as designed - Prevent <SubType> from being written to the project file #182 is tracking revisiting that design. (MSDN Forums)
  2. Something is adding SubType to XML files in some cases in VC++ projects (Connect/Stackoverflow question)
  3. Something is adding SubType to config/XML files in some cases in legacy C# project system (your issue)

I'm going to use this bug to track the last two and find an owner. I'll dig through some code to see if/when this occurs. I suspect this is XML editor component and not the project system.

@davkean davkean reopened this Feb 27, 2018
@davkean
Copy link
Member

davkean commented Feb 27, 2018

Could you double-click those two config files and tell me what editor opens?

@davkean
Copy link
Member

davkean commented Feb 27, 2018

Okay, I can see where this code lives, Package.CheckItemSubType in the XML language service (internal). Looks like both 2 & 3 above are caused by the same thing. Trying to understand the logic, and why it happens.

@davkean
Copy link
Member

davkean commented Feb 27, 2018

@EnCey Can I ask you a favor? Can you Help -> Send Feedback -> Report a Problem and report the same information. Once you've done that point me to it and I'll make sure it gets routed to the right team. I'll add background information to the bug about what I've found, it appears the Connect bug fell off the radar. This is a issue in the XML editor - it looks intentional that its doing this but I'm not entirely sure why.

@davkean
Copy link
Member

davkean commented Feb 27, 2018

Internal bug number for the connect issue is 658114.

@davkean
Copy link
Member

davkean commented Feb 27, 2018

I've filed https://devdiv.visualstudio.com/DevDiv/_workitems/edit/572846 internally. If/when you Send Feedback above, I'll associate that bug with it. Community based feedback lets other people vote on the issue and is given weight over just internal filed bugs.

@davkean davkean closed this as completed Feb 27, 2018
@davkean davkean added Area-External Owned by another feature area and not this repo. Likely be closed in lieu of issue against it. and removed Resolution-No-Repro We cannot reproduce the bug. We need more information, clearer repro steps or a sample project. labels Feb 27, 2018
@EnCey
Copy link

EnCey commented Feb 27, 2018

Hi @davkean , thank you for looking into this!
I reported the problem like you asked here

@davkean
Copy link
Member

davkean commented Feb 27, 2018

Thanks, I've routed to the correct team.

@KirillOsenkov
Copy link
Member

👍

@StingyJack
Copy link

Sorry, what's the result of this? Its kind of annoying and a minor timesink to keep coming up in pending changes or code reviews.

@EnCey
Copy link

EnCey commented Mar 27, 2018

@StingyJack and others annoyed by this bug: please head over to the Developer Community issue and upvote it. Leave a comment / reply if you want to generate even more buzz.

As davkean mentioned above:

Community based feedback lets other people vote on the issue and is given weight over just internal filed bugs.

My personal impression of the situation is that this issue now sits in some "fix when time" backlog (aka never ;), so we'll need some noise to generate interest.

@StingyJack
Copy link

StingyJack commented Mar 27, 2018

Sorry again, but devcomm is a no-go for me anymore. Less than 25% of about 230 issues i opened were resolved, and after pointing out the weird or atrocious mishandling for a few issues, it was apparently easier to suspend my accounts with a suspect excuse rather than address the mishandling problems and the unresolved issues.

EDIT: So I'd probably cast a vote for your issue, but I cant, and really shouldn't have to. If we are taking the time to log a bug for something that is interfering with our work, we shouldn't have to campaign for votes to get things fixed. I could understand if this were solely a free or community version of the program, but those who have paid for a license (pro, enterprise) are not getting any improved level of service for it.

@davkean
Copy link
Member

davkean commented Mar 27, 2018

@StingyJack If there are bugs or issues that are blocking your work that you would like to see addressed, please open a support request. Github/Developer community are intended as convenient ways to report issues and bugs to Microsoft and not intended to replace existing support mechanisms.

@StingyJack
Copy link

Sorry a third time (and final I promise) for belaboring this thread. @davkean - Is there an email address I can reach account support at? One of the unresolved issues on devcomm is that my accounts aren't linked right.

@davkean
Copy link
Member

davkean commented Nov 27, 2018

Just to follow up on the thread around the original issue; this bug has been addressed and will appear in the first preview of VS 2019.

@davkean davkean modified the milestones: Backlog, 16.0 Nov 27, 2018
@davkean davkean added the Resolution-Fixed The bug has been fixed, refer to the milestone to see in which release it was fixed. label Nov 27, 2018
@RealDotNetDave
Copy link

Can it also be fixed in VS2017?

@davkean
Copy link
Member

davkean commented Mar 23, 2019

@RealDotNetDave There are no intentions to back port this fix to Visual Studio 2017. Given VS 2019 RC has been released it's moved to a servicing level where only bugs blocking major scenarios are being addressed. VS 2019 RC has a go-live license, so you can use it for production code.

@smithkl42
Copy link

Given that this is fixed in VS2019, highly ironic that I just ran into this in VS2019 :-).

I upgraded to 16.0.1 today, and when I add new classes, it insists on treating them as components, i.e.:

    <Compile Include="Validation\Commercial\CommercialDataValidatorBase.cs">
      <SubType>Component</SubType>
    </Compile>

@Pilchie
Copy link
Member

Pilchie commented Apr 11, 2019

@smithkl42 The issue was fixed for xml files (hence the original report). For .cs files, the language service checks the first type in the file and all of it's base types to see if any of them have the DesignerCategoryAttribute applied. If one does, that category gets written to the csproj file as the SubType. It sounds like that's what is happening in your case. If you want to override that, add a DesignerCategoryAttribute with a value of code.

@Pilchie
Copy link
Member

Pilchie commented Apr 11, 2019

@smithkl42
Copy link

smithkl42 commented Apr 11, 2019

Thanks, that explains it. We have our own ServiceBase class, but I accidentally had my class inheriting from System.ServiceProcess.ServiceBase. I'm guessing that or one of its basetypes must have the DesignerCategoryAttribute applied.

Sure had me scratching my head...

@michaelkhalsa
Copy link

I had this problem in Visual Studio 16.11.1 when closing Visual Studio randomly removed the SubTypes (Form, User Control) for about 90 % of thousands of user controls and forms in vbproj (winforms, targeting NET 4.8, vb for winforms project, mixed vb and c# for other projects in solution).

Unable to replicate. I had previously renamed some user controls prior to saving.
Note that my solution (a large application) frequently runs out of memory every 2 or 3 days. (I have already split projects into a few solutions), however, has not had memory issues in these later VS builds.

Fixed it by pulling a previous vbproj file saved in git, and then hand modifying changes since last push.

So this issue is still kicking.

@ajmudrak
Copy link

I noticed this issue in one of my projects, and found that in one build configuration (production) we would run the build and it would remove the SubType, but other build configs (dev/test) it would add it back. It turns out that the code behind file (.aspx.cs) was entirely inside a preprocessor directive that hid all the code for the production build config. When we removed that directive (we did not actually need it to fully remove the code behind) it stopped removing the SubType and the builds became consistent. Just food for thought.

@oaspublic
Copy link

the problem still exists with a current visual studio. regularly after a git branch change the project files are modified with extensions or deletions of subtypes. so when changing from branch a to b the subtype is inserted and then with a future identical change from branch a to b the subtype is removed again. the behavior is very disturbing and irritating, because sometimes an automatism arises and with essential changes in prj files, sometimes accidentally wanted changes are retooled!

@SoulSeekkor
Copy link

I've never had this issue until recently (maybe the last 6 months) and it's happening in VS 2022. Super super frustrating as I'll save my solution and it'll randomly add this subtype garbage to a VB.Net project file that I didn't even touch at all or have open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-External Owned by another feature area and not this repo. Likely be closed in lieu of issue against it. Bug This is a functional issue in already written code. Feature-Project-File-Editing Editing the project either while open in Visual Studio, or via other mechanism. Resolution-Fixed The bug has been fixed, refer to the milestone to see in which release it was fixed.
Projects
None yet
Development

No branches or pull requests