Table of Contents

Class CsprojHelper

Namespace
SunamoCsproj
Assembly
SunamoCsproj.dll

Helper methods for working with csproj files.

public class CsprojHelper : CsprojConsts
Inheritance
CsprojHelper
Inherited Members
Extension Methods

Fields

ClassCodeElements

Keywords that indicate class-level code elements.

public static readonly List<string> ClassCodeElements

Field Value

List<string>

Methods

AddLinkToCsproj(string, string, string)

[Obsolete("everything from here will be converted to CsprojInstance. Don't add a single method here!")]
public static Task AddLinkToCsproj(string target, string source, string csprojPath)

Parameters

target string
source string
csprojPath string

Returns

Task

CsprojPathFromName(string, string)

[Obsolete("everything from here will be converted to CsprojInstance. Don't add a single method here!")]
public static string CsprojPathFromName(string slnFolder, string fileNameWithoutExtension)

Parameters

slnFolder string
fileNameWithoutExtension string

Returns

string

DetectDuplicatedProjectAndPackageReferences(List<string>)

EN: Must be here, works with multiple csproj files at once. CZ: Musí být zde, pracuje s více csproj najednou.

public static Task<string> DetectDuplicatedProjectAndPackageReferences(List<string> csprojs)

Parameters

csprojs List<string>

EN: List of csproj file paths. CZ: Seznam cest k csproj souborům.

Returns

Task<string>

EN: String with duplicates report. CZ: Řetězec s reportem duplicit.

GetCsprojFromCsPath(string, string?)

EN: Returns path to csproj file, not folder. CZ: Vrací cestu k csproj souboru, nikoliv složce.

[Obsolete("everything from here will be converted to CsprojInstance. Don't add a single method here!")]
public static string GetCsprojFromCsPath(string path, string? slnFolder = null)

Parameters

path string

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

slnFolder string

EN: Solution folder or null. CZ: Složka solution nebo null.

Returns

string

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

ParseCsproj(string)

Use RHSE2.SetPropertyToInnerClass

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

Parameters

contentOrPath string

Returns

Task

ParseNamespaceFromCsFile(string, string?)

EN: Parses namespace from .cs file. Item1 is project name, Item2 is sanitized full namespace. CZ: Parsuje jmenný prostor z .cs souboru. Item1 je název projektu, Item2 je sanitizované celé NS.

[Obsolete("everything from here will be converted to CsprojInstance. Don't add a single method here!")]
public static (string, string) ParseNamespaceFromCsFile(string content, string? path)

Parameters

content string

EN: File content. CZ: Obsah souboru.

path string

EN: File path or null. CZ: Cesta k souboru nebo null.

Returns

(string, string)

EN: Tuple (project name, full sanitized namespace). CZ: Tuple (název projektu, celé sanitizované NS).

RemoveDuplicatedProjectAndPackageReferences(List<string>)

public static Task RemoveDuplicatedProjectAndPackageReferences(List<string> list)

Parameters

list List<string>

Returns

Task

ReplaceProjectReferenceForPackageReference(string, List<string>, bool)

[Obsolete("everything from here will be converted to CsprojInstance. Don't add a single method here!")]
public static Task<string> ReplaceProjectReferenceForPackageReference(string pathOrContentCsproj, List<string> availableNugetPackages, bool isTests)

Parameters

pathOrContentCsproj string
availableNugetPackages List<string>
isTests bool

Returns

Task<string>

ReplaceProjectReferenceForPackageReferenceWithRemoved(string, List<string>, bool)

EN: Replaces ProjectReference with PackageReference and returns new csproj content + names of replaced projects. CZ: Nahradí ProjectReference za PackageReference a vrátí nový obsah csproj + názvy projektů, které byly nahrazeny.

public static Task<(string, List<string>)> ReplaceProjectReferenceForPackageReferenceWithRemoved(string contentCsproj, List<string> availableNugetPackagesS, bool isTests)

Parameters

contentCsproj string

EN: Content of csproj file. CZ: Obsah csproj souboru.

availableNugetPackagesS List<string>

EN: List of available NuGet packages. CZ: Seznam dostupných NuGet balíčků.

isTests bool

EN: Whether this is a test project. CZ: Zda je to testovací projekt.

Returns

Task<(string, List<string>)>

EN: Tuple of (new csproj content, list of removed project names). CZ: Tuple (nový obsah csproj, seznam odstraněných názvů projektů).