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

"Remove and Sort Usings on save" feature not working on some projects #40

Open
justcla opened this Issue Jul 18, 2016 · 21 comments

Comments

Projects
None yet
8 participants
@justcla
Copy link
Contributor

justcla commented Jul 18, 2016

Travis Illig reported:
"In a project using the new DNX build system targeting dnx46, the "Remove and Sort Usings on save" PowerCommand doesn't actually do anything on document save for any of the C# class files in the project. Same thing for "Format document on save" - saving does not result in the document being formatted.

The features do work as expected for other project types."

@justcla

This comment has been minimized.

Copy link
Contributor

justcla commented Jul 18, 2016

Tipfom reported:
"I'm having a similiar problem with Xamarin Shared Assets Librarys."

@justcla

This comment has been minimized.

Copy link
Contributor

justcla commented Jul 18, 2016

Blandau006 reported:
"I'm experiencing the same issue DNX projects."

@justcla

This comment has been minimized.

Copy link
Contributor

justcla commented Jul 18, 2016

LarryDavidJr reported:
"I don't even get the option on the right click, is that the same as everyone else? That could just be an issue with 'project types' needing to be added to the source, but the source for this function does not appear to be in the public domain yet. so how about it MS, either open up the source for that part, or fix it for .NET Core RC2!"

@justcla

This comment has been minimized.

Copy link
Contributor

justcla commented Jul 18, 2016

Zsolt Miskolczi reported:
"I have the same problem. Both of the Remove and sort unused using on Save and the Format document on save commands does not work on .net core projects."

@rezamohamed

This comment has been minimized.

Copy link

rezamohamed commented Jul 26, 2016

I can't seem to get the simple remove unused savings on Save or anything working with ASP.NET Core.

@VaclavElias

This comment has been minimized.

Copy link

VaclavElias commented Aug 10, 2016

Same problem. It doesn't work on any ASP.NET Core project I have.

@HADB

This comment has been minimized.

Copy link

HADB commented Aug 11, 2016

Same as @VaclavElias. It doesn't work on my ASP.NET Core project.

@VaclavElias

This comment has been minimized.

Copy link

VaclavElias commented Aug 22, 2016

Community, was anyone able to locate in this source code where "Format document on save" and "Remove and Sort Usings on save" is?

@whoiskevinrich

This comment has been minimized.

Copy link

whoiskevinrich commented Nov 13, 2016

I am having the same problem. I have these observations to report:

Given a solution with both ASP.NET Core and ASP.NET 4.6.1 projects:

  • The feature works when working with the ASP.NET 4.6.1 project
  • The feature does not work when working with the ASP.NET Core project.
  • Both projects are class libraries targeting the 4.6.1 framework
@PeterKottas

This comment has been minimized.

Copy link

PeterKottas commented Jan 5, 2017

Same here everybody. Took a while to find this issue but at least I know it's only me.

@coderabsolute

This comment has been minimized.

Copy link

coderabsolute commented Mar 8, 2017

For me, it doesn't work on "Core Projects" specifically. This was the case even for VS2015 as well.

@THammond9

This comment has been minimized.

Copy link

THammond9 commented Mar 9, 2017

Several of my co-workers and I am having this problem in ASP.NET projects. This option does seem to work for us if the warning level on the project less than 4. In fact, if any project does not have a warning level of 4 "remove and sort" does not work at all. see this stackoverflow question. Also I don't know if this is a problem with PPT or VS2015. The question above does not talk about PPT and I used the built in VS command to remove unused usings.

@VaclavElias

This comment has been minimized.

Copy link

VaclavElias commented Mar 9, 2017

It doesn't work for me also on Visual Studio 2017!

@justcla

This comment has been minimized.

Copy link
Contributor

justcla commented Apr 12, 2017

@THammond9 "Remove and Sort Usings" (Lightbulb feature) as described in the stack overflow question is a base VS feature. PPT provides a new feature, which is an option to enable that will "Remove and Sort Usings on Save". When activated, it will apply the Remove and Sort Usings automatically when the file is saved.

@justcla

This comment has been minimized.

Copy link
Contributor

justcla commented Apr 12, 2017

@VaclavElias Are you using .Net Core projects? Do you have ReSharper installed?

@VaclavElias

This comment has been minimized.

Copy link

VaclavElias commented Apr 12, 2017

@justcla Yes, I tried it on .Net Core projects and also Asp.Net MVC 5 or Console Apps and I do have ReSharper installed. The Lightbulb feature is working but PPT "Remove and Sort Usings on Save" is not working.

@THammond9

This comment has been minimized.

Copy link

THammond9 commented Apr 12, 2017

@justcla The solution mentioned in the stackoverflow question fixes PPT "Remove and Sort Usings on Save" for me. The issue with the warning level applies to more than just ASP.NET projects. I encourage you to try it yourself:

  • Install PPT 2015
  • Turn on "Remove and Sort Usings on Save" in PPT
  • Create a new C# project, ASP.NET, Library, console, or winform app
  • Add redundant usings and save and see that PPT works
  • Change the warning level to less than 4
  • Add redundent usings and save and see that PPT does not work
@justcla

This comment has been minimized.

Copy link
Contributor

justcla commented Apr 12, 2017

Thanks!
Does that mean that with the right warning levels set, it will work for .NET Core projects?

@VaclavElias

This comment has been minimized.

Copy link

VaclavElias commented Apr 12, 2017

I will test it with PPT 2017 on my .NET Core projects tomorrow :)

@justcla

This comment has been minimized.

Copy link
Contributor

justcla commented Apr 14, 2017

The new version of Power Commands (v15.0.4) uploaded last night contains an enhancement to enable Remove and Sort Usings on Save to work with .Net Core projects - and also to work with VB in both regular .NET and .NET Core.
Thanks to @olegtk.

@VaclavElias

This comment has been minimized.

Copy link

VaclavElias commented Apr 14, 2017

Thanks @justcla for letting us know.

Ok, I cannot confirm if it was fixed or not but with ReSharper it still doesn't work unless

a) ReSharper is Suspended or
b) Used this work around #81 (comment)

For now I am happy with b) so I get a few seconds saved for each file, it is working for regular .NET and .NET Core :)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment