Skip to content

Commit 2b829ad

Browse files
Merge pull request #687 from codecadwallader/master
v11.1
2 parents fc1bec3 + 8b9668c commit 2b829ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1106
-764
lines changed

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
# Changelog
22

3-
## vNext (11.1)
3+
## vNext (11.2)
44

55
These changes have not been released to the Visual Studio marketplace, but (if checked) are available in preview within the [CI build](http://vsixgallery.com/extension/4c82e17d-927e-42d2-8460-b473ac7df316/).
66

77
- [ ] Features
8-
98
- [ ] Fixes
109

1110
## Previous Releases
1211

1312
These are the changes to each version that has been released to the Visual Studio marketplace.
1413

14+
## 11.1
15+
16+
**2019-11-03**
17+
18+
- [x] Features
19+
- [x] [#620](https://github.com/codecadwallader/codemaid/pull/620) - Formatting: Allow for individual tag formatting rules - thanks [willemduncan](https://github.com/willemduncan)!
20+
- [x] [#665](https://github.com/codecadwallader/codemaid/pull/665) - Use image monikors so icons show up again when tool windows are small - thanks [Diermeier](https://github.com/Diermeier)!
21+
22+
- [x] Fixes
23+
- [x] [#647](https://github.com/codecadwallader/codemaid/pull/647) - Formatting: Fix magically added slashes - thanks [willemduncan](https://github.com/willemduncan)!
24+
- [x] [#670](https://github.com/codecadwallader/codemaid/pull/670) - Options: Fix importing read-only config - thanks [Smartis2812](https://github.com/Smartis2812)!
25+
1526
## 11.0
1627

1728
**2019-03-23**
Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
22
using SteveCadwallader.CodeMaid.Model.Comments;
3+
using SteveCadwallader.CodeMaid.Model.Comments.Options;
34
using System;
4-
using System.Collections.Generic;
55

66
namespace SteveCadwallader.CodeMaid.UnitTests.Formatting
77
{
88
internal class CommentFormatHelper
99
{
10-
public static string AssertEqualAfterFormat(string input)
10+
public static string AssertEqualAfterFormat(
11+
string text,
12+
Action<FormatterOptions> options = null)
1113
{
12-
return AssertEqualAfterFormat(input, input);
14+
return AssertEqualAfterFormat(text, null, null, options);
1315
}
1416

15-
public static string AssertEqualAfterFormat(string input, string expected)
17+
public static string AssertEqualAfterFormat(
18+
string text,
19+
string expected,
20+
Action<FormatterOptions> options = null)
1621
{
17-
return AssertEqualAfterFormat(input, expected, null);
22+
return AssertEqualAfterFormat(text, expected, null, options);
1823
}
1924

20-
public static string AssertEqualAfterFormat(string input, string expected, string prefix)
25+
public static string AssertEqualAfterFormat(
26+
string text,
27+
string expected,
28+
string prefix,
29+
Action<FormatterOptions> options = null)
2130
{
22-
var result = Format(input, prefix);
23-
Assert.AreEqual(expected, result);
31+
var result = CodeComment.Format(text, prefix, options);
32+
Assert.AreEqual(expected ?? text, result);
2433
return result;
2534
}
26-
27-
public static string Format(IEnumerable<string> text)
28-
{
29-
return Format(string.Join(Environment.NewLine, text));
30-
}
31-
32-
public static string Format(string text)
33-
{
34-
return Format(text, null);
35-
}
36-
37-
public static string Format(string text, string prefix)
38-
{
39-
return CodeComment.FormatXml(text, prefix);
40-
}
4135
}
4236
}

CodeMaid.UnitTests/Formatting/FormatWithPrefixTests.cs

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
23
using SteveCadwallader.CodeMaid.Properties;
3-
using System;
44

55
namespace SteveCadwallader.CodeMaid.UnitTests.Formatting
66
{
@@ -19,20 +19,46 @@ public void TestInitialize()
1919
[TestCategory("Formatting UnitTests")]
2020
public void SimpleFormatWithPrefixTests_KeepsPrefix()
2121
{
22-
Settings.Default.Formatting_CommentWrapColumn = 40;
2322
var input = "// Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
2423
var expected =
2524
"// Lorem ipsum dolor sit amet," + Environment.NewLine +
2625
"// consectetur adipiscing elit.";
27-
CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//");
26+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//", o => o.WrapColumn = 40);
2827
}
2928

3029
[TestMethod]
3130
[TestCategory("Formatting UnitTests")]
3231
public void SimpleFormatWithPrefixTests_TrimsTrailingSpace()
3332
{
34-
var input = "// ";
35-
var expected = "//";
33+
var input = "// Trailing space ";
34+
var expected = "// Trailing space";
35+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//");
36+
}
37+
38+
[TestMethod]
39+
[TestCategory("Formatting UnitTests")]
40+
public void SimpleFormatWithPrefixTests_TrimsTrailingLines()
41+
{
42+
var input =
43+
"// Comment with some trailing lines" + Environment.NewLine +
44+
"//" + Environment.NewLine +
45+
"//";
46+
var expected =
47+
"// Comment with some trailing lines";
48+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//");
49+
}
50+
51+
[TestMethod]
52+
[TestCategory("Formatting UnitTests")]
53+
public void SimpleFormatWithPrefixTests_TrimsLeadingLines()
54+
{
55+
var input =
56+
"//" + Environment.NewLine +
57+
"//" + Environment.NewLine +
58+
"// Comment with some leading lines";
59+
var expected =
60+
"// Comment with some leading lines";
61+
3662
CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//");
3763
}
3864

@@ -48,26 +74,24 @@ public void SimpleFormatWithPrefixTests_KeepsLeadingSpace()
4874
[TestCategory("Formatting UnitTests")]
4975
public void SimpleFormatWithPrefixTests_AlignsToFirstPrefix()
5076
{
51-
Settings.Default.Formatting_CommentWrapColumn = 40;
5277
var input =
5378
" // Lorem ipsum dolor sit amet, consectetur" + Environment.NewLine +
5479
" // adipiscing elit.";
5580
var expected =
5681
" // Lorem ipsum dolor sit amet," + Environment.NewLine +
5782
" // consectetur adipiscing elit.";
58-
CommentFormatHelper.AssertEqualAfterFormat(input, expected, " //");
83+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, " //", o => o.WrapColumn = 40);
5984
}
6085

6186
[TestMethod]
6287
[TestCategory("Formatting UnitTests")]
6388
public void SimpleFormatWithPrefixTests_NoTrailingWhitespaceOnEmptyLine()
6489
{
65-
Settings.Default.Formatting_CommentWrapColumn = 40;
6690
var input =
6791
"// Lorem ipsum dolor sit amet." + Environment.NewLine +
6892
"//" + Environment.NewLine +
6993
"// Consectetur adipiscing elit.";
70-
CommentFormatHelper.AssertEqualAfterFormat(input, input, "//");
94+
CommentFormatHelper.AssertEqualAfterFormat(input, input, "//", o => o.WrapColumn = 40);
7195
}
7296
}
7397
}

CodeMaid.UnitTests/Formatting/HeaderFormattingTests.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,19 @@ public void TestInitialize()
2222
/// </summary>
2323
[TestMethod]
2424
[TestCategory("Formatting UnitTests")]
25-
public void HeaderFormattingTests_IndentsXML()
25+
public void HeaderFormattingTests_Copyright_Indenting()
2626
{
27-
Settings.Default.Formatting_CommentXmlValueIndent = 0;
28-
2927
var input =
3028
@"<copyright file=""NameOfFile.cs"" company=""CompanyName"">" + Environment.NewLine +
3129
@"Company copyright tag." + Environment.NewLine +
3230
@"</copyright>";
3331

34-
// It's not fair, but even though we are formatting without a prefix, the forced header
35-
// indenting adds one extra space (to separate the prefix from the text) to the
36-
// indenting, making it 5 total.
3732
var expected =
3833
@"<copyright file=""NameOfFile.cs"" company=""CompanyName"">" + Environment.NewLine +
39-
@" Company copyright tag." + Environment.NewLine +
34+
@" Company copyright tag." + Environment.NewLine +
4035
@"</copyright>";
4136

42-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
37+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.Xml.Default.Indent = 0);
4338
}
4439

4540
[TestMethod]
@@ -58,13 +53,12 @@ public void HeaderFormattingTests_PreservesHyphenLinesWithoutXML()
5853

5954
[TestMethod]
6055
[TestCategory("Formatting UnitTests")]
61-
public void HeaderFormattingTests_PreservesHyphenLinesWithXML()
56+
public void HeaderFormattingTests_Copyright_PreservesHyphenLinesWithXML()
6257
{
63-
// Same as above, indenting without a prefix sneaks in an extra space.
6458
var input =
6559
@"-----------------------------------------------------------------------" + Environment.NewLine +
6660
@"<copyright file=""NameOfFile.cs"" company=""CompanyName"">" + Environment.NewLine +
67-
@" Company copyright tag." + Environment.NewLine +
61+
@" Company copyright tag." + Environment.NewLine +
6862
@"</copyright>" + Environment.NewLine +
6963
@"-----------------------------------------------------------------------";
7064

CodeMaid.UnitTests/Formatting/IgnorePrefixesTests.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public void TestInitialize()
2020
[TestCategory("Formatting UnitTests")]
2121
public void IgnorePrefixesTests_DoesNotWrapSingleLine()
2222
{
23-
Settings.Default.Formatting_CommentWrapColumn = 30;
24-
CommentFormatHelper.AssertEqualAfterFormat(@"TODO: Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
23+
CommentFormatHelper.AssertEqualAfterFormat(@"TODO: Lorem ipsum dolor sit amet, consectetur adipiscing elit.", o => o.WrapColumn = 30);
2524
}
2625

2726
[TestMethod]
@@ -41,8 +40,7 @@ public void IgnorePrefixesTests_DoesNotWrapLineInsideComment()
4140
"Lorem ipsum dolor sit amet," + Environment.NewLine +
4241
"consectetur adipiscing elit.";
4342

44-
Settings.Default.Formatting_CommentWrapColumn = 30;
45-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
43+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 30);
4644
}
4745

4846
[TestMethod]
@@ -64,8 +62,7 @@ public void IgnorePrefixesTests_DoesNotCombineSubsequentLines()
6462
"Lorem ipsum dolor sit amet," + Environment.NewLine +
6563
"consectetur adipiscing elit.";
6664

67-
Settings.Default.Formatting_CommentWrapColumn = 30;
68-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
65+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 30);
6966
}
7067
}
7168
}

