Learn Roslyn Now - E08 - The AdHocWorkspace

Josef Pihrt, whose projects we’ve highlighted a few times (Roslyn Tools, Analyzers, Refactorings and source..., The Essential C# Snippet Source..., Snippetica, 1,581 Snippets and Counting...) has updated his awesome Roslynator and Roslynator Refactorings for Visual Studio 2017 (More VS 2017 information here, Visual Studio Downloads, download it directly, Visual Studio 2017 RC)
“Introduction
A collection of 110+ analyzers and 160+ refactorings for C#, powered by Roslyn.
Links
…
List of Analyzers
- RCS1001 - Add braces.
- RCS1002 - Remove braces.
- RCS1003 - Add braces to if-else.
- RCS1004 - Remove braces from if-else.
- RCS1005 - Simplify nested using statement.
- RCS1006 - Merge else clause with nested if statement.
- RCS1007 - Avoid embedded statement.
- RCS1008 - Use explicit type instead of 'var' (when the type is not obvious).
- RCS1009 - Use explicit type instead of 'var' (foreach variable).
- RCS1010 - Use 'var' instead of explicit type (when the type is obvious).
- RCS1012 - Use explicit type instead of 'var' (even if the type is obvious).
- RCS1013 - Use predefined type.
- RCS1014 - Avoid implicitly-typed array.
- RCS1015 - Use nameof operator.
- RCS1016 - Use expression-bodied member.
- RCS1017 - Avoid multiline expression body.
- RCS1018 - Add default access modifier.
- RCS1019 - Reorder modifiers.
- RCS1020 - Simplify Nullable<T> to T?.
- RCS1021 - Simplify lambda expression.
- RCS1022 - Simplify lambda expression parameter list.
- RCS1023 - Format empty block.
- RCS1024 - Format accessor list.
- RCS1025 - Format each enum member on a separate line.
- RCS1026 - Format each statement on a separate line.
- RCS1027 - Format embedded statement on a separate line.
- RCS1028 - Format switch section's statement on a separate line.
- RCS1029 - Format binary operator on next line.
- RCS1030 - Add empty line after embedded statement.
- RCS1031 - Remove redundant braces.
- RCS1032 - Remove redundant parentheses.
- RCS1033 - Remove redundant boolean literal.
- RCS1034 - Remove redundant sealed modifier.
- RCS1035 - Remove redundant comma in initializer.
- RCS1036 - Remove redundant empty line.
- RCS1037 - Remove trailing white-space.
- RCS1038 - Remove empty statement.
- RCS1039 - Remove empty attribute argument list.
- RCS1040 - Remove empty else clause.
- RCS1041 - Remove empty initializer.
- RCS1042 - Remove enum default underlying type.
- RCS1043 - Remove partial modifier from type with a single part.
- RCS1044 - Remove original exception from throw statement.
- RCS1045 - Rename private field according to camel case with underscore.
- RCS1046 - Asynchronous method name should end with 'Async'.
- RCS1047 - Non-asynchronous method name should not end with 'Async'.
- RCS1048 - Replace anonymous method with lambda expression.
- RCS1049 - Simplify boolean comparison.
- RCS1050 - Add constructor argument list.
- RCS1051 - Parenthesize condition in conditional expression.
- RCS1052 - Declare each attribute separately.
- RCS1054 - Merge local declaration with return statement.
- RCS1055 - Avoid semicolon at the end of declaration.
- RCS1056 - Avoid usage of using alias directive.
- RCS1057 - Add empty line between declarations.
- RCS1058 - Use compound assignment.
- RCS1059 - Avoid locking on publicly accessible instance.
- RCS1060 - Declare each type in separate file.
- RCS1061 - Merge if statement with nested if statement.
- RCS1062 - Avoid interpolated string with no interpolation.
- RCS1063 - Avoid usage of do statement to create an infinite loop.
- RCS1064 - Avoid usage of for statement to create an infinite loop.
- RCS1065 - Avoid usage of while statement to create an inifinite loop.
- RCS1066 - Remove empty finally clause.
- RCS1067 - Remove empty argument list.
- RCS1068 - Simplify logical not expression.
- RCS1069 - Remove unnecessary case label.
- RCS1070 - Remove redundant default switch section.
- RCS1071 - Remove redundant base constructor call.
- RCS1072 - Remove empty namespace declaration.
- RCS1073 - Replace if statement with return statement.
- RCS1074 - Remove redundant constructor.
- RCS1075 - Avoid empty catch clause that catches System.Exception.
- RCS1076 - Format declaration braces.
- RCS1077 - Simplify LINQ method chain.
- RCS1078 - Replace string.Empty with "".
- RCS1079 - Throwing of new NotImplementedException.
- RCS1080 - Replace 'Any' method with 'Count' or 'Length' property.
- RCS1081 - Split variable declaration.
- RCS1082 - Replace 'Count' method with 'Count' or 'Length' property.
- RCS1083 - Replace 'Count' method with 'Any' method.
- RCS1084 - Replace conditional expression with coalesce expression.
- RCS1085 - Replace property with auto-implemented property.
- RCS1086 - Use linefeed as newline.
- RCS1087 - Use carriage return + linefeed as newline.
- RCS1088 - Avoid usage of tab.
- RCS1089 - Use postfix unary operator instead of assignment.
- RCS1090 - Call 'ConfigureAwait(false)'.
- RCS1091 - Remove empty region.
- RCS1092 - Add empty line after last statement in do statement.
- RCS1093 - Remove file with no code.
- RCS1094 - Declare using directive on top level.
- RCS1095 - Use C# 6.0 dictionary initializer.
- RCS1096 - Use bitwise operation instead of 'HasFlag' method.
- RCS1097 - Remove redundant 'ToString' call.
- RCS1098 - Avoid 'null' on the left side of a binary expression.
- RCS1099 - Default label should be last label in switch section.
- RCS1100 - Format documentation summary on a single line.
- RCS1101 - Format documentation summary on multiple lines.
- RCS1102 - Mark class as static.
- RCS1103 - Replace if statement with assignment.
- RCS1104 - Simplify conditional expression.
- RCS1105 - Merge interpolation into interpolated string.
- RCS1106 - Remove empty destructor.
- RCS1107 - Remove redundant 'ToCharArray' call.
- RCS1108 - Add static modifier to all partial class declarations.
- RCS1109 - Use 'Cast' method instead of 'Select' method.
- RCS1110 - Declare type inside namespace.
- RCS1111 - Add braces to switch section with multiple statements.
- RCS1112 - Combine 'Enumerable.Where' method chain.
- RCS1113 - Use 'string.IsNullOrEmpty' method.
- RCS1114 - Remove redundant delegate creation.
List of Refactorings
- Add boolean comparison
- Add braces
- Add braces to if-else
- Add braces to switch section
- Add braces to switch sections
- Add cast expression
- Add default value to parameter
- Add default value to return statement
- Add exception to documentation comment
- Add identifier to variable declaration
- Add parameter name to argument
- Add parameter name to parameter
- Add using directive
- Add using static directive
- Call 'ConfigureAwait(false)'
- Call extension method as instance method
- Call 'To...' method (ToString, ToArray, ToList)
- Change explicit type to 'var'
- Change method return type to 'void'
- Change method/property/indexer type according to return expression
- Change method/property/indexer type according to yield return expression
- Change type according to expression
- Change 'var' to explicit type
- Check expression for null
- Check parameter for null
- Collapse to initalizer
- Comment out member
- Comment out statement
- Copy documentation comment from base member
- Duplicate argument
- Duplicate member
- Duplicate parameter
- Duplicate statement
- Expand assignment expression
- Expand coalesce expression
- Expand event
- Expand expression-bodied member
- Expand initializer
- Expand lambda expression body
- Expand property
- Expand property and add backing field
- Extract declaration from using statement
- Extract expression from condition
- Extract generic type
- Extract statement(s)
- Extract type declaration to a new file
- Format accessor braces
- Format argument list
- Format binary expression
- Format conditional expression
- Format expression chain
- Format initializer
- Format parameter list
- Generate base constructors
- Generate event invoking method
- Generate switch sections
- Initialize local with default value
- Inline alias expression
- Inline method
- Insert string interpolation
- Introduce and initialize field
- Introduce and initialize property
- Introduce constructor
- Introduce field to lock on
- Introduce local from statement that returns value
- Make member abstract
- Make member virtual
- Mark all members as static
- Mark containing class as abstract
- Mark member as static
- Merge assignment expression with return statement
- Merge attributes
- Merge if statements
- Merge interpolation into interpolated string
- Merge local declarations
- Merge string expressions
- Negate binary expression
- Negate boolean literal
- Negate is expression
- Negate operator
- Notify property changed
- Parenthesize expression
- Promote local to parameter
- Remove all comments
- Remove all comments (except documentation comments)
- Remove all documentation comments
- Remove all member declarations
- Remove all preprocessor directives
- Remove all region directives
- Remove all statements
- Remove all switch sections
- Remove braces
- Remove braces from if-else
- Remove braces from switch section
- Remove braces from switch sections
- Remove comment
- Remove condition from last else clause
- Remove directive and related directives
- Remove empty lines
- Remove interpolation
- Remove member
- Remove member declarations above/below
- Remove parameter name from argument
- Remove parentheses
- Remove property initializer
- Remove region
- Remove statement
- Remove statements from switch sections
- Rename backing field according to property name
- Rename identifier according to type name
- Rename method according to type name
- Rename parameter according to its type name
- Rename property according to type name
- Replace "" with String.Empty
- Replace anonymous method with lambda expression
- Replace Any with All (or All with Any)
- Replace as expression with cast expression
- Replace cast expression with as expression
- Replace conditional expression with expression
- Replace conditional expression with if-else
- Replace constant with field
- Replace Count property with Length property (or Length with Count)
- Replace do statement with while statement
- Replace equals expression with String.Equals
- Replace equals expression with String.IsNullOrEmpty
- Replace equals expression with String.IsNullOrWhiteSpace
- Replace field with constant
- Replace for statement with foreach statement
- Replace for statement with while statement
- Replace foreach statement with for statement
- Replace HasFlag invocation with bitwise operation
- Replace if statement with return statement
- Replace if-else with assignment
- Replace if-else with switch statement
- Replace increment operator with decrement operator
- Replace interpolated string with interpolation expression
- Replace interpolated string with string literal
- Replace method group with lambda
- Replace method invocation with []
- Replace method with property
- Replace null literal expression with default expression
- Replace prefix operator to postfix operator
- Replace property with method
- Replace regular string literal with verbatim string literal
- Replace statement with if statement
- Replace string literal with character literal
- Replace String.Contains with String.IndexOf
- Replace String.Empty with ""
- Replace String.Format with interpolated string
- Replace switch statement with if-else
- Replace verbatim string literal with regular string literal
- Replace verbatim string literal with regular string literals
- Replace while statement with do statement
- Reverse for loop
- Simplify lambda expression
- Split attributes
- Split switch labels
- Split variable declaration
- Swap expressions in binary expression
- Swap expressions in conditional expression
- Swap member declarations
- Swap statements in if-else
- Uncomment
- Use expression-bodied member
- Wrap in #if directive
- Wrap in condition
- Wrap in region
- Wrap in try-catch
- Wrap in using statement “
“Introduction
A collection of 160+ refactorings for C#, powered by Roslyn.
Links
…
List of Refactorings
- Add boolean comparison
- Add braces
- Add braces to if-else
- Add braces to switch section
- Add braces to switch sections
- Add cast expression
- Add default value to parameter
- Add default value to return statement
- Add exception to documentation comment
- Add identifier to variable declaration
- Add parameter name to argument
- Add parameter name to parameter
- Add using directive
- Add using static directive
- Call 'ConfigureAwait(false)'
- Call extension method as instance method
- Call 'To...' method (ToString, ToArray, ToList)
- Change explicit type to 'var'
- Change method return type to 'void'
- Change method/property/indexer type according to return expression
- Change method/property/indexer type according to yield return expression
- Change type according to expression
- Change 'var' to explicit type
- Check expression for null
- Check parameter for null
- Collapse to initalizer
- Comment out member
- Comment out statement
- Copy documentation comment from base member
- Duplicate argument
- Duplicate member
- Duplicate parameter
- Duplicate statement
- Expand assignment expression
- Expand coalesce expression
- Expand event
- Expand expression-bodied member
- Expand initializer
- Expand lambda expression body
- Expand property
- Expand property and add backing field
- Extract declaration from using statement
- Extract expression from condition
- Extract generic type
- Extract statement(s)
- Extract type declaration to a new file
- Format accessor braces
- Format argument list
- Format binary expression
- Format conditional expression
- Format expression chain
- Format initializer
- Format parameter list
- Generate base constructors
- Generate event invoking method
- Generate switch sections
- Initialize local with default value
- Inline alias expression
- Inline method
- Insert string interpolation
- Introduce and initialize field
- Introduce and initialize property
- Introduce constructor
- Introduce field to lock on
- Introduce local from statement that returns value
- Make member abstract
- Make member virtual
- Mark all members as static
- Mark containing class as abstract
- Mark member as static
- Merge assignment expression with return statement
- Merge attributes
- Merge if statements
- Merge interpolation into interpolated string
- Merge local declarations
- Merge string expressions
- Negate binary expression
- Negate boolean literal
- Negate is expression
- Negate operator
- Notify property changed
- Parenthesize expression
- Promote local to parameter
- Remove all comments
- Remove all comments (except documentation comments)
- Remove all documentation comments
- Remove all member declarations
- Remove all preprocessor directives
- Remove all region directives
- Remove all statements
- Remove all switch sections
- Remove braces
- Remove braces from if-else
- Remove braces from switch section
- Remove braces from switch sections
- Remove comment
- Remove condition from last else clause
- Remove directive and related directives
- Remove empty lines
- Remove interpolation
- Remove member
- Remove member declarations above/below
- Remove parameter name from argument
- Remove parentheses
- Remove property initializer
- Remove region
- Remove statement
- Remove statements from switch sections
- Rename backing field according to property name
- Rename identifier according to type name
- Rename method according to type name
- Rename parameter according to its type name
- Rename property according to type name
- Replace "" with String.Empty
- Replace anonymous method with lambda expression
- Replace Any with All (or All with Any)
- Replace as expression with cast expression
- Replace cast expression with as expression
- Replace conditional expression with expression
- Replace conditional expression with if-else
- Replace constant with field
- Replace Count property with Length property (or Length with Count)
- Replace do statement with while statement
- Replace equals expression with String.Equals
- Replace equals expression with String.IsNullOrEmpty
- Replace equals expression with String.IsNullOrWhiteSpace
- Replace field with constant
- Replace for statement with foreach statement
- Replace for statement with while statement
- Replace foreach statement with for statement
- Replace HasFlag invocation with bitwise operation
- Replace if statement with return statement
- Replace if-else with assignment
- Replace if-else with switch statement
- Replace increment operator with decrement operator
- Replace interpolated string with interpolation expression
- Replace interpolated string with string literal
- Replace method group with lambda
- Replace method invocation with []
- Replace method with property
- Replace null literal expression with default expression
- Replace prefix operator to postfix operator
- Replace property with method
- Replace regular string literal with verbatim string literal
- Replace statement with if statement
- Replace string literal with character literal
- Replace String.Contains with String.IndexOf
- Replace String.Empty with ""
- Replace String.Format with interpolated string
- Replace switch statement with if-else
- Replace verbatim string literal with regular string literal
- Replace verbatim string literal with regular string literals
- Replace while statement with do statement
- Reverse for loop
- Simplify lambda expression
- Split attributes
- Split switch labels
- Split variable declaration
- Swap expressions in binary expression
- Swap expressions in conditional expression
- Swap member declarations
- Swap statements in if-else
- Uncomment
- Use expression-bodied member
- Wrap in #if directive
- Wrap in condition
- Wrap in region
- Wrap in try-catch
- Wrap in using statement “
Make sure you also check out his other projects;
What? Is the source available? Of course! (and check out how active the repo is ;)
Follow @CH9
Follow @coding4fun
Follow @gduncan411
This conversation has been locked by the site admins. No new comments can be made.