50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using System.Collections.Immutable;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
internal readonly struct InterpolatedStringHandlerData
|
|
{
|
|
public readonly TypeSymbol BuilderType;
|
|
|
|
public readonly BoundExpression Construction;
|
|
|
|
public readonly bool UsesBoolReturns;
|
|
|
|
public readonly ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> ArgumentPlaceholders;
|
|
|
|
public readonly ImmutableArray<ImmutableArray<(bool IsLiteral, bool HasAlignment, bool HasFormat)>> PositionInfo;
|
|
|
|
public readonly BoundInterpolatedStringHandlerPlaceholder ReceiverPlaceholder;
|
|
|
|
public bool HasTrailingHandlerValidityParameter
|
|
{
|
|
get
|
|
{
|
|
if (ArgumentPlaceholders.Length > 0)
|
|
{
|
|
ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> argumentPlaceholders = ArgumentPlaceholders;
|
|
return argumentPlaceholders[argumentPlaceholders.Length - 1].ArgumentIndex == -2;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool IsDefault => Construction == null;
|
|
|
|
public InterpolatedStringHandlerData(TypeSymbol builderType, BoundExpression construction, bool usesBoolReturns, ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> placeholders, ImmutableArray<ImmutableArray<(bool IsLiteral, bool HasAlignment, bool HasFormat)>> positionInfo, BoundInterpolatedStringHandlerPlaceholder receiverPlaceholder)
|
|
{
|
|
BuilderType = builderType;
|
|
Construction = construction;
|
|
UsesBoolReturns = usesBoolReturns;
|
|
ArgumentPlaceholders = placeholders;
|
|
PositionInfo = positionInfo;
|
|
ReceiverPlaceholder = receiverPlaceholder;
|
|
}
|
|
|
|
public BoundObjectCreationExpression GetValidConstructor()
|
|
{
|
|
return (BoundObjectCreationExpression)Construction;
|
|
}
|
|
}
|