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
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix analyzer [RCS1202](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1202) ([PR](https://github.com/dotnet/roslynator/pull/1542))
- Fix analyzer [RCS1246](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1246) ([PR](https://github.com/dotnet/roslynator/pull/1543))
- Fix analyzer [RCS1140](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1140) ([PR](https://github.com/dotnet/roslynator/pull/1524))
- Fix analyzer [RCS1077](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1077) ([PR](https://github.com/dotnet/roslynator/pull/1544))

## [4.12.6] - 2024-09-23

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,14 @@ public static void AnalyzeOrderByIdentity(SyntaxNodeAnalysisContext context, in
if (lambdaExpression.Body is not IdentifierNameSyntax identifier || identifier.Identifier.Text != lambdaExpression.Parameter.Identifier.Text)
return;

if (context.SemanticModel
.GetTypeSymbol(invocationInfo.Expression, context.CancellationToken)?
.OriginalDefinition
.HasMetadataName(MetadataNames.System_Linq_IQueryable_T) == true)
{
return;
}

TextSpan span = TextSpan.FromBounds(invocationInfo.Name.SpanStart, invocationExpression.Span.End);
Report(context, invocationExpression, span, checkDirectives: true);
}
Expand Down
17 changes: 17 additions & 0 deletions src/Tests/Analyzers.Tests/RCS1077OptimizeLinqMethodCallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,23 @@ void M()
list.FirstOrDefault(predicate);
}
}
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.OptimizeLinqMethodCall)]
public async Task TestNoDiagnostic_OrderByToOrder_IQueryable()
{
await VerifyNoDiagnosticAsync(@"
using System.Linq;

class C
{
void M()
{
IQueryable<string> q = null;
var x = q.OrderBy(f => f);
}
}
");
}
}