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
E2sNamespaceCodeElements
Maps NamespaceCodeElementsType enum values to their C# keyword strings.
public static Dictionary<NamespaceCodeElementsType, string> E2sNamespaceCodeElements
Field Value
Instance
Singleton instance of the indexer.
public static SourceCodeIndexerRoslyn Instance
Field Value
Properties
ContainsArgs
Filter arguments for path content matching.
public CsFileFilterRoslyn.ContainsArgs? ContainsArgs { get; set; }
Property Value
ContainsOther
Other path content patterns to exclude from indexing.
public List<string>? ContainsOther { get; set; }
Property Value
EndArgs
Filter arguments for path endings. Removes files from index in ProcessFile that match these criteria.
public CsFileFilterRoslyn.EndArgs? EndArgs { get; set; }
Property Value
EndsOther
Other path endings to exclude from indexing.
public List<string>? EndsOther { get; set; }
Property Value
FileNames
File name patterns to exclude from indexing.
public List<string>? FileNames { get; set; }
Property Value
FileNamesExactly
Exact file names to exclude from indexing.
public List<string>? FileNamesExactly { get; set; }
Property Value
IsCallingIsToIndexed
Whether IsToIndexed is currently being called (prevents recursive checks).
public bool IsCallingIsToIndexed { get; set; }
Property Value
IsLoadingFromFile
Whether the indexer is currently loading from a file.
public bool IsLoadingFromFile { get; set; }
Property Value
LinesWithContent
In key is full path, in value lines with letter content.
public IDictionary<string, List<string>> LinesWithContent { get; set; }
Property Value
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
Watchers
File system watchers for monitoring file changes.
public FileSystemWatchers? Watchers { get; set; }
Property Value
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
loadExtensionsList<string>File extensions to include in the search.
textstringThe text to search for in element names.
typeNamespaceCodeElementsTypeThe namespace code element type filter.
classTypeClassCodeElementsTypeThe class code element type filter.
searchStrategySearchStrategyRoslynThe 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
pathFilestringFull 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
pathFilestringFull 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
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
filestringFull path to the source file.
isFromFileSystemWatcherboolWhether the call originates from a file system watcher event.
isRemovingRegionsboolWhether to remove region directives during processing.
Returns
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
pathFilestringFull path to the source file.
namespaceCodeElementsTypeNamespaceCodeElementsTypeTypes of namespace-level code elements to extract.
classCodeElementsTypeClassCodeElementsTypeTypes of class-level code elements to extract.
isRemovingRegionsboolWhether to remove region directives during processing.
isFromFileSystemWatcherboolWhether the call originates from a file system watcher event.
Returns
ProcessFileAsync(string, bool)
Processes a file triggered by a FileSystemWatcher event.
public Task ProcessFileAsync(string file, bool isFromFileSystemWatcher)
Parameters
filestringFull path to the source file.
isFromFileSystemWatcherboolWhether the call originates from a file system watcher event.
Returns
RemoveFile(string)
Removes a file and all its indexed data from the indexer.
public void RemoveFile(string pathFile)
Parameters
pathFilestringFull 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
loadExtensionsList<string>File extensions to include in the search.
termstringThe search term to look for.
includeEmptyboolWhether to include files with no matches in the result.
inCommentsbool?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.