Skip to content
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

Remove CallerArgumentExpression feature flag #55841

Merged
merged 2 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3126,11 +3126,6 @@ ProduceBoundNode:

Dim isCallerArgumentExpression = callerArgumentExpressionParameterIndex > -1 OrElse (reducedExtensionReceiverOpt IsNot Nothing AndAlso callerArgumentExpressionParameterIndex > -2)

If isCallerArgumentExpression AndAlso Not SyntaxTree.Options.Features.ContainsKey(InternalSyntax.GetFeatureFlag(InternalSyntax.Feature.CallerArgumentExpression)) Then
' Silently require feature flag for this feature until Aleksey approves.
isCallerArgumentExpression = False
End If

If isCallerLineNumber OrElse isCallerMemberName OrElse isCallerFilePath OrElse isCallerArgumentExpression Then
Dim callerInfoValue As ConstantValue = Nothing

Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/VisualBasic/Portable/Parser/ParserFeature.vb
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
UnconstrainedTypeParameterInConditional
CommentsAfterLineContinuation
InitOnlySettersUsage
CallerArgumentExpression
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved
End Enum

Friend Module FeatureExtensions
<Extension>
Friend Function GetFeatureFlag(feature As Feature) As String
Select Case feature
Case Feature.CallerArgumentExpression
Return NameOf(Feature.CallerArgumentExpression)
Case Else
Return Nothing
End Select
Expand Down Expand Up @@ -181,8 +178,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
Return ERRID.FEATURE_CommentsAfterLineContinuation
Case Feature.InitOnlySettersUsage
Return ERRID.FEATURE_InitOnlySettersUsage
Case Feature.CallerArgumentExpression
Return ERRID.FEATURE_CallerArgumentExpression
Case Else
Throw ExceptionUtilities.UnexpectedValue(feature)
End Select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols

Friend Overrides ReadOnly Property CallerArgumentExpressionParameterIndex As Integer
Get
If Not _syntaxRef.SyntaxTree.Options.Features.ContainsKey(InternalSyntax.GetFeatureFlag(InternalSyntax.Feature.CallerArgumentExpression)) Then
' Silently require feature flag for this feature until Aleksey approves.
Return -1
End If

Dim attributeSource As SourceParameterSymbol = If(Me.BoundAttributesSource, Me)

Dim data = attributeSource.GetEarlyDecodedWellKnownAttributeData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
arguments.GetOrCreateData(Of ParameterEarlyWellKnownAttributeData).HasCallerFilePathAttribute = True
ElseIf VisualBasicAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.CallerMemberNameAttribute) Then
arguments.GetOrCreateData(Of ParameterEarlyWellKnownAttributeData).HasCallerMemberNameAttribute = True
ElseIf VisualBasicAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.CallerArgumentExpressionAttribute) AndAlso
Location.SourceTree.Options.Features.ContainsKey(InternalSyntax.GetFeatureFlag(InternalSyntax.Feature.CallerArgumentExpression)) Then
ElseIf VisualBasicAttributeData.IsTargetEarlyAttribute(arguments.AttributeType, arguments.AttributeSyntax, AttributeDescription.CallerArgumentExpressionAttribute) Then
Dim index = -1
Dim attribute = arguments.Binder.GetAttribute(arguments.AttributeSyntax, arguments.AttributeType, False)
If Not attribute.HasErrors Then
Expand All @@ -268,15 +267,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Friend Overrides Iterator Function GetCustomAttributesToEmit(compilationState As ModuleCompilationState) As IEnumerable(Of VisualBasicAttributeData)
Dim attributes = MyBase.GetCustomAttributesToEmit(compilationState)

If Location Is Nothing OrElse Not Location.IsInSource OrElse
Not Location.SourceTree.Options.Features.ContainsKey(InternalSyntax.GetFeatureFlag(InternalSyntax.Feature.CallerArgumentExpression)) Then
' Silently require feature flag for this feature until Aleksey approves.
For Each attribute In attributes
Yield attribute
Next
Return
End If

