Skip to content

Commit 3c6f1c1

Browse files
authored
Fix RCS1077 (#1023)
1 parent 5180806 commit 3c6f1c1

File tree

3 files changed

+6
-34
lines changed

3 files changed

+6
-34
lines changed

ChangeLog.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- [CLI] Add nullable reference type modifier when creating a list of symbols (`list-symbols` command) ([#1013](https://github.com/josefpihrt/roslynator/pull/1013)).
1515
- Add/remove blank line after file scoped namespace declaration ([RCS0060](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS0060.md)) ([#1014](https://github.com/josefpihrt/roslynator/pull/1014)).
1616
- Do not remove overriding member in record ([RCS1132](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1132.md)) ([#1015](https://github.com/josefpihrt/roslynator/pull/1015)).
17-
- Do not remove parameterless empty constructor in a struct with field initializers ([RCS1074](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1074.md)) ([#1020](https://github.com/josefpihrt/roslynator/pull/1020)).
18-
- Do not suggest to use generic event handler ([RCS1159](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1159.md)) ([#1019](https://github.com/josefpihrt/roslynator/pull/1019)).
17+
- Do not remove parameterless empty constructor in a struct with field initializers ([RCS1074](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1074.md)) ([#1021](https://github.com/josefpihrt/roslynator/pull/1021)).
18+
- Do not suggest to use generic event handler ([RCS1159](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1159.md)) ([#1022](https://github.com/josefpihrt/roslynator/pull/1022)).
19+
- Fix ([RCS1077](https://github.com/JosefPihrt/Roslynator/blob/main/docs/analyzers/RCS1077.md)) ([#1023](https://github.com/josefpihrt/roslynator/pull/1023)).
1920

2021
## [4.2.0] - 2022-11-27
2122

src/Analyzers/CSharp/Analysis/OptimizeLinqMethodCallAnalysis.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ public static void AnalyzeOfType(
454454
if (typeSymbol?.IsErrorType() != false)
455455
return;
456456

457+
if (!typeSymbol.IsValueType)
458+
return;
459+
457460
ITypeSymbol typeSymbol2 = semanticModel.GetTypeSymbol(invocationInfo.Expression, cancellationToken);
458461

459462
cancellationToken.ThrowIfCancellationRequested();

src/Tests/Analyzers.Tests/RCS1077OptimizeLinqMethodCallTests.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -389,38 +389,6 @@ void M()
389389
", source, expected);
390390
}
391391

392-
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.OptimizeLinqMethodCall)]
393-
public async Task Test_OptimizeOfType_ReferenceType()
394-
{
395-
await VerifyDiagnosticAndFixAsync(@"
396-
using System.Collections.Generic;
397-
using System.Linq;
398-
399-
class C
400-
{
401-
void M()
402-
{
403-
var items = new List<C>();
404-
405-
var q = items.[|OfType<C>()|];
406-
}
407-
}
408-
", @"
409-
using System.Collections.Generic;
410-
using System.Linq;
411-
412-
class C
413-
{
414-
void M()
415-
{
416-
var items = new List<C>();
417-
418-
var q = items.Where(f => f != null);
419-
}
420-
}
421-
");
422-
}
423-
424392
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.OptimizeLinqMethodCall)]
425393
public async Task Test_OptimizeOfType_ValueType()
426394
{

0 commit comments

Comments
 (0)