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
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix [RCS1164](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1164) ([#1196](https://github.com/JosefPihrt/Roslynator/pull/1196)).

## [4.5.0] - 2023-08-27

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public override void VisitBracketedParameterList(BracketedParameterListSyntax no

public override void VisitParameterList(ParameterListSyntax node)
{
if (node.IsParentKind(SyntaxKind.MethodDeclaration, SyntaxKind.LocalFunctionStatement))
if (node.IsParentKind(SyntaxKind.MethodDeclaration, SyntaxKind.LocalFunctionStatement, SyntaxKind.ParenthesizedLambdaExpression))
base.VisitParameterList(node);
}

Expand Down
45 changes: 45 additions & 0 deletions src/Tests/Analyzers.Tests/RCS1164UnusedTypeParameterTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Josef Pihrt and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Roslynator.CSharp.CodeFixes;
using Roslynator.Testing.CSharp;
using Xunit;

namespace Roslynator.CSharp.Analysis.Tests;

public class RCS1164UnusedTypeParameterTests : AbstractCSharpDiagnosticVerifier<UnusedParameter.UnusedParameterAnalyzer, UnusedParameterCodeFixProvider>
{
public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.UnusedTypeParameter;

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

public static class TestClass
{
public static void RunDelegate<T>(object arg)
{
RunDelegate(arg, (T arg) =>
{
if (arg is string stringArg)
{
Console.WriteLine(stringArg);
}
}
);
}

private static void RunDelegate(
object arg,
Delegate _delegate
)
{
_delegate.DynamicInvoke(arg);
}
}
");
}
}