AnalyzeCSharp Class
Performs static code analysis on the input documents, outputting a new document for each symbol.
Namespace
Statiq.CodeAnalysis
Interfaces
Base Types
graph BT Type-->Base0["Module"] click Base0 "/api/Statiq.Common/Module" Base0-->Base1["object"] Type-.->Interface0["IModule"] click Interface0 "/api/Statiq.Common/IModule" Type["AnalyzeCSharp"] class Type type-node

Syntax

public class AnalyzeCSharp : Module, IModule

Remarks

This module acts as the basis for code analysis scenarios such as generating source code documentation. All input documents are assumed to contain C# source in their content and are used to create a Roslyn compilation. All symbols (namespaces, types, members, etc.) in the compilation are then recursively processed and output from this module as documents, one per symbol. The output documents have empty content and all information about the symbol is contained in the metadata. This lets you pass the output documents for each symbol on to a template engine like Razor and generate pages for each symbol by having the template use the document metadata.

Methods

Name Return Value Summary
AfterExecution(IExecutionContext, ExecutionOutputs) void
Called after each module execution.
Inherited from Module
AfterExecutionAsync(IExecutionContext, ExecutionOutputs) Task
Called after each module execution.
Inherited from Module
BeforeExecution(IExecutionContext) void
Called before each module execution.
Inherited from Module
BeforeExecutionAsync(IExecutionContext) Task
Called before each module execution.
Inherited from Module
ExecuteAsync(IExecutionContext) Task<IEnumerable<IDocument>>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
Inherited from Module
ExecuteContextAsync(IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module once for all input documents.
ExecuteInputAsync(IDocument, IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module.
Inherited from Module
Finally(IExecutionContext) void
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
FinallyAsync(IExecutionContext) Task
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
IncludeEmptyNamespaces(Config<bool>) AnalyzeCSharp
Controls whether symbol documents for empty namespaces (those that contain only other namespaces but no other symbols recursively) are output. By default only namespaces that contain other nested symbols are output.
WhereNamespaces(bool, string[]) AnalyzeCSharp
Limits symbols in the initial result set to those in the specified namespaces.
WhereNamespaces(Func<string, bool>) AnalyzeCSharp
Limits symbols in the initial result set to those in the namespaces that satisfy the specified predicate.
WherePublic(bool) AnalyzeCSharp
Limits symbols in the initial result set to those that are public (and optionally protected).
WhereSymbol(Func<ISymbol, bool>) AnalyzeCSharp
Controls which symbols are processed as part of the initial result set.
WhereSymbol(Func<ISymbol, Compilation, bool>) AnalyzeCSharp
Controls which symbols are processed as part of the initial result set.
WithAssemblies(Config<IEnumerable<string>>) AnalyzeCSharp
Analyzes the specified assemblies.
WithAssemblies(Config<string>) AnalyzeCSharp
Analyzes the specified assemblies.
WithAssemblySymbols(bool) AnalyzeCSharp
Controls whether assembly symbol documents are output.
WithCompilationAssemblyName(Config<string>) AnalyzeCSharp
Allows you to change the name of the assembly created by the compilation this module produces. This can be useful for uniquely identifying multiple instances of the module, for example. By default System.IO.Path.GetRandomFileName is used to derive the compilation assembly name.
WithCssClasses(string, string) AnalyzeCSharp
While converting XML documentation to HTML, any tags with the specified name will get the specified CSS class(s). This is helpful to style your XML documentation comment rendering to support the stylesheet of your site.
WithDestination(Func<ISymbol, Compilation, NormalizedPath>) AnalyzeCSharp
This changes the default behavior for the generated destination paths, which is to place files in a path with the same name as their containing namespace. Namespace documents will have the IndexFileName while other type documents will get a name equal to their SymbolId. Member documents will get the same name as their containing type plus an anchor to their SymbolId.
WithDestination(Func<ISymbol, NormalizedPath>) AnalyzeCSharp
This changes the default behavior for the generated destination paths, which is to place files in a path with the same name as their containing namespace. Namespace documents will have the IndexFileName while other type documents will get a name equal to their SymbolId. Member documents will get the same name as their containing type plus an anchor to their SymbolId.
WithDestinationPrefix(NormalizedPath) AnalyzeCSharp
This lets you add a prefix to the default destination behavior (such as nesting symbol documents inside a folder like "api/"). Whatever you supply will be combined with the destination. This method has no effect if you've supplied a custom destination behavior.
WithDocsForImplicitSymbols(Config<bool>) AnalyzeCSharp
By default, XML documentation comments are not parsed and rendered for documents that are not part of the initial result set. This can control that behavior and be used to generate documentation metadata for all documents, regardless if they were part of the initial result set.
WithImplicitInheritDoc(Config<bool>) AnalyzeCSharp
This will assume inheritdoc if a symbol has no other code comments.
WithInputDocuments(Config<bool>) AnalyzeCSharp
Controls whether the content of input documents is treated as code and used in the analysis (the default is true).
WithNamedTypes(Func<INamedTypeSymbol, bool>) AnalyzeCSharp
Restricts the initial result set to named type symbols (I.e., classes, interfaces, etc.). Also allows supplying an additional predicate on the named type.
WithProjects(Config<IEnumerable<string>>) AnalyzeCSharp
Analyzes the specified projects.
WithProjects(Config<string>) AnalyzeCSharp
Analyzes the specified projects.
WithSolutions(Config<IEnumerable<string>>) AnalyzeCSharp
Analyzes the specified solutions.
WithSolutions(Config<string>) AnalyzeCSharp
Analyzes the specified solutions.

Extension Methods