Package
#n Wyam.CodeAnalysis
Usage
AnalyzeCSharp()
Fluent Methods
Chain these methods together after the constructor to modify behavior.
-
WhereNamespaces(bool includeGlobal, params string[] namespaces)Limits symbols in the initial result set to those in the specified namespaces.
includeGlobalIf set to
true, symbols in the unnamed global namespace are included.namespacesThe namespaces to include symbols from (if
namespacesisnull, symbols from all namespaces are included).
-
WhereNamespaces(Func<string, bool> predicate)Limits symbols in the initial result set to those in the namespaces that satisfy the specified predicate.
predicateA predicate that returns true if symbols in the namespace should be included.
-
WherePublic(bool includeProtected = true)Limits symbols in the initial result set to those that are public (and optionally protected)
includeProtectedIf set to
true, protected symbols are also included.
-
WhereSymbol(Func<ISymbol, bool> predicate)Controls which symbols are processed as part of the initial result set.
predicateA predicate that returns
trueif the symbol should be included in the initial result set.
-
WithAssemblies(IEnumerable<string> assemblies)Analyzes the specified assemblies.
assembliesGlobbing patterns indicating the assemblies to analyze.
-
WithAssemblies(string assemblies)Analyzes the specified assemblies.
assembliesA globbing pattern indicating the assemblies to analyze.
-
WithAssemblySymbols(bool assemblySymbols = true)Controls whether assembly symbol documents are output.
assemblySymbolstrueto output assembly symbol documents.
-
WithCssClasses(string tagName, string cssClasses)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.
tagNameName of the tag.
cssClassesThe CSS classes to set for the specified tag name. Separate multiple CSS classes with a space (just like you would in HTML).
-
WithDocsForImplicitSymbols(bool docsForImplicitSymbols = true)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.
docsForImplicitSymbolsIf set to
true, documentation metadata is generated for XML comments on all symbols.
-
WithImplicitInheritDoc(bool implicitInheritDoc = true)This will assume
inheritdocif a symbol has no other code comments.implicitInheritDocIf set to
true, the symbol will inherit documentation comments if no other comments are provided.
-
WithInputDocuments(bool inputDocuments = true)Controls whether the content of input documents is treated as code and used in the analysis (the default is
true).inputDocumentstrueto analyze the content of input documents.
-
WithNamedTypes(Func<INamedTypeSymbol, bool> predicate = null)Restricts the initial result set to named type symbols (I.e., classes, interfaces, etc.). Also allows supplying an additional predicate on the named type.
predicateA predicate that returns
trueif the symbol should be included in the initial result set.
-
WithProjects(IEnumerable<string> projects)Analyzes the specified projects.
projectsGlobbing patterns indicating the projects to analyze.
-
WithProjects(string projects)Analyzes the specified projects.
projectsA globbing pattern indicating the projects to analyze.
-
WithSolutions(IEnumerable<string> solutions)Analyzes the specified solutions.
solutionsGlobbing patterns indicating the solutions to analyze.
-
WithSolutions(string solutions)Analyzes the specified solutions.
solutionsA globbing pattern indicating the solutions to analyze.
-
WithWritePath(Func<IMetadata, FilePath> writePath)This changes the default behavior for the generated
WritePathmetadata value, which is to place files in a path with the same name as their containing namespace. Namespace documents will be named "index.html" 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. Note that the default scheme makes the assumption that members will not have their own files, if that's not the case a new WritePath function will have to be supplied using this method.writePathA function that takes the metadata for a given symbol and returns a
FilePathto use for theWritePathmetadata value.
-
WithWritePathPrefix(DirectoryPath prefix)This lets you add a prefix to the default
WritePathbehavior (such as nesting symbol documents inside a folder like "api/"). Whatever you supply will be combined with theWritePath. This method has no effect if you've supplied a customWritePathbehavior.prefixThe prefix to use for each generated
WritePath.
Settings
The settings listed below apply globally and can be set from the command line or from a configuration file. They are used to configure options and otherwise control module behavior.
-
CodeAnalysisKeys.OutputBuildLog:System.BooleanSet this to
truein the global settings to generate a binary build log when analyzing projects or solutions. The log will be output alongside the project file.
Output Metadata
The metadata values listed below apply to individual documents and are created and set by the module as indicated in their descriptions.
-
CodeAnalysisKeys.Accessibility:System.StringThis is available for type, method, field, event, and property symbols and contains the declared accessibility of the symbol.
-
CodeAnalysisKeys.AllInterfaces:IReadOnlyList<IDocument>This is available for type symbols and contains a collection of the documents that represent all implemented interfaces. The collection is empty if the type doesn't implement any interfaces.
-
CodeAnalysisKeys.AttributeData:Microsoft.CodeAnalysis.AttributeDataThis is available for attribute symbols and contains the Roslyn
Microsoft.CodeAnalysis.AttributeDatainstance for the attribute. -
CodeAnalysisKeys.Attributes:IReadOnlyList<IDocument>This is available for type, method, field, event, property, parameter, and type parameter symbols and contains the type symbol documents for attributes applied to the symbol.
-
CodeAnalysisKeys.BaseTypes:IReadOnlyList<IDocument>This is available for type symbols and contains a collection of the documents that represent all base types (inner-most first).
-
CodeAnalysisKeys.CommentId:System.StringA unique ID that identifies the symbol for documentation purposes.
-
CodeAnalysisKeys.CommentXml:System.StringThis is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains the full unprocessed XML documentation comments content for this symbol. In addition, special metadata keys may be added for custom comment elements with the name[ElementName]Comments. These special metadata keys contain aWyam.CodeAnalysis.OtherCommentinstance with the rendered HTML content (and any attributes) of the custom XML documentation comments with the given[ElementName]. -
CodeAnalysisKeys.ConstantValue:System.ObjectThis is available for field symbols and contains the constant value (if one exists).
-
CodeAnalysisKeys.Constructors:IReadOnlyList<IDocument>This is available for type symbols and contains a collection of the documents that represent all constructors of the type. The collection is empty if the type doesn't have any explicit constructors.
-
CodeAnalysisKeys.ContainingAssembly:Wyam.Common.Documents.IDocumentThe document that represents the containing assembly (or null if this symbol is not from an assembly).
-
CodeAnalysisKeys.ContainingNamespace:Wyam.Common.Documents.IDocumentThe document that represents the containing namespace (or null if this symbol is not nested).
-
CodeAnalysisKeys.ContainingType:Wyam.Common.Documents.IDocumentThis is available for type, method, field, event, property, and parameter symbols and contains a document representing the containing type(or
nullif no containing type). -
CodeAnalysisKeys.DeclaringType:Wyam.Common.Documents.IDocumentThis is available for type parameter symbols and contains a document that represents the declaring type of the type parameter.
-
CodeAnalysisKeys.DerivedTypes:IReadOnlyList<IDocument>This is available for type symbols and contains a collection of the documents that represent all types derived from the type. The collection is empty if the type doesn't have any derived types.
-
CodeAnalysisKeys.DisplayName:System.StringA display name for the symbol. For namespaces, this is the same as
Wyam.CodeAnalysis.CodeAnalysisKeys.QualifiedName. For types, this is the same asWyam.CodeAnalysis.CodeAnalysisKeys.FullName. -
CodeAnalysisKeys.Example:System.StringThis is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains the rendered HTML content from allexampleXML documentation comments for this symbol. -
CodeAnalysisKeys.Exceptions:System.Collections.Generic.IReadOnlyList`1This is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains a collection of allexceptionXML documentation comments for this symbol with their name, link, and/or rendered HTML content. -
CodeAnalysisKeys.ExtensionMethods:IReadOnlyList<IDocument>This is available for type symbols and contains a collection of the documents that represent all extension members applicable to the type.
-
CodeAnalysisKeys.FullName:System.StringThe full name of the symbol. For namespaces, this is the name of the namespace. For types, this includes all generic type parameters.
-
CodeAnalysisKeys.HasConstantValue:System.BooleanThis is available for field symbols and indicates whether a constant value is available for the field.
-
CodeAnalysisKeys.ImplementingTypes:IReadOnlyList<IDocument>This is available for interface symbols and contains a collection of the documents that represent all types that implement the interface. The collection is empty if no other types implement the interface.
-
CodeAnalysisKeys.IsAbstract:System.BooleanIndicates if the symbol is abstract.
-
CodeAnalysisKeys.IsOverride:System.BooleanIndicates if the symbol is an override.
-
CodeAnalysisKeys.IsResult:System.BooleanBy default only certain symbols are processed as part of the initial result set(such as those that match the specified predicate). If this value is
true, then this symbol was part of the initial result set. If it isfalse, the symbol was lazily processed later while fetching related symbols and may not contain the full set of metadata. -
CodeAnalysisKeys.IsStatic:System.BooleanIndicates if the symbol is static.
-
CodeAnalysisKeys.IsVirtual:System.BooleanIndicates if the symbol is virtual.
-
CodeAnalysisKeys.Kind:System.StringThis is the general kind of symbol. For example, the for a namespace this is "Namespace" and for a type this is "NamedType".
-
CodeAnalysisKeys.MemberNamespaces:IReadOnlyList<IDocument>This is available for namespace symbols and contains a collection of the documents that represent all member namespaces. The collection is empty if there are no member namespaces.
-
CodeAnalysisKeys.Members:IReadOnlyList<IDocument>This is available for type symbols and contains a collection of the documents that represent all members of the type, including inherited ones. The collection is empty if the type doesn't have any members.
-
CodeAnalysisKeys.MemberTypes:IReadOnlyList<IDocument>This is available for namespace and type symbols and contains a collection of the documents that represent all member types. It only contains direct children (as opposed to all nested types).
-
CodeAnalysisKeys.Name:System.StringThe name of the symbol, or an empty string if the symbol has no name (like the global namespace).
-
CodeAnalysisKeys.Operators:IReadOnlyList<IDocument>This is available for type symbols and contains a collection of the documents that represent all operators of the type, including inherited ones. The collection is empty if the type doesn't have any operators.
-
CodeAnalysisKeys.OverriddenMethod:Wyam.Common.Documents.IDocumentThis is available for method symbols and contains a document that represents the method being overridden (or
nullif no method is overriden by this one). -
CodeAnalysisKeys.Parameters:IReadOnlyList<IDocument>This is available for method and property (I.e., indexer) symbols and contains a collection of the documents that represent the parameters of the method or property.
-
CodeAnalysisKeys.Params:System.Collections.Generic.IReadOnlyList`1This is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains a collection of allparamXML documentation comments for this symbol with their name, link, and/or rendered HTML content. -
CodeAnalysisKeys.Permissions:System.Collections.Generic.IReadOnlyList`1This is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains a collection of allpermissionXML documentation comments for this symbol with their name, link, and/or rendered HTML content. -
CodeAnalysisKeys.QualifiedName:System.StringThe qualified name of the symbol which includes all containing namespaces.
-
Keys.RelativeFileDir:Wyam.Common.IO.DirectoryPathThe same as the directory of
Wyam.Common.Meta.Keys.WritePath. This metadata key is available for compatibility with other modules. -
Keys.RelativeFilePath:Wyam.Common.IO.FilePathThe same as
Wyam.Common.Meta.Keys.WritePath. This metadata key is available for compatibility with other modules. -
Keys.RelativeFilePathBase:Wyam.Common.IO.FilePathThe same as
Wyam.Common.Meta.Keys.WritePathwithout the file extension. This metadata key is available for compatibility with other modules. -
CodeAnalysisKeys.Remarks:System.StringThis is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains the rendered HTML content from allremarksXML documentation comments for this symbol. -
CodeAnalysisKeys.Returns:System.StringThis is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains the rendered HTML content from allreturnsXML documentation comments for this symbol. -
CodeAnalysisKeys.ReturnType:Wyam.Common.Documents.IDocumentThis is available for method symbols and contains a document that represents the return type of the method (or
nullif the method returnsvoid). -
CodeAnalysisKeys.SeeAlso:IReadOnlyList<string>This is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains a collection of allseealsoXML documentation comments for this symbol with their rendered HTML link (or just name if no link could be generated). -
CodeAnalysisKeys.SpecificKind:System.StringThe more specific kind of the symbol ("Class", "Struct", etc.) This is the same as
Kindif there is no more specific kind. -
CodeAnalysisKeys.Summary:System.StringThis is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains the rendered HTML content from allsummaryXML documentation comments for this symbol. -
CodeAnalysisKeys.Symbol:Microsoft.CodeAnalysis.ISymbol(orSystem.Collections.Generic.IEnumerable`1if a namespace)The Roslyn
ISymbolfrom which this document is derived. If the document represents a namespace, this metadata might contain more than one symbol since the namespaces documents consolidate same-named namespaces across input code and assemblies. -
CodeAnalysisKeys.SymbolId:System.StringA unique ID that identifies the symbol (can be used for generating folder paths, for example).
-
CodeAnalysisKeys.Syntax:System.StringThis is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains a generated syntax example for the symbol. -
CodeAnalysisKeys.Type:Wyam.Common.Documents.IDocumentThis is available for field, event, property, and parameter symbols and contains the document that represents the type of the symbol.
-
CodeAnalysisKeys.TypeParameters:IReadOnlyList<IDocument>This is available for type and method symbols and contains a collection of the documents that represent all generic type parameters of the type or method. The collection is empty if the type or method doesn't have any generic type parameters.
-
CodeAnalysisKeys.TypeParams:System.Collections.Generic.IReadOnlyList`1This is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains a collection of alltypeparamXML documentation comments for this symbol with their name, link, and/or rendered HTML content. -
CodeAnalysisKeys.Value:System.StringThis is available for documents in the initial result set (
Wyam.CodeAnalysis.CodeAnalysisKeys.IsResultistrue) and contains the rendered HTML content from allvalueXML documentation comments for this symbol. -
Keys.WritePath:Wyam.Common.IO.FilePathA write path is generated for each symbol during code analysis and serves several purposes.First, it's used to automatically create hyperlinks for references in XML documentation comments.It can also be used for generating inbound links from other modules or pipelines to a given symbol. Because the WriteFiles module will check for any WritePath metadata values when outputting documents, this metadata also makes writing symbol documents to disk easier (presumably after they've been sent through a templating module).
