Skip to content

Commit

Permalink
Merge pull request #687 from codecadwallader/master
Browse files Browse the repository at this point in the history
v11.1
  • Loading branch information
codecadwallader authored Nov 3, 2019
2 parents fc1bec3 + 8b9668c commit 2b829ad
Show file tree
Hide file tree
Showing 47 changed files with 1,106 additions and 764 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
# Changelog

## vNext (11.1)
## vNext (11.2)

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/).

- [ ] Features

- [ ] Fixes

## Previous Releases

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

## 11.1

**2019-11-03**

- [x] Features
- [x] [#620](https://github.com/codecadwallader/codemaid/pull/620) - Formatting: Allow for individual tag formatting rules - thanks [willemduncan](https://github.com/willemduncan)!
- [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)!

- [x] Fixes
- [x] [#647](https://github.com/codecadwallader/codemaid/pull/647) - Formatting: Fix magically added slashes - thanks [willemduncan](https://github.com/willemduncan)!
- [x] [#670](https://github.com/codecadwallader/codemaid/pull/670) - Options: Fix importing read-only config - thanks [Smartis2812](https://github.com/Smartis2812)!

## 11.0

**2019-03-23**
Expand Down
40 changes: 17 additions & 23 deletions CodeMaid.UnitTests/Formatting/CommentFormatHelper.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SteveCadwallader.CodeMaid.Model.Comments;
using SteveCadwallader.CodeMaid.Model.Comments.Options;
using System;
using System.Collections.Generic;

namespace SteveCadwallader.CodeMaid.UnitTests.Formatting
{
internal class CommentFormatHelper
{
public static string AssertEqualAfterFormat(string input)
public static string AssertEqualAfterFormat(
string text,
Action<FormatterOptions> options = null)
{
return AssertEqualAfterFormat(input, input);
return AssertEqualAfterFormat(text, null, null, options);
}

public static string AssertEqualAfterFormat(string input, string expected)
public static string AssertEqualAfterFormat(
string text,
string expected,
Action<FormatterOptions> options = null)
{
return AssertEqualAfterFormat(input, expected, null);
return AssertEqualAfterFormat(text, expected, null, options);
}

public static string AssertEqualAfterFormat(string input, string expected, string prefix)
public static string AssertEqualAfterFormat(
string text,
string expected,
string prefix,
Action<FormatterOptions> options = null)
{
var result = Format(input, prefix);
Assert.AreEqual(expected, result);
var result = CodeComment.Format(text, prefix, options);
Assert.AreEqual(expected ?? text, result);
return result;
}

public static string Format(IEnumerable<string> text)
{
return Format(string.Join(Environment.NewLine, text));
}

public static string Format(string text)
{
return Format(text, null);
}

public static string Format(string text, string prefix)
{
return CodeComment.FormatXml(text, prefix);
}
}
}
44 changes: 34 additions & 10 deletions CodeMaid.UnitTests/Formatting/FormatWithPrefixTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SteveCadwallader.CodeMaid.Properties;
using System;

namespace SteveCadwallader.CodeMaid.UnitTests.Formatting
{
Expand All @@ -19,20 +19,46 @@ public void TestInitialize()
[TestCategory("Formatting UnitTests")]
public void SimpleFormatWithPrefixTests_KeepsPrefix()
{
Settings.Default.Formatting_CommentWrapColumn = 40;
var input = "// Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
var expected =
"// Lorem ipsum dolor sit amet," + Environment.NewLine +
"// consectetur adipiscing elit.";
CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//");
CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//", o => o.WrapColumn = 40);
}

[TestMethod]
[TestCategory("Formatting UnitTests")]
public void SimpleFormatWithPrefixTests_TrimsTrailingSpace()
{
var input = "// ";
var expected = "//";
var input = "// Trailing space ";
var expected = "// Trailing space";
CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//");
}

[TestMethod]
[TestCategory("Formatting UnitTests")]
public void SimpleFormatWithPrefixTests_TrimsTrailingLines()
{
var input =
"// Comment with some trailing lines" + Environment.NewLine +
"//" + Environment.NewLine +
"//";
var expected =
"// Comment with some trailing lines";
CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//");
}

[TestMethod]
[TestCategory("Formatting UnitTests")]
public void SimpleFormatWithPrefixTests_TrimsLeadingLines()
{
var input =
"//" + Environment.NewLine +
"//" + Environment.NewLine +
"// Comment with some leading lines";
var expected =
"// Comment with some leading lines";

CommentFormatHelper.AssertEqualAfterFormat(input, expected, "//");
}

Expand All @@ -48,26 +74,24 @@ public void SimpleFormatWithPrefixTests_KeepsLeadingSpace()
[TestCategory("Formatting UnitTests")]
public void SimpleFormatWithPrefixTests_AlignsToFirstPrefix()
{
Settings.Default.Formatting_CommentWrapColumn = 40;
var input =
" // Lorem ipsum dolor sit amet, consectetur" + Environment.NewLine +
" // adipiscing elit.";
var expected =
" // Lorem ipsum dolor sit amet," + Environment.NewLine +
" // consectetur adipiscing elit.";
CommentFormatHelper.AssertEqualAfterFormat(input, expected, " //");
CommentFormatHelper.AssertEqualAfterFormat(input, expected, " //", o => o.WrapColumn = 40);
}

[TestMethod]
[TestCategory("Formatting UnitTests")]
public void SimpleFormatWithPrefixTests_NoTrailingWhitespaceOnEmptyLine()
{
Settings.Default.Formatting_CommentWrapColumn = 40;
var input =
"// Lorem ipsum dolor sit amet." + Environment.NewLine +
"//" + Environment.NewLine +
"// Consectetur adipiscing elit.";
CommentFormatHelper.AssertEqualAfterFormat(input, input, "//");
CommentFormatHelper.AssertEqualAfterFormat(input, input, "//", o => o.WrapColumn = 40);
}
}
}
16 changes: 5 additions & 11 deletions CodeMaid.UnitTests/Formatting/HeaderFormattingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,19 @@ public void TestInitialize()
/// </summary>
[TestMethod]
[TestCategory("Formatting UnitTests")]
public void HeaderFormattingTests_IndentsXML()
public void HeaderFormattingTests_Copyright_Indenting()
{
Settings.Default.Formatting_CommentXmlValueIndent = 0;

var input =
@"<copyright file=""NameOfFile.cs"" company=""CompanyName"">" + Environment.NewLine +
@"Company copyright tag." + Environment.NewLine +
@"</copyright>";

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

CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.Xml.Default.Indent = 0);
}

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

[TestMethod]
[TestCategory("Formatting UnitTests")]
public void HeaderFormattingTests_PreservesHyphenLinesWithXML()
public void HeaderFormattingTests_Copyright_PreservesHyphenLinesWithXML()
{
// Same as above, indenting without a prefix sneaks in an extra space.
var input =
@"-----------------------------------------------------------------------" + Environment.NewLine +
@"<copyright file=""NameOfFile.cs"" company=""CompanyName"">" + Environment.NewLine +
@" Company copyright tag." + Environment.NewLine +
@" Company copyright tag." + Environment.NewLine +
@"</copyright>" + Environment.NewLine +
@"-----------------------------------------------------------------------";

Expand Down
9 changes: 3 additions & 6 deletions CodeMaid.UnitTests/Formatting/IgnorePrefixesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public void TestInitialize()
[TestCategory("Formatting UnitTests")]
public void IgnorePrefixesTests_DoesNotWrapSingleLine()
{
Settings.Default.Formatting_CommentWrapColumn = 30;
CommentFormatHelper.AssertEqualAfterFormat(@"TODO: Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
CommentFormatHelper.AssertEqualAfterFormat(@"TODO: Lorem ipsum dolor sit amet, consectetur adipiscing elit.", o => o.WrapColumn = 30);
}

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

Settings.Default.Formatting_CommentWrapColumn = 30;
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 30);
}

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

Settings.Default.Formatting_CommentWrapColumn = 30;
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 30);
}
}
}
19 changes: 6 additions & 13 deletions CodeMaid.UnitTests/Formatting/ListFormattingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace SteveCadwallader.CodeMaid.UnitTests.Formatting
{
/// <summary>
/// Class with list oriented unit tests for formatting. This calls the formatter directly,
/// rather than invoking it through the UI as with the integration tests.
/// Class with list oriented unit tests for formatting. This calls the formatter directly, rather
/// than invoking it through the UI as with the integration tests.
/// </summary>
[TestClass]
public class ListFormattingTests
Expand Down Expand Up @@ -35,9 +35,7 @@ public void ListFormattingTests_DashedList()
@" words to require wrapping." + Environment.NewLine +
@"Some trailing text.";

Settings.Default.Formatting_CommentWrapColumn = 30;

CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 30);
}

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

