codecadwallader / codemaid

CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
http://www.codemaid.net
GNU Lesser General Public License v3.0
1.92k stars 362 forks source link

Single-Line-Property not working on V12.0 #866

Open Apflkuacha opened 2 years ago

Apflkuacha commented 2 years ago

Environment

Description

With the new version, when the setting Insert explicit access modifiers on properties is activated, following line

public bool AdminMode { get { return _adminMode; } set { if (_adminMode != value) _adminMode = value; } }

is changed to

public bool AdminMode 
{ get { return _adminMode; } set { if (_adminMode != value) _adminMode = value; } }

This line should stay in one line. It stays in one line if the setting mentioned above is deactivated. Following line for example will stay in one line, independent of the setting:

public string StatusMessages { get => _statusMessages; set => Set(ref _statusMessages, value); }

Off topic: why is there a separate 2022 Version of CodeMaid in the Visual Studio Marketplace? It was ranked that high in the default "Most Downloads" sort order, now it begins again with zero downloads?!

nbelley commented 2 years ago

Same issue, it also happens in visual studio 2019.

It took almost a week before we realized this... Some of our repos now need to be manually cleaned and this really sucks.

codecadwallader commented 2 years ago

Thanks for reporting the issue. It looks like a number of issues are cropping up around inserting explicit access modifiers on properties and the underlying API is no longer behaving the way it used to before. At this point I would recommend turning off that option at CodeMaid->Options->Cleaning->Insert->Insert explicit access modifiers on->properties

@nbelley That does really suck, and I'm very sorry to hear it. :(

Off topic: why is there a separate 2022 Version of CodeMaid in the Visual Studio Marketplace? It was ranked that high in the default "Most Downloads" sort order, now it begins again with zero downloads?!

VS2022 included some breaking changes and required all extension authors to split their extensions. The recommendation was to create separate pages in the marketplace for each version. Here's a couple links with more information:

https://www.codemaid.net/codemaid-v12-0-a-fork-in-the-road-edition-released/ https://docs.microsoft.com/en-us/visualstudio/extensibility/migration/update-visual-studio-extension?view=vs-2022

codecadwallader commented 2 years ago

This lookup is not coming back with the expected results: https://github.com/codecadwallader/codemaid/blob/dev/CodeMaidShared/Logic/Cleaning/InsertExplicitAccessModifierLogic.cs#L297

Since it isn't matching the property declaration correctly, it thinks the access modifier is missing and attempts to add it via the VS API. While it should(tm) not be attempting to do that it should(tm) also be harmless.

When we set the access modifier via the API it is introducing the new line. This is happening in both VS2019 and VS2022 although it did not use to do so with the same API call.