CodeMaid.UnitTests/Formatting/ListFormattingTests.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
namespace SteveCadwallader.CodeMaid.UnitTests.Formatting
66
{
77
/// <summary>
8-
/// Class with list oriented unit tests for formatting. This calls the formatter directly,
9-
/// rather than invoking it through the UI as with the integration tests.
8+
/// Class with list oriented unit tests for formatting. This calls the formatter directly, rather
9+
/// than invoking it through the UI as with the integration tests.
1010
/// </summary>
1111
[TestClass]
1212
public class ListFormattingTests
@@ -35,9 +35,7 @@ public void ListFormattingTests_DashedList()
3535
@" words to require wrapping." + Environment.NewLine +
3636
@"Some trailing text.";
3737

38-
Settings.Default.Formatting_CommentWrapColumn = 30;
39-
40-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
38+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 30);
4139
}
4240

4341
[TestMethod]
@@ -58,9 +56,7 @@ public void ListFormattingTests_NumberedList()
5856
@" words to require wrapping." + Environment.NewLine +
5957
@"Some trailing text.";
6058

61-
Settings.Default.Formatting_CommentWrapColumn = 30;
62-
63-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
59+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 30);
6460
}
6561

6662
[TestMethod]
@@ -81,9 +77,7 @@ public void ListFormattingTests_WordList()
8177
@" words to require wrapping." + Environment.NewLine +
8278
@"Some trailing text.";
8379

