本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.ParameterSymbol类的典型用法代码示例。如果您正苦于以下问题:C# ParameterSymbol类的具体用法?C# ParameterSymbol怎么用?C# ParameterSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParameterSymbol类属于Microsoft.CodeAnalysis.CSharp.Symbols命名空间,在下文中一共展示了ParameterSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubstitutedParameterSymbol
private SubstitutedParameterSymbol(Symbol containingSymbol, TypeMap map, ParameterSymbol originalParameter) :
base(originalParameter)
{
Debug.Assert(originalParameter.IsDefinition);
_containingSymbol = containingSymbol;
_mapOrType = map;
}
示例2: DisplayClassInstanceFromParameter
internal DisplayClassInstanceFromParameter(ParameterSymbol parameter)
{
Debug.Assert((object)parameter != null);
Debug.Assert(parameter.Name.EndsWith("this", StringComparison.Ordinal) ||
GeneratedNames.GetKind(parameter.Name) == GeneratedNameKind.TransparentIdentifier);
this.Parameter = parameter;
}
示例3: Rewrite
internal static BoundNode Rewrite(
ParameterSymbol targetMethodThisParameter,
Conversions conversions,
ImmutableDictionary<string, DisplayClassVariable> displayClassVariables,
BoundNode node,
DiagnosticBag diagnostics)
{
var rewriter = new CapturedVariableRewriter(targetMethodThisParameter, conversions, displayClassVariables, diagnostics);
return rewriter.Visit(node);
}
示例4: CapturedVariableRewriter
private CapturedVariableRewriter(
ParameterSymbol targetMethodThisParameter,
Conversions conversions,
ImmutableDictionary<string, DisplayClassVariable> displayClassVariables,
DiagnosticBag diagnostics)
{
_targetMethodThisParameter = targetMethodThisParameter;
_conversions = conversions;
_displayClassVariables = displayClassVariables;
_diagnostics = diagnostics;
}
示例5: TryGetThisParameter
internal override bool TryGetThisParameter(out ParameterSymbol thisParameter)
{
Debug.Assert(!IsStatic);
if ((object)_lazyThisParameter == null)
{
Interlocked.CompareExchange(ref _lazyThisParameter, new ThisParameterSymbol(this), null);
}
thisParameter = _lazyThisParameter;
return true;
}
示例6: TryGetThisParameter
internal override bool TryGetThisParameter(out ParameterSymbol thisParameter)
{
if (IsStatic)
{
thisParameter = null;
return true;
}
if ((object)lazyThisParameter == null)
{
Interlocked.CompareExchange(ref lazyThisParameter, new ThisParameterSymbol(this), null);
}
thisParameter = lazyThisParameter;
return true;
}
示例7: AnonymousTypeConstructorSymbol
internal AnonymousTypeConstructorSymbol(NamedTypeSymbol container, ImmutableArray<AnonymousTypePropertySymbol> properties)
: base(container, WellKnownMemberNames.InstanceConstructorName)
{
// Create constructor parameters
int fieldsCount = properties.Length;
if (fieldsCount > 0)
{
ParameterSymbol[] paramsArr = new ParameterSymbol[fieldsCount];
for (int index = 0; index < fieldsCount; index++)
{
PropertySymbol property = properties[index];
paramsArr[index] = new SynthesizedParameterSymbol(this, property.Type, index, RefKind.None, property.Name);
}
_parameters = paramsArr.AsImmutableOrNull();
}
else
{
_parameters = ImmutableArray<ParameterSymbol>.Empty;
}
}
示例8: VerifyParamArrayAttribute
internal static void VerifyParamArrayAttribute(ParameterSymbol parameter, SourceModuleSymbol module, bool expected = true, OutputKind outputKind = OutputKind.ConsoleApplication)
{
Assert.Equal(expected, parameter.IsParams);
var emitModule = new PEAssemblyBuilder(module.ContainingSourceAssembly, null, outputKind, GetDefaultModulePropertiesForSerialization(), SpecializedCollections.EmptyEnumerable<ResourceDescription>());
var paramArrayAttributeCtor = (MethodSymbol)emitModule.Compilation.GetWellKnownTypeMember(WellKnownMember.System_ParamArrayAttribute__ctor);
bool found = false;
var context = new EmitContext(emitModule, null, new DiagnosticBag());
foreach (Microsoft.Cci.ICustomAttribute attr in parameter.GetSynthesizedAttributes())
{
if (paramArrayAttributeCtor == (MethodSymbol)attr.Constructor(context))
{
Assert.False(found, "Multiple ParamArrayAttribute");
found = true;
}
}
Assert.Equal(expected, found);
context.Diagnostics.Verify();
}
示例9: RetargetParameters
private ImmutableArray<ParameterSymbol> RetargetParameters()
{
var list = this.underlyingMethod.Parameters;
int count = list.Length;
if (count == 0)
{
return ImmutableArray<ParameterSymbol>.Empty;
}
else
{
ParameterSymbol[] parameters = new ParameterSymbol[count];
for (int i = 0; i < count; i++)
{
parameters[i] = new RetargetingMethodParameterSymbol(this, list[i]);
}
return parameters.AsImmutableOrNull();
}
}
示例10: EnterParameter
protected override void EnterParameter(ParameterSymbol parameter)
{
// parameters are NOT intitially assigned here - if that is a problem, then
// the parameters must be captured.
GetOrCreateSlot(parameter);
}
示例11: CanBeOptional
private static bool CanBeOptional(ParameterSymbol parameter, bool isMethodGroupConversion)
{
// NOTE: Section 6.6 will be slightly updated:
//
// - The candidate methods considered are only those methods that are applicable in their
// normal form (§7.5.3.1), and do not omit any optional parameters. Thus, candidate methods
// are ignored if they are applicable only in their expanded form, or if one or more of their
// optional parameters do not have a corresponding parameter in the targeted delegate type.
//
// Therefore, no parameters are optional when performing method group conversion. Alternatively,
// we could eliminate methods based on the number of arguments, but then we wouldn't be able to
// fall back on them if no other candidates were available.
var refKind = parameter.RefKind;
return !isMethodGroupConversion && parameter.IsOptional &&
(refKind == RefKind.None ||
(refKind == RefKind.Ref && parameter.ContainingSymbol.ContainingType.IsComImport));
}
示例12: CopyParameter
private static ParameterSymbol CopyParameter(ParameterSymbol parameter, MethodSymbol owner)
{
return new SynthesizedParameterSymbol(
owner,
parameter.Type,
parameter.Ordinal,
parameter.RefKind,
GeneratedNames.LambdaCopyParameterName(parameter)); // Make sure nothing binds to this.
}
示例13: ReportUnassignedOutParameter
protected override void ReportUnassignedOutParameter(ParameterSymbol parameter, CSharpSyntaxNode node, Location location)
{
if (!dataFlowsOut.Contains(parameter) && (node == null || node is ReturnStatementSyntax))
{
dataFlowsOut.Add(parameter);
}
base.ReportUnassignedOutParameter(parameter, node, location);
}
示例14: ParameterTypeInformation
public ParameterTypeInformation(ParameterSymbol underlyingParameter)
{
Debug.Assert((object)underlyingParameter != null);
this.UnderlyingParameter = underlyingParameter;
}
示例15: GetParamArrayArgument
private static TypedConstant GetParamArrayArgument(ParameterSymbol parameter, ImmutableArray<TypedConstant> constructorArgsArray, int argumentsCount, int argsConsumedCount, Conversions conversions)
{
Debug.Assert(argsConsumedCount <= argumentsCount);
int paramArrayArgCount = argumentsCount - argsConsumedCount;
if (paramArrayArgCount == 0)
{
return new TypedConstant(parameter.Type, ImmutableArray<TypedConstant>.Empty);
}
// If there's exactly one argument and it's an array of an appropriate type, then just return it.
if (paramArrayArgCount == 1 && constructorArgsArray[argsConsumedCount].Kind == TypedConstantKind.Array)
{
TypeSymbol argumentType = (TypeSymbol)constructorArgsArray[argsConsumedCount].Type;
// Easy out (i.e. don't both classifying conversion).
if (argumentType == parameter.Type)
{
return constructorArgsArray[argsConsumedCount];
}
HashSet<DiagnosticInfo> useSiteDiagnostics = null; // ignoring, since already bound argument and parameter
Conversion conversion = conversions.ClassifyConversion(argumentType, parameter.Type, ref useSiteDiagnostics, builtinOnly: true);
// NOTE: Won't always succeed, even though we've performed overload resolution.
// For example, passing int[] to params object[] actually treats the int[] as an element of the object[].
if (conversion.IsValid && conversion.Kind == ConversionKind.ImplicitReference)
{
return constructorArgsArray[argsConsumedCount];
}
}
Debug.Assert(!constructorArgsArray.IsDefault);
Debug.Assert(argsConsumedCount <= constructorArgsArray.Length);
var values = new TypedConstant[paramArrayArgCount];
for (int i = 0; i < paramArrayArgCount; i++)
{
values[i] = constructorArgsArray[argsConsumedCount++];
}
return new TypedConstant(parameter.Type, values.AsImmutableOrNull());
}