本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.GetAllTypeArguments方法的典型用法代码示例。如果您正苦于以下问题:C# NamedTypeSymbol.GetAllTypeArguments方法的具体用法?C# NamedTypeSymbol.GetAllTypeArguments怎么用?C# NamedTypeSymbol.GetAllTypeArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol
的用法示例。
在下文中一共展示了NamedTypeSymbol.GetAllTypeArguments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpperBoundTypeArgumentInference
private void UpperBoundTypeArgumentInference(NamedTypeSymbol source, NamedTypeSymbol target, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
// SPEC: The choice of inference for the i-th type argument is made
// SPEC: based on the declaration of the i-th type parameter of C, as
// SPEC: follows:
// SPEC: * if Ui is known to be of reference type and the i-th type parameter
// SPEC: was declared as covariant then an upper-bound inference is made.
// SPEC: * if Ui is known to be of reference type and the i-th type parameter
// SPEC: was declared as contravariant then a lower-bound inference is made.
// SPEC: * otherwise, an exact inference is made.
Debug.Assert((object)source != null);
Debug.Assert((object)target != null);
Debug.Assert(source.OriginalDefinition == target.OriginalDefinition);
var typeParameters = ArrayBuilder<TypeParameterSymbol>.GetInstance();
var sourceTypeArguments = ArrayBuilder<TypeSymbol>.GetInstance();
var targetTypeArguments = ArrayBuilder<TypeSymbol>.GetInstance();
source.OriginalDefinition.GetAllTypeParameters(typeParameters);
source.GetAllTypeArguments(sourceTypeArguments, ref useSiteDiagnostics);
target.GetAllTypeArguments(targetTypeArguments, ref useSiteDiagnostics);
Debug.Assert(typeParameters.Count == sourceTypeArguments.Count);
Debug.Assert(typeParameters.Count == targetTypeArguments.Count);
for (int arg = 0; arg < sourceTypeArguments.Count; ++arg)
{
var typeParameter = typeParameters[arg];
var sourceTypeArgument = sourceTypeArguments[arg];
var targetTypeArgument = targetTypeArguments[arg];
if (sourceTypeArgument.IsReferenceType && typeParameter.Variance == VarianceKind.Out)
{
UpperBoundInference(sourceTypeArgument, targetTypeArgument, ref useSiteDiagnostics);
}
else if (sourceTypeArgument.IsReferenceType && typeParameter.Variance == VarianceKind.In)
{
LowerBoundInference(sourceTypeArgument, targetTypeArgument, ref useSiteDiagnostics);
}
else
{
ExactInference(sourceTypeArgument, targetTypeArgument, ref useSiteDiagnostics);
}
}
typeParameters.Free();
sourceTypeArguments.Free();
targetTypeArguments.Free();
}
示例2: ExactTypeArgumentInference
private void ExactTypeArgumentInference(NamedTypeSymbol source, NamedTypeSymbol target, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)target != null);
Debug.Assert(source.OriginalDefinition == target.OriginalDefinition);
var sourceTypeArguments = ArrayBuilder<TypeSymbol>.GetInstance();
var targetTypeArguments = ArrayBuilder<TypeSymbol>.GetInstance();
source.GetAllTypeArguments(sourceTypeArguments, ref useSiteDiagnostics);
target.GetAllTypeArguments(targetTypeArguments, ref useSiteDiagnostics);
Debug.Assert(sourceTypeArguments.Count == targetTypeArguments.Count);
for (int arg = 0; arg < sourceTypeArguments.Count; ++arg)
{
ExactInference(sourceTypeArguments[arg], targetTypeArguments[arg], ref useSiteDiagnostics);
}
sourceTypeArguments.Free();
targetTypeArguments.Free();
}