From 2e882b7270608c0b773596f13edcddeccbf4787f Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Tue, 29 Mar 2022 22:59:50 +0200 Subject: [PATCH] Update version to 4.1.0 --- ChangeLog.md | 21 +++--- docs/analyzers/RCS0059.md | 12 ++-- docs/analyzers/RCS1031.md | 2 +- docs/analyzers/RCS1063.md | 2 +- docs/analyzers/RCS1064.md | 2 +- docs/analyzers/RCS1065.md | 2 +- docs/analyzers/RCS1100.md | 2 +- docs/analyzers/RCS1101.md | 2 +- docs/analyzers/RCS1237.md | 2 +- docs/analyzers/RCS1251.md | 25 ++++++++ docs/analyzers/RCS1252.md | 18 ++++++ docs/analyzers/RCS1253.md | 22 +++++++ docs/analyzers/RCS1254.md | 18 ++++++ docs/api.txt | 15 +++-- docs/api/Roslynator/CSharp/README.md | 2 +- .../MemberDeclarationListInfo/README.md | 18 ++++++ .../Roslynator/CSharp/SyntaxInfo/README.md | 1 + .../CSharp/SyntaxInverter/README.md | 3 + docs/cs/CS8602.md | 13 ++++ docs/cs/CS8604.md | 13 ++++ docs/refactorings/RR0194.md | 18 +++--- docs/refactorings/RR0217.md | 45 +++++++++++++ docs/refactorings/Refactorings.md | 64 +++++++++++++------ src/Analyzers/README.md | 18 ++++-- src/CodeFixes/README.md | 2 + src/CommandLine/ChangeLog.md | 4 ++ src/Directory.Build.props | 24 +++---- src/Refactorings/README.md | 2 + src/Tools/MetadataGenerator/Program.cs | 2 +- src/VisualStudio/Properties/AssemblyInfo.cs | 2 +- .../source.extension.vsixmanifest | 2 +- src/VisualStudioCode/package/CHANGELOG.md | 16 +++++ .../package/package-lock.json | 4 +- src/VisualStudioCode/package/package.json | 2 +- tools/build.cmd | 4 +- tools/build_vscode.cmd | 2 +- 36 files changed, 322 insertions(+), 84 deletions(-) create mode 100644 docs/analyzers/RCS1251.md create mode 100644 docs/analyzers/RCS1252.md create mode 100644 docs/analyzers/RCS1253.md create mode 100644 docs/analyzers/RCS1254.md create mode 100644 docs/cs/CS8602.md create mode 100644 docs/cs/CS8604.md create mode 100644 docs/refactorings/RR0217.md diff --git a/ChangeLog.md b/ChangeLog.md index cb24f56a0e..5df5487998 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,15 +1,20 @@ ### Unreleased -* Add analyzer NormalizeFormatOfEnumFlagValue (RCS1254) -* Add analyzer FormatDocumentationCommentSummary (RCS1253) -* Add analyzer NormalizeUsageOfInfiniteLoop (RCS1252) -* Add analyzer RemoveUnnecessaryBraces (RCS1251) -* Call AddRange instead of Add (RCS1235) +### 4.1.0 (2022-03-29) + +* Add analyzer [RCS1254](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1254.md) (Normalize format of enum flag value) +* Add analyzer [RCS1253](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1253.md) (Format documentation comment summary) +* Add analyzer [RCS1252](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1252.md) (Normalize usage of infinite loop) +* Add analyzer [RCS1251](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1251.md) (Remove unnecessary braces from record declaration) +* Add refactoring [Deconstruct foreach variable (RR0217)](https://github.com/JosefPihrt/Roslynator/blob/master/docs/refactoring/RR0217.md) * Add code fix for CS8602, CS8604 -* Fix code fix for CS0225 -* Put back refactoring SplitLocalDeclarationAndAssignment (RR0194) ([issue](https://github.com/JosefPihrt/Roslynator/issues/881)) +* Add suggestion to call AddRange instead of Add (RCS1235) +* Put back refactoring "Split local declaration and assignment" (RR0194) ([issue](https://github.com/JosefPihrt/Roslynator/issues/881)) +* Adopt activation events in VS Code extension ([issue](https://github.com/JosefPihrt/Roslynator/issues/883)) (thanks to [ProphetLamb](https://github.com/ProphetLamb)) * Fix: Get config value from global AnalyzerConfig if available ([issue](https://github.com/JosefPihrt/Roslynator/issues/884)) -* Add refactoring [Deconstruct foreach variable (RR0217)](https://github.com/JosefPihrt/Roslynator/blob/master/docs/refactoring/RR0217.md) +* Fix: Do not suggest using null-forgiving operator for parameter default value (CS8625) +* Fix: Check if equality operator is overloaded (RCS1171) +* Fix: Do not remove field initialization in struct with constructor(s) (RCS1129) ### 4.0.3 (2022-01-29) diff --git a/docs/analyzers/RCS0059.md b/docs/analyzers/RCS0059.md index ecd47a91eb..90cf72da44 100644 --- a/docs/analyzers/RCS0059.md +++ b/docs/analyzers/RCS0059.md @@ -13,9 +13,9 @@ ```csharp items .Select(selector) - .FirstOrDefault() - ?.ToString() - + .FirstOrDefault() + ?.ToString() + ``` ### Code with Fix @@ -23,9 +23,9 @@ items ```csharp items .Select(selector) - .FirstOrDefault()? - .ToString() - + .FirstOrDefault()? + .ToString() + ``` ## Options diff --git a/docs/analyzers/RCS1031.md b/docs/analyzers/RCS1031.md index 110210cb7a..5c04450d2e 100644 --- a/docs/analyzers/RCS1031.md +++ b/docs/analyzers/RCS1031.md @@ -1,4 +1,4 @@ -# RCS1031: Remove unnecessary braces +# RCS1031: Remove unnecessary braces in switch section | Property | Value | | -------- | ------- | diff --git a/docs/analyzers/RCS1063.md b/docs/analyzers/RCS1063.md index 4ed35b56b8..bcd8c759ea 100644 --- a/docs/analyzers/RCS1063.md +++ b/docs/analyzers/RCS1063.md @@ -1,4 +1,4 @@ -# RCS1063: Avoid usage of do statement to create an infinite loop +# RCS1063: \(\[deprecated\] use RCS1252 instead\) Avoid usage of do statement to create an infinite loop | Property | Value | | -------- | ------- | diff --git a/docs/analyzers/RCS1064.md b/docs/analyzers/RCS1064.md index ee0b534963..185d5852e2 100644 --- a/docs/analyzers/RCS1064.md +++ b/docs/analyzers/RCS1064.md @@ -1,4 +1,4 @@ -# RCS1064: Avoid usage of for statement to create an infinite loop +# RCS1064: \(\[deprecated\] use RCS1252 instead\) Avoid usage of for statement to create an infinite loop | Property | Value | | -------- | ------- | diff --git a/docs/analyzers/RCS1065.md b/docs/analyzers/RCS1065.md index 7287c78a5f..b3a39c8c62 100644 --- a/docs/analyzers/RCS1065.md +++ b/docs/analyzers/RCS1065.md @@ -1,4 +1,4 @@ -# RCS1065: Avoid usage of while statement to create an infinite loop +# RCS1065: \(\[deprecated\] use RCS1252 instead\) Avoid usage of while statement to create an infinite loop | Property | Value | | -------- | ------- | diff --git a/docs/analyzers/RCS1100.md b/docs/analyzers/RCS1100.md index e481edd0c9..8f5980304d 100644 --- a/docs/analyzers/RCS1100.md +++ b/docs/analyzers/RCS1100.md @@ -1,4 +1,4 @@ -# RCS1100: Format documentation summary on a single line +# RCS1100: \(\[deprecated\] use RCS1253 instead\) Format documentation summary on a single line | Property | Value | | -------- | ------- | diff --git a/docs/analyzers/RCS1101.md b/docs/analyzers/RCS1101.md index b181aef717..a5fb1fe0e9 100644 --- a/docs/analyzers/RCS1101.md +++ b/docs/analyzers/RCS1101.md @@ -1,4 +1,4 @@ -# RCS1101: Format documentation summary on multiple lines +# RCS1101: \(\[deprecated\] use RCS1253 instead\) Format documentation summary on multiple lines | Property | Value | | -------- | ------- | diff --git a/docs/analyzers/RCS1237.md b/docs/analyzers/RCS1237.md index 70ca212f4a..c8034c6600 100644 --- a/docs/analyzers/RCS1237.md +++ b/docs/analyzers/RCS1237.md @@ -1,4 +1,4 @@ -# RCS1237: Use bit shift operator +# RCS1237: \(\[deprecated\] use RCS1254 instead\) Use bit shift operator | Property | Value | | -------- | ------- | diff --git a/docs/analyzers/RCS1251.md b/docs/analyzers/RCS1251.md new file mode 100644 index 0000000000..992e76b60d --- /dev/null +++ b/docs/analyzers/RCS1251.md @@ -0,0 +1,25 @@ +# RCS1251: Remove unnecessary braces from record declaration + +| Property | Value | +| -------- | ------- | +| Id | RCS1251 | +| Severity | Info | + +## Example + +### Code with Diagnostic + +```csharp +public record Foo(string Value1, string Value2) +{ +} +``` + +### Code with Fix + +```csharp +public record Foo(string Value1, string Value2); +``` + + +*\(Generated with [DotMarkdown](http://github.com/JosefPihrt/DotMarkdown)\)* \ No newline at end of file diff --git a/docs/analyzers/RCS1252.md b/docs/analyzers/RCS1252.md new file mode 100644 index 0000000000..088bf52f90 --- /dev/null +++ b/docs/analyzers/RCS1252.md @@ -0,0 +1,18 @@ +# RCS1252: Normalize usage of infinite loop + +| Property | Value | +| --------------- | -------------------------------- | +| Id | RCS1252 | +| Severity | None | +| Required option | `roslynator_infinite_loop_style` | + +## Options + +### Use 'for'/'while' statement as an infinite loop + +```editorconfig +roslynator_infinite_loop_style = for|while +``` + + +*\(Generated with [DotMarkdown](http://github.com/JosefPihrt/DotMarkdown)\)* \ No newline at end of file diff --git a/docs/analyzers/RCS1253.md b/docs/analyzers/RCS1253.md new file mode 100644 index 0000000000..ab4e153dee --- /dev/null +++ b/docs/analyzers/RCS1253.md @@ -0,0 +1,22 @@ +# RCS1253: Format documentation comment summary + +| Property | Value | +| --------------- | -------------------------------------- | +| Id | RCS1253 | +| Severity | None | +| Required option | `roslynator_doc_comment_summary_style` | + +## Summary + +This analyzer replaces RCS1100 and RCS1101. + +## Options + +### Format documentation comment summary on single line or multiple lines + +```editorconfig +roslynator_doc_comment_summary_style = multi_line|single_line +``` + + +*\(Generated with [DotMarkdown](http://github.com/JosefPihrt/DotMarkdown)\)* \ No newline at end of file diff --git a/docs/analyzers/RCS1254.md b/docs/analyzers/RCS1254.md new file mode 100644 index 0000000000..8bfa73e5e1 --- /dev/null +++ b/docs/analyzers/RCS1254.md @@ -0,0 +1,18 @@ +# RCS1254: Normalize format of enum flag value + +| Property | Value | +| --------------- | ---------------------------------- | +| Id | RCS1254 | +| Severity | Info | +| Required option | `roslynator_enum_flag_value_style` | + +## Options + +### Format enum flag value as decimal number or as a shift operator + +```editorconfig +roslynator_enum_flag_value_style = decimal_number|shift_operator +``` + + +*\(Generated with [DotMarkdown](http://github.com/JosefPihrt/DotMarkdown)\)* \ No newline at end of file diff --git a/docs/api.txt b/docs/api.txt index c09bc1b4f9..fd1dc4a7a7 100644 --- a/docs/api.txt +++ b/docs/api.txt @@ -1,10 +1,10 @@ -assembly Roslynator.Core, Version=2.2.0.1, Culture=neutral, PublicKeyToken=926ea54d246a765e -assembly Roslynator.CSharp, Version=2.2.0.1, Culture=neutral, PublicKeyToken=926ea54d246a765e -assembly Roslynator.CSharp.Workspaces, Version=2.2.0.1, Culture=neutral, PublicKeyToken=926ea54d246a765e -assembly Roslynator.Testing.Common, Version=1.0.0.1, Culture=neutral, PublicKeyToken=926ea54d246a765e -assembly Roslynator.Testing.CSharp, Version=1.0.0.1, Culture=neutral, PublicKeyToken=926ea54d246a765e -assembly Roslynator.Testing.CSharp.Xunit, Version=1.0.0.1, Culture=neutral, PublicKeyToken=926ea54d246a765e -assembly Roslynator.Workspaces.Core, Version=2.2.0.1, Culture=neutral, PublicKeyToken=926ea54d246a765e +assembly Roslynator.Core, Version=4.1.0.0, Culture=neutral, PublicKeyToken=926ea54d246a765e +assembly Roslynator.CSharp, Version=4.1.0.0, Culture=neutral, PublicKeyToken=926ea54d246a765e +assembly Roslynator.CSharp.Workspaces, Version=4.1.0.0, Culture=neutral, PublicKeyToken=926ea54d246a765e +assembly Roslynator.Testing.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=926ea54d246a765e +assembly Roslynator.Testing.CSharp, Version=4.1.0.0, Culture=neutral, PublicKeyToken=926ea54d246a765e +assembly Roslynator.Testing.CSharp.Xunit, Version=4.1.0.0, Culture=neutral, PublicKeyToken=926ea54d246a765e +assembly Roslynator.Workspaces.Core, Version=4.1.0.0, Culture=neutral, PublicKeyToken=926ea54d246a765e namespace Roslynator @@ -971,6 +971,7 @@ namespace Roslynator.CSharp public static LocalDeclarationStatementInfo LocalDeclarationStatementInfo(ExpressionSyntax value, bool allowMissing = false); public static MemberDeclarationListInfo MemberDeclarationListInfo(CompilationUnitSyntax compilationUnit); public static MemberDeclarationListInfo MemberDeclarationListInfo(NamespaceDeclarationSyntax declaration); + public static MemberDeclarationListInfo MemberDeclarationListInfo(BaseNamespaceDeclarationSyntax declaration); public static MemberDeclarationListInfo MemberDeclarationListInfo(TypeDeclarationSyntax declaration); public static MemberDeclarationListInfo MemberDeclarationListInfo(ClassDeclarationSyntax declaration); public static MemberDeclarationListInfo MemberDeclarationListInfo(StructDeclarationSyntax declaration); diff --git a/docs/api/Roslynator/CSharp/README.md b/docs/api/Roslynator/CSharp/README.md index 204c1f5f7c..ce8bed83d0 100644 --- a/docs/api/Roslynator/CSharp/README.md +++ b/docs/api/Roslynator/CSharp/README.md @@ -20,7 +20,7 @@ | [SyntaxAccessibility](SyntaxAccessibility/README.md) | A set of static methods that are related to C\# accessibility\. | | [SyntaxExtensions](SyntaxExtensions/README.md) | A set of extension methods for syntax \(types derived from [CSharpSyntaxNode](https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.csharp.csharpsyntaxnode)\)\. | | [SyntaxInfo](SyntaxInfo/README.md) | Serves as a factory for types in Roslynator\.CSharp\.Syntax namespace\. | -| [SyntaxInverter](SyntaxInverter/README.md) | \[deprecated\] | +| [SyntaxInverter](SyntaxInverter/README.md) | \[deprecated\] Provides static methods for syntax inversion\. | | [SyntaxLogicalInverter](SyntaxLogicalInverter/README.md) | Provides static methods for syntax inversion\. | | [SyntaxLogicalInverterOptions](SyntaxLogicalInverterOptions/README.md) | | | [WorkspaceExtensions](WorkspaceExtensions/README.md) | A set of extension methods for the workspace layer\. | diff --git a/docs/api/Roslynator/CSharp/SyntaxInfo/MemberDeclarationListInfo/README.md b/docs/api/Roslynator/CSharp/SyntaxInfo/MemberDeclarationListInfo/README.md index 9ca7b3f937..a569849bb1 100644 --- a/docs/api/Roslynator/CSharp/SyntaxInfo/MemberDeclarationListInfo/README.md +++ b/docs/api/Roslynator/CSharp/SyntaxInfo/MemberDeclarationListInfo/README.md @@ -10,6 +10,7 @@ | Method | Summary | | ------ | ------- | +| [MemberDeclarationListInfo(BaseNamespaceDeclarationSyntax)](#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_CSharp_Syntax_BaseNamespaceDeclarationSyntax_) | Creates a new [MemberDeclarationListInfo](../../Syntax/MemberDeclarationListInfo/README.md) from the specified declaration\. | | [MemberDeclarationListInfo(ClassDeclarationSyntax)](#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_CSharp_Syntax_ClassDeclarationSyntax_) | Creates a new [MemberDeclarationListInfo](../../Syntax/MemberDeclarationListInfo/README.md) from the specified declaration\. | | [MemberDeclarationListInfo(CompilationUnitSyntax)](#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_CSharp_Syntax_CompilationUnitSyntax_) | Creates a new [MemberDeclarationListInfo](../../Syntax/MemberDeclarationListInfo/README.md) from the specified compilation unit\. | | [MemberDeclarationListInfo(InterfaceDeclarationSyntax)](#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_CSharp_Syntax_InterfaceDeclarationSyntax_) | Creates a new [MemberDeclarationListInfo](../../Syntax/MemberDeclarationListInfo/README.md) from the specified declaration\. | @@ -18,6 +19,23 @@ | [MemberDeclarationListInfo(SyntaxNode)](#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_SyntaxNode_) | Creates a new [MemberDeclarationListInfo](../../Syntax/MemberDeclarationListInfo/README.md) from the specified node\. | | [MemberDeclarationListInfo(TypeDeclarationSyntax)](#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_CSharp_Syntax_TypeDeclarationSyntax_) | Creates a new [MemberDeclarationListInfo](../../Syntax/MemberDeclarationListInfo/README.md) from the specified declaration\. | +## MemberDeclarationListInfo\(BaseNamespaceDeclarationSyntax\) + +\ +Creates a new [MemberDeclarationListInfo](../../Syntax/MemberDeclarationListInfo/README.md) from the specified declaration\. + +```csharp +public static Roslynator.CSharp.Syntax.MemberDeclarationListInfo MemberDeclarationListInfo(Microsoft.CodeAnalysis.CSharp.Syntax.BaseNamespaceDeclarationSyntax declaration) +``` + +### Parameters + +**declaration**   [BaseNamespaceDeclarationSyntax](https://docs.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.csharp.syntax.basenamespacedeclarationsyntax) + +### Returns + +[MemberDeclarationListInfo](../../Syntax/MemberDeclarationListInfo/README.md) + ## MemberDeclarationListInfo\(ClassDeclarationSyntax\) \ diff --git a/docs/api/Roslynator/CSharp/SyntaxInfo/README.md b/docs/api/Roslynator/CSharp/SyntaxInfo/README.md index 5ced0a8e51..bb80ab5fd8 100644 --- a/docs/api/Roslynator/CSharp/SyntaxInfo/README.md +++ b/docs/api/Roslynator/CSharp/SyntaxInfo/README.md @@ -38,6 +38,7 @@ public static class SyntaxInfo | [IsExpressionInfo(SyntaxNode, Boolean, Boolean)](IsExpressionInfo/README.md#Roslynator_CSharp_SyntaxInfo_IsExpressionInfo_Microsoft_CodeAnalysis_SyntaxNode_System_Boolean_System_Boolean_) | Creates a new [IsExpressionInfo](../Syntax/IsExpressionInfo/README.md) from the specified node\. | | [LocalDeclarationStatementInfo(ExpressionSyntax, Boolean)](LocalDeclarationStatementInfo/README.md#Roslynator_CSharp_SyntaxInfo_LocalDeclarationStatementInfo_Microsoft_CodeAnalysis_CSharp_Syntax_ExpressionSyntax_System_Boolean_) | Creates a new [LocalDeclarationStatementInfo](../Syntax/LocalDeclarationStatementInfo/README.md) from the specified expression\. | | [LocalDeclarationStatementInfo(LocalDeclarationStatementSyntax, Boolean)](LocalDeclarationStatementInfo/README.md#Roslynator_CSharp_SyntaxInfo_LocalDeclarationStatementInfo_Microsoft_CodeAnalysis_CSharp_Syntax_LocalDeclarationStatementSyntax_System_Boolean_) | Creates a new [LocalDeclarationStatementInfo](../Syntax/LocalDeclarationStatementInfo/README.md) from the specified local declaration statement\. | +| [MemberDeclarationListInfo(BaseNamespaceDeclarationSyntax)](MemberDeclarationListInfo/README.md#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_CSharp_Syntax_BaseNamespaceDeclarationSyntax_) | Creates a new [MemberDeclarationListInfo](../Syntax/MemberDeclarationListInfo/README.md) from the specified declaration\. | | [MemberDeclarationListInfo(ClassDeclarationSyntax)](MemberDeclarationListInfo/README.md#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_CSharp_Syntax_ClassDeclarationSyntax_) | Creates a new [MemberDeclarationListInfo](../Syntax/MemberDeclarationListInfo/README.md) from the specified declaration\. | | [MemberDeclarationListInfo(CompilationUnitSyntax)](MemberDeclarationListInfo/README.md#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_CSharp_Syntax_CompilationUnitSyntax_) | Creates a new [MemberDeclarationListInfo](../Syntax/MemberDeclarationListInfo/README.md) from the specified compilation unit\. | | [MemberDeclarationListInfo(InterfaceDeclarationSyntax)](MemberDeclarationListInfo/README.md#Roslynator_CSharp_SyntaxInfo_MemberDeclarationListInfo_Microsoft_CodeAnalysis_CSharp_Syntax_InterfaceDeclarationSyntax_) | Creates a new [MemberDeclarationListInfo](../Syntax/MemberDeclarationListInfo/README.md) from the specified declaration\. | diff --git a/docs/api/Roslynator/CSharp/SyntaxInverter/README.md b/docs/api/Roslynator/CSharp/SyntaxInverter/README.md index 138fe21b6f..458bcf464b 100644 --- a/docs/api/Roslynator/CSharp/SyntaxInverter/README.md +++ b/docs/api/Roslynator/CSharp/SyntaxInverter/README.md @@ -10,6 +10,9 @@ SyntaxInverter is obsolete, use SyntaxLogicalInverter instead\. +\ +Provides static methods for syntax inversion\. + ```csharp [Obsolete("SyntaxInverter is obsolete, use SyntaxLogicalInverter instead.")] public static class SyntaxInverter diff --git a/docs/cs/CS8602.md b/docs/cs/CS8602.md new file mode 100644 index 0000000000..2762bb4f94 --- /dev/null +++ b/docs/cs/CS8602.md @@ -0,0 +1,13 @@ +# CS8602 + +| Property | Value | +| -------- | ------------------------------------------ | +| Id | CS8602 | +| Title | Dereference of a possibly null reference\. | +| Severity | Warning | + +## Code Fixes + +* Use null propagation operator + +*\(Generated with [DotMarkdown](http://github.com/JosefPihrt/DotMarkdown)\)* \ No newline at end of file diff --git a/docs/cs/CS8604.md b/docs/cs/CS8604.md new file mode 100644 index 0000000000..c9b426177b --- /dev/null +++ b/docs/cs/CS8604.md @@ -0,0 +1,13 @@ +# CS8604 + +| Property | Value | +| -------- | ------------------------------------------------ | +| Id | CS8604 | +| Title | Possible null reference argument for parameter\. | +| Severity | Warning | + +## Code Fixes + +* Use null\-forgiving operator + +*\(Generated with [DotMarkdown](http://github.com/JosefPihrt/DotMarkdown)\)* \ No newline at end of file diff --git a/docs/refactorings/RR0194.md b/docs/refactorings/RR0194.md index c10a334171..d81efc240b 100644 --- a/docs/refactorings/RR0194.md +++ b/docs/refactorings/RR0194.md @@ -1,12 +1,12 @@ -## Split declaration and initialization - -| Property | Value | -| ------------------ | ------------------------------------ | -| Id | RR0194 | -| Title | Split declaration and initialization | -| Syntax | local variable declaration | -| Span | equals token | -| Enabled by Default | ✓ | +## Split local declaration and assignment + +| Property | Value | +| ------------------ | -------------------------------------- | +| Id | RR0194 | +| Title | Split local declaration and assignment | +| Syntax | local variable declaration | +| Span | equals token | +| Enabled by Default | ✓ | ### Usage diff --git a/docs/refactorings/RR0217.md b/docs/refactorings/RR0217.md new file mode 100644 index 0000000000..1fbedfdc29 --- /dev/null +++ b/docs/refactorings/RR0217.md @@ -0,0 +1,45 @@ +## Deconstruct foreach variable + +| Property | Value | +| ------------------ | ---------------------------- | +| Id | RR0217 | +| Title | Deconstruct foreach variable | +| Syntax | foreach statement | +| Enabled by Default | ✓ | + +## Summary + +type or identifier + +### Usage + +#### Before + +```csharp +var dic = new Dictionary(); + +foreach (var kvp in dic) +{ + var k = kvp.Key; + var v = kvp.Value.ToString(); +} +``` + +#### After + +```csharp +var dic = new Dictionary(); + +foreach (var (key, value) in dic) +{ + var k = key; + var v = value.ToString(); +} +``` + +## See Also + +* [Full list of refactorings](Refactorings.md) + + +*\(Generated with [DotMarkdown](http://github.com/JosefPihrt/DotMarkdown)\)* \ No newline at end of file diff --git a/docs/refactorings/Refactorings.md b/docs/refactorings/Refactorings.md index f8143e35d0..e2af5d8257 100644 --- a/docs/refactorings/Refactorings.md +++ b/docs/refactorings/Refactorings.md @@ -881,6 +881,34 @@ switch (s) } ``` +#### Deconstruct foreach variable \(RR0217\) + +* **Syntax**: foreach statement + +#### Before + +```csharp +var dic = new Dictionary(); + +foreach (var kvp in dic) +{ + var k = kvp.Key; + var v = kvp.Value.ToString(); +} +``` + +#### After + +```csharp +var dic = new Dictionary(); + +foreach (var (key, value) in dic) +{ + var k = key; + var v = value.ToString(); +} +``` + #### Expand coalesce expression \(RR0035\) * **Syntax**: coalesce expression @@ -2065,24 +2093,6 @@ bool Foo(string s) * **Syntax**: selected attribute list ![Split attributes](../../images/refactorings/SplitAttributes.png) -#### Split declaration and initialization \(RR0194\) - -* **Syntax**: local variable declaration -* **Span**: equals token - -#### Before - -```csharp -var s = GetValue(); -``` - -#### After - -```csharp -string s; -s = GetValue(); -``` - #### Split if \(RR0184\) * **Syntax**: if statement that has 'logical or' expression as a condition @@ -2127,6 +2137,24 @@ if (condition2) return false; ``` +#### Split local declaration and assignment \(RR0194\) + +* **Syntax**: local variable declaration +* **Span**: equals token + +#### Before + +```csharp +var s = GetValue(); +``` + +#### After + +```csharp +string s; +s = GetValue(); +``` + #### Split switch labels \(RR0157\) * **Syntax**: selected switch labels diff --git a/src/Analyzers/README.md b/src/Analyzers/README.md index 08d13384aa..93dc485c5a 100644 --- a/src/Analyzers/README.md +++ b/src/Analyzers/README.md @@ -23,7 +23,7 @@ | RCS1019 | [Order modifiers](../../docs/analyzers/RCS1019.md) | None | | RCS1020 | [Simplify Nullable\ to T?](../../docs/analyzers/RCS1020.md) | Info | | RCS1021 | [Convert lambda expression body to expression body](../../docs/analyzers/RCS1021.md) | Info | -| RCS1031 | [Remove unnecessary braces](../../docs/analyzers/RCS1031.md) | Hidden | +| RCS1031 | [Remove unnecessary braces in switch section](../../docs/analyzers/RCS1031.md) | Hidden | | RCS1032 | [Remove redundant parentheses](../../docs/analyzers/RCS1032.md) | Info | | RCS1033 | [Remove redundant boolean literal](../../docs/analyzers/RCS1033.md) | Info | | RCS1034 | [Remove redundant 'sealed' modifier](../../docs/analyzers/RCS1034.md) | Hidden | @@ -50,9 +50,9 @@ | RCS1059 | [Avoid locking on publicly accessible instance](../../docs/analyzers/RCS1059.md) | Warning | | RCS1060 | [Declare each type in separate file](../../docs/analyzers/RCS1060.md) | None | | RCS1061 | [Merge 'if' with nested 'if'](../../docs/analyzers/RCS1061.md) | Hidden | -| RCS1063 | [Avoid usage of do statement to create an infinite loop](../../docs/analyzers/RCS1063.md) | Info | -| RCS1064 | [Avoid usage of for statement to create an infinite loop](../../docs/analyzers/RCS1064.md) | None | -| RCS1065 | [Avoid usage of while statement to create an infinite loop](../../docs/analyzers/RCS1065.md) | None | +| RCS1063 | [(\[deprecated\] use RCS1252 instead) Avoid usage of do statement to create an infinite loop](../../docs/analyzers/RCS1063.md) | Info | +| RCS1064 | [(\[deprecated\] use RCS1252 instead) Avoid usage of for statement to create an infinite loop](../../docs/analyzers/RCS1064.md) | None | +| RCS1065 | [(\[deprecated\] use RCS1252 instead) Avoid usage of while statement to create an infinite loop](../../docs/analyzers/RCS1065.md) | None | | RCS1066 | [Remove empty 'finally' clause](../../docs/analyzers/RCS1066.md) | Hidden | | RCS1068 | [Simplify logical negation](../../docs/analyzers/RCS1068.md) | Info | | RCS1069 | [Remove unnecessary case label](../../docs/analyzers/RCS1069.md) | Hidden | @@ -78,8 +78,8 @@ | RCS1097 | [Remove redundant 'ToString' call](../../docs/analyzers/RCS1097.md) | Info | | RCS1098 | [Constant values should be placed on right side of comparisons](../../docs/analyzers/RCS1098.md) | Info | | RCS1099 | [Default label should be the last label in a switch section](../../docs/analyzers/RCS1099.md) | Info | -| RCS1100 | [Format documentation summary on a single line](../../docs/analyzers/RCS1100.md) | None | -| RCS1101 | [Format documentation summary on multiple lines](../../docs/analyzers/RCS1101.md) | None | +| RCS1100 | [(\[deprecated\] use RCS1253 instead) Format documentation summary on a single line](../../docs/analyzers/RCS1100.md) | None | +| RCS1101 | [(\[deprecated\] use RCS1253 instead) Format documentation summary on multiple lines](../../docs/analyzers/RCS1101.md) | None | | RCS1102 | [Make class static](../../docs/analyzers/RCS1102.md) | Warning | | RCS1103 | [Convert 'if' to assignment](../../docs/analyzers/RCS1103.md) | Info | | RCS1104 | [Simplify conditional expression](../../docs/analyzers/RCS1104.md) | Info | @@ -190,7 +190,7 @@ | RCS1234 | [Duplicate enum value](../../docs/analyzers/RCS1234.md) | Info | | RCS1235 | [Optimize method call](../../docs/analyzers/RCS1235.md) | Info | | RCS1236 | [Use exception filter](../../docs/analyzers/RCS1236.md) | Info | -| RCS1237 | [Use bit shift operator](../../docs/analyzers/RCS1237.md) | Hidden | +| RCS1237 | [(\[deprecated\] use RCS1254 instead) Use bit shift operator](../../docs/analyzers/RCS1237.md) | Hidden | | RCS1238 | [Avoid nested ?: operators](../../docs/analyzers/RCS1238.md) | Hidden | | RCS1239 | [Use 'for' statement instead of 'while' statement](../../docs/analyzers/RCS1239.md) | Info | | RCS1240 | [Operator is unnecessary](../../docs/analyzers/RCS1240.md) | Info | @@ -203,6 +203,10 @@ | RCS1248 | [Normalize null check](../../docs/analyzers/RCS1248.md) | None | | RCS1249 | [Unnecessary null-forgiving operator](../../docs/analyzers/RCS1249.md) | Info | | RCS1250 | [Use implicit/explicit object creation](../../docs/analyzers/RCS1250.md) | None | +| RCS1251 | [Remove unnecessary braces from record declaration](../../docs/analyzers/RCS1251.md) | Info | +| RCS1252 | [Normalize usage of infinite loop](../../docs/analyzers/RCS1252.md) | None | +| RCS1253 | [Format documentation comment summary](../../docs/analyzers/RCS1253.md) | None | +| RCS1254 | [Normalize format of enum flag value](../../docs/analyzers/RCS1254.md) | Info | *\(Generated with [DotMarkdown](http://github.com/JosefPihrt/DotMarkdown)\)* \ No newline at end of file diff --git a/src/CodeFixes/README.md b/src/CodeFixes/README.md index 32a1ee1193..55ef5c2862 100644 --- a/src/CodeFixes/README.md +++ b/src/CodeFixes/README.md @@ -166,6 +166,8 @@ | [CS8139](../../docs/cs/CS8139.md) | Cannot change tuple element names when overriding inherited member\. | | [CS8340](../../docs/cs/CS8340.md) | Instance fields of read\-only structs must be read\-only\. | | [CS8403](../../docs/cs/CS8403.md) | Method with an iterator block must be 'async' to return 'IAsyncEnumerable\ - 4.0.3.0 - 4.0.3 - 4.0.3.0 - 4.0.3 - 0.3.1.0 - 0.3.1 - 4.0.3.0 - 4.0.3 - 4.0.3.0 - 4.0.3 - 4.0.3.0 - 4.0.3 + 4.1.0.0 + 4.1.0 + 4.1.0.0 + 4.1.0 + 0.3.2.0 + 0.3.2 + 4.1.0.0 + 4.1.0 + 4.1.0.0 + 4.1.0 + 4.1.0.0 + 4.1.0 2.0.0 1.0.0 diff --git a/src/Refactorings/README.md b/src/Refactorings/README.md index 38679c8b09..987e99b43b 100644 --- a/src/Refactorings/README.md +++ b/src/Refactorings/README.md @@ -67,6 +67,7 @@ | RR0032 | [Copy parameter](../../docs/refactorings/RR0032.md) | ✓ | | RR0033 | [Copy statement](../../docs/refactorings/RR0033.md) | ✓ | | RR0212 | [Copy switch section](../../docs/refactorings/RR0212.md) | ✓ | +| RR0217 | [Deconstruct foreach variable](../../docs/refactorings/RR0217.md) | ✓ | | RR0035 | [Expand coalesce expression](../../docs/refactorings/RR0035.md) | ✓ | | RR0034 | [Expand compound assignment](../../docs/refactorings/RR0034.md) | ✓ | | RR0036 | [Expand event declaration](../../docs/refactorings/RR0036.md) | ✓ | @@ -169,6 +170,7 @@ | RR0156 | [Split attributes](../../docs/refactorings/RR0156.md) | ✓ | | RR0184 | [Split if](../../docs/refactorings/RR0184.md) | ✓ | | RR0190 | [Split if-else](../../docs/refactorings/RR0190.md) | ✓ | +| RR0194 | [Split local declaration and assignment](../../docs/refactorings/RR0194.md) | ✓ | | RR0157 | [Split switch labels](../../docs/refactorings/RR0157.md) | ✓ | | RR0158 | [Split variable declaration](../../docs/refactorings/RR0158.md) | ✓ | | RR0159 | [Swap binary operands](../../docs/refactorings/RR0159.md) | ✓ | diff --git a/src/Tools/MetadataGenerator/Program.cs b/src/Tools/MetadataGenerator/Program.cs index 494b3a57b4..7a50318afe 100644 --- a/src/Tools/MetadataGenerator/Program.cs +++ b/src/Tools/MetadataGenerator/Program.cs @@ -55,7 +55,7 @@ private static async Task Main(string[] args) WriteAnalyzersReadMe(@"Formatting.Analyzers\README.md", formattingAnalyzers, "Roslynator.Formatting.Analyzers"); #if !DEBUG - VisualStudioInstance instance = MSBuildLocator.QueryVisualStudioInstances().First(f => f.Version.Major == 16); + VisualStudioInstance instance = MSBuildLocator.QueryVisualStudioInstances().First(f => f.Version.Major == 17); MSBuildLocator.RegisterInstance(instance); diff --git a/src/VisualStudio/Properties/AssemblyInfo.cs b/src/VisualStudio/Properties/AssemblyInfo.cs index 63dff29db7..8b2dba54e7 100644 --- a/src/VisualStudio/Properties/AssemblyInfo.cs +++ b/src/VisualStudio/Properties/AssemblyInfo.cs @@ -31,7 +31,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -//[assembly: AssemblyVersion("4.0.2.0")] +//[assembly: AssemblyVersion("4.1.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 ba18e0920d..597f7e65d0 100644 --- a/src/VisualStudio/source.extension.vsixmanifest +++ b/src/VisualStudio/source.extension.vsixmanifest @@ -1,7 +1,7 @@  - + Roslynator 2022 A collection of 500+ analyzers, refactorings and fixes for C#, powered by Roslyn. http://github.com/JosefPihrt/Roslynator diff --git a/src/VisualStudioCode/package/CHANGELOG.md b/src/VisualStudioCode/package/CHANGELOG.md index 2dab5559d6..c857ca509c 100644 --- a/src/VisualStudioCode/package/CHANGELOG.md +++ b/src/VisualStudioCode/package/CHANGELOG.md @@ -1,3 +1,19 @@ +## 4.1.0 (2022-03-29) + +* Add analyzer [RCS1254](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1254.md) (Normalize format of enum flag value) +* Add analyzer [RCS1253](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1253.md) (Format documentation comment summary) +* Add analyzer [RCS1252](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1252.md) (Normalize usage of infinite loop) +* Add analyzer [RCS1251](https://github.com/JosefPihrt/Roslynator/blob/master/docs/analyzers/RCS1251.md) (Remove unnecessary braces from record declaration) +* Add refactoring [Deconstruct foreach variable (RR0217)](https://github.com/JosefPihrt/Roslynator/blob/master/docs/refactoring/RR0217.md) +* Add code fix for CS8602, CS8604 +* Add suggestion to call AddRange instead of Add (RCS1235) +* Put back refactoring "Split local declaration and assignment" (RR0194) ([issue](https://github.com/JosefPihrt/Roslynator/issues/881)) +* Adopt activation events in VS Code extension ([issue](https://github.com/JosefPihrt/Roslynator/issues/883)) (thanks to [ProphetLamb](https://github.com/ProphetLamb)) +* Fix: Get config value from global AnalyzerConfig if available ([issue](https://github.com/JosefPihrt/Roslynator/issues/884)) +* Fix: Do not suggest using null-forgiving operator for parameter default value (CS8625) +* Fix: Check if equality operator is overloaded (RCS1171) +* Fix: Do not remove field initialization in struct with constructor(s) (RCS1129) + ## 4.0.3 (2022-01-29) * Fixed release for VS Code diff --git a/src/VisualStudioCode/package/package-lock.json b/src/VisualStudioCode/package/package-lock.json index 63cc521c90..54916f34fa 100644 --- a/src/VisualStudioCode/package/package-lock.json +++ b/src/VisualStudioCode/package/package-lock.json @@ -1,12 +1,12 @@ { "name": "roslynator", - "version": "4.0.3", + "version": "4.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "roslynator", - "version": "4.0.3", + "version": "4.1.0", "license": "Apache-2.0", "dependencies": { "json5": "^2.1.1" diff --git a/src/VisualStudioCode/package/package.json b/src/VisualStudioCode/package/package.json index a06f0c3481..0c8624ee3a 100644 --- a/src/VisualStudioCode/package/package.json +++ b/src/VisualStudioCode/package/package.json @@ -4,7 +4,7 @@ "displayName": "Roslynator", "description": "A collection of 500+ analyzers, refactorings and fixes for C#, powered by Roslyn.", "icon": "images/icon.png", - "version": "4.0.3", + "version": "4.1.0", "author": "Josef Pihrt", "license": "Apache-2.0", "homepage": "https://github.com/josefpihrt/roslynator", diff --git a/tools/build.cmd b/tools/build.cmd index 4fd7b1c08e..3e1aa08728 100644 --- a/tools/build.cmd +++ b/tools/build.cmd @@ -5,8 +5,8 @@ set _programFiles=%ProgramFiles% set _msbuildPath="%_programFiles%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild" set _properties=Configuration=Release,Deterministic=true,TreatWarningsAsErrors=true,WarningsNotAsErrors=1591 set _outDir=..\out\Release -set _version=4.0.2 -set _version4=4.0.2.0 +set _version=4.1.0 +set _version4=4.1.0.0 orang replace "..\src\VisualStudio\source.extension.vsixmanifest" ^ -c "patterns\vsix_manifest_version.txt" from-file -t m r ^ diff --git a/tools/build_vscode.cmd b/tools/build_vscode.cmd index 2a78de1508..7c62b8b59c 100644 --- a/tools/build_vscode.cmd +++ b/tools/build_vscode.cmd @@ -4,7 +4,7 @@ set _programFiles=%ProgramFiles% set _msbuildPath="%_programFiles%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild" set _properties=Configuration=Release,Deterministic=true,TreatWarningsAsErrors=true,WarningsNotAsErrors=1591,DefineConstants=VSCODE -set _version=4.0.3 +set _version=4.1.0 orang replace "..\src\VisualStudioCode\package\package.json" ^ -c "patterns\vscode_version.txt" from-file -t m r ^