Files - NKS0021

Use Checking.Rooted()

This analyzer provides the following strings:

ContextString

Error List

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

Suggestion Box

Use Checking.Rooted() instead of Path.IsPathRooted

Description

Checking.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 Checking.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

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

Suppression

You can suppress this suggestion by including it in the appropriate place, whichever is convenient.

For more information about how to suppress any warning issued by the Nitrocid analyzer, visit the below page:

Recommendation

We recommend that every caller which use this function use the recommended abovementioned method.