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
pathstringEN: Path to csproj file. CZ: Cesta k csproj souboru.
contentstringEN: 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
xmlDocumentXmlDocumentEN: 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
Properties
XmlDocument
EN: XML document representing csproj file. CZ: XML dokument reprezentující csproj soubor.
public XmlDocument XmlDocument { get; set; }
Property Value
Methods
AddOrEditPropertyGroupItem(string, string, ForceValueForKey)
public void AddOrEditPropertyGroupItem(string tagName, string content, ForceValueForKey forceValueForKey)
Parameters
tagNamestringcontentstringforceValueForKeyForceValueForKey
AddPropertyGroupItemIfNotExists(string)
public string AddPropertyGroupItemIfNotExists(string key)
Parameters
keystring
Returns
AddRemoveDefineConstant(bool, string)
public string AddRemoveDefineConstant(bool add, string defineConstant)
Parameters
Returns
AddRemoveNoWarn(bool, string)
public string AddRemoveNoWarn(bool add, string warn)
Parameters
Returns
AddRemovePropertyGroupItem(bool, string, string)
public string AddRemovePropertyGroupItem(bool add, string tagName, string partValue)
Parameters
Returns
AddXmlElementToItemGroupOrCreate(XmlElement)
public void AddXmlElementToItemGroupOrCreate(XmlElement element)
Parameters
elementXmlElement
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
tagNameItemGroupTagNameEN: Tag name. CZ: Název tagu.
includestringEN: Include attribute value or null. CZ: Hodnota atributu Include nebo null.
versionstringEN: Version attribute value or null. CZ: Hodnota atributu Version nebo null.
packbool?EN: Pack attribute value or null. CZ: Hodnota atributu Pack nebo null.
packagePathstringEN: 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
Returns
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
FilterByAttrAndContains(List<ItemGroupElement>, string, string)
public List<ItemGroupElement> FilterByAttrAndContains(List<ItemGroupElement> list, string attributeName, string mustContain)
Parameters
listList<ItemGroupElement>attributeNamestringmustContainstring
Returns
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
tagNameItemGroupTagNameEN: Tag name. CZ: Název tagu.
attributeNamestringEN: Attribute name. CZ: Název atributu.
mustContainstringEN: 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
tagNameItemGroupTagNameEN: 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
tagNamestring
Returns
RemoveAllItemsInItemGroupWhichContainsInInclude(ItemGroupTagName, string, string)
public void RemoveAllItemsInItemGroupWhichContainsInInclude(ItemGroupTagName tagName, string attributeName, string mustContain)
Parameters
tagNameItemGroupTagNameattributeNamestringmustContainstring
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
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
Returns
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
tagNameItemGroupTagNameEN: Tag name. CZ: Název tagu.
attributeNamestringEN: 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
tagNamestringEN: Tag name to remove. CZ: Název tagu k odstranění.
RemoveSingleItemGroup(string, ItemGroupTagName)
public void RemoveSingleItemGroup(string attributeValue, ItemGroupTagName tagName)
Parameters
attributeValuestringtagNameItemGroupTagName
ReplacePackageReferenceForProjectReference(string)
public Task ReplacePackageReferenceForProjectReference(string pathCsproj)
Parameters
pathCsprojstring
Returns
Save()
public void Save()
TurnOnOffAsyncConditionalCompilationSymbol(bool)
public string TurnOnOffAsyncConditionalCompilationSymbol(bool add)
Parameters
addbool
Returns
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
tagNameItemGroupTagNameEN: Element type (e.g. PackageReference). CZ: Typ elementu (např. PackageReference).
includeValuestringEN: Include attribute value. CZ: Hodnota atributu Include.
attributeNamestringEN: Name of attribute to modify. CZ: Název upravovaného atributu.
newValuestringEN: New attribute value. CZ: Nová hodnota atributu.