Table of Contents

Class MoveToNet5

Namespace
SunamoDevCode.ToNetCore.research
Assembly
SunamoDevCode.dll

Provides methods for migrating .NET Framework projects to .NET 5+ including reference replacement, platform target changes, and cleanup operations.

public class MoveToNet5
Inheritance
MoveToNet5
Inherited Members
Extension Methods

Fields

linesFromDontReplaceReferencesIn

Cached lines from the "don't replace references in" configuration file.

public static List<string>? linesFromDontReplaceReferencesIn

Field Value

List<string>

Properties

Fwss

Gets the list of all FoldersWithSolutions instances from the static collection.

public List<FoldersWithSolutions> Fwss { get; }

Property Value

List<FoldersWithSolutions>

Instance

Singleton instance of MoveToNet5.

public static MoveToNet5 Instance { get; }

Property Value

MoveToNet5

TypeInfo

Type information for the MoveToNet5 class.

public static Type TypeInfo { get; }

Property Value

Type

Methods

AddEssentialWebReferencesToAllWebProjects(ILogger)

Adds essential web references (System.Web, etc.) to all web projects that are missing them.

public Task AddEssentialWebReferencesToAllWebProjects(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

Task

ChangeConvertNonWebPlatformTargetTo(ILogger, string)

Pravděpodobně to kurví csproj A1 can be

Tohle asi nemělo příliš smysl. Když jsem to změnil celé v jakémkoliv řešení z AnyCPU na x86 tak jsem měl u plno projektů modrou ikonku. Navíc s tímto nastavením když jsem spustil EveryLine a ač sln bylo nastavené AnyCPu, hned po spuštení že nemůže načíst EveryLine. Když jsem jeho csproj změnil na AnyCPU, chybu začalo hlásit zase u desktop.

A1 can be x86,x64.AnyCPU

public Task ChangeConvertNonWebPlatformTargetTo(ILogger logger, string replacementPlatformTarget)

Parameters

logger ILogger
replacementPlatformTarget string

Returns

Task

ChangeProjectsToNetStandard(ILogger)

Changes all SDK-style web projects to target netstandard2.0.

public Task ChangeProjectsToNetStandard(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

Task

ClearUnnecessaryFromNonWeb(ILogger, string)

Vyčistí od dočasných souborů z NonWeb

public void ClearUnnecessaryFromNonWeb(ILogger logger, string folderWithTemporaryMovedContentWithoutBackslash)

Parameters

logger ILogger

Logger instance.

folderWithTemporaryMovedContentWithoutBackslash string

Folder path for temporary content (without trailing backslash).

ConvertAlLWebNetStandardProjectsToNet48(ILogger)

Converts all web projects targeting netstandard2.0 to target net4.8.

public Task ConvertAlLWebNetStandardProjectsToNet48(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

Task

DetectFrameworkForWebProjects(ILogger, bool)

1 = sdk style, not netstandard2.0 2 = sdk style, netstandard2.0

public Task<Tuple<List<TWithStringDC<string>>, List<TWithStringDC<string>>>> DetectFrameworkForWebProjects(ILogger logger, bool appendHeader)

Parameters

logger ILogger

Logger instance.

appendHeader bool

Whether to append a header line to the output.

Returns

Task<Tuple<List<TWithStringDC<string>>, List<TWithStringDC<string>>>>

Tuple of (SDK-style web projects, netstandard web projects) with version info.

DetectFrameworkForWebProjectsOnlySupported(ILogger)

Detects the .NET framework version for all web projects and groups them by version.

public Task<string> DetectFrameworkForWebProjectsOnlySupported(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

Task<string>

Report grouped by framework version.

FindProjectsWhichIsSdkStyle(ILogger, bool, bool)

Categorizes projects into SDK style, netstandard, and non-SDK style groups.

public Task<FindProjectsWhichIsSdkStyleResult> FindProjectsWhichIsSdkStyle(ILogger logger, bool appendHeaderForWeb, bool isWeb = true)

Parameters

logger ILogger

Logger instance.

appendHeaderForWeb bool

If true, adds a header label for web SDK style projects.

isWeb bool

If true, processes web projects; otherwise processes non-web projects.

Returns

Task<FindProjectsWhichIsSdkStyleResult>

Result containing three categorized lists of project paths.

FindProjectsWhichIsSdkStyleList(ILogger, bool, bool)

Finds all SDK-style projects and returns a formatted list report.

public Task<string> FindProjectsWhichIsSdkStyleList(ILogger logger, bool appendHeaderForWeb, bool web = true)

Parameters

logger ILogger

Logger instance.

appendHeaderForWeb bool

Whether to append a header for web projects.

web bool

Whether to include web projects.

Returns

Task<string>

Formatted text report of SDK-style projects.

GenerateTryConvert(string)

Generates a try-convert CLI command for converting a csproj to .NET 5.

public string GenerateTryConvert(string csprojPath)

Parameters

csprojPath string

Path to the csproj file to convert.

Returns

string

try-convert command string.

GetAllTargetFrameworks(ILogger)

Gets all unique TargetFramework values across non-web projects and lists projects with multiple TargetFramework elements.

public Task<string> GetAllTargetFrameworks(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

Task<string>

Text output with target frameworks grouped by value and list of multi-framework projects.

ListOfAllWebAndNonWeb(ILogger)

Gets a formatted list of all web and non-web projects.

public string ListOfAllWebAndNonWeb(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

string

Text output with web and non-web project lists.

PlatformTargetToWeb(ILogger, string)

Pravděpodobně to kurví csproj A1 can be

Tohle asi nemělo příliš smysl. Když jsem to změnil celé v jakémkoliv řešení z AnyCPU na x86 tak jsem měl u plno projektů modrou ikonku. Navíc text tímto nastavením když jsem spustil EveryLine a ač sln bylo nastavené AnyCPu, hned po spuštení že nemůže načíst EveryLine. Když jsem jeho csproj změnil na AnyCPU, chybu začalo hlásit zase u desktop.

A1 can be x86,x64.AnyCPU

public Task PlatformTargetToWeb(ILogger logger, string replaceFor)

Parameters

logger ILogger

Logger instance.

replaceFor string

Target platform value to set (x86, x64, AnyCPU).

Returns

Task

ReplaceProjectReferenceForWeb(ILogger, string, string)

Replaces project references in web projects to point to the web-specific version.

public void ReplaceProjectReferenceForWeb(ILogger logger, string projectName, string projectNamespace)

Parameters

logger ILogger

Logger instance.

projectName string

Name of the project to replace references for.

projectNamespace string

Namespace of the project.

ReplaceUnneedReferencesInCsprojs(string)

odstraní reference z c# které

public Task ReplaceUnneedReferencesInCsprojs(string csprojPath)

Parameters

csprojPath string

Path to the csproj file to process.

Returns

Task

ReplaceUnneedReferencesInCsprojsNotSdKStyle(ILogger, bool)

Replaces unnecessary references in csproj files that are not SDK style and generates try-convert commands.

public Task<string> ReplaceUnneedReferencesInCsprojsNotSdKStyle(ILogger logger, bool isWeb = true)

Parameters

logger ILogger

Logger instance.

isWeb bool

If true, processes web projects; otherwise non-web projects.

Returns

Task<string>

Generated try-convert commands for each processed project.

RestoreFromBackup(List<string>)

Restores files from their .old backup copies.

public Task RestoreFromBackup(List<string> filePaths)

Parameters

filePaths List<string>

List of file paths to restore from backup.

Returns

Task

TableWebAndNonWeb(ILogger)

Compares web and non-web projects to find which ones exist in both categories. Projects used in both need to stay on netstandard.

public bool TableWebAndNonWeb(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

bool

Always returns false (incomplete implementation).

WebAndNonWebProjects(ILogger, bool)

Dont use XmlDocumentsCache

public Tuple<List<string>, List<string>> WebAndNonWebProjects(ILogger logger, bool withCsprojs = true)

Parameters

logger ILogger
withCsprojs bool

Returns

Tuple<List<string>, List<string>>

WebAndNonWebSlns()

Gets web and non-web solution paths separated into two lists.

public Tuple<List<string>, List<string>> WebAndNonWebSlns()

Returns

Tuple<List<string>, List<string>>

Tuple where Item1 is web solution paths and Item2 is non-web solution paths.

WebProjectsWhichIsNotSdkStyle(ILogger)

Gets a newline-separated list of web projects that are not SDK style.

public Task<string> WebProjectsWhichIsNotSdkStyle(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

Task<string>

Newline-separated list of non-SDK style web project paths.

WebProjectsWhichIsNotSdkStyleFindTheirBackup(ILogger)

Finds backup files for web projects that are not SDK-style and categorizes them.

public Task<string> WebProjectsWhichIsNotSdkStyleFindTheirBackup(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

Task<string>

Report of backup status for each project.

WebProjectsWhichNotEndWithDotEnd(ILogger)

Lists web projects whose csproj files do not end with .web.csproj.

public string WebProjectsWhichNotEndWithDotEnd(ILogger logger)

Parameters

logger ILogger

Logger instance.

Returns

string

List of non-standard web project paths.