gitlabEdit

chart-mixedFiles - NKS0021

Use Checking.Rooted()

This analyzer provides the following strings:

Context
String

Error List

Caller uses Path.IsPathRooted instead of FilesystemTools.Rooted()

Suggestion Box

Use FilesystemTools.Rooted() instead of Path.IsPathRooted

Description

FilesystemTools.Rooted() uses the filesystem driver to call Path.IsPathRooted.


Extended Description

This code analyzer detects the usage of Delete from the standard Directory class found in the System.IO namespace.

Using Path.IsPathRooted(), it doesn't use any driver to wrap this call, so it calls the built-in IsPathRooted() directly.

Alternatively, you can use FilesystemTools.Rooted(), which uses the filesystem driver for extensibility.


Analysis Comparison

To get a brief insight about how this analyzer works, compare the two code blocks shown to you below:

Before the fix

Somewhere in your mod code...
public static void MyFunction()
{
    Path.IsPathRooted("C:/test.txt");
}

After the fix

Last updated