Open jboeke opened 8 years ago
Thanks for reporting the issue, I have reproduced it.
I've done some tracing and I believe this is tied to the logic that inserts explicit access modifiers on properties. The logic extracts the property prefix by getting the start point and searching forwards for an opening brace. In your example you have braces within your regular expression, so it is terminating the search early and assuming that an explicit access modifier is not present. Where it gets odd is that when it asks the IDE to add the access modifier, you would think it would do nothing if it already exists but instead it appears to be wiping out your comments entirely.
This logic won't need to exist in a future version rewritten on the Roslyn compiler. I'll see what I can find as a working solution until then. As an immediate workaround, you can either move the comment line away that contains a brace or disable CodeMaid's insertion of explicit access modifiers for properties.
Thanks again for reporting this issue.
Confirmed that disabling "Insert explicit access modifiers on ... properties" works.Thanks for the workaround and your commitment to maintaining a great tool!
I took another look at this but I didn't see any clean way to catch this scenario without the aforementioned Roslyn compiler work in place first.
I am seeing this same issue on any simple comment below an attribute. Note that these comments do not have braces in them, so this may be a slightly different issue, but appears to be related.
Example code...
[XmlAnyElement]
// foo -- THIS COMMENT WILL BE CLEANED AND REMOVED
protected string _foo;
// bar
[XmlAnyElement]
protected string _bar;
As a workaround for my issue I also need to disable "Insert explicit access modifiers on ... fields".
Environment
Description
Steps to recreate
Current behavior
Lines 13, 14 and 15 (commented lines) are removed by CodeMaid.
Expected behavior
I expect my comments to remain. I could not find any settings relevant to this behavior.