Settings.Default.Formatting_CommentWrapColumn = 30;

CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 30);
}

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

Settings.Default.Formatting_CommentWrapColumn = 35;

CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 35);
}

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

Settings.Default.Formatting_CommentXmlValueIndent = 2;
CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.Xml.Default.Indent = 2);
}
}
}
22 changes: 11 additions & 11 deletions CodeMaid.UnitTests/Formatting/SimpleFormattingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ public void SimpleFormattingTests_SkipWrapOnLastWord()
var input = "Lorem ipsum dolor sit amet.";
var expected = "Lorem ipsum\r\ndolor sit amet.";

Settings.Default.Formatting_CommentWrapColumn = 12;
Settings.Default.Formatting_CommentSkipWrapOnLastWord = true;

CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o =>
{
o.WrapColumn = 12;
o.SkipWrapOnLastWord = true;
});
}

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

Settings.Default.Formatting_CommentWrapColumn = 12;
Settings.Default.Formatting_CommentSkipWrapOnLastWord = false;

CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o =>
{
o.WrapColumn = 12;
o.SkipWrapOnLastWord = false;
});
}

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

Settings.Default.Formatting_CommentWrapColumn = 12;

CommentFormatHelper.AssertEqualAfterFormat(input, expected);
CommentFormatHelper.AssertEqualAfterFormat(input, expected, o => o.WrapColumn = 12);
}

[TestMethod]
Expand Down
Loading

0 comments on commit 2b829ad

Please sign in to comment.