-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
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
CSIsNull002 - Bad code fix offered in Linq to sql expression #31
Comments
This is a bad example because the logic is wrong, but it does result in the error. |
This seems very similar to #3, and I'm surprised this is still a bug since that was supposedly fixed. |
@AArnott I ran into this again, are you able to have a look? |
@elachlan what version are you using? We have what looks like a test for this case already: CSharpIsNull/test/CSharpIsNullAnalyzer.Tests/CSIsNull002Tests.cs Lines 211 to 240 in 4f23ce0
I even added a new test with compound logic to match yours, but it still did not offer a [Fact]
public async Task NotEqualsNullInExpressionTree_ProducesNoDiagnostic()
{
string source = @"
using System;
using System.Linq.Expressions;
class Test
{
void Method(int o)
{
bool? b = true;
Expression<Func<bool>> e = () => (b != null || 3 < 5);
}
}";
await VerifyCS.VerifyAnalyzerAsync(source);
} Now, in that case, no diagnostic was created either, which isn't good and I'm looking into that. But it's not the issue you're reporting. |
#70 is the fix to what I found, but again, that isn't the issue you're reporting. |
I have a linq query from a DbContext with the following in the where clause:
toDate
is a nullable date. So we check it for null prior to doing a filter using it.CSIsNull002
matches to this and suggests is not null, but when the refactor is made, I get the error:The text was updated successfully, but these errors were encountered: