-
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
Get CallerArgumentExpression ready #54839
Get CallerArgumentExpression ready #54839
Conversation
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 Thanks (iteration 3)
Ping @333fred for review. |
We went through the compiler test plan review today. Overall, it looks good, but we'd like to see some tests around the "Compiler generated calls with user-written code" bullet before we merge to main. @Youssef1313 do you think you can add them to this PR? Test plan is here: #52745 |
@@ -108,7 +108,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax | |||
Return LanguageVersion.VisualBasic16_9 | |||
|
|||
Case Feature.CallerArgumentExpression |
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 this actually checked anywhere?
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.
@333fred If you mean tests, there is TestGoodCallerArgumentExpressionAttribute_Version16_9
that tests old version. If you mean in product code, it's checked here:
roslyn/src/Compilers/VisualBasic/Portable/Binding/Binder_Invocation.vb
Lines 3180 to 3183 in db43364
InternalSyntax.Parser.CheckFeatureAvailability(diagnostics, | |
argumentSyntax.Location, | |
DirectCast(argumentSyntax.SyntaxTree.Options, VisualBasicParseOptions).LanguageVersion, | |
InternalSyntax.Feature.CallerArgumentExpression) |
Yes I'll add them in this PR. |
src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests_CallerInfoAttributes.cs
Show resolved
Hide resolved
@@ -266,6 +267,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols | |||
|
|||
Friend Overrides Iterator Function GetCustomAttributesToEmit(compilationState As ModuleCompilationState) As IEnumerable(Of VisualBasicAttributeData) | |||
Dim attributes = MyBase.GetCustomAttributesToEmit(compilationState) | |||
|
|||
If Not Location.SourceTree.Options.Features.ContainsKey(InternalSyntax.GetFeatureFlag(InternalSyntax.Feature.CallerArgumentExpression)) Then |
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.
@333fred It looks like SourceTree
can be null. I'm not sure what to do for the null case, allow the feature to work or emit the attributes as is?
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.
We should emit the attribute as is in those cases. I imagine most those will be synthesized parameters, and thus not likely to have this attribute in the first place?
Log(123) | ||
~~~ | ||
</expected>) | ||
Dim compilation = CreateCompilation(source, targetFramework:=TargetFramework.NetCoreApp, references:={Net451.MicrosoftVisualBasic}, options:=TestOptions.ReleaseExe, parseOptions:=TestOptions.Regular16_9.WithFeature("CallerArgumentExpression")) |
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.
Rather than modifying this test to succeed, let's leave the feature flag off and verify the behavior when it's not present.
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.
Only a couple of small things left. We're really close!
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 (commit 10). Just one thing to remove the unshipped api txt file. @jcouv, please take another look.
@@ -233,12 +233,12 @@ End Module | |||
</file> | |||
</compilation> | |||
|
|||
Dim compilation = CreateCompilationWithCustomILSource(source, il, options:=TestOptions.ReleaseExe, includeVbRuntime:=True, parseOptions:=TestOptions.RegularLatest) | |||
Dim compilation = CreateCompilationWithCustomILSource(source, il, options:=TestOptions.ReleaseExe, includeVbRuntime:=True, parseOptions:=TestOptions.RegularLatest.WithFeature("CallerArgumentExpression")) |
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.
nit: it may have been good to have a test with feature flag and an earlier version, to illustrate the the feature works on old language versions
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 Thanks (iteration 10)
@333fred How do you want to track the removal of feature flag? We can either use the test plan (keep it open for now) or open a separate issue. |
I'd say let's use the test plan. Edit: I've updated the test plan with a bullet. |
Correctness leg fails with:
|
Merged/squashed. Thanks @Youssef1313 |
Proposal: dotnet/csharplang#287
Test plan: #52745
@333fred @jcouv for review.