Table of Contents

Class XmlDocumentsCache

Namespace
SunamoDevCode
Assembly
SunamoDevCode.dll

Cache for XML documents (typically csproj files) to avoid repeated parsing.

public class XmlDocumentsCache
Inheritance
XmlDocumentsCache
Inherited Members
Extension Methods

Fields

BuildProjectsDependencyTreeList

Delegate for building the project dependency tree from a csproj path and cache.

public static Func<string, Dictionary<string, XmlDocument>?, Task<List<string>>> BuildProjectsDependencyTreeList

Field Value

Func<string, Dictionary<string, XmlDocument>, Task<List<string>>>

Cache

Dictionary caching parsed XmlDocuments keyed by file path.

public static Dictionary<string, XmlDocument> Cache

Field Value

Dictionary<string, XmlDocument>

CantBeLoadWithDictToAvoidCollectionWasChangedButCanWithNull

List of paths that cannot be loaded with a dictionary to avoid collection-was-changed exceptions.

public static List<string> CantBeLoadWithDictToAvoidCollectionWasChangedButCanWithNull

Field Value

List<string>

Clpb

Optional progress bar for displaying cache loading progress.

public static IProgressBarDC? Clpb

Field Value

IProgressBarDC

Nulled

Count of csproj files that were null (ignored or failed to load).

public static int Nulled

Field Value

int

ProjectDeps

In key is csproj path In value is absolute path of references (recursive)

public static Dictionary<string, List<string>> ProjectDeps

Field Value

Dictionary<string, List<string>>

Type

Type reference for this class.

public static Type Type

Field Value

Type

Methods

BadXml()

Returns paths of projects with invalid XML.

public static List<string> BadXml()

Returns

List<string>

List of project paths with null XmlDocument values.

BuildProjectDeps()

Builds a filtered dictionary containing only successfully loaded XML documents from the cache.

public static Dictionary<string, XmlDocument> BuildProjectDeps()

Returns

Dictionary<string, XmlDocument>

Dictionary of valid XML documents keyed by csproj path.

Get(string)

Nemůže se volat společně s .Result! viz. https://stackoverflow.com/a/65820543/9327173 Způsobí to deadlock! Musím to dělat přes ThisApp.async_ Can return null during many situations For example when ignored => must always checking for null

public static Task<ResultWithExceptionDC<XmlDocument>> Get(string path)

Parameters

path string

Path to the csproj file to load or retrieve from cache.

Returns

Task<ResultWithExceptionDC<XmlDocument>>

Result containing the parsed XmlDocument or an exception message.

Set(string, string, bool)

Sets or updates a cached XML document from raw XML content, optionally saving to disk.

public static Task Set(string path, string xmlContent, bool saveToFile = false)

Parameters

path string

Path to the csproj file.

xmlContent string

Raw XML content to parse.

saveToFile bool

Whether to also write the document to disk.

Returns

Task

Set(string, XmlDocument, bool)

Sets or updates a cached XML document, optionally saving to disk.

public static Task Set(string path, XmlDocument document, bool saveToFile = false)

Parameters

path string

Path to the csproj file.

document XmlDocument

XmlDocument to cache.

saveToFile bool

Whether to also write the document to disk.

Returns

Task