The analyzer detected a possible error that deals with two different variables being initialized by the same expression. Not all of such expressions are treated as unsafe but only those where function calls are used (or too long expressions).
Here is the simplest case:
x = X();
y = X();
Three scenarios are possible:
Now consider the following example from real code:
string frameworkPath =
Path.Combine(tmpRootDirectory, frameworkPathPattern);
string manifestFile =
Path.Combine(frameworkPath, "sdkManifest.xml");
string frameworkPath2 =
Path.Combine(tmpRootDirectory, frameworkPathPattern2);
string manifestFile2 =
Path.Combine(frameworkPath, "sdkManifest.xml");
There is a copy-paste error in this code, which is not easy to notice at first. Actually, it deals with mistakenly passing the first part of the path to the 'Path.Combine' function when receiving the 'manifestFile2' string. The code logic suggests that variable 'frameworkPath2' should be used instead of the originally used 'frameworkPath' variable.
The fixed code should look like this:
string manifestFile2 =
Path.Combine(frameworkPath2, "sdkManifest.xml");