diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 98565db55b..b7b095304d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,7 @@ Guidelines for contributing to the Roslynator repo. ## Creating Issues +* **DO** create a new issue rather than commenting a closed issue. * **DO** include analyzer/refactoring/error ID in a title (i.e. RCSxxxx, RRxxxx or CSxxxx). * **DO** use a descriptive title that identifies the issue or requested feature. * **DO** specify a detailed description of the issue or requested feature. diff --git a/ChangeLog.md b/ChangeLog.md index 0b3c603b5f..cc4f962028 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,9 @@ +### 2.2.0 (2019-09-28) + +#### Analyzers + +* Disable analyzer [FormatBinaryOperatorOnNextLine](http://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1029.md) by default. + ### 2.1.3 (2019-08-06) #### Analyzers diff --git a/docs/analyzers/RCS1018.md b/docs/analyzers/RCS1018.md index 1c298cc2a9..834fdf8132 100644 --- a/docs/analyzers/RCS1018.md +++ b/docs/analyzers/RCS1018.md @@ -1,4 +1,4 @@ -# RCS1018: Add default access modifier +# RCS1018: Add accessibility modifiers | Property | Value | | -------- | ----------- | diff --git a/docs/analyzers/RCS1029.md b/docs/analyzers/RCS1029.md index 26ead530b4..8396499f5c 100644 --- a/docs/analyzers/RCS1029.md +++ b/docs/analyzers/RCS1029.md @@ -4,7 +4,7 @@ | -------- | ---------- | | Id | RCS1029 | | Category | Formatting | -| Severity | Info | +| Severity | None | ## Example diff --git a/docs/analyzers/RCS1073.md b/docs/analyzers/RCS1073.md index 02ab430fb0..9bebda6a80 100644 --- a/docs/analyzers/RCS1073.md +++ b/docs/analyzers/RCS1073.md @@ -1,4 +1,4 @@ -# RCS1073: Replace if statement with return statement +# RCS1073: Convert 'if' to 'return' statement | Property | Value | | -------- | -------------- | diff --git a/docs/analyzers/RCS1103.md b/docs/analyzers/RCS1103.md index f5c0e1f047..e48d85e8dc 100644 --- a/docs/analyzers/RCS1103.md +++ b/docs/analyzers/RCS1103.md @@ -1,4 +1,4 @@ -# RCS1103: Replace if statement with assignment +# RCS1103: Convert 'if' to assignment | Property | Value | | -------- | -------------- | diff --git a/docs/analyzers/RCS1217.md b/docs/analyzers/RCS1217.md index c53815b9bd..d4129f984b 100644 --- a/docs/analyzers/RCS1217.md +++ b/docs/analyzers/RCS1217.md @@ -1,4 +1,4 @@ -# RCS1217: Replace interpolated string with concatenation +# RCS1217: Convert interpolated string to concatenation | Property | Value | | -------- | ----------- | diff --git a/docs/refactorings/RR0123.md b/docs/refactorings/RR0123.md index 607828d1ae..d0cc2fe4a4 100644 --- a/docs/refactorings/RR0123.md +++ b/docs/refactorings/RR0123.md @@ -1,12 +1,12 @@ -## Replace do statement with while statement - -| Property | Value | -| ------------------ | ----------------------------------------- | -| Id | RR0123 | -| Title | Replace do statement with while statement | -| Syntax | do statement | -| Span | do keyword | -| Enabled by Default | ✓ | +## Convert 'do' to 'while' + +| Property | Value | +| ------------------ | ----------------------- | +| Id | RR0123 | +| Title | Convert 'do' to 'while' | +| Syntax | do statement | +| Span | do keyword | +| Enabled by Default | ✓ | ### Usage diff --git a/docs/refactorings/RR0129.md b/docs/refactorings/RR0129.md index d09a3d6578..aba6dbcafe 100644 --- a/docs/refactorings/RR0129.md +++ b/docs/refactorings/RR0129.md @@ -1,15 +1,15 @@ -## Replace foreach statement with for statement +## Convert 'foreach' to 'for' -| Property | Value | -| ------------------ | -------------------------------------------- | -| Id | RR0129 | -| Title | Replace foreach statement with for statement | -| Syntax | foreach statement | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | -------------------------- | +| Id | RR0129 | +| Title | Convert 'foreach' to 'for' | +| Syntax | foreach statement | +| Enabled by Default | ✓ | ### Usage -![Replace foreach statement with for statement](../../images/refactorings/ReplaceForEachWithFor.png) +![Convert 'foreach' to 'for'](../../images/refactorings/ConvertForEachToFor.png) ## See Also diff --git a/docs/refactorings/RR0130.md b/docs/refactorings/RR0130.md index 1a6ba2e212..1169eeea0a 100644 --- a/docs/refactorings/RR0130.md +++ b/docs/refactorings/RR0130.md @@ -1,15 +1,15 @@ -## Replace for statement with foreach statement +## Convert 'for' to 'foreach' -| Property | Value | -| ------------------ | -------------------------------------------- | -| Id | RR0130 | -| Title | Replace for statement with foreach statement | -| Syntax | for statement | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | -------------------------- | +| Id | RR0130 | +| Title | Convert 'for' to 'foreach' | +| Syntax | for statement | +| Enabled by Default | ✓ | ### Usage -![Replace for statement with foreach statement](../../images/refactorings/ReplaceForWithForEach.png) +![Convert 'for' to 'foreach'](../../images/refactorings/ConvertForToForEach.png) ## See Also diff --git a/docs/refactorings/RR0131.md b/docs/refactorings/RR0131.md index 19a83c7317..cd6683d213 100644 --- a/docs/refactorings/RR0131.md +++ b/docs/refactorings/RR0131.md @@ -1,16 +1,16 @@ -## Replace for statement with while statement +## Convert 'for' to 'while' -| Property | Value | -| ------------------ | ------------------------------------------ | -| Id | RR0131 | -| Title | Replace for statement with while statement | -| Syntax | for statement | -| Span | for keyword or selected for statement | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | ------------------------------------- | +| Id | RR0131 | +| Title | Convert 'for' to 'while' | +| Syntax | for statement | +| Span | for keyword or selected for statement | +| Enabled by Default | ✓ | ### Usage -![Replace for statement with while statement](../../images/refactorings/ReplaceForWithWhile.png) +![Convert 'for' to 'while'](../../images/refactorings/ConvertForToWhile.png) ## See Also diff --git a/docs/refactorings/RR0132.md b/docs/refactorings/RR0132.md index 76445136f7..dd86400f64 100644 --- a/docs/refactorings/RR0132.md +++ b/docs/refactorings/RR0132.md @@ -1,15 +1,15 @@ -## Replace hexadecimal literal with decimal literal +## Convert hexadecimal literal to decimal literal -| Property | Value | -| ------------------ | ------------------------------------------------ | -| Id | RR0132 | -| Title | Replace hexadecimal literal with decimal literal | -| Syntax | hexadecimal literal | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | ---------------------------------------------- | +| Id | RR0132 | +| Title | Convert hexadecimal literal to decimal literal | +| Syntax | hexadecimal literal | +| Enabled by Default | ✓ | ### Usage -![Replace hexadecimal literal with decimal literal](../../images/refactorings/ReplaceHexadecimalLiteralWithDecimalLiteral.png) +![Convert hexadecimal literal to decimal literal](../../images/refactorings/ConvertHexadecimalLiteralToDecimalLiteral.png) ## See Also diff --git a/docs/refactorings/RR0133.md b/docs/refactorings/RR0133.md index 73f5b8a4d6..2fbce353db 100644 --- a/docs/refactorings/RR0133.md +++ b/docs/refactorings/RR0133.md @@ -1,9 +1,9 @@ -## Replace if with switch +## Convert 'if' to 'switch' | Property | Value | | ------------------ | --------------------------------------- | | Id | RR0133 | -| Title | Replace if with switch | +| Title | Convert 'if' to 'switch' | | Syntax | if statement | | Span | top if keyword or selected if statement | | Enabled by Default | ✓ | diff --git a/docs/refactorings/RR0136.md b/docs/refactorings/RR0136.md index 6587474f06..6117575be8 100644 --- a/docs/refactorings/RR0136.md +++ b/docs/refactorings/RR0136.md @@ -1,15 +1,15 @@ -## Replace interpolated string with string literal +## Convert interpolated string to string literal -| Property | Value | -| ------------------ | ----------------------------------------------- | -| Id | RR0136 | -| Title | Replace interpolated string with string literal | -| Syntax | Interpolated string without any interpolation | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | --------------------------------------------- | +| Id | RR0136 | +| Title | Convert interpolated string to string literal | +| Syntax | Interpolated string without any interpolation | +| Enabled by Default | ✓ | ### Usage -![Replace interpolated string with string literal](../../images/refactorings/ReplaceInterpolatedStringWithStringLiteral.png) +![Convert interpolated string to string literal](../../images/refactorings/ConvertInterpolatedStringToStringLiteral.png) ## See Also diff --git a/docs/refactorings/RR0142.md b/docs/refactorings/RR0142.md index 51b14f1edd..4c16a3b662 100644 --- a/docs/refactorings/RR0142.md +++ b/docs/refactorings/RR0142.md @@ -1,15 +1,15 @@ -## Replace regular string literal with verbatim string literal +## Convert regular string literal to verbatim string literal -| Property | Value | -| ------------------ | ----------------------------------------------------------- | -| Id | RR0142 | -| Title | Replace regular string literal with verbatim string literal | -| Syntax | regular string literal | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | --------------------------------------------------------- | +| Id | RR0142 | +| Title | Convert regular string literal to verbatim string literal | +| Syntax | regular string literal | +| Enabled by Default | ✓ | ### Usage -![Replace regular string literal with verbatim string literal](../../images/refactorings/ReplaceRegularStringLiteralWithVerbatimStringLiteral.png) +![Convert regular string literal to verbatim string literal](../../images/refactorings/ConvertRegularStringLiteralToVerbatimStringLiteral.png) ## See Also diff --git a/docs/refactorings/RR0143.md b/docs/refactorings/RR0143.md index 7788627aa4..31e66e321a 100644 --- a/docs/refactorings/RR0143.md +++ b/docs/refactorings/RR0143.md @@ -1,16 +1,16 @@ -## Replace \(yield\) return statement with if\-else +## Convert '\(yield\) return' to 'if' | Property | Value | | ------------------ | --------------------------------------------------- | | Id | RR0143 | -| Title | Replace \(yield\) return statement with if\-else | +| Title | Convert '\(yield\) return' to 'if' | | Syntax | return statement, yield return statement | | Span | selected statement, yield keyword or return keyword | | Enabled by Default | ✓ | ### Usage -![Replace (yield) return statement with if-else](../../images/refactorings/ReplaceReturnStatementWithIfElse.png) +![Convert '(yield) return' to 'if'](../../images/refactorings/ReplaceReturnStatementWithIfElse.png) ## See Also diff --git a/docs/refactorings/RR0145.md b/docs/refactorings/RR0145.md index c758e2fad7..07faa64ef3 100644 --- a/docs/refactorings/RR0145.md +++ b/docs/refactorings/RR0145.md @@ -1,15 +1,15 @@ -## Replace string\.Format with interpolated string +## Convert 'string\.Format' to interpolated string | Property | Value | | ------------------ | ----------------------------------------------- | | Id | RR0145 | -| Title | Replace string\.Format with interpolated string | +| Title | Convert 'string\.Format' to interpolated string | | Syntax | string\.Format method | | Enabled by Default | ✓ | ### Usage -![Replace string.Format with interpolated string](../../images/refactorings/ReplaceStringFormatWithInterpolatedString.png) +![Convert 'string.Format' to interpolated string](../../images/refactorings/ConvertStringFormatToInterpolatedString.png) ## See Also diff --git a/docs/refactorings/RR0147.md b/docs/refactorings/RR0147.md index b7a5348ab7..bc91c308dd 100644 --- a/docs/refactorings/RR0147.md +++ b/docs/refactorings/RR0147.md @@ -1,16 +1,16 @@ -## Replace switch with if +## Convert 'switch to 'if' -| Property | Value | -| ------------------ | ---------------------- | -| Id | RR0147 | -| Title | Replace switch with if | -| Syntax | switch statement | -| Span | switch keyword | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | ----------------------- | +| Id | RR0147 | +| Title | Convert 'switch to 'if' | +| Syntax | switch statement | +| Span | switch keyword | +| Enabled by Default | ✓ | ### Usage -![Replace switch with if](../../images/refactorings/ReplaceSwitchWithIf.png) +![Convert 'switch to 'if'](../../images/refactorings/ConvertSwitchToIf.png) ## See Also diff --git a/docs/refactorings/RR0148.md b/docs/refactorings/RR0148.md index b556b1d2e8..53b9d21d77 100644 --- a/docs/refactorings/RR0148.md +++ b/docs/refactorings/RR0148.md @@ -1,15 +1,15 @@ -## Replace verbatim string literal with regular string literal +## Convert verbatim string literal to regular string literal -| Property | Value | -| ------------------ | ----------------------------------------------------------- | -| Id | RR0148 | -| Title | Replace verbatim string literal with regular string literal | -| Syntax | verbatim string literal | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | --------------------------------------------------------- | +| Id | RR0148 | +| Title | Convert verbatim string literal to regular string literal | +| Syntax | verbatim string literal | +| Enabled by Default | ✓ | ### Usage -![Replace verbatim string literal with regular string literal](../../images/refactorings/ReplaceVerbatimStringLiteralWithRegularStringLiteral.png) +![Convert verbatim string literal to regular string literal](../../images/refactorings/ConvertVerbatimStringLiteralToRegularStringLiteral.png) ## See Also diff --git a/docs/refactorings/RR0149.md b/docs/refactorings/RR0149.md index d4ebecc555..0e32952664 100644 --- a/docs/refactorings/RR0149.md +++ b/docs/refactorings/RR0149.md @@ -1,15 +1,15 @@ -## Replace verbatim string literal with regular string literals +## Convert verbatim string literal to regular string literals -| Property | Value | -| ------------------ | ------------------------------------------------------------ | -| Id | RR0149 | -| Title | Replace verbatim string literal with regular string literals | -| Syntax | multiline verbatim string literal | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | ---------------------------------------------------------- | +| Id | RR0149 | +| Title | Convert verbatim string literal to regular string literals | +| Syntax | multiline verbatim string literal | +| Enabled by Default | ✓ | ### Usage -![Replace verbatim string literal with regular string literals](../../images/refactorings/ReplaceVerbatimStringLiteralWithRegularStringLiterals.png) +![Convert verbatim string literal to regular string literals](../../images/refactorings/ConvertVerbatimStringLiteralToRegularStringLiterals.png) ## See Also diff --git a/docs/refactorings/RR0152.md b/docs/refactorings/RR0152.md index 1bc3e90676..6b8e03634e 100644 --- a/docs/refactorings/RR0152.md +++ b/docs/refactorings/RR0152.md @@ -1,15 +1,15 @@ -## Reverse for loop +## Reverse 'for' loop -| Property | Value | -| ------------------ | ---------------- | -| Id | RR0152 | -| Title | Reverse for loop | -| Syntax | for statement | -| Enabled by Default | ✓ | +| Property | Value | +| ------------------ | ------------------ | +| Id | RR0152 | +| Title | Reverse 'for' loop | +| Syntax | for statement | +| Enabled by Default | ✓ | ### Usage -![Reverse for loop](../../images/refactorings/ReverseForLoop.png) +![Reverse 'for' loop](../../images/refactorings/ReverseForLoop.png) ## See Also diff --git a/docs/refactorings/RR0171.md b/docs/refactorings/RR0171.md index d973173ec9..ef0bfe00c7 100644 --- a/docs/refactorings/RR0171.md +++ b/docs/refactorings/RR0171.md @@ -1,15 +1,15 @@ -## Use string\.Empty instead of "" +## Convert "" to string\.Empty -| Property | Value | -| ------------------ | ------------------------------- | -| Id | RR0171 | -| Title | Use string\.Empty instead of "" | -| Syntax | empty string literal | -| Enabled by Default | \- | +| Property | Value | +| ------------------ | --------------------------- | +| Id | RR0171 | +| Title | Convert "" to string\.Empty | +| Syntax | empty string literal | +| Enabled by Default | \- | ### Usage -![Use string.Empty instead of ""](../../images/refactorings/UseStringEmptyInsteadOfEmptyStringLiteral.png) +![Convert "" to string.Empty](../../images/refactorings/ConvertEmptyStringToStringEmpty.png) ## See Also diff --git a/docs/refactorings/RR0188.md b/docs/refactorings/RR0188.md index c8039778f0..b80cbdefd0 100644 --- a/docs/refactorings/RR0188.md +++ b/docs/refactorings/RR0188.md @@ -1,11 +1,11 @@ -## Replace foreach with for and reverse loop - -| Property | Value | -| ------------------ | ----------------------------------------- | -| Id | RR0188 | -| Title | Replace foreach with for and reverse loop | -| Syntax | foreach statement | -| Enabled by Default | \- | +## Convert 'foreach' to 'for' and reverse loop + +| Property | Value | +| ------------------ | ------------------------------------------- | +| Id | RR0188 | +| Title | Convert 'foreach' to 'for' and reverse loop | +| Syntax | foreach statement | +| Enabled by Default | \- | ### Usage diff --git a/docs/refactorings/RR0193.md b/docs/refactorings/RR0193.md index 17c7bd4c1e..7a86d35c08 100644 --- a/docs/refactorings/RR0193.md +++ b/docs/refactorings/RR0193.md @@ -1,11 +1,11 @@ -## Replace interpolated string with concatenation - -| Property | Value | -| ------------------ | ---------------------------------------------- | -| Id | RR0193 | -| Title | Replace interpolated string with concatenation | -| Syntax | interpolated string | -| Enabled by Default | ✓ | +## Convert interpolated string to concatenation + +| Property | Value | +| ------------------ | -------------------------------------------- | +| Id | RR0193 | +| Title | Convert interpolated string to concatenation | +| Syntax | interpolated string | +| Enabled by Default | ✓ | ### Usage diff --git a/docs/refactorings/RR0201.md b/docs/refactorings/RR0201.md index e07310d41e..5cfbf68c8a 100644 --- a/docs/refactorings/RR0201.md +++ b/docs/refactorings/RR0201.md @@ -1,9 +1,9 @@ -## Replace interpolated string with string\.Format +## Convert interpolated string to 'string\.Format' | Property | Value | | ------------------ | ----------------------------------------------- | | Id | RR0201 | -| Title | Replace interpolated string with string\.Format | +| Title | Convert interpolated string to 'string\.Format' | | Syntax | interpolated string | | Enabled by Default | ✓ | diff --git a/docs/refactorings/RR0206.md b/docs/refactorings/RR0206.md index 00ca7b0755..408c6db536 100644 --- a/docs/refactorings/RR0206.md +++ b/docs/refactorings/RR0206.md @@ -1,12 +1,12 @@ -## Replace foreach with enumerator - -| Property | Value | -| ------------------ | ------------------------------- | -| Id | RR0206 | -| Title | Replace foreach with enumerator | -| Syntax | foreach statement | -| Span | foreach keyword | -| Enabled by Default | ✓ | +## Use enumerator explicitly + +| Property | Value | +| ------------------ | ------------------------- | +| Id | RR0206 | +| Title | Use enumerator explicitly | +| Syntax | foreach statement | +| Span | foreach keyword | +| Enabled by Default | ✓ | ### Usage diff --git a/docs/refactorings/Refactorings.md b/docs/refactorings/Refactorings.md index cb350d0703..429cac04e6 100644 --- a/docs/refactorings/Refactorings.md +++ b/docs/refactorings/Refactorings.md @@ -363,6 +363,17 @@ List items = new List(); * **Span**: opening or closing brace ![Comment out statement](../../images/refactorings/CommentOutStatement.png) +#### Convert "" to string\.Empty \(RR0171\) + +* **Syntax**: empty string literal +![Convert "" to string.Empty](../../images/refactorings/ConvertEmptyStringToStringEmpty.png) + +#### Convert '\(yield\) return' to 'if' \(RR0143\) + +* **Syntax**: return statement, yield return statement +* **Span**: selected statement, yield keyword or return keyword +![Convert '(yield) return' to 'if'](../../images/refactorings/ReplaceReturnStatementWithIfElse.png) + #### Convert ?: to if\-else \(RR0120\) * **Syntax**: ?: operator that is part of local declaration, assignment or \(yield\) return statement @@ -437,12 +448,159 @@ public class Foo } ``` +#### Convert 'do' to 'while' \(RR0123\) + +* **Syntax**: do statement +* **Span**: do keyword + +#### Before + +```csharp +do +{ +} while (condition); +``` + +#### After + +```csharp +while (condition) +{ +} +``` + +#### Convert 'for' to 'foreach' \(RR0130\) + +* **Syntax**: for statement +![Convert 'for' to 'foreach'](../../images/refactorings/ConvertForToForEach.png) + +#### Convert 'for' to 'while' \(RR0131\) + +* **Syntax**: for statement +* **Span**: for keyword or selected for statement +![Convert 'for' to 'while'](../../images/refactorings/ConvertForToWhile.png) + +#### Convert 'foreach' to 'for' \(RR0129\) + +* **Syntax**: foreach statement +![Convert 'foreach' to 'for'](../../images/refactorings/ConvertForEachToFor.png) + +#### Convert 'foreach' to 'for' and reverse loop \(RR0188\) + +* **Syntax**: foreach statement + +#### Before + +```csharp +foreach (object item in items) +{ + yield return item; +} +``` + +#### After + +```csharp +for (int i = items.Count - 1; i >= 0; i--) +{ + yield return items[i]; +} +``` + +#### Convert hexadecimal literal to decimal literal \(RR0132\) + +* **Syntax**: hexadecimal literal +![Convert hexadecimal literal to decimal literal](../../images/refactorings/ConvertHexadecimalLiteralToDecimalLiteral.png) + #### Convert 'if' to ?: \(RR0166\) * **Syntax**: if statement * **Span**: top if keyword or selected if statement ![Convert 'if' to ?:](../../images/refactorings/ConvertIfToConditionalOperator.png) +#### Convert 'if' to 'switch' \(RR0133\) + +* **Syntax**: if statement +* **Span**: top if keyword or selected if statement + +#### Before + +```csharp +var ch = stringReader.Read(); + +if (ch == 10 || ch == 13) +{ + return; +} +else +{ + stringBuilder.Append(ch); +} +``` + +#### After + +```csharp +var ch = stringReader.Read(); + +switch (ch) +{ + case 10: + case 13: + { + return; + } + + default: + { + stringBuilder.Append(ch); + break; + } +} +``` + +#### Convert interpolated string to concatenation \(RR0193\) + +* **Syntax**: interpolated string + +#### Before + +```csharp +string s = $"a{b}c"; +``` + +#### After + +```csharp +string s = "a" + b + "c"; +``` + +#### Convert interpolated string to string literal \(RR0136\) + +* **Syntax**: Interpolated string without any interpolation +![Convert interpolated string to string literal](../../images/refactorings/ConvertInterpolatedStringToStringLiteral.png) + +#### Convert interpolated string to 'string\.Format' \(RR0201\) + +* **Syntax**: interpolated string + +#### Before + +```csharp +$"name: {name,0:f}, value: {value}" +``` + +#### After + +```csharp +string.Format("name: {0,0:f} value: {1}", name, value) +``` + +#### Convert regular string literal to verbatim string literal \(RR0142\) + +* **Syntax**: regular string literal +![Convert regular string literal to verbatim string literal](../../images/refactorings/ConvertRegularStringLiteralToVerbatimStringLiteral.png) + #### Convert statements to if\-else \(RR0211\) * **Syntax**: selected statements \(first statement must be 'if' statement\) @@ -486,6 +644,27 @@ else } ``` +#### Convert 'string\.Format' to interpolated string \(RR0145\) + +* **Syntax**: string\.Format method +![Convert 'string.Format' to interpolated string](../../images/refactorings/ConvertStringFormatToInterpolatedString.png) + +#### Convert 'switch to 'if' \(RR0147\) + +* **Syntax**: switch statement +* **Span**: switch keyword +![Convert 'switch to 'if'](../../images/refactorings/ConvertSwitchToIf.png) + +#### Convert verbatim string literal to regular string literal \(RR0148\) + +* **Syntax**: verbatim string literal +![Convert verbatim string literal to regular string literal](../../images/refactorings/ConvertVerbatimStringLiteralToRegularStringLiteral.png) + +#### Convert verbatim string literal to regular string literals \(RR0149\) + +* **Syntax**: multiline verbatim string literal +![Convert verbatim string literal to regular string literals](../../images/refactorings/ConvertVerbatimStringLiteralToRegularStringLiterals.png) + #### Convert 'while' statement to 'do' statement \(RR0150\) * **Syntax**: while statement @@ -1683,12 +1862,6 @@ public enum Foo * **Syntax**: property identifier ![Rename property according to type name](../../images/refactorings/RenamePropertyAccordingToTypeName.png) -#### Replace \(yield\) return statement with if\-else \(RR0143\) - -* **Syntax**: return statement, yield return statement -* **Span**: selected statement, yield keyword or return keyword -![Replace (yield) return statement with if-else](../../images/refactorings/ReplaceReturnStatementWithIfElse.png) - #### Replace as expression with cast expression \(RR0117\) * **Syntax**: as expression @@ -1710,27 +1883,6 @@ public enum Foo * **Syntax**: constant declaration ![Replace constant with field](../../images/refactorings/ReplaceConstantWithField.png) -#### Replace do statement with while statement \(RR0123\) - -* **Syntax**: do statement -* **Span**: do keyword - -#### Before - -```csharp -do -{ -} while (condition); -``` - -#### After - -```csharp -while (condition) -{ -} -``` - #### Replace equals expression with string\.Equals \(RR0124\) * **Syntax**: equals expression, not equals expression @@ -1749,159 +1901,12 @@ while (condition) * **Span**: operator ![Replace equals expression with string.IsNullOrWhiteSpace](../../images/refactorings/ReplaceEqualsExpressionWithStringIsNullOrWhiteSpace.png) -#### Replace for statement with foreach statement \(RR0130\) - -* **Syntax**: for statement -![Replace for statement with foreach statement](../../images/refactorings/ReplaceForWithForEach.png) - -#### Replace for statement with while statement \(RR0131\) - -* **Syntax**: for statement -* **Span**: for keyword or selected for statement -![Replace for statement with while statement](../../images/refactorings/ReplaceForWithWhile.png) - -#### Replace foreach statement with for statement \(RR0129\) - -* **Syntax**: foreach statement -![Replace foreach statement with for statement](../../images/refactorings/ReplaceForEachWithFor.png) - -#### Replace foreach with enumerator \(RR0206\) - -* **Syntax**: foreach statement -* **Span**: foreach keyword - -#### Before - -```csharp -foreach (var item in items) -{ - yield return item; -} -``` - -#### After - -```csharp -using (var en = items.GetEnumerator()) -{ - while (en.MoveNext()) - { - yield return item; - } -} -``` - -#### Replace foreach with for and reverse loop \(RR0188\) - -* **Syntax**: foreach statement - -#### Before - -```csharp -foreach (object item in items) -{ - yield return item; -} -``` - -#### After - -```csharp -for (int i = items.Count - 1; i >= 0; i--) -{ - yield return items[i]; -} -``` - -#### Replace hexadecimal literal with decimal literal \(RR0132\) - -* **Syntax**: hexadecimal literal -![Replace hexadecimal literal with decimal literal](../../images/refactorings/ReplaceHexadecimalLiteralWithDecimalLiteral.png) - -#### Replace if with switch \(RR0133\) - -* **Syntax**: if statement -* **Span**: top if keyword or selected if statement - -#### Before - -```csharp -var ch = stringReader.Read(); - -if (ch == 10 || ch == 13) -{ - return; -} -else -{ - stringBuilder.Append(ch); -} -``` - -#### After - -```csharp -var ch = stringReader.Read(); - -switch (ch) -{ - case 10: - case 13: - { - return; - } - - default: - { - stringBuilder.Append(ch); - break; - } -} -``` - -#### Replace interpolated string with concatenation \(RR0193\) - -* **Syntax**: interpolated string - -#### Before - -```csharp -string s = $"a{b}c"; -``` - -#### After - -```csharp -string s = "a" + b + "c"; -``` - #### Replace interpolated string with interpolation expression \(RR0135\) * **Syntax**: interpolated string with single interpolation and no text * **Span**: interpolation ![Replace interpolated string with interpolation expression](../../images/refactorings/ReplaceInterpolatedStringWithInterpolationExpression.png) -#### Replace interpolated string with string literal \(RR0136\) - -* **Syntax**: Interpolated string without any interpolation -![Replace interpolated string with string literal](../../images/refactorings/ReplaceInterpolatedStringWithStringLiteral.png) - -#### Replace interpolated string with string\.Format \(RR0201\) - -* **Syntax**: interpolated string - -#### Before - -```csharp -$"name: {name,0:f}, value: {value}" -``` - -#### After - -```csharp -string.Format("name: {0,0:f} value: {1}", name, value) -``` - #### Replace method group with lambda \(RR0137\) * **Syntax**: method group @@ -1970,36 +1975,10 @@ object[] arr = null; * **Span**: property header ![Replace property with method](../../images/refactorings/ReplacePropertyWithMethod.png) -#### Replace regular string literal with verbatim string literal \(RR0142\) - -* **Syntax**: regular string literal -![Replace regular string literal with verbatim string literal](../../images/refactorings/ReplaceRegularStringLiteralWithVerbatimStringLiteral.png) - -#### Replace string\.Format with interpolated string \(RR0145\) - -* **Syntax**: string\.Format method -![Replace string.Format with interpolated string](../../images/refactorings/ReplaceStringFormatWithInterpolatedString.png) - -#### Replace switch with if \(RR0147\) - -* **Syntax**: switch statement -* **Span**: switch keyword -![Replace switch with if](../../images/refactorings/ReplaceSwitchWithIf.png) - -#### Replace verbatim string literal with regular string literal \(RR0148\) - -* **Syntax**: verbatim string literal -![Replace verbatim string literal with regular string literal](../../images/refactorings/ReplaceVerbatimStringLiteralWithRegularStringLiteral.png) - -#### Replace verbatim string literal with regular string literals \(RR0149\) - -* **Syntax**: multiline verbatim string literal -![Replace verbatim string literal with regular string literals](../../images/refactorings/ReplaceVerbatimStringLiteralWithRegularStringLiterals.png) - -#### Reverse for loop \(RR0152\) +#### Reverse 'for' loop \(RR0152\) * **Syntax**: for statement -![Reverse for loop](../../images/refactorings/ReverseForLoop.png) +![Reverse 'for' loop](../../images/refactorings/ReverseForLoop.png) #### Simplify if \(RR0153\) @@ -2232,6 +2211,32 @@ var dic = new Dictionary() { [0] = "0" }; * **Span**: method name ![Use element access instead of 'First/Last'ElementAt' method](../../images/refactorings/UseElementAccessInsteadOfEnumerableMethod.png) +#### Use enumerator explicitly \(RR0206\) + +* **Syntax**: foreach statement +* **Span**: foreach keyword + +#### Before + +```csharp +foreach (var item in items) +{ + yield return item; +} +``` + +#### After + +```csharp +using (var en = items.GetEnumerator()) +{ + while (en.MoveNext()) + { + yield return item; + } +} +``` + #### Use expression\-bodied member \(RR0169\) * **Syntax**: method, property, indexer, operator @@ -2249,11 +2254,6 @@ var dic = new Dictionary() { [0] = "0" }; * **Syntax**: yield return, yield break ![Use List\ instead of yield](../../images/refactorings/UseListInsteadOfYield.png) -#### Use string\.Empty instead of "" \(RR0171\) - -* **Syntax**: empty string literal -![Use string.Empty instead of ""](../../images/refactorings/UseStringEmptyInsteadOfEmptyStringLiteral.png) - #### Use StringBuilder instead of concatenation \(RR0182\) * **Syntax**: string concatenation diff --git a/src/Analyzers.CodeFixes/Analyzers.CodeFixes.csproj b/src/Analyzers.CodeFixes/Analyzers.CodeFixes.csproj index c2d7e6fa89..cf887b984d 100644 --- a/src/Analyzers.CodeFixes/Analyzers.CodeFixes.csproj +++ b/src/Analyzers.CodeFixes/Analyzers.CodeFixes.csproj @@ -5,7 +5,7 @@ - 2.1.3.0 + 2.2.0.0 Roslynator.CSharp.Analyzers.CodeFixes Roslynator.CSharp ..\global.ruleset diff --git a/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec b/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec index c79a64472e..6dab76b6c7 100644 --- a/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec +++ b/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec @@ -2,7 +2,7 @@ Roslynator.Analyzers - 2.1.0 + 2.2.0-rc Josef Pihrt Josef Pihrt Apache-2.0 @@ -13,7 +13,7 @@ - This package cannot be used with Visual Studio 2015. - This package is dependent on Microsoft.CodeAnalysis.CSharp.Workspaces 2.3.0. - A collection of 190+ analyzers for C#, powered by Roslyn. + A collection of 200+ analyzers for C#, powered by Roslyn. Copyright (c) 2016-2019 Josef Pihrt Roslyn Analyzer Refactoring Productivity CodeAnalysis C# CSharp true diff --git a/src/Analyzers/Analyzers.csproj b/src/Analyzers/Analyzers.csproj index 023143a020..f9ad48ba88 100644 --- a/src/Analyzers/Analyzers.csproj +++ b/src/Analyzers/Analyzers.csproj @@ -5,7 +5,7 @@ - 2.1.3.0 + 2.2.0.0 Roslynator.CSharp.Analyzers Roslynator.CSharp ..\global.ruleset diff --git a/src/Analyzers/AnalyzersByCategory.md b/src/Analyzers/AnalyzersByCategory.md index 323f7f6af7..290f700994 100644 --- a/src/Analyzers/AnalyzersByCategory.md +++ b/src/Analyzers/AnalyzersByCategory.md @@ -30,7 +30,7 @@ | Formatting | [Add new line before enum member](../../docs/analyzers/RCS1025.md) | RCS1025 | None | | Formatting | [Add new line before statement](../../docs/analyzers/RCS1026.md) | RCS1026 | None | | Formatting | [Format accessor list](../../docs/analyzers/RCS1024.md) | RCS1024 | None | -| Formatting | [Format binary operator on next line](../../docs/analyzers/RCS1029.md) | RCS1029 | Info | +| Formatting | [Format binary operator on next line](../../docs/analyzers/RCS1029.md) | RCS1029 | None | | Formatting | [Format conditional expression (format ? and : on next line)](../../docs/analyzers/RCS1184.md) | RCS1184 | None | | Formatting | [Format declaration braces](../../docs/analyzers/RCS1076.md) | RCS1076 | Hidden | | Formatting | [Format documentation summary on a single line](../../docs/analyzers/RCS1100.md) | RCS1100 | None | @@ -66,7 +66,7 @@ | Performance | [Optimize StringBuilder.Append/AppendLine call](../../docs/analyzers/RCS1197.md) | RCS1197 | Info | | Performance | [Use bitwise operation instead of calling 'HasFlag'](../../docs/analyzers/RCS1096.md) | RCS1096 | Info | | Performance | [Use 'Count/Length' property instead of 'Any' method](../../docs/analyzers/RCS1080.md) | RCS1080 | Info | -| Readability | [Add default access modifier](../../docs/analyzers/RCS1018.md) | RCS1018 | Info | +| Readability | [Add accessibility modifiers](../../docs/analyzers/RCS1018.md) | RCS1018 | Info | | Readability | [Add or remove region name](../../docs/analyzers/RCS1189.md) | RCS1189 | Hidden | | Readability | [Add parentheses according to operator precedence](../../docs/analyzers/RCS1123.md) | RCS1123 | Info | | Readability | [Add 'static' modifier to all partial class declarations](../../docs/analyzers/RCS1108.md) | RCS1108 | Info | @@ -75,6 +75,7 @@ | Readability | [Avoid nested ?: operators](../../docs/analyzers/RCS1238.md) | RCS1238 | Hidden | | Readability | [Avoid 'null' on the left side of a binary expression](../../docs/analyzers/RCS1098.md) | RCS1098 | Info | | Readability | [Avoid usage of using alias directive](../../docs/analyzers/RCS1056.md) | RCS1056 | None | +| Readability | [Convert interpolated string to concatenation](../../docs/analyzers/RCS1217.md) | RCS1217 | Hidden | | Readability | [Declare each attribute separately](../../docs/analyzers/RCS1052.md) | RCS1052 | None | | Readability | [Declare enum value as combination of names](../../docs/analyzers/RCS1191.md) | RCS1191 | Info | | Readability | [Declare using directive on top level](../../docs/analyzers/RCS1094.md) | RCS1094 | None | @@ -86,7 +87,6 @@ | Readability | [Order modifiers](../../docs/analyzers/RCS1019.md) | RCS1019 | None | | Readability | [Order named arguments according to the order of parameters](../../docs/analyzers/RCS1205.md) | RCS1205 | Info | | Readability | [Order type parameter constraints](../../docs/analyzers/RCS1209.md) | RCS1209 | Info | -| Readability | [Replace interpolated string with concatenation](../../docs/analyzers/RCS1217.md) | RCS1217 | Hidden | | Readability | [Simplify code branching](../../docs/analyzers/RCS1218.md) | RCS1218 | Info | | Readability | [Sort enum members](../../docs/analyzers/RCS1154.md) | RCS1154 | Info | | Readability | [Split variable declaration](../../docs/analyzers/RCS1081.md) | RCS1081 | None | @@ -143,6 +143,8 @@ | Redundancy | [Unused this parameter](../../docs/analyzers/RCS1175.md) | RCS1175 | Info | | Redundancy | [Unused type parameter](../../docs/analyzers/RCS1164.md) | RCS1164 | Info | | Simplification | [Combine 'Enumerable.Where' method chain](../../docs/analyzers/RCS1112.md) | RCS1112 | Info | +| Simplification | [Convert 'if' to assignment](../../docs/analyzers/RCS1103.md) | RCS1103 | Info | +| Simplification | [Convert 'if' to 'return' statement](../../docs/analyzers/RCS1073.md) | RCS1073 | Info | | Simplification | [Inline lazy initialization](../../docs/analyzers/RCS1180.md) | RCS1180 | Info | | Simplification | [Inline local variable](../../docs/analyzers/RCS1124.md) | RCS1124 | Hidden | | Simplification | [Join string expressions](../../docs/analyzers/RCS1190.md) | RCS1190 | Info | @@ -150,8 +152,6 @@ | Simplification | [Merge if statement with nested if statement](../../docs/analyzers/RCS1061.md) | RCS1061 | Hidden | | Simplification | [Merge local declaration with assignment](../../docs/analyzers/RCS1127.md) | RCS1127 | Info | | Simplification | [Merge switch sections with equivalent content](../../docs/analyzers/RCS1136.md) | RCS1136 | Hidden | -| Simplification | [Replace if statement with assignment](../../docs/analyzers/RCS1103.md) | RCS1103 | Info | -| Simplification | [Replace if statement with return statement](../../docs/analyzers/RCS1073.md) | RCS1073 | Info | | Simplification | [Simplify boolean comparison](../../docs/analyzers/RCS1049.md) | RCS1049 | Info | | Simplification | [Simplify boolean expression](../../docs/analyzers/RCS1199.md) | RCS1199 | Info | | Simplification | [Simplify coalesce expression](../../docs/analyzers/RCS1143.md) | RCS1143 | Hidden | diff --git a/src/Analyzers/README.md b/src/Analyzers/README.md index ea28804086..a5e7dd7ee6 100644 --- a/src/Analyzers/README.md +++ b/src/Analyzers/README.md @@ -20,7 +20,7 @@ | RCS1015 | [Use nameof operator](../../docs/analyzers/RCS1015.md) | Maintainability | Info | | RCS1016 | [Use expression-bodied member](../../docs/analyzers/RCS1016.md) | Usage | None | | RCS1017 | [Avoid multiline expression body](../../docs/analyzers/RCS1017.md) | Style | None | -| RCS1018 | [Add default access modifier](../../docs/analyzers/RCS1018.md) | Readability | Info | +| RCS1018 | [Add accessibility modifiers](../../docs/analyzers/RCS1018.md) | Readability | Info | | RCS1019 | [Order modifiers](../../docs/analyzers/RCS1019.md) | Readability | None | | RCS1020 | [Simplify Nullable\ to T?](../../docs/analyzers/RCS1020.md) | Simplification | Info | | RCS1021 | [Simplify lambda expression](../../docs/analyzers/RCS1021.md) | Simplification | Info | @@ -30,7 +30,7 @@ | RCS1026 | [Add new line before statement](../../docs/analyzers/RCS1026.md) | Formatting | None | | RCS1027 | [Add new line before embedded statement](../../docs/analyzers/RCS1027.md) | Formatting | None | | RCS1028 | [Add new line after switch label](../../docs/analyzers/RCS1028.md) | Formatting | None | -| RCS1029 | [Format binary operator on next line](../../docs/analyzers/RCS1029.md) | Formatting | Info | +| RCS1029 | [Format binary operator on next line](../../docs/analyzers/RCS1029.md) | Formatting | None | | RCS1030 | [Add empty line after embedded statement](../../docs/analyzers/RCS1030.md) | Formatting | None | | RCS1031 | [Remove unnecessary braces](../../docs/analyzers/RCS1031.md) | Redundancy | Hidden | | RCS1032 | [Remove redundant parentheses](../../docs/analyzers/RCS1032.md) | Redundancy | Info | @@ -72,7 +72,7 @@ | RCS1070 | [Remove redundant default switch section](../../docs/analyzers/RCS1070.md) | Redundancy | Hidden | | RCS1071 | [Remove redundant base constructor call](../../docs/analyzers/RCS1071.md) | Redundancy | Hidden | | RCS1072 | [Remove empty namespace declaration](../../docs/analyzers/RCS1072.md) | Redundancy | Info | -| RCS1073 | [Replace if statement with return statement](../../docs/analyzers/RCS1073.md) | Simplification | Info | +| RCS1073 | [Convert 'if' to 'return' statement](../../docs/analyzers/RCS1073.md) | Simplification | Info | | RCS1074 | [Remove redundant constructor](../../docs/analyzers/RCS1074.md) | Redundancy | Hidden | | RCS1075 | [Avoid empty catch clause that catches System.Exception](../../docs/analyzers/RCS1075.md) | Design | Warning | | RCS1076 | [Format declaration braces](../../docs/analyzers/RCS1076.md) | Formatting | Hidden | @@ -99,7 +99,7 @@ | RCS1100 | [Format documentation summary on a single line](../../docs/analyzers/RCS1100.md) | Formatting | None | | RCS1101 | [Format documentation summary on multiple lines](../../docs/analyzers/RCS1101.md) | Formatting | None | | RCS1102 | [Make class static](../../docs/analyzers/RCS1102.md) | Design | Warning | -| RCS1103 | [Replace if statement with assignment](../../docs/analyzers/RCS1103.md) | Simplification | Info | +| RCS1103 | [Convert 'if' to assignment](../../docs/analyzers/RCS1103.md) | Simplification | Info | | RCS1104 | [Simplify conditional expression](../../docs/analyzers/RCS1104.md) | Simplification | Info | | RCS1105 | [Unncessary interpolation](../../docs/analyzers/RCS1105.md) | Simplification | Info | | RCS1106 | [Remove empty destructor](../../docs/analyzers/RCS1106.md) | Redundancy | Info | @@ -194,7 +194,7 @@ | RCS1214 | [Unnecessary interpolated string](../../docs/analyzers/RCS1214.md) | Simplification | Info | | RCS1215 | [Expression is always equal to true/false](../../docs/analyzers/RCS1215.md) | Redundancy | Warning | | RCS1216 | [Unnecessary unsafe context](../../docs/analyzers/RCS1216.md) | Redundancy | Info | -| RCS1217 | [Replace interpolated string with concatenation](../../docs/analyzers/RCS1217.md) | Readability | Hidden | +| RCS1217 | [Convert interpolated string to concatenation](../../docs/analyzers/RCS1217.md) | Readability | Hidden | | RCS1218 | [Simplify code branching](../../docs/analyzers/RCS1218.md) | Readability | Info | | RCS1219 | [Call 'Enumerable.Skip' and 'Enumerable.Any' instead of 'Enumerable.Count'](../../docs/analyzers/RCS1219.md) | Performance | None | | RCS1220 | [Use pattern matching instead of combination of 'is' operator and cast operator](../../docs/analyzers/RCS1220.md) | Usage | Info | diff --git a/src/CSharp.Workspaces/CSharp.Workspaces.csproj b/src/CSharp.Workspaces/CSharp.Workspaces.csproj index a2dffe7055..0d41827b58 100644 --- a/src/CSharp.Workspaces/CSharp.Workspaces.csproj +++ b/src/CSharp.Workspaces/CSharp.Workspaces.csproj @@ -5,7 +5,7 @@ - 1.0.0.15 + 1.0.0.16 Roslynator.CSharp.Workspaces Roslynator ..\api.ruleset diff --git a/src/CSharp/CSharp.csproj b/src/CSharp/CSharp.csproj index 0690f002e1..1e2be18742 100644 --- a/src/CSharp/CSharp.csproj +++ b/src/CSharp/CSharp.csproj @@ -5,7 +5,7 @@ - 1.0.0.15 + 1.0.0.16 Roslynator.CSharp Roslynator ..\api.ruleset diff --git a/src/CodeFixes/CodeFixes.csproj b/src/CodeFixes/CodeFixes.csproj index 4e9b58a403..95f2659b37 100644 --- a/src/CodeFixes/CodeFixes.csproj +++ b/src/CodeFixes/CodeFixes.csproj @@ -5,7 +5,7 @@ - 2.1.3.0 + 2.2.0.0 Roslynator.CSharp.CodeFixes Roslynator.CSharp.CodeFixes ..\global.ruleset diff --git a/src/Common/Common.csproj b/src/Common/Common.csproj index a88aab248b..43b5b55cb4 100644 --- a/src/Common/Common.csproj +++ b/src/Common/Common.csproj @@ -5,7 +5,7 @@ - 2.1.3.0 + 2.2.0.0 Roslynator.Common Roslynator ..\global.ruleset diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj index fdaaa39aeb..a2f82fcf4f 100644 --- a/src/Core/Core.csproj +++ b/src/Core/Core.csproj @@ -5,7 +5,7 @@ - 1.0.0.15 + 1.0.0.16 Roslynator.Core Roslynator ..\api.ruleset diff --git a/src/DefaultConfigFile.xml b/src/DefaultConfigFile.xml index 9032203ed9..1edd4f8926 100644 --- a/src/DefaultConfigFile.xml +++ b/src/DefaultConfigFile.xml @@ -122,35 +122,35 @@ - + - - - - - + + + + + - + - - + + - - - - + + + + - + @@ -169,7 +169,7 @@ - + @@ -186,12 +186,12 @@ - + - + @@ -199,12 +199,12 @@ - + - + diff --git a/src/Refactorings/README.md b/src/Refactorings/README.md index 5f5079d097..0863790667 100644 --- a/src/Refactorings/README.md +++ b/src/Refactorings/README.md @@ -36,10 +36,27 @@ | RR0026 | [Collapse to initalizer](../../docs/refactorings/RR0026.md) | ✓ | | RR0027 | [Comment out member](../../docs/refactorings/RR0027.md) | ✓ | | RR0028 | [Comment out statement](../../docs/refactorings/RR0028.md) | ✓ | +| RR0171 | [Convert "" to string.Empty](../../docs/refactorings/RR0171.md) | \- | +| RR0143 | [Convert '(yield) return' to 'if'](../../docs/refactorings/RR0143.md) | ✓ | | RR0120 | [Convert ?: to if-else](../../docs/refactorings/RR0120.md) | ✓ | | RR0192 | [Convert comment to documentation comment](../../docs/refactorings/RR0192.md) | ✓ | +| RR0123 | [Convert 'do' to 'while'](../../docs/refactorings/RR0123.md) | ✓ | +| RR0130 | [Convert 'for' to 'foreach'](../../docs/refactorings/RR0130.md) | ✓ | +| RR0131 | [Convert 'for' to 'while'](../../docs/refactorings/RR0131.md) | ✓ | +| RR0129 | [Convert 'foreach' to 'for'](../../docs/refactorings/RR0129.md) | ✓ | +| RR0188 | [Convert 'foreach' to 'for' and reverse loop](../../docs/refactorings/RR0188.md) | \- | +| RR0132 | [Convert hexadecimal literal to decimal literal](../../docs/refactorings/RR0132.md) | ✓ | | RR0166 | [Convert 'if' to ?:](../../docs/refactorings/RR0166.md) | ✓ | +| RR0133 | [Convert 'if' to 'switch'](../../docs/refactorings/RR0133.md) | ✓ | +| RR0193 | [Convert interpolated string to concatenation](../../docs/refactorings/RR0193.md) | ✓ | +| RR0136 | [Convert interpolated string to string literal](../../docs/refactorings/RR0136.md) | ✓ | +| RR0201 | [Convert interpolated string to 'string.Format'](../../docs/refactorings/RR0201.md) | ✓ | +| RR0142 | [Convert regular string literal to verbatim string literal](../../docs/refactorings/RR0142.md) | ✓ | | RR0211 | [Convert statements to if-else](../../docs/refactorings/RR0211.md) | ✓ | +| RR0145 | [Convert 'string.Format' to interpolated string](../../docs/refactorings/RR0145.md) | ✓ | +| RR0147 | [Convert 'switch to 'if'](../../docs/refactorings/RR0147.md) | ✓ | +| RR0148 | [Convert verbatim string literal to regular string literal](../../docs/refactorings/RR0148.md) | ✓ | +| RR0149 | [Convert verbatim string literal to regular string literals](../../docs/refactorings/RR0149.md) | ✓ | | RR0150 | [Convert 'while' statement to 'do' statement](../../docs/refactorings/RR0150.md) | ✓ | | RR0151 | [Convert 'while' statement to 'for' statement](../../docs/refactorings/RR0151.md) | ✓ | | RR0029 | [Copy documentation comment from base member](../../docs/refactorings/RR0029.md) | ✓ | @@ -61,7 +78,6 @@ | RR0044 | [Extract generic type](../../docs/refactorings/RR0044.md) | ✓ | | RR0045 | [Extract statement(s)](../../docs/refactorings/RR0045.md) | ✓ | | RR0046 | [Extract type declaration to a new file](../../docs/refactorings/RR0046.md) | ✓ | -| RR0047 | [Format accessor braces](../../docs/refactorings/RR0047.md) | ✓ | | RR0048 | [Format argument list](../../docs/refactorings/RR0048.md) | ✓ | | RR0049 | [Format binary expression](../../docs/refactorings/RR0049.md) | ✓ | | RR0050 | [Format conditional expression](../../docs/refactorings/RR0050.md) | ✓ | @@ -144,38 +160,21 @@ | RR0113 | [Rename method according to type name](../../docs/refactorings/RR0113.md) | ✓ | | RR0114 | [Rename parameter according to its type name](../../docs/refactorings/RR0114.md) | ✓ | | RR0115 | [Rename property according to type name](../../docs/refactorings/RR0115.md) | ✓ | -| RR0143 | [Replace (yield) return statement with if-else](../../docs/refactorings/RR0143.md) | ✓ | | RR0117 | [Replace as expression with cast expression](../../docs/refactorings/RR0117.md) | ✓ | | RR0118 | [Replace cast expression with as expression](../../docs/refactorings/RR0118.md) | ✓ | | RR0119 | [Replace conditional expression with expression](../../docs/refactorings/RR0119.md) | ✓ | | RR0121 | [Replace constant with field](../../docs/refactorings/RR0121.md) | ✓ | -| RR0123 | [Replace do statement with while statement](../../docs/refactorings/RR0123.md) | ✓ | | RR0124 | [Replace equals expression with string.Equals](../../docs/refactorings/RR0124.md) | ✓ | | RR0125 | [Replace equals expression with string.IsNullOrEmpty](../../docs/refactorings/RR0125.md) | ✓ | | RR0126 | [Replace equals expression with string.IsNullOrWhiteSpace](../../docs/refactorings/RR0126.md) | ✓ | -| RR0130 | [Replace for statement with foreach statement](../../docs/refactorings/RR0130.md) | ✓ | -| RR0131 | [Replace for statement with while statement](../../docs/refactorings/RR0131.md) | ✓ | -| RR0129 | [Replace foreach statement with for statement](../../docs/refactorings/RR0129.md) | ✓ | -| RR0206 | [Replace foreach with enumerator](../../docs/refactorings/RR0206.md) | ✓ | -| RR0188 | [Replace foreach with for and reverse loop](../../docs/refactorings/RR0188.md) | \- | -| RR0132 | [Replace hexadecimal literal with decimal literal](../../docs/refactorings/RR0132.md) | ✓ | -| RR0133 | [Replace if with switch](../../docs/refactorings/RR0133.md) | ✓ | -| RR0193 | [Replace interpolated string with concatenation](../../docs/refactorings/RR0193.md) | ✓ | | RR0135 | [Replace interpolated string with interpolation expression](../../docs/refactorings/RR0135.md) | ✓ | -| RR0136 | [Replace interpolated string with string literal](../../docs/refactorings/RR0136.md) | ✓ | -| RR0201 | [Replace interpolated string with string.Format](../../docs/refactorings/RR0201.md) | ✓ | | RR0137 | [Replace method group with lambda](../../docs/refactorings/RR0137.md) | ✓ | | RR0138 | [Replace method with property](../../docs/refactorings/RR0138.md) | \- | | RR0139 | [Replace null literal expression with default expression](../../docs/refactorings/RR0139.md) | ✓ | | RR0185 | [Replace object creation with default value](../../docs/refactorings/RR0185.md) | ✓ | | RR0140 | [Replace prefix operator to postfix operator](../../docs/refactorings/RR0140.md) | ✓ | | RR0141 | [Replace property with method](../../docs/refactorings/RR0141.md) | ✓ | -| RR0142 | [Replace regular string literal with verbatim string literal](../../docs/refactorings/RR0142.md) | ✓ | -| RR0145 | [Replace string.Format with interpolated string](../../docs/refactorings/RR0145.md) | ✓ | -| RR0147 | [Replace switch with if](../../docs/refactorings/RR0147.md) | ✓ | -| RR0148 | [Replace verbatim string literal with regular string literal](../../docs/refactorings/RR0148.md) | ✓ | -| RR0149 | [Replace verbatim string literal with regular string literals](../../docs/refactorings/RR0149.md) | ✓ | -| RR0152 | [Reverse for loop](../../docs/refactorings/RR0152.md) | ✓ | +| RR0152 | [Reverse 'for' loop](../../docs/refactorings/RR0152.md) | ✓ | | RR0153 | [Simplify if](../../docs/refactorings/RR0153.md) | ✓ | | RR0154 | [Simplify lambda expression](../../docs/refactorings/RR0154.md) | ✓ | | RR0207 | [Sort case labels](../../docs/refactorings/RR0207.md) | ✓ | @@ -196,10 +195,10 @@ | RR0165 | [Use coalesce expression instead of if](../../docs/refactorings/RR0165.md) | ✓ | | RR0128 | [Use constant instead of field](../../docs/refactorings/RR0128.md) | ✓ | | RR0167 | [Use element access instead of 'First/Last'ElementAt' method](../../docs/refactorings/RR0167.md) | ✓ | +| RR0206 | [Use enumerator explicitly](../../docs/refactorings/RR0206.md) | ✓ | | RR0169 | [Use expression-bodied member](../../docs/refactorings/RR0169.md) | ✓ | | RR0170 | [Use lambda expression instead of anonymous method](../../docs/refactorings/RR0170.md) | ✓ | | RR0183 | [Use List\ instead of yield](../../docs/refactorings/RR0183.md) | ✓ | -| RR0171 | [Use string.Empty instead of ""](../../docs/refactorings/RR0171.md) | \- | | RR0182 | [Use StringBuilder instead of concatenation](../../docs/refactorings/RR0182.md) | ✓ | | RR0174 | [Wrap in #if directive](../../docs/refactorings/RR0174.md) | ✓ | | RR0172 | [Wrap in condition](../../docs/refactorings/RR0172.md) | ✓ | diff --git a/src/Refactorings/Refactorings.csproj b/src/Refactorings/Refactorings.csproj index ae9f345236..f4e615df58 100644 --- a/src/Refactorings/Refactorings.csproj +++ b/src/Refactorings/Refactorings.csproj @@ -5,7 +5,7 @@ - 2.1.3.0 + 2.2.0.0 Roslynator.CSharp.Refactorings Roslynator.CSharp.Refactorings ..\global.ruleset diff --git a/src/Tools/MetadataGenerator/Program.cs b/src/Tools/MetadataGenerator/Program.cs index 55de102a13..0b4210f015 100644 --- a/src/Tools/MetadataGenerator/Program.cs +++ b/src/Tools/MetadataGenerator/Program.cs @@ -78,7 +78,7 @@ private static async Task Main(string[] args) MetadataFile.SaveSourceFiles(sourceFiles, @"..\SourceFiles.xml"); } #endif - foreach (AnalyzerMetadata analyzer in analyzers.Concat(codeAnalysisAnalyzers)) + foreach (AnalyzerMetadata analyzer in codeAnalysisAnalyzers) { WriteAllText( $@"..\docs\analyzers\{analyzer.Id}.md", diff --git a/src/VisualBasic.Workspaces/VisualBasic.Workspaces.csproj b/src/VisualBasic.Workspaces/VisualBasic.Workspaces.csproj index 0ea9ece2bf..5c667dba9c 100644 --- a/src/VisualBasic.Workspaces/VisualBasic.Workspaces.csproj +++ b/src/VisualBasic.Workspaces/VisualBasic.Workspaces.csproj @@ -5,7 +5,7 @@ - 1.0.0.15 + 1.0.0.16 Roslynator.VisualBasic.Workspaces Roslynator ..\api.ruleset diff --git a/src/VisualBasic/VisualBasic.csproj b/src/VisualBasic/VisualBasic.csproj index 3876317154..b60703ed2f 100644 --- a/src/VisualBasic/VisualBasic.csproj +++ b/src/VisualBasic/VisualBasic.csproj @@ -5,7 +5,7 @@ - 1.0.0.15 + 1.0.0.16 Roslynator.VisualBasic Roslynator ..\api.ruleset diff --git a/src/VisualStudio.Common/Properties/AssemblyInfo.cs b/src/VisualStudio.Common/Properties/AssemblyInfo.cs index 9e4f7f5dd2..7139ff437b 100644 --- a/src/VisualStudio.Common/Properties/AssemblyInfo.cs +++ b/src/VisualStudio.Common/Properties/AssemblyInfo.cs @@ -36,5 +36,5 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.1.3.0")] +[assembly: AssemblyVersion("2.2.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/VisualStudio.Refactorings/Properties/AssemblyInfo.cs b/src/VisualStudio.Refactorings/Properties/AssemblyInfo.cs index b1f25d3304..7e47dae449 100644 --- a/src/VisualStudio.Refactorings/Properties/AssemblyInfo.cs +++ b/src/VisualStudio.Refactorings/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ // Build Number // Revision // -[assembly: AssemblyVersion("2.1.3.0")] +[assembly: AssemblyVersion("2.2.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: NeutralResourcesLanguage("en-US")] diff --git a/src/VisualStudio.Refactorings/source.extension.vsixmanifest b/src/VisualStudio.Refactorings/source.extension.vsixmanifest index e1358dc0bf..83a0b230df 100644 --- a/src/VisualStudio.Refactorings/source.extension.vsixmanifest +++ b/src/VisualStudio.Refactorings/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + Roslynator Refactorings 2017 A collection of 300+ refactorings and fixes for C#, powered by Roslyn. http://github.com/JosefPihrt/Roslynator diff --git a/src/VisualStudio/Properties/AssemblyInfo.cs b/src/VisualStudio/Properties/AssemblyInfo.cs index 6d7d28b42b..01b003b89d 100644 --- a/src/VisualStudio/Properties/AssemblyInfo.cs +++ b/src/VisualStudio/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ // Build Number // Revision // -[assembly: AssemblyVersion("2.1.3.0")] +[assembly: AssemblyVersion("2.2.0.0")] //[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: NeutralResourcesLanguage("en-US")] diff --git a/src/VisualStudio/source.extension.vsixmanifest b/src/VisualStudio/source.extension.vsixmanifest index a87a8ad51b..fde3a735ba 100644 --- a/src/VisualStudio/source.extension.vsixmanifest +++ b/src/VisualStudio/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + Roslynator 2017 A collection of 500+ analyzers, refactorings and fixes for C#, powered by Roslyn. http://github.com/JosefPihrt/Roslynator diff --git a/src/Workspaces.Common/Workspaces.Common.csproj b/src/Workspaces.Common/Workspaces.Common.csproj index 931e1fddc4..1d6d332697 100644 --- a/src/Workspaces.Common/Workspaces.Common.csproj +++ b/src/Workspaces.Common/Workspaces.Common.csproj @@ -5,7 +5,7 @@ - 2.1.3.0 + 2.2.0.0 Roslynator.Workspaces.Common Roslynator ..\global.ruleset diff --git a/src/Workspaces.Core/Workspaces.Core.csproj b/src/Workspaces.Core/Workspaces.Core.csproj index e3797ce708..a0fbe784e7 100644 --- a/src/Workspaces.Core/Workspaces.Core.csproj +++ b/src/Workspaces.Core/Workspaces.Core.csproj @@ -5,7 +5,7 @@ - 1.0.0.15 + 1.0.0.16 Roslynator.Workspaces.Core Roslynator ..\api.ruleset diff --git a/src/default.ruleset b/src/default.ruleset index a525e0a10d..771435e0d7 100644 --- a/src/default.ruleset +++ b/src/default.ruleset @@ -17,7 +17,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -102,7 +102,7 @@ - + @@ -216,7 +216,7 @@ - + diff --git a/tools/build.cmd b/tools/build.cmd index 82b1a00733..a5639864c4 100644 --- a/tools/build.cmd +++ b/tools/build.cmd @@ -2,8 +2,8 @@ set _msbuildPath="C:\Program Files\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild" set _properties=Configuration=Release,Deterministic=true,TreatWarningsAsErrors=true,WarningsNotAsErrors=1591 -set _version=2.1.3.0 -set _apiVersion=1.0.0.15 +set _version=2.2.0.0 +set _apiVersion=1.0.0.16 dotnet restore --force "..\src\Roslynator.sln"