We are using SonarLint in VS2019 with SonarCloud.
The S1451 rule “Add or update the header of this file.” has been configured like so in the SonarLint.xml
<Rule>
<Key>S1451</Key>
<Parameters>
<Parameter>
<Key>headerFormat</Key>
<Value>\/\/ -{71,}(\n|\r|\r\n)\/\/ <copyright file=".*\.cs" company=".*">(\n|\r|\r\n)\/\/\s{5}Copyright \(c\) Magic Bullet Ltd. All rights reserved.(\n|\r|\r\n)\/\/ <\/copyright>(\n|\r|\r\n)\/\/ -{71,}</Value>
</Parameter>
<Parameter>
<Key>isRegularExpression</Key>
<Value>true</Value>
</Parameter>
</Parameters>
</Rule>
Note the start of the RegEx is saying the header should start with
- //
- then a space character
- then 71 “-”
- then a newline character
Something similar is at the end of the regex so as two give the header a top and bottom box of
// -----------------------------------------------------------------------------------------------
However if I goe into the code window and select quickfix “Add file header” the preview popup shows that it is ignoring the surrounding box
Here is a screenshot showing the “quick action” and you can see the missing surround box and the attempt to add five spaces before the "Copyright with “\s{5}”
What am I doing wrong?