提交 228b604c 编写于 作者: G Gen Lu

Roll back implementation change made for c# IHasArgumentsExpression

Since we will try to repalce the logic with existing rewriter, it makes more sense to
minimize the code change here. Also removed the corresponding tests, will fix and add
them back after the implementation is finalized. As result, the contract for
IHasArgumentsExpression.ArgumentsInEvaluationOrder in C# is broken.
上级 cf82b8fb
......@@ -81,7 +81,7 @@
<Rule Id="RS0027" Action="Error" />
</Rules>
<Rules AnalyzerId="System.Collections.Immutable.Analyzers" RuleNamespace="System.Collections.Immutable.Analyzers">
<Rule Id="RS0012" Action="Warning" />
<Rule Id="RS0012" Action="None" />
</Rules>
<Rules AnalyzerId="System.Runtime.Analyzers" RuleNamespace="System.Runtime.Analyzers">
<Rule Id="CA1305" Action="None" />
......@@ -89,7 +89,7 @@
<Rule Id="CA1308" Action="None" />
<Rule Id="CA1810" Action="None" />
<Rule Id="CA1816" Action="None" />
<Rule Id="CA1825" Action="Warning" />
<Rule Id="CA1825" Action="None" />
<Rule Id="CA2002" Action="None" />
<Rule Id="CA2207" Action="None" />
<Rule Id="CA2208" Action="None" />
......@@ -97,7 +97,7 @@
<Rule Id="CA2219" Action="None" />
<Rule Id="CA2241" Action="None" />
<Rule Id="CA2242" Action="None" />
<Rule Id="RS0014" Action="Warning" />
<Rule Id="RS0014" Action="None" />
</Rules>
<Rules AnalyzerId="System.Runtime.InteropServices.Analyzers" RuleNamespace="System.Runtime.InteropServices.Analyzers">
<Rule Id="CA1401" Action="None" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Concurrent;
using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.Semantics;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.Collections;
namespace Microsoft.CodeAnalysis.CSharp
{
......@@ -63,8 +63,8 @@ internal partial class BoundCall : IInvocationExpression
(this.Method.IsVirtual || this.Method.IsAbstract || this.Method.IsOverride) &&
!this.ReceiverOpt.SuppressVirtualCalls;
ImmutableArray<IArgument> IHasArgumentsExpression.ArgumentsInEvaluationOrder
=> DeriveArgumentsInEvaluationOrder(this.Arguments, this.ArgumentNamesOpt, this.ArgsToParamsOpt, this.ArgumentRefKindsOpt, this.Method.Parameters, this.Syntax);
ImmutableArray<IArgument> IHasArgumentsExpression.ArgumentsInEvaluationOrder
=> DeriveArguments(this.Arguments, this.ArgumentNamesOpt, this.ArgsToParamsOpt, this.ArgumentRefKindsOpt, this.Method.Parameters, this.Syntax);
protected override OperationKind ExpressionKind => OperationKind.InvocationExpression;
......@@ -78,83 +78,56 @@ public override void Accept(OperationVisitor visitor)
return visitor.VisitInvocationExpression(this, argument);
}
internal static ImmutableArray<IArgument> DeriveArgumentsInEvaluationOrder(ImmutableArray<BoundExpression> boundArguments, ImmutableArray<string> argumentNames, ImmutableArray<int> argumentsToParameters, ImmutableArray<RefKind> argumentRefKinds, ImmutableArray<Symbols.ParameterSymbol> parameters, SyntaxNode invocationSyntax)
internal static ImmutableArray<IArgument> DeriveArguments(ImmutableArray<BoundExpression> boundArguments, ImmutableArray<string> argumentNamesOpt, ImmutableArray<int> argumentsToParametersOpt, ImmutableArray<RefKind> argumentRefKindsOpt, ImmutableArray<Symbols.ParameterSymbol> parameters, SyntaxNode invocationSyntax)
{
PooledHashSet<int> matchedParameters = PooledHashSet<int>.GetInstance();
ArrayBuilder<IArgument> evaluationOrderArguments = ArrayBuilder<IArgument>.GetInstance(parameters.Length);
ArrayBuilder<IArgument> sourceOrderArguments = ArrayBuilder<IArgument>.GetInstance(boundArguments.Length);
for (int argumentIndex = 0; argumentIndex < boundArguments.Length; argumentIndex++)
{
int parameterIndex = argumentsToParameters.IsDefault ? argumentIndex : argumentsToParameters[argumentIndex];
IArgument argument = DeriveArgument(parameterIndex, argumentIndex, boundArguments, argumentNames, argumentRefKinds, parameters, invocationSyntax);
evaluationOrderArguments.Add(argument);
matchedParameters.Add(parameterIndex);
// If the current argument matches a params parameter and is unnamed, following explicit arguments are treated as part of the params arrray.
if ((uint)parameterIndex < parameters.Length && parameters[parameterIndex].IsParams && (argumentNames.IsDefaultOrEmpty || argumentNames[argumentIndex] == null))
IArgument argument = DeriveArgument(argumentsToParametersOpt.IsDefault ? argumentIndex : argumentsToParametersOpt[argumentIndex], argumentIndex, boundArguments, argumentNamesOpt, argumentRefKindsOpt, parameters, invocationSyntax);
sourceOrderArguments.Add(argument);
if (argument.ArgumentKind == ArgumentKind.ParamArray)
{
break;
}
}
// Include implicit arguments after the explicit arguments.
foreach (Symbols.ParameterSymbol parameter in parameters)
{
if (!matchedParameters.Contains(parameter.Ordinal))
{
evaluationOrderArguments.Add(DeriveArgument(parameter.Ordinal, -1, boundArguments, argumentNames, argumentRefKinds, parameters, invocationSyntax));
}
}
matchedParameters.Free();
return evaluationOrderArguments.ToImmutableAndFree();
}
return sourceOrderArguments.ToImmutableAndFree();
}
private static readonly ConditionalWeakTable<BoundExpression, IArgument> s_argumentMappings = new ConditionalWeakTable<BoundExpression, IArgument>();
private static readonly ConditionalWeakTable<SyntaxNode, ConcurrentDictionary<Symbols.ParameterSymbol, IArgument>> s_omittedArgumentMappings = new ConditionalWeakTable<SyntaxNode, ConcurrentDictionary<Symbols.ParameterSymbol, IArgument>>();
private static IArgument DeriveArgument(int parameterIndex, int argumentIndex, ImmutableArray<BoundExpression> boundArguments, ImmutableArray<string> argumentNames, ImmutableArray<RefKind> argumentRefKinds, ImmutableArray<Symbols.ParameterSymbol> parameters, SyntaxNode invocationSyntax)
private static IArgument DeriveArgument(int parameterIndex, int argumentIndex, ImmutableArray<BoundExpression> boundArguments, ImmutableArray<string> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, ImmutableArray<Symbols.ParameterSymbol> parameters, SyntaxNode invocationSyntax)
{
if ((uint)argumentIndex >= (uint)boundArguments.Length)
{
ConcurrentDictionary<Symbols.ParameterSymbol, IArgument> omittedArguments = s_omittedArgumentMappings.GetValue(invocationSyntax, syntax => new ConcurrentDictionary<Symbols.ParameterSymbol, IArgument>());
return omittedArguments.GetOrAdd(
parameters[parameterIndex],
(parameter) =>
// Check for an omitted argument that becomes an empty params array.
if (parameters.Length > 0)
{
Symbols.ParameterSymbol lastParameter = parameters[parameters.Length - 1];
if (lastParameter.IsParams)
{
// No argument has been supplied for the parameter at `parameterIndex`:
// 1. `argumentIndex == -1' when the arguments are specified out of parameter order, and no argument is provided for the parameter corresponding to `parameters[parameterIndex]`.
// 2. `argumentIndex >= boundArguments.Length` when the arguments are specified in parameter order, and no argument is provided at `parameterIndex`.
// Check for a parameter with a default value.
if (parameter.HasExplicitDefaultValue)
{
return new Argument(ArgumentKind.DefaultValue, parameter, new LiteralExpression(parameter.ExplicitDefaultConstantValue, parameter.Type, invocationSyntax));
}
// Check for an omitted argument that becomes an empty params array.
if (parameter.IsParams)
{
return new Argument(ArgumentKind.ParamArray, parameter, CreateParamArray(parameter, boundArguments, argumentIndex, invocationSyntax));
}
return new Argument(ArgumentKind.ParamArray, lastParameter, CreateParamArray(lastParameter, boundArguments, argumentIndex, invocationSyntax));
}
}
// There is no supplied argument and there is no params parameter. Any action is suspect at this point.
return new Argument(ArgumentKind.DefaultValue, parameter, new InvalidExpression(invocationSyntax));
});
// There is no supplied argument and there is no params parameter. Any action is suspect at this point.
return new SimpleArgument(null, new InvalidExpression(invocationSyntax, ImmutableArray<IOperation>.Empty));
}
return s_argumentMappings.GetValue(
boundArguments[argumentIndex],
(argument) =>
{
string name = !argumentNames.IsDefaultOrEmpty ? argumentNames[argumentIndex] : null;
Symbols.ParameterSymbol parameter = (uint)parameterIndex < (uint)parameters.Length ? parameters[parameterIndex] : null;
string nameOpt = !argumentNamesOpt.IsDefaultOrEmpty ? argumentNamesOpt[argumentIndex] : null;
Symbols.ParameterSymbol parameterOpt = (uint)parameterIndex < (uint)parameters.Length ? parameters[parameterIndex] : null;
if ((object)name == null)
if ((object)nameOpt == null)
{
RefKind refMode = argumentRefKinds.IsDefaultOrEmpty ? RefKind.None : argumentRefKinds[argumentIndex];
RefKind refMode = argumentRefKindsOpt.IsDefaultOrEmpty ? RefKind.None : argumentRefKindsOpt[argumentIndex];
if (refMode != RefKind.None)
{
return new Argument(ArgumentKind.Explicit, parameter, argument);
return new Argument(ArgumentKind.Explicit, parameterOpt, argument);
}
if (argumentIndex >= parameters.Length - 1 &&
......@@ -162,36 +135,19 @@ private static IArgument DeriveArgument(int parameterIndex, int argumentIndex, I
parameters[parameters.Length - 1].IsParams &&
// An argument that is an array of the appropriate type is not a params argument.
(boundArguments.Length > argumentIndex + 1 ||
argument.Type.TypeKind != TypeKind.Array ||
!argument.Type.Equals(parameters[parameters.Length - 1].Type, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds)))
((object)argument.Type != null && // If argument type is null, we are in an error scenario and cannot tell if it is a param array, or not.
(argument.Type.TypeKind != TypeKind.Array ||
!argument.Type.Equals(parameters[parameters.Length - 1].Type, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds)))))
{
return new Argument(ArgumentKind.ParamArray, parameters[parameters.Length - 1], CreateParamArray(parameters[parameters.Length - 1], boundArguments, argumentIndex, invocationSyntax));
}
else
{
return new Argument(ArgumentKind.Explicit, parameter, argument);
return new SimpleArgument(parameterOpt, argument);
}
}
// A named argument which is also the only argument for a params parameter
// is a IArgument of ArgumentKind.ParamArray. e.g.
//
// static void M1(string[] args)
// {
// M2(array: 1, str: "");
// }
// static void M2(string str, params int[] array) { }
if (parameter?.IsParams == true &&
// An argument that is an array of the appropriate type is not a params argument.
(argument.Type.TypeKind != TypeKind.Array ||
!argument.Type.Equals(parameter.Type, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds)))
{
Debug.Assert(parameterIndex == parameters.Length - 1);
return new Argument(ArgumentKind.ParamArray, parameter, CreateParamArray(parameter, argument));
}
return new Argument(ArgumentKind.Explicit, parameter, argument);
return new Argument(ArgumentKind.Explicit, parameterOpt, argument);
});
}
......@@ -200,23 +156,15 @@ private static IOperation CreateParamArray(IParameterSymbol parameter, Immutable
if (parameter.Type.TypeKind == TypeKind.Array)
{
IArrayTypeSymbol arrayType = (IArrayTypeSymbol)parameter.Type;
ImmutableArray<IOperation> paramArrayArguments;
// If there are no matching arguments, then the argument index is negative.
if (firstArgumentElementIndex >= 0)
ArrayBuilder<IOperation> builder = ArrayBuilder<IOperation>.GetInstance(boundArguments.Length - firstArgumentElementIndex);
for (int index = firstArgumentElementIndex; index < boundArguments.Length; index++)
{
ArrayBuilder<IOperation> builder = ArrayBuilder<IOperation>.GetInstance(boundArguments.Length - firstArgumentElementIndex);
for (int index = firstArgumentElementIndex; index < boundArguments.Length; index++)
{
builder.Add(boundArguments[index]);
}
paramArrayArguments = builder.ToImmutableAndFree();
}
else
{
paramArrayArguments = ImmutableArray<IOperation>.Empty;
builder.Add(boundArguments[index]);
}
var paramArrayArguments = builder.ToImmutableAndFree();
// Use the invocation syntax node if there is no actual syntax available for the argument (because the paramarray is empty.)
return new ArrayCreationExpression(arrayType, paramArrayArguments, paramArrayArguments.Length > 0 ? paramArrayArguments[0].Syntax : invocationSyntax);
}
......@@ -224,34 +172,43 @@ private static IOperation CreateParamArray(IParameterSymbol parameter, Immutable
return new InvalidExpression(invocationSyntax, ImmutableArray<IOperation>.Empty);
}
private static IOperation CreateParamArray(IParameterSymbol parameter, BoundExpression boundArgument)
internal static IArgument ArgumentMatchingParameter(ImmutableArray<BoundExpression> arguments, ImmutableArray<int> argumentsToParametersOpt, ImmutableArray<string> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, ISymbol targetMethod, ImmutableArray<Symbols.ParameterSymbol> parameters, IParameterSymbol parameter, SyntaxNode invocationSyntax)
{
var Syntax = boundArgument.Syntax;
if (parameter.Type.TypeKind == TypeKind.Array)
int argumentIndex = ArgumentIndexMatchingParameter(argumentsToParametersOpt, targetMethod, parameter);
if (argumentIndex >= 0)
{
IArrayTypeSymbol arrayType = (IArrayTypeSymbol)parameter.Type;
ImmutableArray<IOperation> paramArrayArguments = ImmutableArray.Create<IOperation>(boundArgument);
return DeriveArgument(parameter.Ordinal, argumentIndex, arguments, argumentNamesOpt, argumentRefKindsOpt, parameters, invocationSyntax);
}
Debug.Assert(boundArgument.Syntax != null);
return new ArrayCreationExpression(arrayType, paramArrayArguments, Syntax);
return null;
}
private static int ArgumentIndexMatchingParameter(ImmutableArray<int> argumentsToParametersOpt, ISymbol targetMethod, IParameterSymbol parameter)
{
if (parameter.ContainingSymbol == targetMethod)
{
int parameterIndex = parameter.Ordinal;
if (!argumentsToParametersOpt.IsDefaultOrEmpty)
{
return argumentsToParametersOpt.IndexOf(parameterIndex);
}
return parameterIndex;
}
return new InvalidExpression(Syntax);
return -1;
}
private class Argument : IArgument
private abstract class ArgumentBase : IArgument
{
public Argument(ArgumentKind kind, IParameterSymbol parameter, IOperation value)
public ArgumentBase(IParameterSymbol parameter, IOperation value)
{
Debug.Assert(value != null);
this.ArgumentKind = kind;
this.Value = value;
this.Parameter = parameter;
}
public ArgumentKind ArgumentKind { get; }
public IParameterSymbol Parameter { get; }
public IOperation Value { get; }
......@@ -270,6 +227,8 @@ public Argument(ArgumentKind kind, IParameterSymbol parameter, IOperation value)
public Optional<object> ConstantValue => default(Optional<object>);
public abstract ArgumentKind ArgumentKind { get; }
void IOperation.Accept(OperationVisitor visitor)
{
visitor.VisitArgument(this);
......@@ -280,6 +239,26 @@ void IOperation.Accept(OperationVisitor visitor)
return visitor.VisitArgument(this, argument);
}
}
private sealed class SimpleArgument : ArgumentBase
{
public SimpleArgument(IParameterSymbol parameter, IOperation value)
: base(parameter, value)
{ }
public override ArgumentKind ArgumentKind => ArgumentKind.Explicit;
}
private sealed class Argument : ArgumentBase
{
public Argument(ArgumentKind kind, IParameterSymbol parameter, IOperation value)
: base(parameter, value)
{
this.ArgumentKind = kind;
}
public override ArgumentKind ArgumentKind { get; }
}
}
internal partial class BoundLocal : ILocalReferenceExpression
......@@ -349,8 +328,7 @@ internal partial class BoundIndexerAccess : IIndexedPropertyReferenceExpression
ISymbol IMemberReferenceExpression.Member => this.Indexer;
ImmutableArray<IArgument> IHasArgumentsExpression.ArgumentsInEvaluationOrder
=> BoundCall.DeriveArgumentsInEvaluationOrder(this.Arguments, this.ArgumentNamesOpt, this.ArgsToParamsOpt, this.ArgumentRefKindsOpt, this.Indexer.Parameters, this.Syntax);
ImmutableArray<IArgument> IHasArgumentsExpression.ArgumentsInEvaluationOrder => BoundCall.DeriveArguments(this.Arguments, this.ArgumentNamesOpt, this.ArgsToParamsOpt, this.ArgumentRefKindsOpt, this.Indexer.Parameters, this.Syntax);
protected override OperationKind ExpressionKind => OperationKind.IndexedPropertyReferenceExpression;
......@@ -506,8 +484,7 @@ internal partial class BoundObjectCreationExpression : IObjectCreationExpression
IMethodSymbol IObjectCreationExpression.Constructor => this.Constructor;
ImmutableArray<IArgument> IHasArgumentsExpression.ArgumentsInEvaluationOrder
=> BoundCall.DeriveArgumentsInEvaluationOrder(this.Arguments, this.ArgumentNamesOpt, this.ArgsToParamsOpt, this.ArgumentRefKindsOpt, this.Constructor.Parameters, this.Syntax);
ImmutableArray<IArgument> IHasArgumentsExpression.ArgumentsInEvaluationOrder => BoundCall.DeriveArguments(this.Arguments, this.ArgumentNamesOpt, this.ArgsToParamsOpt, this.ArgumentRefKindsOpt, this.Constructor.Parameters, this.Syntax);
ImmutableArray<ISymbolInitializer> IObjectCreationExpression.MemberInitializers
{
......@@ -1909,7 +1886,7 @@ public override void Accept(OperationVisitor visitor)
return visitor.VisitNoneOperation(this, argument);
}
}
internal partial class BoundSourceDocumentIndex
{
protected override OperationKind ExpressionKind => OperationKind.None;
......
......@@ -280,7 +280,7 @@ public void M1(int x, int y)
Diagnostic(SwitchTestAnalyzer.NoDefaultSwitchDescriptor.Id, "y").WithLocation(40, 17));
}
[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/18549")]
public void InvocationCSharp()
{
const string source = @"
......@@ -753,7 +753,7 @@ interface IDerived : IMiddle, IBase2
);
}
[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/18549")]
public void ValueContextsCSharp()
{
const string source = @"
......@@ -1167,7 +1167,7 @@ private void Mumbler(object sender, System.EventArgs args)
);
}
[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/18549")]
public void ParamsArraysCSharp()
{
const string source = @"
......@@ -1627,7 +1627,7 @@ static void Main()
}
[WorkItem(8520, "https://github.com/dotnet/roslyn/issues/8520")]
[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/18549")]
public void NullOperationSyntaxCSharp()
{
const string source = @"
......@@ -1724,9 +1724,8 @@ public void Increment(string f)
Diagnostic(InvalidOperatorExpressionTestAnalyzer.InvalidUnaryDescriptor.Id, "-f").WithLocation(11, 16),
Diagnostic(InvalidOperatorExpressionTestAnalyzer.InvalidIncrementDescriptor.Id, "f++").WithLocation(16, 9));
}
[WorkItem(9114, "https://github.com/dotnet/roslyn/issues/9114")]
[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/18549"), WorkItem(9114, "https://github.com/dotnet/roslyn/issues/9114")]
public void InvalidArgumentCSharp()
{
const string source = @"
......@@ -1815,7 +1814,7 @@ public void M0(C p)
}
[WorkItem(9116, "https://github.com/dotnet/roslyn/issues/9116")]
[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/18549")]
public void LiteralCSharp()
{
const string source = @"
......
......@@ -45,15 +45,15 @@ static void Test2(int y, params int[] x)
compilation.VerifyOperationTree(nodes[0], expectedOperationTree:
@"IInvocationExpression (static void Cls.Test1(params System.Int32[] x)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Test1(null)')
Arguments(1): IArgument (Matching Parameter: x) (OperationKind.Argument) (Syntax: 'null')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: 'null')
IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Int32[], Constant: null) (Syntax: 'null')
ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null')");
compilation.VerifyOperationTree(nodes[1], expectedOperationTree:
@"IInvocationExpression (static void Cls.Test2(System.Int32 y, params System.Int32[] x)) (OperationKind.InvocationExpression, Type: System.Void, IsInvalid) (Syntax: 'Test2(new o ... ct(), null)')
Arguments(2): IArgument (Matching Parameter: y) (OperationKind.Argument) (Syntax: 'new object()')
Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: y) (OperationKind.Argument) (Syntax: 'new object()')
IObjectCreationExpression (Constructor: System.Object..ctor()) (OperationKind.ObjectCreationExpression, Type: System.Object) (Syntax: 'new object()')
IArgument (Matching Parameter: x) (OperationKind.Argument) (Syntax: 'null')
IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: 'null')
ILiteralExpression (Text: null) (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'null')");
}
......
......@@ -164,12 +164,12 @@ private void M()
Right: ILiteralExpression (Text: 20) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 20) (Syntax: '20')
IfTrue: IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.WriteLine(m);')
IInvocationExpression (static void System.Console.WriteLine(System.Int32 value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.WriteLine(m)')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: 'm')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'm')
ILocalReferenceExpression: m (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'm')
IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.WriteLine(n);')
IInvocationExpression (static void System.Console.WriteLine(System.Int32 value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.WriteLine(n)')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: 'n')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'n')
ILocalReferenceExpression: n (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'n')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -212,12 +212,12 @@ private void M()
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.WriteLine(m);')
IInvocationExpression (static void System.Console.WriteLine(System.Int32 value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.WriteLine(m)')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: 'm')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'm')
ILocalReferenceExpression: m (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'm')
IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.WriteLine(n);')
IInvocationExpression (static void System.Console.WriteLine(System.Int32 value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.WriteLine(n)')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: 'n')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'n')
ILocalReferenceExpression: n (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'n')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -256,7 +256,7 @@ private void M()
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... than m."");')
IInvocationExpression (static void System.Console.WriteLine(System.String value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... r than m."")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '""Nothing is ... er than m.""')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '""Nothing is ... er than m.""')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: ""Nothing is larger than m."") (Syntax: '""Nothing is ... er than m.""')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -299,7 +299,7 @@ private void M()
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... ""Result1"");')
IInvocationExpression (static void System.Console.WriteLine(System.String value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... (""Result1"")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '""Result1""')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '""Result1""')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: ""Result1"") (Syntax: '""Result1""')
IfFalse: IIfStatement (OperationKind.IfStatement) (Syntax: 'if (m > 10) ... }')
Condition: IBinaryOperatorExpression (BinaryOperationKind.IntegerGreaterThan) (OperationKind.BinaryOperatorExpression, Type: System.Boolean) (Syntax: 'm > 10')
......@@ -308,12 +308,12 @@ private void M()
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... ""Result2"");')
IInvocationExpression (static void System.Console.WriteLine(System.String value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... (""Result2"")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '""Result2""')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '""Result2""')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: ""Result2"") (Syntax: '""Result2""')
IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... ""Result3"");')
IInvocationExpression (static void System.Console.WriteLine(System.String value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... (""Result3"")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '""Result3""')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '""Result3""')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: ""Result3"") (Syntax: '""Result3""')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -341,17 +341,17 @@ private void M()
string expectedOperationTree = @"
IIfStatement (OperationKind.IfStatement) (Syntax: 'if (int.Try ... s ={ s}"");')
Condition: IInvocationExpression (static System.Boolean System.Int32.TryParse(System.String s, out System.Int32 result)) (OperationKind.InvocationExpression, Type: System.Boolean) (Syntax: 'int.TryPars ... out var i)')
Arguments(2): IArgument (Matching Parameter: s) (OperationKind.Argument) (Syntax: 's')
Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: s) (OperationKind.Argument) (Syntax: 's')
ILocalReferenceExpression: s (OperationKind.LocalReferenceExpression, Type: System.String) (Syntax: 's')
IArgument (Matching Parameter: result) (OperationKind.Argument) (Syntax: 'var i')
IArgument (ArgumentKind.Explicit, Matching Parameter: result) (OperationKind.Argument) (Syntax: 'var i')
ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'var i')
IfTrue: IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'System.Cons ... s ={ s}"");')
IInvocationExpression (static void System.Console.WriteLine(System.String value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'System.Cons ... , s ={ s}"")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '$""i ={ i}, s ={ s}""')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '$""i ={ i}, s ={ s}""')
IOperation: (OperationKind.None) (Syntax: '$""i ={ i}, s ={ s}""')
IfFalse: IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'System.Cons ... s ={ s}"");')
IInvocationExpression (static void System.Console.WriteLine(System.String value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'System.Cons ... , s ={ s}"")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '$""i ={ i}, s ={ s}""')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '$""i ={ i}, s ={ s}""')
IOperation: (OperationKind.None) (Syntax: '$""i ={ i}, s ={ s}""')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -390,7 +390,7 @@ private int A()
Condition: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true')
IfTrue: IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'System.Cons ... eLine(A());')
IInvocationExpression (static void System.Console.WriteLine(System.Int32 value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'System.Cons ... teLine(A())')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: 'A()')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'A()')
IInvocationExpression ( System.Int32 P.A()) (OperationKind.InvocationExpression, Type: System.Int32) (Syntax: 'A()')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'A')
";
......@@ -430,11 +430,11 @@ private void A(bool flag)
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'A(int.TryPa ... ut var i));')
IInvocationExpression ( void P.A(System.Boolean flag)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'A(int.TryPa ... out var i))')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'A')
Arguments(1): IArgument (Matching Parameter: flag) (OperationKind.Argument) (Syntax: 'int.TryPars ... out var i)')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: flag) (OperationKind.Argument) (Syntax: 'int.TryPars ... out var i)')
IInvocationExpression (static System.Boolean System.Int32.TryParse(System.String s, out System.Int32 result)) (OperationKind.InvocationExpression, Type: System.Boolean) (Syntax: 'int.TryPars ... out var i)')
Arguments(2): IArgument (Matching Parameter: s) (OperationKind.Argument) (Syntax: 's')
Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: s) (OperationKind.Argument) (Syntax: 's')
ILocalReferenceExpression: s (OperationKind.LocalReferenceExpression, Type: System.String) (Syntax: 's')
IArgument (Matching Parameter: result) (OperationKind.Argument) (Syntax: 'var i')
IArgument (ArgumentKind.Explicit, Matching Parameter: result) (OperationKind.Argument) (Syntax: 'var i')
ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'var i')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -471,9 +471,9 @@ private static void A(bool flag, int number)
Locals: Local_1: System.Int32 i
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'A(o is int i, 1);')
IInvocationExpression (static void Program.A(System.Boolean flag, System.Int32 number)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'A(o is int i, 1)')
Arguments(2): IArgument (Matching Parameter: flag) (OperationKind.Argument) (Syntax: 'o is int i')
Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: flag) (OperationKind.Argument) (Syntax: 'o is int i')
IOperation: (OperationKind.None) (Syntax: 'o is int i')
IArgument (Matching Parameter: number) (OperationKind.Argument) (Syntax: '1')
IArgument (ArgumentKind.Explicit, Matching Parameter: number) (OperationKind.Argument) (Syntax: '1')
ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -506,7 +506,7 @@ private void M()
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.WriteLine(str);')
IInvocationExpression (static void System.Console.WriteLine(System.String value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.WriteLine(str)')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: 'str')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'str')
ILocalReferenceExpression: str (OperationKind.LocalReferenceExpression, Type: System.String) (Syntax: 'str')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -539,7 +539,7 @@ private static void A(object o)
Condition: ILiteralExpression (OperationKind.LiteralExpression, Type: System.Boolean, Constant: True) (Syntax: 'true')
IfTrue: IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'A(25);')
IInvocationExpression (static void Program.A(System.Object o)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'A(25)')
Arguments(1): IArgument (Matching Parameter: o) (OperationKind.Argument) (Syntax: '25')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: o) (OperationKind.Argument) (Syntax: '25')
IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: '25')
ILiteralExpression (Text: 25) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 25) (Syntax: '25')
";
......@@ -579,9 +579,9 @@ private static void A(bool flag, int number)
Locals: Local_1: System.Int32 i
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'A(o is int i, 1);')
IInvocationExpression (static void Program.A(System.Boolean flag, System.Int32 number)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'A(o is int i, 1)')
Arguments(2): IArgument (Matching Parameter: flag) (OperationKind.Argument) (Syntax: 'o is int i')
Arguments(2): IArgument (ArgumentKind.Explicit, Matching Parameter: flag) (OperationKind.Argument) (Syntax: 'o is int i')
IOperation: (OperationKind.None) (Syntax: 'o is int i')
IArgument (Matching Parameter: number) (OperationKind.Argument) (Syntax: '1')
IArgument (ArgumentKind.Explicit, Matching Parameter: number) (OperationKind.Argument) (Syntax: '1')
ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -615,7 +615,7 @@ private void M()
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.WriteLine(str);')
IInvocationExpression (static void System.Console.WriteLine(System.String value)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.WriteLine(str)')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: 'str')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'str')
ILocalReferenceExpression: str (OperationKind.LocalReferenceExpression, Type: System.String) (Syntax: 'str')
IfFalse: IExpressionStatement (OperationKind.ExpressionStatement, IsInvalid) (Syntax: '')
IInvalidExpression (OperationKind.InvalidExpression, Type: ?, IsInvalid) (Syntax: '')
......@@ -800,7 +800,7 @@ class C
Right: IInvocationExpression (virtual System.Boolean System.ValueType.Equals(System.Object obj)) (OperationKind.InvocationExpression, Type: System.Boolean) (Syntax: '((T)d).Equals(x)')
Instance Receiver: IConversionExpression (ConversionKind.CSharp, Explicit) (OperationKind.ConversionExpression, Type: T) (Syntax: '(T)d')
IParameterReferenceExpression: d (OperationKind.ParameterReferenceExpression, Type: dynamic) (Syntax: 'd')
Arguments(1): IArgument (Matching Parameter: obj) (OperationKind.Argument) (Syntax: 'x')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: obj) (OperationKind.Argument) (Syntax: 'x')
IConversionExpression (ConversionKind.Cast, Implicit) (OperationKind.ConversionExpression, Type: System.Object) (Syntax: 'x')
IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: T) (Syntax: 'x')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: '{ ... }')
......
......@@ -303,7 +303,7 @@ class C
string expectedOperationTree = @"
IFieldInitializer (Field: System.Action C.e) (OperationKind.FieldInitializerAtDeclaration) (Syntax: '= MakeAction(1)')
IInvocationExpression (static System.Action C.MakeAction(System.Int32 x)) (OperationKind.InvocationExpression, Type: System.Action) (Syntax: 'MakeAction(1)')
Arguments(1): IArgument (Matching Parameter: x) (OperationKind.Argument) (Syntax: '1')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: '1')
ILiteralExpression (Text: 1) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 1) (Syntax: '1')
";
var expectedDiagnostics = DiagnosticDescription.None;
......@@ -325,7 +325,7 @@ class C
string expectedOperationTree = @"
IFieldInitializer (Field: System.Action C.f) (OperationKind.FieldInitializerAtDeclaration) (Syntax: '= MakeAction(2)')
IInvocationExpression (static System.Action C.MakeAction(System.Int32 x)) (OperationKind.InvocationExpression, Type: System.Action) (Syntax: 'MakeAction(2)')
Arguments(1): IArgument (Matching Parameter: x) (OperationKind.Argument) (Syntax: '2')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: '2')
ILiteralExpression (Text: 2) (OperationKind.LiteralExpression, Type: System.Int32, Constant: 2) (Syntax: '2')
";
var expectedDiagnostics = DiagnosticDescription.None;
......
......@@ -60,7 +60,7 @@ void F(int x)
string expectedOperationTree = @"
IInvocationExpression ( void Program.F(System.Int32 x)) (OperationKind.InvocationExpression, Type: System.Void, IsInvalid) (Syntax: 'F(string.Empty)')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: Program) (Syntax: 'F')
Arguments(1): IArgument (Matching Parameter: x) (OperationKind.Argument) (Syntax: 'string.Empty')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: 'string.Empty')
IFieldReferenceExpression: System.String System.String.Empty (Static) (OperationKind.FieldReferenceExpression, Type: System.String) (Syntax: 'string.Empty')
";
var expectedDiagnostics = new DiagnosticDescription[] {
......
......@@ -169,7 +169,7 @@ Public MustInherit Class SemanticModelTestBase : Inherits BasicTestBase
Friend Function GetOperationTreeForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, Optional compilationOptions As VisualBasicCompilationOptions = Nothing, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0) As String
Dim fileName = "a.vb"
Dim syntaxTree = Parse(testSrc, fileName, parseOptions)
Dim compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, references:={SystemRef, SystemCoreRef}, options:=If(compilationOptions, TestOptions.ReleaseDll))
Dim compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, references:=DefaultVbReferences, options:=If(compilationOptions, TestOptions.ReleaseDll))
Return GetOperationTreeForTest(Of TSyntaxNode)(compilation, fileName, which)
End Function
......@@ -196,7 +196,7 @@ Public MustInherit Class SemanticModelTestBase : Inherits BasicTestBase
Friend Sub VerifyOperationTreeAndDiagnosticsForTest(Of TSyntaxNode As SyntaxNode)(testSrc As String, expectedOperationTree As String, expectedDiagnostics As String, Optional compilationOptions As VisualBasicCompilationOptions = Nothing, Optional parseOptions As VisualBasicParseOptions = Nothing, Optional which As Integer = 0)
Dim fileName = "a.vb"
Dim syntaxTree = Parse(testSrc, fileName, parseOptions)
Dim compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, references:={SystemRef, SystemCoreRef}, options:=If(compilationOptions, TestOptions.ReleaseDll))
Dim compilation = CreateCompilationWithMscorlib45AndVBRuntime({syntaxTree}, references:=DefaultVbReferences, options:=If(compilationOptions, TestOptions.ReleaseDll))
VerifyOperationTreeAndDiagnosticsForTest(Of TSyntaxNode)(compilation, fileName, expectedOperationTree, expectedDiagnostics, which)
End Sub
......
......@@ -96,9 +96,9 @@
<Compile Include="Diagnostics\DiagnosticAnalyzerTests.vb" />
<Compile Include="Diagnostics\DiagnosticTests.vb" />
<Compile Include="Diagnostics\GetDiagnosticsTests.vb" />
<Compile Include="IOperation\IOperationTests_IArgument.vb" />
<Compile Include="IOperation\IOperationTests_InvalidStatement.vb" />
<Compile Include="IOperation\IOperationTests_InvalidExpression.vb" />
<Compile Include="IOperation\IOperationTests_IArgument.vb" />
<Compile Include="IOperation\IOperationTests_IBlockStatement_MethodBlocks.vb" />
<Compile Include="IOperation\IOperationTests_IIfStatement.vb" />
<Compile Include="IOperation\IOperationTests_ISymbolInitializer.vb" />
......
......@@ -306,13 +306,17 @@ End Class
Dim comp = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(source, parseOptions:=TestOptions.RegularWithIOperationFeature)
comp.VerifyDiagnostics()
comp.VerifyAnalyzerDiagnostics({New InvocationTestAnalyzer}, Nothing, Nothing, False,
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "2").WithLocation(11, 21),
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "1").WithLocation(12, 15),
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "2").WithLocation(12, 21),
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "4").WithLocation(12, 33),
Diagnostic(InvocationTestAnalyzer.BigParamArrayArgumentsDescriptor.Id, "M0(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)").WithLocation(14, 9),
Diagnostic(InvocationTestAnalyzer.BigParamArrayArgumentsDescriptor.Id, "M0(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)").WithLocation(15, 9),
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "3").WithLocation(17, 21))
Diagnostic(InvocationTestAnalyzer.UseDefaultArgumentDescriptor.Id, "M3(Nothing,)").WithArguments("b").WithLocation(25, 9),
Diagnostic(InvocationTestAnalyzer.UseDefaultArgumentDescriptor.Id, "M3(,0)").WithArguments("a").WithLocation(26, 9),
Diagnostic(InvocationTestAnalyzer.UseDefaultArgumentDescriptor.Id, "M3(,)").WithArguments("a").WithLocation(27, 9),
Diagnostic(InvocationTestAnalyzer.UseDefaultArgumentDescriptor.Id, "M3(,)").WithArguments("b").WithLocation(27, 9),
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "2").WithLocation(11, 21),
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "4").WithLocation(12, 33),
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "2").WithLocation(12, 21),
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "1").WithLocation(12, 15),
Diagnostic(InvocationTestAnalyzer.BigParamArrayArgumentsDescriptor.Id, "M0(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)").WithLocation(14, 9),
Diagnostic(InvocationTestAnalyzer.BigParamArrayArgumentsDescriptor.Id, "M0(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)").WithLocation(15, 9),
Diagnostic(InvocationTestAnalyzer.OutOfNumericalOrderArgumentsDescriptor.Id, "3").WithLocation(17, 21))
End Sub
<Fact>
......@@ -1216,12 +1220,8 @@ End Class
comp.VerifyDiagnostics()
comp.VerifyAnalyzerDiagnostics({New ParamsArrayTestAnalyzer}, Nothing, Nothing, False,
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "M0(1, 2, 3, 4, 5)").WithLocation(9, 9),
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "M0(1, 2, 3, 4, 5)").WithLocation(9, 9),
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "M0(1, 2, 3, 4, 5, 6)").WithLocation(10, 9),
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "M0(1, 2, 3, 4, 5, 6)").WithLocation(10, 9),
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "New Integer() { 2, 3, 4, 5 }").WithLocation(12, 15),
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "New Integer() { 2, 3, 4, 5 }").WithLocation(12, 15),
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "New Integer() { 2, 3, 4, 5, 6 }").WithLocation(13, 15),
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "New Integer() { 2, 3, 4, 5, 6 }").WithLocation(13, 15),
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "D").WithLocation(14, 30),
Diagnostic(ParamsArrayTestAnalyzer.LongParamsDescriptor.Id, "New Integer() { 2, 3, 4, 5 }").WithLocation(15, 26))
......@@ -1781,10 +1781,7 @@ End Class
comp.VerifyAnalyzerDiagnostics({New NullOperationSyntaxTestAnalyzer}, Nothing, Nothing, False,
Diagnostic(NullOperationSyntaxTestAnalyzer.ParamsArrayOperationDescriptor.Id, "M0()").WithLocation(6, 9),
Diagnostic(NullOperationSyntaxTestAnalyzer.ParamsArrayOperationDescriptor.Id, "M0(1)").WithLocation(7, 9),
Diagnostic(NullOperationSyntaxTestAnalyzer.ParamsArrayOperationDescriptor.Id, "M0(1, 2)").WithLocation(8, 9),
Diagnostic(NullOperationSyntaxTestAnalyzer.ParamsArrayOperationDescriptor.Id, "New Integer() { }").WithLocation(9, 12),
Diagnostic(NullOperationSyntaxTestAnalyzer.ParamsArrayOperationDescriptor.Id, "New Integer() { 1 }").WithLocation(10, 12),
Diagnostic(NullOperationSyntaxTestAnalyzer.ParamsArrayOperationDescriptor.Id, "New Integer() { 1, 2 }").WithLocation(11, 12))
Diagnostic(NullOperationSyntaxTestAnalyzer.ParamsArrayOperationDescriptor.Id, "M0(1, 2)").WithLocation(8, 9))
End Sub
<WorkItem(8114, "https://github.com/dotnet/roslyn/issues/8114")>
......
......@@ -238,7 +238,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If x <> 0 T ... End If')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If x <> 0 T ... End If')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'System.Console.Write(x)')
IInvocationExpression (static Sub System.Console.Write(value As System.Int32)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'System.Console.Write(x)')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: 'x')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'x')
IParameterReferenceExpression: x (OperationKind.ParameterReferenceExpression, Type: System.Int32) (Syntax: 'x')
]]>.Value
......@@ -275,7 +275,7 @@ IForLoopStatement (LoopKind.For) (OperationKind.LoopStatement) (Syntax: 'For i =
Body: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'For i = 0 T ... Next')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'System.Console.Write(i)')
IInvocationExpression (static Sub System.Console.Write(value As System.Int32)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'System.Console.Write(i)')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: 'i')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: 'i')
ILocalReferenceExpression: i (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'i')
]]>.Value
......@@ -331,7 +331,7 @@ BC30581: 'AddressOf' expression cannot be converted to 'Integer' because 'Intege
comp.VerifyOperationTree(nodes(0), expectedOperationTree:=
"IInvocationExpression (static Sub Module1.Test1(ParamArray x As System.Int32())) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Test1(Nothing)')
Arguments(1): IArgument (Matching Parameter: x) (OperationKind.Argument) (Syntax: 'Nothing')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: 'Nothing')
IConversionExpression (ConversionKind.Basic, Implicit) (OperationKind.ConversionExpression, Type: System.Int32(), Constant: null) (Syntax: 'Nothing')
ILiteralExpression (OperationKind.LiteralExpression, Type: null, Constant: null) (Syntax: 'Nothing')")
......
......@@ -300,12 +300,12 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If (m > 10) ... End If')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If (n > 20) ... End If')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... "Result 1")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... "Result 1")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result 1"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result 1"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result 1") (Syntax: '"Result 1"')
IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'Else ... "Result 2")')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... "Result 2")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... "Result 2")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result 2"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result 2"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result 2") (Syntax: '"Result 2"')
]]>.Value
......@@ -348,12 +348,12 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If (m > 10) ... End If')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If (n > 20) ... End If')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... "Result 1")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... "Result 1")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result 1"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result 1"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result 1") (Syntax: '"Result 1"')
IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'Else ... "Result 2")')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... "Result 2")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... "Result 2")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result 2"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result 2"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result 2") (Syntax: '"Result 2"')
]]>.Value
......@@ -391,7 +391,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If (m >= n ... End If')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If (m >= n ... End If')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... r than m.")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... r than m.")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Nothing Is ... er than m."')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Nothing Is ... er than m."')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Nothing Is larger than m.") (Syntax: '"Nothing Is ... er than m."')
]]>.Value
......@@ -427,7 +427,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If (m > 20) ... End If')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If (m > 20) ... End If')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... ("Result1")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... ("Result1")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result1"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result1"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result1") (Syntax: '"Result1"')
IfFalse: IIfStatement (OperationKind.IfStatement) (Syntax: 'ElseIf (n > ... ("Result2")')
Condition: IParenthesizedExpression (OperationKind.ParenthesizedExpression, Type: System.Boolean) (Syntax: '(n > 10)')
......@@ -437,12 +437,12 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If (m > 20) ... End If')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'ElseIf (n > ... ("Result2")')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... ("Result2")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... ("Result2")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result2"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result2"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result2") (Syntax: '"Result2"')
IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'Else ... ("Result3")')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... ("Result3")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... ("Result3")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result3"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result3"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result3") (Syntax: '"Result3"')
]]>.Value
......@@ -471,7 +471,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If (m > 20) ... ("Result3")')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If (m > 20) ... ("Result3")')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'System.Cons ... ("Result1")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'System.Cons ... ("Result1")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result1"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result1"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result1") (Syntax: '"Result1"')
IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'Else If (n ... ("Result3")')
IIfStatement (OperationKind.IfStatement) (Syntax: 'If (n > 10) ... ("Result3")')
......@@ -482,12 +482,12 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If (m > 20) ... ("Result3")')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If (n > 10) ... ("Result3")')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'System.Cons ... ("Result2")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'System.Cons ... ("Result2")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result2"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result2"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result2") (Syntax: '"Result2"')
IfFalse: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'Else System ... ("Result3")')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'System.Cons ... ("Result3")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'System.Cons ... ("Result3")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result3"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result3"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result3") (Syntax: '"Result3"')
]]>.Value
......@@ -522,7 +522,7 @@ IIfStatement (OperationKind.IfStatement) (Syntax: 'If (m > 20) ... Else')
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If (m > 20) ... Else')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... ("Result1")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... ("Result1")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result1"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result1"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result1") (Syntax: '"Result1"')
IfFalse: IBlockStatement (0 statements) (OperationKind.BlockStatement) (Syntax: 'Else')
]]>.Value
......@@ -557,7 +557,7 @@ IIfStatement (OperationKind.IfStatement, IsInvalid) (Syntax: 'If () Then' ... En
IfTrue: IBlockStatement (1 statements) (OperationKind.BlockStatement) (Syntax: 'If () Then' ... End If')
IExpressionStatement (OperationKind.ExpressionStatement) (Syntax: 'Console.Wri ... ("Result1")')
IInvocationExpression (static Sub System.Console.WriteLine(value As System.String)) (OperationKind.InvocationExpression, Type: System.Void) (Syntax: 'Console.Wri ... ("Result1")')
Arguments(1): IArgument (Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result1"')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: value) (OperationKind.Argument) (Syntax: '"Result1"')
ILiteralExpression (OperationKind.LiteralExpression, Type: System.String, Constant: "Result1") (Syntax: '"Result1"')
]]>.Value
......
......@@ -51,7 +51,7 @@ End Class]]>.Value
Dim expectedOperationTree = <![CDATA[
IInvocationExpression ( Sub Program.F(x As System.Int32)) (OperationKind.InvocationExpression, Type: System.Void, IsInvalid) (Syntax: 'F(String.Empty)')
Instance Receiver: IInstanceReferenceExpression (InstanceReferenceKind.Implicit) (OperationKind.InstanceReferenceExpression, Type: Program) (Syntax: 'F')
Arguments(1): IArgument (Matching Parameter: x) (OperationKind.Argument) (Syntax: 'String.Empty')
Arguments(1): IArgument (ArgumentKind.Explicit, Matching Parameter: x) (OperationKind.Argument) (Syntax: 'String.Empty')
IConversionExpression (ConversionKind.Basic, Implicit) (OperationKind.ConversionExpression, Type: System.Int32) (Syntax: 'String.Empty')
IFieldReferenceExpression: System.String.Empty As System.String (Static) (OperationKind.FieldReferenceExpression, Type: System.String) (Syntax: 'String.Empty')
]]>.Value
......
......@@ -542,7 +542,7 @@ private void VisitArguments(IHasArgumentsExpression operation)
public override void VisitArgument(IArgument operation)
{
LogString($"{nameof(IArgument)} (");
LogString($"{nameof(ArgumentKind)}.{operation.ArgumentKind} ");
LogString($"{nameof(ArgumentKind)}.{operation.ArgumentKind}, ");
LogSymbol(operation.Parameter, header: "Matching Parameter", logDisplayString: false);
LogString(")");
LogCommonPropertiesAndNewLine(operation);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册