For Each attribute In attributes
If AttributeData.IsTargetEarlyAttribute(attributeType:=attribute.AttributeClass, attributeArgCount:=attribute.CommonConstructorArguments.Length, description:=AttributeDescription.CallerArgumentExpressionAttribute) Then
Dim callerArgumentExpressionParameterIndex = Me.CallerArgumentExpressionParameterIndex
Expand Down Expand Up @@ -368,8 +358,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
arguments.GetOrCreateData(Of CommonParameterWellKnownAttributeData)().HasOutAttribute = True
ElseIf attrData.IsTargetAttribute(Me, AttributeDescription.MarshalAsAttribute) Then
MarshalAsAttributeDecoder(Of CommonParameterWellKnownAttributeData, AttributeSyntax, VisualBasicAttributeData, AttributeLocation).Decode(arguments, AttributeTargets.Parameter, MessageProvider.Instance)
ElseIf attrData.IsTargetAttribute(Me, AttributeDescription.CallerArgumentExpressionAttribute) AndAlso
Location.SourceTree.Options.Features.ContainsKey(InternalSyntax.GetFeatureFlag(InternalSyntax.Feature.CallerArgumentExpression)) Then
ElseIf attrData.IsTargetAttribute(Me, AttributeDescription.CallerArgumentExpressionAttribute) Then
Dim index = GetEarlyDecodedWellKnownAttributeData()?.CallerArgumentExpressionParameterIndex
If index = Ordinal Then
DirectCast(arguments.Diagnostics, BindingDiagnosticBag).Add(ERRID.WRN_CallerArgumentExpressionAttributeSelfReferential, arguments.AttributeSyntaxOpt.Location, Me.Name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols

Friend Overrides ReadOnly Property CallerArgumentExpressionParameterIndex As Integer
Get
If Not Location.SourceTree.Options.Features.ContainsKey(InternalSyntax.GetFeatureFlag(InternalSyntax.Feature.CallerArgumentExpression)) Then
' Silently require feature flag for this feature until Aleksey approves.
Return -1
End If
Dim data = GetEarlyDecodedWellKnownAttributeData()
If data Is Nothing Then
Return -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ End Module
End Sub

<ConditionalFact(GetType(CoreClrOnly))>
Public Sub TestGoodCallerArgumentExpressionAttribute_OldVersionWithFeatureFlag()
Public Sub TestGoodCallerArgumentExpressionAttribute_OldVersion()
Dim source As String = "
Imports System
Imports System.Runtime.CompilerServices
Expand All @@ -51,7 +51,7 @@ Module Program
End Module
"

Dim compilation = CreateCompilation(source, targetFramework:=TargetFramework.NetCoreApp, references:={Net451.MicrosoftVisualBasic}, options:=TestOptions.ReleaseExe, parseOptions:=TestOptions.Regular16.WithFeature("CallerArgumentExpression"))
Dim compilation = CreateCompilation(source, targetFramework:=TargetFramework.NetCoreApp, references:={Net451.MicrosoftVisualBasic}, options:=TestOptions.ReleaseExe, parseOptions:=TestOptions.Regular16)
CompileAndVerify(compilation, expectedOutput:="123").VerifyDiagnostics()
End Sub

Expand Down Expand Up @@ -258,27 +258,6 @@ End Module
CompileAndVerify(compilation, expectedOutput:="0 + 1").VerifyDiagnostics()
End Sub

<ConditionalFact(GetType(CoreClrOnly))>
Public Sub TestGoodCallerArgumentExpressionAttribute_Version16_9_WithoutFeatureFlag()
Dim source As String = "
Imports System
Imports System.Runtime.CompilerServices
Module Program
Sub Main()
Log(123)
End Sub

Private Const p As String = NameOf(p)
Sub Log(p As Integer, <CallerArgumentExpression(p)> Optional arg As String = ""<default-arg>"")
Console.WriteLine(arg)
End Sub
End Module
"

Dim compilation = CreateCompilation(source, targetFramework:=TargetFramework.NetCoreApp, references:={Net451.MicrosoftVisualBasic}, options:=TestOptions.ReleaseExe, parseOptions:=TestOptions.Regular16_9)
CompileAndVerify(compilation, expectedOutput:="<default-arg>").VerifyDiagnostics()
End Sub

<ConditionalFact(GetType(CoreClrOnly))>
Public Sub TestGoodCallerArgumentExpressionAttribute_ExpressionHasTrivia()
Dim source = "
Expand Down