Table of Contents

Class SourceCodeIndexerRoslyn

Namespace
SunamoRoslyn
Assembly
SunamoRoslyn.dll

Indexes source code files and extracts code elements using Roslyn.

public class SourceCodeIndexerRoslyn
Inheritance
SourceCodeIndexerRoslyn
Inherited Members
Extension Methods

Fields

E2sClassCodeElements

Maps ClassCodeElementsType enum values to their C# keyword strings.

public static Dictionary<ClassCodeElementsType, string> E2sClassCodeElements

Field Value

Dictionary<ClassCodeElementsType, string>

E2sNamespaceCodeElements

Maps NamespaceCodeElementsType enum values to their C# keyword strings.

public static Dictionary<NamespaceCodeElementsType, string> E2sNamespaceCodeElements

Field Value

Dictionary<NamespaceCodeElementsType, string>

Instance

Singleton instance of the indexer.

public static SourceCodeIndexerRoslyn Instance

Field Value

SourceCodeIndexerRoslyn

Properties

ContainsArgs

Filter arguments for path content matching.

public CsFileFilterRoslyn.ContainsArgs? ContainsArgs { get; set; }

Property Value

CsFileFilterRoslyn.ContainsArgs

ContainsOther

Other path content patterns to exclude from indexing.

public List<string>? ContainsOther { get; set; }

Property Value

List<string>

EndArgs

Filter arguments for path endings. Removes files from index in ProcessFile that match these criteria.

public CsFileFilterRoslyn.EndArgs? EndArgs { get; set; }

Property Value

CsFileFilterRoslyn.EndArgs

EndsOther

Other path endings to exclude from indexing.

public List<string>? EndsOther { get; set; }

Property Value

List<string>

FileNames

File name patterns to exclude from indexing.

public List<string>? FileNames { get; set; }

Property Value

List<string>

FileNamesExactly

Exact file names to exclude from indexing.

public List<string>? FileNamesExactly { get; set; }

Property Value

List<string>

IsCallingIsToIndexed

Whether IsToIndexed is currently being called (prevents recursive checks).

public bool IsCallingIsToIndexed { get; set; }

Property Value

bool

IsLoadingFromFile

Whether the indexer is currently loading from a file.

public bool IsLoadingFromFile { get; set; }

Property Value

bool

LinesWithContent

In key is full path, in value lines with letter content.

public IDictionary<string, List<string>> LinesWithContent { get; set; }

Property Value

IDictionary<string, List<string>>

LinesWithIndexes

Contains lines that have no letter content (indexes of empty/non-text lines).

public IDictionary<string, List<int>> LinesWithIndexes { get; set; }

Property Value

IDictionary<string, List<int>>

PathStarts

Path prefixes to exclude from indexing.

public List<string>? PathStarts { get; set; }

Property Value

List<string>

Watchers

File system watchers for monitoring file changes.

public FileSystemWatchers? Watchers { get; set; }

Property Value

FileSystemWatchers

Methods

FindNamespaceElement(List<string>, string, NamespaceCodeElementsType, ClassCodeElementsType, SearchStrategyRoslyn)

Finds namespace and class code elements matching the search criteria.

public CodeElements FindNamespaceElement(List<string> loadExtensions, string text, NamespaceCodeElementsType type, ClassCodeElementsType classType, SearchStrategyRoslyn searchStrategy = SearchStrategyRoslyn.FixedSpace)

Parameters

loadExtensions List<string>

File extensions to include in the search.

text string

The text to search for in element names.

type NamespaceCodeElementsType

The namespace code element type filter.

classType ClassCodeElementsType

The class code element type filter.

searchStrategy SearchStrategyRoslyn

The search strategy to use for matching.

Returns

CodeElements

Combined namespace and class code elements matching the criteria.

IsIndexed(string)

Checks whether a file has been indexed.

public bool IsIndexed(string pathFile)

Parameters

pathFile string

Full path to the file.

Returns

bool

True if the file is indexed; false if loading from file or not indexed.

IsToIndexed(string)

Determines whether a file should be indexed based on all filter criteria.

public bool IsToIndexed(string pathFile)

Parameters

pathFile string

Full path to the file.

Returns

bool

True if the file should be indexed.

IsToIndexedFolder(string, bool)

Determines whether a file's folder path should be indexed based on filter rules.

public bool IsToIndexedFolder(string pathFile, bool alsoEnds)

Parameters

pathFile string

Full path to the file.

alsoEnds bool

Whether to also check path endings.

Returns

bool

True if the file's folder is indexable.

Nuke()

Clears all indexed data.

public void Nuke()

ProcessAllCodeElementsInFiles(string, bool, bool)

Processes all code element types in a file.

public Task ProcessAllCodeElementsInFiles(string file, bool isFromFileSystemWatcher, bool isRemovingRegions = false)

Parameters

file string

Full path to the source file.

isFromFileSystemWatcher bool

Whether the call originates from a file system watcher event.

isRemovingRegions bool

Whether to remove region directives during processing.

Returns

Task

ProcessFile(string, NamespaceCodeElementsType, ClassCodeElementsType, bool, bool)

Processes a source file and indexes its code elements. Public only for testing purposes.

public Task ProcessFile(string pathFile, NamespaceCodeElementsType namespaceCodeElementsType, ClassCodeElementsType classCodeElementsType, bool isRemovingRegions, bool isFromFileSystemWatcher)

Parameters

pathFile string

Full path to the source file.

namespaceCodeElementsType NamespaceCodeElementsType

Types of namespace-level code elements to extract.

classCodeElementsType ClassCodeElementsType

Types of class-level code elements to extract.

isRemovingRegions bool

Whether to remove region directives during processing.

isFromFileSystemWatcher bool

Whether the call originates from a file system watcher event.

Returns

Task

ProcessFileAsync(string, bool)

Processes a file triggered by a FileSystemWatcher event.

public Task ProcessFileAsync(string file, bool isFromFileSystemWatcher)

Parameters

file string

Full path to the source file.

isFromFileSystemWatcher bool

Whether the call originates from a file system watcher event.

Returns

Task

RemoveFile(string)

Removes a file and all its indexed data from the indexer.

public void RemoveFile(string pathFile)

Parameters

pathFile string

Full path to the file to remove.

SearchInContent(List<string>, string, bool, bool?)

Searches indexed file content for a term and returns matching code elements.

public Dictionary<string, List<FoundedCodeElement>> SearchInContent(List<string> loadExtensions, string term, bool includeEmpty, bool? inComments)

Parameters

loadExtensions List<string>

File extensions to include in the search.

term string

The search term to look for.

includeEmpty bool

Whether to include files with no matches in the result.

inComments bool?

If true, search only in comments; if false, exclude comments; if null, search everywhere.

Returns

Dictionary<string, List<FoundedCodeElement>>

Dictionary mapping file paths to lists of found code elements.