本文整理汇总了C#中IMemberContext.GetSignatureForError方法的典型用法代码示例。如果您正苦于以下问题:C# IMemberContext.GetSignatureForError方法的具体用法?C# IMemberContext.GetSignatureForError怎么用?C# IMemberContext.GetSignatureForError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMemberContext
的用法示例。
在下文中一共展示了IMemberContext.GetSignatureForError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ErrorInvalidVariance
public void ErrorInvalidVariance (IMemberContext mc, Variance expected)
{
Report.SymbolRelatedToPreviousError (mc.CurrentMemberDefinition);
string input_variance = Variance == Variance.Contravariant ? "contravariant" : "covariant";
string gtype_variance;
switch (expected) {
case Variance.Contravariant: gtype_variance = "contravariantly"; break;
case Variance.Covariant: gtype_variance = "covariantly"; break;
default: gtype_variance = "invariantly"; break;
}
Delegate d = mc as Delegate;
string parameters = d != null ? d.Parameters.GetSignatureForError () : "";
Report.Error (1961, Location,
"The {2} type parameter `{0}' must be {3} valid on `{1}{4}'",
GetSignatureForError (), mc.GetSignatureForError (), input_variance, gtype_variance, parameters);
}
示例2: Resolve
//
// Resolve the constraints types with only possible early checks, return
// value `false' is reserved for recursive failure
//
public bool Resolve (IMemberContext context, TypeParameter tp)
{
if (resolved)
return true;
if (resolving)
return false;
resolving = true;
var spec = tp.Type;
List<TypeParameterSpec> tparam_types = null;
bool iface_found = false;
spec.BaseType = TypeManager.object_type;
for (int i = 0; i < constraints.Count; ++i) {
var constraint = constraints[i];
if (constraint is SpecialContraintExpr) {
spec.SpecialConstraint |= ((SpecialContraintExpr) constraint).Constraint;
if (spec.HasSpecialStruct)
spec.BaseType = TypeManager.value_type;
// Set to null as it does not have a type
constraints[i] = null;
continue;
}
var type_expr = constraints[i] = constraint.ResolveAsTypeTerminal (context, false);
if (type_expr == null)
continue;
var gexpr = type_expr as GenericTypeExpr;
if (gexpr != null && gexpr.HasDynamicArguments ()) {
context.Compiler.Report.Error (1968, constraint.Location,
"A constraint cannot be the dynamic type `{0}'", gexpr.GetSignatureForError ());
continue;
}
var type = type_expr.Type;
if (!context.CurrentMemberDefinition.IsAccessibleAs (type)) {
context.Compiler.Report.SymbolRelatedToPreviousError (type);
context.Compiler.Report.Error (703, loc,
"Inconsistent accessibility: constraint type `{0}' is less accessible than `{1}'",
type.GetSignatureForError (), context.GetSignatureForError ());
}
if (type.IsInterface) {
if (!spec.AddInterface (type)) {
context.Compiler.Report.Error (405, constraint.Location,
"Duplicate constraint `{0}' for type parameter `{1}'", type.GetSignatureForError (), tparam.Value);
}
iface_found = true;
continue;
}
var constraint_tp = type as TypeParameterSpec;
if (constraint_tp != null) {
if (tparam_types == null) {
tparam_types = new List<TypeParameterSpec> (2);
} else if (tparam_types.Contains (constraint_tp)) {
context.Compiler.Report.Error (405, constraint.Location,
"Duplicate constraint `{0}' for type parameter `{1}'", type.GetSignatureForError (), tparam.Value);
continue;
}
//
// Checks whether each generic method parameter constraint type
// is valid with respect to T
//
if (tp.IsMethodTypeParameter) {
TypeManager.CheckTypeVariance (type, Variance.Contravariant, context);
}
var tp_def = constraint_tp.MemberDefinition as TypeParameter;
if (tp_def != null && !tp_def.ResolveConstraints (context)) {
context.Compiler.Report.Error (454, constraint.Location,
"Circular constraint dependency involving `{0}' and `{1}'",
constraint_tp.GetSignatureForError (), tp.GetSignatureForError ());
continue;
}
//
// Checks whether there are no conflicts between type parameter constraints
//
// class Foo<T, U>
// where T : A
// where U : B, T
//
// A and B are not convertible and only 1 class constraint is allowed
//
if (constraint_tp.HasTypeConstraint) {
if (spec.HasTypeConstraint || spec.HasSpecialStruct) {
//.........这里部分代码省略.........