本文整理汇总了C#中TypeSymbol.BaseTypeWithDefinitionUseSiteDiagnostics方法的典型用法代码示例。如果您正苦于以下问题:C# TypeSymbol.BaseTypeWithDefinitionUseSiteDiagnostics方法的具体用法?C# TypeSymbol.BaseTypeWithDefinitionUseSiteDiagnostics怎么用?C# TypeSymbol.BaseTypeWithDefinitionUseSiteDiagnostics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeSymbol
的用法示例。
在下文中一共展示了TypeSymbol.BaseTypeWithDefinitionUseSiteDiagnostics方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTypesParticipatingInUserDefinedConversion
public static void AddTypesParticipatingInUserDefinedConversion(ArrayBuilder<NamedTypeSymbol> result, TypeSymbol type, bool includeBaseTypes, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if ((object)type == null)
{
return;
}
// CONSIDER: These sets are usually small; if they are large then this is an O(n^2)
// CONSIDER: algorithm. We could use a hash table instead to build up the set.
Debug.Assert(!type.IsTypeParameter());
// optimization:
bool excludeExisting = result.Count > 0;
// The decimal type does not contribute its user-defined conversions to the mix; though its
// conversions are actually implemented via user-defined operators, we logically treat it as
// though those conversions were built-in.
if (type.IsClassType() || type.IsStructType() && type.SpecialType != SpecialType.System_Decimal)
{
var namedType = (NamedTypeSymbol)type;
if (!excludeExisting || !HasIdentityConversionToAny(namedType, result))
{
result.Add(namedType);
}
}
if (!includeBaseTypes)
{
return;
}
NamedTypeSymbol t = type.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
while ((object)t != null)
{
if (!excludeExisting || !HasIdentityConversionToAny(t, result))
{
result.Add(t);
}
t = t.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
}
}
示例2: AddTypesParticipatingInUserDefinedConversion
public static void AddTypesParticipatingInUserDefinedConversion(ArrayBuilder<NamedTypeSymbol> result, TypeSymbol type, bool includeBaseTypes, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if ((object)type == null)
{
return;
}
// CONSIDER: These sets are usually small; if they are large then this is an O(n^2)
// CONSIDER: algorithm. We could use a hash table instead to build up the set.
Debug.Assert(!type.IsTypeParameter());
// optimization:
bool excludeExisting = result.Count > 0;
if (type.IsClassType() || type.IsStructType())
{
var namedType = (NamedTypeSymbol)type;
if (!excludeExisting || !HasIdentityConversionToAny(namedType, result))
{
result.Add(namedType);
}
}
if (!includeBaseTypes)
{
return;
}
NamedTypeSymbol t = type.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
while ((object)t != null)
{
if (!excludeExisting || !HasIdentityConversionToAny(t, result))
{
result.Add(t);
}
t = t.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
}
}
示例3: GetUserDefinedOperators
private bool GetUserDefinedOperators(
BinaryOperatorKind kind,
TypeSymbol type0,
BoundExpression left,
BoundExpression right,
ArrayBuilder<BinaryOperatorAnalysisResult> results,
ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
// Spec 7.3.5 Candidate user-defined operators
// SPEC: Given a type T and an operation operator op(A), where op is an overloadable
// SPEC: operator and A is an argument list, the set of candidate user-defined operators
// SPEC: provided by T for operator op(A) is determined as follows:
// SPEC: Determine the type T0. If T is a nullable type, T0 is its underlying type,
// SPEC: otherwise T0 is equal to T.
// (The caller has already passed in the stripped type.)
// SPEC: For all operator op declarations in T0 and all lifted forms of such operators,
// SPEC: if at least one operator is applicable (7.5.3.1) with respect to the argument
// SPEC: list A, then the set of candidate operators consists of all such applicable
// SPEC: operators in T0. Otherwise, if T0 is object, the set of candidate operators is empty.
// SPEC: Otherwise, the set of candidate operators provided by T0 is the set of candidate
// SPEC: operators provided by the direct base class of T0, or the effective base class of
// SPEC: T0 if T0 is a type parameter.
string name = OperatorFacts.BinaryOperatorNameFromOperatorKind(kind);
var operators = ArrayBuilder<BinaryOperatorSignature>.GetInstance();
bool hadApplicableCandidates = false;
NamedTypeSymbol current = type0 as NamedTypeSymbol;
if ((object)current == null)
{
current = type0.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
}
if ((object)current == null && type0.IsTypeParameter())
{
current = ((TypeParameterSymbol)type0).EffectiveBaseClass(ref useSiteDiagnostics);
}
for (; (object)current != null; current = current.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics))
{
operators.Clear();
GetUserDefinedBinaryOperatorsFromType(current, kind, name, operators);
results.Clear();
if (CandidateOperators(operators, left, right, results, ref useSiteDiagnostics))
{
hadApplicableCandidates = true;
break;
}
}
operators.Free();
return hadApplicableCandidates;
}
示例4: UpperBoundClassInference
private bool UpperBoundClassInference(NamedTypeSymbol source, TypeSymbol target, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)target != null);
if (source.TypeKind != TypeKind.Class || target.TypeKind != TypeKind.Class)
{
return false;
}
// SPEC: * Otherwise, if U is a class type C<U1...Uk> and V is a class type which
// SPEC: inherits directly or indirectly from C<V1...Vk> then an exact
// SPEC: inference is made from each Ui to the corresponding Vi.
var targetBase = target.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
while ((object)targetBase != null)
{
if (targetBase.OriginalDefinition == source.OriginalDefinition)
{
ExactTypeArgumentInference(source, targetBase, ref useSiteDiagnostics);
return true;
}
targetBase = targetBase.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
}
return false;
}
示例5: LowerBoundClassInference
private bool LowerBoundClassInference(TypeSymbol source, NamedTypeSymbol target, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)target != null);
if (target.TypeKind != TypeKind.Class)
{
return false;
}
// Spec: 7.5.2.9 Lower-bound interfaces
// SPEC: * Otherwise, if V is a class type C<V1...Vk> and U is a class type which
// SPEC: inherits directly or indirectly from C<U1...Uk>
// SPEC: then an exact inference is made from each Ui to the corresponding Vi.
// SPEC: * Otherwise, if V is a class type C<V1...Vk> and U is a type parameter
// SPEC: with effective base class C<U1...Uk>
// SPEC: then an exact inference is made from each Ui to the corresponding Vi.
// SPEC: * Otherwise, if V is a class type C<V1...Vk> and U is a type parameter
// SPEC: with an effective base class which inherits directly or indirectly from
// SPEC: C<U1...Uk> then an exact inference is made
// SPEC: from each Ui to the corresponding Vi.
NamedTypeSymbol sourceBase = null;
if (source.TypeKind == TypeKind.Class)
{
sourceBase = source.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
}
else if (source.TypeKind == TypeKind.TypeParameter)
{
sourceBase = ((TypeParameterSymbol)source).EffectiveBaseClass(ref useSiteDiagnostics);
}
while ((object)sourceBase != null)
{
if (sourceBase.OriginalDefinition == target.OriginalDefinition)
{
ExactTypeArgumentInference(sourceBase, target, ref useSiteDiagnostics);
return true;
}
sourceBase = sourceBase.BaseTypeWithDefinitionUseSiteDiagnostics(ref useSiteDiagnostics);
}
return false;
}