codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

Single-Line-Property not working on V12.0

Open Apflkuacha opened this issue 3 years ago • 3 comments

Environment

  • Visual Studio version: 2022 Community, also on 2019
  • CodeMaid version: 12.0
  • Code language: C#

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?!

Apflkuacha avatar Nov 10 '21 13:11 Apflkuacha

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.

nbelley avatar Nov 12 '21 12:11 nbelley

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 avatar Nov 16 '21 13:11 codecadwallader

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.

codecadwallader avatar Nov 19 '21 13:11 codecadwallader