You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See GitHub issue #590 . The following code snippet results in S1751 on the return statement. As the catch contains a way out, the loop exits and will reenter the while loop.
protected virtual FileStream CreateLock(string lockFileName, bool retries)
{
if (retries) ResetRetryTimeout();
FileStream filelock = null;
while (true) {
try {
filelock = new FileStream(lockFileName,
FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 8, FileOptions.DeleteOnClose);
return filelock;
} catch (Exception e) {
int code = System.Runtime.InteropServices.Marshal.GetHRForException(e);
if (code == unchecked((int)0x80070020) ||
code == unchecked((int)0x80070021)) {
// Sharing violation
if (!retries) return null;
if (!WaitRetryTimeout()) throw;
} else {
// All others are considered an error and we don't retry
throw;
}
}
};
}
Description
See GitHub issue #590 . The following code snippet results in S1751 on the return statement. As the catch contains a way out, the loop exits and will reenter the while loop.
Repro steps
See the code snippet above.
Expected behavior
Rule S1751 should not be raised
Actual behavior
S1751 is being raised as a false positive.
Known workarounds
None
Related information
The text was updated successfully, but these errors were encountered: