Skip to content

Commit

Permalink
VB support for CallerArgumentExpression (#54132)
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 authored Jun 29, 2021
1 parent 93b0c43 commit af4b1e1
Show file tree
Hide file tree
Showing 56 changed files with 2,300 additions and 140 deletions.
1 change: 0 additions & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,6 @@ BoundExpression bindDefaultArgument(SyntaxNode syntax, ParameterSymbol parameter
argumentIndex > -1 && argumentIndex < argumentsCount)
{
CheckFeatureAvailability(syntax, MessageID.IDS_FeatureCallerArgumentExpression, diagnostics);
// PROTOTYPE(caller-expr): Do we need to support VB?

var argument = argumentsBuilder[argumentIndex];
defaultValue = new BoundLiteral(syntax, ConstantValue.Create(argument.Syntax.ToString()), Compilation.GetSpecialType(SpecialType.System_String)) { WasCompilerGenerated = true };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ internal override int CallerArgumentExpressionParameterIndex
var parameters = ContainingSymbol.GetParameters();
for (int i = 0; i < parameters.Length; i++)
{
if (parameters[i].Name == parameterName)
if (parameters[i].Name.Equals(parameterName, StringComparison.Ordinal))
{
_lazyCallerArgumentExpressionParameterIndex = i;
return i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,14 @@ internal NativeIntegerParameterSymbol(NativeIntegerTypeSymbol containingType, Na

public override ImmutableArray<CustomModifier> RefCustomModifiers => _underlyingParameter.RefCustomModifiers;

internal override bool IsCallerLineNumber => _underlyingParameter.IsCallerLineNumber;

internal override bool IsCallerFilePath => _underlyingParameter.IsCallerFilePath;

internal override bool IsCallerMemberName => _underlyingParameter.IsCallerMemberName;

internal override int CallerArgumentExpressionParameterIndex => _underlyingParameter.CallerArgumentExpressionParameterIndex;

public override bool Equals(Symbol? other, TypeCompareKind comparison) => NativeIntegerTypeSymbol.EqualsHelper(this, other, comparison, symbol => symbol._underlyingParameter);

public override int GetHashCode() => _underlyingParameter.GetHashCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,30 @@ public override ImmutableArray<CustomModifier> RefCustomModifiers
}
}

internal override bool IsCallerLineNumber
{
// ReducedExtensionMethodParameterSymbol is only exposed to semantic model.
get { throw ExceptionUtilities.Unreachable; }
}

internal override bool IsCallerFilePath
{
// ReducedExtensionMethodParameterSymbol is only exposed to semantic model.
get { throw ExceptionUtilities.Unreachable; }
}

internal override bool IsCallerMemberName
{
// ReducedExtensionMethodParameterSymbol is only exposed to semantic model.
get { throw ExceptionUtilities.Unreachable; }
}

internal override int CallerArgumentExpressionParameterIndex
{
// ReducedExtensionMethodParameterSymbol is only exposed to semantic model.
get { throw ExceptionUtilities.Unreachable; }
}

public sealed override bool Equals(Symbol obj, TypeCompareKind compareKind)
{
if ((object)this == obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,26 @@ protected override RetargetingModuleSymbol RetargetingModule
{
get { return _retargetingMethod.RetargetingModule; }
}

internal override bool IsCallerLineNumber
{
get { return _underlyingParameter.IsCallerLineNumber; }
}

internal override bool IsCallerFilePath
{
get { return _underlyingParameter.IsCallerFilePath; }
}

internal override bool IsCallerMemberName
{
get { return _underlyingParameter.IsCallerMemberName; }
}

internal override int CallerArgumentExpressionParameterIndex
{
get { return _underlyingParameter.CallerArgumentExpressionParameterIndex; }
}
}

internal sealed class RetargetingPropertyParameterSymbol : RetargetingParameterSymbol
Expand All @@ -162,5 +182,25 @@ protected override RetargetingModuleSymbol RetargetingModule
{
get { return _retargetingProperty.RetargetingModule; }
}

internal override bool IsCallerLineNumber
{
get { return _underlyingParameter.IsCallerLineNumber; }
}

internal override bool IsCallerFilePath
{
get { return _underlyingParameter.IsCallerFilePath; }
}

internal override bool IsCallerMemberName
{
get { return _underlyingParameter.IsCallerMemberName; }
}

internal override int CallerArgumentExpressionParameterIndex
{
get { return _underlyingParameter.CallerArgumentExpressionParameterIndex; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

namespace Microsoft.CodeAnalysis.CSharp.Symbols
{

// PROTOTYPE(caller-expr): Make SourceClonedParameterSymbol abstract and introduce new specialized types (same as being done in VB).

/// <summary>
/// Represents a source parameter cloned from another <see cref="SourceParameterSymbol"/>, when they must share attribute data and default constant value.
/// For example, parameters on a property symbol are cloned to generate parameters on accessors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ internal override CSharpAttributeData EarlyDecodeWellKnownAttribute(ref EarlyDec
var parameters = ContainingSymbol.GetParameters();
for (int i = 0; i < parameters.Length; i++)
{
if (parameters[i].Name == parameterName)
if (parameters[i].Name.Equals(parameterName, StringComparison.Ordinal))
{
index = i;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@ public override ImmutableArray<CustomModifier> RefCustomModifiers
}
}

internal override bool IsCallerLineNumber
{
get { return _underlyingParameter.IsCallerLineNumber; }
}

internal override bool IsCallerFilePath
{
get { return _underlyingParameter.IsCallerFilePath; }
}

internal override bool IsCallerMemberName
{
get { return _underlyingParameter.IsCallerMemberName; }
}

internal override int CallerArgumentExpressionParameterIndex
{
get { return _underlyingParameter.CallerArgumentExpressionParameterIndex; }
}

public sealed override bool Equals(Symbol obj, TypeCompareKind compareKind)
{
if ((object)this == obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,6 @@ internal override bool IsIUnknownConstant
get { return _underlyingParameter.IsIUnknownConstant; }
}

internal override bool IsCallerLineNumber
{
get { return _underlyingParameter.IsCallerLineNumber; }
}

internal override bool IsCallerFilePath
{
get { return _underlyingParameter.IsCallerFilePath; }
}

internal override bool IsCallerMemberName
{
get { return _underlyingParameter.IsCallerMemberName; }
}

internal override int CallerArgumentExpressionParameterIndex
{
get { return _underlyingParameter.CallerArgumentExpressionParameterIndex; }
}

internal override FlowAnalysisAnnotations FlowAnalysisAnnotations
{
// https://github.com/dotnet/roslyn/issues/30073: Consider moving to leaf types
Expand Down
Loading

0 comments on commit af4b1e1

Please sign in to comment.