Skip to content

Commit

Permalink
Disable MA0134 in Expression<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou committed Feb 7, 2024
1 parent 8e82029 commit 1708857
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ public override void Initialize(AnalysisContext context)
context.RegisterCompilationStartAction(context =>
{
var awaitableTypes = new AwaitableTypes(context.Compilation);
var operationUtilities = new OperationUtilities(context.Compilation);
context.RegisterSymbolStartAction(context =>
{
context.RegisterOperationAction(context => AnalyzeOperation(context, awaitableTypes), OperationKind.Invocation);
context.RegisterOperationAction(context => AnalyzeOperation(context, operationUtilities, awaitableTypes), OperationKind.Invocation);
}, SymbolKind.Method);
});
}

private static void AnalyzeOperation(OperationAnalysisContext context, AwaitableTypes awaitableTypes)
private static void AnalyzeOperation(OperationAnalysisContext context, OperationUtilities operationUtilities, AwaitableTypes awaitableTypes)
{
var operation = (IInvocationOperation)context.Operation;

Expand All @@ -49,6 +50,9 @@ private static void AnalyzeOperation(OperationAnalysisContext context, Awaitable

if (parent is null or IBlockOperation or IExpressionStatementOperation)
{
if (operationUtilities.IsInExpressionContext(operation))
return;

var semanticModel = operation.SemanticModel!;
var position = operation.Syntax.GetLocation().SourceSpan.End;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ private static void AnalyzeMethodSymbol(IMethodSymbol methodSymbol, INamedTypeSy
return;
}

var type = methodSymbol.Parameters[0].Type;

if (accessorKind is UnsafeAccessorKind.Field or UnsafeAccessorKind.StaticField && methodSymbol.ReturnsVoid)
{
diagnosticReporter.ReportDiagnostic(RuleInvalidSignature, methodSymbol, messageArgs: ["return type does not match the field type"]);
Expand Down Expand Up @@ -126,6 +124,7 @@ private static void AnalyzeMethodSymbol(IMethodSymbol methodSymbol, INamedTypeSy
}

// Roslyn doesn't expose private members from other assemblies
//var type = methodSymbol.Parameters[0].Type;
//switch (accessorKind)
//{
// case UnsafeAccessorKind.Method:
Expand Down

0 comments on commit 1708857

Please sign in to comment.