-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IInvocationExpression and IArgument refinement and testing #11450
Changes from 19 commits
95eed9f
f09e703
22f4439
f8fcd33
8be60e4
8b915a8
ed039e1
e089f4e
c15bc77
da75981
b6e3d29
dcb51b2
4f358d6
6843108
297466f
a340980
f0805f9
4e5617e
4a94d83
dc65eaf
375839d
8a72012
5e97607
b1c39ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -486,14 +486,6 @@ public class InvocationTestAnalyzer : DiagnosticAnalyzer | |
DiagnosticSeverity.Warning, | ||
isEnabledByDefault: true); | ||
|
||
public static readonly DiagnosticDescriptor UseDefaultArgumentDescriptor = new DiagnosticDescriptor( | ||
"UseDefaultArgument", | ||
"Use default argument", | ||
"Invocation uses default argument {0}", | ||
ReliabilityCategory, | ||
DiagnosticSeverity.Warning, | ||
isEnabledByDefault: true); | ||
|
||
public static readonly DiagnosticDescriptor InvalidArgumentDescriptor = new DiagnosticDescriptor( | ||
"InvalidArgument", | ||
"Invalid argument", | ||
|
@@ -509,7 +501,6 @@ public sealed override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics | |
{ | ||
return ImmutableArray.Create(BigParamArrayArgumentsDescriptor, | ||
OutOfNumericalOrderArgumentsDescriptor, | ||
UseDefaultArgumentDescriptor, | ||
InvalidArgumentDescriptor); | ||
} | ||
} | ||
|
@@ -529,14 +520,9 @@ public sealed override void Initialize(AnalysisContext context) | |
return; | ||
} | ||
|
||
if (argument.ArgumentKind == ArgumentKind.DefaultValue) | ||
{ | ||
operationContext.ReportDiagnostic(Diagnostic.Create(UseDefaultArgumentDescriptor, invocation.Syntax.GetLocation(), argument.Parameter.Name)); | ||
} | ||
|
||
TestAscendingArgument(operationContext, argument.Value, ref priorArgumentValue); | ||
|
||
if (argument.ArgumentKind == ArgumentKind.ParamArray) | ||
if (argument.Parameter.IsParams) | ||
{ | ||
IArrayCreationExpression arrayArgument = argument.Value as IArrayCreationExpression; | ||
if (arrayArgument != null) | ||
|
@@ -1085,7 +1071,7 @@ public sealed override void Initialize(AnalysisContext context) | |
{ | ||
IInvocationExpression invocation = (IInvocationExpression)operationContext.Operation; | ||
|
||
foreach (IArgument argument in invocation.ArgumentsInSourceOrder) | ||
foreach (IArgument argument in invocation.ArgumentsInEvaluationOrder) | ||
{ | ||
if (argument.Parameter.IsParams) | ||
{ | ||
|
@@ -1777,7 +1763,7 @@ public override void Visit(IOperation operation) | |
} | ||
if (operation.Kind == OperationKind.Argument) | ||
{ | ||
if (((IArgument)operation).ArgumentKind == ArgumentKind.ParamArray) | ||
if (((IArgument)operation).Parameter.IsParams) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about intent here. ParameterSymbol.IsParams doesn't guarantee that the method was used in expanded form. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For purposes of this test, it doesn't matter whether the arguments were originally in array form or in expanded form. |
||
{ | ||
_paramsList.Add(operation); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about intent here. ParameterSymbol.IsParams doesn't guarantee that the method was used in expanded form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent is to analyzer arrays passed to params/ParamArray parameters in a uniform fashion whether the arguments were originally in array form or in expanded form.