-
Notifications
You must be signed in to change notification settings - Fork 4k
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
ported tests from https://github.com/dotnet/roslyn/pull/21263 #22296
Conversation
@dotnet/analyzer-ioperation can you take a look? |
} | ||
"; | ||
string expectedOperationTree = @" | ||
IArgument (ArgumentKind.Explicit, Matching Parameter: i) (OperationKind.Argument) (Syntax: 'ref i') |
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.
Just realized that we don't expose the RefKind of the argument on IArgument
node. Should we do so? Can you please file a tracking bug? #Resolved
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.
sure - #22297 #Resolved
Instance Receiver: IInstanceReferenceExpression (OperationKind.InstanceReferenceExpression, Type: P) (Syntax: 'this') | ||
Arguments(1): | ||
IArgument (ArgumentKind.ParamArray, Matching Parameter: array) (OperationKind.Argument) (Syntax: 'this[1]') | ||
IArrayCreationExpression (Element Type: System.Int32) (OperationKind.ArrayCreationExpression, Type: System.Int32[]) (Syntax: 'this[1]') |
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.
This is the synthesized one correct? It still looks like a bug that the associated syntax is this[1]
and not 1
. Can you file an issue to track this?
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.
1 seems as weird as this[1] for me :) not sure what is right node to put here though :)
opened -#22298
IObjectCreationExpression (Constructor: Sub Program..ctor(ParamArray a As System.Int32())) (OperationKind.ObjectCreationExpression, Type: Program) (Syntax: 'New Program(1)') | ||
Arguments(1): | ||
IArgument (ArgumentKind.ParamArray, Matching Parameter: a) (OperationKind.Argument) (Syntax: 'Program') | ||
IArrayCreationExpression (Element Type: System.Int32) (OperationKind.ArrayCreationExpression, Type: System.Int32()) (Syntax: 'Program') |
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.
Same here, associated syntax seems weird.
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.
yep. the pattern looks like assigning node above itself regardless what that is.
@dotnet/roslyn-compiler |
jenkins issue - CSC : error CS0016: Could not write to output file 'D:\j\workspace\windows_deter---bd1d49d3\Binaries\Obj\TestUtilities\Debug\Roslyn.Test.Utilities.xml' -- 'The process cannot access the file 'D:\j\workspace\windows_deter---bd1d49d3\Binaries\Obj\TestUtilities\Debug\Roslyn.Test.Utilities.xml' because it is being used by another process.' [D:\j\workspace\windows_deter---bd1d49d3\src\Test\Utilities\Portable\TestUtilities.csproj] |
retest windows_determinism_prtest please |
int i = 0; | ||
M2(/*<bind>*/ref i/*</bind>*/); | ||
} | ||
static void M2(ref int i) { } |
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.
Consider adding a similar test for "ref readonly" parameter.
int i = 0;
ref int refI = ref i;
M2(refI);
FYI @VSadov #Resolved
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.
sure. #Resolved
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.
@jcouv what feature option do I need to turn on to make ref readonly to work? #Resolved
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.
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.
Sorry, had made a mistake above. No "ref readonly" at callsite. #Resolved
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.
I added test but not sure what kind of info we are looking for from IArgument. the difference seems all in IParameter not on callsite.
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.
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.
@mavasani @jinujoseph are we going to support the "ref readonly" feature in IOperation v1?
} | ||
"; | ||
string expectedOperationTree = @" | ||
IArgument (ArgumentKind.Explicit, Matching Parameter: i) (OperationKind.Argument) (Syntax: 'ref i') |
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.
That's pretty useful. I was just wondering about this a couple of days ago, do we have public API to show how arguments and parameters were matched... #Resolved
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.
tagging @genlu who did argument work. #Resolved
{ | ||
static void M1() | ||
{ | ||
/*<bind>*/M2(0, 1);/*</bind>*/ |
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.
Maybe that is tested elsewhere: what happens if the "bind" tags are just around "0" or "1" in this scenario? #Resolved
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.
depends on whether it is literal expression or argument syntax node given. if it is literal expression, then it will return ILiteralExpression. if it is argument syntax, then it will return nothing since that node doesn't exist in IOperation tree. #Resolved
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.
this is what I meant in the description.
"for now, the test doesn't show interesting info, but once @jinujoseph finishes the work to show syntax kind/isImplicit/parent in the test, it will show info such as what got injected (param array) and argument got removed."
VerifyOperationTreeAndDiagnosticsForTest<ElementAccessExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics); | ||
} | ||
|
||
[Fact] |
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.
I don't know how attributes work with IOperation, but something like [MyAttribute(0, 1)]
would be useful to test.
Attributes (in C#) can also initialize properties: [MyAttribute(arg1: 1, arg2: 2, Property1=1, Property2=2)]
.
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.
added. looks like we don't support bound attribute fully yet.
var expectedDiagnostics = DiagnosticDescription.None; | ||
|
||
VerifyOperationTreeAndDiagnosticsForTest<ElementAccessExpressionSyntax>(source, expectedOperationTree, expectedDiagnostics); | ||
} |
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.
Another scenario that may be worth testing is non-trailing named arguments: M(a: 1, 2)
(C# 7.2). This should behave the same as if the argument name wasn't there.
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.
added
@@ -1074,5 +1074,269 @@ End Class]]>.Value | |||
|
|||
VerifyClone(model) | |||
End Sub | |||
|
|||
<Fact> |
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.
If I remember correctly, VB not only has named, un-named and omitted arguments, it also has "range" arguments. I'm not sure the syntax.
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.
added. but the range argument is added implicit operation so it won't return by GetOperation(range argument)
public void DirectlyBindArgument_Attribute() | ||
{ | ||
string source = @" | ||
[assembly: /*<bind>*/System.CLSCompliant(isCompliant: true)/*</bind>*/] |
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.
Is there a tracking issue for attributes?
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.
tracked by this - #18198
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.
LGTM
do I need one more sign off for test only change from compiler team? |
No, test only changes 1 sign off needed. |
@dotnet/roslyn-infrastructure test failed - Roslyn.VisualStudio.IntegrationTests.VisualBasic.BasicLineCommit.CommitOnSave https://ci.dot.net/job/dotnet_roslyn/job/master/job/windows_release_vs-integration_prtest/7913/ |
retest windows_release_vs-integration_prtest please |
* dotnet/master: (351 commits) Avoid scheduling an unnecessary dispose task for EmptyAsyncToken Support for ref-readonly locals (dotnet#22269) ported tests from dotnet#21263 (dotnet#22296) NormalizeWhitespace should not add a space in nullable type (dotnet#22234) Fix the work item number associated with the unit test Add unit test Terminate a sentence Add instructions for upgrading PowerShell Unsafe local should require /unsafe flag on compilation (dotnet#22268) CR feedback Not poisoning restricted types known to be stack only. Typo Error messsage should mention C# 7.0 not C# 7 (dotnet#22255) Package descriptions for CSharp and VB should include summary blurb (dotnet#22166) Fix a trivial issue in how IsLifted is calculated for C# compound assignment operator Do not zero out "With" statement target expression locals referenced within a lambda. (dotnet#22223) Fix unit test failure from merge Mark "private protected", "ref readonly" and other C# 7.2 features as merged (dotnet#22209) Add unit tests for IAwaitExpression and make the API public again more test fixes due to merge conflicts ...
* dotnet/master: (309 commits) Avoid scheduling an unnecessary dispose task for EmptyAsyncToken Support for ref-readonly locals (dotnet#22269) ported tests from dotnet#21263 (dotnet#22296) NormalizeWhitespace should not add a space in nullable type (dotnet#22234) Fix the work item number associated with the unit test Add unit test Terminate a sentence Add instructions for upgrading PowerShell Unsafe local should require /unsafe flag on compilation (dotnet#22268) CR feedback Not poisoning restricted types known to be stack only. Typo Error messsage should mention C# 7.0 not C# 7 (dotnet#22255) Package descriptions for CSharp and VB should include summary blurb (dotnet#22166) Fix a trivial issue in how IsLifted is calculated for C# compound assignment operator Do not zero out "With" statement target expression locals referenced within a lambda. (dotnet#22223) Fix unit test failure from merge Mark "private protected", "ref readonly" and other C# 7.2 features as merged (dotnet#22209) Add unit tests for IAwaitExpression and make the API public again more test fixes due to merge conflicts ...
main issue the PR is trying to fix (#18405) is addressed by this (#21857).
this mainly port over tests added by this pr (#21263) with some changes.
in some cases such as params array, argument node get removed while converted to IOperation since compiler generated array replaces the argument.
for those, I just made test to dump including statement. for now, the test doesn't show interesting info, but once @jinujoseph finishes the work to show syntax kind/isImplicit/parent in the test, it will show info such as what got injected (param array) and argument got removed.