Simplifier Class

Definition

Expands and Reduces subtrees.

Expansion: 1) Makes inferred names explicit (on anonymous types and tuples). 2) Replaces names with fully qualified dotted names. 3) Adds parentheses around expressions 4) Adds explicit casts/conversions where implicit conversions exist 5) Adds escaping to identifiers 6) Rewrites extension method invocations with explicit calls on the class containing the extension method.

Reduction: 1) Shortens dotted names to their minimally qualified form 2) Removes unnecessary parentheses 3) Removes unnecessary casts/conversions 4) Removes unnecessary escaping 5) Rewrites explicit calls to extension methods to use dot notation 6) Removes unnecessary tuple element names and anonymous type member names

public ref class Simplifier abstract sealed
public static class Simplifier
type Simplifier = class
Public Class Simplifier
Inheritance
Simplifier

Properties

AddImportsAnnotation

The annotation Microsoft.CodeAnalysis.CodeActions.CodeAction.CleanupDocumentAsync(Microsoft.CodeAnalysis.Document,Microsoft.CodeAnalysis.CodeCleanup.CodeCleanupOptions,System.Threading.CancellationToken) used to identify sub trees to look for symbol annotations on. It will then add import directives for these symbol annotations.

Annotation

The annotation the reducer uses to identify sub trees to be reduced. The Expand operations add this annotation to nodes so that the Reduce operations later find them.

SpecialTypeAnnotation

This is the annotation used by the simplifier and expander to identify Predefined type and preserving them from over simplification

Methods

Expand(SyntaxToken, SemanticModel, Workspace, Func<SyntaxNode,Boolean>, CancellationToken)

Expand qualifying parts of the specified subtree, annotating the parts using the Annotation annotation.

Expand<TNode>(TNode, SemanticModel, Workspace, Func<SyntaxNode,Boolean>, Boolean, CancellationToken)

Expand qualifying parts of the specified subtree, annotating the parts using the Annotation annotation.

ExpandAsync(SyntaxToken, Document, Func<SyntaxNode,Boolean>, CancellationToken)

Expand qualifying parts of the specified subtree, annotating the parts using the Annotation annotation.

ExpandAsync<TNode>(TNode, Document, Func<SyntaxNode,Boolean>, Boolean, CancellationToken)

Expand qualifying parts of the specified subtree, annotating the parts using the Annotation annotation.

ReduceAsync(Document, IEnumerable<TextSpan>, OptionSet, CancellationToken)

Reduce the sub-trees annotated with Annotation found within the specified spans. The annotated node and all child nodes will be reduced.

ReduceAsync(Document, OptionSet, CancellationToken)

Reduce all sub-trees annotated with Annotation found within the document. The annotated node and all child nodes will be reduced.

ReduceAsync(Document, SyntaxAnnotation, OptionSet, CancellationToken)

Reduce the sub-trees annotated with Annotation found within the subtrees identified with the specified annotation. The annotated node and all child nodes will be reduced.

ReduceAsync(Document, TextSpan, OptionSet, CancellationToken)

Reduce the sub-trees annotated with Annotation found within the specified span. The annotated node and all child nodes will be reduced.

Applies to