Skip to content

Commit

Permalink
Move SkipFieldsNotMatchingType validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthurvdv committed Dec 19, 2023
1 parent 644f04f commit 5a498f4
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Design/Rule0044AnalyzeTransferField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ private async void AnalyzeTransferFields(OperationAnalysisContext ctx)
if (ctx.Operation.Syntax.GetType() != typeof(InvocationExpressionSyntax))
return;

IArgument? skipFieldsNotMatchingTypeParam = ((IInvocationExpression)ctx.Operation).Arguments.Where(args => SemanticFacts.IsSameName(args.Parameter.Name, "SkipFieldsNotMatchingType")).SingleOrDefault() as IArgument;
if (skipFieldsNotMatchingTypeParam != null)
if (skipFieldsNotMatchingTypeParam.Value.ConstantValue.HasValue && (bool)skipFieldsNotMatchingTypeParam.Value.ConstantValue.Value) return;

InvocationExpressionSyntax invocationExpression = (InvocationExpressionSyntax)ctx.Operation.Syntax;

Tuple<string, string>? records = GetInvokingRecordNames(invocationExpression);
Expand Down Expand Up @@ -243,6 +239,8 @@ private void ReportFieldDiagnostics(SyntaxNodeAnalysisContext ctx, Table table,
if (invocationExpression.ArgumentList.Arguments.Count < 1)
return null;

if (invocationExpression.ArgumentList.Arguments.Count == 3 && invocationExpression.ArgumentList.Arguments[2].GetIdentifierOrLiteralValue() == "true") return null;

if (invocationExpression.Expression.GetType() == typeof(MemberAccessExpressionSyntax))
{
MemberAccessExpressionSyntax memberAccessExpression = (MemberAccessExpressionSyntax)invocationExpression.Expression;
Expand Down

0 comments on commit 5a498f4

Please sign in to comment.