84-
Settings.Default.Formatting_CommentWrapColumn = 35;
85-
86-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
80+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 35);
8781
}
8882

8983
[TestMethod]
@@ -153,8 +147,7 @@ public void ListFormattingTests_XmlListWithHeaderAndIndent()
153147
"</list>" + Environment.NewLine +
154148
"Some trailing text.";
155149

156-
Settings.Default.Formatting_CommentXmlValueIndent = 2;
157-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
150+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.Xml.Default.Indent = 2);
158151
}
159152
}
160153
}

CodeMaid.UnitTests/Formatting/SimpleFormattingTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,11 @@ public void SimpleFormattingTests_SkipWrapOnLastWord()
105105
var input = "Lorem ipsum dolor sit amet.";
106106
var expected = "Lorem ipsum\r\ndolor sit amet.";
107107

108-
Settings.Default.Formatting_CommentWrapColumn = 12;
109-
Settings.Default.Formatting_CommentSkipWrapOnLastWord = true;
110-
111-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
108+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o =>
109+
{
110+
o.WrapColumn = 12;
111+
o.SkipWrapOnLastWord = true;
112+
});
112113
}
113114

114115
[TestMethod]
@@ -118,10 +119,11 @@ public void SimpleFormattingTests_WrapOnLastWord()
118119
var input = "Lorem ipsum dolor sit amet.";
119120
var expected = "Lorem ipsum\r\ndolor sit\r\namet.";
120121

121-
Settings.Default.Formatting_CommentWrapColumn = 12;
122-
Settings.Default.Formatting_CommentSkipWrapOnLastWord = false;
123-
124-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
122+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o =>
123+
{
124+
o.WrapColumn = 12;
125+
o.SkipWrapOnLastWord = false;
126+
});
125127
}
126128

127129
[TestMethod]
@@ -147,9 +149,7 @@ public void SimpleFormattingTests_WrapsLinesAsExpected()
147149
var input = "Lorem ipsum dolor sit.";
148150
var expected = "Lorem ipsum\r\ndolor sit.";
149151

150-
Settings.Default.Formatting_CommentWrapColumn = 12;
151-
152-
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
152+
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 12);
153153
}
154154

155155
[TestMethod]

0 commit comments

Comments
 (0)