We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It may happen that programmers write code as following:
public object SomeProperty { get; set; } public void DoSomething() { if (SomeProperty == null) { } if (SomeProperty is IAbc) { } if (SomeProperty is IXyz) { } }
This leads to race-conditions in case SomeProperty gets changed while being inside the method.
SomeProperty
Hence, they should assign the result of SomeProperty to a local variable and use that instead.
public object SomeProperty { get; set; } public void DoSomething() { var value = SomeProperty; if (value == null) { } if (value is IAbc) { } if (value is IXyz) { } }
The text was updated successfully, but these errors were encountered:
Same applies for code like:
public void DoSomething() { if (Abc.Def == null) { return; } foreach (var x in Abc.Def) { ... } }
where Abc.Def represents an access to some properties.
Abc.Def
Sorry, something went wrong.
We should also check for coalescending access, such as in: if (Abc?.Def?.Ghi != null)
if (Abc?.Def?.Ghi != null)
No branches or pull requests
It may happen that programmers write code as following:
This leads to race-conditions in case
SomeProperty
gets changed while being inside the method.Hence, they should assign the result of
SomeProperty
to a local variable and use that instead.The text was updated successfully, but these errors were encountered: