Table of Contents

Class CsprojInstance

Namespace
SunamoCsproj
Assembly
SunamoCsproj.dll

EN: Class for working with csproj files using XmlDocument. Don't add anything here, add to CsprojHelper instead. CZ: Třída pro práci s csproj soubory pomocí XmlDocument. Už tu nic nepřidávat, vše do CsprojHelper.

public class CsprojInstance : CsprojConsts
Inheritance
CsprojInstance
Inherited Members
Extension Methods

Constructors

CsprojInstance(string, string?)

EN: Constructor taking path or content. CZ: Konstruktor přijímající cestu nebo obsah.

public CsprojInstance(string path, string? content = null)

Parameters

path string

EN: Path to csproj file. CZ: Cesta k csproj souboru.

content string

EN: Content or null to load from path. CZ: Obsah nebo null pro načtení z cesty.

CsprojInstance(XmlDocument)

EN: Constructor taking XmlDocument directly. CZ: Konstruktor přijímající XmlDocument přímo.

public CsprojInstance(XmlDocument xmlDocument)

Parameters

xmlDocument XmlDocument

EN: XML document. CZ: XML dokument.

Fields

PathFs

EN: File system path to csproj file. CZ: Cesta k csproj souboru na disku.

public string? PathFs

Field Value

string

Properties

XmlDocument

EN: XML document representing csproj file. CZ: XML dokument reprezentující csproj soubor.

public XmlDocument XmlDocument { get; set; }

Property Value

XmlDocument

Methods

AddOrEditPropertyGroupItem(string, string, ForceValueForKey)

public void AddOrEditPropertyGroupItem(string tagName, string content, ForceValueForKey forceValueForKey)

Parameters

tagName string
content string
forceValueForKey ForceValueForKey

AddPropertyGroupItemIfNotExists(string)

public string AddPropertyGroupItemIfNotExists(string key)

Parameters

key string

Returns

string

AddRemoveDefineConstant(bool, string)

public string AddRemoveDefineConstant(bool add, string defineConstant)

Parameters

add bool
defineConstant string

Returns

string

AddRemoveNoWarn(bool, string)

public string AddRemoveNoWarn(bool add, string warn)

Parameters

add bool
warn string

Returns

string

AddRemovePropertyGroupItem(bool, string, string)

public string AddRemovePropertyGroupItem(bool add, string tagName, string partValue)

Parameters

add bool
tagName string
partValue string

Returns

string

AddXmlElementToItemGroupOrCreate(XmlElement)

public void AddXmlElementToItemGroupOrCreate(XmlElement element)

Parameters

element XmlElement

CreateNewItemGroupElement(ItemGroupTagName, string, string, bool?, string)

EN: Returns value xml. If parameter not needed, insert null. Only creates new element and returns it, whether I insert it via ReplaceChild or AppendChild is up to me. CZ: Vrací value xml. Pokud některý parametr není potřeba, vloží se null. Pouze vytvoří nový element a vrátí jej, zda ho potom vložím přes ReplaceChild či AppendChild je na mně.

public XmlElement CreateNewItemGroupElement(ItemGroupTagName tagName, string include, string version, bool? pack, string packagePath)

Parameters

tagName ItemGroupTagName

EN: Tag name. CZ: Název tagu.

include string

EN: Include attribute value or null. CZ: Hodnota atributu Include nebo null.

version string

EN: Version attribute value or null. CZ: Hodnota atributu Version nebo null.

pack bool?

EN: Pack attribute value or null. CZ: Hodnota atributu Pack nebo null.

packagePath string

EN: PackagePath attribute value or null. CZ: Hodnota atributu PackagePath nebo null.

Returns

XmlElement

EN: Created XML element. CZ: Vytvořený XML element.

CreateNewPackageReference(string, string)

public XmlElement CreateNewPackageReference(string include, string version)

Parameters

include string
version string

Returns

XmlElement

CreateOrReplaceItemGroupForReadmeMd()

EN: Creates or replaces item group for readme.md file. CZ: Vytvoří nebo nahradí item group pro readme.md soubor.

public void CreateOrReplaceItemGroupForReadmeMd()

CreateOrReplaceMicrosoft_Extensions_Logging_Abstractions()

EN: Creates or replaces Microsoft.Extensions.Logging.Abstractions package reference. CZ: Vytvoří nebo nahradí referenci na balíček Microsoft.Extensions.Logging.Abstractions.

public void CreateOrReplaceMicrosoft_Extensions_Logging_Abstractions()

DetectDuplicatedProjectAndPackageReferences()

public Task<DuplicatesInItemGroup> DetectDuplicatedProjectAndPackageReferences()

Returns

Task<DuplicatesInItemGroup>

FilterByAttrAndContains(List<ItemGroupElement>, string, string)

public List<ItemGroupElement> FilterByAttrAndContains(List<ItemGroupElement> list, string attributeName, string mustContain)

Parameters

list List<ItemGroupElement>
attributeName string
mustContain string

Returns

List<ItemGroupElement>

GetAllItemsInItemGroupWhichContainsInInclude(ItemGroupTagName, string, string)

EN: Gets all items in item group which contains in Include. Because I often have null values where pure where fails, this method is here. CZ: Získá všechny položky v item group které obsahují v Include. Protože mám často null hodnoty kde mi čisté where selže, je tu tato metoda.

public List<ItemGroupElement> GetAllItemsInItemGroupWhichContainsInInclude(ItemGroupTagName tagName, string attributeName, string mustContain)

Parameters

tagName ItemGroupTagName

EN: Tag name. CZ: Název tagu.

attributeName string

EN: Attribute name. CZ: Název atributu.

mustContain string

EN: String that must be contained. CZ: Řetězec který musí být obsažen.

Returns

List<ItemGroupElement>

EN: List of item group elements. CZ: Seznam item group elementů.

ItemsInItemGroup(ItemGroupTagName)

EN: Don't need to return XmlDocument, it's in each returned element.OwnerDocument. CZ: Nepotřebuji tu vracet XmlDocument, je v každém vráceném prvku.OwnerDocument.

public List<ItemGroupElement> ItemsInItemGroup(ItemGroupTagName tagName)

Parameters

tagName ItemGroupTagName

EN: Tag name. CZ: Název tagu.

Returns

List<ItemGroupElement>

EN: List of item group elements. CZ: Seznam item group elementů.

PropertyGroupItemContent(string)

public string? PropertyGroupItemContent(string tagName)

Parameters

tagName string

Returns

string

RemoveAllItemsInItemGroupWhichContainsInInclude(ItemGroupTagName, string, string)

public void RemoveAllItemsInItemGroupWhichContainsInInclude(ItemGroupTagName tagName, string attributeName, string mustContain)

Parameters

tagName ItemGroupTagName
attributeName string
mustContain string

RemoveDuplicatedProjectAndPackageReferences()

EN: Returns always XML content of the csproj after removing duplicates. CZ: Vrací vždy XML obsah csproj po odstranění duplikátů.

[Obsolete("everything from here will be converted to CsprojInstance. Don't add a single method here!")]
public Task<string> RemoveDuplicatedProjectAndPackageReferences()

Returns

Task<string>

EN: XML content. CZ: XML obsah.

RemoveDuplicatedProjectAndPackageReferences(DuplicatesInItemGroup)

[Obsolete("everything from here will be converted to CsprojInstance. Don't add a single method here!")]
public Task<string> RemoveDuplicatedProjectAndPackageReferences(DuplicatesInItemGroup data)

Parameters

data DuplicatesInItemGroup

Returns

Task<string>

RemoveItemsFromItemGroupWithAttr(ItemGroupTagName, string)

EN: Removes items from item group with attribute. Must check in detail what will be deleted - no easy reverse path exists. CZ: Odstraní položky z item group s atributem. Nutno zkontrolovat detailně co se bude mazat - snadná reverzní cesta neexistuje.

public void RemoveItemsFromItemGroupWithAttr(ItemGroupTagName tagName, string attributeName)

Parameters

tagName ItemGroupTagName

EN: Tag name. CZ: Název tagu.

attributeName string

EN: Attribute name. CZ: Název atributu.

RemovePropertyGroupItem(string)

EN: Removes property group item by tag name. CZ: Odstraní položku property group podle názvu tagu.

public void RemovePropertyGroupItem(string tagName)

Parameters

tagName string

EN: Tag name to remove. CZ: Název tagu k odstranění.

RemoveSingleItemGroup(string, ItemGroupTagName)

public void RemoveSingleItemGroup(string attributeValue, ItemGroupTagName tagName)

Parameters

attributeValue string
tagName ItemGroupTagName

ReplacePackageReferenceForProjectReference(string)

public Task ReplacePackageReferenceForProjectReference(string pathCsproj)

Parameters

pathCsproj string

Returns

Task

Save()

public void Save()

TurnOnOffAsyncConditionalCompilationSymbol(bool)

public string TurnOnOffAsyncConditionalCompilationSymbol(bool add)

Parameters

add bool

Returns

string

UpdateItemGroupElementAttribute(ItemGroupTagName, string, string, string)

EN: Universal method for modifying attribute of existing element in ItemGroup. CZ: Univerzální metoda pro úpravu atributu existujícího elementu v ItemGroup.

public void UpdateItemGroupElementAttribute(ItemGroupTagName tagName, string includeValue, string attributeName, string newValue)

Parameters

tagName ItemGroupTagName

EN: Element type (e.g. PackageReference). CZ: Typ elementu (např. PackageReference).

includeValue string

EN: Include attribute value. CZ: Hodnota atributu Include.

attributeName string

EN: Name of attribute to modify. CZ: Název upravovaného atributu.

newValue string

EN: New attribute value. CZ: Nová hodnota atributu.