Skip to content

Commit 20d5223

Browse files
committed
Handle bang
1 parent bb71e97 commit 20d5223

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

ReflectionAnalyzers.Tests/REFL001CastReturnValueTests/CodeFix.MethodInfoInvoke.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public static class MethodInfoInvoke
1414
[TestCase("typeof(C).GetMethod(nameof(M)).Invoke(null, null)")]
1515
[TestCase("typeof(C).GetMethod(nameof(M))!.Invoke(null, null)")]
1616
[TestCase("typeof(C).GetMethod(nameof(M))?.Invoke(null, null)")]
17-
//[TestCase("typeof(C).GetMethod(nameof(M))?.Invoke(null, null) ?? throw new Exception()")]
17+
[TestCase("typeof(C).GetMethod(nameof(M))?.Invoke(null, null)!")]
18+
[TestCase("typeof(C).GetMethod(nameof(M))?.Invoke(null, null) ?? throw new Exception()")]
1819
public static void AssigningLocal(string expression)
1920
{
2021
var before = @"

ReflectionAnalyzers/Helpers/Reflection/ReturnValue.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace ReflectionAnalyzers
22
{
33
using Microsoft.CodeAnalysis;
4+
using Microsoft.CodeAnalysis.CSharp;
45
using Microsoft.CodeAnalysis.CSharp.Syntax;
56

67
internal static class ReturnValue
@@ -20,6 +21,8 @@ internal static class ReturnValue
2021
when !IsDiscardName(variableDeclarator.Identifier.ValueText)
2122
=> candidate,
2223
ConditionalAccessExpressionSyntax conditionalAccess => Expression(conditionalAccess),
24+
BinaryExpressionSyntax { RawKind: (int)SyntaxKind.CoalesceExpression } coalesce => Expression(coalesce),
25+
PostfixUnaryExpressionSyntax { RawKind: (int)SyntaxKind.SuppressNullableWarningExpression } bang => Expression(bang),
2326
ArrowExpressionClauseSyntax => candidate,
2427
ReturnStatementSyntax => candidate,
2528
_ => null,

0 commit comments

Comments
 (0)