Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 0 additions & 201 deletions src/EFCore.Analyzers/NullableAttributes.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
Expand Down Expand Up @@ -173,23 +172,22 @@ internal static string GetReplacementMethodName(string oldName)
}

private static DiagnosticDescriptor? AnalyzeInvocation(IInvocationOperation invocation)
{
// ...an interpolated string
if (invocation.Arguments[1].Value is IInterpolatedStringOperation interpolatedString
&& AnalyzeInterpolatedString(interpolatedString))
=> invocation.Arguments[1].Value switch
{
return InterpolatedStringDescriptor;
}
// ...an interpolated string
IInterpolatedStringOperation interpolatedString when AnalyzeInterpolatedString(interpolatedString)
=> InterpolatedStringDescriptor,

// ...a string concatenation
if (TryGetStringConcatenation(invocation.Arguments[1].Value, out var concatenation)
&& AnalyzeConcatenation(concatenation))
{
return StringConcatenationDescriptor;
}
// ...a string concatenation
IBinaryOperation
{
OperatorKind: BinaryOperatorKind.Add,
Type.SpecialType: SpecialType.System_String,
} concatenation when AnalyzeConcatenation(concatenation)
=> StringConcatenationDescriptor,

return null;
}
_ => null,
};

private static bool AnalyzeInterpolatedString(IInterpolatedStringOperation interpolatedString)
{
Expand All @@ -215,22 +213,6 @@ private static bool AnalyzeInterpolatedString(IInterpolatedStringOperation inter
return false;
}

private static bool TryGetStringConcatenation(IOperation operation, [NotNullWhen(true)] out IBinaryOperation? concatenation)
{
if (operation is IBinaryOperation
{
OperatorKind: BinaryOperatorKind.Add,
Type.SpecialType: SpecialType.System_String,
} binaryOperation)
{
concatenation = binaryOperation;
return true;
}

concatenation = default;
return false;
}

private static bool AnalyzeConcatenation(IBinaryOperation operation)
{
var left = operation.LeftOperand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore;

using Verify = CSharpCodeFixVerifier<StringsUsageInRawQueriesDiagnosticAnalyzer, InterpolatedStringUsageInRawQueriesCodeFixProvider>;

public class StringInterpolationnRawQueriesAnalyzerTests
public class StringInterpolationInRawQueriesAnalyzerTests
{
public static readonly TheoryData<string> DoNotReportData =
[
Expand Down
Loading