codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

Saving an Xaml file with unused namespace(s) causes all namespaces to get mixed up.

Open LeoJHarris opened this issue 3 years ago • 5 comments

Environment

  • Visual Studio version: Community 16.8.5
  • CodeMaid version: 11.2
  • Code language: C#

Description

When saving an XAML file with an unused namespace causes all the namespaces to become mixed up... the unused namespace is actually removed however

Steps to recreate

Save an XAML file with unused namespace

Current behavior

Namespaces get all mixed up and leads to incorrectly defined xaml file

Expected behavior

Should removed unused namespace and Xaml file should still be correctly defined.

Before save (note red arrow pointing to unused namespace) before

After save: after

LeoJHarris avatar Feb 19 '21 04:02 LeoJHarris

Thanks for reporting the issue. I wasn't able to immediately reproduce it. Can you please provide a minimal solution that exhibits the bug?

codecadwallader avatar Mar 03 '21 13:03 codecadwallader

I have this too. It happens in a lot of my xaml files but I cant reproduce it in a sample project, even when I copy and paste the repeatably broken files into the test project verbatim.

I am unable to share the affected code sorry.

DuncanStone avatar Mar 03 '21 23:03 DuncanStone

@codecadwallader I should be able to get a sample project soon.

LeoJHarris avatar Mar 04 '21 00:03 LeoJHarris

It seems to have something to do with simultaneously sorting and removing namespaces.

Deleting a namespace when all of them are sorted works correctly. Once a file is "broken" you have to restart Visual Studio to make it work again.

reiseder avatar Apr 07 '21 12:04 reiseder

Just happened, but it is very rare, I can't reproduce it.

fabianoriccardi avatar May 14 '21 10:05 fabianoriccardi

@LeoJHarris closing this as no longer appears to be an issue anymore. Using it with VS 2022 community for the last wee while without incident.

LeoJHarris avatar Sep 09 '22 00:09 LeoJHarris